public static javax.vecmath.Matrix3f convert(com.jme3.math.Matrix3f oldMatrix) { javax.vecmath.Matrix3f newMatrix = new javax.vecmath.Matrix3f(); convert(oldMatrix, newMatrix); return newMatrix; }
public BulletPhysics(WorldProvider world) { broadphase = new DbvtBroadphase(); broadphase.getOverlappingPairCache().setInternalGhostPairCallback(new GhostPairCallback()); CollisionConfiguration defaultCollisionConfiguration = new DefaultCollisionConfiguration(); dispatcher = new CollisionDispatcher(defaultCollisionConfiguration); SequentialImpulseConstraintSolver sequentialImpulseConstraintSolver = new SequentialImpulseConstraintSolver(); discreteDynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, sequentialImpulseConstraintSolver, defaultCollisionConfiguration); discreteDynamicsWorld.setGravity(new Vector3f(0f, -15f, 0f)); blockEntityRegistry = CoreRegistry.get(BlockEntityRegistry.class); wrapper = new PhysicsWorldWrapper(world); VoxelWorldShape worldShape = new VoxelWorldShape(wrapper); liquidWrapper = new PhysicsLiquidWrapper(world); VoxelWorldShape liquidShape = new VoxelWorldShape(liquidWrapper); Matrix3f rot = new Matrix3f(); rot.setIdentity(); DefaultMotionState blockMotionState = new DefaultMotionState(new Transform(new Matrix4f(rot, new Vector3f(0, 0, 0), 1.0f))); RigidBodyConstructionInfo blockConsInf = new RigidBodyConstructionInfo(0, blockMotionState, worldShape, new Vector3f()); BulletRigidBody rigidBody = new BulletRigidBody(blockConsInf); rigidBody.rb.setCollisionFlags(CollisionFlags.STATIC_OBJECT | rigidBody.rb.getCollisionFlags()); short mask = (short) (~(CollisionFilterGroups.STATIC_FILTER | StandardCollisionGroup.LIQUID.getFlag())); discreteDynamicsWorld.addRigidBody(rigidBody.rb, combineGroups(StandardCollisionGroup.WORLD), mask); RigidBodyConstructionInfo liquidConsInfo = new RigidBodyConstructionInfo(0, blockMotionState, liquidShape, new Vector3f()); BulletRigidBody liquidBody = new BulletRigidBody(liquidConsInfo); liquidBody.rb.setCollisionFlags(CollisionFlags.STATIC_OBJECT | rigidBody.rb.getCollisionFlags()); discreteDynamicsWorld.addRigidBody(liquidBody.rb, combineGroups(StandardCollisionGroup.LIQUID), CollisionFilterGroups.SENSOR_TRIGGER); }
/** * Utility method to rotate a given mesh using a given rotation matrix. * @param input the mesh to rotate. Not modified. * @param matrix the rotation to apply to the mesh. Not Modified. * @return the rotated mesh. */ public static MeshDataHolder rotate(MeshDataHolder input, Matrix3d matrix) { return rotate(input, new Matrix3f(matrix)); }
public static javax.vecmath.Matrix3f convert(com.jme3.math.Matrix3f oldMatrix) { javax.vecmath.Matrix3f newMatrix = new javax.vecmath.Matrix3f(); convert(oldMatrix, newMatrix); return newMatrix; }
public static javax.vecmath.Matrix3f convert(com.jme3.math.Matrix3f oldMatrix) { javax.vecmath.Matrix3f newMatrix = new javax.vecmath.Matrix3f(); convert(oldMatrix, newMatrix); return newMatrix; }
private static Matrix3f roundAndReduceMatrixElements(Matrix4f m) { Preconditions.checkArgument(m.m30 == 0); Preconditions.checkArgument(m.m31 == 0); Preconditions.checkArgument(m.m32 == 0); Preconditions.checkArgument(m.m03 == 0); Preconditions.checkArgument(m.m13 == 0); Preconditions.checkArgument(m.m23 == 0); Preconditions.checkArgument(m.m33 == 1); final Matrix3f result = new Matrix3f(); result.m00 = Math.round(m.m00); result.m01 = Math.round(m.m01); result.m02 = Math.round(m.m02); result.m10 = Math.round(m.m10); result.m11 = Math.round(m.m11); result.m12 = Math.round(m.m12); result.m20 = Math.round(m.m20); result.m21 = Math.round(m.m21); result.m22 = Math.round(m.m22); return result; }
Matrix3f m3f = new Matrix3f();
/** * Utility method to rotate a given mesh using a given rotation matrix. * @param input the mesh to rotate. Not modified. * @param axisAngle the axis-angle describing the rotation to apply to the mesh. Not Modified. * @return the rotated mesh. */ public static MeshDataHolder rotate(MeshDataHolder input, AxisAngle4d axisAngle) { Matrix3f matrix = new Matrix3f(); matrix.set(axisAngle); return rotate(input, matrix); }
public static Matrix3f generateRandomMatrix3f(Random random, float maxAbsolute) { Matrix3f ret = new Matrix3f(); for(int row = 0; row < 3; row++) { for (int column = 0; column < 3; column++) { ret.setElement(row, column, generateRandomFloatInRange(random, -maxAbsolute, maxAbsolute)); } } return ret; }
/** * Utility method to rotate a given mesh using a given rotation matrix. * @param input the mesh to rotate. Not modified. * @param quaternion the quaternion describing the rotation to apply to the mesh. Not Modified. * @return the rotated mesh. */ public static MeshDataHolder rotate(MeshDataHolder input, Quat4f quaternion) { Matrix3f matrix = new Matrix3f(); matrix.set(quaternion); return rotate(input, matrix); }
public Transformer(TRSRTransformation transformation, VertexFormat format) { super(new UnpackedBakedQuad.Builder(format)); // position transform this.transformation = transformation.getMatrix(); // normal transform this.normalTransformation = new Matrix3f(); this.transformation.getRotationScale(this.normalTransformation); this.normalTransformation.invert(); this.normalTransformation.transpose(); }
public Transformer(TRSRTransformation transformation, VertexFormat format) { super(new UnpackedBakedQuad.Builder(format)); // position transform this.transformation = transformation.getMatrix(); // normal transform this.normalTransformation = new Matrix3f(); this.transformation.getRotationScale(this.normalTransformation); this.normalTransformation.invert(); this.normalTransformation.transpose(); }
public Transformer(TRSRTransformation transformation, VertexFormat format) { super(new UnpackedBakedQuad.Builder(format)); // position transform this.transformation = transformation.getMatrix(); // normal transform this.normalTransformation = new Matrix3f(); this.transformation.getRotationScale(this.normalTransformation); this.normalTransformation.invert(); this.normalTransformation.transpose(); }
public Transformer(TRSRTransformation transformation, VertexFormat format) { super(new UnpackedBakedQuad.Builder(format)); // position transform this.transformation = transformation.getMatrix(); // normal transform this.normalTransformation = new Matrix3f(); this.transformation.getRotationScale(this.normalTransformation); this.normalTransformation.invert(); this.normalTransformation.transpose(); }
private static Vector3d rotate(Vector3d vector, Vector3d axis, double angle) { Matrix3f rotate = new Matrix3f(); rotate.set(new AxisAngle4f(new Vector3f(axis), (float) Math.toRadians(angle))); Vector3f result = new Vector3f(); Vector3f vector3f = new Vector3f(vector); rotate.transform(vector3f, result); return new Vector3d(result); }
private static Vector3d rotate(Vector3d vector, Vector3d axis, double angle) { Matrix3f rotate = new Matrix3f(); rotate.set(new AxisAngle4f(new Vector3f(axis), (float) Math.toRadians(angle))); Vector3f result = new Vector3f(); Vector3f vector3f = new Vector3f(vector); rotate.transform(vector3f, result); return new Vector3d(result); }
private Orientation(HalfAxis x, HalfAxis y) { this.x = x; this.y = y; this.z = x.cross(y); addDirectionMappings(EnumFacing.EAST, x.dir); addDirectionMappings(EnumFacing.UP, y.dir); addDirectionMappings(EnumFacing.SOUTH, z.dir); this.name = x.shortName + "_" + y.shortName + "_" + z.shortName; this.lowercaseName = name().toLowerCase(Locale.ROOT); this.blockCenterToWorld = new Matrix3f( x.x, y.x, z.x, x.y, y.y, z.y, x.z, y.z, z.z); final Matrix4f tmp = new Matrix4f(); tmp.set(this.blockCenterToWorld); this.blockCornerToWorld = blockCenterToCorner(tmp); }
private static Multimap<Orientation, XYZRotation> calculateXyzRotations(Map<Matrix3f, Orientation> fromMatrix) { final Multimap<Orientation, XYZRotation> toXYZRotation = HashMultimap.create(); for (Rotation x : Rotation.values()) for (Rotation y : Rotation.values()) for (Rotation z : Rotation.values()) { final XYZRotation rotation = new XYZRotation(x, y, z); Quat4f q = new Quat4f(0, 0, 0, 1); Quat4f tmp = new Quat4f(); tmp.set(new AxisAngle4f(0, 0, 1, z.angle)); q.mul(tmp); tmp.set(new AxisAngle4f(0, 1, 0, y.angle)); q.mul(tmp); tmp.set(new AxisAngle4f(1, 0, 0, x.angle)); q.mul(tmp); Matrix3f m = new Matrix3f(); m.set(q); roundMatrixElements(m); final Orientation orientation = fromMatrix.get(m); Preconditions.checkNotNull(orientation, rotation); toXYZRotation.put(orientation, rotation); } return toXYZRotation; }