Greeting,
I'm writing First Person Shooter and implementing FPS camera system using tutorial here.
http://www.ogre3d.org/tikiwiki/tiki-ind ... era+system
but I want camera moving by sticking to the ground. (parallel to the ground.). but whenever I try to look right/left (Yaw/Pitch) operation.
then try to do move operation, camera starts flying.
How do I control the camera, so camera move parallel to the ground ?
Thanks.
FPS - camera move parallel to the ground.
-
- Gnoblar
- Posts: 6
- Joined: Mon Sep 24, 2012 4:43 pm
-
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
Re: FPS - camera move parallel to the ground.
Put the camera in a scenenode. Mouse tilt is applied only to the camera, while yaw is applied to the scenenode (with y axis constraint).
Movement keys move only the scenenode.
Edit: there is enough material already on this
http://www.ogre3d.org/tikiwiki/tiki-ind ... era+system
http://www.ogre3d.org/addonforums/viewtopic.php?t=1261
Ogre CCS also implements a first-person camera: http://ogre-ccs.sourceforge.net/?q=node/12
Movement keys move only the scenenode.
Edit: there is enough material already on this
http://www.ogre3d.org/tikiwiki/tiki-ind ... era+system
http://www.ogre3d.org/addonforums/viewtopic.php?t=1261
Ogre CCS also implements a first-person camera: http://ogre-ccs.sourceforge.net/?q=node/12
Developer @ MakeHuman.org
-
- Gnoblar
- Posts: 6
- Joined: Mon Sep 24, 2012 4:43 pm
Re: FPS - camera move parallel to the ground.
Thanks for the reply, I am following same tutorial that you've mentioned in your reply.
But i m trying give touch inputs from UIView (overly over Ogre) in my iPhone application.
Below is code from my TouchView class's touchesMoved method.
And here is my application's handleTouchInput method.
above code is giving very odd camera movement. camera is continuously rotating around x axis.
When I use OIS input system that comes with the default XCode template it works fine because it passes correct Relative coordinates,
but I don't know how to pass correct Relative coordinates from UITouch. That's why I think my tilt ( not able to look left/right/up/down) movement is not working.
How do i pass correct Relative coordinates from UITouch ?
But i m trying give touch inputs from UIView (overly over Ogre) in my iPhone application.
Below is code from my TouchView class's touchesMoved method.
Code: Select all
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
NSSet *allTouches = [event allTouches];
for (UITouch *touch in allTouches) {
if ([touch hash] == rotationPadHash && rotationPadMoving ){
CGPoint touchLocation = [touch locationInView:self];
float rotationdx = (float)rotationPadCenterx - (float)touchLocation.x;
float rotationdy = (float)rotationpadCentery - (float)touchLocation.y;
rotationPadCenterDistance = sqrtf((rotationPadCenterx - touchLocation.x) * (rotationPadCenterx - touchLocation.x) +
(rotationpadCentery - touchLocation.y) * (rotationpadCentery - touchLocation.y));
roationAngle = atan2(rotationdy,rotationdx);
applicationRef->handleTouchInput(rotationdy, rotationdy);
Code: Select all
void ShootEmUp::handleTouchInput(Ogre::Real x , Ogre::Real y) {
OIS::MultiTouchState state;
int origTransX = 0, origTransY = 0;
origTransX = x;
origTransY = y;
state.X.rel = -origTransY;
state.Y.rel = origTransX;
OIS::MultiTouchEvent event(NULL,state);
m_pCamera->yaw(Degree(state.X.rel * -.1));
m_pCamera->pitch(Degree(state.Y.rel * -.1));
}
When I use OIS input system that comes with the default XCode template it works fine because it passes correct Relative coordinates,
but I don't know how to pass correct Relative coordinates from UITouch. That's why I think my tilt ( not able to look left/right/up/down) movement is not working.
How do i pass correct Relative coordinates from UITouch ?
-
- Gnoblar
- Posts: 6
- Joined: Mon Sep 24, 2012 4:43 pm
Re: FPS - camera move parallel to the ground.
Just looked at the OIS source code. this solved the problem.

Code: Select all
void iPhoneMultiTouch::_touchMoved(UITouch *touch)
{
CGPoint location = [touch locationInView:static_cast<iPhoneInputManager*>(mCreator)->_getDelegate()];
CGPoint previousLocation = [touch previousLocationInView:static_cast<iPhoneInputManager*>(mCreator)->_getDelegate()];
MultiTouchState newState;
newState.X.rel = (location.x - previousLocation.x);
newState.Y.rel = (location.y - previousLocation.y);
newState.X.abs = location.x;
newState.Y.abs = location.y;
newState.touchType |= 1 << MT_Moved;
if( mListener && mBuffered )
{
mListener->touchMoved(MultiTouchEvent(this, newState));
}
else
{
mStates.push_back(newState);
}
}