|
Forum Index : Microcontroller and PC projects : 3D Engine and Wireframe
| Author | Message | ||||
| vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1185 |
The CMM2 3D engine manual has the lineIt is clear from using it that "wireframe" still means hidden face culling. The following code from the manual shows this (tested with Picomite and MMB4W, same for CMM2 as I recall) cls DIM FLOAT vertices(2,7) = (-1,1,-1, 1,1,-1, 1,-1,-1, -1,-1,-1, -1,1,1, 1,1,1, 1,-1,1, -1,-1,1) DIM INTEGER facecount(5)=(4,4,4,4,4,4) DIM INTEGER faces(23)=(0,1,2,3, 1,5,6,2, 0,4,5,1, 5,4,7,6, 2,6,7,3, 0,3,7,4) DIM INTEGER colours(6)=(rgb(blue),rgb(green),rgb(yellow),rgb(cyan),rgb(red),rgb(magenta),rgb(yellow)) DIM INTEGER edge(5)=(6,6,6,6,6,6) DIM INTEGER fill(5)=(0,1,2,3,4,5) DIM n=1, nv=8, nf=6, camera=1 MATH SCALE vertices(), 100.0, vertices() DRAW3D CREATE n, nv,nf,camera,vertices(),facecount(),faces(),colours(),edge()',fill() DIM INTEGER viewplane=500 DRAW3D CAMERA n, viewplane DIM INTEGER x=0, y=0, z=1000 'PAGE WRITE 1 DRAW3D SHOW n, x, y, z DIM FLOAT yaw=rad(1), pitch=rad(2), roll=rad(0.5) DIM FLOAT q(4) DO MATH Q_EULER yaw, pitch, roll, q() DRAW3D ROTATE q(),n DRAW3D show n,x,y,z INC yaw,RAD(1) INC pitch,RAD(2) INC roll,RAD(0.5) 'PAGE COPY 1 to 0,B pause 25 LOOP Line 10 is changed to comment out the fill() parameter. Note also that page copying is commented out, so image flicker is bad. The result is the cube rendered with hidden lines _removed_ and no colour on the faces. Depending on the definition used, this may not be "wireframe." Is there any chance of a true wireframe mode where all edges are drawn, even those on the far side of the object? (And if so, updates to the relevant MMBasic families?) Thanks. Visit Vegipete's *Mite Library for cool programs. |
||||
| AlbertR Senior Member Joined: 29/05/2025 Location: GermanyPosts: 111 |
Hi vegipete, If I'm understanding this correctly, it's not DRAW3D CREATE n, nv,nf,camera,vertices(),facecount(),faces(),colours(),edge()',fill() that needs to be changed, but DRAW3D SHOW n, x, y, z add ',1'Here, it's “hidden face removal” (default) from MMBasic DRAW3D Graphics User Manual Albert |
||||
| disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 1150 |
The latest version of CMM2 has this, I ported it from the Picomite code in recent versions. Is this what you mean. Seems to work on CMM2 with latest firmware. DRAW3D SHOW n,x,y,z [,nocull][,usefurthest] DRAW3D WRITE n,x,y,z [,nocull][,usefurthest] DRAW3D SHOW/WRITE are shown here and are also in the updated The 3D Engine document included in the download. Rendering of the 3D object works by Painters algorithm. This works by sorting the faces and drawing those further away first. In addition the MMBasic firmware supports "back face culling". This doesn't draw faces that are pointing away from the camera. Setting nocull overrides this and they are drawn. In order to sort the faces the current MMBasic code uses the Z axis position of the face centroid. This works in many situations but in some 3D models it is better to use the furthest vertex and sort on that. I've added that as an option to DRAW3D SHOW and DRAW3D WRITE. Set usefurthest to 1 to use the furthest vertex and zero (default) to use the centroid. DO MATH Q_EULER yaw, pitch, roll, q() DRAW3D ROTATE q(),n DRAW3D show n,x,y,z,1 INC yaw,RAD(1) INC pitch,RAD(2) INC roll,RAD(0.5) 'PAGE COPY 1 to 0,B pause 25 LOOP F4 H7FotSF4xGT |
||||
| vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1185 |
Thank you guys for pointing that out to me. That makes far more sense that it should be part of the drawing command instead of the object creation, and it's right there in the manual, if I would just open my eyes. The manual I'm looking at doesn't have the "furthest vertex" option, so I must search out a newer version... Again, thanks for helping me see (the hidden lines. ;-) Visit Vegipete's *Mite Library for cool programs. |
||||
| LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 624 |
Just out of curiosity, has the structure data type been ported to the CMM2? |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |