예제 #1
0
  // debug function that create a displayable frustrum
  protected Geometry createFrustum(Vector3f[] pts, int i) {
    WireFrustum frustum = new WireFrustum(pts);
    Geometry frustumMdl = new Geometry("f", frustum);
    frustumMdl.setCullHint(Spatial.CullHint.Never);
    frustumMdl.setShadowMode(ShadowMode.Off);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.getAdditionalRenderState().setWireframe(true);
    frustumMdl.setMaterial(mat);
    switch (i) {
      case 0:
        frustumMdl.getMaterial().setColor("Color", ColorRGBA.Pink);
        break;
      case 1:
        frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red);
        break;
      case 2:
        frustumMdl.getMaterial().setColor("Color", ColorRGBA.Green);
        break;
      case 3:
        frustumMdl.getMaterial().setColor("Color", ColorRGBA.Blue);
        break;
      default:
        frustumMdl.getMaterial().setColor("Color", ColorRGBA.White);
        break;
    }

    frustumMdl.updateGeometricState();
    return frustumMdl;
  }
예제 #2
0
  private Spatial createFollowBox() {
    // add spatial representing the position the driving car is steering towards
    Box box = new Box(new Vector3f(0, 0, 0), 1f, 1f, 1f);
    Geometry followBox = new Geometry("followBox", box);
    followBox.setLocalTranslation(0, 0, 0);
    Material followBoxMaterial =
        new Material(sim.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    followBoxMaterial.setColor("Color", ColorRGBA.Green);
    followBox.setMaterial(followBoxMaterial);
    followBox.setLocalScale(0.4f);
    sim.getSceneNode().attachChild(followBox);

    if (!settings.isPathVisible()) followBox.setCullHint(CullHint.Always);

    return followBox;
  }
예제 #3
0
  @Override
  public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(0.7804813f, 1.7502685f, -2.1556435f));
    cam.setRotation(new Quaternion(0.1961598f, -0.7213164f, 0.2266092f, 0.6243975f));
    cam.setFrustumFar(10);

    Material mat = assetManager.loadMaterial("Common/Materials/WhiteColor.j3m");
    rootNode.setShadowMode(ShadowMode.Off);
    Box floor = new Box(Vector3f.ZERO, 3, 0.1f, 3);
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(mat);
    floorGeom.setLocalTranslation(0, -0.2f, 0);
    floorGeom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(floorGeom);

    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalScale(2f);
    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(teapot);
    //        lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    //        lightMdl.setMaterial(mat);
    //        // disable shadowing for light representation
    //        lightMdl.setShadowMode(ShadowMode.Off);
    //        rootNode.attachChild(lightMdl);

    bsr = new BasicShadowRenderer(assetManager, 512);
    bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    viewPort.addProcessor(bsr);

    frustum = new WireFrustum(bsr.getPoints());
    frustumMdl = new Geometry("f", frustum);
    frustumMdl.setCullHint(Spatial.CullHint.Never);
    frustumMdl.setShadowMode(ShadowMode.Off);
    frustumMdl.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
    frustumMdl.getMaterial().getAdditionalRenderState().setWireframe(true);
    frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red);
    rootNode.attachChild(frustumMdl);
  }