Losing Orientation
Blitz3D Forums/Blitz3D Beginners Area/Losing Orientation
| ||
OK lets see if I can Explain this. I have a fixed point camera, in the center of my play field. It always points at the player. The player is able to pivot on it's own x and z axis relative to a Joystick movement. The movements get really confusing when the object is at different angles relative to the camera. If the object is at 0 Degrees True all fine, but when it is 180 degrees True, with the camera pointed at it, the controls are reversed. What I need is a way to offset the controls depending on the objects True orientation. Did that make sense? Regards, Eric |
| ||
No, as far as I know 'pivot' is not a verb. But I think you need something like this: (save in samples folder) Graphics3D 640,480,0 camera=CreateCamera() obj=CreateCube() plane=CreatePlane() texture=LoadTexture("si\fps\ladders.bmp") EntityTexture plane,texture PositionEntity plane,0,-5,0 PositionEntity obj,1,-3,1 While Not KeyHit(1) dir1#=-1 If KeyDown(200) Then dir1=0 If KeyDown(205) Then dir1=90 If KeyDown(208) Then dir1=180 If KeyDown(203) Then dir1=270 If KeyDown(200) And KeyDown(205) Then dir1=45 If KeyDown(208) And KeyDown(205) Then dir1=135 If KeyDown(203) And KeyDown(208) Then dir1=225 If KeyDown(200) And KeyDown(203) Then dir1=315 If dir1<>-1 Then dir1=dir1-EntityYaw(camera) MoveEntity obj,.1*Sin(dir1),0,.1*Cos(dir1) End If PointEntity camera,obj RenderWorld Text 0,0,dir1 Flip Wend |
| ||
Ok So on the Grammar, I'm not a winner. My problem is this. I am playing around with a Lunar lander type of thing. I Lunar Lander can turn on two pivots The X and Z Axis. I am using a Joystick, When the angle of the Camera changes I want my lander to act accordingly. Left is left and right is right. Can you help with that one? Regards, Eric |
| ||
If english isn't your first language you probably shouldn't comment on other people's use of it. Pivot is both a noun and a verb; used as a verb, it means to rotate around a point. What you want is to use TFormVector to keep movement camera relative. I'll see if I have some example code to post, but the idea is pretty simple. You use TFormVector to convert the left vector (or whatever) from the camera's coordinate space to that of the lander, then move the lander on TFormedX, TFormedY, and TFormedZ. Actually, a better approach is to convert the vector to the world/global coordinate system, then use TranslateEntity and not MoveEntity. TranslateEntity ignores the entity's orientation and always moves according to the global coordinate system. You will still need to use TFormVector to keep movement camera relative however. |
| ||
I did something similar in some old rotating block collision stuff to move apply movement to a ball with respect to the camera. http://www.blitzbasic.co.nz/Community/posts.php?topic=20523#215634 |
| ||
Yes Pivot is a Verb. (does it matter?) Im not entirely sure without seeing this, but I'm thinking there is'n't any actual problem, just a misinterpretation of the camera. At certain points of pitch and yaw, cameras (and other entities) set to PointAt something else will actually flip over to 'right' themselves. This can be very confusing. Also, of course when at 180 degrees lfet/right will be reversed because it's relative to the ppivotal point or the object itself's orientation. clockwise/anticlockwise may be a better description than left/right. |
| ||
JD, TFormvector Did the Trick, Thanks A million. Up until about 3 weeks ago, I never truly understood what the Tform commands did, Now I use both Tform normal and Vector. Can't imagine how I did stuff before. Regards, Eric |
| ||
Who's JD? Mark once commented that the TForm commands were a pleasant surprise. He had no idea how useful they were for so many different tasks when he added them to BlitzBasic. |
| ||
hahah Sorry, I meant DJ.. Yeah They are, I have been avoiding them, because I couldn't quiet grasp the concept. Now I will "Need" Them in my code. |