コード例 #1
0
  public void simpleInitApp() {
    renderManager.setAlphaToCoverage(true);
    cam.setLocation(new Vector3f(0.14914267f, 0.58147097f, 4.7686534f));
    cam.setRotation(new Quaternion(-0.0044764364f, 0.9767943f, 0.21314798f, 0.020512417f));

    //        cam.setLocation(new Vector3f(2.0606942f, 3.20342f, 6.7860126f));
    //        cam.setRotation(new Quaternion(-0.017481906f, 0.98241085f, -0.12393151f,
    // -0.13857932f));

    viewPort.setBackgroundColor(ColorRGBA.DarkGray);

    Quad q = new Quad(20, 20);
    q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(5));
    Geometry geom = new Geometry("floor", q);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    geom.setMaterial(mat);

    geom.rotate(-FastMath.HALF_PI, 0, 0);
    geom.center();
    geom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(geom);

    // create the geometry and attach it
    Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
    teaGeom.setQueueBucket(Bucket.Transparent);
    teaGeom.setShadowMode(ShadowMode.Cast);
    makeToonish(teaGeom);

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(al);

    DirectionalLight dl1 = new DirectionalLight();
    dl1.setDirection(new Vector3f(1, -1, 1).normalizeLocal());
    dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    rootNode.addLight(dl1);

    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    dl.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    rootNode.addLight(dl);

    rootNode.attachChild(teaGeom);

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    CartoonEdgeFilter toon = new CartoonEdgeFilter();
    toon.setEdgeWidth(0.5f);
    toon.setEdgeIntensity(1.0f);
    toon.setNormalThreshold(0.8f);
    fpp.addFilter(toon);
    viewPort.addProcessor(fpp);
  }
コード例 #2
0
ファイル: SlitScanSimulation.java プロジェクト: tado/CC4p52
  private void setupEnvironments() {
    // カメラ設定
    cam.setFrustumPerspective(80f, 1f, 1f, 1000f);
    cam.setLocation(new Vector3f(0, 1.5f, 10));
    // cam.lookAt(new Vector3f(0, 1.6f, 0), Vector3f.UNIT_Y);
    flyCam.setDragToRotate(true);

    // ライティング
    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White.mult(3.0f));
    dl.setDirection(Vector3f.UNIT_XYZ.negate());
    rootNode.addLight(dl);

    // マテリアル設定
    Material textureMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    textureMat.setTexture("ColorMap", assetManager.loadTexture("myAssets/Textures/woodFloor.jpg"));
    Material whitemat = assetManager.loadMaterial("Common/Materials/WhiteColor.j3m");

    // 床面
    Box floor = new Box(Vector3f.ZERO, 20.0f, 0.01f, 20.0f);
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(textureMat);
    floorGeom.setLocalTranslation(0, 0, 0);
    rootNode.attachChild(floorGeom);

    // 壁面
    wallGeom[0] = new Geometry("Wall1", new Box(Vector3f.ZERO, 20f, 4f, 0.1f));
    wallGeom[1] = new Geometry("Wall2", new Box(Vector3f.ZERO, 20f, 4f, 0.1f));
    wallGeom[2] = new Geometry("Wall3", new Box(Vector3f.ZERO, 20f, 4f, 0.1f));
    wallGeom[0].setMaterial(whitemat);
    wallGeom[1].setMaterial(whitemat);
    wallGeom[2].setMaterial(whitemat);
    wallGeom[0].setLocalTranslation(0, 4, -2);
    wallGeom[1].setLocalTranslation(-20, 4, 0);
    wallGeom[2].setLocalTranslation(20, 4, 0);
    wallGeom[1].rotate(0, (float) (Math.PI / 2f), 0);
    wallGeom[2].rotate(0, (float) (Math.PI / 2f), 0);
    rootNode.attachChild(wallGeom[0]);
    rootNode.attachChild(wallGeom[1]);
    rootNode.attachChild(wallGeom[2]);

    // 女性をランダムに追加
    for (int i = 0; i < girl.length; i++) {
      girl[i] = assetManager.loadModel("myAssets/Models/WalkingGirl/WalkingGirl.obj");
      girlPos[i] =
          new Vector3f((float) (Math.random() * 16.0f - 8f), 0, (float) (Math.random() * 8f));
      // 移動スピードをランダムに
      girlSpeed[i] = (float) (Math.random() * -0.02f) + 0.01f;
      if (girlSpeed[i] < 0) {
        girl[i].rotate(0, (float) (-Math.PI / 2.0f), 0);
      } else {
        girl[i].rotate(0, (float) (Math.PI / 2.0f), 0);
      }
      girl[i].setLocalTranslation(girlPos[i]);
      this.rootNode.attachChild(girl[i]);
    }
  }
