I got it Genjix! Unfortunately I did not find a helper function for doing all at once, though only a few steps were needed. The only thing you did not mention was that it is necessary to find the rotation axis, which can be accomplished by constructing a plane that contains both vectors (csPlane3), and then calculating its normal vector.
Thank you very much! Best Regards, Mario Lapin. -- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Em nome de Genjix Enviada em: sexta-feira, 1 de dezembro de 2006 21:04 Ok, so you're working with positions. If LookAt isn't working for you, you can always compute a vector from local space of #1 towards #2 ... 1. Transform arrows end position to #1's localspace - call it A 2. Transform #2 to #1's localspace - call it B 3. Dot product for angle between A and B 4. Position arrow at #1 using rotation from calculated angle. If you look around CS api though theres probably some helper function to do all, or at least most of this (at the very minimum you have the csVector3 class ;) Amir Taaki On Friday 01 December 2006 23:59, Mario Lapin wrote: > Hi, > > > > I will try to explain what I'm trying to do through an example (instead of > a diagram. :-) ). It's not complicated, but abstract. > > > > Imagine that a camera (you) is looking to 2 meshes, resting on the floor > and positioned 5u apart from each other. You want to set a certain velocity > to mesh #1 making it to hit mesh #2. You can accomplish that by calculating > a vector3 velo = K * (normalize(pos2 - pos1))] -- pos1 and pos2 in world > space - velo in relative space. Let's keep the vector3 velo for using it > later. > > > > But instead of just setting the velocity to mesh #1, you want to visualize > a genmesh arrow, over mesh #1 and pointing towards mesh #2. The arrow > genmesh was previously modeled in Blender, with the care to position its > origin on (0,0,0) and its arrowhead on (1,0,0). You will set the origin of > your arrow transform to the origin of mesh #1. Then the arrow will appear > over mesh #1, pointing to (1,0,0). > > > > The question is: how to orientate the arrow transform to make it visually > point to mesh #2? Everything should be independent of camera-space. The > usage of LookAt() is clear for orientating cameras, but how to correctly > use it on meshes? How to take into account the orientation of the modeled > arrow (1,0,0)? Remember that the vector3 velo, which is our given > direction, is relative to the origin of both the body and the arrow. > > > > Note that this procedure is intended to allow a user to visualize > concretely the abstract concept of a vector, and to preview the trajectory > of moving bodies. As you might guess, I'm not building a game, but an > educational tool!! > > > > I would be very glad to give any further information, including code > snippets if needed. > > > > Thank you! > > > > Best regards, > > > > Mario. > > > > _____ > > De: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Em nome de Amir Taaki > > > > Hi, > > > > I'm not too clear what you're trying to do... Maybe a diagram could help? > > > > If you are trying to make an arrow that stays in a fixed position but > points in a constant direction as the player moves about (like a compass > would), you can try to actually parent its position to the camera but alter > its rotation to point at the direction you wish. > > > > On 11/29/06, Mario Lapin <[EMAIL PROTECTED]> wrote: > > 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 (1,0,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 > <http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV> > &p=sourceforge&CID=DEVDEV > > _______________________________________________ > Crystal-main mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/crystal-main > <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 [email protected] 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 [email protected] https://lists.sourceforge.net/lists/listinfo/crystal-main Unsubscribe: mailto:[EMAIL PROTECTED]
