public void frameUpdate(float timePerFrame) {
    // TODO Auto-generated method stub
    // TODO Play Frame, when in the right time => Sync-Playback-rate
    /*
     *
    // Put A Frame according to its Framerate
     * TODO: Declare    private long controller;
      						private long frameWait;
      						private long starttime;
      						private int iteration;

      			 Initialize starttime = System.currentTimeMillis();
    					controller = System.currentTimeMillis();
    					frameWait = 1000 / perf.getFramerate();
    					iteration = 0;

    This one into the update function:

    if (System.currentTimeMillis() >= (controller + frameWait)){
    		controller = System.currentTimeMillis();
    		System.out.println("There you go: " + System.currentTimeMillis());
    		drawFrame();
    		iteration++;
    }

    if (System.currentTimeMillis() > (starttime + (iteration*frameWait)+frameWait)) {
    	// skip Frame

    	iteration += 2;
    	System.out.println("Look ma, no hands: " + iteration);
    }
     */
    // timer.getTimePerFrame();

    if (oggDecoder.isReady()) {
      oggDecoder.readBody();
      TextureManager.releaseTexture(texture.getTextureKey());

      texture =
          TextureManager.loadTexture(
              Toolkit.getDefaultToolkit().createImage(oggDecoder.getYUVBuffer()),
              MinificationFilter.BilinearNearestMipMap,
              MagnificationFilter.Bilinear,
              true);
      if (texture != null) {
        if (textureState != null)
          textureState = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
        textureState.setTexture(texture);
        quad.setRenderState(textureState);
        quad.updateRenderState();
      }
    }
  }
Exemple #2
0
  public Enemy(String id, Renderer renderer) {
    super(id, null);

    URL model = getClass().getClassLoader().getResource("fokker.jme");
    Spatial ship = null;
    try {
      ship = (Spatial) BinaryImporter.getInstance().load(model.openStream());
    } catch (IOException e) {
      e.printStackTrace();
    }

    ship.setLocalScale(.2f);
    TextureState ts = renderer.createTextureState();
    ts.setEnabled(true);
    ts.setTexture(
        TextureManager.loadTexture(
            getClass().getClassLoader().getResource("fokker.jpg"),
            Texture.MinificationFilter.Trilinear,
            Texture.MagnificationFilter.Bilinear));
    ship.setRenderState(ts);
    ship.setNormalsMode(NormalsMode.AlwaysNormalize);
    ship.setModelBound(new BoundingBox());
    ship.updateModelBound();

    //        ship.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Z));
    setModel(ship);

    Vector3f[] points = new Vector3f[6];
    points[0] = new Vector3f(110, 0, 110);
    points[1] = new Vector3f(110, 0, 50);
    points[2] = new Vector3f(-20, 0, 10);
    points[3] = new Vector3f(20, 0, -20);
    points[4] = new Vector3f(-90, 0, -90);
    points[5] = new Vector3f(0, 0, 110);
    endPoint = points[5];

    CatmullRomCurve curve = new CatmullRomCurve("Curve", points);
    curve.setSteps(512);
    //        ship.setLocalTranslation(points[0]);
    //        curve.setCullHint(CullHint.Always);

    CurveController curveController = new CurveController(curve, ship);
    ship.addController(curveController);
    curveController.setRepeatType(Controller.RT_CLAMP);
    curveController.setSpeed(0.05f);
    curveController.setAutoRotation(true);
    curveController.setUpVector(new Vector3f(0, 0.5f, 0));

    attachChild(curve);

    ExplosionFactory.warmup();
  }
 public static void replaceMaterials(Spatial s) {
   MaterialState ms = materials.remove(s.getName());
   if (ms != null) {
     s.setRenderState(ms);
   }
   s.updateRenderState();
   if (s instanceof Node) {
     if (((Node) s).getChildren() != null) {
       for (Spatial child : ((Node) s).getChildren()) {
         replaceMaterials(child);
       }
     }
   }
 }
 /**
  * Applies color to a Spatial in the form of a <code>MaterialState</code>.
  *
  * @param spatial
  * @param diffuseColor
  * @param ambientColor
  * @see MaterialState
  */
 public static MaterialState applyColor(
     Spatial spatial, ColorRGBA diffuseColor, ColorRGBA ambientColor) {
   colorStripper(spatial);
   MaterialState targetMaterial =
       DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
   targetMaterial.setDiffuse(diffuseColor);
   targetMaterial.setAmbient(ambientColor);
   spatial.setRenderState(targetMaterial);
   spatial.updateRenderState();
   if (workingState != null) {
     MaterialState ms = (MaterialState) workingState;
     workingState = null;
     return ms;
   } else return null;
 }
  private void createShape() {
    quad = new Quad("texturedQuad", Scale.fromMeter(25), Scale.fromMeter(25));
    // quad = new Box("", new Vector3f(), Scale.fromMeter(25), Scale.fromMeter(25),
    // Scale.fromMeter(25));

    // quad.setLocalTranslation(new Vector3f(0,0,-400));

    texture =
        TextureManager.loadTexture(
            "data/foliage/A_Bush_1.png",
            MinificationFilter.BilinearNearestMipMap,
            MagnificationFilter.Bilinear);

    if (texture != null) {
      textureState = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
      textureState.setTexture(texture);
      quad.setRenderState(textureState);
    }

    // rootNode.attachChild(quad);
  }
 private static void doWireframeApplication(Spatial s, boolean apply, WireframeState ws) {
   if (apply) s.setRenderState(ws);
   else if (s.getRenderState(StateType.Wireframe) != null) {
     s.clearRenderState(StateType.Wireframe);
   }
 }
 public static void applyMaterial(Spatial spatial, MaterialState ms) {
   colorStripper(spatial);
   spatial.setRenderState(ms);
   spatial.updateRenderState();
 }