Search the Community
Showing results for tags 'model custom import'.
-
I'm trying to import one of our models into Unigine. Currently I use the following C++ method to create objects from individual elements: Vector<ObjectMeshDynamicPtr> objects; void processElement(MyElement* elem) { for( int i = 0; i < elem->nummeshes; ++i ) { MyMesh& mesh = elem->meshes[i]; ObjectMeshDynamicPtr object = ObjectMeshDynamic::create(0); for (int j = 0; j < object->getNumSurfaces(); j++) { object->setMaterial("mesh_base",j); object->setProperty("surface_base",j); } object->clearVertex(); object->clearIndices(); for (int j = 0; j < mesh.numvertices; ++j) { MyVertex& vert = mesh.vertices[j]; object->addVertex(vec3(vert.x, vert.z, vert.y)); object->addTexCoord(vec4(0.0f)); } for (int j = 0; j < mesh.numindices; j += 3) { object->addIndex(mesh.indices[j + 0]); object->addIndex(mesh.indices[j + 2]); object->addIndex(mesh.indices[j + 1]); } object->updateBounds(); object->updateNormals(); object->updateTangents(); object->flush(); objects.append(object); } } While it loads fine, rendering runs very slow compared to our current implementation. I suppose the engine can't utilize its full power because I gave it "just single meshes". My question is how should I tell the engine (through the C++ API!) that: - meshes are static so it can create large batches from them - tell it where the portals are (doors, windows) - tell it that it should be streamed Thanks Steve