Examples of Mesh


Examples of com.jme3.scene.Mesh

  /**
   * Packs all border cells into a renderable mesh
   * @return Geometry containing the boder cells
   */
  public Geometry getDebugBorderMesh(){
    Mesh m = new Mesh();
    m.setMode(Mode.Triangles);
    int size = 0;
    for(HashSet<com.l2client.navigation.Cell>  set : allBorders){
      size += set.size();
    }
    IntBuffer ib = BufferUtils.createIntBuffer(size*3*3);
    FloatBuffer vb = BufferUtils.createFloatBuffer(size*3*3);
        vb.rewind();
        int i=0;
        for(HashSet<com.l2client.navigation.Cell>  set : allBorders){
          for(Cell c : set){
            for(int v= 0;v<3;v++){
              vb.put(c.m_Vertex[v].x);
              vb.put(c.m_Vertex[v].y);
              vb.put(c.m_Vertex[v].z);
              ib.put(i++);
            }
          }
        }
        log.severe("Debug Borders for:"+this.toString());
        if(i <= 0){
          log.warning("Navmesh without any bordercells:"+this);
        }
    m.setBuffer(Type.Position, 3, vb);
    m.setBuffer(Type.Index, 3, ib);
    m.updateBound();
   
    Geometry g = new Geometry("Debug_NavBorderMesh_"+this.toString(),m);
    g.updateModelBound();
    return g;
  }
View Full Code Here

Examples of com.jme3.scene.Mesh

   
    l = new Line(new Vector3f(left.EndPointA().x, y, left.EndPointA().y),
          new Vector3f(left.EndPointB().x, y, left.EndPointB().y));
    geometries.add(new Geometry("left", l));

    Mesh m = new Mesh();
    GeometryBatchFactory.mergeGeometries(geometries, m);
    Geometry g = new Geometry("bounds of "+toString(), m);
    g.updateModelBound();
    return g;
View Full Code Here

Examples of com.jme3.scene.Mesh

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

Examples of com.jme3.scene.Mesh

        if (spatial == null) {
            return;
        }
        if (spatial instanceof Geometry) {
            Geometry geom = (Geometry) spatial;
            Mesh mesh = geom.getMesh();
            if (mesh instanceof Sphere) {
                collisionShape = new SphereCollisionShape(((Sphere) mesh).getRadius());
                return;
            } else if (mesh instanceof Box) {
                collisionShape = new BoxCollisionShape(new Vector3f(((Box) mesh).getXExtent(), ((Box) mesh).getYExtent(), ((Box) mesh).getZExtent()));
View Full Code Here

Examples of com.jme3.scene.Mesh

        geom.updateModelBound();
        return geom;
    }

    public static Mesh getDebugMesh(CollisionShape shape) {
        Mesh mesh = new Mesh();
        mesh = new Mesh();
        DebugMeshCallback callback = new DebugMeshCallback();
        getVertices(shape.getObjectId(), callback);
        mesh.setBuffer(Type.Position, 3, callback.getVertices());
        mesh.getFloatBuffer(Type.Position).clear();
        return mesh;
    }
View Full Code Here

Examples of com.jme3.scene.Mesh

    public Mesh createMesh(Vector3f scale, Vector2f tcScale, boolean center){
        FloatBuffer pb = writeVertexArray(null, scale, center);
        FloatBuffer tb = writeTexCoordArray(null, Vector2f.ZERO, tcScale);
        FloatBuffer nb = writeNormalArray(null, scale);
        IntBuffer ib = writeIndexArray(null);
        Mesh m = new Mesh();
        m.setBuffer(Type.Position, 3, pb);
        m.setBuffer(Type.Normal, 3, nb);
        m.setBuffer(Type.TexCoord, 2, tb);
        m.setBuffer(Type.Index, 3, ib);
        m.setStatic();
        m.updateBound();
        return m;
    }
View Full Code Here

Examples of com.jme3.scene.Mesh

            throw new IllegalArgumentException("LodControl can only be attached to Geometry!");
        }

        super.setSpatial(spatial);
        Geometry geom = (Geometry) spatial;
        Mesh mesh = geom.getMesh();
        numLevels = mesh.getNumLodLevels();
        numTris = new int[numLevels];
        for (int i = numLevels - 1; i >= 0; i--) {
            numTris[i] = mesh.getTriangleCount(i);
        }
    }
View Full Code Here

