Search in sources :

Example 36 with Transform

use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.

the class ShadowUtil method computeUnionBound.

/**
     * Compute bounds of a geomList
     * @param list
     * @param transform
     * @return
     */
public static BoundingBox computeUnionBound(GeometryList list, Transform transform) {
    BoundingBox bbox = new BoundingBox();
    TempVars tempv = TempVars.get();
    for (int i = 0; i < list.size(); i++) {
        BoundingVolume vol = list.get(i).getWorldBound();
        BoundingVolume newVol = vol.transform(transform, tempv.bbox);
        //Nehon : prevent NaN and infinity values to screw the final bounding box
        if (!Float.isNaN(newVol.getCenter().x) && !Float.isInfinite(newVol.getCenter().x)) {
            bbox.mergeLocal(newVol);
        }
    }
    tempv.release();
    return bbox;
}
Also used : BoundingBox(com.jme3.bounding.BoundingBox) BoundingVolume(com.jme3.bounding.BoundingVolume) TempVars(com.jme3.util.TempVars)

Example 37 with Transform

use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.

the class GeometryBatchFactory method doTransformVerts.

private static void doTransformVerts(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f pos = new Vector3f();
    // offset is given in element units
    // convert to be in component units
    offset *= 3;
    for (int i = 0; i < inBuf.limit() / 3; i++) {
        pos.x = inBuf.get(i * 3 + 0);
        pos.y = inBuf.get(i * 3 + 1);
        pos.z = inBuf.get(i * 3 + 2);
        transform.mult(pos, pos);
        outBuf.put(offset + i * 3 + 0, pos.x);
        outBuf.put(offset + i * 3 + 1, pos.y);
        outBuf.put(offset + i * 3 + 2, pos.z);
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 38 with Transform

use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.

the class GeometryBatchFactory method doTransformTangents.

private static void doTransformTangents(FloatBuffer inBuf, int offset, int components, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f tan = new Vector3f();
    // offset is given in element units
    // convert to be in component units
    offset *= components;
    for (int i = 0; i < inBuf.limit() / components; i++) {
        tan.x = inBuf.get(i * components + 0);
        tan.y = inBuf.get(i * components + 1);
        tan.z = inBuf.get(i * components + 2);
        transform.multNormal(tan, tan);
        outBuf.put(offset + i * components + 0, tan.x);
        outBuf.put(offset + i * components + 1, tan.y);
        outBuf.put(offset + i * components + 2, tan.z);
        if (components == 4) {
            outBuf.put(offset + i * components + 3, inBuf.get(i * components + 3));
        }
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 39 with Transform

use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.

the class GeometryBatchFactory method doTransformNorms.

private static void doTransformNorms(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f norm = new Vector3f();
    // offset is given in element units
    // convert to be in component units
    offset *= 3;
    for (int i = 0; i < inBuf.limit() / 3; i++) {
        norm.x = inBuf.get(i * 3 + 0);
        norm.y = inBuf.get(i * 3 + 1);
        norm.z = inBuf.get(i * 3 + 2);
        transform.multNormal(norm, norm);
        outBuf.put(offset + i * 3 + 0, norm.x);
        outBuf.put(offset + i * 3 + 1, norm.y);
        outBuf.put(offset + i * 3 + 2, norm.z);
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 40 with Transform

use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.

the class Constraint method apply.

/**
     * Applies the constraint to owner (and in some cases can alter other bones of the skeleton).
     * @param frame
     *            the frame of the animation
     */
public void apply(int frame) {
    if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.log(Level.FINEST, "Applying constraint: {0} for frame {1}", new Object[] { name, frame });
    }
    Transform targetTransform = targetOMA != null ? constraintHelper.getTransform(targetOMA, subtargetName, targetSpace) : null;
    constraintDefinition.bake(ownerSpace, targetSpace, targetTransform, (float) ipo.calculateValue(frame));
}
Also used : Transform(com.jme3.math.Transform)

Aggregations

Vector3f (com.jme3.math.Vector3f)29 Transform (com.jme3.math.Transform)26 TempVars (com.jme3.util.TempVars)24 Quaternion (com.jme3.math.Quaternion)11 Matrix4f (com.jme3.math.Matrix4f)10 Bone (com.jme3.animation.Bone)9 BoundingBox (com.jme3.bounding.BoundingBox)6 BoneContext (com.jme3.scene.plugins.blender.animations.BoneContext)5 PointLight (com.jme3.light.PointLight)4 Spatial (com.jme3.scene.Spatial)4 FloatBuffer (java.nio.FloatBuffer)4 Transform (com.bulletphysics.linearmath.Transform)3 ChildCollisionShape (com.jme3.bullet.collision.shapes.infos.ChildCollisionShape)3 DirectionalLight (com.jme3.light.DirectionalLight)3 Light (com.jme3.light.Light)3 SpotLight (com.jme3.light.SpotLight)3 CompoundShape (com.bulletphysics.collision.shapes.CompoundShape)2 BoneTrack (com.jme3.animation.BoneTrack)2 SpatialTrack (com.jme3.animation.SpatialTrack)2 BoundingVolume (com.jme3.bounding.BoundingVolume)2