本文整理汇总了Java中com.jme3.renderer.Camera.getLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.getLocation方法的具体用法?Java Camera.getLocation怎么用?Java Camera.getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.renderer.Camera
的用法示例。
在下文中一共展示了Camera.getLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPositionOnCamera
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
@JMEThread
private @NotNull Vector3f getPositionOnCamera(@NotNull final Vector3f location) {
final LocalObjects local = LocalObjects.get();
final Camera camera = EDITOR.getCamera();
final Vector3f cameraLocation = camera.getLocation();
final Vector3f resultPosition = location.subtract(cameraLocation, local.nextVector())
.normalizeLocal()
.multLocal(camera.getFrustumNear() + 0.5f);
return cameraLocation.add(resultPosition, local.nextVector());
}
示例2: preFrame
import com.jme3.renderer.Camera; //导入方法依赖的package包/类
@Override
protected void preFrame(float tpf) {
time = time + (tpf * speed);
material.setFloat("Time", time);
Camera sceneCam = viewPort.getCamera();
biasMatrix.mult(sceneCam.getViewProjectionMatrix(), textureProjMatrix);
material.setMatrix4("TextureProjMatrix", textureProjMatrix);
material.setVector3("CameraPosition", sceneCam.getLocation());
material.setMatrix4("ViewProjectionMatrixInverse", sceneCam.getViewProjectionMatrix().invert());
material.setFloat("WaterHeight", waterHeight);
//update reflection cam
ray.setOrigin(sceneCam.getLocation());
ray.setDirection(sceneCam.getDirection());
plane = new Plane(Vector3f.UNIT_Y, new Vector3f(0, waterHeight, 0).dot(Vector3f.UNIT_Y));
reflectionProcessor.setReflectionClipPlane(plane);
boolean inv = false;
if (!ray.intersectsWherePlane(plane, targetLocation)) {
ray.setDirection(ray.getDirection().negateLocal());
ray.intersectsWherePlane(plane, targetLocation);
inv = true;
}
Vector3f loc = plane.reflect(sceneCam.getLocation(), new Vector3f());
reflectionCam.setLocation(loc);
reflectionCam.setFrustum(sceneCam.getFrustumNear(),
sceneCam.getFrustumFar(),
sceneCam.getFrustumLeft(),
sceneCam.getFrustumRight(),
sceneCam.getFrustumTop(),
sceneCam.getFrustumBottom());
TempVars vars = TempVars.get();
vars.vect1.set(sceneCam.getLocation()).addLocal(sceneCam.getUp());
float planeDistance = plane.pseudoDistance(vars.vect1);
vars.vect2.set(plane.getNormal()).multLocal(planeDistance * 2.0f);
vars.vect3.set(vars.vect1.subtractLocal(vars.vect2)).subtractLocal(loc).normalizeLocal().negateLocal();
reflectionCam.lookAt(targetLocation, vars.vect3);
vars.release();
if (inv) {
reflectionCam.setAxes(reflectionCam.getLeft().negateLocal(), reflectionCam.getUp(), reflectionCam.getDirection().negateLocal());
}
//if we're under water no need to compute reflection
if (sceneCam.getLocation().y >= waterHeight) {
boolean rtb = true;
if (!renderManager.isHandleTranslucentBucket()) {
renderManager.setHandleTranslucentBucket(true);
rtb = false;
}
renderManager.renderViewPort(reflectionView, tpf);
if (!rtb) {
renderManager.setHandleTranslucentBucket(false);
}
renderManager.setCamera(sceneCam, false);
renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer());
underWater = false;
} else {
underWater = true;
}
}