Camera attached to something else?

Problems building or running the engine, queries about how to use features etc.
Post Reply
capture
Goblin
Posts: 237
Joined: Sun Nov 20, 2005 2:44 pm

Camera attached to something else?

Post by capture »

I am trying to attach my camera to a follownode for my camera system.

Code: Select all

mFollowNode->attachObject(mCamera);
The problem is when I run the program, it crashes and the Ogre log states some error about camera already being attached to an object.

Code: Select all

OGRE EXCEPTION(2:InvalidParametersException): Object already attached to a SceneNode
I've ran a search in my code for "attachObject", and the only time i attached anything was the camera and the follow node once.

Any one have any ideas what the problem might be, or how i should go about debugging it?
User avatar
Kaelic
Halfling
Posts: 95
Joined: Tue May 15, 2007 1:32 pm
Location: Guildford, UK

Post by Kaelic »

Can we see all of the code relating to the camera?
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: Camera attached to something else?

Post by nullsquared »

capture wrote:

Code: Select all

OGRE EXCEPTION(2:InvalidParametersException): Object already attached to a SceneNode
I'm pretty sure Ogre gives you the name of the attached object with that exception, did it?
capture
Goblin
Posts: 237
Joined: Sun Nov 20, 2005 2:44 pm

nope

Post by capture »

Nope, it doesn't.
Here is the full line.

Code: Select all

08:07:22: OGRE EXCEPTION(2:InvalidParametersException): Object already attached to a SceneNode or a Bone in SceneNode::attachObject at e:\ogre3d\ogrenew\ogremain\src\ogrescenenode.cpp (line 127)
holymoly
Gnoblar
Posts: 7
Joined: Tue May 27, 2008 10:18 am

Post by holymoly »

if such things happens, try the following approch,

first : get parent node of the camera
second : detach the camera you want to make another attach
third : attach the camera to the new node.

this will work in most acations
User avatar
jacobb
Greenskin
Posts: 127
Joined: Tue Feb 14, 2006 1:34 am
Location: Orlando, FL
x 1

Post by jacobb »

Would seem that your camera is already attached to a scene node. It can't be attached to two different nodes at the same time, which is what ogre is trying to tell you.

Either detach camera from the node its already attached to before attaching it to the new node OR add the node the camera is already attached to as a child of the new node, which will have the same effect.

See api docs for SceneNode::attachObject, SceneNode::detachObject, and SceneNode::addChild
find / -name base -exec chown -R us {} ';'
Check the API | Read the Manual | Browse the Wiki
capture
Goblin
Posts: 237
Joined: Sun Nov 20, 2005 2:44 pm

Sorry

Post by capture »

Sorry every one, I found the problem. I was trying to attach the object inside of a loop, and this created an error.
Post Reply