I'm pretty new to 3D programming, so my problem might be easy for you to solve, but I don't really have any more ideas how I can solve it.
I have a flat boxed object which I move around on a surface (bound to a environment collision). Now I want to add several raytests to the box model to check for collision with the environment.
I have access to the Object-translation (a 3x4 matrix). Now I thought a good idea would be to make ray-based collisiontests on each border of the object (so 8 tests in total)
I calculate these positions using the center of my box object and adding / subtracting length or depth from this position.
e.g.
v3CenterPos(0.0, 0.0, 0.0)
length = 10.0
depth = 5.0
testing positions:v3TopLeft = v3CenterPos.x - (length / 2.0), v3CenterPos.y, v3CenterPos.z - (depth / 2.0)v3TopCenter = v3CenterPos.x, v3CenterPos.y, v3CenterPos.z - (depth / 2.0)v3TopRight = v3CenterPos.x + (length / 2.0), v3CenterPos.y, v3CenterPos.z - (depth / 2.0)v3CenterLeft = v3CenterPos.x - (length / 2.0), v3CenterPos.y, v3CenterPos.zv3CenterRight = v3CenterPos.x + (length / 2.0), v3CenterPos.y, v3CenterPos.zv3BottomLeft = v3CenterPos.x - (length / 2.0), v3CenterPos.y, v3CenterPos.z + (depth / 2.0)v3BottomCenter = v3CenterPos.x, v3CenterPos.y, v3CenterPos.z + (depth / 2.0)v3BottomRight = v3CenterPos.x + (length / 2.0), v3CenterPos.y, v3CenterPos.z + (depth / 2.0)
In the image the red dots are the positions calculated the way described above. This works fine when the box object is not rotated (here is my problem)
How do I calculate the test positions (marked as blue dots in the image) when the object itself is rotated by an unknown angle? (I know this angle should be accessable from the 3x4 matrix, but I don't know how to use it to calculate the proper vector positions.
I hope my writing does make any sence ;)
Thx for your help!
-Zerd