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


Java VertexAnimationFrame类代码示例

本文整理汇总了Java中rajawali.animation.mesh.VertexAnimationFrame的典型用法代码示例。如果您正苦于以下问题:Java VertexAnimationFrame类的具体用法?Java VertexAnimationFrame怎么用?Java VertexAnimationFrame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getTriangles

import rajawali.animation.mesh.VertexAnimationFrame; //导入依赖的package包/类
private void getTriangles(BufferedInputStream stream, byte[] bytes, float[] texCoords)
        throws IOException {
    ByteArrayInputStream ba = new ByteArrayInputStream(bytes,
            mHeader.offsetTriangles - 68, bytes.length
            - mHeader.offsetTriangles);
    LittleEndianDataInputStream is = new LittleEndianDataInputStream(ba);
    int[] indices = new int[mHeader.numTriangles * 3];
    int[] uvIndices = new int[mHeader.numTriangles * 3];
    int index = 0, uvIndex = 0;

    for (int i = 0; i < mHeader.numTriangles; i++) {
        indices[index++] = is.readShort();
        indices[index++] = is.readShort();
        indices[index++] = is.readShort();
        uvIndices[uvIndex++] = is.readShort();
        uvIndices[uvIndex++] = is.readShort();
        uvIndices[uvIndex++] = is.readShort();
    }
    is.close();

    short newVertexIndex = (short) mHeader.numVerts;
    int numIndices = indices.length;
    Stack<VertexIndices> changedIndices = new Stack<MD2Parser.VertexIndices>();

    for (int i = 0; i < numIndices; i++) {
        for (int j = i + 1; j < numIndices; j++) {
            if (indices[i] == indices[j] && uvIndices[i] != uvIndices[j]) {
                changedIndices.add(new VertexIndices((short) j, indices[j], newVertexIndex));

                for (int k = j + 1; k < numIndices; k++) {
                    if (indices[j] == indices[k] && uvIndices[j] == uvIndices[k]) {
                        indices[k] = newVertexIndex;
                    }
                }

                indices[j] = newVertexIndex;
                newVertexIndex++;
            }
        }
    }

    int[] cIndices = new int[changedIndices.size()];
    for (int j = 0; j < changedIndices.size(); j++)
        cIndices[j] = changedIndices.get(j).oldVertexIndex;

    float[] reorderedTexCoords = new float[(mHeader.numVerts + changedIndices.size()) * 2];

    for (int i = 0; i < indices.length; i++) {
        int fid = indices[i];
        int uvid = uvIndices[i];

        reorderedTexCoords[fid * 2] = texCoords[uvid * 2];
        reorderedTexCoords[fid * 2 + 1] = texCoords[uvid * 2 + 1];
    }

    mTextureCoords = reorderedTexCoords;
    mIndices = indices;

    for (int i = 0; i < mHeader.numFrames; ++i) {
        VertexAnimationFrame frame = (VertexAnimationFrame) mFrames.get(i);
        duplicateAndAppendVertices(i, cIndices);
        frame.getGeometry().setVertices(mFrameVerts[i]);
        frame.getGeometry().setNormals(frame.calculateNormals(indices));
        frame.getGeometry().createVertexAndNormalBuffersOnly();
    }
}
 
开发者ID:BitMastro,项目名称:PortalLW,代码行数:67,代码来源:MD2Parser.java

示例2: exportToSerialized

import rajawali.animation.mesh.VertexAnimationFrame; //导入依赖的package包/类
/**
 * Make sure this line is in your AndroidManifer.xml file, under <manifest>: <uses-permission
 * android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 */
private void exportToSerialized() {
    FileOutputStream fos;
    try {
        File f = getExportFile();
        fos = new FileOutputStream(f);
        ObjectOutputStream os = null;
        if (mCompressed) {
            GZIPOutputStream gz = new GZIPOutputStream(fos);
            os = new ObjectOutputStream(gz);
        } else {
            os = new ObjectOutputStream(fos);
        }

        SerializedObject3D ser = mObject.toSerializedObject3D();

        if (mObject instanceof VertexAnimationObject3D) {
            VertexAnimationObject3D o = (VertexAnimationObject3D) mObject;
            int numFrames = o.getNumFrames();
            float[][] vs = new float[numFrames][];
            float[][] ns = new float[numFrames][];
            String[] frameNames = new String[numFrames];

            for (int i = 0; i < numFrames; ++i) {
                VertexAnimationFrame frame = (VertexAnimationFrame) o.getFrame(i);
                Geometry3D geom = frame.getGeometry();
                float[] v = new float[geom.getVertices().limit()];
                geom.getVertices().get(v);
                float[] n = new float[geom.getNormals().limit()];
                geom.getNormals().get(n);
                vs[i] = v;
                ns[i] = n;
                frameNames[i] = frame.getName();
            }

            ser.setFrameVertices(vs);
            ser.setFrameNormals(ns);
            ser.setFrameNames(frameNames);
        }

        os.writeObject(ser);
        os.close();
        RajLog.i("Successfully serialized " + mFileName);
    } catch (Exception e) {
        RajLog.e("Serializing " + mFileName + " was unsuccessfull.");
        e.printStackTrace();
    }

}
 
