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.
So i have tried on my own, here's the result so far:
; vector defintion Type vec3d Field x# Field y# Field z# End Type Function VectorDot#(v1.vec3d,v2.vec3d) Return (v1\x*v2\x)+(v1\y*v2\y)+(v1\z*v2\z) End Function v1.vec3d = New vec3d v2.vec3d = New vec3d ; some geometry Graphics3D 800,600,0,2 SetBuffer BackBuffer() cam = CreateCamera() CameraZoom cam,1.6 obj1 = CreateCone() ScaleEntity obj1,2,4,2 obj2 = CreateCube() EntityColor obj1,255,0,0 EntityColor obj2,0,255,0 plane = CreatePlane() EntityPickMode plane,2 PositionEntity plane,0,-1,0 RotateEntity obj1,90,0,0 PositionEntity cam,0,50,0 PointEntity cam,plane ;PositionEntity obj1,-10,0,-5 While Not KeyHit(1) If CameraPick (cam,MouseX(),MouseY()) PositionEntity obj2,PickedX(),0,PickedZ() TFormNormal 0,0,1,obj1,0 v1\x = TFormedX() v1\y = TFormedY() v1\z = TFormedZ() TFormNormal PickedX()-EntityX(obj1,1),PickedY()-EntityY(obj1,1),PickedZ()-EntityZ(obj1,1),0,obj1 v2\x = TFormedX() v2\y = TFormedY() v2\z = TFormedZ() If v2\x < 0 dir = 1 Else dir = -1 EndIf dot# = VectorDot#(v2,v1) angle# = ACos(-dot) TurnEntity obj1,0,angle*dir*0.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 Flip Wend Delete Each vec3d ClearWorld() EndGraphics() End
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.