Page 6 of 6

Re: ConstantAngularSpeedCurve ?

Posted: Fri May 31, 2013 7:16 pm
by Norbo
So the better solution, is to have a normal driving ?
Yes.
Bepuphysics give helper for quaternion comparaison ?
Sort of. These methods are sometimes useful:
Toolbox.GetAngleFromQuaternion
Toolbox.GetAxisAngleFromQuaternion
Toolbox.GetQuaternionBetweenNormalizedVectors

Another useful operation for comparison is computing the intermediate rotation between two orientation quaternions, which you can get with a conjugate and multiply.

Also, since you're primarily concerned with the forward direction versus a desired direction, you should be able to avoid quaternions in favor of simple dot products or projections.

Re: ConstantAngularSpeedCurve ?

Posted: Fri May 31, 2013 7:28 pm
by kavatortank
In fact, I only want to now if the tank must turn to the left or the right.
I only have the orientation on the tank ( quaternion ), and the point where the tank must go.
I have problem with quaternion manipulation, can you help me ?

Re: ConstantAngularSpeedCurve ?

Posted: Sat Jun 01, 2013 4:53 am
by Norbo
In fact, I only want to now if the tank must turn to the left or the right.
I only have the orientation on the tank ( quaternion ), and the point where the tank must go.
You also have the tank's forward vector (and quite a bit of other information). The forward direction can be computed by transforming a local direction by the orientation. Or, you could grab the Forward vector right out of the OrientationMatrix representation.

Comparing the forward vector against the desired direction will give you the information needed for steering. One option would be to project the forward vector onto the horizontal plane, normalize it, and use a dot product and/or cross product with the desired direction to compute the signed angle. Another option would be to use atan2 to compute the yaw. Quaternion manipulation should not be needed.

Re: ConstantAngularSpeedCurve ?

Posted: Wed Jun 05, 2013 8:49 pm
by kavatortank
Hi,
I have lots of difficulties to connect the Heighmap graphical model and the physical model.
I didn't understand why, when I draw my graphical model with no transform, and when the modelDrawer draw the physcal model with no transform, models displayed with different size and position.

Help me plz

Re: ConstantAngularSpeedCurve ?

Posted: Wed Jun 05, 2013 11:04 pm
by Norbo
Make sure the origin of the model is the same, and make sure that the transform of the terrain collidable (which can contain any arbitrary affine transform) is consistent with the terrain graphic.

Re: ConstantAngularSpeedCurve ?

Posted: Wed Jun 05, 2013 11:06 pm
by kavatortank
How I can check that ?

Re: ConstantAngularSpeedCurve ?

Posted: Wed Jun 05, 2013 11:41 pm
by Norbo
If you mean the terrain's transform, it is whatever you assigned during the terrain's construction. For example, from the TerrainDemo:

Code: Select all

            var terrain = new Terrain(heights, new AffineTransform(
                    new Vector3(xSpacing, 1, zSpacing),
                    Quaternion.Identity,
                    new Vector3(-xLength * xSpacing / 2, 0, -zLength * zSpacing / 2)));
The second parameter, the AffineTransform, defines a scale and translation.

Note that, when unscaled, the terrain's triangles are spaced 1 unit apart.

Re: ConstantAngularSpeedCurve ?

Posted: Thu Jun 06, 2013 12:08 am
by kavatortank
How do I get those values ?

Re: ConstantAngularSpeedCurve ?

Posted: Thu Jun 06, 2013 12:20 am
by Norbo
I'm not sure what you mean; you choose xSpacing etc. yourself to produce the desired simulation behavior.

If you're asking how to access the transform later, use the Terrain.WorldTransform property.

Re: ConstantAngularSpeedCurve ?

Posted: Thu Jun 06, 2013 12:29 am
by kavatortank
No, I generate my Heighmap with the content processor, and I catch heights, but how I can check xSpacing... ?

Re: ConstantAngularSpeedCurve ?

Posted: Thu Jun 06, 2013 12:33 am
by Norbo
It is a value that you choose. You do not need to 'check' for it, it is just a value used to create whatever transform you want.

In the example, xSpacing and zSpacing are used to create a scale factor. That scaling transform would multiply the X coordinates by xSpacing, the Y coordinates (heights) by 1, and the Z coordinates by zSpacing. The demo does this because I wanted more than 1 horizontal unit between adjacent vertices.

Re: ConstantAngularSpeedCurve ?

Posted: Thu Jun 06, 2013 12:37 am
by kavatortank
In the content processor I have this :

Code: Select all

for (int y = 0; y < heightfield.Height; y++)
            {
                for (int x = 0; x < heightfield.Width; x++)
                {
                    Vector3 position;

                    // position the vertices so that the heightfield is centered
                    // around x=0,z=0
                    position.X = scale * (x - ((heightfield.Width - 1) / 2.0f));
                    position.Z = scale * (y - ((heightfield.Height - 1) / 2.0f));
                    position.Y = (heightfield.GetPixel(x, y) - 1) * bumpiness;
                    builder.CreatePosition(position);
                }
            }
To create positions.
I have a model.