本文整理汇总了Java中com.jme3.math.Matrix3f类的典型用法代码示例。如果您正苦于以下问题:Java Matrix3f类的具体用法?Java Matrix3f怎么用?Java Matrix3f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Matrix3f类属于com.jme3.math包,在下文中一共展示了Matrix3f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import com.jme3.math.Matrix3f; //导入依赖的package包/类
@FXThread
private void build(@NotNull final ChildCollisionShape shape, @NotNull final VBox container,
@NotNull final ModelChangeConsumer changeConsumer) {
final Vector3f location = shape.location;
final Matrix3f rotation = shape.rotation;
final DefaultSinglePropertyControl<ModelChangeConsumer, ChildCollisionShape, Vector3f> locationControl =
new DefaultSinglePropertyControl<>(location, Messages.MODEL_PROPERTY_LOCATION, changeConsumer);
locationControl.setSyncHandler(collisionShape -> collisionShape.location);
locationControl.setToStringFunction(Vector3f::toString);
locationControl.setEditObject(shape);
final DefaultSinglePropertyControl<ModelChangeConsumer, ChildCollisionShape, Matrix3f> rotationControl =
new DefaultSinglePropertyControl<>(rotation, Messages.MODEL_PROPERTY_ROTATION, changeConsumer);
rotationControl.setSyncHandler(collisionShape -> collisionShape.rotation);
rotationControl.setToStringFunction(matrix3f -> new Quaternion().fromRotationMatrix(matrix3f).toString());
rotationControl.setEditObject(shape);
rotationControl.reload();
FXUtils.addToPane(locationControl, container);
FXUtils.addToPane(rotationControl, container);
}
示例2: onAction
import com.jme3.math.Matrix3f; //导入依赖的package包/类
public void onAction(String binding, boolean value, float tpf) {
if (binding.equals("Lefts")) {
hoverControl.steer(value ? 50f : 0);
} else if (binding.equals("Rights")) {
hoverControl.steer(value ? -50f : 0);
} else if (binding.equals("Ups")) {
hoverControl.accelerate(value ? 100f : 0);
} else if (binding.equals("Downs")) {
hoverControl.accelerate(value ? -100f : 0);
} else if (binding.equals("Reset")) {
if (value) {
System.out.println("Reset");
hoverControl.setPhysicsLocation(new Vector3f(-140, 14, -23));
hoverControl.setPhysicsRotation(new Matrix3f());
hoverControl.clearForces();
} else {
}
} else if (binding.equals("Space") && value) {
makeMissile();
}
}
示例3: getOffsetTransform
import com.jme3.math.Matrix3f; //导入依赖的package包/类
/**
* Stores the skinning transform in the specified Matrix4f.
* The skinning transform applies the animation of the bone to a vertex.
* @param m
*/
void getOffsetTransform(Matrix4f m, Quaternion tmp1, Vector3f tmp2, Vector3f tmp3, Matrix3f rotMat) {
//Computing scale
Vector3f scale = worldScale.mult(worldBindInverseScale, tmp3);
//computing rotation
Quaternion rotate = worldRot.mult(worldBindInverseRot, tmp1);
//computing translation
//translation depend on rotation and scale
Vector3f translate = worldPos.add(rotate.mult(scale.mult(worldBindInversePos, tmp2), tmp2), tmp2);
//populating the matrix
m.loadIdentity();
m.setTransform(translate, scale, rotate.toRotationMatrix(rotMat));
}
示例4: write
import com.jme3.math.Matrix3f; //导入依赖的package包/类
@Override
public void write(JmeExporter e) throws IOException {
super.write(e);
OutputCapsule capsule = e.getCapsule(this);
capsule.write(getMass(), "mass", 1.0f);
capsule.write(getGravity(), "gravity", Vector3f.ZERO);
capsule.write(getFriction(), "friction", 0.5f);
capsule.write(getRestitution(), "restitution", 0);
capsule.write(getAngularFactor(), "angularFactor", 1);
capsule.write(kinematic, "kinematic", false);
capsule.write(constructionInfo.linearDamping, "linearDamping", 0);
capsule.write(constructionInfo.angularDamping, "angularDamping", 0);
capsule.write(constructionInfo.linearSleepingThreshold, "linearSleepingThreshold", 0.8f);
capsule.write(constructionInfo.angularSleepingThreshold, "angularSleepingThreshold", 1.0f);
capsule.write(getCcdMotionThreshold(), "ccdMotionThreshold", 0);
capsule.write(getCcdSweptSphereRadius(), "ccdSweptSphereRadius", 0);
capsule.write(getPhysicsLocation(new Vector3f()), "physicsLocation", new Vector3f());
capsule.write(getPhysicsRotationMatrix(new Matrix3f()), "physicsRotation", new Matrix3f());
capsule.writeSavableArrayList(joints, "joints", null);
}
示例5: read
import com.jme3.math.Matrix3f; //导入依赖的package包/类
@Override
public void read(JmeImporter e) throws IOException {
super.read(e);
InputCapsule capsule = e.getCapsule(this);
float mass = capsule.readFloat("mass", 1.0f);
this.mass = mass;
rebuildRigidBody();
setGravity((Vector3f) capsule.readSavable("gravity", Vector3f.ZERO.clone()));
setFriction(capsule.readFloat("friction", 0.5f));
setKinematic(capsule.readBoolean("kinematic", false));
setRestitution(capsule.readFloat("restitution", 0));
setAngularFactor(capsule.readFloat("angularFactor", 1));
setDamping(capsule.readFloat("linearDamping", 0), capsule.readFloat("angularDamping", 0));
setSleepingThresholds(capsule.readFloat("linearSleepingThreshold", 0.8f), capsule.readFloat("angularSleepingThreshold", 1.0f));
setCcdMotionThreshold(capsule.readFloat("ccdMotionThreshold", 0));
setCcdSweptSphereRadius(capsule.readFloat("ccdSweptSphereRadius", 0));
setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f()));
setPhysicsRotation((Matrix3f) capsule.readSavable("physicsRotation", new Matrix3f()));
joints = capsule.readSavableArrayList("joints", null);
}
示例6: SixDofJoint
import com.jme3.math.Matrix3f; //导入依赖的package包/类
/**
* @param pivotA local translation of the joint connection point in node A
* @param pivotB local translation of the joint connection point in node B
*/
public SixDofJoint(PhysicsRigidBody nodeA, PhysicsRigidBody nodeB, Vector3f pivotA, Vector3f pivotB, Matrix3f rotA, Matrix3f rotB, boolean useLinearReferenceFrameA) {
super(nodeA, nodeB, pivotA, pivotB);
this.useLinearReferenceFrameA = useLinearReferenceFrameA;
Transform transA = new Transform(Converter.convert(rotA));
Converter.convert(pivotA, transA.origin);
Converter.convert(rotA, transA.basis);
Transform transB = new Transform(Converter.convert(rotB));
Converter.convert(pivotB, transB.origin);
Converter.convert(rotB, transB.basis);
constraint = new Generic6DofConstraint(nodeA.getObjectId(), nodeB.getObjectId(), transA, transB, useLinearReferenceFrameA);
gatherMotors();
}
示例7: renderFromControl
import com.jme3.math.Matrix3f; //导入依赖的package包/类
/**
* Callback from Control.render(), do not use.
*
* @param rm
* @param vp
*/
private void renderFromControl(RenderManager rm, ViewPort vp) {
Camera cam = vp.getCamera();
if (meshType == ParticleMesh.Type.Point) {
float C = cam.getProjectionMatrix().m00;
C *= cam.getWidth() * 0.5f;
// send attenuation params
this.getMaterial().setFloat("Quadratic", C);
}
Matrix3f inverseRotation = Matrix3f.IDENTITY;
TempVars vars = null;
if (!worldSpace) {
vars = TempVars.get();
inverseRotation = this.getWorldRotation().toRotationMatrix(vars.tempMat3).invertLocal();
}
particleMesh.updateParticleData(particles, cam, inverseRotation);
if (!worldSpace) {
vars.release();
}
}
示例8: influenceParticle
import com.jme3.math.Matrix3f; //导入依赖的package包/类
@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);
}
}
示例9: rotateCamera
import com.jme3.math.Matrix3f; //导入依赖的package包/类
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.normalize();
cam.setAxes(q);
}
示例10: getPropertyEditor
import com.jme3.math.Matrix3f; //导入依赖的package包/类
@Override
public PropertyEditor getPropertyEditor() {
if (valueType == Vector3f.class) {
return new Vector3fPropertyEditor();
} else if (valueType == Quaternion.class) {
return new QuaternionPropertyEditor();
} else if (valueType == Matrix3f.class) {
return new Matrix3fPropertyEditor();
} else if (valueType == ColorRGBA.class) {
return new ColorRGBAPropertyEditor();
} else if (valueType == Vector2f.class) {
return new Vector2fPropertyEditor();
} else if (valueType == Texture.class) {
return new TexturePropertyEditor(lookup.lookup(ProjectAssetManager.class));
}
return super.getPropertyEditor();
}
示例11: setAsText
import com.jme3.math.Matrix3f; //导入依赖的package包/类
public void setAsText(String text) throws IllegalArgumentException {
text = text.replace('[', ' ');
text = text.replace(']', ' ');
String[] values = text.split(",");
if (values.length != 3) {
throw (new IllegalArgumentException("String not correct"));
}
float[] floats = new float[3];
for (int i = 0; i < values.length; i++) {
String string = values[i];
floats[i] = Float.parseFloat(string);
}
Matrix3f old = new Matrix3f();
old.set(vector);
// vector.set(floats[0], floats[1], floats[2]);
notifyListeners(old, vector);
}
示例12: addSixDofJoint
import com.jme3.math.Matrix3f; //导入依赖的package包/类
public MySixDofJoint addSixDofJoint(Spatial item1, Spatial item2, Vector3f refPt1, Vector3f refPt2,
Matrix3f rot1, Matrix3f rot2, boolean collision) {
if (!items.contains(item1)) {
throw new IllegalArgumentException(item1 + " does not exist in the inventory");
}
if (!items.contains(item2)) {
throw new IllegalArgumentException(item2 + " does not exist in the inventory");
}
MyRigidBodyControl c1 = item1.getControl(MyRigidBodyControl.class);
MyRigidBodyControl c2 = item2.getControl(MyRigidBodyControl.class);
MySixDofJoint joint = new MySixDofJoint(c1, c2, refPt1, refPt2, rot1, rot2, false);
joint.setCollisionBetweenLinkedBodys(collision);
joints.add(joint);
bulletAppState.getPhysicsSpace().add(joint);
return joint;
}
示例13: changeRotation
import com.jme3.math.Matrix3f; //导入依赖的package包/类
protected void changeRotation(float value, Point3D axis){
Matrix3f mat = new Matrix3f();
mat.fromAngleNormalAxis(value, TranslateUtil.toVector3f(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);
rotation = new Quaternion();
rotation.fromAxes(left, up, dir);
rotation.normalizeLocal();
applyRotationToCam();
}
示例14: rotateCamera
import com.jme3.math.Matrix3f; //导入依赖的package包/类
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);
cam.setAxes(q);
}
示例15: rotateCamera
import com.jme3.math.Matrix3f; //导入依赖的package包/类
private 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);
}