|
Post by shadow008 on Nov 14, 2010 14:07:08 GMT -5
So heres the problem: I have a 3d object (a gun model in this case) and i have the camera (using glulookat()). I get the position of the camera based on 2 angles: x angle from mouse, and the y angle from the mouse. Now, i want to have the object follow the camera and stay on the proper rotation based on the cameras rotation. I hope you see what i mean by this: basic4gl.proboards.com/index.cgi?action=display&board=demo&thread=3279&page=1I updated the link in there. The code part that displays the gun is right in the middle of the main loop. If anyone can help me out here that would be greatly appreciated.
|
|
|
Post by shadow008 on Nov 26, 2010 15:19:12 GMT -5
Im guessing no one saw this post? I decided to update it because i still cant get it right and now i need the algorithm for more than just what was posted above...
|
|
|
Post by chris857 on Nov 26, 2010 16:16:35 GMT -5
Do you want the gun to point straight away from the camera?
EDIT: If you do, then here is a solution.
Change worldrenderer.gb's section for gun's rotation to be
gun.rot(0) = cam.rot(1) gun.rot(1) = -cam.rot(0)+180 'gun.rot(2)
and change obj.inc's displayobject() subroutine to include
glrotatef(o.rot(1),0,1,0) glrotatef(o.rot(0),1,0,0) glrotatef(o.rot(2),0,0,1)
instead of
glrotatef(o.rot(1),1,0,0) glrotatef(o.rot(0),0,1,0) glrotatef(o.rot(2),0,0,1)
|
|
|
Post by shadow008 on Nov 27, 2010 19:53:47 GMT -5
Do you want the gun to point straight away from the camera? Yeah, thats exactly it, thank you so much! Im kinda noobish on rotation matricies :\
|
|