Page 1 of 1

HELP: "Cannot draw triangles, too many primitives"

Posted: Mon Mar 27, 2006 6:15 am
by Sd-RawK-Cab25
Hi, sorry if there is a similar post to this, cos I really need help A.S.A.P!

I've been doing some modelling in 3DSMax for a FPS project. I modeled a room's interior and with one room, everything was fine. However, my whole project involves multiple rooms and when I tried duplicating it to 3 whole rooms, I got the aforementioned message when running it:

"Cannot draw triangles, too many primitives (maximum is 655...)"

I'm not really sure about the exact problem but my guesses are:

1) the renderscene optimization? (currently using OctTreeSceneNode following tutorial)

2) the collision triangle selector? (using OctTree too)

3) or do I have to really cut down on the modelling stage i.e. swapping with low polys etc. (I kinda modelled the room at 80-90% accuracy but no meshsmoothing and tried to lower poly count as much as possible).

With this message, the resulting environment was rendered minus one object (in my case, the mattresses on the beds) for each room.

Please help me! Is there a way that doesn't involve me changing the modelling stage?

need help A.S.A.P!

thanks!

Posted: Mon Mar 27, 2006 6:28 am
by Heizi
maybe it works to seperate the level into 2
and also load it seperately.

Posted: Mon Mar 27, 2006 7:10 am
by Sd-RawK-Cab25
Hmm..so for example if I have 6 rooms in a level. I should have 6 room#.3ds and load them seperately? Which means all the positioning would be done in coding?

for instance:

Code: Select all

scene::IAnimatedMesh* v5mesh = smgr->getMesh("actual.3ds");
	scene::ISceneNode* v5node = 0;

if (v5mesh)
		v5node = smgr->addOctTreeSceneNode(v5mesh->getMesh(0));
scene::ITriangleSelector* selector = 0;

if (v5node)
	{
		v5node->setPosition(core::vector3df(0,-100,0));
		v5node->setRotation(core::vector3df(0,180,0));
		selector = smgr->createOctTreeTriangleSelector(v5mesh->getMesh(0),v5node,128);
		v5node->setTriangleSelector(selector);
		selector->drop();
	}

So i should be doing this for every part of level i would want to load, only with different variables?

I'm a noob with Irrlicht here, so bear with me. :oops:

Is there any other way to just load a whole level, but being able to draw a lot of triangles at once?

thanks!

Posted: Mon Mar 27, 2006 9:27 am
by hybrid
If your model has more than 65535 vertices you need the 32bit index extension for Irrlicht. But you'll find some other problems (such as lighting) which will also require to split the level into parts (i.e. different objects). So just make it right from the start.

Posted: Mon Mar 27, 2006 11:18 am
by Sd-RawK-Cab25
well, okay so i guess there's no such alternative way other than splitting levels up and loading them seperately. Now the question is:

1) How do I go about doing that? Anyone kind enough to give an example on how to load multiple parts of a level?

2) How will the collision detection be affected? Admittedly I did try to do this:

Code: Select all

scene::IAnimatedMesh* v5mesh = smgr->getMesh("part1.3ds");
scene::IAnimatedMesh* v5mesh2 = smgr->getMesh("part2.3ds");
	scene::ISceneNode* v5node = 0;

if (v5mesh)
		v5node = smgr->addOctTreeSceneNode(v5mesh->getMesh(0));
		v5node = smgr->addOctTreeSceneNode(v5mesh2->getMesh(0));
and somehow there was no coldet for the second part. I tried adding to the:

Code: Select all

selector = smgr->createOctTreeTriangleSelector(v5mesh->getMesh(0),v5node,128);
selector = smgr->createOctTreeTriangleSelector(v5mesh2->getMesh(0),v5node,128);
and this is where everything got messed up.

Basically, I think I know the basic thing to do is to load the multiple parts into different mesh buffers, and somehow 'join' them together then (got this from one of bitplane's replies on another thread). The thing is I do not know how to actually implement it in Irrlicht.

Please help, I'm so so lost. Thanks. :(

Posted: Mon Mar 27, 2006 11:42 am
by hybrid
You should use a second scene node for your second mesh. The position those scene nodes where you'd like to have them in your world. Collision detection would use several selectors and a multiSelector.

Posted: Mon Mar 27, 2006 11:55 am
by Sd-RawK-Cab25
Okay, so that basically means for each part, create indv scene nodes and their meshes.

Now how do I do that multiSelector thing? How do I assign these multiple selectors to the camera?

If possible please do give samples in coding. I have no intention to rip off codes as this project is for non-beneficial purposes.

I need to be doing this as soon as possible, and I don't have a clear grip on Irrlicht's engine structure.

Please help, and thanks! (thanks to you hybrid too for giving me the general ideas)

Posted: Mon Mar 27, 2006 12:23 pm
by hybrid
There is a thread in this forum named "collision detection". Take it as a start. then do a search on MetaTriangleSelector which will also bring up lots of code how to do it. Or check the collision detection example which might have some, too.

Posted: Mon Mar 27, 2006 12:47 pm
by Sd-RawK-Cab25
Cool. Thanks for your help hybrid!! Appreciate it lots!

Posted: Mon Mar 27, 2006 1:40 pm
by Spintz
As far as the 65536 limit, you only need 32 bit indices, if you have more than 65,536 indices in a single model. I assume you're using OpenGL? You need to override the getMaximalPrimitiveCount function from CNullDriver to use a value like 1048576; That value is used to render the maximum number of primitives in a scene and should be much higher than 65536, Niko keeps forgetting to fix it.

Posted: Mon Mar 27, 2006 3:09 pm
by Sd-RawK-Cab25
Spintz wrote:As far as the 65536 limit, you only need 32 bit indices, if you have more than 65,536 indices in a single model. I assume you're using OpenGL? You need to override the getMaximalPrimitiveCount function from CNullDriver to use a value like 1048576; That value is used to render the maximum number of primitives in a scene and should be much higher than 65536, Niko keeps forgetting to fix it.
Yes, I'm using OpenGL. So is this method necessary or it's just an alternative way besides using the multinodes/selectors? Which way is the best? (for example: if I alter getMaxPrimCount, I can just load the whole level as one, not worrying about splitting levels into parts?)

Does it help by using other render modes besides OpenGL?

Thanks Spintz!

Posted: Mon Mar 27, 2006 5:29 pm
by Spintz
no it doesnt help using other rendermodes.

if you're level has any meshbuffers that have more than 65536 indices then you'll need to split it up.

Posted: Fri Apr 14, 2006 6:04 am
by TomB
I get this error and my poly count is only 33,000. Whay does this happen? I could understand if it was near the limit but this seems odd since I have a simple scene.

Posted: Fri Apr 14, 2006 9:35 am
by hybrid
The index count is not the face (or poly or triangle) count, but usually #indices=#faces*3 because we have triangles. So each triangle references 3 vertices such that this many indices are needed. If all of your faces belong to one Meshbuffer then 33000 faces means 100000 indices - if you have quad faces in there even more indices are used. Right now none of the mesh loaders uses triangle fans such that a high index count is always guaranteed.