I have made a sample application with panda. In this application a mesh is displayed.
Pseudo c++ code is :
NodePath BuildTess(const & arTess)
{
NodePath nRet("tess");
int iName(0);
for (const auto& t : arTess)
{
// Build data (vertices)
PT(GeomVertexData) pData = new GeomVertexData("TesselationData", GeomVertexFormat::get_v3n3t2(), Geom::UH_static);
// Build Vertices data.
pData->set_num_rows(iNbVertices);
GeomVertexWriter vertex(pData, "vertex");
GeomVertexWriter normal(pData, "normal");
GeomVertexWriter textcoord(pData, "texcoord");
// Fill vertices, normals and texcoor
//Build geometry (triangles)
PT(GeomTriangles) primT = new GeomTriangles(Geom::UH_dynamic);
primT->reserve_num_vertices(iNbIndicies);
for (int ii = 0; ii < iNbIndicies; ii+=3)
{
// Fill pPrim T With vertices
primT->add_vertices(pIndicies->at(ii), pIndicies->at(ii + 1), pIndicies->at(ii + 2));
}
// Build geometry based on vertices
PT(Geom) geomSolid;
geomSolid = new Geom(pData);
// Create a primitive
geomSolid->add_primitive(primT);
//Create pandanode for solid
std::string sName = "gnodemesh_";
sName += std::to_string(iName++);
PT(GeomNode) nodemesh = new GeomNode(sName);
// add mesh geometry
nodemesh->add_geom(geomSolid);
//
NodePath n = nRet.attach_new_node(nodemesh);
PT(Material) pMat = new Material("material");
//Fill Material
pMat->set_ambient(...);
pMat->set_diffuse(...);
pMat->set_specular(...);
pMat->set_shininess(...);
pMat->clear_emission();
pMat->set_twoside(true);
n.set_material(pMat);
}
return nRet;
}
If i use Geom::UHStatic in new geom Triangles
//Build geometry (triangles)
PT(GeomTriangles) primT = new GeomTriangles(Geom::UH_static);
The frame ret ias about 10th slower (using dynamic is 260 fps, static falls to 25-30 fps)
I understood while reading documentation that I should use Static mode because all data of the rendered mesh are not modified during the process. But it is faster with dynamic mode. So I’m not sure too clearly understant the difference between dynamic and static mode.
Can anyone help?
Yoy