use of net.runelite.cache.definitions.ObjectDefinition in project runelite by runelite.
the class MapImageDumper method drawObjects.
private void drawObjects(BufferedImage image, int drawBaseX, int drawBaseY, Region region, int z) {
Graphics2D graphics = image.createGraphics();
for (Location location : region.getLocations()) {
int rotation = location.getOrientation();
int type = location.getType();
int localX = location.getPosition().getX() - region.getBaseX();
int localY = location.getPosition().getY() - region.getBaseY();
boolean isBridge = (region.getTileSetting(1, localX, localY) & 2) != 0;
if (location.getPosition().getZ() == z + 1) {
if (!isBridge) {
continue;
}
} else if (location.getPosition().getZ() == z) {
if (isBridge) {
continue;
}
if ((region.getTileSetting(z, localX, localY) & 24) != 0) {
continue;
}
} else {
continue;
}
ObjectDefinition object = findObject(location.getId());
int drawX = (drawBaseX + localX) * MAP_SCALE;
int drawY = (drawBaseY + (Region.Y - 1 - localY)) * MAP_SCALE;
if (type >= 0 && type <= 3) {
// this is a wall
int hash = (localY << 7) + localX + (location.getId() << 14) + 0x4000_0000;
if (object.getAnInt2088() == 0) {
hash -= Integer.MIN_VALUE;
}
int rgb = wallColor;
if (hash > 0) {
rgb = doorColor;
}
if (object.getMapSceneID() != -1) {
Image spriteImage = scaledMapIcons.get(object.getMapSceneID());
graphics.drawImage(spriteImage, drawX * MAP_SCALE, drawY * MAP_SCALE, null);
} else {
if (type == 0 || type == 2) {
if (rotation == 0) {
image.setRGB(drawX + 0, drawY + 0, rgb);
image.setRGB(drawX + 0, drawY + 1, rgb);
image.setRGB(drawX + 0, drawY + 2, rgb);
image.setRGB(drawX + 0, drawY + 3, rgb);
} else if (rotation == 1) {
image.setRGB(drawX + 0, drawY + 0, rgb);
image.setRGB(drawX + 1, drawY + 0, rgb);
image.setRGB(drawX + 2, drawY + 0, rgb);
image.setRGB(drawX + 3, drawY + 0, rgb);
} else if (rotation == 2) {
image.setRGB(drawX + 3, drawY + 0, rgb);
image.setRGB(drawX + 3, drawY + 1, rgb);
image.setRGB(drawX + 3, drawY + 2, rgb);
image.setRGB(drawX + 3, drawY + 3, rgb);
} else if (rotation == 3) {
image.setRGB(drawX + 0, drawY + 3, rgb);
image.setRGB(drawX + 1, drawY + 3, rgb);
image.setRGB(drawX + 2, drawY + 3, rgb);
image.setRGB(drawX + 3, drawY + 3, rgb);
}
}
if (type == 3) {
if (rotation == 0) {
image.setRGB(drawX + 0, drawY + 0, rgb);
} else if (rotation == 1) {
image.setRGB(drawX + 3, drawY + 0, rgb);
} else if (rotation == 2) {
image.setRGB(drawX + 3, drawY + 3, rgb);
} else if (rotation == 3) {
image.setRGB(drawX + 0, drawY + 3, rgb);
}
}
if (type == 2) {
if (rotation == 3) {
image.setRGB(drawX + 0, drawY + 0, rgb);
image.setRGB(drawX + 0, drawY + 1, rgb);
image.setRGB(drawX + 0, drawY + 2, rgb);
image.setRGB(drawX + 0, drawY + 3, rgb);
} else if (rotation == 0) {
image.setRGB(drawX + 0, drawY + 0, rgb);
image.setRGB(drawX + 1, drawY + 0, rgb);
image.setRGB(drawX + 2, drawY + 0, rgb);
image.setRGB(drawX + 3, drawY + 0, rgb);
} else if (rotation == 1) {
image.setRGB(drawX + 3, drawY + 0, rgb);
image.setRGB(drawX + 3, drawY + 1, rgb);
image.setRGB(drawX + 3, drawY + 2, rgb);
image.setRGB(drawX + 3, drawY + 3, rgb);
} else if (rotation == 2) {
image.setRGB(drawX + 0, drawY + 3, rgb);
image.setRGB(drawX + 1, drawY + 3, rgb);
image.setRGB(drawX + 2, drawY + 3, rgb);
image.setRGB(drawX + 3, drawY + 3, rgb);
}
}
}
} else if (type == 9) {
if (object.getMapSceneID() != -1) {
Image spriteImage = scaledMapIcons.get(object.getMapSceneID());
graphics.drawImage(spriteImage, drawX, drawY, null);
continue;
}
int hash = (localY << 7) + localX + (location.getId() << 14) + 0x4000_0000;
if (object.getAnInt2088() == 0) {
hash -= Integer.MIN_VALUE;
}
if ((hash >> 29 & 3) != 2) {
continue;
}
int rgb = 0xEE_EEEE;
if (hash > 0) {
rgb = 0xEE_0000;
}
if (rotation != 0 && rotation != 2) {
image.setRGB(drawX + 0, drawY + 0, rgb);
image.setRGB(drawX + 1, drawY + 1, rgb);
image.setRGB(drawX + 2, drawY + 2, rgb);
image.setRGB(drawX + 3, drawY + 3, rgb);
} else {
image.setRGB(drawX + 0, drawY + 3, rgb);
image.setRGB(drawX + 1, drawY + 2, rgb);
image.setRGB(drawX + 2, drawY + 1, rgb);
image.setRGB(drawX + 3, drawY + 0, rgb);
}
} else if (type == 22 || (type >= 9 && type <= 11)) {
// ground object
if (object.getMapSceneID() != -1) {
Image spriteImage = scaledMapIcons.get(object.getMapSceneID());
graphics.drawImage(spriteImage, drawX, drawY, null);
}
}
}
graphics.dispose();
}
use of net.runelite.cache.definitions.ObjectDefinition in project runelite by runelite.
the class ObjectLoader method load.
public ObjectDefinition load(int id, byte[] b) {
ObjectDefinition def = new ObjectDefinition();
InputStream is = new InputStream(b);
def.setId(id);
for (; ; ) {
int opcode = is.readUnsignedByte();
if (opcode == 0) {
break;
}
processOp(opcode, def, is);
}
post(def);
return def;
}
use of net.runelite.cache.definitions.ObjectDefinition in project runelite by runelite.
the class ObjectManager method java.
public void java(File java) throws IOException {
System.setProperty("line.separator", "\n");
java.mkdirs();
File targ = new File(java, "ObjectID.java");
try (PrintWriter fw = new PrintWriter(targ)) {
fw.println("/* This file is automatically generated. Do not edit. */");
fw.println("package net.runelite.api;");
fw.println("");
fw.println("public final class ObjectID");
fw.println("{");
for (ObjectDefinition def : objects.values()) {
String name;
if (def.getName().equalsIgnoreCase("NULL")) {
name = namer.name("NULL", def.getId());
} else {
name = namer.name(def.getName(), def.getId());
}
if (name == null) {
continue;
}
fw.println(" public static final int " + name + " = " + def.getId() + ";");
}
fw.println("}");
}
}
use of net.runelite.cache.definitions.ObjectDefinition in project runelite by runelite.
the class ObjectManager method load.
public void load() throws IOException {
ObjectLoader loader = new ObjectLoader();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.OBJECT.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile f : files.getFiles()) {
ObjectDefinition def = loader.load(f.getFileId(), f.getContents());
objects.put(f.getFileId(), def);
}
}
use of net.runelite.cache.definitions.ObjectDefinition 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();
}
}
Aggregations