Hello again,
I am still working around my collision issue from my previous post (http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=8484) and I'm now playing around using raycasting, however... it seems I was unclear on how Bullet handled rays. Since I'm just a hobbyist, I am stuck trying to remember my high school math class and how to resolve a bodies pitch, yaw, and roll, into normals so I can set the ray to test in the direction of the projectiles.
The wrapper I am using is doing this using btRaySetDirection(int ray, float nx, float ny, float nz ) - How would I translate my projectiles body rotation (for example: a bodies rotation set to 45,15,0) into these values so that the ray is testing in the direction it is facing?
Translating a bodies orientation to vector for Raycasting?
-
- Posts: 4
- Joined: Fri Oct 05, 2012 7:56 am
-
- Posts: 10
- Joined: Mon Sep 03, 2012 12:09 am
Re: Translating a bodies orientation to vector for Raycastin
In order to get the direction the object is traveling in, I use:
where quat is the orientation of your object represented by a Quaternion, and where Vector3::UNIT_Z is a prettier way of writing a unit z vector, which would be (0, 0, 1).
Taking a guess, I'm thinking you would use the resulting direction vector in your function like so: btRaySetDirection(1337, dirvec.x, dirvec.y, dirvec.z);
Good luck on your project!
Code: Select all
dirvec = quat * Vector3::UNIT_Z;
Taking a guess, I'm thinking you would use the resulting direction vector in your function like so: btRaySetDirection(1337, dirvec.x, dirvec.y, dirvec.z);
Good luck on your project!