Examples of com.jme3.scene.Mesh

                        ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
                        Node curveObject = (Node) objectHelper.toObject(curveStructure, blenderContext);
                        Set<Number> referencesToCurveLengths = new HashSet<Number>(curveObject.getChildren().size());
                        for (Spatial spatial : curveObject.getChildren()) {
                            if (spatial instanceof Geometry) {
                                Mesh mesh = ((Geometry) spatial).getMesh();
                                if (mesh instanceof Curve) {
                                    length += ((Curve) mesh).getLength();
                                } else {
                                    // if bevel object has several parts then each mesh will have the same reference
                                    // to length value (and we should use only one)
View Full Code Here

Examples of com.jme3.scene.Mesh

        bbox.setYExtent(extent);
        bbox.setZExtent(extent);

        Triangle t = new Triangle();
        for (int g = 0; g < geoms.length; g++){
            Mesh m = geoms[g].getMesh();
            for (int i = 0; i < m.getTriangleCount(); i++){
                m.getTriangle(i, t);
                OCTTriangle ot = new OCTTriangle(t.get1(), t.get2(), t.get3(), i, g);
                allTris.add(ot);
                // convert triangle to world space
//                geom.getWorldTransform().transformVector(t.get1(), t.get1());
//                geom.getWorldTransform().transformVector(t.get2(), t.get2());
View Full Code Here

Examples of com.jme3.scene.Mesh

                        mirrorPlaneNormal.set(0, 0, 0).set(mirrorIndex, Math.signum(mirrorPlaneCenter.get(mirrorIndex)));
                    }

                    for (Spatial spatial : node.getChildren()) {
                        if (spatial instanceof Geometry) {
                            Mesh mesh = ((Geometry) spatial).getMesh();
                            Mesh clone = mesh.deepClone();

                            LOGGER.log(Level.FINEST, "Fetching buffers of cloned spatial: {0}", spatial.getName());
                            FloatBuffer position = mesh.getFloatBuffer(Type.Position);
                            FloatBuffer bindPosePosition = mesh.getFloatBuffer(Type.BindPosePosition);

                            FloatBuffer clonePosition = clone.getFloatBuffer(Type.Position);
                            FloatBuffer cloneBindPosePosition = clone.getFloatBuffer(Type.BindPosePosition);
                            FloatBuffer cloneNormals = clone.getFloatBuffer(Type.Normal);
                            FloatBuffer cloneBindPoseNormals = clone.getFloatBuffer(Type.BindPoseNormal);
                            Buffer cloneIndexes = clone.getBuffer(Type.Index).getData();

                            for (int i = 0; i < cloneIndexes.limit(); ++i) {
                                int index = cloneIndexes instanceof ShortBuffer ? ((ShortBuffer) cloneIndexes).get(i) : ((IntBuffer) cloneIndexes).get(i);
                                if (!modifiedIndexes.contains(index)) {
                                    modifiedIndexes.add(index);

                                    this.get(clonePosition, index, point);
                                    if (mirrorAtPoint0) {
                                        d = Math.abs(point.get(mirrorIndex));
                                        shiftVector.set(0, 0, 0).set(mirrorIndex, -point.get(mirrorIndex));
                                    } else {
                                        d = this.computeDistanceFromPlane(point, mirrorPlaneCenter, mirrorPlaneNormal);
                                        mirrorPlaneNormal.mult(d, shiftVector);
                                    }

                                    if (merge && d <= tolerance) {
                                        point.addLocal(shiftVector);

                                        this.set(index, point, clonePosition, cloneBindPosePosition, position, bindPosePosition);
                                        if (cloneNormals != null) {
                                            this.get(cloneNormals, index, normal);
                                            normal.set(mirrorIndex, 0);
                                            this.set(index, normal, cloneNormals, cloneBindPoseNormals);
                                        }
                                    } else {
                                        point.addLocal(shiftVector.multLocal(2));

                                        this.set(index, point, clonePosition, cloneBindPosePosition);
                                        if (cloneNormals != null) {
                                            this.get(cloneNormals, index, normal);
                                            normal.set(mirrorIndex, -normal.get(mirrorIndex));
                                            this.set(index, normal, cloneNormals, cloneBindPoseNormals);
                                        }
                                    }
                                }
                            }
                            modifiedIndexes.clear();

                            LOGGER.finer("Flipping index order.");
                            switch (mesh.getMode()) {
                                case Points:
                                    cloneIndexes.flip();
                                    break;
                                case Lines:
                                    for (int i = 0; i < cloneIndexes.limit(); i += 2) {
                                        if (cloneIndexes instanceof ShortBuffer) {
                                            short index = ((ShortBuffer) cloneIndexes).get(i + 1);
                                            ((ShortBuffer) cloneIndexes).put(i + 1, ((ShortBuffer) cloneIndexes).get(i));
                                            ((ShortBuffer) cloneIndexes).put(i, index);
                                        } else {
                                            int index = ((IntBuffer) cloneIndexes).get(i + 1);
                                            ((IntBuffer) cloneIndexes).put(i + 1, ((IntBuffer) cloneIndexes).get(i));
                                            ((IntBuffer) cloneIndexes).put(i, index);
                                        }
                                    }
                                    break;
                                case Triangles:
                                    for (int i = 0; i < cloneIndexes.limit(); i += 3) {
                                        if (cloneIndexes instanceof ShortBuffer) {
                                            short index = ((ShortBuffer) cloneIndexes).get(i + 2);
                                            ((ShortBuffer) cloneIndexes).put(i + 2, ((ShortBuffer) cloneIndexes).get(i + 1));
                                            ((ShortBuffer) cloneIndexes).put(i + 1, index);
                                        } else {
                                            int index = ((IntBuffer) cloneIndexes).get(i + 2);
                                            ((IntBuffer) cloneIndexes).put(i + 2, ((IntBuffer) cloneIndexes).get(i + 1));
                                            ((IntBuffer) cloneIndexes).put(i + 1, index);
                                        }
                                    }
                                    break;
                                default:
                                    throw new IllegalStateException("Invalid mesh mode: " + mesh.getMode());
                            }

                            if (mirrorU && clone.getBuffer(Type.TexCoord) != null) {
                                LOGGER.finer("Mirroring U coordinates.");
                                FloatBuffer cloneUVs = (FloatBuffer) clone.getBuffer(Type.TexCoord).getData();
                                for (int i = 0; i < cloneUVs.limit(); i += 2) {
                                    cloneUVs.put(i, 1.0f - cloneUVs.get(i));
                                }
                            }
                            if (mirrorV && clone.getBuffer(Type.TexCoord) != null) {
                                LOGGER.finer("Mirroring V coordinates.");
                                FloatBuffer cloneUVs = (FloatBuffer) clone.getBuffer(Type.TexCoord).getData();
                                for (int i = 1; i < cloneUVs.limit(); i += 2) {
                                    cloneUVs.put(i, 1.0f - cloneUVs.get(i));
                                }
                            }
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.