Sure. Here is an example of a camera moving around in a
Simple environment. The goal is to have simple first-person
controls. The problem lies in the fact that nothing seems
to change the camera's pivot point. It's always at (0,0,0).
I noticed that all mesh objects rotate at their local center,
like they're supposed to. So I though I might be able to
get the camera to do the same if I linked it to a mesh
object. (A terrible hack, if you ask me)
It doesn't work though. As you'll see, the camera translates
along with the cube just fine, but its pivot point is not the
cube, but the center of the world, so it rotates independantly.
The point of all this is to try to change the camera's pivot
point to anything but (0,0,0). Anything.
Simple environment. The goal is to have simple first-person
controls. The problem lies in the fact that nothing seems
to change the camera's pivot point. It's always at (0,0,0).
Strict Framework pub.dreide TDreide.graphics3d(800,600,0,0,False) 'create camera Local CPosX:Float, CPosY:Float, CPosZ:Float = 30.0 Local CRotX:Float, CRotY:Float, CRotZ:Float Local camera:Tcamera = New Tcamera camera.setposition(CPosX, CPosY, CPosZ)) 'create and position a quad and a box. This is our level. Local ground:Tmesh = Tprimitive.createquad() ground.scalevertices(30,30,1) ground.setrotation (-90,0,0) ground.setposition(0,-10,0) Local pillar:Tmesh = TPrimitive.createcube() pillar.scalevertices(10,50,10) pillar.setposition(10,0,-20) 'turn the lights on glEnable(GL_LIGHTING) glEnable(GL_LIGHT0) Repeat If KeyDown(key_up) CPosZ:-1 If KeyDown(key_down) CPosZ:+1 If KeyDown(key_right) CRotY:-2 If KeyDown(key_left) CRotY:+2 camera.setposition(CposX, cPosY, CPosZ) camera.setrotation(CRotX, CRotY, CRotZ) camera.render() Flip Until KeyDown(key_escape) EndGraphics() End
I noticed that all mesh objects rotate at their local center,
like they're supposed to. So I though I might be able to
get the camera to do the same if I linked it to a mesh
object. (A terrible hack, if you ask me)
Strict Framework pub.dreide TDreide.graphics3d(800,600,0,0,False) 'create a box that our camera will piggyback on. Local CPosX:Float, CPosY:Float, CPosZ:Float = 30.0 Local CRotX:Float, CRotY:Float, CRotZ:Float Local CBox:Tmesh = TPrimitive.createcube() Cbox.setposition(CPosX, CPosY, CPosZ) 'create camera Local camera:Tcamera = New Tcamera camera.setparent(CBox) 'create and position a quad and a box. This is our level. Local ground:Tmesh = Tprimitive.createquad() ground.scalevertices(30,30,1) ground.setrotation (-90,0,0) ground.setposition(0,-10,0) Local pillar:Tmesh = TPrimitive.createcube() pillar.scalevertices(10,50,10) pillar.setposition(10,0,-20) 'turn the lights on glEnable(GL_LIGHTING) glEnable(GL_LIGHT0) Repeat If KeyDown(key_up) CPosZ:-1 If KeyDown(key_down) CPosZ:+1 If KeyDown(key_right) CRotY:-2 If KeyDown(key_left) CRotY:+2 CBox.setposition(CposX, cPosY, CPosZ) CBox.SetRotation(CRotX, CRotY, CRotZ) camera.render() Flip Until KeyDown(key_escape) EndGraphics() End
It doesn't work though. As you'll see, the camera translates
along with the cube just fine, but its pivot point is not the
cube, but the center of the world, so it rotates independantly.
The point of all this is to try to change the camera's pivot
point to anything but (0,0,0). Anything.