New body already attached

DarthDie

12-07-2007 18:13:37

Hey everyone,
Im trying to get a small ODE world up and running and im running into a problem, im creating a new entity , attaching it to a scenenode , creating a new body, and then trying to attach it to the scenenode...too bad for some reason the new body is already attached??? Why? From what I can tell this has been asked about before and the only answer was to switch to a different compiler. Im using Microsoft Visual C++ 2005 Express . Can anyone help?

rewb0rn

12-07-2007 18:50:50

have you created a geometry and called setBody()? I dont know if it works without it, maybe it doesnt, so you should give it a try. thats how i do it:

create scenenode
create entity
attach entity to scenenode
create geometry
create body
set body in geometry
attach body to scenenode

DarthDie

12-07-2007 20:39:26

Thanks for the reply, and yeah I also create geometry and call setbody.I also moved the node->attachObject(body); to the end...and it still doesnt work. Any other suggestions?

rewb0rn

12-07-2007 20:53:24

show some code please

DarthDie

13-07-2007 00:25:36

// Create the Ogre box
String name = String("Box_") + StringConverter::toString(numofboxs) + "_";;
Entity* box = sceneMgr->createEntity("box","cube.mesh");

numofboxs++;
box->setCastShadows(true);

SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(box);
node->setScale(0.15,0.15,0.15);

// Set the position
Ogre::Vector3 pos(50 + x,130,50 + z);
node->setPosition(pos);

// Create a box for ODE and attach it to the Ogre version
OgreOde::Body* body = new Body(_world);
OgreOde::BoxGeometry* geom = new OgreOde::BoxGeometry(Vector3(1.5,1.5,1.5), _world, _world->getDefaultSpace());

geom->setBody(body);

body->setMass(OgreOde::BoxMass(0.5,Vector3(1.5,1.5,1.5)));

node->attachObject(body);

Its example code just edited a little.

rewb0rn

13-07-2007 12:41:18

well the code looks absolutely okay to me. it shouldnt be a problem with vc 8 ee because i use it too. the only thing i can now imagine is that your attach method is called twice for some reason?

DarthDie

13-07-2007 14:03:49

Its only called once for the ent and once for the body. :/ Not sure what todo.

rewb0rn

13-07-2007 14:33:26

compile the demos and test them, do they work? thoroughly debug your code, check if the variables have the expected values etc. if the demos work (would really confuse me if they wouldnt) copy the code from there over to your app and change it step by step for your need.

DarthDie

13-07-2007 16:51:57

The demos compile but all have the same 2 linker errors:


4>GranTurismOgre.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl OIS::InputManager::destroyInputSystem(class OIS::InputManager *)" (__imp_?destroyInputSystem@InputManager@OIS@@SAXPAV12@@Z) referenced in function "public: virtual void __thiscall ExampleFrameListener::windowClosed(class Ogre::RenderWindow *)" (?windowClosed@ExampleFrameListener@@UAEXPAVRenderWindow@Ogre@@@Z)
4>GranTurismOgre.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class OIS::InputManager * __cdecl OIS::InputManager::createInputSystem(class std::multimap<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &)" (__imp_?createInputSystem@InputManager@OIS@@SAPAV12@AAV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z) referenced in function "public: __thiscall ExampleFrameListener::ExampleFrameListener(class Ogre::RenderWindow *,class Ogre::Camera *,bool,bool,bool)" (??0ExampleFrameListener@@QAE@PAVRenderWindow@Ogre@@PAVCamera@2@_N22@Z)


Edit: Which can be fixed by adding OIS_d.lib to additonal library files

SimpleScenes wont run cause it cant find material 1 - Default .
Right now trying to run landscape demo but I cant find landscape5.cfg ...
Found it...running landscape demo...I see it has given exception..

Landscape demo is now running...it only works if I run it using OpenGL though, when i try running it using Directx it gives exception that it failed to draw primitive.