Sign in to follow this  

Vertices and idices correct?

Recommended Posts

Sorry for double post(I put this in the graphics forum), but I have been anguishing over this for hours. I'm generating a mesh for my terrain using polyvox and rendering it with irrlicht, but the mesh produced is disjointed and it seems like it's missing polygons. Am I loading my vertices and Indices correctly? thankyou.
[code]SMesh* TerrainManager::generateCubicMesh(SimpleVolume<MaterialDensityPair44>& volData)
//extract the surface mesh from the voxels
SMesh* sMesh = new SMesh();
SurfaceMesh<PositionMaterialNormal> vMesh;
CubicSurfaceExtractorWithNormals<SimpleVolume, MaterialDensityPair44 > surfaceExtractor(&volData, volData.getEnclosingRegion(), &vMesh);
//get the indices and vertices
const std::vector<uint32_t>& vecIndices = vMesh.getIndices();
const std::vector<PositionMaterialNormal>& vecVertices = vMesh.getVertices();
//copy indices to an array
u16 *arrIndices = new u16[vMesh.getNoOfIndices()];
for(int i =0; i < vMesh.getNoOfIndices();i++)
arrIndices[i] =(u32)vecIndices[i];
//copy vertices to an array
f32 *arrVertices = new f32[vecVertices.size()*3];
int j = 0;
for(int i =0; i < vecVertices.size();i++)

arrVertices[j] = (f32)vecVertices[i].getPosition().getX();j++;
arrVertices[j] = (f32)vecVertices[i].getPosition().getY();j++;
arrVertices[j] = (f32)vecVertices[i].getPosition().getZ();j++;

//generate mesh buffer and add it to the mesh
SMeshBuffer *buf = new SMeshBuffer();
return sMesh;

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this