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


Java Mesh.getVertexCount方法代码示例

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


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

示例1: BIHTree

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public BIHTree(Mesh mesh, int maxTrisPerNode) {
    this.mesh = mesh;
    this.maxTrisPerNode = maxTrisPerNode;

    if (maxTrisPerNode < 1 || mesh == null) {
        throw new IllegalArgumentException();
    }

    bihSwapTmp = new float[9];

    FloatBuffer vb = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
    IndexBuffer ib = mesh.getIndexBuffer();
    if (ib == null) {
        ib = new VirtualIndexBuffer(mesh.getVertexCount(), mesh.getMode());
    } else if (mesh.getMode() != Mode.Triangles) {
        ib = new WrappedIndexBuffer(mesh);
    }

    numTris = ib.size() / 3;
    initTriList(vb, ib);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:BIHTree.java

示例2: renderMesh

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public void renderMesh(Mesh mesh, int lod, int count) {
        if (mesh.getVertexCount() == 0) {
            return;
        }
        if (context.pointSize != mesh.getPointSize()) {
            glPointSize(mesh.getPointSize());
            context.pointSize = mesh.getPointSize();
        }
        if (context.lineWidth != mesh.getLineWidth()) {
            glLineWidth(mesh.getLineWidth());
            context.lineWidth = mesh.getLineWidth();
        }

        statistics.onMeshDrawn(mesh, lod);
//        if (GLContext.getCapabilities().GL_ARB_vertex_array_object){
//            renderMeshVertexArray(mesh, lod, count);
//        }else{
            renderMeshDefault(mesh, lod, count);
//        }
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:LwjglRenderer.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: getPoints

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
protected float[] getPoints(Mesh mesh) {
    FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
    vertices.rewind();
    int components = mesh.getVertexCount() * 3;
    float[] pointsArray = new float[components];
    for (int i = 0; i < components; i += 3) {
        pointsArray[i] = vertices.get();
        pointsArray[i + 1] = vertices.get();
        pointsArray[i + 2] = vertices.get();
    }
    return pointsArray;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:HullCollisionShape.java

示例5: buildPointMapForMesh

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private static Map<Integer, List<Float>> buildPointMapForMesh(Mesh mesh, Map<Integer, List<Float>> map) {

        FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
        ByteBuffer boneIndices = (ByteBuffer) mesh.getBuffer(Type.BoneIndex).getData();
        FloatBuffer boneWeight = (FloatBuffer) mesh.getBuffer(Type.BoneWeight).getData();

        vertices.rewind();
        boneIndices.rewind();
        boneWeight.rewind();

        int vertexComponents = mesh.getVertexCount() * 3;
        int k, start, index;
        float maxWeight = 0;

        for (int i = 0; i < vertexComponents; i += 3) {


            start = i / 3 * 4;
            index = 0;
            maxWeight = -1;
            for (k = start; k < start + 4; k++) {
                float weight = boneWeight.get(k);
                if (weight > maxWeight) {
                    maxWeight = weight;
                    index = boneIndices.get(k);
                }
            }
            List<Float> points = map.get(index);
            if (points == null) {
                points = new ArrayList<Float>();
                map.put(index, points);
            }
            points.add(vertices.get(i));
            points.add(vertices.get(i + 1));
            points.add(vertices.get(i + 2));
        }
        return map;
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:RagdollUtils.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: compressIndexBuffer

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static void compressIndexBuffer(Mesh mesh){
    int vertCount = mesh.getVertexCount();
    VertexBuffer vb = mesh.getBuffer(Type.Index);
    Format targetFmt;
    if (vb.getFormat() == Format.UnsignedInt && vertCount <= 0xffff){
        if (vertCount <= 256)
            targetFmt = Format.UnsignedByte;
        else
            targetFmt = Format.UnsignedShort;
    }else if (vb.getFormat() == Format.UnsignedShort && vertCount <= 0xff){
        targetFmt = Format.UnsignedByte;
    }else{
        return;
    }

    IndexBuffer src = mesh.getIndexBuffer();
    Buffer newBuf = VertexBuffer.createBuffer(targetFmt, vb.getNumComponents(), src.size());

    VertexBuffer newVb = new VertexBuffer(Type.Index);
    newVb.setupData(vb.getUsage(), vb.getNumComponents(), targetFmt, newBuf);
    mesh.clearBuffer(Type.Index);
    mesh.setBuffer(newVb);

    IndexBuffer dst = mesh.getIndexBuffer();
    for (int i = 0; i < src.size(); i++){
        dst.put(i, src.get(i));
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:FloatToFixed.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: renderMesh

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public void renderMesh(Mesh mesh, int lod, int count) {
        if (mesh.getVertexCount() == 0) {
            return;
        }

        if (context.pointSize != mesh.getPointSize()) {
            glPointSize(mesh.getPointSize());
            context.pointSize = mesh.getPointSize();
        }
        if (context.lineWidth != mesh.getLineWidth()) {
            glLineWidth(mesh.getLineWidth());
            context.lineWidth = mesh.getLineWidth();
        }

        boolean dynamic = false;
        if (mesh.getBuffer(Type.InterleavedData) != null) {
            throw new UnsupportedOperationException("Interleaved meshes are not supported");
        }

        if (mesh.getNumLodLevels() == 0) {
            IntMap<VertexBuffer> bufs = mesh.getBuffers();
            for (Entry<VertexBuffer> entry : bufs) {
                if (entry.getValue().getUsage() != VertexBuffer.Usage.Static) {
                    dynamic = true;
                    break;
                }
            }
        } else {
            dynamic = true;
        }

        statistics.onMeshDrawn(mesh, lod);

//        if (!dynamic) {
        // dealing with a static object, generate display list
//            renderMeshDisplayList(mesh);
//        } else {
        renderMeshDefault(mesh, lod, count);
//        }


    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:43,代码来源:LwjglGL1Renderer.java

示例10: 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

示例11: getPoints

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
/**
 * returns a list of points for the given bone
 * @param mesh
 * @param boneIndex
 * @param offset
 * @param link
 * @return 
 */
private static List<Float> getPoints(Mesh mesh, int boneIndex, Vector3f initialScale, Vector3f offset, float weightThreshold) {

    FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);
    ByteBuffer boneIndices = (ByteBuffer) mesh.getBuffer(Type.BoneIndex).getData();
    FloatBuffer boneWeight = (FloatBuffer) mesh.getBuffer(Type.BoneWeight).getData();

    vertices.rewind();
    boneIndices.rewind();
    boneWeight.rewind();

    ArrayList<Float> results = new ArrayList<Float>();

    int vertexComponents = mesh.getVertexCount() * 3;

    for (int i = 0; i < vertexComponents; i += 3) {
        int k;
        boolean add = false;
        int start = i / 3 * 4;
        for (k = start; k < start + 4; k++) {
            if (boneIndices.get(k) == boneIndex && boneWeight.get(k) >= weightThreshold) {
                add = true;
                break;
            }
        }
        if (add) {

            Vector3f pos = new Vector3f();
            pos.x = vertices.get(i);
            pos.y = vertices.get(i + 1);
            pos.z = vertices.get(i + 2);
            pos.subtractLocal(offset).multLocal(initialScale);
            results.add(pos.x);
            results.add(pos.y);
            results.add(pos.z);

        }
    }

    return results;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:49,代码来源:RagdollUtils.java


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