Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Question About _MAPTRIANGLE
#1
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.
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
Reply
#2
Simply put, _MapTriangle works this way because it’s based on OpenGL. In OpenGL, after setting up the scene, materials, lighting, and perspective, you load individual vertices into memory using _GlVertex3D, which takes X, Y, and Z coordinates. Once the vertices are defined in the correct order, you apply the texture, then call _GlFlush (similar to _Display), which renders the entire model.
So before rendering, the memory is filled with all the vertex data, and only then the model is drawn. If you want to see individual triangles, you can call _Display right after _MapTriangle — though that may cause some glitches.


Reply
#3
(11-02-2025, 10:54 AM)Petr Wrote: Simply put, _MapTriangle works this way because it’s based on OpenGL. In OpenGL, after setting up the scene, materials, lighting, and perspective, you load individual vertices into memory using _GlVertex3D, which takes X, Y, and Z coordinates. Once the vertices are defined in the correct order, you apply the texture, then call _GlFlush (similar to _Display), which renders the entire model.
So before rendering, the memory is filled with all the vertex data, and only then the model is drawn. If you want to see individual triangles, you can call _Display right after _MapTriangle — though that may cause some glitches.
Petr, thanks.  I rather assumed that the vertex data must be handled in such a way.  So thanks for the clarity.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  _MAPTRIANGLE EXAMPLES NakedApe 22 1,169 01-25-2026, 05:43 PM
Last Post: ahenry3068
  _Putimage Question. Pete 11 672 01-04-2026, 09:33 PM
Last Post: Pete
  Nice simple, I hope, question Mad Axeman 4 335 12-20-2025, 09:28 PM
Last Post: SMcNeill
  NewBie Question niteflyer 2 329 11-06-2025, 07:11 PM
Last Post: Petr
  '$include: 'file.tmr' Timing Question pmackay 2 428 10-16-2025, 12:20 PM
Last Post: a740g

Forum Jump:


Users browsing this thread: 1 Guest(s)