use of org.joml.Matrix4f in project Terasology by MovingBlocks.
the class BlockSelectionRenderer method renderMark2.
public void renderMark2(Vector3ic blockPos) {
Camera camera = worldRenderer.getActiveCamera();
final Vector3f cameraPosition = camera.getPosition();
Matrix4f modelView = new Matrix4f();
modelView.set(camera.getViewMatrix()).mul(new Matrix4f().setTranslation(blockPos.x() - cameraPosition.x, blockPos.y() - cameraPosition.y, blockPos.z() - cameraPosition.z));
blockSelectionMat.setMatrix4("modelViewMatrix", modelView);
overlayMesh2.render();
}
use of org.joml.Matrix4f in project Terasology by MovingBlocks.
the class BulletPhysics method removeRigidBody.
@Override
public boolean removeRigidBody(EntityRef entity) {
BulletRigidBody rigidBody = entityRigidBodies.remove(entity);
if (rigidBody != null) {
removeRigidBody(rigidBody);
// wake up this entities neighbors
Matrix4f m = new Matrix4f();
Vector3f aabbMin = new Vector3f();
Vector3f aabbMax = new Vector3f();
rigidBody.rb.getCollisionShape().getAabb(m, aabbMin, aabbMax);
awakenArea(rigidBody.getLocation(new Vector3f()), (aabbMax.sub(aabbMin)).length() * .5f);
return true;
} else {
logger.warn("Deleting non existing rigidBody from physics engine?! Entity: {}", entity);
return false;
}
}
use of org.joml.Matrix4f in project Terasology by MovingBlocks.
the class BulletPhysics method updateTrigger.
@Override
public // TODO: update if detectGroups changed
boolean updateTrigger(EntityRef entity) {
LocationComponent location = entity.getComponent(LocationComponent.class);
if (location == null) {
logger.warn("Trying to update or create trigger of entity that has no LocationComponent?! Entity: {}", entity);
return false;
}
btPairCachingGhostObject triggerObj = entityTriggers.get(entity);
if (triggerObj != null) {
float scale = location.getWorldScale();
if (Math.abs(triggerObj.getCollisionShape().getLocalScaling().x - scale) > SIMD_EPSILON) {
discreteDynamicsWorld.removeCollisionObject(triggerObj);
newTrigger(entity);
} else {
Quaternionf worldRotation = location.getWorldRotation(new Quaternionf());
Vector3f position = location.getWorldPosition(new Vector3f());
if (!position.isFinite() || !worldRotation.isFinite()) {
logger.warn("Can't update Trigger entity with a non-finite position/rotation?! Entity: {}", entity);
return false;
}
triggerObj.setWorldTransform(new Matrix4f().translationRotateScale(position, worldRotation, 1.0f));
}
return true;
} else {
newTrigger(entity);
return false;
}
}
use of org.joml.Matrix4f in project Terasology by MovingBlocks.
the class BulletCollisionShape method getAABB.
@Override
public AABBf getAABB(Vector3fc origin, Quaternionfc rotation, float scale) {
Vector3f min = new Vector3f();
Vector3f max = new Vector3f();
Matrix4f m = new Matrix4f();
underlyingShape.getAabb(m, min, max);
return new AABBf(min, max).translate(origin);
}
use of org.joml.Matrix4f in project Terasology by MovingBlocks.
the class BulletCompoundShape method rotate.
// TODO: Add removeChildShape if needed
@Override
public CollisionShape rotate(Quaternionf rot) {
BulletCompoundShape shape = new BulletCompoundShape();
for (BulletCompoundShapeChild child : childList) {
Matrix4f transform = new Matrix4f().rotate(rot).mul(child.transform);
shape.compoundShape.addChildShape(transform, child.childShape.underlyingShape);
shape.childList.add(new BulletCompoundShapeChild(transform, child.childShape, compoundShape.getChildShape(compoundShape.getNumChildShapes() - 1)));
}
return shape;
}
Aggregations