Phil Jones' pitch and roll example

Blitz3D Forums/Blitz3D Programming/Phil Jones' pitch and roll example

If your plane is a pickable polygon mesh then you can use a single linepick (much quicker than using lots of linepicks) from the centre of your entity, then obtain the picked normals (use PICKEDNX#(), PICKEDNY#() and PICKEDNZ#() ) then use 2 ALIGNTOVECTOR commands to correctly orient the object.

Like this -
ground = LinePick( EntityX#(v\bodymesh,True),EntityY#(v\bodymesh,True) + 1.0,EntityZ#(v\bodymesh,True) , 0,-2.0,0 , 0.0)
		If ground
			nx# = PickedNX#()
			ny# = PickedNY#()
			nz# = PickedNZ#()
			AlignToVector v\shadowmesh,nx#,ny#,nz#,1,1
			AlignToVector v\shadowmesh,nx#,ny#,nz#,3,1


Note that this will result in you entity pointing straight upwards along the polygon's normal so you will need to orient the entity's mesh correctly in your 3D package for it to look visually correct. If you can't do that, then make your primary object a pivot, use the above code to orient this pivot, and have your visual mesh as a child of the pivot that is correctly pre-rotated so that it faces forwards and not upwards (probably ROTATEENTITY child,90,0,0).