Merge pull request #9 from UniquePassive/master
Cache definitions changes/additions
This commit is contained in:
@@ -68,7 +68,7 @@ public class ItemDumper
|
||||
|
||||
for (net.runelite.cache.fs.File f : archive.getFiles())
|
||||
{
|
||||
ItemDefinition def = loader.load(f.getFileId(), new InputStream(f.getContents()));
|
||||
ItemDefinition def = loader.load(f.getFileId(), f.getContents());
|
||||
items.add(def);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,7 +452,7 @@ public class MapImageDumper
|
||||
byte[] contents = file.getContents();
|
||||
|
||||
SpriteLoader loader = new SpriteLoader();
|
||||
SpriteDefinition[] sprites = loader.load(a.getArchiveId(), new InputStream(contents));
|
||||
SpriteDefinition[] sprites = loader.load(a.getArchiveId(), contents);
|
||||
|
||||
for (SpriteDefinition sprite : sprites)
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ public class NpcDumper
|
||||
|
||||
for (net.runelite.cache.fs.File f : archive.getFiles())
|
||||
{
|
||||
NpcDefinition npc = loader.load(f.getFileId(), new InputStream(f.getContents()));
|
||||
NpcDefinition npc = loader.load(f.getFileId(), f.getContents());
|
||||
npcs.add(npc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,9 @@ public class ItemDefinition
|
||||
public int team;
|
||||
|
||||
public int shiftClickDropIndex = -2;
|
||||
|
||||
public int boughtId = -1;
|
||||
public int boughtTemplateId = -1;
|
||||
|
||||
public int placeholderId = -1;
|
||||
public int placeholderTemplateId = -1;
|
||||
|
||||
@@ -6,76 +6,84 @@ import net.runelite.cache.models.VertexNormal;
|
||||
public class ModelDefinition
|
||||
{
|
||||
public int id;
|
||||
public short[] texTriangleX;
|
||||
public int[] vertexX;
|
||||
public byte[] faceRenderPriorities;
|
||||
public int[] vertexY;
|
||||
public int triangleFaceCount;
|
||||
public int[] trianglePointsX;
|
||||
public int[] vertexSkins;
|
||||
public int[] trianglePointsZ;
|
||||
public int anInt2562;
|
||||
public int[] trianglePointsY;
|
||||
|
||||
public int vertexCount = 0;
|
||||
public int[] vertexPositionsX;
|
||||
public int[] vertexPositionsY;
|
||||
public int[] vertexPositionsZ;
|
||||
public transient VertexNormal[] vertexNormals;
|
||||
|
||||
public int faceCount;
|
||||
public int[] faceVertexIndices1;
|
||||
public int[] faceVertexIndices2;
|
||||
public int[] faceVertexIndices3;
|
||||
public byte[] faceAlphas;
|
||||
public short aShort2565;
|
||||
public byte[] faceRenderType;
|
||||
public short[] faceColors;
|
||||
public byte[] faceRenderPriorities;
|
||||
public byte[] faceRenderTypes;
|
||||
public transient FaceNormal[] faceNormals;
|
||||
|
||||
public int textureTriangleCount;
|
||||
public short[] textureTriangleVertexIndices1;
|
||||
public short[] textureTriangleVertexIndices2;
|
||||
public short[] textureTriangleVertexIndices3;
|
||||
public transient float[][] faceTextureUCoordinates;
|
||||
public transient float[][] faceTextureVCoordinates;
|
||||
public short[] texturePrimaryColors;
|
||||
public short[] faceTextures;
|
||||
public byte priority;
|
||||
public int texTriangleCount;
|
||||
public byte[] textureCoordinates;
|
||||
public byte[] textureRenderTypes;
|
||||
public short[] texTriangleY;
|
||||
public short[] texTriangleZ;
|
||||
|
||||
public int[] vertexSkins;
|
||||
public int[] faceSkins;
|
||||
|
||||
public byte priority;
|
||||
public int shadowIntensity;
|
||||
|
||||
public int anInt2562;
|
||||
public short aShort2565;
|
||||
boolean aBool2579;
|
||||
public short[] aShortArray2574;
|
||||
public short[] aShortArray2575;
|
||||
public short[] aShortArray2577;
|
||||
public short[] aShortArray2578;
|
||||
boolean aBool2579;
|
||||
public byte[] aByteArray2580;
|
||||
public byte[] textureCoords;
|
||||
public int[] triangleSkinValues;
|
||||
public int[][] anIntArrayArray2583;
|
||||
public int[][] anIntArrayArray2584;
|
||||
public short[] aShortArray2586;
|
||||
public short aShort2589;
|
||||
public short[] faceColor;
|
||||
public int shadowIntensity;
|
||||
public int anInt2592;
|
||||
public int anInt2593;
|
||||
public int[] vertexZ;
|
||||
public int anInt2595;
|
||||
public int vertexCount = 0;
|
||||
public short[] texturePrimaryColor;
|
||||
public transient VertexNormal[] normals;
|
||||
public transient FaceNormal[] faceNormals;
|
||||
|
||||
public void computeNormals()
|
||||
{
|
||||
if (this.normals != null)
|
||||
if (this.vertexNormals != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.normals = new VertexNormal[this.vertexCount];
|
||||
this.vertexNormals = new VertexNormal[this.vertexCount];
|
||||
|
||||
int var1;
|
||||
for (var1 = 0; var1 < this.vertexCount; ++var1)
|
||||
{
|
||||
this.normals[var1] = new VertexNormal();
|
||||
this.vertexNormals[var1] = new VertexNormal();
|
||||
}
|
||||
|
||||
for (var1 = 0; var1 < this.triangleFaceCount; ++var1)
|
||||
for (var1 = 0; var1 < this.faceCount; ++var1)
|
||||
{
|
||||
int vertexA = this.trianglePointsX[var1];
|
||||
int vertexB = this.trianglePointsY[var1];
|
||||
int vertexC = this.trianglePointsZ[var1];
|
||||
int vertexA = this.faceVertexIndices1[var1];
|
||||
int vertexB = this.faceVertexIndices2[var1];
|
||||
int vertexC = this.faceVertexIndices3[var1];
|
||||
|
||||
int xA = this.vertexX[vertexB] - this.vertexX[vertexA];
|
||||
int yA = this.vertexY[vertexB] - this.vertexY[vertexA];
|
||||
int zA = this.vertexZ[vertexB] - this.vertexZ[vertexA];
|
||||
int xA = this.vertexPositionsX[vertexB] - this.vertexPositionsX[vertexA];
|
||||
int yA = this.vertexPositionsY[vertexB] - this.vertexPositionsY[vertexA];
|
||||
int zA = this.vertexPositionsZ[vertexB] - this.vertexPositionsZ[vertexA];
|
||||
|
||||
int xB = this.vertexX[vertexC] - this.vertexX[vertexA];
|
||||
int yB = this.vertexY[vertexC] - this.vertexY[vertexA];
|
||||
int zB = this.vertexZ[vertexC] - this.vertexZ[vertexA];
|
||||
int xB = this.vertexPositionsX[vertexC] - this.vertexPositionsX[vertexA];
|
||||
int yB = this.vertexPositionsY[vertexC] - this.vertexPositionsY[vertexA];
|
||||
int zB = this.vertexPositionsZ[vertexC] - this.vertexPositionsZ[vertexA];
|
||||
|
||||
// Compute cross product
|
||||
int var11 = yA * zB - yB * zA;
|
||||
@@ -100,30 +108,30 @@ public class ModelDefinition
|
||||
var13 = var13 * 256 / length;
|
||||
|
||||
byte var15;
|
||||
if (this.faceRenderType == null)
|
||||
if (this.faceRenderTypes == null)
|
||||
{
|
||||
var15 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var15 = this.faceRenderType[var1];
|
||||
var15 = this.faceRenderTypes[var1];
|
||||
}
|
||||
|
||||
if (var15 == 0)
|
||||
{
|
||||
VertexNormal var16 = this.normals[vertexA];
|
||||
VertexNormal var16 = this.vertexNormals[vertexA];
|
||||
var16.x += var11;
|
||||
var16.y += var12;
|
||||
var16.z += var13;
|
||||
++var16.magnitude;
|
||||
|
||||
var16 = this.normals[vertexB];
|
||||
var16 = this.vertexNormals[vertexB];
|
||||
var16.x += var11;
|
||||
var16.y += var12;
|
||||
var16.z += var13;
|
||||
++var16.magnitude;
|
||||
|
||||
var16 = this.normals[vertexC];
|
||||
var16 = this.vertexNormals[vertexC];
|
||||
var16.x += var11;
|
||||
var16.y += var12;
|
||||
var16.z += var13;
|
||||
@@ -133,7 +141,7 @@ public class ModelDefinition
|
||||
{
|
||||
if (this.faceNormals == null)
|
||||
{
|
||||
this.faceNormals = new FaceNormal[this.triangleFaceCount];
|
||||
this.faceNormals = new FaceNormal[this.faceCount];
|
||||
}
|
||||
|
||||
FaceNormal var17 = this.faceNormals[var1] = new FaceNormal();
|
||||
@@ -144,4 +152,118 @@ public class ModelDefinition
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the UV coordinates for every three-vertex face that has a texture.
|
||||
*/
|
||||
public void computeTextureUVCoordinates()
|
||||
{
|
||||
this.faceTextureUCoordinates = new float[faceCount][];
|
||||
this.faceTextureVCoordinates = new float[faceCount][];
|
||||
|
||||
for (int i = 0; i < faceCount; i++)
|
||||
{
|
||||
int textureCoordinate;
|
||||
if (textureCoordinates == null)
|
||||
{
|
||||
textureCoordinate = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
textureCoordinate = textureCoordinates[i];
|
||||
}
|
||||
|
||||
int textureIdx;
|
||||
if (faceTextures == null)
|
||||
{
|
||||
textureIdx = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
textureIdx = faceTextures[i] & 0xFFFF;
|
||||
}
|
||||
|
||||
if (textureIdx != -1)
|
||||
{
|
||||
float[] u = new float[3];
|
||||
float[] v = new float[3];
|
||||
|
||||
if (textureCoordinate == -1)
|
||||
{
|
||||
u[0] = 0.0F;
|
||||
v[0] = 1.0F;
|
||||
|
||||
u[1] = 1.0F;
|
||||
v[1] = 1.0F;
|
||||
|
||||
u[2] = 0.0F;
|
||||
v[2] = 0.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
textureCoordinate &= 0xFF;
|
||||
|
||||
byte textureRenderType = 0;
|
||||
if (textureRenderTypes != null)
|
||||
{
|
||||
textureRenderType = textureRenderTypes[textureCoordinate];
|
||||
}
|
||||
|
||||
if (textureRenderType == 0)
|
||||
{
|
||||
int faceVertexIdx1 = faceVertexIndices1[i];
|
||||
int faceVertexIdx2 = faceVertexIndices2[i];
|
||||
int faceVertexIdx3 = faceVertexIndices3[i];
|
||||
|
||||
short triangleVertexIdx1 = textureTriangleVertexIndices1[textureCoordinate];
|
||||
short triangleVertexIdx2 = textureTriangleVertexIndices2[textureCoordinate];
|
||||
short triangleVertexIdx3 = textureTriangleVertexIndices3[textureCoordinate];
|
||||
|
||||
float triangleX = (float) vertexPositionsX[triangleVertexIdx1];
|
||||
float triangleY = (float) vertexPositionsY[triangleVertexIdx1];
|
||||
float triangleZ = (float) vertexPositionsZ[triangleVertexIdx1];
|
||||
|
||||
float f_882_ = (float) vertexPositionsX[triangleVertexIdx2] - triangleX;
|
||||
float f_883_ = (float) vertexPositionsY[triangleVertexIdx2] - triangleY;
|
||||
float f_884_ = (float) vertexPositionsZ[triangleVertexIdx2] - triangleZ;
|
||||
float f_885_ = (float) vertexPositionsX[triangleVertexIdx3] - triangleX;
|
||||
float f_886_ = (float) vertexPositionsY[triangleVertexIdx3] - triangleY;
|
||||
float f_887_ = (float) vertexPositionsZ[triangleVertexIdx3] - triangleZ;
|
||||
float f_888_ = (float) vertexPositionsX[faceVertexIdx1] - triangleX;
|
||||
float f_889_ = (float) vertexPositionsY[faceVertexIdx1] - triangleY;
|
||||
float f_890_ = (float) vertexPositionsZ[faceVertexIdx1] - triangleZ;
|
||||
float f_891_ = (float) vertexPositionsX[faceVertexIdx2] - triangleX;
|
||||
float f_892_ = (float) vertexPositionsY[faceVertexIdx2] - triangleY;
|
||||
float f_893_ = (float) vertexPositionsZ[faceVertexIdx2] - triangleZ;
|
||||
float f_894_ = (float) vertexPositionsX[faceVertexIdx3] - triangleX;
|
||||
float f_895_ = (float) vertexPositionsY[faceVertexIdx3] - triangleY;
|
||||
float f_896_ = (float) vertexPositionsZ[faceVertexIdx3] - triangleZ;
|
||||
|
||||
float f_897_ = f_883_ * f_887_ - f_884_ * f_886_;
|
||||
float f_898_ = f_884_ * f_885_ - f_882_ * f_887_;
|
||||
float f_899_ = f_882_ * f_886_ - f_883_ * f_885_;
|
||||
float f_900_ = f_886_ * f_899_ - f_887_ * f_898_;
|
||||
float f_901_ = f_887_ * f_897_ - f_885_ * f_899_;
|
||||
float f_902_ = f_885_ * f_898_ - f_886_ * f_897_;
|
||||
float f_903_ = 1.0F / (f_900_ * f_882_ + f_901_ * f_883_ + f_902_ * f_884_);
|
||||
|
||||
u[0] = (f_900_ * f_888_ + f_901_ * f_889_ + f_902_ * f_890_) * f_903_;
|
||||
u[1] = (f_900_ * f_891_ + f_901_ * f_892_ + f_902_ * f_893_) * f_903_;
|
||||
u[2] = (f_900_ * f_894_ + f_901_ * f_895_ + f_902_ * f_896_) * f_903_;
|
||||
|
||||
f_900_ = f_883_ * f_899_ - f_884_ * f_898_;
|
||||
f_901_ = f_884_ * f_897_ - f_882_ * f_899_;
|
||||
f_902_ = f_882_ * f_898_ - f_883_ * f_897_;
|
||||
f_903_ = 1.0F / (f_900_ * f_885_ + f_901_ * f_886_ + f_902_ * f_887_);
|
||||
|
||||
v[0] = (f_900_ * f_888_ + f_901_ * f_889_ + f_902_ * f_890_) * f_903_;
|
||||
v[1] = (f_900_ * f_891_ + f_901_ * f_892_ + f_902_ * f_893_) * f_903_;
|
||||
v[2] = (f_900_ * f_894_ + f_901_ * f_895_ + f_902_ * f_896_) * f_903_;
|
||||
}
|
||||
}
|
||||
|
||||
this.faceTextureUCoordinates[i] = u;
|
||||
this.faceTextureVCoordinates[i] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,19 +34,20 @@ public class ItemLoader
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(ItemLoader.class);
|
||||
|
||||
public ItemDefinition load(int id, InputStream stream)
|
||||
public ItemDefinition load(int id, byte[] b)
|
||||
{
|
||||
ItemDefinition def = new ItemDefinition(id);
|
||||
InputStream is = new InputStream(b);
|
||||
|
||||
while (true)
|
||||
{
|
||||
int opcode = stream.readUnsignedByte();
|
||||
int opcode = is.readUnsignedByte();
|
||||
if (opcode == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
this.decodeValues(opcode, def, stream);
|
||||
this.decodeValues(opcode, def, is);
|
||||
}
|
||||
|
||||
return def;
|
||||
@@ -239,11 +240,11 @@ public class ItemLoader
|
||||
}
|
||||
else if (opcode == 139)
|
||||
{
|
||||
stream.readUnsignedShort();
|
||||
def.boughtId = stream.readUnsignedShort();
|
||||
}
|
||||
else if (opcode == 140)
|
||||
{
|
||||
stream.readUnsignedShort();
|
||||
def.boughtTemplateId = stream.readUnsignedShort();
|
||||
}
|
||||
else if (opcode == 148)
|
||||
{
|
||||
|
||||
@@ -5,18 +5,18 @@ import net.runelite.cache.io.InputStream;
|
||||
|
||||
public class ModelLoader
|
||||
{
|
||||
public ModelDefinition load(int modelId, byte[] var1)
|
||||
public ModelDefinition load(int modelId, byte[] b)
|
||||
{
|
||||
ModelDefinition def = new ModelDefinition();
|
||||
def.id = modelId;
|
||||
|
||||
if (var1[var1.length - 1] == -1 && var1[var1.length - 2] == -1)
|
||||
if (b[b.length - 1] == -1 && b[b.length - 2] == -1)
|
||||
{
|
||||
this.load1(def, var1);
|
||||
this.load1(def, b);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.load2(def, var1);
|
||||
this.load2(def, b);
|
||||
}
|
||||
|
||||
def.computeNormals();
|
||||
@@ -141,14 +141,14 @@ public class ModelLoader
|
||||
int var46 = position;
|
||||
position += var7 * 2 + var29 * 2;
|
||||
model.vertexCount = verticeCount;
|
||||
model.triangleFaceCount = triangleCount;
|
||||
model.texTriangleCount = textureTriangleCount;
|
||||
model.vertexX = new int[verticeCount];
|
||||
model.vertexY = new int[verticeCount];
|
||||
model.vertexZ = new int[verticeCount];
|
||||
model.trianglePointsX = new int[triangleCount];
|
||||
model.trianglePointsY = new int[triangleCount];
|
||||
model.trianglePointsZ = new int[triangleCount];
|
||||
model.faceCount = triangleCount;
|
||||
model.textureTriangleCount = textureTriangleCount;
|
||||
model.vertexPositionsX = new int[verticeCount];
|
||||
model.vertexPositionsY = new int[verticeCount];
|
||||
model.vertexPositionsZ = new int[verticeCount];
|
||||
model.faceVertexIndices1 = new int[triangleCount];
|
||||
model.faceVertexIndices2 = new int[triangleCount];
|
||||
model.faceVertexIndices3 = new int[triangleCount];
|
||||
if (modelVertexSkins == 1)
|
||||
{
|
||||
model.vertexSkins = new int[verticeCount];
|
||||
@@ -156,7 +156,7 @@ public class ModelLoader
|
||||
|
||||
if (var13 == 1)
|
||||
{
|
||||
model.faceRenderType = new byte[triangleCount];
|
||||
model.faceRenderTypes = new byte[triangleCount];
|
||||
}
|
||||
|
||||
if (modelPriority == 255)
|
||||
@@ -175,7 +175,7 @@ public class ModelLoader
|
||||
|
||||
if (var17 == 1)
|
||||
{
|
||||
model.triangleSkinValues = new int[triangleCount];
|
||||
model.faceSkins = new int[triangleCount];
|
||||
}
|
||||
|
||||
if (modelTexture == 1)
|
||||
@@ -185,15 +185,15 @@ public class ModelLoader
|
||||
|
||||
if (modelTexture == 1 && textureTriangleCount > 0)
|
||||
{
|
||||
model.textureCoords = new byte[triangleCount];
|
||||
model.textureCoordinates = new byte[triangleCount];
|
||||
}
|
||||
|
||||
model.faceColor = new short[triangleCount];
|
||||
model.faceColors = new short[triangleCount];
|
||||
if (textureTriangleCount > 0)
|
||||
{
|
||||
model.texTriangleX = new short[textureTriangleCount];
|
||||
model.texTriangleY = new short[textureTriangleCount];
|
||||
model.texTriangleZ = new short[textureTriangleCount];
|
||||
model.textureTriangleVertexIndices1 = new short[textureTriangleCount];
|
||||
model.textureTriangleVertexIndices2 = new short[textureTriangleCount];
|
||||
model.textureTriangleVertexIndices3 = new short[textureTriangleCount];
|
||||
if (var7 > 0)
|
||||
{
|
||||
model.aShortArray2574 = new short[var7];
|
||||
@@ -206,7 +206,7 @@ public class ModelLoader
|
||||
|
||||
if (var29 > 0)
|
||||
{
|
||||
model.texturePrimaryColor = new short[var29];
|
||||
model.texturePrimaryColors = new short[var29];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,12 +245,12 @@ public class ModelLoader
|
||||
vertexZOffset = var28.readShortSmart();
|
||||
}
|
||||
|
||||
model.vertexX[point] = vX + vertexXOffset;
|
||||
model.vertexY[point] = vY + vertexYOffset;
|
||||
model.vertexZ[point] = vZ + vertexZOffset;
|
||||
vX = model.vertexX[point];
|
||||
vY = model.vertexY[point];
|
||||
vZ = model.vertexZ[point];
|
||||
model.vertexPositionsX[point] = vX + vertexXOffset;
|
||||
model.vertexPositionsY[point] = vY + vertexYOffset;
|
||||
model.vertexPositionsZ[point] = vZ + vertexZOffset;
|
||||
vX = model.vertexPositionsX[point];
|
||||
vY = model.vertexPositionsY[point];
|
||||
vZ = model.vertexPositionsZ[point];
|
||||
if (modelVertexSkins == 1)
|
||||
{
|
||||
model.vertexSkins[point] = var6.readUnsignedByte();
|
||||
@@ -267,10 +267,10 @@ public class ModelLoader
|
||||
|
||||
for (point = 0; point < triangleCount; ++point)
|
||||
{
|
||||
model.faceColor[point] = (short) var2.readUnsignedShort();
|
||||
model.faceColors[point] = (short) var2.readUnsignedShort();
|
||||
if (var13 == 1)
|
||||
{
|
||||
model.faceRenderType[point] = var24.readByte();
|
||||
model.faceRenderTypes[point] = var24.readByte();
|
||||
}
|
||||
|
||||
if (modelPriority == 255)
|
||||
@@ -285,7 +285,7 @@ public class ModelLoader
|
||||
|
||||
if (var17 == 1)
|
||||
{
|
||||
model.triangleSkinValues[point] = var6.readUnsignedByte();
|
||||
model.faceSkins[point] = var6.readUnsignedByte();
|
||||
}
|
||||
|
||||
if (modelTexture == 1)
|
||||
@@ -293,9 +293,9 @@ public class ModelLoader
|
||||
model.faceTextures[point] = (short) (var55.readUnsignedShort() - 1);
|
||||
}
|
||||
|
||||
if (model.textureCoords != null && model.faceTextures[point] != -1)
|
||||
if (model.textureCoordinates != null && model.faceTextures[point] != -1)
|
||||
{
|
||||
model.textureCoords[point] = (byte) (var51.readUnsignedByte() - 1);
|
||||
model.textureCoordinates[point] = (byte) (var51.readUnsignedByte() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,9 +316,9 @@ public class ModelLoader
|
||||
trianglePointY = var2.readShortSmart() + trianglePointX;
|
||||
trianglePointZ = var2.readShortSmart() + trianglePointY;
|
||||
vertexYOffset = trianglePointZ;
|
||||
model.trianglePointsX[vertexZOffset] = trianglePointX;
|
||||
model.trianglePointsY[vertexZOffset] = trianglePointY;
|
||||
model.trianglePointsZ[vertexZOffset] = trianglePointZ;
|
||||
model.faceVertexIndices1[vertexZOffset] = trianglePointX;
|
||||
model.faceVertexIndices2[vertexZOffset] = trianglePointY;
|
||||
model.faceVertexIndices3[vertexZOffset] = trianglePointZ;
|
||||
}
|
||||
|
||||
if (numFaces == 2)
|
||||
@@ -326,9 +326,9 @@ public class ModelLoader
|
||||
trianglePointY = trianglePointZ;
|
||||
trianglePointZ = var2.readShortSmart() + vertexYOffset;
|
||||
vertexYOffset = trianglePointZ;
|
||||
model.trianglePointsX[vertexZOffset] = trianglePointX;
|
||||
model.trianglePointsY[vertexZOffset] = trianglePointY;
|
||||
model.trianglePointsZ[vertexZOffset] = trianglePointZ;
|
||||
model.faceVertexIndices1[vertexZOffset] = trianglePointX;
|
||||
model.faceVertexIndices2[vertexZOffset] = trianglePointY;
|
||||
model.faceVertexIndices3[vertexZOffset] = trianglePointZ;
|
||||
}
|
||||
|
||||
if (numFaces == 3)
|
||||
@@ -336,9 +336,9 @@ public class ModelLoader
|
||||
trianglePointX = trianglePointZ;
|
||||
trianglePointZ = var2.readShortSmart() + vertexYOffset;
|
||||
vertexYOffset = trianglePointZ;
|
||||
model.trianglePointsX[vertexZOffset] = trianglePointX;
|
||||
model.trianglePointsY[vertexZOffset] = trianglePointY;
|
||||
model.trianglePointsZ[vertexZOffset] = trianglePointZ;
|
||||
model.faceVertexIndices1[vertexZOffset] = trianglePointX;
|
||||
model.faceVertexIndices2[vertexZOffset] = trianglePointY;
|
||||
model.faceVertexIndices3[vertexZOffset] = trianglePointZ;
|
||||
}
|
||||
|
||||
if (numFaces == 4)
|
||||
@@ -348,9 +348,9 @@ public class ModelLoader
|
||||
trianglePointY = var57;
|
||||
trianglePointZ = var2.readShortSmart() + vertexYOffset;
|
||||
vertexYOffset = trianglePointZ;
|
||||
model.trianglePointsX[vertexZOffset] = trianglePointX;
|
||||
model.trianglePointsY[vertexZOffset] = var57;
|
||||
model.trianglePointsZ[vertexZOffset] = trianglePointZ;
|
||||
model.faceVertexIndices1[vertexZOffset] = trianglePointX;
|
||||
model.faceVertexIndices2[vertexZOffset] = var57;
|
||||
model.faceVertexIndices3[vertexZOffset] = trianglePointZ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,16 +366,16 @@ public class ModelLoader
|
||||
int type = model.textureRenderTypes[texIndex] & 255;
|
||||
if (type == 0)
|
||||
{
|
||||
model.texTriangleX[texIndex] = (short) var2.readUnsignedShort();
|
||||
model.texTriangleY[texIndex] = (short) var2.readUnsignedShort();
|
||||
model.texTriangleZ[texIndex] = (short) var2.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices1[texIndex] = (short) var2.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices2[texIndex] = (short) var2.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices3[texIndex] = (short) var2.readUnsignedShort();
|
||||
}
|
||||
|
||||
if (type == 1)
|
||||
{
|
||||
model.texTriangleX[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.texTriangleY[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.texTriangleZ[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices1[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices2[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices3[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.aShortArray2574[texIndex] = (short) var3.readUnsignedShort();
|
||||
model.aShortArray2575[texIndex] = (short) var3.readUnsignedShort();
|
||||
model.aShortArray2586[texIndex] = (short) var3.readUnsignedShort();
|
||||
@@ -386,23 +386,23 @@ public class ModelLoader
|
||||
|
||||
if (type == 2)
|
||||
{
|
||||
model.texTriangleX[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.texTriangleY[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.texTriangleZ[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices1[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices2[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices3[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.aShortArray2574[texIndex] = (short) var3.readUnsignedShort();
|
||||
model.aShortArray2575[texIndex] = (short) var3.readUnsignedShort();
|
||||
model.aShortArray2586[texIndex] = (short) var3.readUnsignedShort();
|
||||
model.aShortArray2577[texIndex] = (short) var28.readUnsignedShort();
|
||||
model.aByteArray2580[texIndex] = var6.readByte();
|
||||
model.aShortArray2578[texIndex] = (short) var55.readUnsignedShort();
|
||||
model.texturePrimaryColor[texIndex] = (short) var55.readUnsignedShort();
|
||||
model.texturePrimaryColors[texIndex] = (short) var55.readUnsignedShort();
|
||||
}
|
||||
|
||||
if (type == 3)
|
||||
{
|
||||
model.texTriangleX[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.texTriangleY[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.texTriangleZ[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices1[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices2[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices3[texIndex] = (short) var24.readUnsignedShort();
|
||||
model.aShortArray2574[texIndex] = (short) var3.readUnsignedShort();
|
||||
model.aShortArray2575[texIndex] = (short) var3.readUnsignedShort();
|
||||
model.aShortArray2586[texIndex] = (short) var3.readUnsignedShort();
|
||||
@@ -492,20 +492,20 @@ public class ModelLoader
|
||||
var46 += var20;
|
||||
int var10000 = var46 + var36;
|
||||
model.vertexCount = var10;
|
||||
model.triangleFaceCount = var11;
|
||||
model.texTriangleCount = var12;
|
||||
model.vertexX = new int[var10];
|
||||
model.vertexY = new int[var10];
|
||||
model.vertexZ = new int[var10];
|
||||
model.trianglePointsX = new int[var11];
|
||||
model.trianglePointsY = new int[var11];
|
||||
model.trianglePointsZ = new int[var11];
|
||||
model.faceCount = var11;
|
||||
model.textureTriangleCount = var12;
|
||||
model.vertexPositionsX = new int[var10];
|
||||
model.vertexPositionsY = new int[var10];
|
||||
model.vertexPositionsZ = new int[var10];
|
||||
model.faceVertexIndices1 = new int[var11];
|
||||
model.faceVertexIndices2 = new int[var11];
|
||||
model.faceVertexIndices3 = new int[var11];
|
||||
if (var12 > 0)
|
||||
{
|
||||
model.textureRenderTypes = new byte[var12];
|
||||
model.texTriangleX = new short[var12];
|
||||
model.texTriangleY = new short[var12];
|
||||
model.texTriangleZ = new short[var12];
|
||||
model.textureTriangleVertexIndices1 = new short[var12];
|
||||
model.textureTriangleVertexIndices2 = new short[var12];
|
||||
model.textureTriangleVertexIndices3 = new short[var12];
|
||||
}
|
||||
|
||||
if (var28 == 1)
|
||||
@@ -515,8 +515,8 @@ public class ModelLoader
|
||||
|
||||
if (var13 == 1)
|
||||
{
|
||||
model.faceRenderType = new byte[var11];
|
||||
model.textureCoords = new byte[var11];
|
||||
model.faceRenderTypes = new byte[var11];
|
||||
model.textureCoordinates = new byte[var11];
|
||||
model.faceTextures = new short[var11];
|
||||
}
|
||||
|
||||
@@ -536,10 +536,10 @@ public class ModelLoader
|
||||
|
||||
if (var15 == 1)
|
||||
{
|
||||
model.triangleSkinValues = new int[var11];
|
||||
model.faceSkins = new int[var11];
|
||||
}
|
||||
|
||||
model.faceColor = new short[var11];
|
||||
model.faceColors = new short[var11];
|
||||
var5.setOffset(var16);
|
||||
var39.setOffset(var34);
|
||||
var26.setOffset(var35);
|
||||
@@ -575,12 +575,12 @@ public class ModelLoader
|
||||
var7 = var9.readShortSmart();
|
||||
}
|
||||
|
||||
model.vertexX[var18] = var41 + var31;
|
||||
model.vertexY[var18] = var33 + var6;
|
||||
model.vertexZ[var18] = var19 + var7;
|
||||
var41 = model.vertexX[var18];
|
||||
var33 = model.vertexY[var18];
|
||||
var19 = model.vertexZ[var18];
|
||||
model.vertexPositionsX[var18] = var41 + var31;
|
||||
model.vertexPositionsY[var18] = var33 + var6;
|
||||
model.vertexPositionsZ[var18] = var19 + var7;
|
||||
var41 = model.vertexPositionsX[var18];
|
||||
var33 = model.vertexPositionsY[var18];
|
||||
var19 = model.vertexPositionsZ[var18];
|
||||
if (var28 == 1)
|
||||
{
|
||||
model.vertexSkins[var18] = var3.readUnsignedByte();
|
||||
@@ -595,25 +595,25 @@ public class ModelLoader
|
||||
|
||||
for (var18 = 0; var18 < var11; ++var18)
|
||||
{
|
||||
model.faceColor[var18] = (short) var5.readUnsignedShort();
|
||||
model.faceColors[var18] = (short) var5.readUnsignedShort();
|
||||
if (var13 == 1)
|
||||
{
|
||||
var8 = var39.readUnsignedByte();
|
||||
if ((var8 & 1) == 1)
|
||||
{
|
||||
model.faceRenderType[var18] = 1;
|
||||
model.faceRenderTypes[var18] = 1;
|
||||
var2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.faceRenderType[var18] = 0;
|
||||
model.faceRenderTypes[var18] = 0;
|
||||
}
|
||||
|
||||
if ((var8 & 2) == 2)
|
||||
{
|
||||
model.textureCoords[var18] = (byte) (var8 >> 2);
|
||||
model.faceTextures[var18] = model.faceColor[var18];
|
||||
model.faceColor[var18] = 127;
|
||||
model.textureCoordinates[var18] = (byte) (var8 >> 2);
|
||||
model.faceTextures[var18] = model.faceColors[var18];
|
||||
model.faceColors[var18] = 127;
|
||||
if (model.faceTextures[var18] != -1)
|
||||
{
|
||||
var43 = true;
|
||||
@@ -621,7 +621,7 @@ public class ModelLoader
|
||||
}
|
||||
else
|
||||
{
|
||||
model.textureCoords[var18] = -1;
|
||||
model.textureCoordinates[var18] = -1;
|
||||
model.faceTextures[var18] = -1;
|
||||
}
|
||||
}
|
||||
@@ -638,7 +638,7 @@ public class ModelLoader
|
||||
|
||||
if (var15 == 1)
|
||||
{
|
||||
model.triangleSkinValues[var18] = var3.readUnsignedByte();
|
||||
model.faceSkins[var18] = var3.readUnsignedByte();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,9 +660,9 @@ public class ModelLoader
|
||||
var8 = var5.readShortSmart() + var18;
|
||||
var31 = var5.readShortSmart() + var8;
|
||||
var6 = var31;
|
||||
model.trianglePointsX[var7] = var18;
|
||||
model.trianglePointsY[var7] = var8;
|
||||
model.trianglePointsZ[var7] = var31;
|
||||
model.faceVertexIndices1[var7] = var18;
|
||||
model.faceVertexIndices2[var7] = var8;
|
||||
model.faceVertexIndices3[var7] = var31;
|
||||
}
|
||||
|
||||
if (var22 == 2)
|
||||
@@ -670,9 +670,9 @@ public class ModelLoader
|
||||
var8 = var31;
|
||||
var31 = var5.readShortSmart() + var6;
|
||||
var6 = var31;
|
||||
model.trianglePointsX[var7] = var18;
|
||||
model.trianglePointsY[var7] = var8;
|
||||
model.trianglePointsZ[var7] = var31;
|
||||
model.faceVertexIndices1[var7] = var18;
|
||||
model.faceVertexIndices2[var7] = var8;
|
||||
model.faceVertexIndices3[var7] = var31;
|
||||
}
|
||||
|
||||
if (var22 == 3)
|
||||
@@ -680,9 +680,9 @@ public class ModelLoader
|
||||
var18 = var31;
|
||||
var31 = var5.readShortSmart() + var6;
|
||||
var6 = var31;
|
||||
model.trianglePointsX[var7] = var18;
|
||||
model.trianglePointsY[var7] = var8;
|
||||
model.trianglePointsZ[var7] = var31;
|
||||
model.faceVertexIndices1[var7] = var18;
|
||||
model.faceVertexIndices2[var7] = var8;
|
||||
model.faceVertexIndices3[var7] = var31;
|
||||
}
|
||||
|
||||
if (var22 == 4)
|
||||
@@ -692,9 +692,9 @@ public class ModelLoader
|
||||
var8 = var21;
|
||||
var31 = var5.readShortSmart() + var6;
|
||||
var6 = var31;
|
||||
model.trianglePointsX[var7] = var18;
|
||||
model.trianglePointsY[var7] = var21;
|
||||
model.trianglePointsZ[var7] = var31;
|
||||
model.faceVertexIndices1[var7] = var18;
|
||||
model.faceVertexIndices2[var7] = var21;
|
||||
model.faceVertexIndices3[var7] = var31;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,23 +703,23 @@ public class ModelLoader
|
||||
for (var7 = 0; var7 < var12; ++var7)
|
||||
{
|
||||
model.textureRenderTypes[var7] = 0;
|
||||
model.texTriangleX[var7] = (short) var5.readUnsignedShort();
|
||||
model.texTriangleY[var7] = (short) var5.readUnsignedShort();
|
||||
model.texTriangleZ[var7] = (short) var5.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices1[var7] = (short) var5.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices2[var7] = (short) var5.readUnsignedShort();
|
||||
model.textureTriangleVertexIndices3[var7] = (short) var5.readUnsignedShort();
|
||||
}
|
||||
|
||||
if (model.textureCoords != null)
|
||||
if (model.textureCoordinates != null)
|
||||
{
|
||||
boolean var45 = false;
|
||||
|
||||
for (var22 = 0; var22 < var11; ++var22)
|
||||
{
|
||||
var21 = model.textureCoords[var22] & 255;
|
||||
var21 = model.textureCoordinates[var22] & 255;
|
||||
if (var21 != 255)
|
||||
{
|
||||
if ((model.texTriangleX[var21] & '\uffff') == model.trianglePointsX[var22] && (model.texTriangleY[var21] & '\uffff') == model.trianglePointsY[var22] && (model.texTriangleZ[var21] & '\uffff') == model.trianglePointsZ[var22])
|
||||
if ((model.textureTriangleVertexIndices1[var21] & '\uffff') == model.faceVertexIndices1[var22] && (model.textureTriangleVertexIndices2[var21] & '\uffff') == model.faceVertexIndices2[var22] && (model.textureTriangleVertexIndices3[var21] & '\uffff') == model.faceVertexIndices3[var22])
|
||||
{
|
||||
model.textureCoords[var22] = -1;
|
||||
model.textureCoordinates[var22] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -730,7 +730,7 @@ public class ModelLoader
|
||||
|
||||
if (!var45)
|
||||
{
|
||||
model.textureCoords = null;
|
||||
model.textureCoordinates = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -741,7 +741,7 @@ public class ModelLoader
|
||||
|
||||
if (!var2)
|
||||
{
|
||||
model.faceRenderType = null;
|
||||
model.faceRenderTypes = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,19 +33,20 @@ public class NpcLoader
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(NpcLoader.class);
|
||||
|
||||
public NpcDefinition load(int id, InputStream stream)
|
||||
public NpcDefinition load(int id, byte[] b)
|
||||
{
|
||||
NpcDefinition def = new NpcDefinition(id);
|
||||
InputStream is = new InputStream(b);
|
||||
|
||||
while (true)
|
||||
{
|
||||
int opcode = stream.readUnsignedByte();
|
||||
int opcode = is.readUnsignedByte();
|
||||
if (opcode == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
this.decodeValues(opcode, def, stream);
|
||||
this.decodeValues(opcode, def, is);
|
||||
}
|
||||
|
||||
return def;
|
||||
|
||||
@@ -33,19 +33,20 @@ public class SequenceLoader
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(SequenceLoader.class);
|
||||
|
||||
public SequenceDefinition load(int id, InputStream stream)
|
||||
public SequenceDefinition load(int id, byte[] b)
|
||||
{
|
||||
SequenceDefinition def = new SequenceDefinition(id);
|
||||
InputStream is = new InputStream(b);
|
||||
|
||||
while (true)
|
||||
{
|
||||
int opcode = stream.readUnsignedByte();
|
||||
int opcode = is.readUnsignedByte();
|
||||
if (opcode == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
this.decodeValues(opcode, def, stream);
|
||||
this.decodeValues(opcode, def, is);
|
||||
}
|
||||
|
||||
return def;
|
||||
|
||||
@@ -33,20 +33,21 @@ public class SpotAnimLoader
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(SpotAnimLoader.class);
|
||||
|
||||
public SpotAnimDefinition load(int id, InputStream stream)
|
||||
public SpotAnimDefinition load(int id, byte[] b)
|
||||
{
|
||||
SpotAnimDefinition def = new SpotAnimDefinition();
|
||||
InputStream is = new InputStream(b);
|
||||
def.id = id;
|
||||
|
||||
while (true)
|
||||
{
|
||||
int opcode = stream.readUnsignedByte();
|
||||
int opcode = is.readUnsignedByte();
|
||||
if (opcode == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
this.decodeValues(opcode, def, stream);
|
||||
this.decodeValues(opcode, def, is);
|
||||
}
|
||||
|
||||
return def;
|
||||
|
||||
@@ -33,22 +33,24 @@ public class SpriteLoader
|
||||
public static final int FLAG_VERTICAL = 0b01;
|
||||
public static final int FLAG_ALPHA = 0b10;
|
||||
|
||||
public SpriteDefinition[] load(int id, InputStream stream)
|
||||
public SpriteDefinition[] load(int id, byte[] b)
|
||||
{
|
||||
stream.setOffset(stream.getLength() - 2);
|
||||
int spriteCount = stream.readUnsignedShort();
|
||||
InputStream is = new InputStream(b);
|
||||
|
||||
is.setOffset(is.getLength() - 2);
|
||||
int spriteCount = is.readUnsignedShort();
|
||||
|
||||
SpriteDefinition[] sprites = new SpriteDefinition[spriteCount];
|
||||
|
||||
// 2 for size
|
||||
// 5 for width, height, palette length
|
||||
// + 8 bytes per sprite for offset x/y, width, and height
|
||||
stream.setOffset(stream.getLength() - 7 - spriteCount * 8);
|
||||
is.setOffset(is.getLength() - 7 - spriteCount * 8);
|
||||
|
||||
// max width and height
|
||||
int width = stream.readUnsignedShort();
|
||||
int height = stream.readUnsignedShort();
|
||||
int paletteLength = stream.readUnsignedByte() + 1;
|
||||
int width = is.readUnsignedShort();
|
||||
int height = is.readUnsignedShort();
|
||||
int paletteLength = is.readUnsignedByte() + 1;
|
||||
|
||||
for (int i = 0; i < spriteCount; ++i)
|
||||
{
|
||||
@@ -61,31 +63,31 @@ public class SpriteLoader
|
||||
|
||||
for (int i = 0; i < spriteCount; ++i)
|
||||
{
|
||||
sprites[i].setOffsetX(stream.readUnsignedShort());
|
||||
sprites[i].setOffsetX(is.readUnsignedShort());
|
||||
}
|
||||
|
||||
for (int i = 0; i < spriteCount; ++i)
|
||||
{
|
||||
sprites[i].setOffsetY(stream.readUnsignedShort());
|
||||
sprites[i].setOffsetY(is.readUnsignedShort());
|
||||
}
|
||||
|
||||
for (int i = 0; i < spriteCount; ++i)
|
||||
{
|
||||
sprites[i].setWidth(stream.readUnsignedShort());
|
||||
sprites[i].setWidth(is.readUnsignedShort());
|
||||
}
|
||||
|
||||
for (int i = 0; i < spriteCount; ++i)
|
||||
{
|
||||
sprites[i].setHeight(stream.readUnsignedShort());
|
||||
sprites[i].setHeight(is.readUnsignedShort());
|
||||
}
|
||||
|
||||
// same as above + 3 bytes for each palette entry, except for the first one (which is transparent)
|
||||
stream.setOffset(stream.getLength() - 7 - spriteCount * 8 - (paletteLength - 1) * 3);
|
||||
is.setOffset(is.getLength() - 7 - spriteCount * 8 - (paletteLength - 1) * 3);
|
||||
int[] palette = new int[paletteLength];
|
||||
|
||||
for (int i = 1; i < paletteLength; ++i)
|
||||
{
|
||||
palette[i] = stream.read24BitInt();
|
||||
palette[i] = is.read24BitInt();
|
||||
|
||||
if (palette[i] == 0)
|
||||
{
|
||||
@@ -93,7 +95,7 @@ public class SpriteLoader
|
||||
}
|
||||
}
|
||||
|
||||
stream.setOffset(0);
|
||||
is.setOffset(0);
|
||||
|
||||
for (int i = 0; i < spriteCount; ++i)
|
||||
{
|
||||
@@ -104,14 +106,14 @@ public class SpriteLoader
|
||||
byte[] pixelPaletteIndicies = new byte[dimension];
|
||||
byte[] pixelAlphas = new byte[dimension];
|
||||
|
||||
int flags = stream.readUnsignedByte();
|
||||
int flags = is.readUnsignedByte();
|
||||
|
||||
if ((flags & FLAG_VERTICAL) == 0)
|
||||
{
|
||||
// read horizontally
|
||||
for (int j = 0; j < dimension; ++j)
|
||||
{
|
||||
pixelPaletteIndicies[j] = stream.readByte();
|
||||
pixelPaletteIndicies[j] = is.readByte();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -121,7 +123,7 @@ public class SpriteLoader
|
||||
{
|
||||
for (int k = 0; k < spriteHeight; ++k)
|
||||
{
|
||||
pixelPaletteIndicies[spriteWidth * k + j] = stream.readByte();
|
||||
pixelPaletteIndicies[spriteWidth * k + j] = is.readByte();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +136,7 @@ public class SpriteLoader
|
||||
// read horizontally
|
||||
for (int j = 0; j < dimension; ++j)
|
||||
{
|
||||
pixelAlphas[j] = stream.readByte();
|
||||
pixelAlphas[j] = is.readByte();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -144,7 +146,7 @@ public class SpriteLoader
|
||||
{
|
||||
for (int k = 0; k < spriteHeight; ++k)
|
||||
{
|
||||
pixelAlphas[spriteWidth * k + j] = stream.readByte();
|
||||
pixelAlphas[spriteWidth * k + j] = is.readByte();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,19 +49,19 @@ public class ObjExporter
|
||||
|
||||
for (int i = 0; i < model.vertexCount; ++i)
|
||||
{
|
||||
objWriter.println(" v " + model.vertexX[i] + " " + model.vertexY[i] + " " + model.vertexZ[i]);
|
||||
objWriter.println(" v " + model.vertexPositionsX[i] + " " + model.vertexPositionsY[i] + " " + model.vertexPositionsZ[i]);
|
||||
}
|
||||
|
||||
for (VertexNormal normal : model.normals)
|
||||
for (VertexNormal normal : model.vertexNormals)
|
||||
{
|
||||
objWriter.println(" vn " + normal.x + " " + normal.y + " " + normal.z);
|
||||
}
|
||||
|
||||
Set<Integer> usedMaterials = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < model.triangleFaceCount; ++i)
|
||||
for (int i = 0; i < model.faceCount; ++i)
|
||||
{
|
||||
Color color = rs2hsbToColor(model.faceColor[i]);
|
||||
Color color = rs2hsbToColor(model.faceColors[i]);
|
||||
|
||||
int alpha = 0;
|
||||
|
||||
@@ -73,9 +73,9 @@ public class ObjExporter
|
||||
int rgba = color.getRGB() << 8 | alpha;
|
||||
|
||||
objWriter.println(" usemtl color" + rgba);
|
||||
objWriter.println(" f " + (model.trianglePointsX[i] + 1) + "//" + (model.trianglePointsX[i] + 1) +
|
||||
" " + (model.trianglePointsY[i] + 1) + "//" + (model.trianglePointsY[i] + 1) +
|
||||
" " + (model.trianglePointsZ[i] + 1) + "//" + (model.trianglePointsZ[i] + 1));
|
||||
objWriter.println(" f " + (model.faceVertexIndices1[i] + 1) + "//" + (model.faceVertexIndices1[i] + 1) +
|
||||
" " + (model.faceVertexIndices2[i] + 1) + "//" + (model.faceVertexIndices2[i] + 1) +
|
||||
" " + (model.faceVertexIndices3[i] + 1) + "//" + (model.faceVertexIndices3[i] + 1));
|
||||
objWriter.println("");
|
||||
|
||||
// Write material
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SequenceDumper
|
||||
for (File file : archive.getFiles())
|
||||
{
|
||||
SequenceLoader loader = new SequenceLoader();
|
||||
SequenceDefinition seq = loader.load(file.getFileId(), new InputStream(file.getContents()));
|
||||
SequenceDefinition seq = loader.load(file.getFileId(), file.getContents());
|
||||
|
||||
Files.write(gson.toJson(seq), new java.io.File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
|
||||
++count;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class SpriteDumperTest
|
||||
byte[] contents = file.getContents();
|
||||
|
||||
SpriteLoader loader = new SpriteLoader();
|
||||
SpriteDefinition[] sprites = loader.load(a.getArchiveId(), new InputStream(contents));
|
||||
SpriteDefinition[] sprites = loader.load(a.getArchiveId(), contents);
|
||||
|
||||
for (SpriteDefinition def : sprites)
|
||||
{
|
||||
|
||||
@@ -247,15 +247,15 @@ public class ModelViewer
|
||||
|
||||
private static void drawModel(ModelDefinition md, short[] recolourToFind, short[] recolourToReplace)
|
||||
{
|
||||
for (int i = 0; i < md.triangleFaceCount; ++i)
|
||||
for (int i = 0; i < md.faceCount; ++i)
|
||||
{
|
||||
int vertexA = md.trianglePointsX[i];
|
||||
int vertexB = md.trianglePointsY[i];
|
||||
int vertexC = md.trianglePointsZ[i];
|
||||
int vertexA = md.faceVertexIndices1[i];
|
||||
int vertexB = md.faceVertexIndices2[i];
|
||||
int vertexC = md.faceVertexIndices3[i];
|
||||
|
||||
VertexNormal normalVertexA = md.normals[vertexA];
|
||||
VertexNormal normalVertexB = md.normals[vertexB];
|
||||
VertexNormal normalVertexC = md.normals[vertexC];
|
||||
VertexNormal normalVertexA = md.vertexNormals[vertexA];
|
||||
VertexNormal normalVertexB = md.vertexNormals[vertexB];
|
||||
VertexNormal normalVertexC = md.vertexNormals[vertexC];
|
||||
|
||||
Vector3f nA = normalVertexA.normalize();
|
||||
Vector3f nB = normalVertexB.normalize();
|
||||
@@ -266,19 +266,19 @@ public class ModelViewer
|
||||
nB.y = -nB.y;
|
||||
nC.y = -nC.y;
|
||||
|
||||
int vertexAx = md.vertexX[vertexA];
|
||||
int vertexAy = md.vertexY[vertexA];
|
||||
int vertexAz = md.vertexZ[vertexA];
|
||||
int vertexAx = md.vertexPositionsX[vertexA];
|
||||
int vertexAy = md.vertexPositionsY[vertexA];
|
||||
int vertexAz = md.vertexPositionsZ[vertexA];
|
||||
|
||||
int vertexBx = md.vertexX[vertexB];
|
||||
int vertexBy = md.vertexY[vertexB];
|
||||
int vertexBz = md.vertexZ[vertexB];
|
||||
int vertexBx = md.vertexPositionsX[vertexB];
|
||||
int vertexBy = md.vertexPositionsY[vertexB];
|
||||
int vertexBz = md.vertexPositionsZ[vertexB];
|
||||
|
||||
int vertexCx = md.vertexX[vertexC];
|
||||
int vertexCy = md.vertexY[vertexC];
|
||||
int vertexCz = md.vertexZ[vertexC];
|
||||
int vertexCx = md.vertexPositionsX[vertexC];
|
||||
int vertexCy = md.vertexPositionsY[vertexC];
|
||||
int vertexCz = md.vertexPositionsZ[vertexC];
|
||||
|
||||
short hsb = md.faceColor[i];
|
||||
short hsb = md.faceColors[i];
|
||||
|
||||
// Check recolor
|
||||
if (recolourToFind != null)
|
||||
|
||||
Reference in New Issue
Block a user