If you want to contribute to the forum discussions, please
First off, just wanted to say that really impressed with the libraries. I'm not too good when it comes to 3D but working with your stuff has been pretty easy so far, even for me! Currently using the 30 day trial but very tempted to purchase an indie license come payday.
I've been working on a simple slotcar style game, and so far it's been great. I'm using a Path3F and getting the position is fine, using GetParameterFromLength();
Using GetTangent() it returns a Vector3F. To create a new Pose it requires a Vector3F for Position, and then a QuaternionF or Matrix33F for Orientation.
Using QuaternionF.CreateRotation() it requires a Vector3F, and then a float for the angle.
How do I get the angle from GetTangent()? The documentation just says to use GetTangent() but doesn't give any examples, so I'm guessing it's a pretty simple thing, it's just got me stuck.
Thanks a bunch!
Welcome! Glad you are finding our libs useful ;-)
Helpful documentation and samples for paths:
- Article "How To: Move Objects on a 3D Path" in the DigitalRune Mathematics documentation. (I guess you have already found this.)
- "Sample 04 - Kinematic on path" in the DigitalRune Physics General Samples solution.
In the sample a cone is moved on a path. The forward vector of the cone (in the local cone space) is (0, 1, 0). Now, we need the orientation which rotates the local forward vector to the tangent direction. For the cone sample this is simply:
Vector3F forward = _path.GetTangent(parameter).Normalized;
QuaternionF targetOrientation = QuaternionF.CreateRotation(Vector3F.UnitY, forward);
This should work for simple cases. In general, computing a stable orientation for movement along a path is actually a non-trivial problem. If the path goes up/down and the car should always be aligned to a certain ground plane, then you might need a more sophisticated solution. In this case let us know.
Ah I forgot about the other samples, I only looked at the documentation!
Thanks very much! =)