Drawing text is horribly slow, there are lots of instructions -> we only want to draw the instruction labels on the screen.
To do this, rgat uses colour picking - regularly (a few times a second) drawing a sphere to the screen with 32 columns with a green gradient and 16 rows with a red gradient. It looks like this:
Before it's cleared, we check the green value of the pixel either side of the screen (and the red on top and bottom, but those values are not used yet).
This tells us the columns we need to draw text in.
Then we iterate through every node on the graph to checking if it is within those columns.
The problem with this is that my maths is horrendous. The formula to convert a node coordinate to a column looks like this [graphicsMaths.cpp]:
The constant was found by looking at a few example row/node mappings and multiplying them.
eg: coord 8a is between col 0 and 1 at h_edge_sep ~1.39.
-> 1.39*8 = 11.12
(The constant that has worked best so far is 11.16).
This generally works but it gets very dubious at high graph widths and breaks entirely when the graph starts wrapping a long way around the sphere.
Drawing text is horribly slow, there are lots of instructions -> we only want to draw the instruction labels on the screen.
To do this, rgat uses colour picking - regularly (a few times a second) drawing a sphere to the screen with 32 columns with a green gradient and 16 rows with a red gradient. It looks like this:
Before it's cleared, we check the green value of the pixel either side of the screen (and the red on top and bottom, but those values are not used yet).
This tells us the columns we need to draw text in.
Then we iterate through every node on the graph to checking if it is within those columns.
The problem with this is that my maths is horrendous. The formula to convert a node coordinate to a column looks like this [graphicsMaths.cpp]:
node column = floor(<horizontal coordinate> / (COLOUR_PICKING_MYSTERY_CONSTANTA / <horizontal edge separation>)) % 32;
The constant was found by looking at a few example row/node mappings and multiplying them. eg: coord 8a is between col 0 and 1 at h_edge_sep ~1.39. -> 1.39*8 = 11.12
(The constant that has worked best so far is 11.16).
This generally works but it gets very dubious at high graph widths and breaks entirely when the graph starts wrapping a long way around the sphere.