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


Java Mesh.getBuffers方法代码示例

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


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

示例1: getChildren

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
@FXThread
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {

    final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class);

    final Mesh element = getElement();
    final IntMap<VertexBuffer> buffers = element.getBuffers();
    buffers.forEach(entry -> result.add(FACTORY_REGISTRY.createFor(entry.getValue())));

    return result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:13,代码来源:MeshTreeNode.java

示例2: updateVertexArray

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public void updateVertexArray(Mesh mesh) {
    int id = mesh.getId();
    if (id == -1) {
        IntBuffer temp = intBuf1;
        ARBVertexArrayObject.glGenVertexArrays(temp);
        id = temp.get(0);
        mesh.setId(id);
    }

    if (context.boundVertexArray != id) {
        ARBVertexArrayObject.glBindVertexArray(id);
        context.boundVertexArray = id;
    }

    VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData);
    if (interleavedData != null && interleavedData.isUpdateNeeded()) {
        updateBufferData(interleavedData);
    }

    IntMap<VertexBuffer> buffers = mesh.getBuffers();
    for (Entry<VertexBuffer> entry : buffers) {
        VertexBuffer vb = entry.getValue();

        if (vb.getBufferType() == Type.InterleavedData
                || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
                || vb.getBufferType() == Type.Index) {
            continue;
        }

        if (vb.getStride() == 0) {
            // not interleaved
            setVertexAttrib(vb);
        } else {
            // interleaved
            setVertexAttrib(vb, interleavedData);
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:LwjglRenderer.java

示例3: preloadScene

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
/**
 * Preloads a scene for rendering.
 * <p>
 * After invocation of this method, the underlying
 * renderer would have uploaded any textures, shaders and meshes
 * used by the given scene to the video driver. 
 * Using this method is useful when wishing to avoid the initial pause
 * when rendering a scene for the first time. Note that it is not 
 * guaranteed that the underlying renderer will actually choose to upload
 * the data to the GPU so some pause is still to be expected.
 * 
 * @param scene The scene to preload
 */
public void preloadScene(Spatial scene) {
    if (scene instanceof Node) {
        // recurse for all children
        Node n = (Node) scene;
        List<Spatial> children = n.getChildren();
        for (int i = 0; i < children.size(); i++) {
            preloadScene(children.get(i));
        }
    } else if (scene instanceof Geometry) {
        // add to the render queue
        Geometry gm = (Geometry) scene;
        if (gm.getMaterial() == null) {
            throw new IllegalStateException("No material is set for Geometry: " + gm.getName());
        }

        gm.getMaterial().preload(this);
        Mesh mesh = gm.getMesh();
        if (mesh != null) {
            for (Entry<VertexBuffer> entry : mesh.getBuffers()) {
                VertexBuffer buf = entry.getValue();
                if (buf.getData() != null) {
                    renderer.updateBufferData(buf);
                }
            }
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:41,代码来源:RenderManager.java

示例4: optimize

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static void optimize(Mesh mesh, boolean toFixed){
        // update any data that need updating
        mesh.updateBound();
        mesh.updateCounts();

        // set all buffers into STATIC_DRAW mode
        mesh.setStatic();

        if (mesh.getBuffer(Type.Index) != null){
            // compress index buffer from UShort to UByte (if possible)
            FloatToFixed.compressIndexBuffer(mesh);

            // generate triangle strips stitched with degenerate tris
            generateStrips(mesh, false, false, 16, 0);
        }

        IntMap<VertexBuffer> bufs = mesh.getBuffers();
        for (Entry<VertexBuffer> entry : bufs){
            VertexBuffer vb = entry.getValue();
            if (vb == null || vb.getBufferType() == Type.Index)
                continue;

             if (vb.getFormat() == Format.Float){
                if (vb.getBufferType() == Type.Color){
                    // convert the color buffer to UByte
                    vb = FloatToFixed.convertToUByte(vb);
                    vb.setNormalized(true);
                }else if (toFixed){
                    // convert normals, positions, and texcoords
                    // to fixed-point (16.16)
                    vb = FloatToFixed.convertToFixed(vb);
//                    vb = FloatToFixed.convertToFloat(vb);
                }
                mesh.clearBuffer(vb.getBufferType());
                mesh.setBuffer(vb);
            }
        }
        mesh.setInterleaved();
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:40,代码来源:ModelConverter.java

示例5: renderMeshDefault

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private void renderMeshDefault(Mesh mesh, int lod, int count) {
    VertexBuffer indices = null;

    VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData);
    if (interleavedData != null && interleavedData.isUpdateNeeded()) {
        updateBufferData(interleavedData);
    }

    IntMap<VertexBuffer> buffers = mesh.getBuffers();
    if (mesh.getNumLodLevels() > 0) {
        indices = mesh.getLodLevel(lod);
    } else {
        indices = buffers.get(Type.Index.ordinal());
    }
    for (Entry<VertexBuffer> entry : buffers) {
        VertexBuffer vb = entry.getValue();

        if (vb.getBufferType() == Type.InterleavedData
                || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
                || vb.getBufferType() == Type.Index) {
            continue;
        }

        if (vb.getStride() == 0) {
            // not interleaved
            setVertexAttrib(vb);
        } else {
            // interleaved
            setVertexAttrib(vb, interleavedData);
        }
    }

    if (indices != null) {
        drawTriangleList(indices, mesh, count);
    } else {
        glDrawArrays(convertElementMode(mesh.getMode()), 0, mesh.getVertexCount());
    }
    
    // TODO: Fix these to use IDList??
    clearVertexAttribs();
    clearTextureUnits();
    clearSetFixedFuncBindings();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:44,代码来源:LwjglGL1Renderer.java

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


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