本文整理汇总了Java中rajawali.util.LittleEndianDataInputStream.readShort方法的典型用法代码示例。如果您正苦于以下问题:Java LittleEndianDataInputStream.readShort方法的具体用法?Java LittleEndianDataInputStream.readShort怎么用?Java LittleEndianDataInputStream.readShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rajawali.util.LittleEndianDataInputStream
的用法示例。
在下文中一共展示了LittleEndianDataInputStream.readShort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: 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();
}
}