i got a Transformspace problem i think

Problems building or running the engine, queries about how to use features etc.
Meddten
Halfling
Posts: 71
Joined: Mon Aug 09, 2004 8:28 pm
Location: Austria

i got a Transformspace problem i think

Post by Meddten »

Hello,

following code

Code: Select all

class PostProcessListener : public ExampleFrameListener
{
protected:
public:

	PostProcessListener(RenderWindow* win, Camera* cam) : ExampleFrameListener(win, cam)
	{
	}

	bool frameStarted(const FrameEvent& evt)
	{
		mainLightNode->rotate(Vector3::UNIT_Y, Degree(300 * evt.timeSinceLastFrame), SceneNode::TS_WORLD);


		return ExampleFrameListener::frameStarted(evt);
	}
};
I have a mesh file attached to mainLightNode, the startup translation in createScene is Vector3(300, 0, 0)

So mainLightNode starts 300 units right of origin

With the framelistener code above i want to achieve that mainLightNode is rotating around the origin, around the world y axis. But it is only rotating around itselfs y axis still at 300, 0, 0

I have looked at the dot3bump demo (wiht rotating lights) but i´m doing exactly the same thing.

I think it has something to do with my ogre 1.0.0
Is this thing working different in this version of ogre?

How can i rotat around the worlds/origins y axis?


Thanks in advance
Meddten
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8

Post by haffax »

Make the mainLightNode a child of another node. Translate the mainLightNode away in the desired direction and distance. Then rotate its parent.
team-pantheon programmer
creators of Rastullahs Lockenpracht
Meddten
Halfling
Posts: 71
Joined: Mon Aug 09, 2004 8:28 pm
Location: Austria

Post by Meddten »

I thought i have done that

See here

Code: Select all

mainLightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("mainLightNode");

mainLightNode->attachObject(mainLight);
mainLightNode->attachObject(lightDebug1);
mainLightNode->translate(Vector3(300, 0, 0));
Where mainLight is a Light and lightDebug1 is a Entity with the mesh file
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8

Post by haffax »

No this is not what I meant.
The origin of the SceneNode's coordinate system is the centre of the rotation, translate it away and you traslate the rotation centre away too.

Try this setup:

Code: Select all

rotNode = mSceneMgr->getRootSceneNode()->
    createChildSceneNode("rotNode"); 

mainLightNode = rotNode->createChildSceneNode("mainLightNode",
   Vector3(300, 0, 0));

...
// apply rotation *not* to mainLightNode but to rotNode
rotNode->yaw(Degree(300 * evt.timeSinceLastFrame));
team-pantheon programmer
creators of Rastullahs Lockenpracht
Meddten
Halfling
Posts: 71
Joined: Mon Aug 09, 2004 8:28 pm
Location: Austria

Post by Meddten »

Oh :)

thanks you very much its working now