Attach Camera to Scene Node

quasarchangel

13-03-2008 17:37:29

This is not directly related to OgreNewt but I am using it with my application and the ExampleFramework.

I am trying to attach the camera to a SceneNode object but I am getting the following exception:
OGRE EXCEPTION(2:InvalidParametersException): Object already attached to a SceneNode or a Bone in SceneNode::attachObject at c:\development\game development\projects\ogre\ogrenew\ogremain\src\ogrescenenode.cpp (line 127)

This is my attach code:
mPlayer->mNode->attachObject(mCamera);
and this is the createCamera function:
void ExampleApplication::createCamera(void)
{
mCamera = mSceneMgr->createCamera("Camera");

mCamera->setPosition(Vector3(50,50,50));

mCamera->lookAt(Vector3(0,0,0));
mCamera->setNearClipDistance(5);
}

Now I have not attached the camera to any nodes but I'm getting this error. Any ideas why?

quasarchangel

13-03-2008 17:49:23

lol, I placed my attach code inside the frameStarted function... so its fixed now.