Page 1 of 1

Help

Posted: Thu Dec 20, 2007 8:10 pm
by M.Irr
Hi,
this is my first Message in this forum. First I am not English (german) and my english is terrible I am just learning it (I'm 14) i hope you will hlep me altough. My problem is:
I wrtoe a little game in Irrlicht and i've a problem with the collision when I load a x mesh file it works but i want to use a 3ds file. I think the problem is near my TriangleSelector because when i use 3ds there is konw messag like " Needed 0ms to create OctTreeTriangleSelector.(13 nodes, 1024 polys)" . Here is my code:

Code: Select all

//Map laden
	scene::IAnimatedMesh* Terrain1 = smgr->getMesh("./media/terrain1.x");
	scene::IAnimatedMeshSceneNode* Terrain1_node = smgr->addAnimatedMeshSceneNode(Terrain1);
scene::ITriangleSelector* selector = 0;
scene::ITriangleSelector* selector2 = 0;
	//Map eigenschafte
if (Terrain1_node)

{	
	Terrain1_node->setPosition(core::vector3df(100,100,100));
	Terrain1_node->setScale(core::vector3df(50.f,50.f,50.f));
	selector = smgr->createOctTreeTriangleSelector(Terrain1,Terrain1_node, 64);
	
scene::IMetaTriangleSelector * selector2 = smgr->createMetaTriangleSelector();

selector2->addTriangleSelector(selector);
selector->drop();

Terrain1_node->setMaterialFlag(video::EMF_LIGHTING, false);

//	Terrain1_node->setMaterialTexture(0, driver->getTexture("../../media/terrain-texture.jpg"));
//	Terrain1_node->setMaterialTexture(1, driver->getTexture("../../media/detailmap3.jpg"));
	
//	Terrain1_node->setMaterialType(video::EMT_DETAIL_MAP);


//Kolision

	
	
	scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
		selector2, camera, core::vector3df(30,10,20),
		core::vector3df(0,0,0),
		core::vector3df(0,0,0));

		selector2->drop();
I hope you can help me! :D
M.Irr

Posted: Thu Dec 20, 2007 8:19 pm
by Avian
So what's wrong exactly? does it just crash? There is no real difference between .X and .3ds other then animation and filesize, so if your code works for a .X model it should work for a .3ds model with no problems.

Posted: Thu Dec 20, 2007 8:22 pm
by M.Irr
The problem is with the .x file i could not fly in walls with the 3ds file i could.

Posted: Thu Dec 20, 2007 8:44 pm
by Avian
Try realigning the normals in the model. That could be it.

You will need to alter the model to do that, however.

P.S. in a 3D model the normals are the basically which way each triangle faces.

Posted: Thu Dec 20, 2007 9:31 pm
by christianclavet
M.Irr Your current code here should work correctly and it load an .X object. Can you post the code that is not working?

If you wish to add to the "terrain", for example a "house". You will have to put a selector on it and also add it in the metaselector.

Once I have the code that is not working I'll be more able to help you.

Posted: Fri Dec 21, 2007 3:16 am
by dejai
Mr.Irr do a forum search for The Glade , look in the code snippets section, I had similar problems.

Posted: Fri Dec 21, 2007 11:21 am
by M.Irr
I have search and seen your Message but I've not understand how you could repait it. The code who doesn't work is the same only replace the .x with .3ds and it load the other file i've made .Any thing must be different in the selector and you can see I also try the meta selctor but i think the problem is :
smgr->createOctTreeTriangleSelector(Terrain1,Terrain1_node, 64)

Posted: Fri Dec 21, 2007 11:25 am
by rogerborg
1) You're declaring a "selector2" variable outside your if(), then another variable with the same name but a different type inside it. That's technically legal, but often ends in disaster.

2) I don't see why you're using a meta triangle selector, unless you intend to add more triangle selectors to it later.

3) In your call to createOctTreeTriangleSelector(), you're passing an IAnimatedMesh * rather than an IMesh *. I'd recommend doing Terrain1->getMesh(0) instead of relying on the implicit behaviour.

Your problem may be related to this bug. IAnimatedMesh::getMesh() is currently broken for skinned meshes. I'd expect the problem to be more apparent with X files than 3ds, but there's always something new.

If you really want help, I suggest that you post the full source of the non-working version, along with all of the required resource files. Otherwise we're just guessing.

Posted: Fri Dec 21, 2007 11:43 am
by M.Irr
Thanks very mutch the Problem was the number 3) ;)