Code: Select all
void World::newWorld(bool moar, scene::ICameraSceneNode* camera, ISceneManager* smgr, IVideoDriver* driver)
{
vector3df mappos(0,0,0);
IMeshSceneNode* cube[1000];
ITriangleSelector* sel;
IMetaTriangleSelector* meta = smgr->createMetaTriangleSelector();
for (int i = 0; moar; ++i)
{
cube[i] = smgr->addCubeSceneNode(100);
cube[i]->setPosition(mappos);
cube[i]->setMaterialTexture(0, driver->getTexture("../../../irrlicht-1.8.1/media/wall.jpg"));
/*smgr->getMeshManipulator()->setVertexColors(cube[i]->getMesh(), SColor(0, 255, 0, 255));*/
cube[i]->setMaterialFlag(EMF_LIGHTING, false);
scene::ITriangleSelector* selector = smgr->createTriangleSelectorFromBoundingBox(cube[i]);
cube[i]->setTriangleSelector(selector);
selector->drop();
meta->addTriangleSelector(cube[i]->getTriangleSelector());
ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(meta, camera, vector3df(30, 50, 30), vector3df(0, -20, 0), vector3df(0, 20, 0));
camera->addAnimator(anim);
anim->drop();
//dungeon generator
if (i < 50)mappos.X += 100;
else
moar = false;
}
}
1. How can I minimize the drawcalls? When I try to draw 250 cubes (1500 faces) I only get 10 fps. Thats a bit too low, I think.
And I know what I am doing wrong, I have to many drawcalls. I plan to combine all cube nodes and then have an octree.
So how can I do that? Please give me an explanation about that.(or a link to a tutorial)
2. I want the floor to be one cube to optimize the game,but how can I change its dimensions? when I want a 1000u long cube, its automaticly 1000 in depth too. Please help
Any other Ideas to optimize this?
Thanks for helping