Movements relative to camera?

Blitz3D Forums/Blitz3D Programming/Movements relative to camera?

FlagDKT(Posted 2010) [#1]
This is the moving dir for player going to the right and the camera is positioned at -z
vx=1
vz=0

If I position the camera to the left of the player I want the vector to become:
vx=0
vz=-1

How to achieve this?How to transform the vector relative to camera?
Blitz Tform() function won't work...


Ross C(Posted 2010) [#2]
Read Floyds post below.


FlagDKT(Posted 2010) [#3]
Tried already..It doesn't!


Ross C(Posted 2010) [#4]
It does work. Can you post the code your using?


Floyd(Posted 2010) [#5]
TFormVector vx,vy,vz, camera, 0
i.e. transform from camera space to world space.


_PJ_(Posted 2010) [#6]
Note that trasditionally, x is the lef/right axis, and z is forward/back.

So when the player is to the left, the vector ought to be x = -1 and z=0

if you wanted x=0 and z=-1 then you need to adjust the values by a change of -90 degrees yaw to compensate.


Ross C(Posted 2010) [#7]
[EDIT]I should never doubt the mighty Floyd!


Ross C(Posted 2010) [#8]
[EDIT] Ignore

Demonstrates Floyds TFormVector. Arrow keys to move the player.

Graphics3D 800,600
SetBuffer BackBuffer()

Global pivot = CreatePivot()
Global camera = CreateCamera(pivot)
PositionEntity camera,0,10,-20

Global player = CreateCone()
RotateMesh player,90,0,0

Global vx# = 0
Global vz# = 0

Global light = CreateLight()

plane = CreateCube()
EntityColor plane,0,255,0
ScaleEntity plane,100,.1,100

While Not KeyHit(1)


	If KeyDown(205) Then
		vx = 0.1
	ElseIf KeyDown(203) Then
		vx = -0.1
	Else
		vx = 0
	End If
	
	If KeyDown(200) Then
		vz = 0.1
	ElseIf KeyDown(208) Then
		vz = -0.1
	Else
		vz = 0
	End If
	
	TFormVector vx,0,vz,camera,0
	
	MoveEntity player,TFormedX(),0,TFormedZ()
	
	TurnEntity pivot,0,0.5,0
	
	UpdateWorld
	RenderWorld
	Text 0,0,"TFormedx = "+TFormedX()+" tformedz = "+TFormedZ()
	Text 0,10," vx = "+vx+" vz = "+vz
	Flip

Wend



FlagDKT(Posted 2010) [#9]
It works :))
Thank you!!!!!

It didn't work before, because I tformed world to camera :(