Simple 3D morphing with _MAPTRIANGLE - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7) +---- Thread: Simple 3D morphing with _MAPTRIANGLE (/showthread.php?tid=1392) |
Simple 3D morphing with _MAPTRIANGLE - RokCoder - 01-10-2023 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. morph.zip (Size: 419.28 KB / Downloads: 51) 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. RE: Simple 3D morphing with _MAPTRIANGLE - bplus - 01-11-2023 +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. RE: Simple 3D morphing with _MAPTRIANGLE - RokCoder - 01-11-2023 (01-11-2023, 12:28 AM)bplus Wrote: +1 for even attempting this stuff! ;-)) 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 RE: Simple 3D morphing with _MAPTRIANGLE - bplus - 01-11-2023 Ohhhhhhhhhh! dang I forgot to extract dah! Very nice! see I knew that was going to be a +1 RE: Simple 3D morphing with _MAPTRIANGLE - TerryRitchie - 01-11-2023 Mind ... blown! Outstanding. RE: Simple 3D morphing with _MAPTRIANGLE - SMcNeill - 01-11-2023 (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! _CLockWise and _AntiClockWise only work with hardware images, and not with software screens. RE: Simple 3D morphing with _MAPTRIANGLE - RokCoder - 01-11-2023 (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! 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 |