本文整理汇总了Java中com.jme3.renderer.Camera.getScreenCoordinates方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.getScreenCoordinates方法的具体用法?Java Camera.getScreenCoordinates怎么用?Java Camera.getScreenCoordinates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.renderer.Camera
的用法示例。
在下文中一共展示了Camera.getScreenCoordinates方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isVisibleOnEditor
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
@FXThread
private boolean isVisibleOnEditor(@NotNull final Spatial spatial) {
final MA editor3DState = getEditor3DState();
final Camera camera = editor3DState.getCamera();
final Vector3f position = spatial.getWorldTranslation();
final Vector3f coordinates = camera.getScreenCoordinates(position, new Vector3f());
boolean invisible = coordinates.getZ() < 0F || coordinates.getZ() > 1F;
invisible = invisible || !isInside(coordinates.getX(), camera.getHeight() - coordinates.getY(), Event.class);
return !invisible;
}
示例2: processTransform
import com.jme3.renderer.Camera; //导入方法依赖的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);
}
示例3: processTransform
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
@Override
public void processTransform() {
final EditorTransformSupport editorControl = getEditorControl();
final LocalObjects local = LocalObjects.get();
final Camera camera = editorControl.getCamera();
final InputManager inputManager = EDITOR.getInputManager();
final Transform transform = notNull(editorControl.getTransformCenter());
// cursor position and selected position vectors
final Vector2f cursorPos = inputManager.getCursorPosition();
final Vector3f transformOnScreen = camera.getScreenCoordinates(transform.getTranslation(), local.nextVector());
final Vector2f selectedCoords = local.nextVector(transformOnScreen.getX(), transformOnScreen.getY());
// set new deltaVector if it's not set (scale tool stores position of a cursor)
if (Float.isNaN(editorControl.getTransformDeltaX())) {
editorControl.setTransformDeltaX(cursorPos.getX());
editorControl.setTransformDeltaY(cursorPos.getY());
}
final Node parentNode = getParentNode();
final Node childNode = getChildNode();
// Picked vector
final Spatial toTransform = notNull(editorControl.getToTransform());
final TransformationMode transformationMode = editorControl.getTransformationMode();
transformationMode.prepareToScale(parentNode, childNode, transform, camera);
// scale according to distance
final Vector3f deltaVector = local.nextVector(editorControl.getTransformDeltaX(), editorControl.getTransformDeltaY(), 0F);
final Vector2f delta2d = local.nextVector(deltaVector.getX(), deltaVector.getY());
final Vector3f baseScale = local.nextVector(transform.getScale()); // default scale
final Vector3f pickedVector = local.nextVector(transformationMode.getScaleAxis(transform, editorControl.getPickedAxis(), camera));
pickedVector.setX(abs(pickedVector.getX()));
pickedVector.setY(abs(pickedVector.getY()));
pickedVector.setZ(abs(pickedVector.getZ()));
if (Config.DEV_TRANSFORMS_DEBUG) {
System.out.println("Base scale " + baseScale + ", pickedVector " + pickedVector);
}
// scale object
float disCursor = cursorPos.distance(selectedCoords);
float disDelta = delta2d.distance(selectedCoords);
float scaleValue = (float) (cursorPos.distance(delta2d) * 0.01f * Math.sqrt(baseScale.length()));
if (disCursor > disDelta) {
baseScale.addLocal(pickedVector.mult(scaleValue, local.nextVector()));
} else {
scaleValue = Math.min(scaleValue, 0.999f); // remove negateve values
baseScale.subtractLocal(pickedVector.mult(scaleValue, local.nextVector()));
}
parentNode.setLocalScale(baseScale);
if (Config.DEV_TRANSFORMS_DEBUG) {
System.out.println("New scale " + baseScale + ", result world " + childNode.getWorldScale());
}
parentNode.setLocalScale(baseScale);
toTransform.setLocalScale(childNode.getWorldScale());
editorControl.notifyTransformed(toTransform);
}