コード例 #3
0
  protected void makeLight() {
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(2));
    reflectNode.addLight(al);

    DirectionalLight dl1 = new DirectionalLight();
    dl1.setDirection(new Vector3f(0.98f, -0.98f, 0.94f).normalizeLocal());
    dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    reflectNode.addLight(dl1);
  }
コード例 #4
0
  @Override
  public void setUpLight() {
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(1.3f));
    app.getRootNode().addLight(al);

    sun = new DirectionalLight();
    sun.setColor(ColorRGBA.White);
    sun.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());
    app.getRootNode().addLight(sun);
  }
コード例 #5
0
  /** This method adds lighting to the game world. */
  private void setupLights() {
    // Add simple light so we can see the world
    com.jme3.light.DirectionalLight sun = new com.jme3.light.DirectionalLight();
    sun.setColor(com.jme3.math.ColorRGBA.White.mult(0.5f));
    sun.setDirection(new com.jme3.math.Vector3f(-0.2f, -1.0f, -0.2f));
    rootNode.addLight(sun);

    // Add ambient light for a more realistic look
    com.jme3.light.AmbientLight al = new com.jme3.light.AmbientLight();
    al.setColor(com.jme3.math.ColorRGBA.White.mult(2.0f));
    rootNode.addLight(al);
  }
コード例 #6
0
ファイル: HelloProjector.java プロジェクト: tado/CC4p52b6
  @Override
  public void simpleInitApp() {
    // sun
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -1f, -1).normalizeLocal());
    dl.setColor(ColorRGBA.Orange);
    rootNode.addLight(dl);
    // ambient light
    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
    rootNode.addLight(al);

    // floor
    Material textureMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    textureMat.setTexture("ColorMap", assetManager.loadTexture("myAssets/Textures/woodFloor.jpg"));
    Box floor = new Box(Vector3f.ZERO, 20.0f, 0.01f, 20.0f);
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(textureMat);
    rootNode.attachChild(floorGeom);

    // object
    Spatial tree = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
    tree.setQueueBucket(Bucket.Transparent);
    rootNode.attachChild(tree);

    // projector
    PApplet applet = new ColorBarsPApplet();
    PAppletProjectorNode projectorNode =
        new PAppletProjectorNode("projector0", assetManager, applet, 200, 200, true);
    rootNode.attachChild(projectorNode);
    rootNode.attachChild(
        projectorNode
            .getFrustmMdel()); // if you don't want to see frustum, please don't attach it to
    // rootNode.
    // projector should be added to TextureProjectorRenderer, and TextureProjectorRenderer should be
    // added to ViewPort.
    TextureProjectorRenderer ptr = new TextureProjectorRenderer(assetManager);
    ptr.getTextureProjectors().add(projectorNode.getProjector());
    viewPort.addProcessor(ptr);

    // projector is a kind of Shadow, and following processes are necessary for Shadow Rendering.
    floorGeom.setShadowMode(ShadowMode.Receive);
    tree.setShadowMode(ShadowMode.CastAndReceive); // tree makes and receives shadow

    projectorNode.setLocalTranslation(new Vector3f(0, 10, 0)); // move the projector,
    projectorNode.lookAt(
        new Vector3f(0, 0, 0), Vector3f.UNIT_X); // and make it to look at where you want.

    // cam
    cam.setLocation(Vector3f.UNIT_XYZ.mult(10.0f)); // camera moves to 10, 10, 10
    cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y); // and looks at 0,0,0.
  }
