mistigrii33
04-12-2011 23:42:03
Hi,
I'm trying to implements a camera collision for a 3rd person game for it not to pass through the walls when my character is moving.
I have an AnimatedCharacter, which create a cameraNode that my camera is attached to.
Then, i try to folow these two posts http://www.ogre3d.org/addonforums/viewtopic.php?f=6&t=11126&p=63928&hilit=camera+camera+collision#p63928 and http://www.ogre3d.org/addonforums/viewtopic.php?t=7615, and create a BodyDescription, that i add my cameraNode and create a Body with that.
Unfortunately, the result isn't as expected and i'm dealing with a body (seen in the debugger) in the middle of my terrain which is not related in any way to my camera...
Why does the body i just created isn't at the same place than the camera node ? What am i missing ?
Here is my code (a quick rewrite to make it simple) (Using NxOgre 1.7) :
Thanks !
I'm trying to implements a camera collision for a 3rd person game for it not to pass through the walls when my character is moving.
I have an AnimatedCharacter, which create a cameraNode that my camera is attached to.
Then, i try to folow these two posts http://www.ogre3d.org/addonforums/viewtopic.php?f=6&t=11126&p=63928&hilit=camera+camera+collision#p63928 and http://www.ogre3d.org/addonforums/viewtopic.php?t=7615, and create a BodyDescription, that i add my cameraNode and create a Body with that.
Unfortunately, the result isn't as expected and i'm dealing with a body (seen in the debugger) in the middle of my terrain which is not related in any way to my camera...
Why does the body i just created isn't at the same place than the camera node ? What am i missing ?
Here is my code (a quick rewrite to make it simple) (Using NxOgre 1.7) :
class MyCharacter : public AnimatedCharacter
{
public void attachCamera(Ogre::Camera* mCamera)
{
//create the cameraNode, place it just behind the character. mNode is the AnimatedCharacter node
cameraNode = mNode->createChildSceneNode();
cameraNode->setPosition(Ogre::Vector3(0, 8, -16));
cameraNode->attachObject(mCamera);
//create a critter::node to give it to the bodyDesc then it'll be related to cameraNode
Critter::Node* camNode = new Critter::Node(mSceneMgr, cameraNode, mRenderSystem);
Critter::BodyDescription bodyDesc;
bodyDesc.mMass = 1.0f;
bodyDesc.mDensity = 0.0f;
bodyDesc.mDynamicRigidbodyFlags |= NxOgre::DynamicRigidbodyFlags::FreezeRotation;
bodyDesc.mDynamicRigidbodyFlags |= NxOgre::DynamicRigidbodyFlags::DisableGravity;
bodyDesc.mNode = camNode;
NxOgre::SphereDescription sphereDesc;
sphereDesc.mRadius = 10.0;
sphereDesc.mMass = 1.0f;
sphereDesc.mDensity = 0.0f;
Critter::Body* b = mRenderSystem->createBody(sphereDesc, NxOgre::Vec3(0,1,0), "", bodyDesc);
}
}
Thanks !