IrrODE - an Irrlicht - ODE wrapper (now with SVN)

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Hmm ... maybe I got some initial values wrong. I think I'll have to check that ;)
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Sky-Fox
Posts: 29
Joined: Fri Feb 04, 2011 10:49 am

Post by Sky-Fox »

Brainsaw, your tutorials (http://www.bulletbyte.de/irrOde/tutoria ... ial01.html) of a site does not work

My code, copy past :-)

Code: Select all

#include "include\irrlicht.h" // Irr - Графический движок "IrrLicht"
#include "include\IrrODE.h"   // Irr - Физический движок "IrrODE"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace ode;

int main(int argc, char** argv) {
  IrrlichtDevice *device=createDevice(video::EDT_OPENGL,core::dimension2d<u32>(800, 600), 16,false,false,false,0);
  device->setWindowCaption(L"HelloOdeWorld");

  IVideoDriver* driver = device->getVideoDriver();
  ISceneManager* smgr = device->getSceneManager();
  IGUIEnvironment* guienv = device->getGUIEnvironment();

  CIrrOdeSceneNodeFactory cFactory(smgr);
  smgr->registerSceneNodeFactory(&cFactory);

  CIrrOdeManager::getSharedInstance()->install(device);

  ISceneNode *pNode=smgr->addSceneNode(
                    CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_WORLD_NAME),
                    smgr->getRootSceneNode());
  CIrrOdeWorld *worldNode=reinterpret_cast<CIrrOdeWorld *>(pNode);


  worldNode->setGravity(vector3df(0,-10,0));

  IAnimatedMesh *Mesh=smgr->getMesh("data/box.3ds");
  IAnimatedMeshSceneNode *Node=smgr->addAnimatedMeshSceneNode(Mesh,worldNode);
  Node->setMaterialTexture(0,driver->getTexture("data/box0.jpg"));
  Node->setScale(vector3df(15.0f,1.5f,15.0f));
  Node->setMaterialFlag(EMF_LIGHTING,false);

  CIrrOdeGeomBox *bx=reinterpret_cast<CIrrOdeGeomBox *>(smgr->addSceneNode(
                     CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_GEOM_BOX_NAME),
                     Node));
  bx->getSurfaceParameters(0)->setBounce(1.0f);
  bx->getSurfaceParameters(0)->setModeBounce(true);
  bx->drop();

  //first add a body as child of the worldNode
  CIrrOdeBody *pBody=reinterpret_cast<CIrrOdeBody *>(
                     smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(
                     IRR_ODE_BODY_NAME),worldNode));
  pBody->setPosition(vector3df(0.0f,15.0f,0.0f));

  //next load a mesh and add an AnimatedMeshSceneNode
  //as child of the body
  Mesh=smgr->getMesh("data/sphere.3ds");
  Node=smgr->addAnimatedMeshSceneNode(Mesh,pBody);
  Node->setMaterialTexture(0,driver->getTexture("data/sphere0.jpg"));
  Node->setMaterialFlag(EMF_LIGHTING,false);

  //as the last part we add a sphere geom as child of the
  //AnimatedMeshSceneNode
  CIrrOdeGeomSphere *pSphere=reinterpret_cast<CIrrOdeGeomSphere *>
                     (smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(
                      IRR_ODE_GEOM_SPHERE_NAME),Node));
  pSphere->setMassTotal(0.5f);
  pSphere->getSurfaceParameters(0)->setBounce(1.0f);
  pSphere->getSurfaceParameters(0)->setModeBounce(true);
  pSphere->drop();

//Before adding objects to the system we init ODE.
  CIrrOdeManager::getSharedInstance()->initODE();

  worldNode->initPhysics();

  ICameraSceneNode *cam=smgr->addCameraSceneNode();
  cam->setPosition(vector3df(-20.0f, 15.0f, -20.0f));
  cam->setTarget(vector3df(0.0f,0.0f,0.0f));

  while(device->run()) {
    CIrrOdeManager::getSharedInstance()->step();
    driver->beginScene(true, true, SColor(0,200,200,200));

    smgr->drawAll();
    guienv->drawAll();

    driver->endScene();
  }

  device->drop();
  return 0;
}

Error Masage
ODE Message 2: mass must be > 0 in dMassCheck() File ode\ode-0.11(2)
\ode-0.11\ode\src\mass.cpp Line 50



P.S. Where you can download working examples(tutorials)?
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Hmm .. that's strange. The line

Code: Select all

