Examples of NanoTimer


Examples of com.jme3.system.NanoTimer

   */
  public void update(float tpf){
    usedBudget = 0f;
    Component c = null;
    Component started = null;
    NanoTimer timer = new NanoTimer();
    do{
      c = getComponent();
      if(c != null) {
        if(started != null){
          if(c!=started){
            onUpdateOf(c, tpf);
          } else {
            log.finest(this.getClass()+" used budget up to:"+usedBudget+" of "+timeBudget);         
            return;
          }
        } else {
          started = c;
          onUpdateOf(c, tpf);
        }
      }
      else
        return;
      usedBudget = timer.getTimeInSeconds();
      log.finest(this.getClass()+" used time budget:"+usedBudget);
    } while( usedBudget <timeBudget);
    log.severe(this.getClass()+" used complete budget:"+usedBudget+" of "+timeBudget);
  }
View Full Code Here

Examples of com.jme3.system.NanoTimer

      if (fs.isDirectory())
        convert(fs);
  }

  public int convertNav(File from) throws Throwable {
    Timer t = new NanoTimer();
    float time = 0f;

    // new loader each time, yes
    try {
      Geometry g;
      // need to load vial loadModel, JME does not see obj, etc as
      // Assets..
      t.reset();
      Spatial n = (Spatial) assetMan.loadModel(from.getAbsolutePath());
      time = t.getTimeInSeconds();
      System.out.println("File " + from.getAbsolutePath() + " loaded in "
          + time + " seconds");
      if (n instanceof Geometry) {
        g = (Geometry) n;
        n = new Node(g.getName());
        ((Node)n).attachChild(g);
      } else if (n instanceof Node) {
        if (((Node) n).getChildren().size() > 1)
          throw new Throwable(
              "Mesh with more children detected than one on "
                  + from.getName());
        g = (Geometry) ((Node) n).getChild(0);
      } else
        throw new Throwable("Spatial loaded was unexpected type "
            + n.getClass());
      // jme fucked up the model names, and ignores any object name
      // entries so we fix a bit
      String fName = from.getName().substring(0,
          from.getName().length() - fileEnding.length());// without .nav
      g.setName(fName.toLowerCase());
      TiledNavMesh navMesh = new TiledNavMesh();

      {
      String[] xy = from.getParentFile().getName().split("_");
      // l2j's center is in x between region 19 (-32768) and 20 (+32768)
      // and in y between region 18 (+32768) and 17 (-32768)
     
      // minus 20*2048, 20 because region count starts with 0_0,
      // 2048 because one region consists of 8x8 tiles (each 256x256 long)
      int xd = (Integer.parseInt(xy[0]) * 256) - (20 * 2048);
      // minus 18*2048
      int yd = (Integer.parseInt(xy[1])) * 256 - (18 * 2048);
     
      // center is in top left corner for nav mesh to be consistent with
      // this for borders move x right, move y up by half size
      Vector3f offset = new Vector3f(xd + 128, 0, yd - 128);
      System.out.println("Offset for "+from.getParentFile().getName()+"/nav2.obj should be at:"+offset);
      }
     
      navMesh.loadFromMesh(g.getMesh(), Vector3f.ZERO, isMeshRelative);
     
      time = t.getTimeInSeconds();
      System.out.println("File " + from.getAbsolutePath()
          + " converted in " + time + " seconds");
      String path = from.getAbsolutePath();
      String parent = from.getParent();
      // replace .nav with .jnv
      t.reset();
      BinaryExporter.getInstance().save(navMesh,
          new File(parent+"/nav.jnv"));
      time = t.getTimeInSeconds();
//      System.out.println("File "+parent+"/nav.jnv saved in "
//          + time + " seconds");
//      t.reset();
//      writeMeshToObjFile(mesh,
//          new File(parent+"/nav.obj"));
View Full Code Here

Examples of com.jme3.system.NanoTimer

      if (fs.isDirectory())
        convert(fs);
  }

  public int convertNav(File from) throws Throwable {
    Timer t = new NanoTimer();
    float time = 0f;

    // new loader each time, yes
    try {
//      System.out.println("-------------------------------------------------------");
      // need to load vial loadModel, JME does not see obj, etc as
      // Assets..
      t.reset();
      Spatial model = assetMan.loadModel(from.getAbsolutePath());
      Node n = new Node("dummy");
      if(!(model instanceof Node))
        n.attachChild(model);
      time = t.getTimeInSeconds();
//      System.out.println("File " + from.getAbsolutePath() + " loaded in "
//          + time + " seconds");

      // jme fucked up the model names, and ignores any object name
      // entries so we fix a bit
      String fName = from.getName().substring(0,
          from.getName().length() - fileEnding.length());// without .obj


      String[] xy = fName.split("_");
      if (xy.length < 2) {
        System.out.println("File " + from.getAbsolutePath()
            + " does not conform to x_y.nav file name convention");
        return -100;
      }
      // l2j's center is in x between region 19 (-32768) and 20 (+32768)
      // and in y between region 18 (+32768) and 17 (-32768)
     
      // minus 20*2048, 20 because region count starts with 0_0,
      // 2048 because one region consists of 8x8 tiles (each 256x256 long)
      int xd = (Integer.parseInt(xy[0]) * 256) - (20 * 2048);
      // minus 18*2048
      int yd = (Integer.parseInt(xy[1])) * 256 - (18 * 2048);
     
      // center is in top left corner for nav mesh to be consistent with
      // this for borders move x right, move y up by half size
      Vector3f offset = new Vector3f(xd + 128, 0, yd - 128);
     
      t.reset();   
      Mesh mesh = NavMeshGenerator.buildNavmesh(n);
      if(mesh != null) {
      TiledNavMesh navMesh = new TiledNavMesh();
      navMesh.loadFromMesh(mesh, offset, isMeshRelative);
      time = t.getTimeInSeconds();
      System.out.println("File " + from.getAbsolutePath()
          + " converted in " + time + " seconds");
      String path = from.getAbsolutePath();
      String parent = from.getParent();
      // replace .nav with .jnv
      t.reset();
      BinaryExporter.getInstance().save(navMesh,
          new File(parent+"/nav.jnv"));
      time = t.getTimeInSeconds();
//      System.out.println("File "+parent+"/nav.jnv saved in "
//          + time + " seconds");
//      t.reset();
//      writeMeshToObjFile(mesh,
//          new File(parent+"/nav.obj"));
View Full Code Here

Examples of com.jme3.system.NanoTimer

      if (fs.isDirectory())
        convert(fs);
  }

  public int convertNav(File from) throws Throwable {
    Timer t = new NanoTimer();
    float time = 0f;

    // new loader each time, yes
    try {
      t.reset();
      Spatial n = (Spatial) assetMan.loadModel(from.getAbsolutePath());
      if(n != null) {
        String fName = from.getName().substring(0,
            from.getName().length() - fileEnding.length());
        fName = from.getParent()+"/"+fName+".j3o";
        n.updateModelBound();
        n.updateGeometricState();
        BinaryExporter.getInstance().save(n,new File(fName));
        time = t.getTimeInSeconds();
        System.out.println("File "+fName+".saved in "+ time +" seconds");
      } else {
        System.out.println("Failed to load model "+from);
      }
View Full Code Here

Examples of com.jme3.system.NanoTimer

      if (fs.isDirectory())
        convert(fs);
  }

  public int convertNav(File from) throws Throwable {
    Timer t = new NanoTimer();
    float time = 0f;

    // new loader each time, yes
    try {
      Geometry g;
      // need to load vial loadModel, JME does not see obj, etc as
      // Assets..
      t.reset();
      Spatial n = (Spatial) assetMan.loadModel(from.getAbsolutePath());
      time = t.getTimeInSeconds();
      System.out.println("File " + from.getAbsolutePath() + " loaded in "
          + time + " seconds");
      if (n instanceof Geometry) {
        g = (Geometry) n;
        n = new Node(g.getName());
        ((Node)n).attachChild(g);
      } else if (n instanceof Node) {
        if (((Node) n).getChildren().size() > 1)
          throw new Throwable(
              "Mesh with more children detected than one on "
                  + from.getName());
        g = (Geometry) ((Node) n).getChild(0);
      } else
        throw new Throwable("Spatial loaded was unexpected type "
            + n.getClass());
      // jme fucked up the model names, and ignores any object name
      // entries so we fix a bit
      String fName = from.getName().substring(0,
          from.getName().length() - fileEnding.length());// without .nav
      g.setName(fName.toLowerCase());
      TiledNavMesh navMesh = new TiledNavMesh();

      {
      String[] xy = from.getParentFile().getName().split("_");
      // l2j's center is in x between region 19 (-32768) and 20 (+32768)
      // and in y between region 18 (+32768) and 17 (-32768)
     
      // minus 20*2048, 20 because region count starts with 0_0,
      // 2048 because one region consists of 8x8 tiles (each 256x256 long)
      int xd = (Integer.parseInt(xy[0]) * 256) - (20 * 2048);
      // minus 18*2048
      int yd = (Integer.parseInt(xy[1])) * 256 - (18 * 2048);
     
      // center is in top left corner for nav mesh to be consistent with
      // this for borders move x right, move y up by half size
      Vector3f offset = new Vector3f(xd + 128, 0, yd - 128);
      //System.out.println("Offset for "+from.getParentFile().getName()+"/nav2.obj should be at:"+offset);
      }
     
      navMesh.loadFromMesh(g.getMesh(), Vector3f.ZERO, isMeshRelative);
     
      time = t.getTimeInSeconds();
      System.out.println("File " + from.getAbsolutePath()
          + " converted in " + time + " seconds");
      String path = from.getAbsolutePath();
      String parent = from.getParent();
      // replace .nav with .jnv
      t.reset();
      BinaryExporter.getInstance().save(navMesh,
          new File(parent+"/nav.jnv"));
      time = t.getTimeInSeconds();
//      System.out.println("File "+parent+"/nav.jnv saved in "
//          + time + " seconds");
//      t.reset();
//      writeMeshToObjFile(mesh,
//          new File(parent+"/nav.obj"));
View Full Code Here

Examples of limelight.util.NanoTimer

  private final NanoTimer timer;
  private long lastExecutionDuration;

  public PanelPainterLoop()
  {
    timer = new NanoTimer();
    setUpdatesPerSecond(30);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.