AlignToVector Question

Blitz3D Forums/Blitz3D Beginners Area/AlignToVector Question

Thought I know how to use it, but how can I use AlignToVector without pickedNX() or CollisionNX() ?

Say I have a mesh and I want an other mesh to align to it smoothly, but there was no Linepick or Collision. All I got is EntityPitch/Yaw/Roll. How should I do that?

You pick a Vector, and align them both to it

I think you can do it like so ...

tformnormal 1,0,0,Target, 0
aligntovector Source, tformedx(), tformedy(), tformedz(), 1, Rate#

tformnormal 0,1,0,Target, 0
aligntovector Source, tformedx(), tformedy(), tformedz(), 2, Rate#

tformnormal 0,0,1,Target, 0
aligntovector Source, tformedx(), tformedy(), tformedz(), 3, Rate#


Not sure if that works as haven't tested but you may get away with aligning on the x and z axis only.

Stevie

you coud also use deltaPitch deltayaw and delateroll functions.

if you can use EntityX entityY and EntityZ, maybe this should work:
Graphics3D 800,600,0,2
SetBuffer BackBuffer()

light	=	CreateLight	(1)
			MoveEntity	light,50,50,-50

cam		=	CreateCamera()
			MoveEntity	cam,0,40,0
			TurnEntity	cam,90,0,0

point1	=	CreateCone	()
			RotateMesh	point1,90,0,0
			ScaleMesh	point1,1,1,2
			EntityColor	point1,0,255,0

point2	=	CreateCone()
			RotateMesh	point2,90,0,0
			ScaleMesh	point2,1,1,2
			EntityColor	point2,255,0,0
			MoveEntity	point2,-10,0,15

Repeat
	mx=MouseX()
	my=MouseY()
	px#=40*(Float(mx-400)/400)
	pz#=40*(Float(300-my)/400)
	PositionEntity point2,px,0,pz
	PointEntity point2,point1
	SmoothPoint(point1,point2,.1)
	RenderWorld
	Flip
Until KeyHit(1)

End




Function SmoothPoint(source%,dest%,rate#=1)
	Dx#=EntityX(dest,1)-EntityX(source,1)
	Dy#=EntityY(dest,1)-EntityY(source,1)
	Dz#=EntityZ(dest,1)-EntityZ(source,1)
	AlignToVector source,dx#,dy#,dz#,3,rate
End Function


Bobysalt - I tried that, isn't that easy compared to position things. Pitch goes from 0 to 90 then to -90 and finally back to zero. Yaw seems to jump from 180 to -180 depending on roll - or the other way, however, it's still confusing me. If there's a working delta angle function then let me know.

But that's really for what AlignToVertex would be useful.

Stevie - thanks a lot, I'll try that.

H&K - that's what I tried, with Linepick it works, but I don't want to Linepick because it may slow things unneccessarily down.

Stevie - works perfectly! Thanks!

As confusion comes form Euler to Quat transforms, it 's confusing me too ...