BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Properties | List of all members
BrawlLib.SSBB.ResourceNodes.HavokNode Class Reference
Inheritance diagram for BrawlLib.SSBB.ResourceNodes.HavokNode:
BrawlLib.SSBB.ResourceNodes.ARCEntryNode BrawlLib.SSBB.ResourceNodes.U8EntryNode BrawlLib.SSBB.ResourceNodes.ResourceNode

Public Member Functions

override bool OnInitialize ()
 
override void OnPopulate ()
 
HavokClassNode GetClassNode (string className, bool searchClasses=true)
 
override void Export (string outPath)
 
override int OnCalculateSize (bool force)
 
override void OnRebuild (VoidPtr address, int length, bool force)
 
override void Replace (string fileName, FileMapProtect prot, FileOptions options)
 
bool IsValid ()
 
VoidPtr GetAddress ()
 
int GetLength ()
 
- Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ARCEntryNode
bool isModelData ()
 
bool isTextureData ()
 
void UpdateName ()
 
override void Initialize (ResourceNode parent, DataSource origSource, DataSource uncompSource)
 
override bool OnInitialize ()
 
- Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
void OnRenamed ()
 
List< ResourceNodeGetChildrenRecursive ()
 Used primarily to get bone lists. Kept for all resource nodes for utility. More...
 
virtual void SignalPropertyChange ()
 
virtual void Dispose ()
 
void SelectChildAtIndex (int index)
 
void UpdateProperties ()
 
void UpdateCurrentControl ()
 
virtual bool MoveUp ()
 
virtual bool MoveDown ()
 
virtual void OnMoved ()
 
virtual void DoMoveDown ()
 
virtual void DoMoveDown (bool select)
 
virtual void DoMoveUp ()
 
virtual void DoMoveUp (bool select)
 
virtual bool AddUp ()
 
virtual bool AddDown ()
 
virtual bool ToParent ()
 
void Populate (int levels=-1)
 
virtual void OnPopulate ()
 
void Initialize (ResourceNode parent, FileMap source)
 
void Initialize (ResourceNode parent, VoidPtr address, int length)
 
void Initialize (ResourceNode parent, DataSource origSource)
 
virtual void Initialize (ResourceNode parent, DataSource origSource, DataSource uncompSource)
 
virtual bool OnInitialize ()
 
virtual void Restore ()
 
virtual void Remove ()
 
virtual void RemoveChild (ResourceNode child)
 
virtual void AddChild (ResourceNode child)
 
virtual void AddChild (ResourceNode child, bool change)
 
virtual void InsertChild (ResourceNode child, int index)
 
virtual void InsertChild (ResourceNode child, bool change, int index)
 
void SetSizeInternal (int size)
 
virtual void Replace (string fileName)
 
virtual void Replace (ResourceNode node)
 
virtual void Replace (string fileName, FileMapProtect prot, FileOptions options)
 
virtual void ReplaceRaw (VoidPtr address, int length)
 
virtual void ReplaceRaw (FileMap map)
 
virtual void Export (string outPath)
 
void Export (FileStream outStream)
 
virtual void ExportUncompressed (string outPath)
 
void ExportUncompressed (FileStream outStream)
 
virtual void Rebuild ()
 
virtual void Rebuild (bool force)
 
virtual void Rebuild (VoidPtr address, int length, bool force)
 
virtual void OnRebuild (VoidPtr address, int length, bool force)
 
virtual int CalculateSize (bool force)
 
virtual int OnCalculateSize (bool force)
 
void Merge ()
 
void Merge (bool forceBuild)
 
ResourceNode FindChildByType (string path, bool searchChildren, params ResourceType[] types)
 
ResourceNode FindChildByType (string path, bool searchChildren, StringComparison compare, params ResourceType[] types)
 
ResourceNode FindChild (string path)
 
ResourceNode FindChild (string path, bool searchChildren)
 
ResourceNode FindChild (string path, StringComparison compare)
 
