• Advertisement
Sign in to follow this  

Vertices and idices correct?

This topic is 2326 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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.
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;
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement