I'm starting using ODE engine wrapped with IrrODE in c++ based project for Irrlicht visualisation. My example is inspired by hello ode world vc tutorial.
It seems that my project is set properly, because compilation and linking work. Application crashes during initialization of scene. My code workflow is as follows:
Code: Select all
IrrlichtDevice *device=createDevice(EDT_DIRECT3D9, dimension2d<u32>(640,480),16,false,false,false,0);
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
IGUIEnvironment *guienv = device->getGUIEnvironment();
CIrrOdeSceneNodeFactory cFactory(smgr);
smgr->registerSceneNodeFactory(&cFactory);
CIrrOdeManager::getSharedInstance()->install(device);
//init the ODE
CIrrOdeManager::getSharedInstance()->initODE();
CIrrOdeManager::getSharedInstance()->initPhysics();
//world definition
ISceneNode *pNode=smgr->addSceneNode(
CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_WORLD_NAME),
smgr->getRootSceneNode());
CIrrOdeWorld *worldNode=reinterpret_cast<CIrrOdeWorld *>(pNode);
CIrrOdeWorld *worldNode=reinterpret_cast<CIrrOdeWorld *>(pNode);
worldNode->setGravity(vector3df(0,-10,0));
IAnimatedMesh *Mesh=smgr->getMesh("box.3ds");
IAnimatedMeshSceneNode *Node=smgr->addAnimatedMeshSceneNode(Mesh,worldNode);
Node->setMaterialTexture(0,driver->getTexture("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));
//here occurs an ERROR : wrong memory allocation
bx->getSurfaceParameters(0)->setBounce(1.0f);
bx->getSurfaceParameters(0)->setModeBounce(true);
bx->drop();
//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();
1. an error occurs when the second scene node is creating
(for this example it is bx box)
smgr->addSceneNode...
[CSceneManager.cpp]
SceneNodeFactoryList->addSceneNode(sceneNodeTypeName, parent);
[CIrrOdeGeomBox->CIrrOdeGeom]
m_iMass=m_pOdeDevice->massCreate();
[CIrrOdeDevice.cpp]
m_pOdeData.push_back(wrap); //here occurs memory allocation error
there is problem in reallocation memory.
Does anybody have similar experience with this issue?