![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | D2191 |
![]() |
Old Version | Published before Godot 3 was released. |
Hi,
Im currently working on a project and looking for a way to dynamically generate shapes, Im aware there is a testcube object however im looking to generate some shapes using just the api. However there doesent seem to be a simple way to dynamically generate an immediategeometry object and create a cube mesh in the same way one would with opengl by using quads, or polygons…
I have tried the following:
var cube=ImmediateGeometry.new()
cube.begin(VS.PRIMITIVE_POINTS ,white)
cube.add_vertex(Vector3(1,1,-1))
cube.add_vertex(Vector3(-1,1,-1))
cube.add_vertex(Vector3(-1,1,1))
cube.add_vertex(Vector3(1,1,1))
cube.end()
cube.begin(VS.PRIMITIVE_POINTS ,white)
cube.add_vertex(Vector3(1,-1,1))
cube.add_vertex(Vector3(-1,-1,1))
cube.add_vertex(Vector3(-1,-1,-1))
cube.add_vertex(Vector3(-1,-1,-1))
cube.end()
cube.begin(VS.PRIMITIVE_POINTS ,white)
cube.add_vertex(Vector3(1,1,1))
cube.add_vertex(Vector3(-1,1,1))
cube.add_vertex(Vector3(-1,-1,1))
cube.add_vertex(Vector3(1,-1,1))
cube.end()
cube.begin(VS.PRIMITIVE_POINTS ,white)
cube.add_vertex(Vector3(1,-1,-1))
cube.add_vertex(Vector3(-1,-1,-1))
cube.add_vertex(Vector3(-1,1,-1))
cube.add_vertex(Vector3(1,1,-1))
cube.end()
cube.begin(VS.PRIMITIVE_POINTS ,white)
cube.add_vertex(Vector3(-1,1,1))
cube.add_vertex(Vector3(-1,1,-1))
cube.add_vertex(Vector3(-1,-1,-1))
cube.add_vertex(Vector3(-1,-1,1))
cube.end()
cube.begin(VS.PRIMITIVE_POINTS ,white)
cube.add_vertex(Vector3(1,1,-1))
cube.add_vertex(Vector3(1,1,1))
cube.add_vertex(Vector3(1,-1,1))
cube.add_vertex(Vector3(1,-1,-1))
cube.end()
and other variations using VS.primitive_triangles etc…however at most it displays only 1/2 of the entire cube due to it being triangles and not polygons/quads…Is there any other way to simply create a cube mesh using a similar style of api or will i have to use triangles and double up the code?