pSphere->setMassTotal(0.5f);
should prevent that. Maybe you could try to set a higher value for that. I'll also take a look at it this weekend (if I find time to do so ;) ).
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Sky-Fox
Posts: 29
Joined: Fri Feb 04, 2011 10:49 am

Post by Sky-Fox »

Thanks, I'll be waiting :-)
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

OK, I noticed a couple of things:

- you should set the paths in your IDE so that you don't have to add the "include" folder to the #include command, neither for irrlicht.h nor IrrOde.h. But this should not be too much of a problem as long as the program compiles.
- make sure you paths are correct. I was able to reproduce the error when the "sphere" mesh couldn't be loaded (although I had to add another nullpointer check, otherwise the program crashed). If your objects can't be loaded no intialization will be done in IrrOde and therefore no mass is added to the body.

I hope I could help you with that information. If it still doesn't work you could leave the "CIrrOdeManager::getSharedInstance()->step()" call out, the program should then run without any motion and you can see if the scene looks OK.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Sky-Fox
Posts: 29
Joined: Fri Feb 04, 2011 10:49 am

Post by Sky-Fox »

Brainsaw, Thank you very much. Problem solved!
I used version Irrlicht 1.7.2
At Irrlicht 1.7.1 Everything works!
Sky-Fox
Posts: 29
Joined: Fri Feb 04, 2011 10:49 am

Post by Sky-Fox »

How to work with BSP?

Code: Select all

  IAnimatedMesh *Mesh=smgr->getMesh("data/box.3ds");
  IAnimatedMeshSceneNode *Node=smgr->addAnimatedMeshSceneNode(Mesh,worldNode);

Code: Select all

        scene::IAnimatedMesh* Mesh = smgr->getMesh("20kdm2.bsp");
        scene::ISceneNode* Node = 0;

        if (mesh)
                Node = smgr->addOctreeSceneNode(Mesh->getMesh(0), 0, -1, 1024);
//              Node = smgr->addMeshSceneNode(Mesh->getMesh(0));
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

I think it should work by simply adding a child of type "CIrrOdeGeomTrimesh" to the level node. Check the sources of "HelloOdeWorld", I think I added bsp support there.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Sky-Fox
Posts: 29
Joined: Fri Feb 04, 2011 10:49 am

Post by Sky-Fox »

Sky-Fox
Posts: 29
Joined: Fri Feb 04, 2011 10:49 am

Post by Sky-Fox »

People need more simple tutorials end examples. ^_^
Please...
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

I haven't added it to the tutorial, but it's in the source of the example that comes with the download.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Sky-Fox
Posts: 29
Joined: Fri Feb 04, 2011 10:49 am

Post by Sky-Fox »

SVN ?
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

I only removed the binaries of most old demo applications, but the sources are still there. Are you using the SVN (I guess so)? Just take a look into the "source" and "include" folders, there are subfolders for the demos.

Oh ... I guess I removed the stuff from the VC project (not sure though) as I am using Code::Blocks for everything except the IrrEdit plugin.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Sky-Fox
Posts: 29
Joined: Fri Feb 04, 2011 10:49 am

Post by Sky-Fox »

SVN: main.cpp Revision 95

http://irrode.svn.sourceforge.net/viewv ... oOdeWorld/

My code

Code: Select all

/// ///////////////////////
/// irrlicht 1.7.1
/// IrrOde (1.7.1 x 0.11)
/// ODE 0.11
/// CodeBlocks 10.05
/// ///////////////////////

#include "include\irrlicht\irrlicht.h"
#include "include\IrrOde\IrrODE.h"

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace ode;

