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


Java VertexBuffer.setupData方法代码示例

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


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

示例1: startFaces

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
private void startFaces(String count) throws SAXException {
    int numFaces = parseInt(count);
    int numIndices;

    if (mesh.getMode() == Mesh.Mode.Triangles) {
        numIndices = numFaces * 3;
    } else {
        throw new SAXException("Triangle strip or fan not supported!");
    }

    vb = new VertexBuffer(VertexBuffer.Type.Index);
    if (!usesBigIndices) {
        sb = BufferUtils.createShortBuffer(numIndices);
        ib = null;
        vb.setupData(Usage.Static, 3, Format.UnsignedShort, sb);
    } else {
        ib = BufferUtils.createIntBuffer(numIndices);
        sb = null;
        vb.setupData(Usage.Static, 3, Format.UnsignedInt, ib);
    }
    mesh.setBuffer(vb);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:MeshLoader.java

示例2: startLodFaceList

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
private void startLodFaceList(String submeshindex, String numfaces) {
    int index = Integer.parseInt(submeshindex);
    int faceCount = Integer.parseInt(numfaces);

    vb = new VertexBuffer(VertexBuffer.Type.Index);
    sb = BufferUtils.createShortBuffer(faceCount * 3);
    ib = null;
    vb.setupData(Usage.Static, 3, Format.UnsignedShort, sb);

    List<VertexBuffer> levels = lodLevels.get(index);
    if (levels == null) {
        levels = new ArrayList<VertexBuffer>();
        Mesh submesh = geoms.get(index).getMesh();
        levels.add(submesh.getBuffer(Type.Index));
        lodLevels.put(index, levels);
    }

    levels.add(vb);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:MeshLoader.java

示例3: RenderDeviceJme

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public RenderDeviceJme(NiftyJmeDisplay display) {
    this.display = display;
    
    quadColor = new VertexBuffer(Type.Color);
    quadColor.setNormalized(true);
    ByteBuffer bb = BufferUtils.createByteBuffer(4 * 4);
    quadColor.setupData(Usage.Stream, 4, Format.UnsignedByte, bb);
    quad.setBuffer(quadColor);
    
    quadModTC.setUsage(Usage.Stream);
    
    niftyMat = new Material(display.getAssetManager(), "Common/MatDefs/Nifty/NiftyTex.j3md");
    niftyMat.getAdditionalRenderState().setDepthTest(false);
    niftyQuadMat = new Material(display.getAssetManager(), "Common/MatDefs/Nifty/NiftyQuad.j3md");
    niftyQuadMat.getAdditionalRenderState().setDepthTest(false);
}
 
开发者ID:AMPBEdu,项目名称:gjOryx,代码行数:17,代码来源:RenderDeviceJme.java

示例4: SkeletonPoints

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public SkeletonPoints(Skeleton skeleton){
    this.skeleton = skeleton;

    setMode(Mode.Points);

    VertexBuffer pb = new VertexBuffer(Type.Position);
    FloatBuffer fpb = BufferUtils.createFloatBuffer(skeleton.getBoneCount() * 3);
    pb.setupData(Usage.Stream, 3, Format.Float, fpb);
    setBuffer(pb);

    setPointSize(7);

    updateCounts();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:SkeletonPoints.java

示例5: startBoneAssigns

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
private void startBoneAssigns() {
    if (mesh != sharedMesh && usesSharedVerts) {
        // will use bone assignments from shared mesh (?)
        return;
    }

    // current mesh will have bone assigns
    //int vertCount = mesh.getVertexCount();
    // each vertex has
    // - 4 bone weights
    // - 4 bone indices
    if (HARDWARE_SKINNING) {
        weightsFloatData = BufferUtils.createFloatBuffer(vertCount * 4);
        indicesData = BufferUtils.createByteBuffer(vertCount * 4);
    } else {
        // create array-backed buffers if software skinning for access speed
        weightsFloatData = FloatBuffer.allocate(vertCount * 4);
        indicesData = ByteBuffer.allocate(vertCount * 4);
    }
    
    VertexBuffer weights = new VertexBuffer(Type.BoneWeight);
    VertexBuffer indices = new VertexBuffer(Type.BoneIndex);

    Usage usage = HARDWARE_SKINNING ? Usage.Static : Usage.CpuOnly;
    weights.setupData(usage, 4, Format.Float, weightsFloatData);
    indices.setupData(usage, 4, Format.UnsignedByte, indicesData);

    mesh.setBuffer(weights);
    mesh.setBuffer(indices);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:MeshLoader.java

示例6: RenderDeviceJme

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public RenderDeviceJme(NiftyJmeDisplay display){
    this.display = display;

    quadColor = new VertexBuffer(Type.Color);
    quadColor.setNormalized(true);
    ByteBuffer bb = BufferUtils.createByteBuffer(4 * 4);
    quadColor.setupData(Usage.Stream, 4, Format.UnsignedByte, bb);
    quad.setBuffer(quadColor);

    quadModTC.setUsage(Usage.Stream);

    niftyMat = new Material(display.getAssetManager(), "Common/MatDefs/Nifty/Nifty.j3md");
    niftyMat.getAdditionalRenderState().setDepthTest(false);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:RenderDeviceJme.java

示例7: initParticleData

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
@Override
public void initParticleData(ParticleEmitter emitter, int numParticles) {
    setMode(Mode.Points);

    this.emitter = emitter;

    // set positions
    FloatBuffer pb = BufferUtils.createVector3Buffer(numParticles);
    VertexBuffer pvb = new VertexBuffer(VertexBuffer.Type.Position);
    pvb.setupData(Usage.Stream, 3, Format.Float, pb);
    setBuffer(pvb);

    // set colors
    ByteBuffer cb = BufferUtils.createByteBuffer(numParticles * 4);
    VertexBuffer cvb = new VertexBuffer(VertexBuffer.Type.Color);
    cvb.setupData(Usage.Stream, 4, Format.UnsignedByte, cb);
    cvb.setNormalized(true);
    setBuffer(cvb);

    // set sizes
    FloatBuffer sb = BufferUtils.createFloatBuffer(numParticles);
    VertexBuffer svb = new VertexBuffer(VertexBuffer.Type.Size);
    svb.setupData(Usage.Stream, 1, Format.Float, sb);
    setBuffer(svb);

    // set UV-scale
    FloatBuffer tb = BufferUtils.createFloatBuffer(numParticles*4);
    VertexBuffer tvb = new VertexBuffer(VertexBuffer.Type.TexCoord);
    tvb.setupData(Usage.Stream, 4, Format.Float, tb);
    setBuffer(tvb);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:32,代码来源:ParticlePointMesh.java

示例8: compressIndexBuffer

import com.jme3.scene.VertexBuffer; //导入方法依赖的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

示例9: convertToUByte

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public static VertexBuffer convertToUByte(VertexBuffer vb){
    FloatBuffer fb = (FloatBuffer) vb.getData();
    ByteBuffer bb = BufferUtils.createByteBuffer(fb.capacity());
    convertToUByte(fb, bb);

    VertexBuffer newVb = new VertexBuffer(vb.getBufferType());
    newVb.setupData(vb.getUsage(),
                    vb.getNumComponents(),
                    Format.UnsignedByte,
                    bb);
    newVb.setNormalized(true);
    return newVb;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:FloatToFixed.java

示例10: convertToFixed

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public static VertexBuffer convertToFixed(VertexBuffer vb){
    if (vb.getFormat() == Format.Int)
        return vb;

    FloatBuffer fb = (FloatBuffer) vb.getData();
    IntBuffer ib = BufferUtils.createIntBuffer(fb.capacity());
    convertToFixed(fb, ib);

    VertexBuffer newVb = new VertexBuffer(vb.getBufferType());
    newVb.setupData(vb.getUsage(),
                    vb.getNumComponents(),
                    Format.Int,
                    ib);
    return newVb;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:FloatToFixed.java

示例11: convertToFloat

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public static VertexBuffer convertToFloat(VertexBuffer vb){
    if (vb.getFormat() == Format.Float)
        return vb;

    IntBuffer ib = (IntBuffer) vb.getData();
    FloatBuffer fb = BufferUtils.createFloatBuffer(ib.capacity());
    convertToFloat(ib, fb);

    VertexBuffer newVb = new VertexBuffer(vb.getBufferType());
    newVb.setupData(vb.getUsage(),
                    vb.getNumComponents(),
                    Format.Float,
                    fb);
    return newVb;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:FloatToFixed.java

示例12: init

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
private void init(TransferFunctionEditor tfe, Node node) {
	this.tfe = tfe;
	buffer = new VertexBuffer(VertexBuffer.Type.Position);
	buffer.setupData(VertexBuffer.Usage.Dynamic, 4, VertexBuffer.Format.Float, BufferUtils.createFloatBuffer(4 * points.size()));

	this.node = new Node(name);
	node.attachChild(this.node);
	
	Mesh mesh1 = new Mesh();
	mesh1.setMode(Mesh.Mode.LineStrip);
	mesh1.setBuffer(buffer);
	Material mat1 = new Material(tfe.app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
	mat1.setColor("Color", color);
	mat1.getAdditionalRenderState().setLineWidth(LINE_WIDTHS[0]);
	Geometry geom1 = new Geometry(name, mesh1);
	geom1.setMaterial(mat1);
	geom1.setLocalScale(1, Y_SIZE, 1);
	this.node.attachChild(geom1);
	meshes[0] = mesh1;
	geoms[0] = geom1;
	
	Mesh mesh2 = new Mesh();
	mesh2.setMode(Mesh.Mode.Points);
	mesh2.setBuffer(buffer);
	Material mat2 = new Material(tfe.app.getAssetManager(), "org/shaman/jmecl/utils/UnshadedPoint.j3md");
	mat2.getAdditionalRenderState().setPointSprite(true);
	mat2.setColor("Color", color);
	Geometry geom2 = new Geometry(name+"_p", mesh2);
	geom2.setMaterial(mat2);
	geom2.setLocalScale(1, Y_SIZE, 1);
	this.node.attachChild(geom2);
	meshes[1] = mesh2;
	geoms[1] = geom2;
}
 
开发者ID:shamanDevel,项目名称:jME3-OpenCL-Library,代码行数:35,代码来源:TransferFunctionEditor.java

示例13: createSkinCommonVertData

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
void createSkinCommonVertData() {
        SkinMeshData smd = meshConverter.getSkinMeshData();
        skinvb = new VertexBuffer(VertexBuffer.Type.Position);
        FloatBuffer skinvfb = smd.skinvfb;
        skinvb.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb);

        skinvb2 = new VertexBuffer(VertexBuffer.Type.Position);
        FloatBuffer skinvfb2 = smd.skinvfb2;
        skinvb2.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb2);
        
        skinnb = new VertexBuffer(VertexBuffer.Type.Normal);
        FloatBuffer skinnfb = smd.skinnfb;
        skinnb.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.Float, skinnfb);

        skintb = new VertexBuffer(VertexBuffer.Type.TexCoord);
        FloatBuffer skintfb = smd.skintfb;
        skintb.setupData(VertexBuffer.Usage.Static, 2, VertexBuffer.Format.Float, skintfb);

        skinbib = new VertexBuffer(VertexBuffer.Type.BoneIndex);
        ShortBuffer skinbisb = smd.skinbisb;
        skinbib.setupData(VertexBuffer.Usage.Static, 2, VertexBuffer.Format.UnsignedShort, skinbisb);

        skinwb = new VertexBuffer(VertexBuffer.Type.BoneWeight);
        FloatBuffer wfb = smd.wfb;
        skinwb.setupData(VertexBuffer.Usage.Static, 2, VertexBuffer.Format.Float, wfb);

        skinvfb.position(0);
        skinvfb2.position(0);
        skinvfb2.put(skinvfb);
        skinnfb.position(0);
//        skinnfb2.position(0);
//        skinnfb2.put(skinnfb);
        skinIndexArray = smd.skinIndexArray;
    }
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:35,代码来源:PMDLoaderGLSLSkinning2.java

示例14: createSkinMesh

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
PMDSkinMesh createSkinMesh(PMDMaterial pmdMaterial) {
        boolean textureFlag = true;
        if (pmdMaterial.getTextureFileName().length() == 0) {
            textureFlag = false;
        }
        PMDSkinMesh mesh = new PMDSkinMesh();
        mesh.setMode(Mesh.Mode.Triangles);
        mesh.setBuffer(skinvb);
        mesh.setSkinvb2(skinvb2);
        mesh.setBuffer(skinnb);
//        mesh.setSkinnb2(skinnb2);
        if (textureFlag) {
            mesh.setBuffer(skintb);
        }
        mesh.setBuffer(skinbib);
        mesh.setBuffer(skinwb);
        VertexBuffer ib = new VertexBuffer(VertexBuffer.Type.Index);
        ShortBuffer isb = meshConverter.getSkinMeshData().indexShortBufferMap.get(pmdMaterial);
        ib.setupData(VertexBuffer.Usage.Static, 1, VertexBuffer.Format.UnsignedShort, isb);
        mesh.setBuffer(ib);
        mesh.setBoneIndexArray(skinIndexArray);
        ShortBuffer boneIndexBuffer = BufferUtils.createShortBuffer(skinIndexArray.length);
        for(int i=0;i<skinIndexArray.length;i++) {
            boneIndexBuffer.put((short)skinIndexArray[i]);
        }
        mesh.setBoneIndexBuffer(boneIndexBuffer);
        mesh.setBoneMatrixArray(new Matrix4f[skinIndexArray.length]);
        for (int i = 0; i < mesh.getBoneMatrixArray().length; i++) {
            mesh.getBoneMatrixArray()[i] = new Matrix4f();
            mesh.getBoneMatrixArray()[i].loadIdentity();
        }
        FloatBuffer boneMatrixBuffer = BufferUtils.createFloatBuffer(skinIndexArray.length * 16);
        mesh.setBoneMatrixBuffer(boneMatrixBuffer);
        return mesh;
    }
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:36,代码来源:PMDLoaderGLSLSkinning2.java

示例15: clone

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
@Override
    public synchronized PMDSkinMesh clone() {
        PMDSkinMesh newMesh = (PMDSkinMesh)super.clone();
//        newMesh.boneMatrixArray = new Matrix4f[boneMatrixArray.length];
        newMesh.skinvb2 = new VertexBuffer(VertexBuffer.Type.Position);
        FloatBuffer skinvfb2 = BufferUtils.clone((FloatBuffer)this.skinvb2.getData());
        newMesh.skinvb2.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb2);
        
//        newMesh.skinnb2 = new VertexBuffer(VertexBuffer.Type.Normal);
//        FloatBuffer skinnfb2 = BufferUtils.clone((FloatBuffer)this.skinnb2.getData());
//        newMesh.skinnb2.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.Float, skinnfb2);
        
        VertexBuffer skinvb1 = new VertexBuffer(VertexBuffer.Type.Position);
//        FloatBuffer skinvfb1 = BufferUtils.clone((FloatBuffer)this.skinvb2.getData());
        FloatBuffer skinvfb1 = BufferUtils.clone((FloatBuffer)this.getBuffer(VertexBuffer.Type.Position).getData());
        skinvb1.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb1);
        newMesh.clearBuffer(VertexBuffer.Type.Position);
        newMesh.setBuffer(skinvb1);
        
//        VertexBuffer skinnb1 = new VertexBuffer(VertexBuffer.Type.Normal);
//        FloatBuffer skinnfb1 = BufferUtils.clone((FloatBuffer)this.skinnb2.getData());
//        FloatBuffer skinnfb1 = BufferUtils.clone((FloatBuffer)this.getBuffer(VertexBuffer.Type.Normal).getData());
//        skinnb1.setupData(VertexBuffer.Usage.Stream, 3, VertexBuffer.Format.Float, skinnfb1);
//        newMesh.clearBuffer(VertexBuffer.Type.Normal);
//        newMesh.setBuffer(skinnb1);
        FloatBuffer newBoneMatrixBuffer = BufferUtils.createFloatBuffer(boneMatrixBuffer.capacity());
        boneMatrixBuffer.position(0);
        newBoneMatrixBuffer.put(boneMatrixBuffer);
        newBoneMatrixBuffer.position(0);
        newMesh.setBoneMatrixBuffer(newBoneMatrixBuffer);
        return newMesh;
    }
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:33,代码来源:PMDSkinMesh.java


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