コード例 #7
0
ファイル: TestQ3.java プロジェクト: filinep/castlegame
  public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    flyCam.setMoveSpeed(100);
    setupKeys();

    this.cam.setFrustumFar(2000);

    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White.clone().multLocal(2));
    dl.setDirection(new Vector3f(-1, -1, -1).normalize());
    rootNode.addLight(dl);

    AmbientLight am = new AmbientLight();
    am.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(am);

    // load the level from zip or http zip
    if (useHttp) {
      assetManager.registerLocator(
          "http://jmonkeyengine.googlecode.com/files/quake3level.zip",
          HttpZipLocator.class.getName());
    } else {
      assetManager.registerLocator("basic.scene", ZipLocator.class.getName());
    }

    // create the geometry and attach it
    MaterialList matList = (MaterialList) assetManager.loadAsset("Scene.material");
    OgreMeshKey key = new OgreMeshKey("main.meshxml", matList);
    gameLevel = (Node) assetManager.loadAsset(key);
    gameLevel.setLocalScale(0.1f);

    // add a physics control, it will generate a MeshCollisionShape based on the gameLevel
    gameLevel.addControl(new RigidBodyControl(0));

    player = new PhysicsCharacter(new SphereCollisionShape(5), .01f);
    player.setJumpSpeed(20);
    player.setFallSpeed(30);
    player.setGravity(30);

    player.setPhysicsLocation(new Vector3f(60, 10, -60));

    rootNode.attachChild(gameLevel);

    getPhysicsSpace().addAll(gameLevel);
    getPhysicsSpace().add(player);
  }
コード例 #8
0
  @Override
  public void simpleInitApp() {

    Sphere sphereMesh = new Sphere(32, 32, 1f);

    Geometry spherePlainGeo = new Geometry("rough sphere", sphereMesh);
    Material spherePlainMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    spherePlainMat.setFloat("Shininess", 0f); // [1,128]
    spherePlainMat.setBoolean("UseMaterialColors", true);
    spherePlainMat.setColor("Ambient", ColorRGBA.Black);
    spherePlainMat.setColor("Diffuse", ColorRGBA.Cyan);
    spherePlainMat.setColor("Specular", ColorRGBA.White);
    spherePlainGeo.setMaterial(spherePlainMat);
    spherePlainGeo.move(-2.5f, 0, 0);
    rootNode.attachChild(spherePlainGeo);

    Geometry sphereShinyGeo = new Geometry("normal sphere", sphereMesh);
    Material sphereShinyMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    sphereShinyMat.setBoolean("UseMaterialColors", true);
    sphereShinyMat.setColor("Ambient", ColorRGBA.Black);
    sphereShinyMat.setColor("Diffuse", ColorRGBA.Cyan);
    sphereShinyMat.setColor("Specular", ColorRGBA.White);
    sphereShinyMat.setFloat("Shininess", 4f); // [1,128]
    sphereShinyGeo.setMaterial(sphereShinyMat);
    rootNode.attachChild(sphereShinyGeo);

    Geometry sphereVeryShinyGeo = new Geometry("Smooth sphere", sphereMesh);
    Material sphereVeryShinyMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    sphereVeryShinyMat.setBoolean("UseMaterialColors", true);
    sphereVeryShinyMat.setColor("Ambient", ColorRGBA.Black);
    sphereVeryShinyMat.setColor("Diffuse", ColorRGBA.Cyan);
    sphereVeryShinyMat.setColor("Specular", ColorRGBA.White);
    sphereVeryShinyMat.setFloat("Shininess", 100f); // [1,128]
    sphereVeryShinyGeo.setMaterial(sphereVeryShinyMat);
    sphereVeryShinyGeo.move(2.5f, 0, 0);
    rootNode.attachChild(sphereVeryShinyGeo);

    /** Must add a light to make the lit object visible! */
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(1, 0, -2));
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun);
  }
コード例 #9
0
ファイル: Translator.java プロジェクト: emixam16/OpenRTS
  public static void toJMELight(DirectionalLight JMEdl, DirectionalLighting dl) {
    JMEdl.setColor(toColorRGBA(dl.color).multLocal((float) (dl.intensity)));
    Node world = new Node();

    Node yaw = new Node();
    world.attachChild(yaw);

    Node pitch = new Node();
    yaw.attachChild(pitch);

    Node offset = new Node();
    pitch.attachChild(offset);
    offset.setLocalTranslation(Vector3f.UNIT_X);

    pitch.rotate(0, (float) dl.pitch, 0);

    yaw.rotate(0, 0, (float) dl.yaw);
    JMEdl.setDirection(offset.getWorldTranslation());
  }
