Moparscape - RSPS Community

RuneScape 2 Development => RS Client Hacking => Topic started by: Ambokile on November 03, 2014, 07:57:20 PM

Title: [194] Refactored ModelJoint class
Post by: Ambokile on November 03, 2014, 07:57:20 PM
Here is my attempt at refactoring the ModelJoint class. I think this is often called "Skins" in 317 refactors, but I did some research and it seemed to refer to it as joints. This would make sense seeing as the "opcodes" of animations are infact the joint affected  by the transformations.

Code: Java
  1. publicclass ModelJoint {
  2.         publicstatic ModelJoint[] joints;
  3.         publicint count;
  4.         publicint[] transformTypes;
  5.         publicint[][] jointList;
  6.  
  7.         publicstaticvoid load(Archive archive){
  8.                 Stream head =new Stream(archive.getFile(null,
  9.                                 "base_head.dat"));
  10.                 Stream type =new Stream(archive.getFile(null,
  11.                                 "base_type.dat"));
  12.                 Stream label =new Stream(archive.getFile(null,
  13.                                 "base_label.dat"));
  14.                
  15.                 int jointCount = head.getUnsignedLEShort();
  16.                 int highestJointId = head.getUnsignedLEShort();
  17.                
  18.                 joints =new ModelJoint[highestJointId +1];
  19.                 for(int j =0; j < jointCount; j++){
  20.                         int jointId = head.getUnsignedLEShort();
  21.                         int count = head.getUnsignedByte();
  22.                         int[] transformTypes =newint[count];
  23.                         int[][] jointList =newint[count][];
  24.                         for(int joint =0; joint < count; joint++){
  25.                                 transformTypes[joint]= type.getUnsignedByte();
  26.                                 int subJointCount = label.getUnsignedByte();
  27.                                 jointList[joint]=newint[subJointCount];
  28.                                
  29.                                 for(int subJoint =0; subJoint < subJointCount; subJoint++)
  30.                                         jointList[joint][subJoint]= label.getUnsignedByte();
  31.                         }
  32.                         joints[jointId]=new ModelJoint();
  33.                         joints[jointId].count= count;
  34.                         joints[jointId].transformTypes= transformTypes;
  35.                         joints[jointId].jointList= jointList;
  36.                 }
  37.         }
  38. }