mulova
January 22, 2011, 6:00am
1
Currently q.mult(q1, q2) allows q1 and q2 as same instance.
if q and q2 is the same instance the operation will fail.
[patch]
Index: src/core/com/jme3/math/Quaternion.java
===================================================================
— src/core/com/jme3/math/Quaternion.java (revision 6541)
+++ src/core/com/jme3/math/Quaternion.java (working copy)
@@ -819,13 +819,15 @@
public Quaternion mult(Quaternion q, Quaternion res) {
if (res == null)
res = new Quaternion();
float qw = q.w, qx = q.x, qy = q.y, qz = q.z;<br />
res.x = x * qw + y * qz - z * qy + w * qx;<br />
res.y = -x * qz + y * qw + z * qx + w * qy;<br />
res.z = x * qy - y * qx + z * qw + w * qz;<br />
res.w = -x * qx - y * qy - z * qz + w * qw;<br />
float qw = q.getW(), qx = q.getX(), qy = q.getY(), qz = q.getZ();<br />
float lw = w, lx = x, ly = y, lz = z;<br />
res.x = lx * qw + ly * qz - lz * qy + lw * qx;<br />
res.y = -lx * qz + ly * qw + lz * qx + lw * qy;<br />
res.z = lx * qy - ly * qx + lz * qw + lw * qz;<br />
res.w = -lx * qx - ly * qy - lz * qz + lw * qw;<br />
return res;
}
+
/**
<code>apply</code> multiplies this quaternion by a parameter matrix
[/patch]
mulova
January 23, 2011, 4:52pm
3
committed in svn. rev 6560
madjack
February 19, 2011, 12:28am
4
There seem to be a problem here.
If I turn my ship left about 90 degrees then pitch up/down the rotation acts as if the ship was facing the same way before it had turned. So, instead of dipping down/up, it’ll bank left/right.
I reverted to 6559 and it works fine after rebuilding everything. Then just to make sure I updated to latest version and the problem is back.
I’m not entirely sure about the next part, but it sure seems like it. I don’t know if it’s only the parameters that are wrongly named, but in spatial.rotation(…), it says:
[java]rotate(float yaw, float roll, float pitch)[/java]
When in fact it’s: pitch, roll, yaw.
Unless I’m wrong and AFAIK, pitch is up/down (dip head), roll is turning left/right (shake head) and yaw is rolling left/right (cocking head).
To ascertain that it wasn’t the model, I re-exported it making sure it was facing the X axis, but the result is the same.
Could anyone confirm please?
Here’s how I do it:
[java]
private AnalogListener analogListener = new AnalogListener() {
@Override
public void onAnalog(String name, float value, float tpf) {
if (name.equals(“PitchDown”)) {
player.getShipSpatial().rotate(.5f * tpf, 0, 0);
galaxyNode.updateGeometricState();
} else if (name.equals(“PitchUp”)) {
player.getShipSpatial().rotate(-.5f * tpf, 0, 0);
galaxyNode.updateGeometricState();
} else if (name.equals(“MoveLeft”)) {
player.getShipSpatial().rotate(0, .5f * tpf, 0);
galaxyNode.updateGeometricState();
} else if (name.equals(“MoveRight”)) {
player.getShipSpatial().rotate(0, -.5f * tpf, 0);
galaxyNode.updateGeometricState();
} else if (name.equals(“RollRight”)) {
player.getShipSpatial().rotate(0, 0, .5f * tpf);
galaxyNode.updateGeometricState();
} else if (name.equals(“RollLeft”)) {
player.getShipSpatial().rotate(0, 0, -.5f * tpf);
galaxyNode.updateGeometricState();
}
}
};
[/java]
normen
February 19, 2011, 12:47am
5
Yeah, I have strange issues in physics with rotation too since some time… It seems I get zero Matrixes out of some Quaternions lately…
mulova
February 19, 2011, 3:45am
6
reverted the change. rev. 6790
I don’t find any logical error on this patch.
But I reverted because of the wierd errors. rev. 6689, 6616, 6560
madjack
February 19, 2011, 9:16pm
7
I confirm that the reverts fix the problem. The ship now behaves the way it was before.