, Sr. Member
Hi
Although I dont know why its giving me a flat 2d shape in 3d space, instead of a 3d geometry in 3d space? Am i going about this totally wrong.
how do i create a 3d geometry?
am I suppose to add more subgeometries to the singular geometry?
I think your on the right way. All you need to understand is this:
A Mesh in 3D is displayed by a number of triangle-shapes (faces).
You are only creating 2 Faces, so maybe you will see more 3D. if you create some more. (for each new triangle you need to add 3 pointIndices to the IndexBuffer. You might need to create new Points (Verticles) in the other Buffers too, but you can reuse allready existing points, too).
It simply might be the position of the camera and the mesh/faces that makes you believe the shape is not 3d.
try changing the camera position like this:
view.camera.z = -2000;
view.camera.x = 2000;
view.camera.y = 300;
view.camera.lookAt(new Vector3D());
or try to change the rotation / position of the mesh:
mesh.x=100;
mesh.rotateX=20;
The use of Subgeometrys is this:
Each face of a mesh, can only have one material assigned to it.
If you want to different faces of you mesh have different materials assigned, you would need to split you mesh into subMeshes, so you have one Submesh for every material you want to use.
So for your situation, you do not need to add more SubGeometrys.
If you want to use Textures on the Mesh later, you will need to define the correct uvs for the Meshes, but that is something that is quite messy when building meshes the procedual way. if you want to display the Meshes only by using color, not texture, you will not run into the problem with the uvs.
You should not define the normals, as you do it, because they do not seam to be correct, and the SubGeometry can autoderive them in a better way.
i think you just need to get rid of this line:
subGeometry.updateVertexNormalData(normals);
The Subgeometry should autoDerive the normals now.
Hope that helps