Camera Movement Question

Problems building or running the engine, queries about how to use features etc.
User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Camera Movement Question

Post by Robomaniac »

I'm attempting to implementi something similar to this : http://www.thethirdreich.com/forum/dloa ... file_id=21 into Centaur Force. Basically, I want to have a box in which the gun is able to move freely (arms and gun move to "point" in that direction) without moving the view. (The Video Exemplifies this nicely)

My First Attempt Failed, and I'm wondering if I'm missing something:

Code: Select all

bool Camera::HandleEvent(Event e)
	{
		if (e.m_Recipient == m_Name || e.m_Recipient == "All")
		{
			if (e.m_Event == "Cam_Move")
				m_CameraNode->translate(Ogre::StringConverter::parseVector3(e.m_Data), Ogre::SceneNode::TS_LOCAL);

			if (e.m_Event == "Cam_Pitch")
			{
				float move = Ogre::StringConverter::parseReal(e.m_Data) * -0.13;
				m_MouseY += move;

				if (m_MouseY <= m_BoxSize.y && m_MouseY >= 0)
				{
					//Mouse just moved inside the box, just update the look at
					m_CurrentChild->GetNode()->lookAt(Ogre::Vector3(m_MouseX, m_MouseY, -100), Ogre::SceneNode::TS_LOCAL);
				}
				else if (m_MouseY <= 0 || m_MouseY >= m_BoxSize.y)
				{
					//Thinking outside the box, reset the mouse so the cursor doesn't go outside the box
					m_MouseY -= move;

					// yaw it
					m_CameraNode->pitch(Ogre::Degree(move), Ogre::SceneNode::TS_LOCAL);
				}
			}

			if (e.m_Event == "Cam_Yaw")
			{
				float move = Ogre::StringConverter::parseReal(e.m_Data) * -0.13;
				m_MouseX += move;

				if (m_MouseX <= m_BoxSize.x && m_MouseX >= 0)
				{
					//Mouse just moved inside the box, just update the look at
					m_CurrentChild->GetNode()->lookAt(Ogre::Vector3(m_MouseX, m_MouseY, -100), Ogre::SceneNode::TS_LOCAL);
				}
				else if (m_MouseX <= 0 || m_MouseX >= m_BoxSize.x)
				{
					//Thinking outside the box
					m_MouseX -= move;

					// yaw it
					m_CameraNode->yaw(Ogre::Degree(move), Ogre::SceneNode::TS_WORLD);
				}
			}
		}
		return true;
	}
m_BoxSize is a Vector3, m_MouseX and m_MouseY are floats set to BoxSize.x / 2; and BoxSize.y /2; respectively

The weapon basically moves around like somone who just drank a liter of espresso at once. It also blinks very fast when i just start :\

I'll see if i can make a little movie of the behavior sometime tonight.

I just want to see if there was anything that i missed in my first attempt thats obvious :)

-- The Robomaniac
phear hingo

My Webpage
User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

To Clarify on

"Moves around like a person who just drank a liter of espresso"

Basically, when i reach the edge of the box, the gun doesn't move (like it should) but it doesn't accpept Rotations

...

which is b/c i'm lookin at that point still

*codes*

AHA

I fixed it, i just had to yaw and pitch instead of look at and it works fine

*does a happy dance*
phear hingo

My Webpage
User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

Alright, another problem, well, not really a problem, but an though

Is there a way i can easily get a node to rotate around a single point?

Like instead of rotating from the end, it rotates around a defined point?
phear hingo

My Webpage
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Rotations always occur around the centre. If you want to offset it, just create a child node and attach the 'orbiter' to it.

I really don't follow your previous question, but since you fixed it I'll let it pass.