I am using _MAPTRIANGLE(3D) a lot at the moment. Unseen (John) would say that I should be coding with OPENGL but that's another matter.
When I'm placing a 3D object (eg the surface of a sphere), I have lots of triangles to map into the _MAPTRIANGLE(3D) space, and I use coding such as below. In this particular case there are geometry manipulations to carry out and we can ignore all the lines from line 7 to line 44 and just note that the 12 variables x13! to z43! are used in the _MAPTRIANGLE statements.
x13! to z43! are used (and over-written each time) 64 times in the _MAPTRIANGLE statements before the next _DISPLAY statement puts the object (128 triangles) on the screen.
It all works exceeding well. But my question is how does the hardware know to keep the 64 lots of _MAPTRIANGLE positions when the same variable names are used? It is good that the hardware knows how to do it so that I don't have to use 64 lots of differently-named variables.
When I'm placing a 3D object (eg the surface of a sphere), I have lots of triangles to map into the _MAPTRIANGLE(3D) space, and I use coding such as below. In this particular case there are geometry manipulations to carry out and we can ignore all the lines from line 7 to line 44 and just note that the 12 variables x13! to z43! are used in the _MAPTRIANGLE statements.
x13! to z43! are used (and over-written each time) 64 times in the _MAPTRIANGLE statements before the next _DISPLAY statement puts the object (128 triangles) on the screen.
It all works exceeding well. But my question is how does the hardware know to keep the 64 lots of _MAPTRIANGLE positions when the same variable names are used? It is good that the hardware knows how to do it so that I don't have to use 64 lots of differently-named variables.
Code: (Select All)
WHILE Displaying
_LIMIT 120
FOR K%% = 1 TO 64
'Object Body
z10! = MapToClinder!(K%% - 1, 0)
z20! = MapToClinder!(K%%, 0)
z30! = MapToClinder!(K%%, 0)
z40! = MapToClinder!(K%% - 1, 0)
x10! = MapToClinder!(K%% - 1, 1)
x20! = MapToClinder!(K%%, 1)
x30! = MapToClinder!(K%%, 1)
x40! = MapToClinder!(K%% - 1, 1)
y10! = HalfLength%%
y20! = HalfLength%%
y30! = -HalfLength%%
y40! = -HalfLength%%
'Rotate about y-axis
z1! = z10! * COS(Gamma!) + x10! * SIN(Gamma!)
x1! = -z10! * SIN(Gamma!) + x10! * COS(Gamma!)
z2! = z20! * COS(Gamma!) + x20! * SIN(Gamma!)
x2! = -z20! * SIN(Gamma!) + x20! * COS(Gamma!)
z3! = z30! * COS(Gamma!) + x30! * SIN(Gamma!)
x3! = -z30! * SIN(Gamma!) + x30! * COS(Gamma!)
z4! = z40! * COS(Gamma!) + x40! * SIN(Gamma!)
x4! = -z40! * SIN(Gamma!) + x40! * COS(Gamma!)
y1! = y10!
y2! = y20!
y3! = y30!
y4! = y40!
'Then rotate by Theta about the x- axis
z12! = z1! * COS(Phi!) + y1! * SIN(Phi!)
y12! = -z1! * SIN(Phi!) + y1! * COS(Phi!)
z22! = z2! * COS(Phi!) + y2! * SIN(Phi!)
y22! = -z2! * SIN(Phi!) + y2! * COS(Phi!)
z32! = z3! * COS(Phi!) + y3! * SIN(Phi!)
y32! = -z3! * SIN(Phi!) + y3! * COS(Phi!)
z42! = z4! * COS(Phi!) + y4! * SIN(Phi!)
y42! = -z4! * SIN(Phi!) + y4! * COS(Phi!)
x12! = x1!
x22! = x2!
x32! = x3!
x42! = x4!
'Then add Y! & Y!
x13! = x12! + 0
x23! = x22! + 0
x33! = x32! + 0
x43! = x42! + 0
y13! = y12! + 0.9 * Y! - 200
y23! = y22! + 0.9 * Y! - 200
y33! = y32! + 0.9 * Y! - 200
y43! = y42! + 0.9 * Y! - 200
z13! = z12! + 7.3 * Z! - 1500
z23! = z22! + 7.3 * Z! - 1500
z33! = z32! + 7.3 * Z! - 1500
z43! = z42! + 7.3 * Z! - 1500
_MAPTRIANGLE (MapFromCylinder%(NoArcs%% - K%% + 1), ApolloJ%)-(MapFromCylinder%(NoArcs%% - K%%), ApolloJ%)-(MapFromCylinder%(NoArcs%% - K%%), 0), Apollo11& TO(x13!, y13!, z13! - ZOffset%)-(x23!, y23!, z23! - ZOffset%)-(x33!, y33!, z33! - ZOffset%)
_MAPTRIANGLE (MapFromCylinder%(NoArcs%% - K%%), 0)-(MapFromCylinder%(NoArcs%% - K%% + 1), 0)-(MapFromCylinder%(NoArcs%% - K%% + 1), ApolloJ%), Apollo11& TO(x33!, y33!, z33! - ZOffset%)-(x43!, y43!, z43! - ZOffset%)-(x13!, y13!, z13! - ZOffset%)
NEXT K%%
_DISPLAY
WEND

