本文整理汇总了Java中com.jme3.scene.CameraNode.setControlDir方法的典型用法代码示例。如果您正苦于以下问题:Java CameraNode.setControlDir方法的具体用法?Java CameraNode.setControlDir怎么用?Java CameraNode.setControlDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.scene.CameraNode
的用法示例。
在下文中一共展示了CameraNode.setControlDir方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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;
}
示例4: 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);
}
}
示例5: 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);
}
示例6: 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();
}
示例7: 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;
}
示例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: 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();
}
示例10: 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(CameraControl.class).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();
}