开发者ID:BitMastro,项目名称:PortalLW,代码行数:53,代码来源:MeshExporter.java

示例3: getTriangles

import rajawali.animation.mesh.VertexAnimationFrame; //导入依赖的package包/类
private void getTriangles(BufferedInputStream stream, byte[] bytes, float[] texCoords)
		throws IOException {
	ByteArrayInputStream ba = new ByteArrayInputStream(bytes,
			mHeader.offsetTriangles - 68, bytes.length
					- mHeader.offsetTriangles);
	LittleEndianDataInputStream is = new LittleEndianDataInputStream(ba);
	int[] indices = new int[mHeader.numTriangles * 3];
	int[] uvIndices = new int[mHeader.numTriangles * 3];
	int index = 0, uvIndex = 0;

	for (int i = 0; i < mHeader.numTriangles; i++) {
		indices[index++] = is.readShort();
		indices[index++] = is.readShort();
		indices[index++] = is.readShort();
		uvIndices[uvIndex++] = is.readShort();
		uvIndices[uvIndex++] = is.readShort();
		uvIndices[uvIndex++] = is.readShort();
	}
	is.close();

	short newVertexIndex = (short) mHeader.numVerts;
	int numIndices = indices.length;
	Stack<VertexIndices> changedIndices = new Stack<LoaderMD2.VertexIndices>();

	for (int i = 0; i < numIndices; i++) {
		for (int j = i + 1; j < numIndices; j++)
		{
			if (indices[i] == indices[j] && uvIndices[i] != uvIndices[j])
			{
				changedIndices.add(new VertexIndices((short) j, indices[j], newVertexIndex));

				for (int k = j + 1; k < numIndices; k++) {
					if (indices[j] == indices[k] && uvIndices[j] == uvIndices[k]) {
						indices[k] = newVertexIndex;
					}
				}

				indices[j] = newVertexIndex;
				newVertexIndex++;
			}
		}
	}

	int[] cIndices = new int[changedIndices.size()];
	for (int j = 0; j < changedIndices.size(); j++)
		cIndices[j] = changedIndices.get(j).oldVertexIndex;

	float[] reorderedTexCoords = new float[(mHeader.numVerts + changedIndices.size()) * 2];

	for (int i = 0; i < indices.length; i++) {
		int fid = indices[i];
		int uvid = uvIndices[i];

		reorderedTexCoords[fid * 2] = texCoords[uvid * 2];
		reorderedTexCoords[fid * 2 + 1] = texCoords[uvid * 2 + 1];
	}

	mTextureCoords = reorderedTexCoords;
	mIndices = indices;

	for (int i = 0; i < mHeader.numFrames; ++i) {
		VertexAnimationFrame frame = (VertexAnimationFrame) mFrames.get(i);
		duplicateAndAppendVertices(i, cIndices);
		frame.getGeometry().setVertices(mFrameVerts[i]);
		frame.getGeometry().setNormals(frame.calculateNormals(indices));
		frame.getGeometry().createVertexAndNormalBuffersOnly();
	}
}
 
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:69,代码来源:LoaderMD2.java

示例4: export

import rajawali.animation.mesh.VertexAnimationFrame; //导入依赖的package包/类
@Override
public void export() throws Exception {
	FileOutputStream fos;
	try {
		fos = new FileOutputStream(exportFile);
		ObjectOutputStream os = null;
		if (mCompressed) {
			GZIPOutputStream gz = new GZIPOutputStream(fos);
			os = new ObjectOutputStream(gz);
		} else {
			os = new ObjectOutputStream(fos);
		}

		SerializedObject3D ser = mObject.toSerializedObject3D();

		if (mObject instanceof VertexAnimationObject3D) {
			VertexAnimationObject3D o = (VertexAnimationObject3D) mObject;
			int numFrames = o.getNumFrames();
			float[][] vs = new float[numFrames][];
			float[][] ns = new float[numFrames][];
			String[] frameNames = new String[numFrames];

			for (int i = 0; i < numFrames; ++i) {
				VertexAnimationFrame frame = (VertexAnimationFrame) o.getFrame(i);
				Geometry3D geom = frame.getGeometry();
				float[] v = new float[geom.getVertices().limit()];
				geom.getVertices().get(v);
				float[] n = new float[geom.getNormals().limit()];
				geom.getNormals().get(n);
				vs[i] = v;
				ns[i] = n;
				frameNames[i] = frame.getName();
			}

			ser.setFrameVertices(vs);
			ser.setFrameNormals(ns);
			ser.setFrameNames(frameNames);
		}

		os.writeObject(ser);
		os.close();
		RajLog.i("Successfully serialized " + exportFile.getName() + " to " + exportFile.getCanonicalPath());
	} catch (Exception e) {
		RajLog.e("Serializing " + exportFile.getName() + " was unsuccessfull.");
		e.printStackTrace();
	}

}
 
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:49,代码来源:SerializationExporter.java

