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


Java IndexBuffer.size方法代码示例

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


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

示例1: BIHTree

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

import com.jme3.scene.mesh.IndexBuffer; //导入方法依赖的package包/类
/**
 * The method generates normal buffer for the created mesh of the curve.
 * 
 * @param indexes
 *            the indexes of the mesh points
 * @param points
 *            the mesh's points
 * @param smooth
 *            the flag indicating if the result is to be smooth or solid
 * @return normals buffer for the mesh
 */
private FloatBuffer generateNormals(IndexBuffer indexes, FloatBuffer points, boolean smooth) {
    Map<Integer, Vector3f> normalMap = new TreeMap<Integer, Vector3f>();
    Vector3f[] allVerts = BufferUtils.getVector3Array(points);

    for (int i = 0; i < indexes.size(); i += 3) {
        int index1 = indexes.get(i);
        int index2 = indexes.get(i + 1);
        int index3 = indexes.get(i + 2);

        Vector3f n = FastMath.computeNormal(allVerts[index1], allVerts[index2], allVerts[index3]);
        this.addNormal(n, normalMap, smooth, index1, index2, index3);
    }

    FloatBuffer normals = BufferUtils.createFloatBuffer(normalMap.size() * 3);
    for (Entry<Integer, Vector3f> entry : normalMap.entrySet()) {
        normals.put(entry.getValue().x);
        normals.put(entry.getValue().y);
        normals.put(entry.getValue().z);
    }
    return normals;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:33,代码来源:CurvesHelper.java

示例3: compressIndexBuffer

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

示例4: optimize

import com.jme3.scene.mesh.IndexBuffer; //导入方法依赖的package包/类
public Mesh optimize(Mesh mesh) {
    nmgen = new NavmeshGenerator(cellSize, cellHeight, minTraversableHeight,
            maxTraversableStep, maxTraversableSlope,
            clipLedges, traversableAreaBorderSize,
            smoothingThreshold, useConservativeExpansion,
            minUnconnectedRegionSize, mergeRegionSize,
            maxEdgeLength, edgeMaxDeviation, maxVertsPerPoly,
            contourSampleDistance, contourMaxDeviation);

    FloatBuffer pb = mesh.getFloatBuffer(Type.Position);
    IndexBuffer ib = mesh.getIndexBuffer();

    // copy positions to float array
    float[] positions = new float[pb.capacity()];
    pb.clear();
    pb.get(positions);

    // generate int array of indices
    int[] indices = new int[ib.size()];
    for (int i = 0; i < indices.length; i++) {
        indices[i] = ib.get(i);
    }


    TriangleMesh triMesh = buildNavMesh(positions, indices, intermediateData);
    if (triMesh == null) {
        return null;
    }

    int[] indices2 = triMesh.indices;
    float[] positions2 = triMesh.vertices;

    Mesh mesh2 = new Mesh();
    mesh2.setBuffer(Type.Position, 3, positions2);
    mesh2.setBuffer(Type.Index, 3, indices2);
    mesh2.updateBound();
    mesh2.updateCounts();

    return mesh2;
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:41,代码来源:NavMeshGenerator.java

示例5: processTriangles

import com.jme3.scene.mesh.IndexBuffer; //导入方法依赖的package包/类
private static List<VertexData> processTriangles(Mesh mesh, int[] index, Vector3f[] v, Vector2f[] t, boolean splitMirrored) {
	IndexBuffer indexBuffer = mesh.getIndexBuffer();
	FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
	if (mesh.getBuffer(Type.TexCoord) == null) {
		throw new IllegalArgumentException("Can only generate tangents for " + "meshes with texture coordinates");
	}

	FloatBuffer textureBuffer = (FloatBuffer) mesh.getBuffer(Type.TexCoord).getData();

	List<VertexData> vertices = initVertexData(vertexBuffer.limit() / 3);

	for (int i = 0; i < indexBuffer.size() / 3; i++) {
		for (int j = 0; j < 3; j++) {
			index[j] = indexBuffer.get(i * 3 + j);
			populateFromBuffer(v[j], vertexBuffer, index[j]);
			populateFromBuffer(t[j], textureBuffer, index[j]);
		}

		TriangleData triData = processTriangle(index, v, t);
		if (splitMirrored) {
			triData.setIndex(index);
			triData.triangleOffset = i * 3;
		}
		if (triData != null) {
			vertices.get(index[0]).triangles.add(triData);
			vertices.get(index[1]).triangles.add(triData);
			vertices.get(index[2]).triangles.add(triData);
		}
	}

	return vertices;
}
 
开发者ID:meltzow,项目名称:supernovae,代码行数:33,代码来源:SilentTangentBinormalGenerator.java

示例6: processTriangles

import com.jme3.scene.mesh.IndexBuffer; //导入方法依赖的package包/类
private static VertexData[] processTriangles(Mesh mesh,
        int[] index, Vector3f[] v, Vector2f[] t)
{
    IndexBuffer indexBuffer =  mesh.getIndexBuffer();
    FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
    if (mesh.getBuffer(Type.TexCoord) == null)
        throw new IllegalArgumentException("Can only generate tangents for "
                                         + "meshes with texture coordinates");
    
    FloatBuffer textureBuffer = (FloatBuffer) mesh.getBuffer(Type.TexCoord).getData();

    VertexData[] vertices = initVertexData(vertexBuffer.capacity() / 3);

    for (int i = 0; i < indexBuffer.size() / 3; i++) {
        for (int j = 0; j < 3; j++) {
            index[j] = indexBuffer.get(i*3 + j);
            populateFromBuffer(v[j], vertexBuffer, index[j]);
            populateFromBuffer(t[j], textureBuffer, index[j]);
        }

        TriangleData triData = processTriangle(index, v, t);
        if (triData != null) {
            vertices[index[0]].triangles.add(triData);
            vertices[index[1]].triangles.add(triData);
            vertices[index[2]].triangles.add(triData);
        }
    }
    
    return vertices;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:31,代码来源:TangentBinormalGenerator.java

示例7: processTriangleStrip

import com.jme3.scene.mesh.IndexBuffer; //导入方法依赖的package包/类
private static List<VertexData> processTriangleStrip(Mesh mesh, int[] index, Vector3f[] v, Vector2f[] t) {
	IndexBuffer indexBuffer = mesh.getIndexBuffer();
	FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
	FloatBuffer textureBuffer = (FloatBuffer) mesh.getBuffer(Type.TexCoord).getData();

	List<VertexData> vertices = initVertexData(vertexBuffer.limit() / 3);

	index[0] = indexBuffer.get(0);
	index[1] = indexBuffer.get(1);

	populateFromBuffer(v[0], vertexBuffer, index[0]);
	populateFromBuffer(v[1], vertexBuffer, index[1]);

	populateFromBuffer(t[0], textureBuffer, index[0]);
	populateFromBuffer(t[1], textureBuffer, index[1]);

	for (int i = 2; i < indexBuffer.size(); i++) {
		index[2] = indexBuffer.get(i);
		BufferUtils.populateFromBuffer(v[2], vertexBuffer, index[2]);
		BufferUtils.populateFromBuffer(t[2], textureBuffer, index[2]);

		boolean isDegenerate = isDegenerateTriangle(v[0], v[1], v[2]);
		TriangleData triData = processTriangle(index, v, t);

		if (triData != null && !isDegenerate) {
			vertices.get(index[0]).triangles.add(triData);
			vertices.get(index[1]).triangles.add(triData);
			vertices.get(index[2]).triangles.add(triData);
		}

		Vector3f vTemp = v[0];
		v[0] = v[1];
		v[1] = v[2];
		v[2] = vTemp;

		Vector2f tTemp = t[0];
		t[0] = t[1];
		t[1] = t[2];
		t[2] = tTemp;

		index[0] = index[1];
		index[1] = index[2];
	}

	return vertices;
}
 
开发者ID:meltzow,项目名称:supernovae,代码行数:47,代码来源:SilentTangentBinormalGenerator.java

示例8: processTriangleStrip

import com.jme3.scene.mesh.IndexBuffer; //导入方法依赖的package包/类
private static VertexData[] processTriangleStrip(Mesh mesh,
        int[] index, Vector3f[] v, Vector2f[] t)
{
    IndexBuffer indexBuffer =  mesh.getIndexBuffer();
    FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
    FloatBuffer textureBuffer = (FloatBuffer) mesh.getBuffer(Type.TexCoord).getData();

    VertexData[] vertices = initVertexData(vertexBuffer.capacity() / 3);

    index[0] = indexBuffer.get(0);
    index[1] = indexBuffer.get(1);

    populateFromBuffer(v[0], vertexBuffer, index[0]);
    populateFromBuffer(v[1], vertexBuffer, index[1]);

    populateFromBuffer(t[0], textureBuffer, index[0]);
    populateFromBuffer(t[1], textureBuffer, index[1]);
    
    for (int i = 2; i < indexBuffer.size(); i++) {
        index[2] = indexBuffer.get(i);
        BufferUtils.populateFromBuffer(v[2], vertexBuffer, index[2]);
        BufferUtils.populateFromBuffer(t[2], textureBuffer, index[2]);
        
        boolean isDegenerate = isDegenerateTriangle(v[0], v[1], v[2]);
        TriangleData triData = processTriangle(index, v, t);
        
        if (triData != null && !isDegenerate) {
            vertices[index[0]].triangles.add(triData);
            vertices[index[1]].triangles.add(triData);
            vertices[index[2]].triangles.add(triData);
        }

        Vector3f vTemp = v[0];
        v[0] = v[1];
        v[1] = v[2];
        v[2] = vTemp;

        Vector2f tTemp = t[0];
        t[0] = t[1];
        t[1] = t[2];
        t[2] = tTemp;

        index[0] = index[1];
        index[1] = index[2];
    }

    return vertices;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:49,代码来源:TangentBinormalGenerator.java


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