use of com.jme3.math.Matrix3f in project jmonkeyengine by jMonkeyEngine.
the class PhysicsGhostObject method getPhysicsRotationMatrix.
/**
* @return the physicsLocation
*/
public Matrix3f getPhysicsRotationMatrix(Matrix3f rot) {
if (rot == null) {
rot = new Matrix3f();
}
gObject.getWorldTransform(tempTrans);
Converter.convert(tempTrans.getRotation(tempRot), physicsLocation.getRotation());
return rot.set(physicsLocation.getRotation());
}
use of com.jme3.math.Matrix3f in project jmonkeyengine by jMonkeyEngine.
the class NewtonianParticleInfluencer method influenceParticle.
@Override
public void influenceParticle(Particle particle, EmitterShape emitterShape) {
emitterShape.getRandomPointAndNormal(particle.position, particle.velocity);
// influencing the particle's velocity
if (surfaceTangentFactor == 0.0f) {
particle.velocity.multLocal(normalVelocity);
} else {
// calculating surface tangent (velocity contains the 'normal' value)
temp.set(particle.velocity.z * surfaceTangentFactor, particle.velocity.y * surfaceTangentFactor, -particle.velocity.x * surfaceTangentFactor);
if (surfaceTangentRotation != 0.0f) {
// rotating the tangent
Matrix3f m = new Matrix3f();
m.fromAngleNormalAxis(FastMath.PI * surfaceTangentRotation, particle.velocity);
temp = m.multLocal(temp);
}
// applying normal factor (this must be done first)
particle.velocity.multLocal(normalVelocity);
// adding tangent vector
particle.velocity.addLocal(temp);
}
if (velocityVariation != 0.0f) {
this.applyVelocityVariation(particle);
}
}
use of com.jme3.math.Matrix3f in project jmonkeyengine by jMonkeyEngine.
the class FlyByCamera method rotateCamera.
protected void rotateCamera(float value, Vector3f axis) {
if (dragToRotate) {
if (canRotate) {
// value = -value;
} else {
return;
}
}
Matrix3f mat = new Matrix3f();
mat.fromAngleNormalAxis(rotationSpeed * value, axis);
Vector3f up = cam.getUp();
Vector3f left = cam.getLeft();
Vector3f dir = cam.getDirection();
mat.mult(up, up);
mat.mult(left, left);
mat.mult(dir, dir);
Quaternion q = new Quaternion();
q.fromAxes(left, up, dir);
q.normalizeLocal();
cam.setAxes(q);
}
use of com.jme3.math.Matrix3f in project jmonkeyengine by jMonkeyEngine.
the class CompoundCollisionShape method addChildShape.
/**
* adds a child shape at the given local translation
* @param shape the child shape to add
* @param location the local location of the child shape
*/
public void addChildShape(CollisionShape shape, Vector3f location, Matrix3f rotation) {
if (shape instanceof CompoundCollisionShape) {
throw new IllegalStateException("CompoundCollisionShapes cannot have CompoundCollisionShapes as children!");
}
Transform transA = new Transform(Converter.convert(rotation));
Converter.convert(location, transA.origin);
Converter.convert(rotation, transA.basis);
children.add(new ChildCollisionShape(location.clone(), rotation.clone(), shape));
((CompoundShape) cShape).addChildShape(transA, shape.getCShape());
}
use of com.jme3.math.Matrix3f in project jmonkeyengine by jMonkeyEngine.
the class PhysicsGhostObject method read.
@Override
public void read(JmeImporter e) throws IOException {
super.read(e);
InputCapsule capsule = e.getCapsule(this);
buildObject();
setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f()));
setPhysicsRotation(((Matrix3f) capsule.readSavable("physicsRotation", new Matrix3f())));
setCcdMotionThreshold(capsule.readFloat("ccdMotionThreshold", 0));
setCcdSweptSphereRadius(capsule.readFloat("ccdSweptSphereRadius", 0));
}
Aggregations