本文整理汇总了Java中com.jme3.math.Ray.intersectsWherePlane方法的典型用法代码示例。如果您正苦于以下问题:Java Ray.intersectsWherePlane方法的具体用法?Java Ray.intersectsWherePlane怎么用?Java Ray.intersectsWherePlane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.math.Ray
的用法示例。
在下文中一共展示了Ray.intersectsWherePlane方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAction
import com.jme3.math.Ray; //导入方法依赖的package包/类
public void onAction(String name, boolean isPressed, float tpf) {
operation = name;
if (isPressed) {
supportedOperations.get(operation).setEnabled(true);
Vector2f click2d = MonkeyBrainsAppState.getInstance().getApp().getInputManager().getCursorPosition();
Vector3f click3d = agent.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f).clone();
Vector3f dir = agent.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d).normalizeLocal();
Ray ray = new Ray(click3d, dir);
Plane ground = new Plane(Vector3f.UNIT_Y, 0);
Vector3f groundpoint = new Vector3f();
ray.intersectsWherePlane(ground, groundpoint);
((SimpleAttackBehavior) supportedOperations.get(operation)).setTarget(groundpoint);
} else {
operation = null;
}
}
示例2: calculateMouseGroundPosition
import com.jme3.math.Ray; //导入方法依赖的package包/类
private void calculateMouseGroundPosition() {
Vector2f mouse2dPosition = inputManager.getCursorPosition();
Vector3f mouse3dPosition = cam
.getWorldCoordinates(mouse2dPosition, 0.0f);
Vector3f rayDirection = cam
.getWorldCoordinates(mouse2dPosition, 1.0f)
.subtractLocal(mouse3dPosition).normalizeLocal();
Ray ray = new Ray(mouse3dPosition, rayDirection);
ray.intersectsWherePlane(floorPlane, mouseGroundPosition);
}
示例3: calculateMouseLocation
import com.jme3.math.Ray; //导入方法依赖的package包/类
private void calculateMouseLocation() {
Vector2f mouse2dPosition = inputManager.getCursorPosition();
Vector3f mouse3dPosition =
cam.getWorldCoordinates(mouse2dPosition, 0.0f);
Vector3f rayDirection = cam.getWorldCoordinates(mouse2dPosition, 1.0f)
.subtractLocal(mouse3dPosition).normalizeLocal();
Ray ray = new Ray(mouse3dPosition, rayDirection);
ray.intersectsWherePlane(floorPlane, intersectionPoint);
}