ResourceNode FindChild (string path, bool searchChildren, StringComparison compare)
 
ResourceNode[] FindChildrenByClassType (string path, Type type)
 
ResourceNode[] FindChildrenByType (string path, ResourceType type)
 
ResourceNode[] FindChildrenByTypeInGroup (string path, ResourceType type, byte group)
 
ResourceNode[] FindChildrenByName (string name)
 
unsafe string FindName (string name)
 
ResourceNode FindEmbeddedIndex (int index)
 
virtual unsafe byte[] MD5 ()
 Find the MD5 checksum of this node's data. If this node doesn't have any data (BRESGroupNode, for example), this method will return null. More...
 
string MD5Str ()
 Get the result of the MD5() function as a string of hexadecimal digits. If MD5() returns null, this method will return an empty string. More...
 
ResourceNode PrevSibling ()
 
ResourceNode NextSibling ()
 
override string ToString ()
 
virtual void SortChildren ()
 

Public Attributes

Dictionary< string, uint > _mainTypeSignatures
 
Dictionary< string, uint > _mainDataSignatures
 
Dictionary< string, uint > _allSignatures
 
string _versionString
 
string _rootClass
 
UnsafeBuffer _buffer
 
HavokSectionNode _dataSection
 
- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.ARCEntryNode
ResourceType _resourceType = ResourceType.ARCEntry
 
- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.U8EntryNode
int _u8Parent
 
int _u8FirstNotChild
 
int _u8Type
 
int _u8Index
 
- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
Form _mainForm
 
string _name
 
string _origPath
 
ResourceNode _parent
 
List< ResourceNode_children = new List<ResourceNode>()
 
int _calcSize
 
EventHandler UpdateControl
 
MoveEventHandler MovedDown
 
ResourceEventHandler Renamed
 
ResourceEventHandler PropertyChanged
 
ResourceEventHandler Replaced
 
ResourceEventHandler Restored
 
ResourceChildEventHandler ChildRemoved
 
bool _isPopulating
 
bool _replaced
 

Static Public Attributes

const bool AssignClassParents = true
 

Protected Member Functions

override string GetName ()
 
- Protected Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ARCEntryNode
virtual string GetName ()
 
virtual string GetName (string fileType)
 
- Protected Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
void ForceReplacedEvent ()
 
virtual void MergeInternal ()
 

Properties

override ResourceType ResourceFileType [get]
 
override bool supportsCompression [get]
 
int UserTag [get]
 
int Version [get]
 
string VersionString [get]
 
string RootClass [get]
 
Dictionary< string, uint > MainTypeSignatures [get]
 
Dictionary< string, uint > MainDataSignatures [get]
 
