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


Java BufferUtils.createShortBuffer方法代码示例

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


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

示例1: Sector

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * Create a sector using the points from a specified arc.
 *
 * @param arc Arc to pull points from
 */
public Sector( PointArc arc ) {
    this.arc = arc;

    // calculate convenience numbers
    int numTriangles = arc.getNumVertices() - 1;
    int numEdgeVertices = numTriangles + 1;
    int numVertices = numEdgeVertices + 1; // +1 for origin

    positionBuffer = BufferUtils.createFloatBuffer( numVertices * 3 );
    ShortBuffer indexBuffer = BufferUtils.createShortBuffer( numVertices );

    setPositions();

    // our shape is easy to make with the TriangleFan mode
    for ( int i = 0; i < numVertices; i++ ) {
        indexBuffer.put( (short) i );
    }

    this.setMode( Mode.TriangleFan );
    this.setBuffer( VertexBuffer.Type.Position, 3, positionBuffer );
    this.setBuffer( VertexBuffer.Type.Index, 3, indexBuffer );
    this.updateBound();
    this.updateCounts();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:Sector.java

示例2: PointArc

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * Creates an Arc
 *
 * @param startDir        Unit vector for one end of the arc
 * @param endDir          Unit vector for the other end of the arc
 * @param radius          How far from the origin should the arc be? (Radius of the circle that the arc is part of)
 * @param numSegments     How many line segments should the arc be approximated by
 * @param lastMidpointDir The direction that the arc will point out in if it is determined to be too close to 180 degrees
 */
public PointArc( Vector3f startDir, Vector3f endDir, float radius, int numSegments, Vector3f lastMidpointDir ) {
    this.radius = radius;
    numVertices = numSegments + 1;
    numFloats = numVertices * 3;
    int numIndices = numSegments + 1;

    positionBuffer = BufferUtils.createFloatBuffer( numFloats );
    ShortBuffer indexBuffer = BufferUtils.createShortBuffer( numIndices );

    setPositions( startDir, endDir, lastMidpointDir );

    for ( short i = 0; i < numIndices; i++ ) {
        indexBuffer.put( i );
    }

    this.setMode( Mode.LineStrip );
    this.setBuffer( VertexBuffer.Type.Position, 3, positionBuffer );
    this.setBuffer( VertexBuffer.Type.Index, 2, indexBuffer );
    this.updateBound();
    this.updateCounts();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:PointArc.java

示例3: WireSphere

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
public WireSphere(float radius) {
        updatePositions(radius);
        ShortBuffer ib = BufferUtils.createShortBuffer(samples * 2 * 2 + zSamples * samples * 2 /*+ 3 * 2*/);
        setBuffer(Type.Index, 2, ib);

//        ib.put(new byte[]{
//            (byte) 0, (byte) 1,
//            (byte) 2, (byte) 3,
//            (byte) 4, (byte) 5,
//        });

//        int curNum = 3 * 2;
        int curNum = 0;
        for (int j = 0; j < 2 + zSamples; j++) {
            for (int i = curNum; i < curNum + samples - 1; i++) {
                ib.put((short) i).put((short) (i + 1));
            }
            ib.put((short) (curNum + samples - 1)).put((short) curNum);
            curNum += samples;
        }

        setMode(Mode.Lines);

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

示例4: startFaces

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

示例5: startLodFaceList

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

示例6: setIndexData

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * sets the indices for rendering the sphere.
 */
private void setIndexData() {
    // allocate connectivity
    int nbSegments = (radialSamples);// * 3;

    ShortBuffer idxBuf = BufferUtils.createShortBuffer(2 * nbSegments);
    setBuffer(Type.Index, 2, idxBuf);

    int idx = 0;
    int segDone = 0;
    while (segDone < nbSegments) {
        idxBuf.put((short) idx);
        idxBuf.put((short) (idx + 1));
        idx++;
        segDone++;
    }

}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:21,代码来源:ProbeRadiusShape.java

示例7: createBuffer

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private java.nio.Buffer createBuffer(int size) {
	switch (format) {
		case Byte:
		case UnsignedByte:
			return BufferUtils.createByteBuffer(size);
		case Double: return BufferUtils.createDoubleBuffer(size);
		case Float: return BufferUtils.createFloatBuffer(size);
		case Half:
		case Short:
		case UnsignedShort:
			return BufferUtils.createShortBuffer(size);
		case Int:
		case UnsignedInt:
			return BufferUtils.createIntBuffer(size);
		default:
			throw new IllegalArgumentException("unknown format "+format);
	}
}
 
开发者ID:shamanDevel,项目名称:jME3-OpenCL-Library,代码行数:19,代码来源:SharedBuffer.java

示例8: updateMaxVertexCount

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private void updateMaxVertexCount( int maxVertexCount ) {
    positionBuffer = BufferUtils.createFloatBuffer( maxVertexCount * 3 );
    normalBuffer = BufferUtils.createFloatBuffer( maxVertexCount * 3 );
    textureBuffer = BufferUtils.createFloatBuffer( maxVertexCount * 2 );
    indexBuffer = BufferUtils.createShortBuffer( maxVertexCount * 3 ); // allow a bit extra index information

    // pre-initialize the normal data
    for ( int i = 0; i < maxVertexCount; i++ ) {
        normalBuffer.put( new float[] { 0, 0, 1 } );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:PlanarPolygon.java

示例9: createBuffer

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * Creates a {@link Buffer} that satisfies the given type and size requirements
 * of the parameters. The buffer will be of the type specified by
 * {@link Format format} and would be able to contain the given number
 * of elements with the given number of components in each element.
 */
public static Buffer createBuffer(Format format, int components, int numElements){
    if (components < 1 || components > 4)
        throw new IllegalArgumentException("Num components must be between 1 and 4");

    int total = numElements * components;

    switch (format){
        case Byte:
        case UnsignedByte:
            return BufferUtils.createByteBuffer(total);
        case Half:
            return BufferUtils.createByteBuffer(total * 2);
        case Short:
        case UnsignedShort:
            return BufferUtils.createShortBuffer(total);
        case Int:
        case UnsignedInt:
            return BufferUtils.createIntBuffer(total);
        case Float:
            return BufferUtils.createFloatBuffer(total);
        case Double:
            return BufferUtils.createDoubleBuffer(total);
        default:
            throw new UnsupportedOperationException("Unrecoginized buffer format: "+format);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:33,代码来源:VertexBuffer.java

示例10: initialize

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
public void initialize() {
	vb = BufferUtils.createFloatBuffer(batch.getQuads().size() * 3 * 4);
	cb = BufferUtils.createFloatBuffer(batch.getQuads().size() * 4 * 4);
	tcb = BufferUtils.createFloatBuffer(batch.getQuads().size() * 2 * 4);
	ib = BufferUtils.createShortBuffer(batch.getQuads().size() * 6);
	init = true;
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:8,代码来源:AnimElementMesh.java

示例11: setIndexData

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private void setIndexData() {
    int nbSegments = 3;

    ShortBuffer idxBuf = BufferUtils.createShortBuffer(2 * nbSegments);
    setBuffer(VertexBuffer.Type.Index, 2, idxBuf);
    idxBuf.put((short) 0);
    idxBuf.put((short) 1);

    idxBuf.put((short) 1);
    idxBuf.put((short) 2);

    idxBuf.put((short) 2);
    idxBuf.put((short) 0);
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:15,代码来源:Triangle.java

示例12: Grid

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * Creates a grid debug shape.
 * @param xLines
 * @param yLines
 * @param lineDist 
 */
public Grid(int xLines, int yLines, float lineDist){
    xLines -= 2;
    yLines -= 2;
    int lineCount = xLines + yLines + 4;

    FloatBuffer fpb = BufferUtils.createFloatBuffer(6 * lineCount);
    ShortBuffer sib = BufferUtils.createShortBuffer(2 * lineCount);

    float xLineLen = (yLines + 1) * lineDist;
    float yLineLen = (xLines + 1) * lineDist;
    int curIndex = 0;

    // add lines along X
    for (int i = 0; i < xLines + 2; i++){
        float y = (i) * lineDist;

        // positions
        fpb.put(0)       .put(0).put(y);
        fpb.put(xLineLen).put(0).put(y);

        // indices
        sib.put( (short) (curIndex++) );
        sib.put( (short) (curIndex++) );
    }

    // add lines along Y
    for (int i = 0; i < yLines + 2; i++){
        float x = (i) * lineDist;

        // positions
        fpb.put(x).put(0).put(0);
        fpb.put(x).put(0).put(yLineLen);

        // indices
        sib.put( (short) (curIndex++) );
        sib.put( (short) (curIndex++) );
    }

    fpb.flip();
    sib.flip();

    setBuffer(Type.Position, 3, fpb);
    setBuffer(Type.Index, 2, sib);
    
    setMode(Mode.Lines);

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

示例13: compact

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * Reduces the capacity of the buffer to the given amount
 * of elements, any elements at the end of the buffer are truncated
 * as necessary.
 *
 * @param numElements The number of elements to reduce to.
 */
public void compact(int numElements){
    int total = components * numElements;
    data.clear();
    switch (format){
        case Byte:
        case UnsignedByte:
        case Half:
            ByteBuffer bbuf = (ByteBuffer) data;
            bbuf.limit(total);
            ByteBuffer bnewBuf = BufferUtils.createByteBuffer(total);
            bnewBuf.put(bbuf);
            data = bnewBuf;
            break;
        case Short:
        case UnsignedShort:
            ShortBuffer sbuf = (ShortBuffer) data;
            sbuf.limit(total);
            ShortBuffer snewBuf = BufferUtils.createShortBuffer(total);
            snewBuf.put(sbuf);
            data = snewBuf;
            break;
        case Int:
        case UnsignedInt:
            IntBuffer ibuf = (IntBuffer) data;
            ibuf.limit(total);
            IntBuffer inewBuf = BufferUtils.createIntBuffer(total);
            inewBuf.put(ibuf);
            data = inewBuf;
            break;
        case Float:
            FloatBuffer fbuf = (FloatBuffer) data;
            fbuf.limit(total);
            FloatBuffer fnewBuf = BufferUtils.createFloatBuffer(total);
            fnewBuf.put(fbuf);
            data = fnewBuf;
            break;
        default:
            throw new UnsupportedOperationException("Unrecognized buffer format: "+format);
    }
    data.clear();
    setUpdateNeeded();
    dataSizeChanged = true;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:51,代码来源:VertexBuffer.java

示例14: setIndexData

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * sets the indices for rendering the sphere.
 */
private void setIndexData() {
    // allocate connectivity
    triCount = 2 * (zSamples - 2) * radialSamples;
    ShortBuffer idxBuf = BufferUtils.createShortBuffer(3 * triCount);
    setBuffer(Type.Index, 3, idxBuf);

    // generate connectivity
    int index = 0;
    for (int iZ = 0, iZStart = 0; iZ < (zSamples - 3); iZ++) {
        int i0 = iZStart;
        int i1 = i0 + 1;
        iZStart += (radialSamples + 1);
        int i2 = iZStart;
        int i3 = i2 + 1;
        for (int i = 0; i < radialSamples; i++, index += 6) {
            if (!interior) {
                idxBuf.put((short) i0++);
                idxBuf.put((short) i1);
                idxBuf.put((short) i2);
                idxBuf.put((short) i1++);
                idxBuf.put((short) i3++);
                idxBuf.put((short) i2++);
            } else { // inside view
                idxBuf.put((short) i0++);
                idxBuf.put((short) i2);
                idxBuf.put((short) i1);
                idxBuf.put((short) i1++);
                idxBuf.put((short) i2++);
                idxBuf.put((short) i3++);
            }
        }
    }

    // south pole triangles
    for (int i = 0; i < radialSamples; i++, index += 3) {
        if (!interior) {
            idxBuf.put((short) i);
            idxBuf.put((short) (vertCount - 2));
            idxBuf.put((short) (i + 1));
        } else { // inside view
            idxBuf.put((short) i);
            idxBuf.put((short) (i + 1));
            idxBuf.put((short) (vertCount - 2));
        }
    }

    // north pole triangles
    int iOffset = (zSamples - 3) * (radialSamples + 1);
    for (int i = 0; i < radialSamples; i++, index += 3) {
        if (!interior) {
            idxBuf.put((short) (i + iOffset));
            idxBuf.put((short) (i + 1 + iOffset));
            idxBuf.put((short) (vertCount - 1));
        } else { // inside view
            idxBuf.put((short) (i + iOffset));
            idxBuf.put((short) (vertCount - 1));
            idxBuf.put((short) (i + 1 + iOffset));
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:64,代码来源:Sphere.java

示例15: setIndexData

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private void setIndexData() {
        // allocate connectivity
        int triCount = 2 * circleSamples * radialSamples;

        ShortBuffer sib = BufferUtils.createShortBuffer(3 * triCount);
        setBuffer(Type.Index, 3, sib);

        int i;
        // generate connectivity
        int connectionStart = 0;
        int index = 0;
        for (int circleCount = 0; circleCount < circleSamples; circleCount++) {
            int i0 = connectionStart;
            int i1 = i0 + 1;
            connectionStart += radialSamples + 1;
            int i2 = connectionStart;
            int i3 = i2 + 1;
            for (i = 0; i < radialSamples; i++, index += 6) {
//                if (true) {
                    sib.put((short)i0++);
                    sib.put((short)i2);
                    sib.put((short)i1);
                    sib.put((short)i1++);
                    sib.put((short)i2++);
                    sib.put((short)i3++);

//                    getIndexBuffer().put(i0++);
//                    getIndexBuffer().put(i2);
//                    getIndexBuffer().put(i1);
//                    getIndexBuffer().put(i1++);
//                    getIndexBuffer().put(i2++);
//                    getIndexBuffer().put(i3++);
//                } else {
//                    getIndexBuffer().put(i0++);
//                    getIndexBuffer().put(i1);
//                    getIndexBuffer().put(i2);
//                    getIndexBuffer().put(i1++);
//                    getIndexBuffer().put(i3++);
//                    getIndexBuffer().put(i2++);
//                }
            }
        }
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:44,代码来源:Torus.java


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