Search in sources :

Example 1 with Quaternion

use of com.jogamp.opengl.math.Quaternion in project narchy by automenta.

the class Flatten method accept.

@Override
public void accept(Spatial<X> ss) {
    if (ss instanceof SimpleSpatial) {
        SimpleSpatial s = (SimpleSpatial) ss;
        // v3 f = v();
        // locate(s, f);
        // s.move(f, rate);
        Body3D b = s.body;
        if (b == null)
            return;
        float tz = b.transform.z;
        if (Math.abs(tz) > zTolerance) {
            // b.velAdd(v( 0, 0,
            // -(tz > 0 ? (tz - zTolerance) : (tz + zTolerance)) * zSpeed));
            b.linearVelocity.z *= zSpeed;
            b.transform.z *= zSpeed;
        } else {
        // dont affect
        }
        s.rotate(up, rotateRate, new Quaternion());
    // dampening: keep upright and eliminate z-component of linear velocity
    // b.linearVelocity.scale(
    // 1f, 1f, 0.9f
    // );
    // b.angularVelocity.scale(1f-rotateRate);
    // b.angularVelocity.zero();
    }
}
Also used : SimpleSpatial(spacegraph.space3d.SimpleSpatial) Quaternion(com.jogamp.opengl.math.Quaternion) Body3D(spacegraph.space3d.phys.Body3D)

Example 2 with Quaternion

use of com.jogamp.opengl.math.Quaternion in project narchy by automenta.

the class SimpleSpatial method rotate.

public void rotate(Quaternion target, float speed, Quaternion tmp) {
    // if (motionLock)
    // return;
    Quaternion current = transform.getRotation(tmp);
    current.setSlerp(current, target, speed);
    transform.setRotation(current);
    reactivate();
}
Also used : Quaternion(com.jogamp.opengl.math.Quaternion)

Example 3 with Quaternion

use of com.jogamp.opengl.math.Quaternion in project narchy by automenta.

the class SimpleSpatial method rotate.

public void rotate(float tx, float ty, float tz, float angle, float speed) {
    Quaternion q = transform.getRotation(new Quaternion());
    q.rotateByAngleNormalAxis(angle, tx, ty, tz);
    rotate(q, speed);
}
Also used : Quaternion(com.jogamp.opengl.math.Quaternion)

Aggregations

Quaternion (com.jogamp.opengl.math.Quaternion)3 SimpleSpatial (spacegraph.space3d.SimpleSpatial)1 Body3D (spacegraph.space3d.phys.Body3D)1