int main(int argc, char** argv) {

  printf("choose your static collision object:\n\n(1) use box\n(2) use quake3 level\n(3) exit\n\n..");

  char c;
  do { c=getchar(); } while (c!='1' && c!='2' && c!='3');
  if (c=='3') return 0;

  IrrlichtDevice *device=createDevice(video::EDT_OPENGL,dimension2d<u32>(640,480),16,false,false,false,0);

  device->setWindowCaption(L"HelloOdeWorld");

  ISceneManager *smgr = device->getSceneManager();
  IVideoDriver* driver = device->getVideoDriver();
  IGUIEnvironment* guienv = device->getGUIEnvironment();

  stringc aTitle=stringc("hello world!");
  printf("%s\n",aTitle.c_str());
  CIrrOdeSceneNodeFactory cFactory(smgr);
  smgr->registerSceneNodeFactory(&cFactory);

  //set the scene manager
  CIrrOdeManager::getSharedInstance()->install(device);

  //init the ODE
  CIrrOdeManager::getSharedInstance()->initODE();

  ISceneNode *pNode=smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_WORLD_NAME),smgr->getRootSceneNode());
  CIrrOdeWorld *worldNode=reinterpret_cast<CIrrOdeWorld *>(pNode);

  worldNode->setGravity(vector3df(0.0f,-10.0f,0.0f));

  device->getFileSystem()->addZipFileArchive("data/map-20kdm2.pk3");

  scene::IAnimatedMesh *mesh=smgr->getMesh("20kdm2.bsp");

  //if the user has entered "2" we'll load the quake3 level...
  CIrrOdeBody *pBody=NULL;
  if (c=='2') {
    if (mesh) {
      //for optimization we use an octree scene node...
      scene::IMeshSceneNode *node=smgr->addOctreeSceneNode(mesh,worldNode); //->addAnimatedMeshSceneNode(mesh,worldNode);
      if (node) {
        node->setPosition(core::vector3df(-1300,-144,-1249));
        //... and for detailed collision detection we use a trimesh.
        CIrrOdeGeomTrimesh *pTri=reinterpret_cast<CIrrOdeGeomTrimesh *>(smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_GEOM_TRIMESH_NAME),node));

        //One important thing: a static trimesh has one surface for every meshbuffer (aka "material") of the parent scene node
        for (u32 j=0; j<pTri->getSurfaceParametersCount(); j++) {
          pTri->getSurfaceParameters(j)->setBounce(1.0f);
          pTri->getSurfaceParameters(j)->setModeBounce(true);
        }

        pTri->drop();
      }
    }
  }
  else {
    IAnimatedMesh *Mesh=smgr->getMesh("data/box.3ds");
    IAnimatedMeshSceneNode *Node=smgr->addAnimatedMeshSceneNode(Mesh,worldNode);
    Node->setMaterialTexture(0,driver->getTexture("data/box0.jpg"));
    Node->setScale(vector3df(15.0f,1.5f,15.0f));
    Node->setMaterialFlag(EMF_LIGHTING,false);

    CIrrOdeGeomBox *bx=reinterpret_cast<CIrrOdeGeomBox *>(smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_GEOM_BOX_NAME),Node));
    bx->getSurfaceParameters(0)->setBounce(1.0f);
    bx->getSurfaceParameters(0)->setModeBounce(true);
    bx->drop();
  }

  //first add a body as child of the worldNode
  pBody=reinterpret_cast<CIrrOdeBody *>(smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_BODY_NAME),worldNode));
  pBody->setPosition(vector3df(0.0f,15.0f,0.0f));
  //next load a mesh and add an AnimatedMeshSceneNode
  //as child of the body
  IAnimatedMesh *Mesh=smgr->getMesh("data/sphere.3ds");
  IAnimatedMeshSceneNode *Node=smgr->addAnimatedMeshSceneNode(Mesh,pBody);
  Node->setMaterialTexture(0,driver->getTexture("data/sphere0.jpg"));
  Node->setMaterialFlag(EMF_LIGHTING,false);

  //as the last part we add a sphere geom as child of the
  //AnimatedMeshSceneNode
  CIrrOdeGeomSphere *pSphere=reinterpret_cast<CIrrOdeGeomSphere *>(smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_GEOM_SPHERE_NAME),Node));
  pSphere->setMassTotal(0.5f);
  pSphere->getSurfaceParameters(0)->setBounce(1.0f);
  pSphere->getSurfaceParameters(0)->setModeBounce(true);
  pSphere->drop();

  worldNode->initPhysics();

  ICameraSceneNode *cam=smgr->addCameraSceneNode();
  cam->setPosition(vector3df(-20.0f, 15.0f, -20.0f));
  cam->setTarget(vector3df(0.0f,0.0f,0.0f));

  while(device->run()) {
    CIrrOdeManager::getSharedInstance()->step();
    driver->beginScene(true, true, SColor(0,200,200,200));

    if (c=='2' && pBody!=NULL) cam->setTarget(pBody->getAbsolutePosition());

    smgr->drawAll();
    guienv->drawAll();

    driver->endScene();
  }

  device->drop();
  return 0;
}


1. use box - OK

2. use quake3 level - Error:
Image
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Seems that I use Opcode for the trimesh collision stuff. I'll take a look on how to compile with Opcode instead of Gimpact when I find time to (I hope I can get that done this evening). This means you'd have to recompile ODE.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Post Reply