本文整理了Java中com.jme3.math.Quaternion.multLocal
方法的一些代码示例,展示了Quaternion.multLocal
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Quaternion.multLocal
方法的具体详情如下:
包路径:com.jme3.math.Quaternion
类名称:Quaternion
方法名:multLocal
[英]mult
multiplies this quaternion by a parameter scalar. The result is stored locally.
[中]mult
将这个四元数乘以一个参数标量。结果存储在本地。
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Updates the local X-Z view direction and the corresponding rotation
* quaternion for the spatial.
*/
protected void updateLocalViewDirection() {
//update local rotation quaternion to use for view rotation
localForwardRotation.multLocal(rotatedViewDirection.set(viewDirection));
calculateNewForward(rotation, rotatedViewDirection, localUp);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Updates the local X-Z view direction and the corresponding rotation
* quaternion for the spatial.
*/
protected void updateLocalViewDirection() {
//update local rotation quaternion to use for view rotation
localForwardRotation.multLocal(rotatedViewDirection.set(viewDirection));
calculateNewForward(rotation, rotatedViewDirection, localUp);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Rotates the spatial by the given rotation.
*
* @return The spatial on which this method is called, e.g <code>this</code>.
*/
public Spatial rotate(Quaternion rot) {
this.localTransform.getRotation().multLocal(rot);
setTransformRefresh();
return this;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private static Quaternion toQuat(float ax1v, Vector3f ax1, float ax2v, Vector3f ax2, float ax3v, Vector3f ax3) {
// TODO It has some potential in optimization
Quaternion q1 = new Quaternion().fromAngleNormalAxis(ax1v, ax1);
Quaternion q2 = new Quaternion().fromAngleNormalAxis(ax2v, ax2);
Quaternion q3 = new Quaternion().fromAngleNormalAxis(ax3v, ax3);
return q1.multLocal(q2).multLocal(q3);
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Rotate the physics object to the specified orientation.
* <p>
* We don't set the actual physics rotation but the view rotation here. It
* might actually be altered by the calculateNewForward method.
*
* @param quat desired orientation (not null, unaffected)
*/
@Override
protected void setPhysicsRotation(Quaternion quat) {
rotation.set(quat);
rotation.multLocal(rotatedViewDirection.set(viewDirection));
updateLocalViewDirection();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Rotate the physics object to the specified orientation.
* <p>
* We don't set the actual physics rotation but the view rotation here. It
* might actually be altered by the calculateNewForward method.
*
* @param quat desired orientation (not null, unaffected)
*/
@Override
protected void setPhysicsRotation(Quaternion quat) {
rotation.set(quat);
rotation.multLocal(rotatedViewDirection.set(viewDirection));
updateLocalViewDirection();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void simpleUpdate(float tpf){
// Rotate around X axis
Quaternion rotate = new Quaternion();
rotate.fromAngleAxis(tpf, Vector3f.UNIT_X);
// Combine rotation with previous
rotation.multLocal(rotate);
// Set new rotation into bone
bone.setUserTransforms(Vector3f.ZERO, rotation, Vector3f.UNIT_XYZ);
// After changing skeleton transforms, must update world data
skeleton.updateWorldVectors();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private static Quaternion spline(Quaternion qnm1, Quaternion qn, Quaternion qnp1, Quaternion store, Quaternion tmp) {
Quaternion invQn = new Quaternion(-qn.x, -qn.y, -qn.z, qn.w);
log(invQn.mult(qnp1), tmp);
log(invQn.mult(qnm1), store);
store.addLocal(tmp).multLocal(-1f / 4f);
exp(store, tmp);
store.set(qn).multLocal(tmp);
return store.normalizeLocal();
//return qn * (((qni * qnm1).log() + (qni * qnp1).log()) / -4).exp();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
*
* Sets the transforms of this bone in local space (relative to the parent bone)
*
* @param translation the translation in local space
* @param rotation the rotation in local space
* @param scale the scale in local space
*/
public void setUserTransforms(Vector3f translation, Quaternion rotation, Vector3f scale) {
if (!userControl) {
throw new IllegalStateException("You must call setUserControl(true) in order to setUserTransform to work");
}
localPos.set(bindPos);
localRot.set(bindRot);
localScale.set(bindScale);
localPos.addLocal(translation);
localRot.multLocal(rotation);
localScale.multLocal(scale);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Sets the local animation transform of this bone.
* Bone is assumed to be in bind pose when this is called.
*/
void setAnimTransforms(Vector3f translation, Quaternion rotation, Vector3f scale) {
if (userControl) {
return;
}
// localPos.addLocal(translation);
// localRot.multLocal(rotation);
//localRot = localRot.mult(rotation);
localPos.set(bindPos).addLocal(translation);
localRot.set(bindRot).multLocal(rotation);
if (scale != null) {
localScale.set(bindScale).multLocal(scale);
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Returns the local transform of this bone combined with the given position and rotation
* @param position a position
* @param rotation a rotation
*/
public Transform getCombinedTransform(Vector3f position, Quaternion rotation) {
if(tmpTransform == null){
tmpTransform = new Transform();
}
rotation.mult(localPos, tmpTransform.getTranslation()).addLocal(position);
tmpTransform.setRotation(rotation).getRotation().multLocal(localRot);
return tmpTransform;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* rotate the camera around the target
*/
protected void rotateCamera() {
verticalRotation = FastMath.clamp(verticalRotation, minVerticalRotation, maxVerticalRotation);
TempVars vars = TempVars.get();
Quaternion rot = vars.quat1;
Quaternion rot2 = vars.quat2;
rot.fromAngleNormalAxis(verticalRotation, leftVector);
rot2.fromAngleNormalAxis(horizontalRotation, upVector);
rot2.multLocal(rot);
target.setLocalRotation(rot2);
vars.release();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void simpleUpdate(float tpf) {
if(forward){
model.move(model.getLocalRotation().multLocal(new Vector3f(0,0,1)).multLocal(tpf));
}else if(backward){
model.move(model.getLocalRotation().multLocal(new Vector3f(0,0,1)).multLocal(-tpf));
}else if(leftRotate){
model.rotate(0, tpf, 0);
}else if(rightRotate){
model.rotate(0, -tpf, 0);
}
fpsText.setText(cam.getLocation() + "/" + cam.getRotation());
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public Quaternion getFinalObserverRotation(int index) {
OSVRViewManager vrvm = (OSVRViewManager)environment.getVRViewManager();
if( vrvm == null || isInputDeviceTracking(index) == false ) return null;
Object obs = environment.getObserver();
if( obs instanceof Camera ) {
tempq.set(((Camera)obs).getRotation());
} else {
tempq.set(((Spatial)obs).getWorldRotation());
}
return tempq.multLocal(getOrientation(index));
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Get the observer final rotation within the scene.
* @return the observer final rotation within the scene.
* @see #getFinalObserverPosition()
*/
public Quaternion getFinalObserverRotation() {
if( viewmanager == null ) {
if( observer == null ) {
return getCamera().getRotation();
} else return observer.getWorldRotation();
}
if( observer == null ) {
tempq.set(dummyCam.getRotation());
} else {
tempq.set(observer.getWorldRotation());
}
return tempq.multLocal(VRhardware.getOrientation());
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public Quaternion getFinalObserverRotation(int index) {
// Copied from OpenVRInput
VREnvironment env = hardware.getEnvironment();
OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager();
Object obs = env.getObserver();
Quaternion tempq = new Quaternion(); // TODO move to class scope?
if (obs instanceof Camera) {
tempq.set(((Camera) obs).getRotation());
} else {
tempq.set(((Spatial) obs).getWorldRotation());
}
return tempq.multLocal(getOrientation(index));
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Alter the transforms of a rigidBody to match the transforms of a bone.
* This is used to make the ragdoll follow animated motion in Kinematic mode
*
* @param link the bone link connecting the bone and the rigidBody
* @param position temporary storage used in calculations (not null)
* @param tmpRot1 temporary storage used in calculations (not null)
*/
protected void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) {
//computing position from rotation and scale
targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position);
//computing rotation
tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getModelBindInverseRotation());
targetModel.getWorldRotation().mult(tmpRot1, tmpRot1);
tmpRot1.normalizeLocal();
//updating physics location/rotation of the physics bone
link.rigidBody.setPhysicsLocation(position);
link.rigidBody.setPhysicsRotation(tmpRot1);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Alter the transforms of a rigidBody to match the transforms of a bone.
* This is used to make the ragdoll follow animated motion in Kinematic mode
*
* @param link the bone link connecting the bone and the rigidBody
* @param position temporary storage used in calculations (not null)
* @param tmpRot1 temporary storage used in calculations (not null)
*/
protected void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) {
//computing position from rotation and scale
targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position);
//computing rotation
tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getModelBindInverseRotation());
targetModel.getWorldRotation().mult(tmpRot1, tmpRot1);
tmpRot1.normalizeLocal();
//updating physics location/rotation of the physics bone
link.rigidBody.setPhysicsLocation(position);
link.rigidBody.setPhysicsRotation(tmpRot1);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private void spatialToLight(Light light) {
final Vector3f worldTranslation = spatial.getWorldTranslation();
if (light instanceof PointLight) {
((PointLight) light).setPosition(worldTranslation);
return;
}
final TempVars vars = TempVars.get();
final Vector3f vec = vars.vect1;
if (light instanceof DirectionalLight) {
((DirectionalLight) light).setDirection(vec.set(worldTranslation).multLocal(-1.0f));
}
if (light instanceof SpotLight) {
final SpotLight spotLight = (SpotLight) light;
spotLight.setPosition(worldTranslation);
spotLight.setDirection(spatial.getWorldRotation().multLocal(vec.set(Vector3f.UNIT_Y).multLocal(-1)));
}
vars.release();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void applyWheelTransform() {
if (wheelSpatial == null) {
return;
}
Quaternion localRotationQuat = wheelSpatial.getLocalRotation();
Vector3f localLocation = wheelSpatial.getLocalTranslation();
if (!applyLocal && wheelSpatial.getParent() != null) {
localLocation.set(wheelWorldLocation).subtractLocal(wheelSpatial.getParent().getWorldTranslation());
localLocation.divideLocal(wheelSpatial.getParent().getWorldScale());
tmp_inverseWorldRotation.set(wheelSpatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
localRotationQuat.set(wheelWorldRotation);
tmp_inverseWorldRotation.set(wheelSpatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);
wheelSpatial.setLocalTranslation(localLocation);
wheelSpatial.setLocalRotation(localRotationQuat);
} else {
wheelSpatial.setLocalTranslation(wheelWorldLocation);
wheelSpatial.setLocalRotation(wheelWorldRotation);
}
}
内容来源于网络,如有侵权,请联系作者删除!