Guest User

Untitled

a guest
Aug 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. package rs2.config;
  2.  
  3. import rs2.animable.Model;
  4. import rs2.misc.FileOperations;
  5. import rs2.node.MemCache;
  6. import rs2.sign.Signlink;
  7. import rs2.stream.Buffer;
  8. import rs2.stream.JagexArchive;
  9.  
  10. public final class GraphicDefinition {
  11.  
  12.  
  13. public static void unpackConfig(JagexArchive streamLoader)
  14. {
  15. Buffer stream = new Buffer(FileOperations.ReadFile(Signlink.findcachedir() + "spotanim.dat"));
  16. int totalGfx = stream.readUnsignedWord();
  17. if(cache == null)
  18. cache = new GraphicDefinition[totalGfx];
  19. System.out.println("Gfx Amount: " + totalGfx);
  20. for(int j = 0; j < totalGfx; j++)
  21. {
  22. if(cache[j] == null)
  23. cache[j] = new GraphicDefinition();
  24. cache[j].anInt404 = j;
  25. cache[j].readValues(stream);
  26. }
  27. cache[726].modelId = 12411;
  28. }
  29.  
  30.  
  31. private void readValues(Buffer stream) {
  32. do
  33. {
  34. int opcode = stream.readUnsignedByte();
  35. if(opcode == 0)
  36. return;
  37. if(opcode == 1)
  38. modelId = stream.readUnsignedWord();
  39. else if(opcode == 2) {
  40. animId = stream.readUnsignedWord();
  41. if (AnimationDefinition.anims != null && animId != 65535 && animId != -1) {
  42. if(animId > AnimationDefinition.anims.length) {
  43. animationSequence = AnimationDefinition.anims[0];
  44. } else {
  45. animationSequence = AnimationDefinition.anims[animId];
  46. }
  47. }
  48. } else if(opcode == 3)
  49. scaleModelWidth = stream.readUnsignedByte();
  50. else if(opcode == 4)
  51. scaleModelHeight = stream.readUnsignedByte();
  52. else
  53. if(opcode >= 40 && opcode < 50)
  54. modifiedModelColours[opcode - 40] = stream.readUnsignedWord();
  55. else
  56. if(opcode >= 50 && opcode < 60)
  57. originalModelColours[opcode - 50] = stream.readUnsignedWord();
  58. else if(opcode == 5)
  59. modelBrightness = stream.readUnsignedByte();
  60. else if(opcode == 6)
  61. modelShadow = stream.readUnsignedByte();
  62. else if(opcode == 7)
  63. rotation = stream.readUnsignedWord();
  64. else
  65. System.out.println("Error unrecognised spotanim config code: " + opcode);
  66. } while(true);
  67. }
  68.  
  69. public Model getModel()
  70. {
  71. Model model = (Model) modelCache.get(anInt404);
  72. if(model != null)
  73. return model;
  74. model = Model.getModel(modelId);
  75. if(model == null)
  76. return null;
  77. for(int i = 0; i < 6; i++)
  78. if(originalModelColours[0] != 0)
  79. model.method476(originalModelColours[i], modifiedModelColours[i]);
  80.  
  81. modelCache.put(model, anInt404);
  82. return model;
  83. }
  84.  
  85. private GraphicDefinition()
  86. {
  87. anInt400 = 9;
  88. animId = -1;
  89. originalModelColours = new int[6];
  90. modifiedModelColours = new int[6];
  91. scaleModelWidth = 128;
  92. scaleModelHeight = 128;
  93. }
  94.  
  95. private final int anInt400;
  96. public static GraphicDefinition cache[];
  97. private int anInt404;
  98. public int modelId;
  99. public int animId;
  100. public AnimationDefinition animationSequence;
  101. public int[] originalModelColours;
  102. public int[] modifiedModelColours;
  103. public int scaleModelWidth;
  104. public int scaleModelHeight;
  105. public int rotation;
  106. public int modelBrightness;
  107. public int modelShadow;
  108. public static MemCache modelCache = new MemCache(30);
  109.  
  110. }
Add Comment
Please, Sign In to add comment