AlignToVector question

Blitz3D Forums/Blitz3D Programming/AlignToVector question

John Blackledge(Posted 2004) [#1]
I feel sure I'm missing something obvious.
I want to create and align a simple shadow quad under a tree, then AddMesh it as part od a larger 'shadow' mesh.
The tree will always sit on a known triangle.
How can I (a) get the slope of the triangle's surface and (b) align the quad to that slope?
Currently the shadows are not aligning to the slope of the triangle below.

This is the code I'm using:

indshadow = CopyMesh(mastershadow)
FitMesh indshadow, x1,y1,z1, x2,0.001,z2, True
ScaleMesh indshadow,newscalex#,1,newscalez#
LinePick(treex#,treey#+10,treez#, 0,-20,0)
AlignToVector indshadow,PickedNX(),PickedNY(),PickedNZ(),3,1
PositionMesh indshadow,treex#,treey#+0.1,treez#
AddMesh indshadow, treeshadowmesh
FreeEntity indshadow


Tom(Posted 2004) [#2]
What axis did you create the shadow tris? Also, I'd move the quad along the normal rather than move it Y+, else as the slope of the ground gets steeper, the distance between the quad and the ground will get smaller, possibly increasing the chances of Z-fighting at a distance.

;Assuming quad normal is Y+
Const AXISX=1
Const AXISY=2
Const AXISZ=3

...
AlignToVector indshadow,PickedNX(),PickedNY(),PickedNZ(),AXISY,1
PositionMesh indshadow,treex#,treey#+0.1,treez#
MoveEntity indshadow,0,.1,0 ;raise the quad along ground normal rather than absolute Y+
..

Tom


John Blackledge(Posted 2004) [#3]
Hi Tom. Thanks for the reply.

But if you check my code above you'll see that your AXISY variable is equivalent to the last but one parameter of 3 in my AlignToVector line.

So no change there.

Let me clarify:
Imagine a triangle in a mesh.
I can get the triangle and I can get each vertex, but I need to align my shadow mesh to the slope of that triangle.

Surely (please...) one of the big brains out there has already done something like this?
I guess it's the same as aligning a bullet-damage sprite to a wall, but it's beyond me.