Camera issue

Maroho

11-06-2010 17:19:33

I'm making a Marble Madness type game and I want to use a third person viewpoint. Obviously I'm able to do with with Ogre by attaching the camera to the scene node using attachObject, however when I implemented OgreNewt the player object just falls through the geometry as if no collision has taken place. If I remove the camera from the scene node the collision works again, so that's where the problem is.

This section of code is where it all happens:

mPlayerEntity = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Cylinder", "marble2.mesh");
mPlayerNode = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Cylinder");
mPlayerNode->attachObject(mPlayerEntity);
mPlayerNode->setPosition(Ogre::Vector3(1520, 410, 1450))
mPlayerNode->attachObject(OgreFramework::getSingletonPtr()->m_pCamera);
spinner = PrimitiveFactory::getSingleton().createEllipsoid(mPlayerNode, 100);
spinner->setAutoSleep(0);


Any ideas? Is it a glitch, or have I done something wrong?

SFCBias

11-06-2010 22:19:40

Its quite hard for me to try and diagnose this problem, kallaspirit may know what the problem is but try taking out "spinner->setAutoSleep(0)"

*EDIT* also looking at your code again, try attaching the camera to a child node of the playerNode rather than directly to the playerNode, i haven't got time to look at the Primitive-factory code for Ellipsoid creation at the moment but that may be the problem so use

mPlayerNode->createChildNode()->attachObject(OgreFramework->getSingletonPtr()->m_pCamera);

Maroho

12-06-2010 00:33:52

Attaching the camera as a child node fixes the problem, thanks.

I have another issue now though; the camera spins with the marble, probably because I'm calling the player node when creating the ellipsoid. Any idea how I can get the camera to just follow behind like in 3rd person?

SFCBias

13-06-2010 04:15:58

on the child node call setInheritRotation(false); (this is straight from my head but there is a function along those lines)

Maroho

13-06-2010 13:08:00

That gets rid of the camera rotation around the marble, but the camera still bobs around when the marble rotates.

Here's the code I have now:

mPlayerEntity = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Cylinder", "marble2.mesh");
mPlayerNode = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Cylinder");
mPlayerNode->attachObject(mPlayerEntity);
mPlayerNode->setPosition(Ogre::Vector3(1520, 410, 1450));
cNode = mPlayerNode->createChildSceneNode("cNode");
cNode->attachObject(OgreFramework::getSingletonPtr()->m_pCamera);
cNode->setInheritOrientation(false);
spinner = PrimitiveFactory::getSingleton().createEllipsoid(mPlayerNode, 100);


Thanks for all your help so far.

SFCBias

14-06-2010 02:43:04

Umm i can't really explain that but id just play around with the child node settings or maybe the camera itself but thats about all i can tell you..sorry

mvelazquezm

16-06-2010 11:51:50

I will use this Ogre Camera Control System, try with it.

http://ogre-ccs.sourceforge.net/

Greetings