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


Java LittleEndianDataInputStream类代码示例

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


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

示例1: getTexCoords

import rajawali.util.LittleEndianDataInputStream; //导入依赖的package包/类
private float[] getTexCoords(BufferedInputStream stream, byte[] bytes)
        throws IOException {
    ByteArrayInputStream ba = new ByteArrayInputStream(bytes,
            mHeader.offsetTexCoord - 68, bytes.length
            - mHeader.offsetTexCoord);
    LittleEndianDataInputStream is = new LittleEndianDataInputStream(ba);

    float[] coords = new float[mHeader.numTexCoord * 2];

    int buffIndex = 0;
    for (int i = 0; i < mHeader.numTexCoord; i++) {
        buffIndex = i * 2;
        coords[buffIndex] = (float) is.readShort() / (float) mHeader.skinWidth;
        coords[buffIndex + 1] = (float) is.readShort() / (float) mHeader.skinHeight;
    }
    is.close();
    return coords;
}
 
开发者ID:BitMastro,项目名称:PortalLW,代码行数:19,代码来源:MD2Parser.java

示例2: getTexCoords

import rajawali.util.LittleEndianDataInputStream; //导入依赖的package包/类
private float[] getTexCoords(BufferedInputStream stream, byte[] bytes)
		throws IOException {
	ByteArrayInputStream ba = new ByteArrayInputStream(bytes,
			mHeader.offsetTexCoord - 68, bytes.length
					- mHeader.offsetTexCoord);
	LittleEndianDataInputStream is = new LittleEndianDataInputStream(ba);

	float[] coords = new float[mHeader.numTexCoord * 2];

	int buffIndex = 0;
	for (int i = 0; i < mHeader.numTexCoord; i++) {
		buffIndex = i * 2;
		coords[buffIndex] = (float) is.readShort() / (float) mHeader.skinWidth;
		coords[buffIndex + 1] = (float) is.readShort() / (float) mHeader.skinHeight;
	}
	is.close();
	return coords;
}
 
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:19,代码来源:LoaderMD2.java

示例3: getFrames

import rajawali.util.LittleEndianDataInputStream; //导入依赖的package包/类
private void getFrames(BufferedInputStream stream, byte[] bytes)
        throws IOException {
    ByteArrayInputStream ba = new ByteArrayInputStream(bytes,
            mHeader.offsetFrames - 68, bytes.length - mHeader.offsetFrames);
    LittleEndianDataInputStream is = new LittleEndianDataInputStream(ba);

    mFrameVerts = new float[mHeader.numFrames][];

    for (int i = 0; i < mHeader.numFrames; i++) {
        float scaleX = is.readFloat();
        float scaleZ = is.readFloat();
        float scaleY = is.readFloat();
        float translateX = is.readFloat();
        float translateZ = is.readFloat();
        float translateY = is.readFloat();
        String name = is.readString(16);
        IAnimationFrame frame = mFrames.get(i);

        if (name.indexOf("_") > 0)
            name = name.subSequence(0, name.lastIndexOf("_")).toString();
        else
            name = name.trim().replaceAll("[0-9]{1,2}$", "");
        frame.setName(name);

        float vertices[] = new float[mHeader.numVerts * 3];
        int index = 0;

        for (int j = 0; j < mHeader.numVerts; j++) {
            vertices[index + 0] = scaleX * is.readUnsignedByte() + translateX;
            vertices[index + 2] = scaleZ * is.readUnsignedByte() + translateZ;
            vertices[index + 1] = scaleY * is.readUnsignedByte() + translateY;
            index += 3;
            is.readUnsignedByte();

        }
        mFrameVerts[i] = vertices;
    }
    is.close();
}
 
开发者ID:BitMastro,项目名称:PortalLW,代码行数:40,代码来源:MD2Parser.java

示例4: getFrames

import rajawali.util.LittleEndianDataInputStream; //导入依赖的package包/类
private void getFrames(BufferedInputStream stream, byte[] bytes)
		throws IOException {
	ByteArrayInputStream ba = new ByteArrayInputStream(bytes,
			mHeader.offsetFrames - 68, bytes.length - mHeader.offsetFrames);
	LittleEndianDataInputStream is = new LittleEndianDataInputStream(ba);

	mFrameVerts = new float[mHeader.numFrames][];

	for (int i = 0; i < mHeader.numFrames; i++) {
		float scaleX = is.readFloat();
		float scaleZ = is.readFloat();
		float scaleY = is.readFloat();
		float translateX = is.readFloat();
		float translateZ = is.readFloat();
		float translateY = is.readFloat();
		String name = is.readString(16);
		IAnimationFrame frame = mFrames.get(i);

		if (name.indexOf("_") > 0)
			name = name.subSequence(0, name.lastIndexOf("_")).toString();
		else
			name = name.trim().replaceAll("[0-9]{1,2}$", "");
		frame.setName(name);

		float vertices[] = new float[mHeader.numVerts * 3];
		int index = 0;

		for (int j = 0; j < mHeader.numVerts; j++) {
			vertices[index + 0] = scaleX * is.readUnsignedByte() + translateX;
			vertices[index + 2] = scaleZ * is.readUnsignedByte() + translateZ;
			vertices[index + 1] = scaleY * is.readUnsignedByte() + translateY;
			index += 3;
			is.readUnsignedByte();

		}
		mFrameVerts[i] = vertices;
	}
	is.close();
}
 
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:40,代码来源:LoaderMD2.java

