2012-11-23 14:26:03 -05:00
|
|
|
[[Category RSC]]
|
|
|
|
|
|
|
|
Work in progress.
|
|
|
|
|
|
|
|
This page refers to .ob3, a custom format for 3D models created by Jagex. It is used by the RuneScape Classic engine.
|
|
|
|
|
2012-11-25 13:36:07 -05:00
|
|
|
<pre>
|
|
|
|
import util.Data;
|
|
|
|
|
|
|
|
public class Ob3Model {
|
|
|
|
public int faceCount;
|
|
|
|
public int vertexCount;
|
|
|
|
|
|
|
|
public int faceVertexCount[];
|
|
|
|
public int faceBack[];
|
|
|
|
public int faceFront[];
|
|
|
|
public int verticesX[];
|
|
|
|
public int verticesZ[];
|
|
|
|
public int verticesY[];
|
|
|
|
|
|
|
|
private static final int trigger = 0xbc614e;
|
|
|
|
|
|
|
|
public Ob3Model(byte data[], int position) {
|
|
|
|
int vertexCount = Data.readInt16(data, position);
|
|
|
|
position += 2;
|
|
|
|
int faceCount = Data.readInt16(data, position);
|
|
|
|
position += 2;
|
|
|
|
|
|
|
|
verticesX = new int[vertexCount];
|
|
|
|
verticesY = new int[vertexCount];
|
|
|
|
verticesZ = new int[vertexCount];
|
|
|
|
|
|
|
|
faceBack = new int[faceCount];
|
|
|
|
faceFront = new int[faceCount];
|
|
|
|
faceVertexCount = new int[faceCount];
|
|
|
|
|
|
|
|
for (int i = 0; i < vertexCount; i++) {
|
|
|
|
verticesX[i] = Data.readSignedInt16(data, position);
|
|
|
|
position += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < vertexCount; i++) {
|
|
|
|
verticesZ[i] = Data.readSignedInt16(data, position);
|
|
|
|
position += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < vertexCount; i++) {
|
|
|
|
verticesY[i] = Data.readSignedInt16(data, position);
|
|
|
|
position += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < faceCount; i++)
|
|
|
|
faceVertexCount[i] = data[position++] & 0xff;
|
|
|
|
|
|
|
|
for (int i = 0; i < faceCount; i++) {
|
|
|
|
faceBack[i] = Data.readSignedInt16(data, position);
|
|
|
|
position += 2;
|
|
|
|
if (faceBack[i] == 32767)
|
|
|
|
faceBack[i] = trigger;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < faceCount; i++) {
|
|
|
|
faceFront[i] = Data.readSignedInt16(data, position);
|
|
|
|
position += 2;
|
|
|
|
if (faceFront[i] == 32767)
|
|
|
|
faceFront[i] = trigger;
|
|
|
|
}
|
|
|
|
|
|
|
|
position += faceCount - 1;
|
|
|
|
|
|
|
|
for (int i = 0; i < faceCount; i++) {
|
|
|
|
for (int j = 0; j < faceVertexCount[i]; j++) {
|
|
|
|
if (vertexCount < 256) {
|
|
|
|
position++;
|
|
|
|
} else {
|
|
|
|
Data.readInt16(data, position);
|
|
|
|
position += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.vertexCount = vertexCount;
|
|
|
|
this.faceCount = faceCount;
|
|
|
|
}
|
|
|
|
}</pre>
|
2012-11-23 14:26:03 -05:00
|
|
|
|
|
|
|
== '''Face sides''' ==
|
|
|
|
|
|
|
|
A '''negative''' face_back or face_front value indicates a '''solid colour''', whereas a '''positive''' value indicates a '''texture'''.
|