camera turing problem

Blitz3D Forums/Blitz3D Beginners Area/camera turing problem

ok,

this is hard to explain... here is the code


Graphics3D 640,480
SetBuffer BackBuffer()

type_camera=1
type_entity=2


Function pause()
Text 100,150, "Game Paused - press any key (except P or start) to continue"

WaitKey()
WaitJoy()
End Function 



light=CreateLight()


camera=CreateCamera()
PositionEntity camera,0,1,0
CameraClsColor camera,92,236,222
EntityType camera, type_camera 
CameraRange camera,.001,1000



camera2=CreateCamera()
PositionEntity camera2,0,1,-5
CameraClsColor camera2,92,236,222
CameraRange camera2,.001,1000
EntityType camera2,type_camera





CameraViewport camera,0,0,GraphicsWidth()/2,GraphicsHeight()
CameraViewport camera2,GraphicsWidth()/2,0, GraphicsWidth()/2,GraphicsHeight()

test=CreateCube()
PositionEntity test,0,1,5

plane=CreatePlane()
EntityType plane, type_entity 


;Ptex=LoadTexture("grass.jpg")
;EntityTexture plane,ptex


;mesh=LoadMesh("building.b3d")
;PositionEntity mesh,0,0,10
;ScaleEntity mesh,.05,.05,.05
;EntityType mesh, type_entity















Collisions type_camera,type_entity,2,2

While Not KeyDown(1)

If KeyDown(208) Then MoveEntity camera2,0,0,-.1
If KeyDown(200) Then MoveEntity camera2,0,0,.1
If KeyDown(203) Then MoveEntity camera2,-.1,0,0
If KeyDown(205) Then MoveEntity camera2,.1,0,0
If KeyDown(30)  Then TurnEntity camera2,0,1,0
If KeyDown(31)  Then TurnEntity camera2,0,-1,0







If JoyXDir() = -1 MoveEntity camera,-.1,0,0
If JoyXDir() = 1 MoveEntity camera,.1,0,0
If JoyYDir() = -1 MoveEntity camera,0,0,.1
If JoyYDir() = 1 MoveEntity camera,0,0,-.1
;If JoyHit(4) MoveEntity camera,0,1.5,0
;If JoyDown(2) MoveEntity camera,0,-.1,0
If JoyDown(1) TurnEntity camera,0,2,0
If JoyDown(3) TurnEntity camera,0,-2,0
If JoyDown(4) TurnEntity camera,-1,0,0
If JoyDown(2) TurnEntity camera,1,0,0
;If EntityY(camera) > 1.5 TranslateEntity camera,0,-1,0









TranslateEntity camera,0,-.5,0
TranslateEntity camera2,0,-.5,0

RenderWorld
UpdateWorld 

Text 0,0,EntityX(camera,True)
 Text 0,15,EntityY(camera,True)
 Text 0,30,EntityZ(camera,True) 

Text 600,0,EntityX(camera2,True)
 Text 600,15,EntityY(camera2,True)
 Text 600,30,EntityZ(camera2,True) 





If KeyDown(25) Then pause 
If JoyDown(10) Then pause
Flip


Wend

End


ok, with the game controller buttons I turn down, then I turn left or right, and then, the screen is all crazy and on its side... can anyone please help... this has been bugging me for hours!!!

It's because you're turning in multiple directions. Use a pivot to turn left and right,and move the camera up and down. That should work. Also please use code or codebox tags in the future
;insert code here


Graphics3D 640,480
SetBuffer BackBuffer()

type_camera=1
type_entity=2


Function pause()
Text 100,150, "Game Paused - press any key (except P or start) to continue"

WaitKey()
WaitJoy()
End Function 



light=CreateLight()


camera=CreateCamera()
PositionEntity camera,0,1,0
CameraClsColor camera,92,236,222
EntityType camera, type_camera 
CameraRange camera,.001,1000



camera2=CreateCamera()
PositionEntity camera2,0,1,-5
CameraClsColor camera2,92,236,222
CameraRange camera2,.001,1000
EntityType camera2,type_camera





CameraViewport camera,0,0,GraphicsWidth()/2,GraphicsHeight()
CameraViewport camera2,GraphicsWidth()/2,0, GraphicsWidth()/2,GraphicsHeight()

test=CreateCube()
PositionEntity test,0,1,5

plane=CreatePlane()
EntityType plane, type_entity 


;Ptex=LoadTexture("grass.jpg")
;EntityTexture plane,ptex


;mesh=LoadMesh("building.b3d")
;PositionEntity mesh,0,0,10
;ScaleEntity mesh,.05,.05,.05
;EntityType mesh, type_entity















Collisions type_camera,type_entity,2,2

While Not KeyDown(1)

If KeyDown(208) Then MoveEntity camera2,0,0,-.1
If KeyDown(200) Then MoveEntity camera2,0,0,.1
If KeyDown(203) Then MoveEntity camera2,-.1,0,0
If KeyDown(205) Then MoveEntity camera2,.1,0,0
If KeyDown(30) Then TurnEntity camera2,0,1,0
If KeyDown(31) Then TurnEntity camera2,0,-1,0







If JoyXDir() = -1 MoveEntity camera,-.1,0,0
If JoyXDir() = 1 MoveEntity camera,.1,0,0
If JoyYDir() = -1 MoveEntity camera,0,0,.1
If JoyYDir() = 1 MoveEntity camera,0,0,-.1
;If JoyHit(4) MoveEntity camera,0,1.5,0
;If JoyDown(2) MoveEntity camera,0,-.1,0
If JoyDown(1) TurnEntity camera,0,2,0
If JoyDown(3) TurnEntity camera,0,-2,0
If JoyDown(4) TurnEntity camera,-1,0,0
If JoyDown(2) TurnEntity camera,1,0,0
;If EntityY(camera) > 1.5 TranslateEntity camera,0,-1,0









TranslateEntity camera,0,-.5,0
TranslateEntity camera2,0,-.5,0

RenderWorld
UpdateWorld 

Text 0,0,EntityX(camera,True)
Text 0,15,EntityY(camera,True)
Text 0,30,EntityZ(camera,True) 

Text 600,0,EntityX(camera2,True)
Text 600,15,EntityY(camera2,True)
Text 600,30,EntityZ(camera2,True) 





If KeyDown(25) Then pause 
If JoyDown(10) Then pause
Flip


Wend

End



how would I use a pivot to move left and right?

If keyhit(203) turnentity campivot,0,1,0
If keyhit(200) turnentity camera,1,0,0


I just wouldn't use turnentity if you can help it :o) Try using rotateentity.

Function Turn_Entity(entity, x#, y#, z#, coordsys=False)

  RotateEntity Entity, EntityPitch(entity,coordsys)+x, EntityYaw(entity,coordsys)+y, EntityRoll(entity,coordsys)+z, coordsys

End Function


That way you don't need to use a pivot.

The thread on this:

http://www.blitzbasic.com/Community/posts.php?topic=81169