• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CameraNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createCameraMotion

import com.jme3.scene.CameraNode; //导入依赖的package包/类
private void createCameraMotion() {

        CameraNode camNode = cinematic.bindCamera("topView", cam);
        camNode.setLocalTranslation(new Vector3f(0, 50, 0));
        camNode.lookAt(model.getLocalTranslation(), Vector3f.UNIT_Y);

        CameraNode camNode2 = cinematic.bindCamera("aroundCam", cam);
        path = new MotionPath();
        path.setCycle(true);
        path.addWayPoint(new Vector3f(20, 3, 0));
        path.addWayPoint(new Vector3f(0, 3, 20));
        path.addWayPoint(new Vector3f(-20, 3, 0));
        path.addWayPoint(new Vector3f(0, 3, -20));
        path.setCurveTension(0.83f);
        cameraMotionTrack = new MotionTrack(camNode2, path);
        cameraMotionTrack.setLoopMode(LoopMode.Loop);
        cameraMotionTrack.setLookAt(model.getWorldTranslation(), Vector3f.UNIT_Y);
        cameraMotionTrack.setDirectionType(MotionTrack.Direction.LookAt);

    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:TestCinematic.java


示例2: doChase

import com.jme3.scene.CameraNode; //导入依赖的package包/类
private void doChase(Vector3f position, float distance) {
    Camera camera = editorCam.getCamera();
    
    Vector3f camEndLoc = new Vector3f().set(position).subtractLocal(camera.getDirection().mult(distance));
    
    CameraNode cameraNode = new CameraNode("", editorCam.getCamera());
    cameraNode.setLocalRotation(editorCam.getCamera().getRotation());
    cameraNode.setControlDir(CameraControl.ControlDirection.SpatialToCamera);

    CurveMoveAnim locAnim = new CurveMoveAnim();
    locAnim.setControlPoints(Arrays.asList(camera.getLocation(), camEndLoc));
    locAnim.setCurveTension(0);
    locAnim.setTarget(cameraNode);
    locAnim.setUseTime(0.5f);
    locAnim.addListener((Anim anim) -> {
        editorCam.setFocus(position);
    });
    locAnim.start();
    AnimNode locAnimNode = new AnimNode(locAnim, true);
    locAnimNode.attachChild(cameraNode);
    edit.getEditRoot().attachChild(locAnimNode);
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:23,代码来源:CameraTool.java


示例3: setEye

import com.jme3.scene.CameraNode; //导入依赖的package包/类
public void setEye(ChannelHandlerContext ctx, Cmds.SetEye cmd) {
	todo("setEye", (rc)-> {
		CameraNode cam = rc.cam;
		Quaternion rot = toJME(cmd.getRotation());
		cam.setLocalRotation(rot.clone());
		cam.setLocalTranslation(toJME(cmd.getLocation()));
		//if (cmd.hasNear()) cam0.setFrustumNear(cmd.getNear())
		//if (cmd.hasFar()) cam0.setFrustumFar(cmd.getFar())
		if (cmd.hasProjection()) {
			Matrix4f proj = toJME(cmd.getProjection());
			cam.getCamera().setParallelProjection(cmd.getProjMode() == ProjMode.orthographic);
			if (cmd.getProjMode() == ProjMode.orthographic) {
				float[] lr = pairOf(proj.m00, proj.m03);
				float[] bt = pairOf(proj.m11, proj.m13);
				float[] nf = pairOf(-proj.m22, proj.m23);
				cam.getCamera().setFrustum(nf[0], nf[1], lr[0], lr[1], bt[1], bt[0]);
			} else {
				float fovY = 2f * FastMath.RAD_TO_DEG * FastMath.atan(1f / proj.m11);
				float aspect = proj.m11 / proj.m00;
				cam.getCamera().setFrustumPerspective(fovY, aspect, cmd.getNear(), cmd.getFar());
			}
		}
		cam.getCamera().update();
		cam.setEnabled(true);
	});
}
 
开发者ID:xbuf,项目名称:jme3_xbuf,代码行数:27,代码来源:ReqHandler.java


示例4: makePlayer

import com.jme3.scene.CameraNode; //导入依赖的package包/类
Spatial makePlayer() {
	Node root = new Node("player");
	Geometry g = new Geometry("Player", new Sphere(16, 16, 0.5f));
	Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
	mat.setColor("Color", ColorRGBA.Red);
	g.setMaterial(mat);
	root.attachChild(g);

	CameraNode camn = new CameraNode("follower", app.getCamera());
	camn.setLocalTranslation(new Vector3f(0,2,6));
	camn.lookAt(root.getWorldTranslation(), Vector3f.UNIT_Y);
	root.attachChild(camn);

	root.addControl(c4t);
	return root;
}
 
开发者ID:davidB,项目名称:jme3_skel,代码行数:17,代码来源:PageInGame.java


示例5: toCamera249

import com.jme3.scene.CameraNode; //导入依赖的package包/类
/**
 * This method converts the given structure to jme camera. Should be used form blender 2.49.
 * 
 * @param structure
 *            camera structure
 * @return jme camera object
 * @throws BlenderFileException
 *             an exception is thrown when there are problems with the
 *             blender file
 */
private CameraNode toCamera249(Structure structure) throws BlenderFileException {
    Camera camera = new Camera(DEFAULT_CAM_WIDTH, DEFAULT_CAM_HEIGHT);
    int type = ((Number) structure.getFieldValue("type")).intValue();
    if (type != 0 && type != 1) {
        LOGGER.log(Level.WARNING, "Unknown camera type: {0}. Perspective camera is being used!", type);
        type = 0;
    }
    // type==0 - perspective; type==1 - orthographic; perspective is used as default
    camera.setParallelProjection(type == 1);
    float aspect = 0;
    float clipsta = ((Number) structure.getFieldValue("clipsta")).floatValue();
    float clipend = ((Number) structure.getFieldValue("clipend")).floatValue();
    if (type == 0) {
        aspect = ((Number) structure.getFieldValue("lens")).floatValue();
    } else {
        aspect = ((Number) structure.getFieldValue("ortho_scale")).floatValue();
    }
    camera.setFrustumPerspective(aspect, camera.getWidth() / camera.getHeight(), clipsta, clipend);
    return new CameraNode(null, camera);
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:31,代码来源:CameraHelper.java


示例6: LoadingResults

import com.jme3.scene.CameraNode; //导入依赖的package包/类
/**
 * Private constructor prevents users to create an instance of this class from outside the
 * @param featuresToLoad
 *            bitwise mask of features that are to be loaded
 * @see FeaturesToLoad FeaturesToLoad
 */
private LoadingResults(int featuresToLoad) {
    this.featuresToLoad = featuresToLoad;
    if ((featuresToLoad & FeaturesToLoad.SCENES) != 0) {
        scenes = new ArrayList<Node>();
    }
    if ((featuresToLoad & FeaturesToLoad.OBJECTS) != 0) {
        objects = new ArrayList<Node>();
        if ((featuresToLoad & FeaturesToLoad.MATERIALS) != 0) {
            materials = new ArrayList<Material>();
            if ((featuresToLoad & FeaturesToLoad.TEXTURES) != 0) {
                textures = new ArrayList<Texture>();
            }
        }
        if ((featuresToLoad & FeaturesToLoad.ANIMATIONS) != 0) {
            animations = new ArrayList<AnimationData>();
        }
    }
    if ((featuresToLoad & FeaturesToLoad.CAMERAS) != 0) {
        cameras = new ArrayList<CameraNode>();
    }
    if ((featuresToLoad & FeaturesToLoad.LIGHTS) != 0) {
        lights = new ArrayList<LightNode>();
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:31,代码来源:BlenderKey.java


示例7: parseCamera

import com.jme3.scene.CameraNode; //导入依赖的package包/类
private void parseCamera(Attributes attribs) throws SAXException {
    camera = new Camera(DEFAULT_CAM_WIDTH, DEFAULT_CAM_HEIGHT);
    if (SAXUtil.parseString(attribs.getValue("projectionType"), "perspective").equals("parallel")){
        camera.setParallelProjection(true);
    }
    float fov = SAXUtil.parseFloat(attribs.getValue("fov"), 45f);
    if (fov < FastMath.PI) { 
        // XXX: Most likely, it is in radians..
        fov = fov * FastMath.RAD_TO_DEG;
    }
    camera.setFrustumPerspective(fov, (float)DEFAULT_CAM_WIDTH / DEFAULT_CAM_HEIGHT, 1, 1000);
    
    cameraNode = new CameraNode(attribs.getValue("name"), camera);
    cameraNode.setControlDir(ControlDirection.SpatialToCamera);
    
    node.attachChild(cameraNode);
    node = null;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:19,代码来源:SceneLoader.java


示例8: setFirstPersonCam

import com.jme3.scene.CameraNode; //导入依赖的package包/类
/**Sets the chase cam to the minimum distance and heightens
 * the sensitivity of the cam. Called by input listener.
 */
public void setFirstPersonCam(){
	if (!getWorld().getScreenManager().getHudScreenController().chatFocused()){
		isInFirstPerson = !isInFirstPerson;
		if(isInFirstPerson){
			chaseCam.setEnabled(false);
			camNode = new CameraNode("cam",camera);
			((Node)getMesh()).attachChild(camNode);
			camNode.setLocalTranslation(new Vector3f(0,4,0));
			camNode.setLocalRotation(new Quaternion(0,1,0,0));
		}
		else{
			((Node)getMesh()).detachChild(camNode);
			chaseCam.setEnabled(true);
			chaseCam.setTrailingEnabled(true);
		}
		world.getScreenManager().getHudScreenController().hideShowCrossHairs(isInFirstPerson);
	}
}
 
开发者ID:GSam,项目名称:Game-Project,代码行数:22,代码来源:Player.java


示例9: read

import com.jme3.scene.CameraNode; //导入依赖的package包/类
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);

    cinematicEvents = ic.readSavableArrayList("cinematicEvents", null);
    cameras = (Map<String, CameraNode>) ic.readStringSavableMap("cameras", null);
    timeLine = (TimeLine) ic.readSavable("timeLine", null);
    niftyXmlPath = ic.readString("niftyXmlPath", null);

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:Cinematic.java


示例10: bindCamera

import com.jme3.scene.CameraNode; //导入依赖的package包/类
public CameraNode bindCamera(String cameraName, Camera cam) {
    CameraNode node = new CameraNode(cameraName, cam);
    node.setControlDir(ControlDirection.SpatialToCamera);
    node.getControl(0).setEnabled(false);
    cameras.put(cameraName, node);
    scene.attachChild(node);
    return node;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:Cinematic.java


示例11: loadCameraSettings

import com.jme3.scene.CameraNode; //导入依赖的package包/类
protected void loadCameraSettings() {        
    Vector3f centerPoint = new Vector3f((Game.MAP_SIZE * Game.TILE_SIZE) * 0.5f, 0, (Game.MAP_SIZE * Game.TILE_SIZE) * 0.5f);

    cameraJointNode = new Node("camerajoint");
    cameraJointNode.setLocalTranslation(centerPoint);
    rootNode.attachChild(cameraJointNode);

    cameraNode = new CameraNode("camnode", camera);
    cameraNode.setLocalTranslation(0, cameraHeight, cameraHeight * anglePerZ);
    cameraNode.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
    cameraJointNode.attachChild(cameraNode);
}
 
开发者ID:jMonkeyEngine,项目名称:examplegame-skulls,代码行数:13,代码来源:EditScreen.java


示例12: loadCameraSettings

import com.jme3.scene.CameraNode; //导入依赖的package包/类
/**
 * Load how the camera will view
 */
protected void loadCameraSettings() {
    float angleY = FastMath.DEG_TO_RAD * 0f;
    Vector3f centerPoint = new Vector3f((Game.MAP_SIZE * Game.TILE_SIZE) * 0.5f, 0, (Game.MAP_SIZE * Game.TILE_SIZE) * 0.5f);

    cameraJointNode = new Node("camerajoint");
    cameraJointNode.setLocalTranslation(centerPoint);
    cameraJointNode.rotate(0, angleY, 0);
    rootNode.attachChild(cameraJointNode);

    cameraNode = new CameraNode("camnode", camera);
    cameraNode.setLocalTranslation(0, cameraHeight, cameraHeight * anglePerZ);
    cameraNode.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
    cameraJointNode.attachChild(cameraNode);
}
 
开发者ID:jMonkeyEngine,项目名称:examplegame-skulls,代码行数:18,代码来源:PlayScreen.java


示例13: simpleInitApp

import com.jme3.scene.CameraNode; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    flyCam.setMoveSpeed(20);
    rootNode.attachChild(helperNode);

    initializeFloor();

    initializeBloom();

    initializePlayer();

    initializeEnemy();

    // Disable the default flyby cam
    flyCam.setEnabled(false);
    //create the camera Node
    CameraNode camNode = new CameraNode("Camera Node", cam);
    //This mode means that camera copies the movements of the target:
    camNode.setControlDir(ControlDirection.SpatialToCamera);
    //Attach the camNode to the target:
    player.attachChild(camNode);
    //Move camNode, e.g. behind and above the target:
    camNode.setLocalTranslation(new Vector3f(0, 6, -18));
    //Rotate the camNode to look at the target:
    camNode.lookAt(player.getLocalTranslation(), Vector3f.UNIT_Y);
    camNode.setLocalTranslation(new Vector3f(0, 12, -22));

    registerInput();

    if (addDebugObjects) {
        Geometry playfield = new Geometry("debuggrid", new Grid(floorsize, floorsize, floorsize / 10));
        Material plafieldmat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        plafieldmat.getAdditionalRenderState().setWireframe(true);
        plafieldmat.setColor("Color", ColorRGBA.Yellow);
        playfield.setMaterial(plafieldmat);
        playfield.center().move(0, 0.2f, 0);
        rootNode.attachChild(playfield);
    }
}
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:41,代码来源:Main.java


示例14: toCamera

import com.jme3.scene.CameraNode; //导入依赖的package包/类
/**
 * This method converts the given structure to a camera.
 * @param structure
 *            structure of a camera
 * @return camera's node
 */
public CameraNode toCamera(Structure structure) throws BlenderFileException {
    CameraHelper cameraHelper = blenderContext.getHelper(CameraHelper.class);
    if (cameraHelper.shouldBeLoaded(structure, blenderContext)) {
        return cameraHelper.toCamera(structure, blenderContext);
    }
    return null;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:14,代码来源:AbstractBlenderLoader.java


示例15: simpleInitApp

import com.jme3.scene.CameraNode; //导入依赖的package包/类
@Override
public void simpleInitApp() {
  // activate physics
  bulletAppState = new BulletAppState();
  stateManager.attach(bulletAppState);

  // init a physical test scene
  PhysicsTestHelper.createPhysicsTestWorldSoccer(rootNode, assetManager, bulletAppState.getPhysicsSpace());
  setupKeys();

  // Add a physics character to the world
  physicsCharacter = new CharacterControl(new CapsuleCollisionShape(0.5f, 1.8f), .1f);
  physicsCharacter.setPhysicsLocation(new Vector3f(0, 1, 0));
  characterNode = new Node("character node");
  Spatial model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
  model.scale(0.25f);
  characterNode.addControl(physicsCharacter);
  getPhysicsSpace().add(physicsCharacter);
  rootNode.attachChild(characterNode);
  characterNode.attachChild(model);

  // set forward camera node that follows the character
  camNode = new CameraNode("CamNode", cam);
  camNode.setControlDir(ControlDirection.SpatialToCamera);
  camNode.setLocalTranslation(new Vector3f(0, 1, -5));
  camNode.lookAt(model.getLocalTranslation(), Vector3f.UNIT_Y);
  characterNode.attachChild(camNode);

  //disable the default 1st-person flyCam (don't forget this!!)
  flyCam.setEnabled(false);

}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:33,代码来源:TestPhysicsCharacter.java


示例16: simpleInitApp

import com.jme3.scene.CameraNode; //导入依赖的package包/类
public void simpleInitApp() {
  // load a teapot model 
  teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
  Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
  teaGeom.setMaterial(mat);
  //create a node to attach the geometry and the camera node
  teaNode = new Node("teaNode");
  teaNode.attachChild(teaGeom);
  rootNode.attachChild(teaNode);
  // create a floor
  mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
  Geometry ground = new Geometry("ground", new Quad(50, 50));
  ground.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
  ground.setLocalTranslation(-25, -1, 25);
  ground.setMaterial(mat);
  rootNode.attachChild(ground);

  //creating the camera Node
  camNode = new CameraNode("CamNode", cam);
  //Setting the direction to Spatial to camera, this means the camera will copy the movements of the Node
  camNode.setControlDir(ControlDirection.SpatialToCamera);
  //attaching the camNode to the teaNode
  teaNode.attachChild(camNode);
  //setting the local translation of the cam node to move it away from the teanNode a bit
  camNode.setLocalTranslation(new Vector3f(-10, 0, 0));
  //setting the camNode to look at the teaNode
  camNode.lookAt(teaNode.getLocalTranslation(), Vector3f.UNIT_Y);

  //disable the default 1st-person flyCam (don't forget this!!)
  flyCam.setEnabled(false);

  registerInput();
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:35,代码来源:TestCameraNode.java


示例17: bindCamera

import com.jme3.scene.CameraNode; //导入依赖的package包/类
public CameraNode bindCamera(String cameraName, Camera cam) {
    CameraNode node = new CameraNode(cameraName, cam);
    node.setControlDir(ControlDirection.SpatialToCamera);
    node.getControl(CameraControl.class).setEnabled(false);
    cameras.put(cameraName, node);
    scene.attachChild(node);
    return node;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:9,代码来源:Cinematic.java


示例18: setWorld

import com.jme3.scene.CameraNode; //导入依赖的package包/类
public void setWorld(World w, boolean physics, boolean rendering, WorldType worldType) {
	if(world != null) {
		for(Entity e : world.getEntitiesOfClass(Entity.class))
			world.removeEntity(e);
		world.detachFromGame(stateManager);
		rootNode.detachChild(world.getNode());
	}

	world = w;

	if(world != null) {
		world.USE_SUPERFAST_PHYSICS = !physics;
		World.USE_SUPERFAST_RENDERING = !rendering;

		world.attachToGame(stateManager, new CachingAssetManager(assetManager), null, cam, worldType, viewPort);

		if(!physics)
			stateManager.detach(stateManager.getState(BulletAppState.class));
		if(rendering) {
			rootNode.attachChild(world.getNode());

			if(worldType == WorldType.SP) {
				CameraNode cn = new CameraNode("camera", cam);
		        cn.setLocalRotation(new Quaternion(new float[] {(float)Math.PI*0.25f, (float)Math.PI, 0}));
		        cn.setLocalTranslation(0, 80, 80);
		        ((Node)world.getPlayer().getMesh()).attachChild(cn);
			}
		}
	}
}
 
开发者ID:GSam,项目名称:Game-Project,代码行数:31,代码来源:GameTest.java


示例19: postInitialize

import com.jme3.scene.CameraNode; //导入依赖的package包/类
@Override
protected final void postInitialize() {
	flyCamera = app.getFlyByCamera().isEnabled();
	mouseManager = parent.getMouseManager();
	stateManager.attach(gameKeysState = new GameKeysAppState());

	// Player
	playerEntity = parent.getPlayerEntity();

	// Camera

	Quaternion rot = new Quaternion();
	rot.fromAngleAxis(0, Vector3f.UNIT_X);
	rot.fromAngleAxis(0, Vector3f.UNIT_Y);
	rot.fromAngleAxis(0, Vector3f.UNIT_Z);
	this.app.getCamera().setRotation(rot);

	camNode = new CameraNode("CamNode", this.app.getCamera());
	camNode.setControlDir(CameraControl.ControlDirection.CameraToSpatial);
	camNode.setEnabled(true);
	camNode.lookAt(playerEntity.getSpatial().getLocalTranslation(), Vector3f.UNIT_Y);

	chaseCam = new DetachableChaseCam(camNode.getCamera(), playerEntity.getSpatial(), inputManager) {
		@Override
		protected void followView(float rotation) {
		}
	};
	chaseCam.setPushZoom(true);
	chaseCam.setHeightAdjust(-5f);
	chaseCam.setLookAtOffset(new Vector3f(0, 20, 0));
	chaseCam.setSmoothMotion(false);
	chaseCam.setDownRotateOnCloseViewOnly(true);
	chaseCam.setInvertVerticalAxis(true);
	chaseCam.setChasingSensitivity(5f);
	chaseCam.setDragToRotate(true);
	chaseCam.setTrailingEnabled(true);
	chaseCam.setDefaultDistance(56);
	chaseCam.setMaxDistance(200);
	chaseCam.setRotationSpeed(Constants.CAMERA_ROTATE_SPEED);
	chaseCam.setZoomSensitivity(Constants.CAMERA_ZOOM_SENSITIVITY);

	chaseCam.setDefaultHorizontalRotation(-FastMath.DEG_TO_RAD * 90);
	chaseCam.setDefaultVerticalRotation(FastMath.DEG_TO_RAD * 10);

	app.getFlyByCamera().setEnabled(false);

	// NOTE - This is important, the camera needs to be added once the
	// player spatial is actually fully
	// loaded or we'll get this weird flickering in physics. This took AGES
	// to find
	if (playerEntity.isLoadedScene()) {
		playerEntity.getSpatial().addControl(chaseCam);
	} else {
		playerEntity.invoke(AbstractLoadableEntity.When.AFTER_SCENE_LOADED, new Callable<Void>() {
			public Void call() throws Exception {
				playerEntity.getSpatial().addControl(chaseCam);
				return null;
			}
		});
	}

}
 
开发者ID:rockfireredmoon,项目名称:iceclient,代码行数:63,代码来源:GamePlayAppState.java


示例20: simpleInitApp

import com.jme3.scene.CameraNode; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    createScene();
    cam.setLocation(new Vector3f(8.4399185f, 11.189463f, 14.267577f));
    camNode = new CameraNode("Motion cam", cam);
    camNode.setControlDir(ControlDirection.SpatialToCamera);
    camNode.getControl(0).setEnabled(false);
    path = new MotionPath();
    path.setCycle(true);
    path.addWayPoint(new Vector3f(20, 3, 0));
    path.addWayPoint(new Vector3f(0, 3, 20));
    path.addWayPoint(new Vector3f(-20, 3, 0));
    path.addWayPoint(new Vector3f(0, 3, -20));
    path.setCurveTension(0.83f);
    path.enableDebugShape(assetManager, rootNode);

    cameraMotionControl = new MotionTrack(camNode, path);
    cameraMotionControl.setLoopMode(LoopMode.Loop);
    //cameraMotionControl.setDuration(15f);
    cameraMotionControl.setLookAt(teapot.getWorldTranslation(), Vector3f.UNIT_Y);
    cameraMotionControl.setDirectionType(MotionTrack.Direction.LookAt);

    rootNode.attachChild(camNode);

    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    final BitmapText wayPointsText = new BitmapText(guiFont, false);
    wayPointsText.setSize(guiFont.getCharSet().getRenderedSize());

    guiNode.attachChild(wayPointsText);

    path.addListener(new MotionPathListener() {

        public void onWayPointReach(MotionTrack control, int wayPointIndex) {
            if (path.getNbWayPoints() == wayPointIndex + 1) {
                wayPointsText.setText(control.getSpatial().getName() + " Finish!!! ");
            } else {
                wayPointsText.setText(control.getSpatial().getName() + " Reached way point " + wayPointIndex);
            }
            wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);
        }
    });

    flyCam.setEnabled(false);
    chaser = new ChaseCamera(cam, teapot);
    chaser.registerWithInput(inputManager);
    chaser.setSmoothMotion(true);
    chaser.setMaxDistance(50);
    chaser.setDefaultDistance(50);
    initInputs();

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:52,代码来源:TestCameraMotionPath.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BlockDirt类代码示例发布时间:2022-05-22
下一篇:
Java IsisContext类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap