Page 13 of 38

Posted: Mon Apr 12, 2010 2:11 pm
by Zurzaza
Here is it the map code:

Code: Select all

		  IAnimatedMesh *Mesh=smgr->getMesh("20kdm2.bsp");

  IAnimatedMeshSceneNode *MapNode=smgr->addAnimatedMeshSceneNode(Mesh,worldNode);

  MapNode->setPosition(vector3df(map->mapoffset[0],map->mapoffset[1],map->mapoffset[2]));

  MapNode->setMaterialFlag(EMF_LIGHTING,false);


CIrrOdeGeomBox  *map=reinterpret_cast<CIrrOdeGeomBox  *>(smgr->addSceneNode(
                     CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_GEOM_BOX_NAME),
                     MapNode));

  map->getSurfaceParameters(0)->setBounce(1.0f);
  map->getSurfaceParameters(0)->setModeBounce(true);
  map->drop();
...and this the "sphere code":

Code: Select all

	CIrrOdeBody *pBody=reinterpret_cast<CIrrOdeBody *>(
                     smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(
                     IRR_ODE_BODY_NAME),worldNode));
  pBody->setPosition(vector3df(0.0f,15.0f,0.0f));

  Mesh=smgr->getMesh("data/sphere.3ds");
  IAnimatedMeshSceneNode *Node2=smgr->addAnimatedMeshSceneNode(Mesh,pBody);
  Node2->setMaterialTexture(0,driver->getTexture("data/sphere0.jpg"));
  Node2->setMaterialFlag(EMF_LIGHTING,false);

  CIrrOdeGeomSphere *pSphere=reinterpret_cast<CIrrOdeGeomSphere *>
                     (smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(
                      IRR_ODE_GEOM_SPHERE_NAME),Node2));
  pSphere->setMassTotal(0.5f);
  pSphere->getSurfaceParameters(1)->setBounce(1.0f);
  pSphere->getSurfaceParameters(1)->setModeBounce(true);
  pSphere->drop();

Destructible terrain

Posted: Tue Apr 13, 2010 12:37 pm
by jacercutio
Brainsaw wrote:@jacercutio: can you specify the position of the line you modified? Couldn't find it in the IrrODE wrapper source, but that would really be an intersting feature.
Hi Brainsaw, its true its NOT in the IrrODE wrapper. It's in CTerrainSceneNode... so it's in the IrrLicht engin.

Right now I didn't rebuild the IrrLicht library but I made just a quick fix by
creating a class that implements ITerrainSceneNode. My class just get a ITerrainSceneNode from the engin at class constructor and redirect all the method calls using this one... all but the GetHeight(...) method that I just use the rendereing buffer instead.

Posted: Tue Apr 13, 2010 1:44 pm
by Brainsaw
@jacercutio: thought so. I have chosen the callback method to get the height-data for exactly that reason ;) (but haven't tried it)

@Zurzaza: I'll take a look at that tonight (I hope I find the time to). That code looks familiar ... you just replaced the box by a trimesh from a quake map? I thought I already tried that.

Posted: Tue Apr 13, 2010 1:52 pm
by Zurzaza
Brainsaw wrote:@Zurzaza: I'll take a look at that tonight (I hope I find the time to). That code looks familiar ... you just replaced the box by a trimesh from a quake map? I thought I already tried that.
Yes it's quite similar the example you put into your package...but how he doesn't work?!

Edit: It seems that there is a problem while loading the physics of the bsp mesh (map). I tested the physics with others 3ds models, and the bounce work fine...any idea about that? Why the physics doesn't work with bsp map?

Posted: Wed Apr 14, 2010 5:41 am
by Brainsaw
I tried to get that done yesterday, but I failed :( . If a .bsp is loaded another type of mesh is created (IQ3LevelMesh), and I just can't get the meshbuffer I need to initialize ODE. I think I'll have to post a question about that in the beginner forum.

Posted: Wed Apr 14, 2010 9:29 am
by Darkcoder
I've been using the library for a few days now and I've got it mostly working fine(though there could seriously be more documentation), one issue I've just come across is that I have no idea how to remove collision from a node, everything I try results in a crash.

In my test I'm just trying to remove collision from a static trimesh object right after I've setup the collision, this particular code is run through lua but you should be able to understand it:

Code: Select all

node:setParent( phyWorld )
colNode = scene:addSceneNode( "CIrrOdeGeomTrimesh", node )
colNode:initPhysics()
colNode:drop()

node:remove() -- This causes a crash
I've tried just changing the node's parent, but I'm pretty sure that just leaves the collision node in the simulation as I then get the crash when the device is dropped. Currently the only way to not get a crash is to just drop the device as done in your examples, but this obviously isn't a solution.

Anyway the details of the error are: "R6025 - Pure virtual function call", my call stack only goes as high as showing me: "myExeName.exe!irr::ode::CIrrOdeManager::removeOdeSceneNode() + 0x37 bytes C++" and the rest just trails into msvcrt.dll, I'm using your lib as a static library so I can't be much more helpful. So am I doing something completely wrong here or what?

Posted: Wed Apr 14, 2010 10:26 am
by Brainsaw
There is a method in CIrrOdeGeom:

CIrrOdeGeom::removeFromPhysics

this should remove a node from physics. I think I'll test that when I got time to. I only remove dynamic objects from my ODE scenes sometimes, didn't yet test it with static parts.

And you're right. More documentation would be fine. It's all a matter of time :(

Posted: Wed Apr 14, 2010 2:01 pm
by Zurzaza
Brainsaw wrote:I tried to get that done yesterday, but I failed :( . If a .bsp is loaded another type of mesh is created (IQ3LevelMesh), and I just can't get the meshbuffer I need to initialize ODE. I think I'll have to post a question about that in the beginner forum.
Ok, so basically it's a problem of your wrapper...right?
I'm looking forward to see news about that...I really need to load mesh like this..

Posted: Thu Apr 15, 2010 5:37 am
by Brainsaw
Hello,

I finally managed to get it done yesterday. I don't even know what I did wrong on Tuesday, I just reverted all those changes and started over again. I think it was some minimal thing. The helloOdeWorld application will let you choose whether to use the box or a quake3 map as static environment.

I didn't yet upload a new version (been with my girlfriend yesterday, and I don't have internet access there ;) ), but maybe I can do this today, or within the next days. I just wanted to inform you that I got it done.

One backdraw: you still have to use an AnimatedMeshSceneNode for the level, I'll have to take a look into the OctTreeSceneNode because this node is optimized for rendering things like that.

Posted: Fri Apr 16, 2010 5:36 am
by Brainsaw
Alright, I uploaded a new version yesterday including the support for .bsp files. Download link can be found in the first post.

I also tried to use an Octree scene node, and it also works fine, but requires a new version of IrrODE. I'll upload that one this afternoon.

Posted: Fri Apr 16, 2010 10:45 am
by Brainsaw
Alright, here we go again: I am currently uploading the latest version. It supports both .bsp files and the octree scenenode. The VC2005 lib is not (yet) updated, so if anyone uses that it needs to be compiled first. Happy downloading.

Posted: Fri Apr 16, 2010 2:27 pm
by Zurzaza
Thank you very much again brainsaw...
P.s. I'm going to recompile the VC2005 lib now....

EDIT: Updated....download from previous link

Posted: Fri Apr 16, 2010 7:04 pm
by Brainsaw
I am currently uploading another version. This time with the VC2005 lib compiled from the lastest sources. Thanks @Zurzaza for compiling.

Posted: Sun Apr 18, 2010 10:05 am
by Zurzaza
I think there is another bug in your wrapper...
See this picture:

Image

Ok, now i'm going to explain...
I put in a bsp map an example mesh, next i applyed the gravity to the scene with worldNode->setGravity(vector3df(0,-10,0)); like your tutorial.
When the game starts, the mash slowly get down to the ground...but she stops her landing in a point out of the mesh's center.

I cannot explain that, because the gravity it's applyed to the mesh "body" scene node that coincides with the mesh center (if there isn't any offset).

So, why is there the gray offset from the ground?
I cannot understand how to find and move this point...

Posted: Mon Apr 19, 2010 5:24 am
by Brainsaw
I gotta check that. Are you using a GeomBox as collision geom? And does the model remain in that position, or does it slowly sink into the ground? If it would then some surface parameters might be wrong.