本文整理汇总了Java中com.jme3.scene.CameraNode.lookAt方法的典型用法代码示例。如果您正苦于以下问题:Java CameraNode.lookAt方法的具体用法?Java CameraNode.lookAt怎么用?Java CameraNode.lookAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.scene.CameraNode
的用法示例。
在下文中一共展示了CameraNode.lookAt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: 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;
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
}
示例6: 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);
}
示例7: 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();
}
示例8: 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;
}
});
}
}
示例9: setupCinematic
import com.jme3.scene.CameraNode; //导入方法依赖的package包/类
public void setupCinematic(final Node jaime) {
cinematic = new Cinematic(rootNode, 60);
stateManager.attach(cinematic);
jaime.move(0, 0, -3);
AnimationFactory af = new AnimationFactory(0.7f, "JumpForward");
af.addTimeTranslation(0, new Vector3f(0, 0, -3));
af.addTimeTranslation(0.35f, new Vector3f(0, 1, -1.5f));
af.addTimeTranslation(0.7f, new Vector3f(0, 0, 0));
jaime.getControl(AnimControl.class).addAnim(af.buildAnimation());
cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Idle",3, LoopMode.DontLoop));
float jumpStart = cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "JumpStart", LoopMode.DontLoop));
cinematic.addCinematicEvent(jumpStart+0.2f, new AnimationEvent(jaime, "JumpForward", LoopMode.DontLoop,1));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "JumpEnd", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "Punches", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "SideKick", LoopMode.DontLoop));
float camStart = cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "Taunt", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "Idle",1, LoopMode.DontLoop));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "Wave", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "Idle", LoopMode.DontLoop));
CameraNode camNode = cinematic.bindCamera("cam", cam);
camNode.setLocalTranslation(new Vector3f(1.1f, 1.2f, 2.9f));
camNode.lookAt(new Vector3f(0, 0.5f, 0), Vector3f.UNIT_Y);
MotionPath path = new MotionPath();
path.addWayPoint(new Vector3f(1.1f, 1.2f, 2.9f));
path.addWayPoint(new Vector3f(0f, 1.2f, 3.0f));
path.addWayPoint(new Vector3f(-1.1f, 1.2f, 2.9f));
path.enableDebugShape(assetManager, rootNode);
path.setCurveTension(0.8f);
MotionEvent camMotion = new MotionEvent(camNode, path,6);
camMotion.setDirectionType(MotionEvent.Direction.LookAt);
camMotion.setLookAt(new Vector3f(0, 0.5f, 0), Vector3f.UNIT_Y);
cinematic.addCinematicEvent(camStart, camMotion);
cinematic.activateCamera(0, "cam");
cinematic.fitDuration();
cinematic.setSpeed(1.2f);
cinematic.setLoopMode(LoopMode.Loop);
cinematic.play();
}
示例10: setupCinematic
import com.jme3.scene.CameraNode; //导入方法依赖的package包/类
public void setupCinematic(final Node jaime) {
cinematic = new Cinematic(rootNode, 60);
stateManager.attach(cinematic);
jaime.move(0, 0, -3);
AnimationFactory af = new AnimationFactory(0.7f, "JumpForward");
af.addTimeTranslation(0, new Vector3f(0, 0, -3));
af.addTimeTranslation(0.35f, new Vector3f(0, 1, -1.5f));
af.addTimeTranslation(0.7f, new Vector3f(0, 0, 0));
jaime.getControl(AnimControl.class).addAnim(af.buildAnimation());
cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Idle",3, LoopMode.DontLoop));
float jumpStart = cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "JumpStart", LoopMode.DontLoop));
cinematic.addCinematicEvent(jumpStart+0.2f, new AnimationEvent(jaime, "JumpForward", LoopMode.DontLoop,1));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "JumpEnd", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "Punches", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "SideKick", LoopMode.DontLoop));
float camStart = cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "Taunt", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "Idle",1, LoopMode.DontLoop));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "Wave", LoopMode.DontLoop));
cinematic.enqueueCinematicEvent( new AnimationEvent(jaime, "Idle", LoopMode.DontLoop));
CameraNode camNode = cinematic.bindCamera("cam", cam);
camNode.setLocalTranslation(new Vector3f(1.1f, 1.2f, 2.9f));
camNode.lookAt(new Vector3f(0, 0.5f, 0), Vector3f.UNIT_Y);
MotionPath path = new MotionPath();
path.addWayPoint(new Vector3f(1.1f, 1.2f, 2.9f));
path.addWayPoint(new Vector3f(0f, 1.2f, 3.0f));
path.addWayPoint(new Vector3f(-1.1f, 1.2f, 2.9f));
path.enableDebugShape(assetManager, rootNode);
path.setCurveTension(0.8f);
MotionEvent camMotion = new MotionEvent(camNode, path,6);
camMotion.setDirectionType(MotionEvent.Direction.LookAt);
camMotion.setLookAt(new Vector3f(0, 0.5f, 0), Vector3f.UNIT_Y);
cinematic.addCinematicEvent(camStart, camMotion);
cinematic.activateCamera(0, "cam");
cinematic.fitDuration();
cinematic.setSpeed(1.2f);
cinematic.setLoopMode(LoopMode.Loop);
cinematic.play();
}