Ich habe ein Problem mit meinem selbst geschriebenen Mesh Loader.
Nach dem Laden des kompletten Meshes wird dieser nur fehlerhaft flackernd blau dargestellt. Wenn ich nur teile des Meshes lade, werden diese scheinbar korrekt dargestellt.
Es handelt sich hierbei um ein Animierten Mesh welcher aus 8 Meshes besteht mit insgesammt 13.776 Vertices und 71.226 Indices. Ist dies zuviel für die Irrlicht Engine oder kann ich was am Code ändern um alle Meshteile korrekt darzustellen?
Am System sollte es nicht liegen:
Operating System: Windows 7 Ultimate 64-bit
Processor: Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz (8 CPUs), ~2.9GHz
Memory: 4096MB RAM
Card name: NVIDIA GeForce GTX 470
Code ausschnitte:
Main
Code:
IrrlichtDevice *device = createDevice( video::EDT_DIRECT3D9, dimension2d<u32>(1280, 768));
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
smgr->addCameraSceneNodeFPS(0,100.0F,0.1F);
XNAMeshLoader *xnameshloader = new XNAMeshLoader(driver, device);
smgr->addExternalMeshLoader(xnameshloader);
IAnimatedMesh* mesh = smgr->getMesh("XYZ");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
smgr->registerNodeForRendering(node);
node->setMaterialFlag(EMF_LIGHTING, false);
while(device->run()) {
driver->beginScene();
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
Loader Function
Code:
irr::scene::IAnimatedMesh *XNAMeshLoader::createMesh(irr::io::IReadFile *file){
....[fill model struktur]...
irr::scene::SAnimatedMesh *full_mesh = new irr::scene::SAnimatedMesh();
irr::scene::SMesh* mesh;
irr::scene::SMeshBuffer *buf = 0;
for(int i = 0; i < model.meshes.size(); i++){
mesh = new irr::scene::SMesh();
buf = new irr::scene::SMeshBuffer();
mesh->addMeshBuffer(buf);
buf->drop();
// Vertices
buf->Vertices.reallocate(model.meshes[i].vertices.size());
buf->Vertices.set_used(model.meshes[i].vertices.size());
for(int j = 0; j < model.meshes[i].vertices.size(); j++){
buf->Vertices[j] = irr::video::S3DVertex(model.meshes[i].vertices[j].position.x,
model.meshes[i].vertices[j].position.y,
model.meshes[i].vertices[j].position.z,
model.meshes[i].vertices[j].normal.x,
model.meshes[i].vertices[j].normal.y,
model.meshes[i].vertices[j].normal.z,
irr::video::SColor(model.meshes[i].vertices[j].color.red,
model.meshes[i].vertices[j].color.green,
model.meshes[i].vertices[j].color.blue,
model.meshes[i].vertices[j].color.alpha),
model.meshes[i].vertices[j].texcords.x,
model.meshes[i].vertices[j].texcords.y);
}
// Indices
buf->Indices.reallocate(model.meshes[i].indices.size());
buf->Indices.set_used(model.meshes[i].indices.size());
for(int j = 0; j < model.meshes[i].indices.size(); j++){
buf->Indices[j]=model.meshes[i].indices[j];
}
// Textures
std::string fname;
for(int j = 0; j < model.meshes[i].texture.size(); j++){
fname = path;
fname.append(model.meshes[i].texture[j].name);
if(fs->existFile(fname.c_str())){
buf->Material.setTexture(model.meshes[i].texture[j].uvlayerindex, _driver->getTexture(fname.c_str()));
}
}
buf->setHardwareMappingHint(irr::scene::E_HARDWARE_MAPPING::EHM_STATIC);
buf->setDirty(irr::scene::EBT_VERTEX_AND_INDEX);
buf->recalculateBoundingBox();
vert += model.meshes[i].vertices.size();
ind += model.meshes[i].indices.size();
full_mesh->addMesh(mesh);
}
return full_mesh;