DeltaYaw

Blitz3D Forums/Blitz3D Programming/DeltaYaw

lo-tekk(Posted 2007) [#1]
I have searched the forums for a way to get the deltayaw between an entity and a coordinate without the need to create a temporary pivot and such without a success.
So i have tried on my own, here's the result so far:


Although it spits out results that will fit my needs, i am not absolutely sure, if the transformations used are correct. Beside of this you will notice that the dot product is negated, i believe this is not correct since a negative dot product will show something that is behind the center object. Maybe someone has a deeper understanding of vectormath and may improve the above.


Stevie G(Posted 2007) [#2]
Why overcomplicate it for the sake of creating a global pivot which is re-used. I'd imagine it's also quicker than what you have.

That said - this is less code ..

;; some geometry
Graphics3D 800,600,0,2
SetBuffer BackBuffer()
cam = CreateCamera()
CameraZoom cam,1.6
obj1 = CreateCone()
RotateMesh obj1, 90,0,0
ScaleMesh obj1,2,2,4
obj2 = CreateCube()
EntityColor obj1,255,0,0
EntityColor obj2,0,255,0
plane = CreatePlane()
EntityPickMode plane,2
PositionEntity plane, 0, -1, 0
PositionEntity cam,0,50,0
PointEntity cam,plane


While Not KeyHit(1)

 If CameraPick (cam,MouseX(),MouseY())
	
  PositionEntity obj2,PickedX(),PickedY(),PickedZ()

	TFormPoint PickedX() , 0 , PickedZ()  , 0 , obj1
	angle# = ATan2( TFormedZ() , TFormedX() ) - 90
	TurnEntity obj1,0, angle * .1,0, 1
			
 EndIf

 UpdateWorld()
 RenderWorld()
 Text 10,10,"X: " + EntityX(obj2)
 Text 10,30,"Y: " + EntityY(obj2)
 Text 10,50,"Z: " + EntityZ(obj2)
 Text 10,70,"ANGLE: " + angle
Text 10,80,"TX : "+TFormedX()
Text 10,90,"Tz : "+TFormedZ()

 Flip
 
 Wend

ClearWorld()
EndGraphics()
End


Stevie


lo-tekk(Posted 2007) [#3]
Ah, thank you ! This is indeed quite simple. I have found the corresponding function in the blitz-help now.

Cheers.