use of net.runelite.cache.region.Position in project runelite by runelite.
the class LocationsLoader method loadLocations.
private void loadLocations(LocationsDefinition loc, byte[] b) {
InputStream buf = new InputStream(b);
int id = -1;
int idOffset;
while ((idOffset = buf.readUnsignedShortSmart()) != 0) {
id += idOffset;
int position = 0;
int positionOffset;
while ((positionOffset = buf.readUnsignedShortSmart()) != 0) {
position += positionOffset - 1;
int localY = position & 0x3F;
int localX = position >> 6 & 0x3F;
int height = position >> 12 & 0x3;
int attributes = buf.readUnsignedByte();
int type = attributes >> 2;
int orientation = attributes & 0x3;
loc.getLocations().add(new Location(id, type, orientation, new Position(localX, localY, height)));
}
}
}
use of net.runelite.cache.region.Position in project runelite by runelite.
the class ModelViewer method drawLocations.
private static void drawLocations(Region region) {
for (Location location : region.getLocations()) {
int id = location.getId();
ObjectDefinition object = getObject(id);
if (object == null || object.getObjectModels() == null) {
continue;
}
Position objectPos = location.getPosition();
if (location.getPosition().getZ() != 0) {
continue;
}
int regionX = objectPos.getX() - region.getBaseX();
int regionY = objectPos.getY() - region.getBaseY();
int height = -region.getTileHeight(objectPos.getZ(), regionX, regionY) / HEIGHT_MOD;
GL11.glMatrixMode(GL11.GL_MODELVIEW);
// TILE_SCALE/2 to draw the object from the center of the tile it is on
GL11.glTranslatef(regionX * TILE_SCALE + (TILE_SCALE / 2), height, -regionY * TILE_SCALE - (TILE_SCALE / 2));
for (int i = 0; i < object.getObjectModels().length; ++i) {
ModelDefinition md = ModelManager.getModel(object.getObjectModels()[i], object, location);
if (object.getObjectTypes() != null && object.getObjectTypes()[i] != location.getType()) {
continue;
}
drawModel(md, object.getRecolorToFind(), object.getRecolorToReplace());
}
GL11.glTranslatef(-regionX * TILE_SCALE - (TILE_SCALE / 2), -height, regionY * TILE_SCALE + (TILE_SCALE / 2));
GL11.glPopMatrix();
}
}
use of net.runelite.cache.region.Position in project runelite by runelite.
the class WorldMapLoader method load.
public WorldMapDefinition load(byte[] b, int fileId) {
WorldMapDefinition def = new WorldMapDefinition();
InputStream in = new InputStream(b);
def.fileId = fileId;
def.safeName = in.readString();
def.name = in.readString();
int packedPos = in.readInt();
if (packedPos == -1) {
def.position = new Position(-1, -1, -1);
} else {
int y = packedPos >> 28 & 3;
int x = packedPos >> 14 & 16383;
int z = packedPos & 16383;
def.position = new Position(x, y, z);
}
def.field450 = in.readInt();
in.readUnsignedByte();
def.field457 = in.readUnsignedByte() == 1;
def.field451 = in.readUnsignedByte();
int var3 = in.readUnsignedByte();
def.field458 = new LinkedList();
for (int var4 = 0; var4 < var3; ++var4) {
def.field458.add(this.loadType(in));
}
return def;
}
Aggregations