I used the code from CGeometryCreator::createCubeMesh(...) to generate the mesh buffer, vertices and indices, basically it uses:
Code: Select all
SMeshBuffer* buffer = new SMeshBuffer();
Vertices = new video::S3DVertex[TotalVertices];
indices = new u16[TotalIndices];
...
buffer->Indices.set_used(TotalIndices);
buffer->Vertices.reallocate(TotalVertices);
buffer->BoundingBox.reset(0,0,0);
SMesh* Mesh = new SMesh;
Mesh->addMeshBuffer(buffer);
buffer->drop();
Mesh->recalculateBoundingBox();
...
Code: Select all
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
// for debug purposes only:
video::SMaterial mat = Mesh->getMeshBuffer(0)->getMaterial();
// overwrite half transparency
if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY)
mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
else
driver->setMaterial(Mesh->getMeshBuffer(0)->getMaterial());
driver->setMaterial(mat);
driver->drawMeshBuffer(Mesh->getMeshBuffer(0));
...
// rest of the debugging code
The way this is added to the scene is:
Code: Select all
scene::IMeshSceneNode *mesh = smgr->addConeSceneNode(0, -1,
36, 0, 5, 5, video::SColor(0,255,0,255));
Am planing to add thousands of this nodes to a scene, create a random movement for each. I wonder what will be the best way for this to work, maybe changing the calls for the render method or giving a hint to use a vertex buffer or whatever serves performance wise. What would you recommend?
I added this line
Code: Select all
mesh->getMesh()->getMeshBuffer(0)->setHardwareMappingHint(scene::EHM_STATIC);