Exemplo n.º 1
0
  public Trapeeze(Game game) {
    Cylinder pole = new Cylinder(10, 10, radius, height, true);
    leftPole = new Geometry("leftPole", pole);
    leftPole.rotate(90f * FastMath.DEG_TO_RAD, 0, 0);
    leftPole.setLocalTranslation(-1f, height / 2f, 0f);
    leftPole.setShadowMode(RenderQueue.ShadowMode.Cast);

    rightPole = new Geometry("rightPole", pole);
    rightPole.rotate(90f * FastMath.DEG_TO_RAD, 0, 0);
    rightPole.setLocalTranslation(1f, height / 2f, 0f);
    rightPole.setShadowMode(RenderQueue.ShadowMode.Cast);

    float betweenPoles = rightPole.getLocalTranslation().x - leftPole.getLocalTranslation().x;
    Box seat = new Box(betweenPoles, radius, radius * 4);
    swing = new Geometry("swing", seat);
    swing.rotate(90f * FastMath.DEG_TO_RAD, 0, 0);
    swing.setLocalTranslation(0f, 3, 0f);
    swing.setShadowMode(RenderQueue.ShadowMode.Cast);

    swing.move(-4.0f, 6f, 0.0f);
    leftPole.move(-4.0f, 10f, 0.0f);
    rightPole.move(-4.0f, 10f, 0.0f);

    setTrapeezeMaterial(Main.matOrange);

    collisionShape = CollisionShapeFactory.createBoxShape(leftPole);
    collisionShape = CollisionShapeFactory.createBoxShape(rightPole);
    collisionShape = CollisionShapeFactory.createBoxShape(swing);

    this.attachChild(leftPole);
    this.attachChild(swing);
  }
Exemplo n.º 2
0
 public void addBrick(Vector3f ori) {
   Geometry reBoxg = new Geometry("brick", brick);
   reBoxg.setMaterial(mat);
   reBoxg.setLocalTranslation(ori);
   reBoxg.rotate(0f, (float) Math.toRadians(angle), 0f);
   reBoxg.addControl(new RigidBodyControl(1.5f));
   reBoxg.setShadowMode(ShadowMode.CastAndReceive);
   reBoxg.getControl(RigidBodyControl.class).setFriction(1.6f);
   this.rootNode.attachChild(reBoxg);
   this.getPhysicsSpace().add(reBoxg);
 }
  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);
  }
  @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);
  }