Help with Rotation

Blitz3D Forums/Blitz3D Beginners Area/Help with Rotation

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

What you could do is this. Have a pivot parented to your player or whatever your using. Move this one blitz unit ahead of it. Something like: (press left mouse button to move. Arrow keys to turn left,right,up and down)

Graphics3D 800,600
SetBuffer BackBuffer()

light = CreateLight()

Global cam = CreateCamera()
PositionEntity cam,0,0,-10

Global cube = CreateCube()
Global campivot = CreatePivot(cube)
PositionEntity campivot,0,2,-7

Global pivot = CreatePivot()
EntityParent pivot,cube

PositionEntity pivot,0,0,1


Dim backstuff(20)
For loop = 0 To 20
	backstuff(loop) = CreateCube()
	PositionEntity backstuff(loop),Rnd(-20,20),Rnd(-20,20),Rnd(-20,20)
Next




While Not KeyHit(1)

	If KeyDown(203) Then RotateEntity cube,EntityPitch(cube),EntityYaw(cube)+1,EntityRoll(cube)
	If KeyDown(205) Then RotateEntity cube,EntityPitch(cube),EntityYaw(cube)-1,EntityRoll(cube)
	If KeyDown(200) Then RotateEntity cube,EntityPitch(cube)+1,EntityYaw(cube),EntityRoll(cube)
	If KeyDown(208) Then RotateEntity cube,EntityPitch(cube)-1,EntityYaw(cube),EntityRoll(cube)	

	If MouseDown(1) Then MoveEntity cube,0,0,0.1

	updatecamera()
	UpdateWorld
	RenderWorld
	Text 0,0,"x vector="+(EntityX(pivot,True)-EntityX(cube,True))+"  y vector="+(EntityY(pivot,True)-EntityY(cube,True))+"  z vector="+(EntityZ(pivot,True)-EntityZ(cube,True))
	Flip
Wend
End

Function updatecamera()

	PointEntity cam,campivot
	If EntityDistance#(cam,campivot) > 0.5 Then
		MoveEntity cam,0,0,EntityDistance#(cam,campivot)/20
	End If
	PointEntity cam,cube
	
End Function


Basically, you have a pivot parented to the cube, exactly one unit ahead of the cube. You subtract the pivots GLOBAL X Y and Z from the cube's GLOBAL X Y and Z. The rest of that code up there is just so you can see it in action. Hope that helps :o)