Hey, Try this. I wrote it up while i'm in college so i can't run it to see if it works, but it seems ok. Press the 1 key to generate a new point for the camera to goto. Press keys 2 and 3 to change the movement mode. I don't know anything about Hermite Spline, but this might do what you want it to :D. Loosely based around Dr Av's cam system.
[EDIT] Got home now, and made changes so it works :)
Graphics3D 800,600
SetBuffer BackBuffer()
Dim cubes(80)
For loop=0 To 80
cubes(loop)=CreateCube()
PositionEntity cubes(loop),Rnd(-15,15),Rnd(-15,15),Rnd(-15,15)
ScaleEntity cubes(loop),0.3,0.3,0.3
Next
Global camera=CreateCamera()
PositionEntity camera,0,2,0
Global light=CreateLight()
Global dest_piv=CreateSphere()
EntityColor dest_piv,100,100,255
EntityAlpha dest_piv,0.4
ScaleEntity dest_piv,0.2,0.2,0.2
Global move_piv=CreatePivot()
Global cam_speed#=100; increase to slow the camera down
Global cam_point=0; if this is set to 0 then the camera will move to the next point, but continue facing the way it is facing. Set to 1 and the camera will face the point.
While Not KeyHit(1)
If KeyHit(2) Then generate_point( Rnd(-10,10),Rnd(2,5),Rnd(-10,10) )
If KeyHit(3) Then cam_point=0
If KeyHit(4) Then cam_point=1
update_camera(cam_point)
UpdateWorld
RenderWorld
Text 0,0," Press 2 and 3 to change point mode. Current:"+cam_point
Flip
Wend
End
Function generate_point(x#,y#,z#)
PositionEntity dest_piv,x,y,z
RotateEntity move_piv,EntityPitch(camera,True),EntityYaw(camera,True),EntityRoll(camera,True)
PositionEntity move_piv,EntityX(camera),EntityY(camera),EntityZ(camera)
MoveEntity move_piv,0,0,5
End Function
Function update_camera(point)
If point=0 Then
tempx=EntityPitch(camera,True); puts the cam rotations in temp variables
tempy=EntityYaw(camera,True);same
tempz=EntityRoll(camera,True);same
PointEntity camera,dest_piv; point the camera at the destination
MoveEntity camera,0,0,EntityDistance(camera,dest_piv)/cam_speed; move the camera the way it's facing,
;based on the distance remaining from the destination
PositionEntity move_piv,EntityX(camera),EntityY(camera),EntityZ(camera); take the move pivot along so it can be used whenever point mode 1 is needed
RotateEntity camera,tempx,tempy,tempz; rotate the camera back to its orginal rotations
ElseIf point=1 Then
PointEntity camera,dest_piv
MoveEntity camera,0,0,EntityDistance(camera,dest_piv)/cam_speed
PointEntity move_piv,dest_piv
MoveEntity move_piv,0,0,EntityDistance(move_piv,dest_piv)/(cam_speed*0.5); move the move pivot along twice as quick as the camera
PointEntity camera,move_piv; point the camera at the move pivot, for smooth turning
End If
End Function
|