Package com.jme3.scene

Examples of com.jme3.scene.Geometry


        ret = new PatchInfo(x, y, false);//FIXME how can this happen?
    }
    try {
      Quad q = new Quad(1f * IArea.TERRAIN_SIZE, 1f * IArea.TERRAIN_SIZE);
      //this is the same as in GotoClickedInputAction
      Geometry n = new Geometry(IArea.TILE_PREFIX + x + " " + y,q);
      n.setMaterial(material);
      n.setLocalTranslation(x * IArea.TERRAIN_SIZE, 0f,y * IArea.TERRAIN_SIZE);
      ret.patch = n;
      n.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    } catch (Exception e) {
      //TODO use logger & error handling on failed load of a tile (in which case is this ok?)
      e.printStackTrace();
    }

View Full Code Here


        Node node = new Node("NavBorderMeshes");
        Material mat = matWireframe.clone();
            mat.setColor("Color", ColorRGBA.Blue);
        TiledNavMesh[] array = Singleton.get().getNavManager().getNavMeshes();
        for(TiledNavMesh t : array){
          Geometry g = t.getDebugBorderMesh();
          g.setMaterial(mat);
          node.attachChild(g);
        }
        navs.attachChild(node);
      }
    }
View Full Code Here

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

    try {
      Savable load = BinaryImporter.getInstance().load(selectedFile);
     
      if(load instanceof Geometry)
      {
        Geometry m = (Geometry) load;
        assembler.addMesh(m.getName(),m, true);
        meshModel.addElement(m.getName());
        updateJME();
      } else {
        JOptionPane.showMessageDialog(null, "The jme file is not an OgreMesh but a "+(load != null?load.getClass().getSimpleName():"Null file"),"Error",JOptionPane.ERROR_MESSAGE);
      }
    } catch (Exception e) {
View Full Code Here

      CollisionResults results = new CollisionResults();

      sin.getSceneManager().getRoot().collideWith(ray, results);

      if (results.size() > 0) {
        Geometry geom = null;
        for (CollisionResult res : results) {
          geom = res.getGeometry();
          if (geom != null) {
            log.fine("picked " + geom.getName());
            Integer id = geom.getUserData(Entity.ENTITY_ID);
            if (id != null) {
              //Just create a target component rest is done in the jmeupdatesystem
              Node n = res.getGeometry().getParent();
              String na = n.getName();
              log.fine("picked " + na + " id:"+ id);
View Full Code Here

          throw new Throwable("Mesh with more children detected than one on "+name.getName());
       
        Spatial s = n.getChild(0);
        String mat = "default";
        if(s instanceof Geometry) {
          Geometry g = ((Geometry)s);
          g.setName(fName);
          g.updateModelBound();
          mat = g.getMaterial().getName();
          //remove material, we don't want jme to store different materials being all the same on load, so we remove it here
          g.setMaterial(null);
        }
       
          BinaryExporter.getInstance().save(s,
              new File(path + File.separatorChar + file.getName()+ File.separatorChar + fName+ ".j3o"));
          appendMegaSet(new String[] {"entity",file.getName(),"mesh",truncateEndNumbers(fName),mat,"meshes/"+file.getName()+"/"+fName + ".j3o"});
View Full Code Here

        return null;
  }
 
  public static void debugShowCell(AssetManager assetMan, com.jme3.scene.Node root, Cell c,
      ColorRGBA color, boolean doLinkVis) {
    Geometry geom = getLine(c.m_Vertex[0], c.m_Vertex[1])
    Material mat = new Material(assetMan, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", color);
    geom.setMaterial(mat);
    root.attachChild(geom);   
    geom = getLine(c.m_Vertex[1], c.m_Vertex[2]);
    geom.setMaterial(mat);
    root.attachChild(geom);
    geom = getLine(c.m_Vertex[2], c.m_Vertex[0]);
    geom.setMaterial(mat);
    root.attachChild(geom);
    if(doLinkVis){
    if(c.m_Link[0] != null){
    geom = getLine(c.m_WallMidpoint[0],c.m_Link[0].m_CenterPoint, 0.5f);
    mat = new Material(assetMan, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    geom.setMaterial(mat);
    root.attachChild(geom);
    }
    if(c.m_Link[1] != null){
    geom = getLine(c.m_WallMidpoint[1],c.m_Link[1].m_CenterPoint, 0.5f);
    mat = new Material(assetMan, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Red);
    geom.setMaterial(mat);
    root.attachChild(geom);
    }
    if(c.m_Link[2] != null){
    geom = getLine(c.m_WallMidpoint[2],c.m_Link[2].m_CenterPoint, 0.5f);
    mat = new Material(assetMan, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Green);
    geom.setMaterial(mat);
    root.attachChild(geom);
    }}
  }
View Full Code Here

    }}
  }
 
  public static void debugShowBox(AssetManager assetMan, com.jme3.scene.Node root, Vector3f position, ColorRGBA color, float x, float y, float z) {
    Box b = new Box(position, x, y, z);
    Geometry geom = new Geometry("Box", b);
    Material mat = new Material(assetMan, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", color);
    geom.setMaterial(mat);
    root.attachChild(geom);
  }
View Full Code Here

 
  private static void debugShowLine(AssetManager assetMan, com.jme3.scene.Node root, Vector3f start, Vector3f end,
      ColorRGBA color) {
    Line b = new Line(start.add(0f, 1f, 0f), end.add(0f,1f,0f));//, 0.1f, 0.4f, 0.1f);
    b.setLineWidth(2f);
    Geometry geom = new Geometry("Box", b);
    Material mat = new Material(assetMan, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", color);
    geom.setMaterial(mat);
    root.attachChild(geom);   
  }
View Full Code Here

  public static void debugShowMesh(AssetManager assetMan, com.jme3.scene.Node root, TiledNavMesh mesh) {
    int cnt = mesh.mCellArray.length;
    Material mat = new Material(assetMan, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.White);
    Cell c = null;
    Geometry geom = null;
    for(int i=0; i<cnt;i++){
     
//      if(i>2)
//        return;
      c = mesh.mCellArray[i];
View Full Code Here

TOP

Related Classes of com.jme3.scene.Geometry

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.