Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rs2.config;
- import rs2.animable.Model;
- import rs2.misc.FileOperations;
- import rs2.node.MemCache;
- import rs2.sign.Signlink;
- import rs2.stream.Buffer;
- import rs2.stream.JagexArchive;
- public final class GraphicDefinition {
- public static void unpackConfig(JagexArchive streamLoader)
- {
- Buffer stream = new Buffer(FileOperations.ReadFile(Signlink.findcachedir() + "spotanim.dat"));
- int totalGfx = stream.readUnsignedWord();
- if(cache == null)
- cache = new GraphicDefinition[totalGfx];
- System.out.println("Gfx Amount: " + totalGfx);
- for(int j = 0; j < totalGfx; j++)
- {
- if(cache[j] == null)
- cache[j] = new GraphicDefinition();
- cache[j].anInt404 = j;
- cache[j].readValues(stream);
- }
- cache[726].modelId = 12411;
- }
- private void readValues(Buffer stream) {
- do
- {
- int opcode = stream.readUnsignedByte();
- if(opcode == 0)
- return;
- if(opcode == 1)
- modelId = stream.readUnsignedWord();
- else if(opcode == 2) {
- animId = stream.readUnsignedWord();
- if (AnimationDefinition.anims != null && animId != 65535 && animId != -1) {
- if(animId > AnimationDefinition.anims.length) {
- animationSequence = AnimationDefinition.anims[0];
- } else {
- animationSequence = AnimationDefinition.anims[animId];
- }
- }
- } else if(opcode == 3)
- scaleModelWidth = stream.readUnsignedByte();
- else if(opcode == 4)
- scaleModelHeight = stream.readUnsignedByte();
- else
- if(opcode >= 40 && opcode < 50)
- modifiedModelColours[opcode - 40] = stream.readUnsignedWord();
- else
- if(opcode >= 50 && opcode < 60)
- originalModelColours[opcode - 50] = stream.readUnsignedWord();
- else if(opcode == 5)
- modelBrightness = stream.readUnsignedByte();
- else if(opcode == 6)
- modelShadow = stream.readUnsignedByte();
- else if(opcode == 7)
- rotation = stream.readUnsignedWord();
- else
- System.out.println("Error unrecognised spotanim config code: " + opcode);
- } while(true);
- }
- public Model getModel()
- {
- Model model = (Model) modelCache.get(anInt404);
- if(model != null)
- return model;
- model = Model.getModel(modelId);
- if(model == null)
- return null;
- for(int i = 0; i < 6; i++)
- if(originalModelColours[0] != 0)
- model.method476(originalModelColours[i], modifiedModelColours[i]);
- modelCache.put(model, anInt404);
- return model;
- }
- private GraphicDefinition()
- {
- anInt400 = 9;
- animId = -1;
- originalModelColours = new int[6];
- modifiedModelColours = new int[6];
- scaleModelWidth = 128;
- scaleModelHeight = 128;
- }
- private final int anInt400;
- public static GraphicDefinition cache[];
- private int anInt404;
- public int modelId;
- public int animId;
- public AnimationDefinition animationSequence;
- public int[] originalModelColours;
- public int[] modifiedModelColours;
- public int scaleModelWidth;
- public int scaleModelHeight;
- public int rotation;
- public int modelBrightness;
- public int modelShadow;
- public static MemCache modelCache = new MemCache(30);
- }
Add Comment
Please, Sign In to add comment