[SOLVED]Cube seems to be moving

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
onesixtyfourth
Posts: 21
Joined: Mon Nov 03, 2008 10:18 am

[SOLVED]Cube seems to be moving

Post by onesixtyfourth »

I have added a cube to a scene (I am simply using the quake castle scene from tut 2) and I am rotating it. No problem in that but as I move the camera around the cube appears to be changing position. Is it just appearing to do so or has anyone seen this before?

Code I use to add cube

Code: Select all

 
//add cube seems to be moving
    scene::ISceneNode *cubeOne = smgr->addCubeSceneNode(10.0f, 0, -1,
                                                    core::vector3df(10,10,5),
                                                        core::vector3df(0,0,0),
                                            core::vector3df(0.25f,0.25f,0.25f));
 
I am using rotation function I found here and the movement seems to occur whether or not I am using this.
Last edited by onesixtyfourth on Fri Oct 07, 2011 2:44 pm, edited 1 time in total.
Glasys
Noli illegitimi carborundum
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Cube seems to be moving

Post by mongoose7 »

Your cube is not at the origin of your node. If you rotate the node, the cube will describe a circle.

Put the cube at the centre of the node and then translate the node.
onesixtyfourth
Posts: 21
Joined: Mon Nov 03, 2008 10:18 am

Re: Cube seems to be moving

Post by onesixtyfourth »

Well the cube rotates ok the movement appears to be from the camera perspective. So if I stay still and view the cube it rotates nicely. If I move the camera the cube appears to alter position and even size.
Glasys
Noli illegitimi carborundum
onesixtyfourth
Posts: 21
Joined: Mon Nov 03, 2008 10:18 am

Re: Cube seems to be moving

Post by onesixtyfourth »

Well you seem to have been correct as I now create the cube with no arguments and the movement seems to have gone. I am now altering the position of the node with set position after creation which is what I thought I was doing with the args. :?
Glasys
Noli illegitimi carborundum
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Cube seems to be moving

Post by mongoose7 »

OK. You didn't show the camera creation. Irrlicht's cameras are really weird.

Err, I don't want to see any more code, though! :-)
Post Reply