Getting Pitch/Yaw/Roll of a collided triangle

Blitz3D Forums/Blitz3D Programming/Getting Pitch/Yaw/Roll of a collided triangle

Adam Novagen(Posted 2009) [#1]
Hey all,

Okay, I've figure out how to get specific triangles from a mesh using CollisionTriangle(). Once I've got that triangle, though, how can I determine its global Pitch/Yaw/Roll values?


Stevie G(Posted 2009) [#2]
Use a pivot and align it to the collision normals, then get the pitch, roll , yaw from this pivot :

global PIVOT = createpivot()

.
.
.
.

Nx# = 0
Ny# = 0
Nz# = 0
for c = 1 to countcollisions( Entity )
   Nx = Nx + collisionnx( Entity , c )
   Ny = Ny + collisionny( Entity, c )
   Nz = Nz + collisionnz( Entity, c )
next
aligntovector PIVOT, Nx, Ny, Nz, 2, 1

Pitch# = entitypitch( PIVOT )
Yaw# = entityyaw( PIVOT )
Roll# = entityroll( PIVOT )



Gabriel(Posted 2009) [#3]
A triangle doesn't have pitch, yaw and roll. If it did, what would it be your point of reference? It presumably wouldn't be the entity they belong to because all the triangles can point in different directions. So I guess it could be relative to a fixed axis, but it could still be +x, -x, +y, -y, +z or -z.

If you want to know which direction the triangle is facing, collisions give the normal, I think, or you could retrieve the triangle normal manually. If that's not what you want, then I'm not quite clear on what you're after.


Adam Novagen(Posted 2009) [#4]
Thanks Stevie G; I actually happened to stumble on the CollisionNX/Y/Z() commands shortly after I posted this, and it works!