trans.LookAt(vector from object to point, normal object up direction);

this works for me most of the time. A camera has an up of 0,0,1  an object is 
default 0, 1, 0 or thats what I see.



  ----- Original Message ----- 
  From: Mario Lapin 
  To: crystal-main@lists.sourceforge.net 
  Sent: Tuesday, November 28, 2006 6:19 PM
  Subject: [CsMain] How to have an arrow-like mesh pointing to a givendirection


  Hi all,

   

  I'm putting the question back to the top of the list, in the hope that 
someone else might read it. I'm trying hard to solve it, though unsuccessfully. 
TIA.

  --

   

  I'm coding a visual representation of an arrow-like vector that would make it 
possible for the user to actually see a direction in 3D space, for educational 
purposes. First, it would be possible for the user to move (rotate) the arrow, 
turning it to a new direction, returned as a world-space csVector3. Second, the 
user might also supply a world-space csVector3, and then the arrow should point 
to it. The 3D vector representation was modeled on Blender as an arrow starting 
at (0,0,0) and pointing to (0,1,0), in CS coordinate system, and then a 
MeshWrapper is instantiated from the iMeshFactoryWrapper loaded from file.

   

  Well, the first objective was achieved with the following code :

   

  csRef<iMeshWrapper> arrow;

  csVector3 direction;

  ...

  direction = 
(arrow->GetMovable()->GetTransform().This2OtherRelative(csVector3(0, 1, 0)));

   

  However, I can't realize how to do the contrary, i.e.,, having the arrow to 
point to a given "csVector3 direction" in world space. I supposed that the 
following code might work, but it doesn't:

   

  // Given direction

  csVector3 direction(...);

  ...

  csReversibleTransform trans;

  trans = arrow->GetMovable()->GetTransform();

  csVector3 trans_direction = trans.Other2ThisRelative(direction);

  trans.LookAt(trans_direction, trans.GetUp());

  arrow ->GetMovable()->SetTransform(trans);

   

  I ask you if someone could kindly suggest how to obtain the desired results, 
as I've ran out of ideas!!! I would be very glad to give any other required 
information.

   

  Thank you in advance!

   

  Best regards,

   

  Mario.

   



------------------------------------------------------------------------------


  -------------------------------------------------------------------------
  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]
-------------------------------------------------------------------------
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]

Reply via email to