Search in sources :

Example 16 with Matrix4f

use of javax.vecmath.Matrix4f in project bdx by GoranM.

the class GameObject method position.

public void position(Vector3f vec) {
    activate();
    Matrix4f t = transform();
    t.setTranslation(vec);
    transform(t);
}
Also used : Matrix4f(javax.vecmath.Matrix4f)

Example 17 with Matrix4f

use of javax.vecmath.Matrix4f in project bdx by GoranM.

the class GameObject method orientation.

public Matrix3f orientation() {
    Matrix4f t = transform();
    Matrix3f ori = new Matrix3f();
    t.getRotationScale(ori);
    return ori;
}
Also used : Matrix4f(javax.vecmath.Matrix4f) Matrix3f(javax.vecmath.Matrix3f)

Example 18 with Matrix4f

use of javax.vecmath.Matrix4f in project bdx by GoranM.

the class GameObject method scale.

public void scale(float x, float y, float z, boolean updateLocal) {
    activate();
    // Set unit scale
    Matrix4 t = modelInstance.transform;
    Matrix4 mat_scale = new Matrix4();
    Vector3 s = new Vector3();
    t.getScale(s);
    mat_scale.scl(1 / s.x, 1 / s.y, 1 / s.z);
    t.mul(mat_scale);
    scale.set(x, y, z);
    // Set target scale
    mat_scale.idt();
    mat_scale.scl(x, y, z);
    t.mul(mat_scale);
    // Relevant bullet body update
    CollisionShape cs = body.getCollisionShape();
    cs.setLocalScaling(new Vector3f(x, y, z));
    if (body.isInWorld() && body.isStaticOrKinematicObject())
        scene.world.updateSingleAabb(body);
    // Child propagation
    Vector3f ps = scale();
    Matrix4f pt = transform();
    Matrix4f ct = new Matrix4f();
    Matrix4f ms = new Matrix4f();
    ms.setIdentity();
    ms.m00 = ps.x;
    ms.m11 = ps.y;
    ms.m22 = ps.z;
    pt.mul(ms);
    for (GameObject c : children) {
        c.scale(scale().mul(c.localScale), false);
        ct.mul(pt, c.localTransform);
        c.transform(ct, false);
    }
    if (parent != null && updateLocal) {
        updateLocalScale();
    }
}
Also used : Matrix4f(javax.vecmath.Matrix4f) CollisionShape(com.bulletphysics.collision.shapes.CollisionShape) Vector3f(javax.vecmath.Vector3f) Vector3(com.badlogic.gdx.math.Vector3) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 19 with Matrix4f

use of javax.vecmath.Matrix4f in project bdx by GoranM.

the class GameObject method transform.

public Matrix4f transform() {
    Transform t = new Transform();
    body.getWorldTransform(t);
    Vector3f v = new Vector3f();
    for (int i = 0; i < 3; ++i) {
        t.basis.getColumn(i, v);
        v.normalize();
        t.basis.setColumn(i, v);
    }
    Matrix4f m = new Matrix4f();
    t.getMatrix(m);
    return m;
}
Also used : Matrix4f(javax.vecmath.Matrix4f) Vector3f(javax.vecmath.Vector3f) Transform(com.bulletphysics.linearmath.Transform) ManifoldPoint(com.bulletphysics.collision.narrowphase.ManifoldPoint)

Example 20 with Matrix4f

use of javax.vecmath.Matrix4f in project bdx by GoranM.

the class GameObject method updateChildTransforms.

public void updateChildTransforms() {
    Matrix4f pt = transform();
    Matrix4f ct = new Matrix4f();
    Matrix4f ms = new Matrix4f();
    ms.setIdentity();
    Vector3f ps = scale();
    ms.m00 = ps.x;
    ms.m11 = ps.y;
    ms.m22 = ps.z;
    pt.mul(ms);
    for (GameObject c : children) {
        ct.mul(pt, c.localTransform);
        c.transform(ct, false);
    }
}
Also used : Matrix4f(javax.vecmath.Matrix4f) Vector3f(javax.vecmath.Vector3f)

Aggregations

Matrix4f (javax.vecmath.Matrix4f)29 Vector3f (javax.vecmath.Vector3f)10 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)4 Matrix3f (javax.vecmath.Matrix3f)3 Matrix4 (com.badlogic.gdx.math.Matrix4)2 Vector3 (com.badlogic.gdx.math.Vector3)2 ManifoldPoint (com.bulletphysics.collision.narrowphase.ManifoldPoint)2 CollisionShape (com.bulletphysics.collision.shapes.CollisionShape)2 Transform (com.bulletphysics.linearmath.Transform)2 Mesh (com.nilunder.bdx.gl.Mesh)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Vector4f (javax.vecmath.Vector4f)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 ConveyorDirection (blusunrize.immersiveengineering.api.tool.ConveyorHandler.ConveyorDirection)1 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)1 IMixinTextureAtlasSprite (com.almuradev.content.mixin.iface.IMixinTextureAtlasSprite)1 Face (com.almuradev.content.model.obj.geometry.Face)1 Group (com.almuradev.content.model.obj.geometry.Group)1 Vertex (com.almuradev.content.model.obj.geometry.Vertex)1