Pitch Problems
Blitz3D Forums/Blitz3D Beginners Area/Pitch Problems
| ||
Does any one else get problems with this code... on my machine when the pitch gets greater then 90, or less then -90 it goes wierd. |
| ||
put this code:PositionEntity Cam, entityx(Ball), entityy(Ball), entityz(ball) RotateEntity Cam, entitypitch(Ball), entityyaw(Ball), 0 MoveEntity Cam, 0, 0, -10 outside of the main while..wend loop. If you leave it inside the loop, then the ball rotation affects also the camera position and rotation. Which, I guess, is not exactly what you want.. Anyway, I've made a slight modification to your code, it may inspire you: Graphics3D 800, 600, 32, 2 Global cam = CreateCamera() Global ball = CreateSphere(32) ScaleEntity ball,2,2,2 Global light = CreateLight(3) ;spot light PositionEntity light,0,5,0 PointEntity light,ball ;let's just create a squared texture batex = CreateTexture(32,32) SetBuffer TextureBuffer(batex) Color 200,25,0 Rect 2,2,30,30 SetBuffer BackBuffer() EntityTexture ball,batex ScaleTexture batex,0.1,0.1 SetBuffer BackBuffer() PositionEntity Cam, EntityX(Ball), EntityY(Ball), EntityZ(ball) RotateEntity Cam, EntityPitch(Ball), EntityYaw(Ball), 0 MoveEntity Cam, 0, 0, -10 While Not KeyHit(1) If KeyDown(200) Then TurnEntity Ball, 1, 0, 0 ElseIf KeyDown(208) Then TurnEntity Ball, -1, 0, 0 EndIf UpdateWorld: RenderWorld Flip: Cls Wend:End Sergio. |
| ||
no that is what i want, i am trying to make a 3d flight combat game and i need it so that you can do loop'da'loops and things like that. |
| ||
good luck then with your loop'da'loops and things like that Sergio. |
| ||
I think for a 3D flight sim you shouldn't use rotateentity at all, instead use Turnentity and feed it directly with the forces of the flight controls: the average of both tail planes that are both above or both below the normal level will give you the pitch to TURN. The diffrence of both of them will also give you the roll to turn (well, if it's a jet fighter thing) And for the camera, I'd suggest to calculate a point that is behind the camera and then rubber-band-move the camera to that point continously (smoothed). Or you coul d even parent the camera to the plane. Or you can parent a dummy pivot to the airplane and then rubber-nand-move the camera to that pivots position, and simply point the camera to the airplane. |
| ||
Ok, I see now what you meant. I wrote a little Flight sim and everything works fine, I can do Loopings etc. withtout any problem, using the TurnEntity Command. But then I wanted some Filght Control Displays onscreen that shows the angles of the airplane. Now ENtityPitch gives me a range from -90 to 90. But unfortunately it doesn't represent a circe from 0 to 360 that would restart at 0 when it reaches 361, but goes up from 0 to 90, then sinks down to -90, just to raise again to 0. Additionally the EntityYaw also jumps from 0 to 180 at a certain point of the Pitch. sorry, I currently have no better idea than to add a value to a variable simultanously with TurnEntity and from time to time correct the variable when Pitch passes the angle Zero. |
| ||
somtimes it also effects the roll as well which can be very annoying :< |
| ||
can u show me the code you used for the filght sim plz |
| ||
Graphics3D 640,480,32,2 SetBuffer BackBuffer() TFormFilter 0 Dim side(35) ; used for the display side(0)=LoadImage("hud_side.bmp") For i=1 To 35 side(i)=CopyImage(side(0)) MidHandle side(i) RotateImage(side(i)),i*10 Next MidHandle side(0) jet=CreatePivot() PositionEntity jet,0,3,0 camera=CreateCamera(jet) CameraRange camera,1,100000 CameraFogMode camera,1 CameraFogRange camera,100,100000 CameraFogColor camera,100,150,170 CameraClsColor camera,100,150,170 ground=CreatePlane() tex=CreateTexture(1024,1024) ; create a random "landscape" SetBuffer TextureBuffer(tex) For i=0 To 5000 Color Rand(128,255),Rand(128,255),Rand(50,100) Rect Rand(-100,1124),Rand(-100,1124),Rand(100),Rand(100),1 Next SetBuffer BackBuffer() ScaleTexture tex,10000,10000 EntityTexture ground,tex speed#=0 EntityType ground,2 EntityType jet,1 Collisions 1,2,2,2 While KeyDown(1)=0 If KeyDown(200) Then speed=speed+1 If speed >50 Then speed=50 EndIf If KeyDown(208) Then speed=speed-.1 If speed <0 Then speed=0 EndIf button=GetJoy() jxs$=JoyX() jys$=JoyY() jzs$=JoyZ() If Instr(jxs$,"e")<>0 Then jxs$="0" ; prevent joystick rounding errors trough exponentional notation... If Instr(jys$,"e")<>0 Then jys$="0" If Instr(jzs$,"e")<>0 Then jzs$="0" jx#=jxs$ jy#=jys$ jz#=jzs$ MoveEntity jet,0,0,speed ; forward TranslateEntity jet,0,-1.0,0 ; down by gravity rudl#=jy+(-jx) ; check rudders rudr#=jy+jx turnpitch#=-(rudl+rudr)/2.0 turnroll#=rudl-rudr TurnEntity jet,turnpitch,0,turnroll UpdateWorld() RenderWorld() ; just some disply stuff Color 255,255,255 Text 0,64,"Atlitude: "+ EntityY(jet)+" m" Text 0,80,"Speed: "+speed Oval 0,0,50,50,0 Line 25+Cos(EntityRoll(jet,1))*25,25+Sin(EntityRoll(jet,1))*25,50-(25+Cos(EntityRoll(jet,1))*25),50-(25+Sin(EntityRoll(jet,1))*25) Line 25+Cos(EntityRoll(jet,1))*25,25+Sin(EntityRoll(jet,1))*25,50-(25+Cos(EntityRoll(jet,1)+90)*5),50-(25+Sin(EntityRoll(jet,1)+90)*5) Line 50-(25+Cos(EntityRoll(jet,1))*25),50-(25+Sin(EntityRoll(jet,1))*25),50-(25+Cos(EntityRoll(jet,1)+90)*5),50-(25+Sin(EntityRoll(jet,1)+90)*5) 50-(25+Sin(EntityPitch(jet,1))*25) wside=(18+(((EntityPitch(jet,1)+90.0)*2.0)/10.0))Mod 35 If wside>35 Then wside=36 If wside<0 Then wside=0 DrawImage side(wside),85,25 Text 120,25,"Pitch: "+EntityPitch(jet,1) Flip Wend It uses a joystick. First press the Cursor Up key to accellerate. THen pull back the Joystick to lift off. It's using a 50*50 Pixel sideview image of a jetfighter, but as I described, the display stuff don't works as I wanted. The solution I explained in my lates post isn't implemented here. But of course, like in any 3D game, you need to remain inside a range of -32000 to 32000 to prevent zbuffer inaccuracies (that would result in wobbling geometry) |