csReversibleTransform has a LookAt function that will compute a look-at
transform.
So, you can use this to compute a transform that will "look" towards the
normal of the terrain. You can do this by doing the following:
csReversibleTransform rt;
rt.LookAt(terrainNormal, csVector3(0,1,0));
csMatrix3 mat = rt.GetT2O();
meshWrapper->GetMovable()->SetTransform(mat);
This should orient your mesh so that some part of it is facing down the
terrain, but it probably won't be the correct part. I can't remember off
the top of my head which way the lookat will orient, but you can fix this
with a bit of trial and error. What you'll have to do is rotate your
character and then apply the lookat transform.
For example, if your character's back faces the direction you want its front
to face then you can change line 3 to:
csMatrix3 mat = rt.GetT2O() * csYRotMatrix3(3.14f);
3.14f is a half-turn rotation.
If your character isn't even standing upright, then you'll probably have to
apply a rotation around the X axis:
csMatrix3 mat = rt.GetT2O() * csXRotMatrix3(3.14f * 0.5f); // half of
3.14fis a quarter turn
If neither is sufficient then you might have to combine the two in some way:
csMatrix3 mat = rt.GetT2O() * csYRotMatrix3(3.14f) * csXRotMatrix3(3.14f *
0.5f);
or something similar. If you play around with it then you should get a feel
for transforming your character and manage to get him facing the right way.
--
Andrew Robberts
On 2/14/07, Quentin Anciaux <[EMAIL PROTECTED]> wrote:
Hi,
I've another question now that I know how to find the elevation. I would
like
the character displayed on the surface not only to be shown at the correct
elevation but also to "rotate" according to the vector perpendicular
(normal ?) from the terrain... How can I do ?
Thank you very much, any help is appreciated.
Quentin Anciaux
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Crystal-main mailing list
Crystal-main@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]
?subject=unsubscribe
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Crystal-main mailing list
Crystal-main@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]