Unresolved External Symbol... And minor project bugs

denreaper

07-06-2006 03:47:53

I've been working on a test project... It is sort of a test of player movement using Ogre3D+OgreNewt. Working with it thus far has been extremely enjoyable. One problem I came across was translating my playerSceneNode while applying setStandardForceCallback() to it's OgreNewt body. My workaround was to translate the body itself by updating setPositionOrientation() with the playerSceneNode's getPosition() followed by where I wanted to move it. This worked fine with the physics, however, once my playerSceneNode had rested on the ground, it seemed as if freeze() was called for the playerBody. So, I attempted to add unFreeze() to the frameStarted() boolean in order to keep the playerBody() from freezing so the physics would always effect the player. This resulted in the following unresolved external symbol:
error LNK2019: unresolved external symbol __imp__NewtonWorldUnfreezeBody referenced in function "public: void __thiscall OgreNewt::Body::unFreeze(void)" (?unFreeze@Body@OgreNewt@@QAEXXZ)
I have tried using the command playerBody->unFreeze(); outside of the main frame loop, but it does the same thing. The only thing that it seems it could be is a missing library. I haven't gotten any errors with the SDK up to this point, so it seems wierd for it to do it now.

Another issue I had was with the camera following the playerSceneNode. I have set it up so every time the frame updates, the camera's position updates to a position relative to the playerSceneNode. This seems to work, but the camera is glitching when physics effect the playerBody. It seems as if the physics are updating the position of the playerBody more than every frame, which doesn't seem logical. If you need more information, please say so. I can send you a zipped up package of the project so you can see what I mean by the camera issue. I can also paste of my coding on here if that helps as well.

Thanks,
Denny

walaber

07-06-2006 04:32:39

you must have a problem with your version of the Newton SDK, that function should be there.

note that you can also use "setAutoFreeze(0)" during body setup, to keep it from freezing on you.

also, you really shouldn't move an object by calling setPositionOrientation manually... please search this and the Newton forum , you will find lots of reasons why I say this, and also lots of solutions for moving objects with a physics engine.

denreaper

07-06-2006 06:59:30

Thank you for your swift and accurate response, walaber. I'll search around for a different method of moving my object. I fixed the problem with the unresolved external symbol by including Newton.lib in my linker input. If anyone has any suggestions about the camera issue, I would be extremely greatful. Thank you very much for your help thus far.
-Denny

abecam

07-06-2006 10:49:30

I attached also my camera to my moving object in a similar way:


msnCam = (container->getOgreNode())->createChildSceneNode("CameraNode");
msnCam->attachObject( mCamera );


And it works well... Even when this object is falling, hit...
So it can work, let try to find your problem elsewhere. I guess the setPosition Orientation might be the cause. Walaber already explained that (it is why I know that), if you do that, you go against the physics simulation, so it glitches!

Another part of (working) code using addForce in the callback (my camera is attached to an object linked by a joint to the "handler" I define here):



void OgreNewtonApplication::createScene()
{
...

Ogre::Quaternion orientHandle ( Ogre::Vector3(0,0,0),Ogre::Vector3(0,1,0),Ogre::Vector3(0,0,0) );
handleBox = makeSimpleEll(Ogre::Vector3(0.5,1,0.5), Ogre::Vector3(0,42.5,0),orientHandle,rigiBodyNod);


LogManager::getSingleton().logMessage(" Create the exchange object ");
mesInteractions.setForceTrans(Ogre::Vector3(0,0,0));
LogManager::getSingleton().logMessage(" Pass it to the handleBox body ");
handleBox->setUserData(&mesInteractions);
LogManager::getSingleton().logMessage(" Set the custom callback ");
handleBox->setCustomForceAndTorqueCallback<OgreNewtonApplication>(userForceCallback,this);
handleBox->setAutoFreeze(0);

...
}



void OgreNewtonApplication::userForceCallback(OgreNewt::Body* me)
{
Ogre::Real mass;
Ogre::Vector3 inertia;

Interactions * interactions= (Interactions *)(me->getUserData());

me->getMassMatrix(mass, inertia);
me->addForce(Ogre::Vector3(0,-1,0)*mass*9.8);
me->addForce((interactions->getForceTrans())*mass*9.8);

}


FrameListener:


OgreNewtonFrameListener::OgreNewtonFrameListener(RenderWindow* win, Camera* cam, SceneManager* mgr, OgreNewt::World* W, SceneNode* ncam, OgreNewt::Body * cont) :
ExampleFrameListener(win,cam)
{
...

LogManager::getSingleton().logMessage(" Recover the interaction object ");
if ( handler == NULL)
LogManager::getSingleton().logMessage(" Error - No instance of handler");
listenerInteractions = (Interactions *)(handler->getUserData());

...
}

bool OgreNewtonFrameListener::frameStarted(const FrameEvent &evt)
{

if (mInputDevice->isKeyDown(Ogre::KC_W))
{
listenerInteractions->setForceTrans(Ogre::Vector3(0,0,-0.5));
}


if (mInputDevice->isKeyDown(Ogre::KC_S))
{
listenerInteractions->setForceTrans(Ogre::Vector3(0,0,0.5));
}

if (mInputDevice->isKeyDown(Ogre::KC_A))
{
listenerInteractions->setForceTrans(Ogre::Vector3(-0.5,0,0));
}

if (mInputDevice->isKeyDown(Ogre::KC_D))
{
listenerInteractions->setForceTrans(Ogre::Vector3(0.5,0,0));
}
}


(Don't worry, I have other parts which are NOT working... That's life... :roll: )