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