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);
}
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;
}
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();
}
}
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;
}
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);
}
}
Aggregations