TurnEntity problem!
Blitz3D Forums/Blitz3D Programming/TurnEntity problem!
| ||
Now forgive for being soo stupid... OK imagine a cube and you rotate it on the x axis so that its pointing almost straight up... rotateentity cube,-85,0,0,0 Now image wanting to 'look' left right based upon the cubes local y axis (which is now effectively running almost thru the screen (on the global z axis). So you do this... rotateentity cube, 0,45,0,0 rotateentity cube, 0,-45,0,0 Now the problem is it doesn't turn along its local y axis, i.e. the y axis has not been 'transformed' by the original x axis rotate. Have can I achieve this? ; RotateEntity Example ; -------------------- Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() light=CreateLight() cone=CreateCube() PositionEntity cone,0,0,5 While Not KeyDown( 1 ) ; Change rotation values depending on the key pressed If KeyDown( 208 )=True Then pitch#=pitch#-1 If KeyDown( 200 )=True Then pitch#=pitch#+1 If KeyDown( 203 )=True Then yaw#=yaw#-1 If KeyDown( 205 )=True Then yaw#=yaw#+1 If KeyDown( 45 )=True Then roll#=roll#-1 If KeyDown( 44 )=True Then roll#=roll#+1 ; Rotate cone using rotation values RotateEntity cone,pitch#,yaw#,roll#,1 RenderWorld Text 0,0,"Use cursor/Z/X keys to change cone rotation" Text 0,20,"Pitch: "+pitch# Text 0,40,"Yaw : "+yaw# Text 0,60,"Roll : "+roll# Flip Wend End So turn the cube to face almost up (down arrow) then look left right using right left cursor keys. The cubes axis is always up down. How can I 'translate' it's axis so that it's not fixed to the global axis. Hope this makes sence. |
| ||
did you try turnentity instead? Or, perhaps, aligntovector? |
| ||
dude, i have no clue. I mainly work in 2d, but i'm starting on some 3d. I have no clue. EDIT: Sorry about this. I guess I just wanted to post something on that boring day 2 years ago. Now I feel all stupid inside... |
| ||
Well turnentity will make NO difference. TurnEntity turns relative to its current position but it STILL uses the global axis not a 'local' axis. Ryudin, thanks for your helpful input! |
| ||
Maybe this ? |
| ||
Hows about;Note the final 1. Turn entity has a global flag too.... ;So you can set it to 0...... Turnentity entity,0,45,0,1 Damn, just as i finished that I note that Bram32 also has the same answer :) |
| ||
TurnEntity turns relative to its current position but it STILL uses the global axis not a 'local' axis. Don't know where you got that idea from but its totally incorrect. Don't mix the rotateentity and turnentity commands and it should work fine as in the example by brams32. |
| ||
Hmm, another stupid problem... I have a 'player' and a camera parented to the player. When I fire a 'bullet' is created at entityx, entityy-1, entityz. All is good! Now I turn the player entity on the z axis. The player and camera turn. No if I fire the bullet is relative to the players axis's so it's not at the bottom of the screen, it's at the side. How can I always ensure that the bullet is at the bottom of the screen? Even when I turn on the z axis and check the entity local and global co-ords they are the same! ARGH! |
| ||
a bullet is created at entityx etc. of what? the player? or the camera? If you want the bullet to be created at a certain screen coordinate then you best use entityx etc. of the camera. then, instead of positionentity bullet, entityx(camera,1), entityy(camera,1) - 1 , entityz(camera,1),1 you should use positionentity bullet, entityx(camera,1), entityy(camera,1), entityz(camera,1),1 rotateentity bullet, entitypitch(camera,1), entityyaw(camera,1), entityroll(camera,1),1 moveentity bullet,0,-1,0 |
| ||
By Z-axis I assume you mean roll axis? Are you parenting the bullet to the player when it's created initially? Some code would be nice. If I understand you correctly you should be able to fix this with ... tformpoint 0,-1,0, Player, 0 positionentity bullet, tformedx(), tformedy(), tformedz() Stevie |