本文整理匯總了Java中com.jme3.scene.Spatial.setLocalRotation方法的典型用法代碼示例。如果您正苦於以下問題:Java Spatial.setLocalRotation方法的具體用法?Java Spatial.setLocalRotation怎麽用?Java Spatial.setLocalRotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.scene.Spatial
的用法示例。
在下文中一共展示了Spatial.setLocalRotation方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateObject
import com.jme3.scene.Spatial; //導入方法依賴的package包/類
@Override
protected void updateObject(Spatial object, Entity e) {
//only position will be updated during test
PhysicsPosition pos = e.get(PhysicsPosition.class);
object.setLocalTranslation(pos.getLocation());
object.setLocalRotation(pos.getRotation());
}
示例2: applyPhysicsTransform
import com.jme3.scene.Spatial; //導入方法依賴的package包/類
protected void applyPhysicsTransform(@NotNull final Vector3f worldLocation, @NotNull final Quaternion worldRotation,
@Nullable final Spatial spatial) {
if (spatial == null) return;
final Vector3f localLocation = spatial.getLocalTranslation();
final Quaternion localRotation = spatial.getLocalRotation();
final Node parent = spatial.getParent();
if (parent == null) {
spatial.setLocalTranslation(worldLocation);
spatial.setLocalRotation(worldRotation);
} else {
localLocation.set(worldLocation)
.subtractLocal(parent.getWorldTranslation());
localLocation.divideLocal(parent.getWorldScale());
inverseWorldRotation.set(parent.getWorldRotation())
.inverseLocal()
.multLocal(localLocation);
localRotation.set(worldRotation);
inverseWorldRotation.set(parent.getWorldRotation())
.inverseLocal()
.mult(localRotation, localRotation);
spatial.setLocalTranslation(localLocation);
spatial.setLocalRotation(localRotation);
}
}
示例3: applyViewRotation
import com.jme3.scene.Spatial; //導入方法依賴的package包/類
private static void applyViewRotation(Entity entity, Spatial spatial){
spatial.setLocalRotation(entity.get(ViewRotation.class).getRotation());
}
示例4: processTransform
import com.jme3.scene.Spatial; //導入方法依賴的package包/類
@Override
public void processTransform() {
final LocalObjects local = LocalObjects.get();
final EditorTransformSupport editorControl = getEditorControl();
final InputManager inputManager = EDITOR.getInputManager();
final Camera camera = editorControl.getCamera();
final Transform transform = notNull(editorControl.getTransformCenter());
// cursor position and selected position vectors
final Vector2f cursorPos = inputManager.getCursorPosition();
final Vector3f transformOnScreen = camera.getScreenCoordinates(transform.getTranslation());
final Vector2f selectedCoords = local.nextVector(transformOnScreen.getX(), transformOnScreen.getY());
//set new deltaVector if it's not set
if (Float.isNaN(editorControl.getTransformDeltaX())) {
editorControl.setTransformDeltaX(selectedCoords.getX() - cursorPos.getX());
editorControl.setTransformDeltaY(selectedCoords.getY() - cursorPos.getY());
}
// Picked vector
final TransformationMode transformationMode = editorControl.getTransformationMode();
final Vector3f pickedVector = transformationMode.getPickedVector(transform, editorControl.getPickedAxis(), camera);
final Vector3f deltaVector = local.nextVector(editorControl.getTransformDeltaX(), editorControl.getTransformDeltaY(), 0F);
// rotate according to angle
final Vector2f cursorDirection = selectedCoords.subtractLocal(cursorPos).normalizeLocal();
float angle = cursorDirection.angleBetween(local.nextVector(deltaVector.getX(), deltaVector.getY()));
angle = FastMath.RAD_TO_DEG * angle * FastMath.DEG_TO_RAD;
final Node parentNode = getParentNode();
final Node childNode = getChildNode();
transformationMode.prepareToRotate(parentNode, childNode, transform, camera);
final Quaternion rotation = parentNode.getLocalRotation();
final Vector3f axisToRotate = rotation.mult(pickedVector, local.nextVector());
float angleCheck = axisToRotate.angleBetween(camera.getDirection(local.nextVector()));
if (angleCheck > FastMath.HALF_PI) {
angle = -angle;
}
final Quaternion difference = local.nextRotation().fromAngleAxis(angle, pickedVector);
final Quaternion newRotation = rotation.mult(difference, local.nextRotation());
parentNode.setLocalRotation(newRotation);
final Spatial toTransform = notNull(editorControl.getToTransform());
toTransform.setLocalRotation(childNode.getWorldRotation());
editorControl.notifyTransformed(toTransform);
}