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


Java Camera类代码示例

本文整理汇总了Java中com.jme.renderer.Camera的典型用法代码示例。如果您正苦于以下问题:Java Camera类的具体用法?Java Camera怎么用?Java Camera使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Camera类属于com.jme.renderer包,在下文中一共展示了Camera类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onWheel

import com.jme.renderer.Camera; //导入依赖的package包/类
/**
 * Called in {@link com.jme.input.KeyInput#update()} whenever the mouse wheel is rotated.
 * @param wheelDelta steps the wheel was rotated
 * @param x x position of the mouse while wheel was rotated
 * @param y y position of the mouse while wheel was rotated
 */
public void onWheel(int wheelDelta, int x, int y) {
    Camera cam = m.sf.gameState.getCamera();
    float xloc, yloc, zloc, alpha = 0.05f;
    Vector3f location, direction;
    location = cam.getLocation();
    direction = cam.getDirection();
    xloc = location.x;
    yloc = location.y;
    zloc = location.z;
    xloc += alpha * wheelDelta * direction.x;
    yloc += alpha * wheelDelta * direction.y;
    zloc += alpha * wheelDelta * direction.z;
    Vector3f newlocation = new Vector3f(xloc, yloc, zloc);
    cam.setLocation(newlocation);
}
 
开发者ID:CST-Group,项目名称:ws3d,代码行数:22,代码来源:MouseInputListener3D.java

示例2: cameraMoved

