Vertices and idices correct?

Started by
-1 comments, last by Hollandera 12 years, 6 months ago
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.
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);
surfaceExtractor.execute();
//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 =(u32)vecIndices;
}
//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.getPosition().getX();j++;
arrVertices[j] = (f32)vecVertices.getPosition().getY();j++;
arrVertices[j] = (f32)vecVertices.getPosition().getZ();j++;
}

//generate mesh buffer and add it to the mesh
SMeshBuffer *buf = new SMeshBuffer();
buf->append(arrVertices,vecVertices.size()*3,arrIndices,vecIndices.size());
sMesh->addMeshBuffer(buf);
return sMesh;
}

This topic is closed to new replies.

Advertisement