示例5: readProperties

import rajawali.util.LittleEndianDataInputStream; //导入依赖的package包/类
protected final void readProperties(LittleEndianDataInputStream dis) throws IOException {
	// Determine the length of the properties
	final long propsLength = dis.readUnsignedInt();

	// TODO need to figure out what uses and needs this so I can better understand implementation

	// skip properties until an implementation can be determined
	dis.skip(propsLength);
}
 
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:10,代码来源:ABlockLoader.java

示例6: getTriangles

import rajawali.util.LittleEndianDataInputStream; //导入依赖的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

示例7: readBinary

import rajawali.util.LittleEndianDataInputStream; //导入依赖的package包/类
/**
 * Read stream as binary STL. This is significantly faster than ASCII parsing. Additionally binary files are much
 * more compressed allowing smaller file sizes for larger models compared to ASCII.
 *
 * @param dis
 * @throws IOException
 */
private void readBinary(final LittleEndianDataInputStream dis) throws IOException {
    RajLog.i("StlPaser: Reading Binary");

    // Skip the header
    dis.skip(80);

    // Read the number of facets (have to convert the uint to a long
    int facetCount = dis.readInt();

    float[] verticesArr = new float[facetCount * 9];
    float[] normalsArr = new float[facetCount * 9];
    int[] indicesArr = new int[facetCount * 3];
    float[] tempNorms = new float[3];
    int vertPos = 0, normPos = 0;

    for (int i = 0; i < indicesArr.length; i++)
        indicesArr[i] = i;

    // Read all the facets
    while (dis.available() > 0) {

        // Read normals
        for (int j = 0; j < 3; j++) {
            tempNorms[j] = dis.readFloat();
            if (Float.isNaN(tempNorms[j]) || Float.isInfinite(tempNorms[j])) {
                RajLog.w("STL contains bad normals of NaN or Infinite!");
                tempNorms[0] = 0;
                tempNorms[1] = 0;
                tempNorms[2] = 0;
                break;
            }
        }

        for (int j = 0; j < 3; j++) {
            normalsArr[normPos++] = tempNorms[0];
            normalsArr[normPos++] = tempNorms[1];
            normalsArr[normPos++] = tempNorms[2];
        }

        // Read vertices
        for (int j = 0; j < 9; j++)
            verticesArr[vertPos++] = dis.readFloat();

        dis.skip(2);
    }

    mRootObject.setData(verticesArr, normalsArr, null, null, indicesArr);
}
 
开发者ID:BitMastro,项目名称:PortalLW,代码行数:56,代码来源:StlParser.java

示例8: readBinary

import rajawali.util.LittleEndianDataInputStream; //导入依赖的package包/类
/**
 * Read stream as binary STL. This is significantly faster than ASCII parsing. Additionally binary files are much
 * more compressed allowing smaller file sizes for larger models compared to ASCII.
 * 
 * @param dis
 * @throws IOException
 */
private void readBinary(final LittleEndianDataInputStream dis) throws IOException {
	RajLog.i("StlPaser: Reading Binary");

	// Skip the header
	dis.skip(80);

	// Read the number of facets (have to convert the uint to a long
	int facetCount = dis.readInt();

	float[] verticesArr = new float[facetCount * 9];
	float[] normalsArr = new float[facetCount * 9];
	int[] indicesArr = new int[facetCount * 3];
	float[] tempNorms = new float[3];
	int vertPos = 0, normPos = 0;

	for (int i = 0; i < indicesArr.length; i++)
		indicesArr[i] = i;

	// Read all the facets
	while (dis.available() > 0) {

		// Read normals
		for (int j = 0; j < 3; j++) {
			tempNorms[j] = dis.readFloat();
			if (Float.isNaN(tempNorms[j]) || Float.isInfinite(tempNorms[j])) {
				RajLog.w("STL contains bad normals of NaN or Infinite!");
				tempNorms[0] = 0;
				tempNorms[1] = 0;
				tempNorms[2] = 0;
				break;
			}
		}

		for (int j = 0; j < 3; j++) {
			normalsArr[normPos++] = tempNorms[0];
			normalsArr[normPos++] = tempNorms[1];
			normalsArr[normPos++] = tempNorms[2];
		}

		// Read vertices
		for (int j = 0; j < 9; j++)
			verticesArr[vertPos++] = dis.readFloat();

		dis.skip(2);
	}

	mRootObject.setData(verticesArr, normalsArr, null, null, indicesArr);
}
 
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:56,代码来源:LoaderSTL.java

示例9: getTriangles

import rajawali.util.LittleEndianDataInputStream; //导入依赖的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

示例10: getTriangles

import rajawali.util.LittleEndianDataInputStream; //导入依赖的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

示例11: getLittleEndianInputStream

import rajawali.util.LittleEndianDataInputStream; //导入依赖的package包/类
/**
 * Open a DataInputStream for the current resource or file using Little Endian format with a buffer size of 8192
 * bytes.
 * 
 * @return
 * @throws FileNotFoundException
 */
protected LittleEndianDataInputStream getLittleEndianInputStream() throws FileNotFoundException {
	return getLittleEndianInputStream(8192);
}
 
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:11,代码来源:ALoader.java


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