Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:48 08 Sep 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : 3D Engine and Wireframe

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1184
Posted: 04:39am 08 Sep 2026
Copy link to clipboard 
Print this post

The CMM2 3D engine manual has the line
  Quote  If the optional parameter fill() is omitted then the 3D object will be drawn as a wireframe
It 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: Germany
Posts: 111
Posted: 05:59am 08 Sep 2026
Copy link to clipboard 
Print this post

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
  Quote  
Example
DRAW3D SHOW 1, 0, 0, 200
DRAW3D SHOW 1, 0, 0, 200, 1     ' Show all faces
DRAW3D SHOW 1, 0, 0, 200, 0, 1  ' Vertex-based depth
DRAW3D SHOW 1, 0, 0, 200, 0, 2  ' Hidden-line wireframe


Albert
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1150
Posted: 06:18am 08 Sep 2026
Copy link to clipboard 
Print this post

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
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026