当前位置: 首页>>代码示例>>Java>>正文


Java ControlDirection类代码示例

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


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

示例1: parseCamera

import com.jme3.scene.control.CameraControl.ControlDirection; //导入依赖的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

示例2: bindCamera

import com.jme3.scene.control.CameraControl.ControlDirection; //导入依赖的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

示例3: simpleInitApp

import com.jme3.scene.control.CameraControl.ControlDirection; //导入依赖的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

示例4: simpleInitApp

import com.jme3.scene.control.CameraControl.ControlDirection; //导入依赖的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

示例5: simpleInitApp

import com.jme3.scene.control.CameraControl.ControlDirection; //导入依赖的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

示例6: bindCamera

import com.jme3.scene.control.CameraControl.ControlDirection; //导入依赖的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

示例7: simpleInitApp

import com.jme3.scene.control.CameraControl.ControlDirection; //导入依赖的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

示例8: setControlDir

import com.jme3.scene.control.CameraControl.ControlDirection; //导入依赖的package包/类
public void setControlDir(ControlDirection controlDir) {
    camControl.setControlDir(controlDir);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:CameraNode.java

示例9: getControlDir

import com.jme3.scene.control.CameraControl.ControlDirection; //导入依赖的package包/类
public ControlDirection getControlDir() {
    return camControl.getControlDir();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:CameraNode.java

示例10: simpleInitApp

import com.jme3.scene.control.CameraControl.ControlDirection; //导入依赖的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();

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


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