Help

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
M.Irr
Posts: 11
Joined: Thu Dec 20, 2007 6:54 pm

Help

Post 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
Avian
Posts: 17
Joined: Sun Dec 16, 2007 7:14 am

Post 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.
M.Irr
Posts: 11
Joined: Thu Dec 20, 2007 6:54 pm

Post by M.Irr »

The problem is with the .x file i could not fly in walls with the 3ds file i could.
Avian
Posts: 17
Joined: Sun Dec 16, 2007 7:14 am

Post 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.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post 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.
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Post by dejai »

Mr.Irr do a forum search for The Glade , look in the code snippets section, I had similar problems.
Programming Blog: http://www.uberwolf.com
M.Irr
Posts: 11
Joined: Thu Dec 20, 2007 6:54 pm

Post 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)
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
M.Irr
Posts: 11
Joined: Thu Dec 20, 2007 6:54 pm

Post by M.Irr »

Thanks very mutch the Problem was the number 3) ;)
Post Reply