當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。