当前位置: 首页>>代码示例>>Java>>正文


Java Camera.getLocation方法代码示例

本文整理汇总了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());
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:14,代码来源:AbstractSceneEditor3DState.java

示例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;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:67,代码来源:WaterFilter.java


注:本文中的com.jme3.renderer.Camera.getLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。