示例5: getTriangles

import rajawali.animation.mesh.VertexAnimationFrame; //导入依赖的package包/类
private void getTriangles(BufferedInputStream stream, byte[] bytes, float[] texCoords)
		throws IOException {
	ByteArrayInputStream ba = new ByteArrayInputStream(bytes,
			mHeader.offsetTriangles - 68, bytes.length
					- mHeader.offsetTriangles);
	LittleEndianDataInputStream is = new LittleEndianDataInputStream(ba);
	int[] indices = new int[mHeader.numTriangles * 3];
	int[] uvIndices = new int[mHeader.numTriangles * 3];
	int index = 0, uvIndex = 0;

	for (int i = 0; i < mHeader.numTriangles; i++) {
		indices[index++] = is.readShort();
		indices[index++] = is.readShort();
		indices[index++] = is.readShort();
		uvIndices[uvIndex++] = is.readShort();
		uvIndices[uvIndex++] = is.readShort();
		uvIndices[uvIndex++] = is.readShort();
	}
	is.close();

	short newVertexIndex = (short) mHeader.numVerts;
	int numIndices = indices.length;
	Stack<VertexIndices> changedIndices = new Stack<MD2Parser.VertexIndices>();

	for (int i = 0; i < numIndices; i++) {
		for (int j = i + 1; j < numIndices; j++)
		{
			if (indices[i] == indices[j] && uvIndices[i] != uvIndices[j])
			{
				changedIndices.add(new VertexIndices((short) j, indices[j], newVertexIndex));

				for (int k = j + 1; k < numIndices; k++) {
					if (indices[j] == indices[k] && uvIndices[j] == uvIndices[k]) {
						indices[k] = newVertexIndex;
					}
				}

				indices[j] = newVertexIndex;
				newVertexIndex++;
			}
		}
	}

	int[] cIndices = new int[changedIndices.size()];
	for (int j = 0; j < changedIndices.size(); j++)
		cIndices[j] = changedIndices.get(j).oldVertexIndex;

	float[] reorderedTexCoords = new float[(mHeader.numVerts + changedIndices.size()) * 2];

	for (int i = 0; i < indices.length; i++) {
		int fid = indices[i];
		int uvid = uvIndices[i];

		reorderedTexCoords[fid * 2] = texCoords[uvid * 2];
		reorderedTexCoords[fid * 2 + 1] = texCoords[uvid * 2 + 1];
	}

	mTextureCoords = reorderedTexCoords;
	mIndices = indices;

	for (int i = 0; i < mHeader.numFrames; ++i) {
		VertexAnimationFrame frame = (VertexAnimationFrame) mFrames.get(i);
		duplicateAndAppendVertices(i, cIndices);
		frame.getGeometry().setVertices(mFrameVerts[i]);
		frame.getGeometry().setNormals(frame.calculateNormals(indices));
		frame.getGeometry().createVertexAndNormalBuffersOnly();
	}
}
 
开发者ID:OpsLabJPL,项目名称:MarsImagesAndroid,代码行数:69,代码来源:MD2Parser.java

示例6: exportToSerialized

import rajawali.animation.mesh.VertexAnimationFrame; //导入依赖的package包/类
/**
 * Make sure this line is in your AndroidManifer.xml file, under <manifest>: <uses-permission
 * android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 */
private void exportToSerialized() {
	FileOutputStream fos;
	try {
		File f = getExportFile();
		fos = new FileOutputStream(f);
		ObjectOutputStream os = null;
		if (mCompressed) {
			GZIPOutputStream gz = new GZIPOutputStream(fos);
			os = new ObjectOutputStream(gz);
		} else {
			os = new ObjectOutputStream(fos);
		}

		SerializedObject3D ser = mObject.toSerializedObject3D();

		if (mObject instanceof VertexAnimationObject3D) {
			VertexAnimationObject3D o = (VertexAnimationObject3D) mObject;
			int numFrames = o.getNumFrames();
			float[][] vs = new float[numFrames][];
			float[][] ns = new float[numFrames][];
			String[] frameNames = new String[numFrames];

			for (int i = 0; i < numFrames; ++i) {
				VertexAnimationFrame frame = (VertexAnimationFrame) o.getFrame(i);
				Geometry3D geom = frame.getGeometry();
				float[] v = new float[geom.getVertices().limit()];
				geom.getVertices().get(v);
				float[] n = new float[geom.getNormals().limit()];
				geom.getNormals().get(n);
				vs[i] = v;
				ns[i] = n;
				frameNames[i] = frame.getName();
			}

			ser.setFrameVertices(vs);
			ser.setFrameNormals(ns);
			ser.setFrameNames(frameNames);
		}

		os.writeObject(ser);
		os.close();
		RajLog.i("Successfully serialized " + mFileName);
	} catch (Exception e) {
		RajLog.e("Serializing " + mFileName + " was unsuccessfull.");
		e.printStackTrace();
	}

}
 
开发者ID:OpsLabJPL,项目名称:MarsImagesAndroid,代码行数:53,代码来源:MeshExporter.java


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