Camera strafe

View previous topic View next topic Go down

Camera strafe

Post  _-MADMAN-_ on Wed May 27, 2009 5:37 am

How Can I get camera strafe directions? I have tried this:

Code:
btVector3 bslide (sio2->_SIO2camera->_SIO2transform->dir->x*90.0f, sio2->_SIO2camera->_SIO2transform->dir->y, sio2->_SIO2camera->_SIO2transform->dir->z);

Works weel until I rotate the camera - bslide doesn't update, it's always the same world direction. Also tried to flip x with y with no succes (bugs between 0-90-180-360 angles).

Any advice will be great!

Regards,
Mad

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: Camera strafe

Post  sio2interactive on Wed May 27, 2009 5:39 am

Calculate the cross product of the direction vector of the camera and the up vector...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Camera strafe

Post  _-MADMAN-_ on Wed May 27, 2009 8:56 am

Works perfectly:

Code:

      btVector3 bforward (sio2->_SIO2camera->_SIO2transform->dir->x,
                     sio2->_SIO2camera->_SIO2transform->dir->y,
                     sio2->_SIO2camera->_SIO2transform->dir->z);
      
      btVector3 bside (0.0,
                   0.0,
                   1.0);
      
      btVector3 bslide = cross(bforward, bside);

Thank You!

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: Camera strafe

Post  swebal on Thu Oct 08, 2009 9:14 am

Thanks for that!

swebal

Posts : 5
Join date : 2009-10-08

View user profile

Back to top Go down

Re: Camera strafe

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum