I haven't looked at 3D in Purebasic before, I am interested in plotting the Utah Teapot, and thought it should be easiest in 3D first.
I will want to work backwards then, and plot it with 2D Drawing tools to then plot it on old computers.
I really want to see how each of the vertices coordinates is used, and hoped it would be easier in actual 3D.
How can I take the list of vertices here: https://github.com/dasch/graphics/blob/ ... eapot.data and turn that into a wireframe model?
Drawing a 3D Wireframe
Drawing a 3D Wireframe
Last edited by matalog on Mon Aug 04, 2025 6:13 pm, edited 1 time in total.
Re: Drawing a 3D Wireframe
Hello, you need use CreateMesh( to start building the mesh.
Now use MeshVertex(x,y,z,u,v,color,normalX,normalY,normalZ) to add all vertex.
Later with MeshFace(v1,v2,v3[,v4]) Build every face.
At end use FinishMesh(#true) to finish the mesh.
Use BuildMeshShadow and BuildMeshTangents if you need this.
I hope this help you.
Now use MeshVertex(x,y,z,u,v,color,normalX,normalY,normalZ) to add all vertex.
Later with MeshFace(v1,v2,v3[,v4]) Build every face.
At end use FinishMesh(#true) to finish the mesh.
Use BuildMeshShadow and BuildMeshTangents if you need this.
I hope this help you.
If translation=Error: reply="Sorry, Im Spanish": Endif
Re: Drawing a 3D Wireframe
Thanks, i'll be much bettwr off looking at an example for my first go.
Does anyone have an example of a model made from a similar list of vertices?
Does anyone have an example of a model made from a similar list of vertices?
Re: Drawing a 3D Wireframe
Sure! an example is allways better
Use this to create vertex: MeshVertex(x,y,z, x,y, $ffffff, 1,0,0)
The 3 first x,y,z is the position of the vertex, the next 2 are UV for textures, later color and normal direction.
We use same x and y for UV in this example because our loop goes from 0 to 1. UV 0,0 is left top and 1,1 is right bottom.
For normals is another history, you can search in the forum for any procedure to make it or use NormalizeMesh().
In my opinion, the best way to make this is store all vertex, uv and normals in a list or array and later build the object.
Can use a list or array with the type meshvertex. Some thing like this:
global NewList v.MeshVertex() and you have v\x, v\y, v\z, every thing.. UV, normals..
Dont forget watch in the forum for other examples
This code show how to make a simple mesh with 4 vertex.

Use this to create vertex: MeshVertex(x,y,z, x,y, $ffffff, 1,0,0)
The 3 first x,y,z is the position of the vertex, the next 2 are UV for textures, later color and normal direction.
We use same x and y for UV in this example because our loop goes from 0 to 1. UV 0,0 is left top and 1,1 is right bottom.
For normals is another history, you can search in the forum for any procedure to make it or use NormalizeMesh().
In my opinion, the best way to make this is store all vertex, uv and normals in a list or array and later build the object.
Can use a list or array with the type meshvertex. Some thing like this:
global NewList v.MeshVertex() and you have v\x, v\y, v\z, every thing.. UV, normals..
Dont forget watch in the forum for other examples

This code show how to make a simple mesh with 4 vertex.
Code: Select all
InitEngine3D(#PB_Engine3D_DebugLog):InitSprite():InitKeyboard():InitMouse()
OpenWindow(0, 0,0, 1200,700, "simple mesh",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0),WindowHeight(0), 0, 0, 0)
CreateCamera(0,0,0,100,100)
MoveCamera(0, 0,0.5,3)
CameraLookAt(0, 0,0.5,0)
CreateLight(0, $ffffff, 1,5,1)
CreateMesh(0)
For y= 0 To 1
For x= 0 To 1
MeshVertex(x,y,0, x,y, $ffffff, 1,0,0)
Next x
Next y
MeshFace(0,1,3,2)
FinishMesh(#True)
CreateMaterial(0,#Null,$0000ff)
CreateEntity(0,MeshID(0),MaterialID(0))
Repeat
While WindowEvent():Wend
ExamineMouse(): ExamineKeyboard()
renderTime= RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
End
If translation=Error: reply="Sorry, Im Spanish": Endif