Rotation problem

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
razi3l
Gnoblar
Posts: 8
Joined: Fri Mar 18, 2005 11:42 pm

Rotation problem

Post by razi3l »

I don't know is there a bug in ogre or i'm doing something wrong.
I'm trying to create FPS game. I created scene node and atached weapon and camera to it. Camera is set to the same position as SceneNode and weapon moved to the right. But when i rotate scene node camera is not acting as it should. for example: when i move mouse to the right camera is not moved to the right but to the right AND down.
When i move only camera without attaching it to the SceneNode everything is right.
Is there difference in rotation of SceneNode and Camera...
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus
Contact:

Post by SuprChikn »

The camera can have it's own rotation.
For the purposes you're using here (camera is the player, with weapon attached there), don't rotate the camera. Do the rotation and movement through the scene node it's attached to.
User avatar
razi3l
Gnoblar
Posts: 8
Joined: Fri Mar 18, 2005 11:42 pm

Post by razi3l »

i know i need rotate scene node. I already do that, but still it doesn't work.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

razi3l, just before you attach the camera to the scenenode, do the following:

Code: Select all

camera->setPosition(Vector3::ZERO);
camera->setOrientation(Quaternion::IDENTITY);
Else you have the old values, that were there before as an offset and the camera does not behave as expected. If you use the example framework, the camera is indeed moved without a scenenode in the scene setup.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
razi3l
Gnoblar
Posts: 8
Joined: Fri Mar 18, 2005 11:42 pm

Post by razi3l »

I've just try that and it doesn't work.

Code: Select all

m_pControlNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode();
	m_pControlNode->setPosition( 0, 0, 0 );
	m_pCamera->setPosition( Vector3::ZERO );
	m_pCamera->setOrientation( Quaternion::IDENTITY );
	m_pControlNode->attachObject( m_pCamera );	
	m_pWeaponNode = m_pControlNode->createChildSceneNode();
	m_pWeaponNode->attachObject( m_pWeapon );
	m_pWeaponNode->setPosition( 2, -1.5, -5 );
	m_pWeaponNode->yaw( (Radian)Math::PI );
.
.
.

Code: Select all

m_pControlNode->setPosition( m_Player.vPosition );
	m_pControlNode->lookAt( vLookAt, Node::TransformSpace::TS_WORLD );
I've also tried with TS_LOCAL and TS_PARENT.
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus
Contact:

Post by SuprChikn »

If that lookAt isnt pointing you in the right direction, I can only imagine that vLookAt is not correct.
What are you setting it to?
User avatar
razi3l
Gnoblar
Posts: 8
Joined: Fri Mar 18, 2005 11:42 pm

Post by razi3l »

Sory i didn't answered before.
Yes vLookAt is pointing in right direction. I tried it with camera, without
attaching it to the SceneNode and it works ok.
I also tried setting camera and scenenode, (not attached) at the same position and same rotation. They both rotate BUT they don't acting the same way. Camera is always little "faster" than scenenode.
Sinjaph
Kobold
Posts: 29
Joined: Tue Apr 12, 2005 11:41 pm

Post by Sinjaph »

User avatar
BlasterN
Gnome
Posts: 378
Joined: Thu Mar 24, 2005 1:07 am
Location: Spain
Contact:

Post by BlasterN »

you have to offset your model for the weapon ( i don't know how much ). with that you can rotate camera & the model at the same time and work perfectly.

With the code in the post left by Sinjaph you can do it.

BTW. try OgreOde have a little example, the ragdoll one, that is a little fps. http://www.green-eyed-monster.com/
Works:
MapToMesh | Bengine B9 @ www.sourceforge.net/projects/maptoogremesh/
3DWorldStudio exporter@ www.blastern.info
Post Reply