Simple 3D morphing with _MAPTRIANGLE
#1
I went on a complete tangent from what I was intending to do this evening when I stumbled upon _MAPTRIANGLE!

First this project creates the vertices of a cube - but it does this based on a hard-coded TESSELATION constant. If this is set to one then each face of the cube has four vertices, if it's set to two then each face has nine vertices, 16 vertices for a value of 4, etc.

The reason for allowing the tessellation is that the project continually morphs between a cube and a sphere (while rotating on three axes). The higher the tessellation value, the better the quality of the sphere but also the greater the number of vertices, calculations, triangles to render, etc. I wanted the code to be clear and well commented so it isn't optimised at all (which is why I've set the tessellation value quite low).

The ZIP file containing the project and its assets is attached. As always, you can also find the code over at my GitHub.

   


.zip   morph.zip (Size: 419.28 KB / Downloads: 40)

On a side note, does anyone know if _CLOCKWISE and _ANTICLOCKWISE actually do anything at the moment in _MAPTRIANGLE? I tried using it to do the back-face culling but it didn't seem to have any effect so I ended up using cross-products for the culling.

On a second side note, is there any command for altering the brightness while rendering? I had a brief go with _SETALPHA for each triangle being rendered but (a) it didn't seem to affect _MAPTRIANGLE and (b) the performance impact was horrendous.
Reply
#2
+1 for even attempting this stuff! ;-))

Your code is erroring at line 265 for me.

I don't know dukie about 3D but did example 4 in Wiki about _MapTriangle offer any clues?

For shading, could you overlay the box with alpha faces assuming you want the sides at different shades.
b = b + ...
Reply
#3
(01-11-2023, 12:28 AM)bplus Wrote: +1 for even attempting this stuff! ;-))

Your code is erroring at line 265 for me.

I don't know dukie about 3D but did example 4 in Wiki about _MapTriangle offer any clues?

For shading, could you overlay the box with alpha faces assuming you want the sides at different shades.

My guess is that's a texture handle issue. Are you compiling with "build exe in same folder as bas"?

I'll check example 4 to see if it sheds light on the clockwise wotsits. And I did think about alpha overlays for lighting but it seemed like overkill. But if it's the only way then I'll give it a shot - thanks Smile
Reply
#4
Ohhhhhhhhhh! dang I forgot to extract dah!

Very nice! see I knew that was going to be a +1

   
b = b + ...
Reply
#5
Mind ... blown! Outstanding.
Reply
#6
(01-10-2023, 11:41 PM)RokCoder Wrote: I went on a complete tangent from what I was intending to do this evening when I stumbled upon _MAPTRIANGLE!

First this project creates the vertices of a cube - but it does this based on a hard-coded TESSELATION constant. If this is set to one then each face of the cube has four vertices, if it's set to two then each face has nine vertices, 16 vertices for a value of 4, etc.

The reason for allowing the tessellation is that the project continually morphs between a cube and a sphere (while rotating on three axes). The higher the tessellation value, the better the quality of the sphere but also the greater the number of vertices, calculations, triangles to render, etc. I wanted the code to be clear and well commented so it isn't optimised at all (which is why I've set the tessellation value quite low).

The ZIP file containing the project and its assets is attached. As always, you can also find the code over at my GitHub.





On a side note, does anyone know if _CLOCKWISE and _ANTICLOCKWISE actually do anything at the moment in _MAPTRIANGLE? I tried using it to do the back-face culling but it didn't seem to have any effect so I ended up using cross-products for the culling.

On a second side note, is there any command for altering the brightness while rendering? I had a brief go with _SETALPHA for each triangle being rendered but (a) it didn't seem to affect _MAPTRIANGLE and (b) the performance impact was horrendous.

_CLockWise and _AntiClockWise only work with hardware images, and not with software screens.  Wink
Reply
#7
(01-11-2023, 03:33 AM)SMcNeill Wrote:
(01-10-2023, 11:41 PM)RokCoder Wrote: I went on a complete tangent from what I was intending to do this evening when I stumbled upon _MAPTRIANGLE!

First this project creates the vertices of a cube - but it does this based on a hard-coded TESSELATION constant. If this is set to one then each face of the cube has four vertices, if it's set to two then each face has nine vertices, 16 vertices for a value of 4, etc.

The reason for allowing the tessellation is that the project continually morphs between a cube and a sphere (while rotating on three axes). The higher the tessellation value, the better the quality of the sphere but also the greater the number of vertices, calculations, triangles to render, etc. I wanted the code to be clear and well commented so it isn't optimised at all (which is why I've set the tessellation value quite low).

The ZIP file containing the project and its assets is attached. As always, you can also find the code over at my GitHub.





On a side note, does anyone know if _CLOCKWISE and _ANTICLOCKWISE actually do anything at the moment in _MAPTRIANGLE? I tried using it to do the back-face culling but it didn't seem to have any effect so I ended up using cross-products for the culling.

On a second side note, is there any command for altering the brightness while rendering? I had a brief go with _SETALPHA for each triangle being rendered but (a) it didn't seem to affect _MAPTRIANGLE and (b) the performance impact was horrendous.

_CLockWise and _AntiClockWise only work with hardware images, and not with software screens.  Wink

Aha!

So I've tried copying the images with mode 33 and then applying _CLOCKWISE / _ANTICLOCKWISE but still can't seem to get it working. I'm sure it's a daft oversight on my behalf.

I've pushed the code to GitHub. If the CONST HARDWARECULLING on line 17 is set to TRUE then it uses my attempt at getting it culling via the _MAPTRIANGLE call. In that test it displays two cubes - one rendered with _CLOCKWISE and the other with _ANTICLOCKWISE.

If you (or anyone) has a chance and inclination to scan through, I'd be very grateful to know what daft mistake I'm making Smile
Reply




Users browsing this thread: 2 Guest(s)