Very Quick Camera Question!
Blitz3D Forums/Blitz3D Beginners Area/Very Quick Camera Question!
| ||
Ahoy! I have a quick question regarding cameras in Blitz3D. My problem might have to do with the fact that I am misunderstanding the way AlignToVector and MoveEntity commands work. Here's a bit of code to illustrate my problem:Graphics3D 800,600 SetBuffer BackBuffer() Global mx,my,mz,mzspd,rotup,ticker,camera camera = CreateCamera() PositionEntity camera,0,-15,-5 TurnEntity camera,-90,0,0 light = CreateLight() cube = CreateCube() Function UpdateCamera() If mzspd > 0 rotup = 1 ElseIf mzspd < 0 rotup = -1 EndIf If rotup = 1 And ticker < 60 AlignToVector camera,0,.01,0,2,.01 MoveEntity camera,0,.1,.1 ticker = ticker + 1 ElseIf rotup = -1 And ticker < 60 AlignToVector camera,0,-.01,0,2,.01 MoveEntity camera,0,-.1,-.1 ticker = ticker + 1 EndIf If ticker = 60 rotup = 0 ticker = 0 EndIf End Function While Not KeyHit(1) mx = MouseX() my = MouseY() mz = MouseZ() UpdateWorld RenderWorld UpdateCamera() mxspd = MouseXSpeed() myspd = MouseYSpeed() mzspd = MouseZSpeed() If MilliSecs()<timer+1000 Then frame=frame+1 Else fps=frame frame=0 timer=MilliSecs() End If Flip Wend End I wanted it to work so that when I scroll up on the mouse button (just one click should do), it moves the camera up and tilts it down on the cube. When I scroll back (again, a single click should do), I want it to _perfectly reverse_ that motion. However, I find that when I scroll back, it doesn't bring the camera back to its starting point! What gives? If you could offer any help, I'd greatly appreciate it. Thanks, -- DJ3J, once again showing just how much of a beginner he really is. |
| ||
Maybe this helps:if rotup=0 If mzspd > 0 rotup = 1 ElseIf mzspd < 0 rotup = -1 EndIf endif you could also try to store its way upward in an array and simply play the positions inside the array reversly when rotup is -1. you never know, rounding errors and the like. BTW - pls don't cross-post. |