Dictionary< string, uint > AllSignatures [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.ARCEntryNode
override ResourceType ResourceFileType [get]
 
override string Compression [get, set]
 
ARCFileType FileType [get, set]
 
short FileIndex [get, set]
 
byte GroupID [get, set]
 
int AbsoluteIndex [get]
 
short RedirectIndex [get, set]
 
string RedirectTargetName [get]
 
string RedirectTarget [get, set]
 
ResourceNode RedirectNode [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.U8EntryNode
int ParentIndex [get]
 
int ChildEndIndex [get]
 
int Type [get]
 
int ID [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
string FilePath [get]
 
string FileName [get]
 
string DirectoryName [get]
 
ResourceNode RootNode [get]
 
DataSource OriginalSource [get]
 
DataSource UncompressedSource [get]
 
DataSource WorkingSource [get]
 
DataSource WorkingUncompressed [get]
 
virtual bool HasChildren [get]
 
virtual ResourceType ResourceFileType [get]
 
string NodeType [get]
 
virtual string TreePathAbsolute [get]
 
virtual string TreePath [get]
 
virtual int Level [get]
 
virtual int MaxNameLength [get]
 
virtual bool AllowDuplicateNames [get]
 
virtual bool AllowNullNames [get]
 
virtual string Name [get, set]
 
ResourceNode Parent [get, set]
 
List< ResourceNodeChildren [get]
 
int Index [get]
 
int HexIndex [get]
 
bool IsCompressed [get]
 
bool HasChanged [get, set]
 
bool IsBranch [get]
 
bool HasMerged [get]
 
virtual bool AllowSaving [get, set]
 
virtual bool IsDirty [get, set]
 
virtual uint UncompressedSize [get]
 
virtual Type[] AllowedChildTypes [get]
 
virtual string Compression [get, set]
 
virtual bool RetainChildrenOnReplace [get]
 
virtual bool supportsCompression [get]
 
static MD5CryptoServiceProvider MD5Provider [get]
 

Additional Inherited Members

- Static Public Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
static ResourceNode[] FindAllSubNodes (ResourceNode root)
 
static ResourceNode FindNode (ResourceNode root, string path, bool searchChildren, StringComparison compare)
 
- Protected Attributes inherited from BrawlLib.SSBB.ResourceNodes.ARCEntryNode
ResourceNode redirectTargetNode
 
- Events inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
SelectEventHandler SelectChild
 
EventHandler UpdateProps
 
MoveEventHandler MovedUp
 
ResourceEventHandler Disposing
 
ResourceChildEventHandler ChildAdded
 
ResourceChildInsertEventHandler ChildInserted
 

Member Function Documentation

◆ Export()

override void BrawlLib.SSBB.ResourceNodes.HavokNode.Export ( string  outPath)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

359 {
360 if (outPath.ToUpper().EndsWith(".XML"))
361 {
362 HavokXML.Serialize(this, outPath);
363 }
364 //else if (outPath.ToUpper().EndsWith(".PMD"))
365 // PMDModel.Export(this, outPath);
366 //else if (outPath.ToUpper().EndsWith(".RMDL"))
367 // XMLExporter.ExportRMDL(this, outPath);
368 else
369 {
370 base.Export(outPath);
371 }
372 }

◆ GetAddress()

VoidPtr BrawlLib.SSBB.ResourceNodes.HavokNode.GetAddress ( )
inline
420 {
421 return _buffer.Address;
422 }
VoidPtr Address
Definition: UnsafeBuffer.cs:9
UnsafeBuffer _buffer
Definition: HavokNode.cs:42

◆ GetClassNode()

HavokClassNode BrawlLib.SSBB.ResourceNodes.HavokNode.GetClassNode ( string  className,
bool  searchClasses = true 
)
inline
320 {
321 HavokClassNode e = null;
322 if (_classNodeTypes.ContainsKey(className))
323 {
324 e = Activator.CreateInstance(_classNodeTypes[className]) as HavokClassNode;
325 }
326
327 if (e == null && searchClasses)
328 {
329 foreach (HavokSectionNode section in Children)
330 {
331 if (section._classCache != null)
332 {
333 foreach (HavokClassNode c in section._classCache)
334 {
335 if (c.Name == className)
336 {
337 e = c;
338 break;
339 }
340 }
341 }
342
343 if (e != null)
344 {
345 break;
346 }
347 }
348 }
349
350 if (e == null)
351 {
352 Console.WriteLine("Unsupported class type: " + className);
353 }
354
355 return e;
356 }
List< ResourceNode > Children
Definition: ResourceNode.cs:262

◆ GetLength()

int BrawlLib.SSBB.ResourceNodes.HavokNode.GetLength ( )
inline
425 {
426 return _buffer.Length;
427 }
int Length
Definition: UnsafeBuffer.cs:14

◆ GetName()

override string BrawlLib.SSBB.ResourceNodes.HavokNode.GetName ( )
inlineprotectedvirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ARCEntryNode.

21 {
22 return base.GetName("HavokData");
23 }

◆ IsValid()

bool BrawlLib.SSBB.ResourceNodes.HavokNode.IsValid ( )
inline
415 {
416 return _buffer != null && _buffer.Length > 0 && _buffer.Address != null;
417 }

◆ OnCalculateSize()

override int BrawlLib.SSBB.ResourceNodes.HavokNode.OnCalculateSize ( bool  force)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

375 {
376 return _buffer.Length;
377 }

◆ OnInitialize()

override bool BrawlLib.SSBB.ResourceNodes.HavokNode.OnInitialize ( )
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.U8EntryNode.

46 {
47 _userTag = Header->_userTag;
48 _version = Header->_classVersion;
49 _versionString = Header->Name;
50
51 _mainTypeSignatures = new Dictionary<string, uint>();
52 _mainDataSignatures = new Dictionary<string, uint>();
53 _allSignatures = new Dictionary<string, uint>();
54
55 PatchPointers();
56
57 PhysicsOffsetSection* section = Header->OffsetSections;
58 sbyte* classNames = (sbyte*) (_buffer.Address + section[Header->_classNameSectionIndex]._dataOffset);
59 _rootClass = new string(classNames + Header->_rootClassNameOffset);
60
61 return true;
62 }
Dictionary< string, uint > _mainDataSignatures
Definition: HavokNode.cs:35
Dictionary< string, uint > _allSignatures
Definition: HavokNode.cs:36
string _versionString
Definition: HavokNode.cs:39
Dictionary< string, uint > _mainTypeSignatures
Definition: HavokNode.cs:34
string _rootClass
Definition: HavokNode.cs:40
buint _rootClassNameOffset
Definition: HKX.cs:35
bint _classNameSectionIndex
Definition: HKX.cs:31
PhysicsOffsetSection * OffsetSections
Definition: HKX.cs:47
bint _userTag
Definition: HKX.cs:15
bint _classVersion
Definition: HKX.cs:16
string Name
Definition: HKX.cs:60

◆ OnPopulate()

override void BrawlLib.SSBB.ResourceNodes.HavokNode.OnPopulate ( )
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

127 {
128 HKXHeader* header = (HKXHeader*) _buffer.Address;
129 PhysicsOffsetSection* section = header->OffsetSections;
130
131 PhysicsOffsetSection* classes = &section[header->_classNameSectionIndex];
132 sbyte* classNames = (sbyte*) (_buffer.Address + classes->_dataOffset);
133
134 VoidPtr dataAddr = classNames;
135 VoidPtr baseAddr = dataAddr;
136 while (dataAddr - baseAddr < classes->DataLength && *(byte*) (dataAddr + 4) == 9)
137 {
138 uint signature = *(buint*) dataAddr;
139 string c = new string((sbyte*) dataAddr + 5);
140 if (!_allSignatures.ContainsKey(c))
141 {
142 _allSignatures.Add(c, signature);
143 }
144
145 dataAddr += 5 + c.Length + 1;
146 }
147
148 //Types have to be parsed first so that they can be used to parse the data last
149 for (int i = 0; i < header->_sectionCount; i++, section++)
150 {
151 if (i == header->_classNameSectionIndex || i == header->_dataSectionIndex)
152 {
153 continue;
154 }
155
156 int dataOffset = section->_dataOffset;
157 VoidPtr data = _buffer.Address + dataOffset;
158
159 int classNamePatchLength = section->ClassNamePatchesLength;
160 if (classNamePatchLength > 0)
161 {
162 HavokSectionNode sectionNode = new HavokSectionNode
163 {
164 //sectionNode._name = section->Name;
165 _name = "Classes"
166 };
167 sectionNode.Initialize(this, data, section->DataLength);
168
169 //HavokGroupNode classGroup = new HavokGroupNode() { _parent = sectionNode, _name = "Classes" };
170 //sectionNode.Children.Add(classGroup);
171
172 //HavokGroupNode enumGroup = new HavokGroupNode() { _parent = sectionNode, _name = "Enums" };
173 //sectionNode.Children.Add(enumGroup);
174
175 VoidPtr start = data + section->_classNamePatchesOffset;
176 ClassNamePatch* patch = (ClassNamePatch*) start;
177
178 int x = 0;
179 while ((int) patch - (int) start < classNamePatchLength && patch->_dataOffset >= 0)
180 {
181 string className = new string(classNames + patch->_classNameOffset);
182 uint signature = *(buint*) (classNames + (patch->_classNameOffset - 5));
183 if (!_mainTypeSignatures.ContainsKey(className))
184 {
185 _mainTypeSignatures.Add(className, signature);
186 }
187
188 HavokClassNode entry = GetClassNode(className, false);
189 if (entry != null)
190 {
191 entry._signature = signature;
192 entry._className = className;
193 entry.Initialize(sectionNode, data + patch->_dataOffset, 0);
194 }
195
196 patch++;
197 x++;
198 }
199
200 sectionNode._classCache = sectionNode._children.Select(b => b as HavokClassNode).ToList();
202 {
203 sectionNode._children.Clear();
204 for (int r = 0; r < sectionNode._classCache.Count; r++)
205 {
206 HavokClassNode n = sectionNode._classCache[r];
207 if (n == null)
208 {
209 continue;
210 }
211
212 n.Populate(0);
213 n._parent = sectionNode;
214 if (n is hkClassNode)
215 {
216 hkClassNode c = n as hkClassNode;
217 if (!string.IsNullOrEmpty(c.ParentClass))
218 {
219 for (int w = 0; w < sectionNode._classCache.Count; w++)
220 {
221 HavokClassNode n2 = sectionNode._classCache[w];
222 if (w != r && n2 is hkClassNode && n2.Name == c.ParentClass)
223 {
224 n._parent = n2;
225 }
226 }
227 }
228 }
229 }
230
231 foreach (HavokClassNode n in sectionNode._classCache)
232 {
233 if (n == null)
234 {
235 continue;
236 }
237
238 if (n._parent._children == null)
239 {
240 n._parent._children = new List<ResourceNode>();
241 }
242
243 n._parent._children.Add(n);
244 }
245 }
246
247 foreach (HavokClassNode classNode in sectionNode._classCache)
248 {
249 if (classNode is hkClassNode)
250 {
251 hkClassNode c = classNode as hkClassNode;
252 c.GetInheritance();
253 }
254 }
255 }
256 }
257
258 //Parse data using class types, unless the data is explicitly supported
259 if (header->_dataSectionIndex >= 0)
260 {
261 section = &header->OffsetSections[header->_dataSectionIndex];
262 int dataOffset = section->_dataOffset;
263 VoidPtr data = _buffer.Address + dataOffset;
264
265 int classNamePatchLength = section->ClassNamePatchesLength;
266 if (classNamePatchLength > 0)
267 {
268 HavokSectionNode sectionNode = new HavokSectionNode
269 {
270 //sectionNode._name = section->Name;
271 _name = "Instances"
272 };
273 sectionNode.Initialize(this, data, section->DataLength);
274 sectionNode._classCache = new List<HavokClassNode>();
275 _dataSection = sectionNode;
276
277 uint rootOffset = header->_rootClassNameOffset;
278
279 VoidPtr start = data + section->_classNamePatchesOffset;
280 ClassNamePatch* patch = (ClassNamePatch*) start;
281
282 int x = 0;
283 while ((int) patch - (int) start < classNamePatchLength && patch->_dataOffset >= 0)
284 {
285 string className = new string(classNames + patch->_classNameOffset);
286 uint signature = *(buint*) (classNames + (patch->_classNameOffset - 5));
287
288 if (!_mainDataSignatures.ContainsKey(className))
289 {
290 _mainDataSignatures.Add(className, signature);
291 }
292
293 HavokClassNode entry = GetClassNode(className);
294 if (entry != null && patch->_classNameOffset == rootOffset)
295 {
296 new HavokMetaObjectNode(entry as hkClassNode) {_signature = signature}
297 .Initialize(sectionNode, data + patch->_dataOffset, 0);
298 }
299
300 patch++;
301 x++;
302 }
303 }
304 }
305 }
HavokClassNode GetClassNode(string className, bool searchClasses=true)
Definition: HavokNode.cs:319
HavokSectionNode _dataSection
Definition: HavokNode.cs:43
const bool AssignClassParents
Definition: HavokNode.cs:14
string _name
Definition: ResourceNode.cs:139
Definition: VoidPtr.cs:9
Definition: BigEndianTypes.cs:59
bint _classNameOffset
Definition: HKX.cs:171
bint _dataOffset
Definition: HKX.cs:166
Definition: HKX.cs:9
bint _dataSectionIndex
Definition: HKX.cs:27
bint _sectionCount
Definition: HKX.cs:24
bint _dataOffset
Definition: HKX.cs:73

◆ OnRebuild()

override void BrawlLib.SSBB.ResourceNodes.HavokNode.OnRebuild ( VoidPtr  address,
int  length,
bool  force 
)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

380 {
381 Memory.Move(address, WorkingUncompressed.Address, (uint) length);
382 foreach (HavokEntryNode r in Children)
383 {
384 RecursiveRebuild(r, address);
385 }
386 }
Definition: Memory.cs:8
static void Move(VoidPtr dst, VoidPtr src, uint size)
Definition: Memory.cs:9
DataSource WorkingUncompressed
Definition: ResourceNode.cs:183
VoidPtr Address
Definition: ResourceNode.cs:31

◆ Replace()

override void BrawlLib.SSBB.ResourceNodes.HavokNode.Replace ( string  fileName,
FileMapProtect  prot,
FileOptions  options 
)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

405 {
406 base.Replace(fileName, prot, options);
407 }

Member Data Documentation

◆ _allSignatures

Dictionary<string, uint> BrawlLib.SSBB.ResourceNodes.HavokNode._allSignatures

◆ _buffer

UnsafeBuffer BrawlLib.SSBB.ResourceNodes.HavokNode._buffer

◆ _dataSection

HavokSectionNode BrawlLib.SSBB.ResourceNodes.HavokNode._dataSection

◆ _mainDataSignatures

Dictionary<string, uint> BrawlLib.SSBB.ResourceNodes.HavokNode._mainDataSignatures

◆ _mainTypeSignatures

Dictionary<string, uint> BrawlLib.SSBB.ResourceNodes.HavokNode._mainTypeSignatures

◆ _rootClass

string BrawlLib.SSBB.ResourceNodes.HavokNode._rootClass

◆ _versionString

string BrawlLib.SSBB.ResourceNodes.HavokNode._versionString

◆ AssignClassParents

const bool BrawlLib.SSBB.ResourceNodes.HavokNode.AssignClassParents = true
static

Property Documentation

◆ AllSignatures

Dictionary<string, uint> BrawlLib.SSBB.ResourceNodes.HavokNode.AllSignatures
get

◆ MainDataSignatures

Dictionary<string, uint> BrawlLib.SSBB.ResourceNodes.HavokNode.MainDataSignatures
get

◆ MainTypeSignatures

Dictionary<string, uint> BrawlLib.SSBB.ResourceNodes.HavokNode.MainTypeSignatures
get

◆ ResourceFileType

override ResourceType BrawlLib.SSBB.ResourceNodes.HavokNode.ResourceFileType
get

◆ RootClass

string BrawlLib.SSBB.ResourceNodes.HavokNode.RootClass
get

◆ supportsCompression

override bool BrawlLib.SSBB.ResourceNodes.HavokNode.supportsCompression
get

◆ UserTag

int BrawlLib.SSBB.ResourceNodes.HavokNode.UserTag
get

◆ Version

int BrawlLib.SSBB.ResourceNodes.HavokNode.Version
get

◆ VersionString

string BrawlLib.SSBB.ResourceNodes.HavokNode.VersionString
get

The documentation for this class was generated from the following file: