Hi all,
My lead object has a rotation I cam access via:
obj->_SIO2objectphysic->_btRigidBody->getWorldTransform().getBasis();
And a direction facing/moving vector btVector3 facing
I wish to raycast from this main object but ahead of itself and in the direction facing and slightly lower than it's current Z
I assume I have all the information I need to do this without resulting to sin/cos and moving the end ray point around in a standard manner.
Just a bit lost on how I use the main character's orientation/facing vector to position the ray endpoint.
Any help appreciated.
Cheers
Raycasting ahead of moving object
-
markhula
- Posts: 34
- Joined: Thu Jun 17, 2010 10:11 am
Re: Raycasting ahead of moving object
Hi all,
I've achieved almost what I want with :
btVector3 b;
btTransform tr;
tr= obj->_SIO2objectphysic->_btRigidBody->getWorldTransform();
b=tr.getOrigin();
float ya,pi,ro;
orn.getEuler(ya,pi,ro);
b.setX(b.getX()+cos(pi));
b.setY(b.getY()+sin(pi));
As I assume it's a quaternion being converted to euler it only works for half the rotation. What do I do to make the other half ok? (as quats only do upto 180 degrees I believe....)
Secondly; this seems really, really inefficient - is there a better way???? - is it better to rotate with the quaternion returned rather than convert via geteuler? (if so how)
Thanks in advance
I've achieved almost what I want with :
btVector3 b;
btTransform tr;
tr= obj->_SIO2objectphysic->_btRigidBody->getWorldTransform();
b=tr.getOrigin();
float ya,pi,ro;
orn.getEuler(ya,pi,ro);
b.setX(b.getX()+cos(pi));
b.setY(b.getY()+sin(pi));
As I assume it's a quaternion being converted to euler it only works for half the rotation. What do I do to make the other half ok? (as quats only do upto 180 degrees I believe....)
Secondly; this seems really, really inefficient - is there a better way???? - is it better to rotate with the quaternion returned rather than convert via geteuler? (if so how)
Thanks in advance
-
markhula
- Posts: 34
- Joined: Thu Jun 17, 2010 10:11 am
Re: Raycasting ahead of moving object
Ok, got it working.
But again, it seems a really inefficient way; is there a better method?
Which is more expensive a raycast or having a dummy collision object in front the object and looking at that for collisions??
Thanks
But again, it seems a really inefficient way; is there a better method?
Which is more expensive a raycast or having a dummy collision object in front the object and looking at that for collisions??
Thanks