Package com.l2client.navigation

Examples of com.l2client.navigation.TiledNavMesh


     * @param name      name of the mesh
     * @param worldtrans  center position of quad
     * @return
     */
    private TiledNavMesh getNavMesh(String name, Vector3f worldtrans){
      TiledNavMesh m = new TiledNavMesh();
      m.loadFromData(new Vector3f[] {new Vector3f(0,0,IArea.TERRAIN_SIZE),
          new Vector3f(0,0,0),
          new Vector3f(IArea.TERRAIN_SIZE,0,0),
          new Vector3f(IArea.TERRAIN_SIZE,0,IArea.TERRAIN_SIZE)},
          new short[][] {{0,2,1},{0,3,2}}, worldtrans);
      return m;
View Full Code Here


      // 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();
View Full Code Here

      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();
View Full Code Here

    }
    @Override
    public void afterLoad(){
      if(baseAsset != null && baseAsset instanceof TiledNavMesh ){
        if(moveNonNavToOrigin){
          TiledNavMesh  n = (TiledNavMesh)baseAsset;
          // 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);
          //n.setPosition(new Vector3f(Tile.getWorldPositionOfXTile(x)+IArea.TERRAIN_SIZE_HALF, 0f,Tile.getWorldPositionOfZTile(z)-IArea.TERRAIN_SIZE_HALF));
          n.setPosition(new Vector3f(Tile.getWorldPositionOfXTile(x), 0f,Tile.getWorldPositionOfZTile(z)));
//          System.out.println(getLocation()+" Navmesh "+n+" moved to:"+n.getPosition());
          log.fine("Navmesh "+n+" moved to:"+n.getPosition());
        }
        Singleton.get().getNavManager().attachMesh((TiledNavMesh) baseAsset);
      }
      log.finer("NavAsset afterLoad of:"+this.name);
    }
View Full Code Here

      // 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();
View Full Code Here

public class NavLoadingTest extends TestCase {

  public void testSelf(){
   
    TiledNavMesh m = getNavMesh("0_0", Vector3f.ZERO);
    try {
      BinaryExporter.getInstance().save(m, new File("0_0.jnv"));
      m = (TiledNavMesh) BinaryImporter.getInstance().load(new File("0_0.jnv"));
      DesktopAssetManager assetManager = new DesktopAssetManager(true);
      Geometry g00 = (Geometry) assetManager.loadAsset("grid.0_0.j3o");
      assertNotNull("Asset for grid 0_0 is missing", g00);
      m = new TiledNavMesh();
     
      long eT = 0L;
          long sT =  System.currentTimeMillis();         
      m.loadFromGeom(g00);
      int cells = m.TotalCells();
      eT =System.currentTimeMillis();         
          System.out.println("Navmesh building from g00 took "+(eT-sT)+" milli seconds for "+cells+" cells");
          BinaryExporter.getInstance().save(m, new File("0_0.jnv"));
          sT = System.currentTimeMillis();
          m = (TiledNavMesh) BinaryImporter.getInstance().load(new File("0_0.jnv"));
View Full Code Here

      e.printStackTrace();
    }
  }
 
    private TiledNavMesh getNavMesh(String name, Vector3f worldtrans){
      TiledNavMesh m = new TiledNavMesh();
      m.loadFromData(new Vector3f[] {new Vector3f(-64,0,64),new Vector3f(-64,0,-64), new Vector3f(64,0,-64), new Vector3f(64,0,64)}, new short[][] {{0,2,1},{0,3,2}}, worldtrans);
      return m;
    }
View Full Code Here

TOP

Related Classes of com.l2client.navigation.TiledNavMesh

Copyright © 2018 www.massapicom. 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.