當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。