コード例 #10
0
  // シーンを定義
  private void setupScene() {
    // カメラの位置、向き、移動速度を設定
    cam.setLocation(new Vector3f(0.0f, 1.6f, 24.0f));
    cam.lookAt(new Vector3f(0f, 1.6f, 0f), Vector3f.UNIT_Y);
    flyCam.setMoveSpeed(5);
    flyCam.setDragToRotate(true);

    // 空を追加
    Texture west = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_west.jpg");
    Texture east = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_east.jpg");
    Texture north = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_north.jpg");
    Texture south = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_south.jpg");
    Texture up = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_up.jpg");
    Texture down = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_down.jpg");
    Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
    rootNode.attachChild(sky);

    // 床面を生成
    Material floor_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    floor_mat.setColor("Color", ColorRGBA.Gray);
    Box floor = new Box(Vector3f.ZERO, 1500f, 0.01f, 1500f);
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(floor_mat);
    rootNode.attachChild(floorGeom);

    // 照明
    DirectionalLight sun = new DirectionalLight();
    sun.setColor(ColorRGBA.White.mult(3.0f));
    sun.setDirection(new Vector3f(-.5f, -.5f, -.5f).normalizeLocal());
    rootNode.addLight(sun);

    // 女性を追加
    Spatial girl = assetManager.loadModel("myAssets/Models/WalkingGirl/WalkingGirl.obj");
    girl.rotate(0, (float) (Math.PI), 0);
    girl.setLocalTranslation(0f, 0f, 20f);
    this.rootNode.attachChild(girl);
  }
コード例 #11
0
  @Override
  public void simpleInitApp() {
    viewPort.setBackgroundColor(ColorRGBA.White);
    flyCam.setMoveSpeed(50);

    /** A simple textured sphere */
    Sphere sphereMesh = new Sphere(16, 16, 1);
    Geometry sphereGeo = new Geometry("lit textured sphere", sphereMesh);
    Material sphereMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    sphereMat.setTexture("DiffuseMap", assetManager.loadTexture("Interface/Monkey.png"));
    sphereMat.setBoolean("UseMaterialColors", true);
    sphereMat.setColor("Diffuse", ColorRGBA.Gray);
    sphereMat.setColor("Ambient", ColorRGBA.Gray);
    // alpha test start
    sphereMat.getAdditionalRenderState().setAlphaTest(true);
    sphereMat.getAdditionalRenderState().setAlphaFallOff(.5f);
    sphereGeo.setQueueBucket(Bucket.Transparent);
    // alpha test end
    sphereGeo.setMaterial(sphereMat);
    sphereGeo.move(-2f, 0f, 0f);
    sphereGeo.rotate(FastMath.DEG_TO_RAD * -90, FastMath.DEG_TO_RAD * 120, 0f);
    rootNode.attachChild(sphereGeo);

    /**
     * This material turns the box into a stained glass window. The texture has an alpha channel and
     * is partially transparent.
     */
    Box windowMesh = new Box(new Vector3f(0f, 0f, 0f), 1f, 1.4f, 0.01f);
    Geometry windowGeo = new Geometry("stained glass window", windowMesh);
    Material windowMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    windowMat.setTexture("DiffuseMap", assetManager.loadTexture("Textures/mucha-window.png"));
    windowMat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
    windowGeo.setMaterial(windowMat);
    windowGeo.setQueueBucket(Bucket.Transparent);
    windowGeo.setMaterial(windowMat);
    windowGeo.move(1, 0, 0);
    rootNode.attachChild(windowGeo);

    /**
     * A box with its material color "bleeding" through. The texture has an alpha channel and is
     * partially transparent.
     */
    Cylinder logMesh = new Cylinder(32, 32, 1, 8, true);
    TangentBinormalGenerator.generate(logMesh);
    Geometry logGeo = new Geometry("Bleed-through color", logMesh);
    Material logMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    logMat.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Bark/bark_diffuse.png"));
    logMat.setTexture("NormalMap", assetManager.loadTexture("Textures/Bark/bark_normal.png"));
    logMat.setBoolean("UseMaterialColors", true);
    logMat.setColor("Diffuse", ColorRGBA.Orange);
    logMat.setColor("Ambient", ColorRGBA.Gray);
    logMat.setBoolean("UseAlpha", true);
    logGeo.setMaterial(logMat);
    logGeo.move(0f, 0f, -2f);
    logGeo.rotate(0f, FastMath.DEG_TO_RAD * 90, 0f);
    rootNode.attachChild(logGeo);

    /** Must add a light to make the lit object visible! */
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(1, 0, -2).normalizeLocal());
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun);
    AmbientLight ambient = new AmbientLight();
    ambient.setColor(ColorRGBA.White);
    rootNode.addLight(ambient);
  }