当前位置: 首页>>代码示例>>Java>>正文


Java Mesh.getTriangleCount方法代码示例

本文整理汇总了Java中com.jme3.scene.Mesh.getTriangleCount方法的典型用法代码示例。如果您正苦于以下问题:Java Mesh.getTriangleCount方法的具体用法?Java Mesh.getTriangleCount怎么用?Java Mesh.getTriangleCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.scene.Mesh的用法示例。


在下文中一共展示了Mesh.getTriangleCount方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setSpatial

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
public void setSpatial(Spatial spatial) {
    if (!(spatial instanceof Geometry)) {
        throw new IllegalArgumentException("LodControl can only be attached to Geometry!");
    }

    super.setSpatial(spatial);
    Geometry geom = (Geometry) spatial;
    Mesh mesh = geom.getMesh();
    numLevels = mesh.getNumLodLevels();
    
    for (int i = 0; i < numLevels; i++)
    	if (mesh.getLodLevel( i ) == null)
    		numLevels--;
    
    numTris = new int[numLevels];
    for (int i = numLevels - 1; i >= 0; i--) {
        numTris[i] = mesh.getTriangleCount(i);
    }
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:21,代码来源:GISLodControl.java

示例2: updateItem

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
protected void updateItem(@Nullable final Integer level, final boolean empty) {
    super.updateItem(level, empty);

    final Geometry geometry = getEditObject();
    final Mesh mesh = geometry.getMesh();

    if (level == null || mesh == null) {
        setText("None");
        return;
    }

    int elements;

    if (level < mesh.getNumLodLevels()) {
        final VertexBuffer lodLevel = mesh.getLodLevel(level);
        elements = lodLevel.getNumElements();
    } else {
        elements = mesh.getTriangleCount();
    }

    setText(Messages.MODEL_PROPERTY_LEVEL + ": " + level + " (" + elements + " " +
            Messages.MODEL_PROPERTY_TRIANGLE_COUNT + ")");
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:25,代码来源:LodLevelPropertyControl.java

示例3: WrappedIndexBuffer

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public WrappedIndexBuffer(Mesh mesh){
    super(mesh.getVertexCount(), mesh.getMode());
    this.ib = mesh.getIndexBuffer();
    switch (meshMode){
        case Points:
            numIndices = mesh.getTriangleCount();
            break;
        case Lines:
        case LineLoop:
        case LineStrip:
            numIndices = mesh.getTriangleCount() * 2;
            break;
        case Triangles:
        case TriangleStrip:
        case TriangleFan:
            numIndices = mesh.getTriangleCount() * 3;
            break;
        default:
            throw new UnsupportedOperationException();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:WrappedIndexBuffer.java

示例4: setMeshes

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
public void setMeshes(List<Mesh> meshes) {
    this.vertices = new ArrayList<List<Vector3f>>(meshes.size());
    this.normals = new ArrayList<List<Vector3f>>(meshes.size());
    for (Mesh mesh : meshes) {
        Vector3f[] vertexTable = BufferUtils.getVector3Array(mesh.getFloatBuffer(Type.Position));
        int[] indices = new int[3];
        List<Vector3f> vertices = new ArrayList<Vector3f>(mesh.getTriangleCount() * 3);
        List<Vector3f> normals = new ArrayList<Vector3f>(mesh.getTriangleCount());
        for (int i = 0; i < mesh.getTriangleCount(); ++i) {
            mesh.getTriangle(i, indices);
            vertices.add(vertexTable[indices[0]]);
            vertices.add(vertexTable[indices[1]]);
            vertices.add(vertexTable[indices[2]]);
            normals.add(FastMath.computeNormal(vertexTable[indices[0]], vertexTable[indices[1]], vertexTable[indices[2]]));
        }
        this.vertices.add(vertices);
        this.normals.add(normals);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:EmitterMeshFaceShape.java

示例5: setSpatial

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
public void setSpatial(Spatial spatial){
    if (!(spatial instanceof Geometry))
        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);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:LodControl.java

示例6: convert

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static IndexedMesh convert(Mesh mesh) {
    IndexedMesh jBulletIndexedMesh = new IndexedMesh();
    jBulletIndexedMesh.triangleIndexBase = ByteBuffer.allocate(mesh.getTriangleCount() * 3 * 4);
    jBulletIndexedMesh.vertexBase = ByteBuffer.allocate(mesh.getVertexCount() * 3 * 4);

    IndexBuffer indices = mesh.getIndicesAsList();
    
    FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
    vertices.rewind();

    int verticesLength = mesh.getVertexCount() * 3;
    jBulletIndexedMesh.numVertices = mesh.getVertexCount();
    jBulletIndexedMesh.vertexStride = 12; //3 verts * 4 bytes per.
    for (int i = 0; i < verticesLength; i++) {
        float tempFloat = vertices.get();
        jBulletIndexedMesh.vertexBase.putFloat(tempFloat);
    }

    int indicesLength = mesh.getTriangleCount() * 3;
    jBulletIndexedMesh.numTriangles = mesh.getTriangleCount();
    jBulletIndexedMesh.triangleIndexStride = 12; //3 index entries * 4 bytes each.
    for (int i = 0; i < indicesLength; i++) {
        jBulletIndexedMesh.triangleIndexBase.putInt(indices.get(i));
    }
    vertices.rewind();
    vertices.clear();

    return jBulletIndexedMesh;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:Converter.java

示例7: Octree

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public Octree(Spatial scene, int minTrisPerNode){
        scene.updateGeometricState();

        List<Geometry> geomsList = getGeometries(scene);
        geoms = new Geometry[geomsList.size()];
        geomsList.toArray(geoms);
        // generate bound box for all geom
        bbox = new BoundingBox();
        for (Geometry geom : geoms){
            BoundingVolume bv = geom.getWorldBound();
            bbox.mergeLocal(bv);
        }

        // set largest extent
        float extent = Math.max(bbox.getXExtent(), Math.max(bbox.getYExtent(), bbox.getZExtent()));
        bbox.setXExtent(extent);
        bbox.setYExtent(extent);
        bbox.setZExtent(extent);

        this.minTrisPerNode = minTrisPerNode;

        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());
//                geom.getWorldTransform().transformVector(t.get3(), t.get3());
            }
        }
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:36,代码来源:Octree.java

示例8: buildForImpl

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
@FXThread
protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, @NotNull final VBox container,
                            @NotNull final ModelChangeConsumer changeConsumer) {

    if (!(object instanceof Mesh)) return;

    final Mesh mesh = (Mesh) object;
    final Mesh.Mode mode = mesh.getMode();

    final int id = mesh.getId();
    final int instanceCount = mesh.getInstanceCount();
    final int vertexCount = mesh.getVertexCount();
    final int numLodLevels = mesh.getNumLodLevels();
    final int triangleCount = mesh.getTriangleCount();

    final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> idControl =
            new DefaultSinglePropertyControl<>(id, Messages.MODEL_PROPERTY_ID, changeConsumer);

    idControl.setSyncHandler(Mesh::getId);
    idControl.setToStringFunction(value -> Integer.toString(value));
    idControl.setEditObject(mesh);

    final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> instanceCountControl =
            new DefaultSinglePropertyControl<>(instanceCount, Messages.MODEL_PROPERTY_INSTANCE_COUNT, changeConsumer);

    instanceCountControl.setSyncHandler(Mesh::getInstanceCount);
    instanceCountControl.setToStringFunction(value -> Integer.toString(value));
    instanceCountControl.setEditObject(mesh);

    final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> vertexCountControl =
            new DefaultSinglePropertyControl<>(vertexCount, Messages.MODEL_PROPERTY_VERTEX_COUNT, changeConsumer);

    vertexCountControl.setSyncHandler(Mesh::getVertexCount);
    vertexCountControl.setToStringFunction(value -> Integer.toString(value));
    vertexCountControl.setEditObject(mesh);

    final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> triangleCountControl =
            new DefaultSinglePropertyControl<>(triangleCount, Messages.MODEL_PROPERTY_TRIANGLE_COUNT, changeConsumer);

    triangleCountControl.setSyncHandler(Mesh::getTriangleCount);
    triangleCountControl.setToStringFunction(value -> Integer.toString(value));
    triangleCountControl.setEditObject(mesh);

    final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> numLodLevelsControl =
            new DefaultSinglePropertyControl<>(numLodLevels, Messages.MODEL_PROPERTY_NUM_LOD_LEVELS, changeConsumer);

    numLodLevelsControl.setSyncHandler(Mesh::getNumLodLevels);
    numLodLevelsControl.setToStringFunction(value -> Integer.toString(value));
    numLodLevelsControl.setEditObject(mesh);

    final EnumPropertyControl<ModelChangeConsumer, Mesh, Mesh.Mode> modeControl =
            new EnumPropertyControl<>(mode, Messages.MODEL_PROPERTY_MODE, changeConsumer, MODES);
    modeControl.setApplyHandler(Mesh::setMode);
    modeControl.setSyncHandler(Mesh::getMode);
    modeControl.setEditObject(mesh);

    FXUtils.addToPane(idControl, container);
    FXUtils.addToPane(instanceCountControl, container);
    FXUtils.addToPane(vertexCountControl, container);
    FXUtils.addToPane(triangleCountControl, container);
    FXUtils.addToPane(numLodLevelsControl, container);
    FXUtils.addToPane(modeControl, container);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:65,代码来源:MeshPropertyBuilder.java

示例9: onMeshDrawn

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
/**
 * Called by the Renderer when a mesh has been drawn.
 * 
 */
public void onMeshDrawn(Mesh mesh, int lod){
    numObjects ++;
    numTriangles += mesh.getTriangleCount(lod);
    numVertices += mesh.getVertexCount();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:Statistics.java


注:本文中的com.jme3.scene.Mesh.getTriangleCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。