import com.jme.renderer.Camera; //导入依赖的package包/类
public void cameraMoved(CellTransform cameraWorldTransform) {
    synchronized (cameraLock) {
	cameraWorldTransform.getTranslation(cameraPositionWorld);
	if (cameraComp != null) {
	    Camera camera = cameraComp.getCamera();
	    cameraModelViewMatrix = ((AbstractCamera)camera).getModelViewMatrix();
	    cameraModelViewMatrixInverse = null;
	}
    }
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:11,代码来源:InputPicker.java

示例3: viewPropertiesChange

import com.jme.renderer.Camera; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void viewPropertiesChange(ViewProperty property) {
    // Update the camera properties, if it has been created already.
    if (cameraComponent != null) {
        Camera camera = cameraComponent.getCamera();
        float fov = viewProperties.getFieldOfView();
        float frontClip = viewProperties.getFrontClip();
        float backClip = viewProperties.getBackClip();
        camera.setFrustumPerspective(fov, aspect, frontClip, backClip);
    }
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:14,代码来源:ViewManager.java

示例4: setCamera

import com.jme.renderer.Camera; //导入依赖的package包/类
public void setCamera(Camera camera)
{
	if(camera==null)
		cameraNode.setCamera(CameraManager.getDummyCamera());
	else
		cameraNode.setCamera(camera);
}
 
开发者ID:sambayless,项目名称:golems,代码行数:8,代码来源:EmbeddedCamera.java

示例5: getCamera

import com.jme.renderer.Camera; //导入依赖的package包/类
/** 
 * Returns the current camera.
 */
Camera getCamera() {
    return inputPicker.getCameraComponent().getCamera();
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:7,代码来源:InputManager3D.java

示例6: KeyboardWorldInputHandler

import com.jme.renderer.Camera; //导入依赖的package包/类
public KeyboardWorldInputHandler( Camera cam, float moveSpeed, float rotateSpeed ) {
    this.moveSpeed = moveSpeed;
    KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager();

    keyboard.set( "forward", KeyInput.KEY_W );
    keyboard.set( "backward", KeyInput.KEY_S );
    keyboard.set( "strafeLeft", KeyInput.KEY_A );
    keyboard.set( "strafeRight", KeyInput.KEY_D );
    keyboard.set( "lookUp", KeyInput.KEY_M );
    keyboard.set( "lookDown", KeyInput.KEY_N );
    keyboard.set( "turnRight", KeyInput.KEY_O );
    keyboard.set( "turnLeft", KeyInput.KEY_P );
    keyboard.set( "elevateUp", KeyInput.KEY_Q);
    keyboard.set( "elevateDown", KeyInput.KEY_Z);
    keyboard.set( "tleft", KeyInput.KEY_RIGHT);
    keyboard.set( "tright", KeyInput.KEY_LEFT);
    keyboard.set( "ascend", KeyInput.KEY_Y);
    keyboard.set( "descend", KeyInput.KEY_H);
    keyboard.set( "moveforward", KeyInput.KEY_UP);
    keyboard.set( "movebackward", KeyInput.KEY_DOWN);
    keyboard.set( "spinleft", KeyInput.KEY_C);
    keyboard.set( "spinright", KeyInput.KEY_V);
    KeyTurnLeftAction tl = new KeyTurnLeftAction( cam, 0.5f );
    addAction(tl, "tleft", true );
    KeyTurnRightAction tr = new KeyTurnRightAction( cam, 0.5f );
    addAction(tr, "tright", true );
    KeyAscendAction aa = new KeyAscendAction(cam, 0.5f);
    addAction(aa,"ascend",true);
    KeyDescendAction da = new KeyDescendAction(cam, 0.5f);
    addAction(da,"descend",true);
    KeyMoveFrontAction mf = new KeyMoveFrontAction(cam, 0.5f);
    addAction(mf,"moveforward",true);
    KeyMoveBackAction mb = new KeyMoveBackAction(cam, 0.5f);
    addAction(mb,"movebackward",true);
    KeySpinLeftAction sl = new KeySpinLeftAction(cam, 0.5f);
    addAction(sl,"spinleft",true);
    KeySpinRightAction sr = new KeySpinRightAction(cam, 0.5f);
    addAction(sr,"spinright",true);
    forward = new KeyForwardAction( cam, moveSpeed );
    addAction( forward, "forward", true );
    backward = new KeyBackwardAction( cam, moveSpeed );
    addAction( backward, "backward", true );
    sLeft = new KeyStrafeLeftAction( cam, moveSpeed );
    addAction( sLeft, "strafeLeft", true );
    sRight = new KeyStrafeRightAction( cam, moveSpeed );
    addAction( sRight, "strafeRight", true );
    addAction( new KeyLookUpAction( cam, rotateSpeed ), "lookUp", true );
    addAction( new KeyLookDownAction( cam, rotateSpeed ), "lookDown", true );
    down = new KeyStrafeDownAction(cam, moveSpeed);
    Vector3f upVec = new Vector3f(cam.getUp());
    down.setUpVector(upVec);
    addAction(down, "elevateDown", true);
    up = new KeyStrafeUpAction( cam, moveSpeed );
    up.setUpVector(upVec);
    addAction( up, "elevateUp", true);
    right = new KeyRotateRightAction( cam, rotateSpeed );
    right.setLockAxis(new Vector3f(cam.getUp()));
    addAction(right, "turnRight", true );
    left = new KeyRotateLeftAction( cam, rotateSpeed );
    left.setLockAxis(new Vector3f(cam.getUp()));
    addAction( left, "turnLeft", true );
}
 
开发者ID:CST-Group,项目名称:ws3d,代码行数:63,代码来源:KeyboardWorldInputHandler.java

示例7: returnIfCaptured

import com.jme.renderer.Camera; //导入依赖的package包/类
/**
 * Return ALL Things in the creature's field-of-view, but those that has
 * been occluded has the corresponding flag "isOccluded" properly set.
 * It is used by the clients to correctly display the Thing.
 * @param th
 * @return
 */
public boolean returnIfCaptured(Thing th, Environment e){
    int cameraIndex;
    boolean ret = false;
    th.isOccluded = 0; //false - let's check it now

    synchronized (e.semaphore3) {
    if (e.getCpool().indexOf(owner) % 2 == 0) cameraIndex = 0;
    else cameraIndex = 1;

        try {

        //direction from the camera to the thing
        Vector3f directionToCenter = th.shape.getLocalTranslation().subtract(e.getRobotCamera(cameraIndex).getCameraNode().getLocalTranslation()).normalizeLocal();

        Vector3f lowerLeft = new Vector3f((float) (th.getX1() / 10 - e.width / 20), (float) (th.getZ() + th.getDepth()), (float) (th.getY1() / 10 - e.height / 20));
        Vector3f upperRight = new Vector3f((float) (th.getX2() / 10 - e.width / 20), (float) (th.getZ() + th.getDepth()), (float) (th.getY2() / 10 - e.height / 20));

        Vector3f directionToLowerLeft = lowerLeft.subtract(e.getRobotCamera(cameraIndex).getCameraNode().getLocalTranslation()).normalizeLocal();

        Vector3f directionToUpperRight = upperRight.subtract(e.getRobotCamera(cameraIndex).getCameraNode().getLocalTranslation()).normalizeLocal();


        // check if thing is within the camera view:
        Vector3f difference = e.getRobotCamera(cameraIndex).getCameraNode().getLocalRotation().getRotationColumn(2).subtract(directionToCenter);

        //the state must be backup and then set to 0 before using "camera.contais".
        //This is a "must do" procedure documented by JME.
        int stateBKP = e.getRobotCamera(cameraIndex).getCameraNode().getCamera().getPlaneState();
        e.getRobotCamera(cameraIndex).getCameraNode().getCamera().setPlaneState(0);

        Camera.FrustumIntersect aux1 = e.getRobotCamera(cameraIndex).getCameraNode().getCamera().contains(th.shape.getWorldBound());
        if ( aux1 == Camera.FrustumIntersect.Outside){
            return false;
        }
        
        ret = true;
        e.getRobotCamera(cameraIndex).getCameraNode().getCamera().setPlaneState(stateBKP);
        /**
         * Thing is within the camera view, BUT maybe be occluded by another
         * thing.
         */
            // Ray ray = new Ray(e.rcnEven.getCameraNode().getLocalTranslation(), direction);
            Ray rayCenter = new Ray(e.getRobotCamera(cameraIndex).getCameraNode().getLocalTranslation(), directionToCenter);
            Ray rayLowerLeft = new Ray(e.getRobotCamera(cameraIndex).getCameraNode().getLocalTranslation(), directionToLowerLeft);
            Ray rayUpperRight = new Ray(e.getRobotCamera(cameraIndex).getCameraNode().getLocalTranslation(), directionToUpperRight);

            //if at least one of these 3 reference points is visible, then the thing is not occluded
            boolean centerB = checkIfThingPointIsOccluded(e, cameraIndex, th, rayCenter);
            boolean lowerLeftB = checkIfThingPointIsOccluded(e, cameraIndex, th, rayLowerLeft);
            boolean upperRightB = checkIfThingPointIsOccluded(e, cameraIndex, th, rayUpperRight);

            if(centerB && lowerLeftB && upperRightB){
                th.isOccluded = 1;
            }

        
    } catch (Exception ev) {
        log.severe("Error when getting things from camera...");
        ev.printStackTrace();
    }

    }
    return ret;
}
 
开发者ID:CST-Group,项目名称:ws3d,代码行数:72,代码来源:VisualSensor.java

示例8: engageCamera

import com.jme.renderer.Camera; //导入依赖的package包/类
public void engageCamera(Camera camera) {
	// TODO Auto-generated method stub
	camera.setFrustumPerspective(45.0f, (float) DisplaySystem.getDisplaySystem().getWidth() / (float) DisplaySystem.getDisplaySystem().getHeight(), 1,15000);
	 cameraNode.setCamera(camera);
}
 
开发者ID:sambayless,项目名称:golems,代码行数:6,代码来源:StandardCamera.java

示例9: getDummyCamera

import com.jme.renderer.Camera; //导入依赖的package包/类
public static Camera getDummyCamera() {
	return dummyCamera;
}
 
开发者ID:sambayless,项目名称:golems,代码行数:4,代码来源:CameraManager.java

示例10: KeyDescendAction

import com.jme.renderer.Camera; //导入依赖的package包/类
/**
 * Constructor instantiates a new <code>KeyRotateLeftAction</code> object.
 * 
 * @param camera
 *            the camera to rotate.
 * @param speed
 *            the speed at which to rotate.
 */
public KeyDescendAction(Camera camera, float speed) {
    this.camera = camera;
    this.speed = speed;
}
 
开发者ID:CST-Group,项目名称:ws3d,代码行数:13,代码来源:KeyDescendAction.java

示例11: KeyTurnRightAction

import com.jme.renderer.Camera; //导入依赖的package包/类
/**
 * Constructor instantiates a new <code>KeyRotateLeftAction</code> object.
 * 
 * @param camera
 *            the camera to rotate.
 * @param speed
 *            the speed at which to rotate.
 */
public KeyTurnRightAction(Camera camera, float speed) {
    this.camera = camera;
    this.speed = speed;
}
 
开发者ID:CST-Group,项目名称:ws3d,代码行数:13,代码来源:KeyTurnRightAction.java

示例12: KeySpinRightAction

import com.jme.renderer.Camera; //导入依赖的package包/类
/**
 * Constructor instantiates a new <code>KeyRotateLeftAction</code> object.
 * 
 * @param camera
 *            the camera to rotate.
 * @param speed
 *            the speed at which to rotate.
 */
public KeySpinRightAction(Camera camera, float speed) {
    this.camera = camera;
    this.speed = speed;
}
 
开发者ID:CST-Group,项目名称:ws3d,代码行数:13,代码来源:KeySpinRightAction.java

示例13: KeyAscendAction

import com.jme.renderer.Camera; //导入依赖的package包/类
/**
 * Constructor instantiates a new <code>KeyRotateLeftAction</code> object.
 * 
 * @param camera
 *            the camera to rotate.
 * @param speed
 *            the speed at which to rotate.
 */
public KeyAscendAction(Camera camera, float speed) {
    this.camera = camera;
    this.speed = speed;
}
 
开发者ID:CST-Group,项目名称:ws3d,代码行数:13,代码来源:KeyAscendAction.java

示例14: KeyTurnLeftAction

import com.jme.renderer.Camera; //导入依赖的package包/类
/**
 * Constructor instantiates a new <code>KeyRotateLeftAction</code> object.
 * 
 * @param camera
 *            the camera to rotate.
 * @param speed
 *            the speed at which to rotate.
 */
public KeyTurnLeftAction(Camera camera, float speed) {
    this.camera = camera;
    this.speed = speed;
}
 
开发者ID:CST-Group,项目名称:ws3d,代码行数:13,代码来源:KeyTurnLeftAction.java

示例15: KeySpinLeftAction

import com.jme.renderer.Camera; //导入依赖的package包/类
/**
 * Constructor instantiates a new <code>KeyRotateLeftAction</code> object.
 * 
 * @param camera
 *            the camera to rotate.
 * @param speed
 *            the speed at which to rotate.
 */
public KeySpinLeftAction(Camera camera, float speed) {
    this.camera = camera;
    this.speed = speed;
}
 
开发者ID:CST-Group,项目名称:ws3d,代码行数:13,代码来源:KeySpinLeftAction.java


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