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

Public Member Functions

override bool OnInitialize ()
 
override void OnPopulate ()
 
override int OnCalculateSize (bool force)
 
void CalculateCamBoundaries (out float? minX, out float? minY, out float? maxX, out float? maxY)
 
override void OnRebuild (VoidPtr address, int length, bool force)
 
void Render ()
 
Box GetBox ()
 
void MergeWith ()
 
void MergeWith (CollisionNode external)
 
- 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 ()
 

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 Type[] AllowedChildTypes [get]
 
bool IsRendering [get, set]
 
- 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)
 
- 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
 
- 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

◆ CalculateCamBoundaries()

void BrawlLib.SSBB.ResourceNodes.CollisionNode.CalculateCamBoundaries ( out float?  minX,
out float?  minY,
out float?  maxX,
out float?  maxY 
)
inline
70 {
71 minX = null;
72 minY = null;
73 maxX = null;
74 maxY = null;
75 foreach (CollisionObject o in Children)
76 {
77 foreach (CollisionLink l in o._points)
78 {
79 if (minX == null || l.Value._x < minX)
80 {
81 minX = l.Value._x;
82 }
83
84 if (minY == null || l.Value._y < minY)
85 {
86 minY = l.Value._y;
87 }
88
89 if (maxX == null || l.Value._x > maxX)
90 {
91 maxX = l.Value._x;
92 }
93
94 if (maxY == null || l.Value._y > maxY)
95 {
96 maxY = l.Value._y;
97 }
98 }
99 }
100 }
List< ResourceNode > Children
Definition: ResourceNode.cs:262

◆ GetBox()

Box BrawlLib.SSBB.ResourceNodes.CollisionNode.GetBox ( )
inline
224 {
226 foreach (CollisionObject obj in Children)
227 {
228 foreach (CollisionPlane plane in obj._planes)
229 {
230 box.ExpandVolume(new Vector3(plane.PointLeft._x, plane.PointLeft._y, 0));
231 box.ExpandVolume(new Vector3(plane.PointRight._x, plane.PointRight._y, 0));
232 }
233 }
234
235 return box;
236 }
Definition: Box.cs:6
static readonly Box ExpandableVolume
Definition: Box.cs:7
void ExpandVolume(Vector3 value)
Definition: Box.cs:29
Definition: Vector3.cs:40

◆ GetName()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ARCEntryNode.

50 {
51 return base.GetName("Collision Data");
52 }

◆ MergeWith() [1/2]

void BrawlLib.SSBB.ResourceNodes.CollisionNode.MergeWith ( )
inline
267 {
268 OpenFileDialog o = new OpenFileDialog
269 {
270 Filter = FileFilters.CollisionDef,
271 Multiselect = true,
272 Title = "Please select a collision to merge with"
273 };
274 if (o.ShowDialog() == DialogResult.OK)
275 {
276 foreach (string f in o.FileNames)
277 {
278 CollisionNode external = (CollisionNode)NodeFactory.FromFile(null, f, typeof(CollisionNode));
279 if (external != null)
280 {
281 MergeWith(external);
282 }
283 }
284 }
285 }
void MergeWith()
Definition: CollisionNode.cs:266

◆ MergeWith() [2/2]

void BrawlLib.SSBB.ResourceNodes.CollisionNode.MergeWith ( CollisionNode  external)
inline
288 {
289 foreach (ResourceNode co in external.Children)
290 {
291 co.Name = $"{external.Name} {co.Name}";
292 AddChild(co);
293 }
294
296 }
virtual void SignalPropertyChange()
Definition: ResourceNode.cs:313
virtual void AddChild(ResourceNode child)
Definition: ResourceNode.cs:757

◆ OnCalculateSize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

57 {
58 _pointCount = _planeCount = 0;
59 foreach (CollisionObject obj in Children)
60 {
61 _pointCount += obj._points.Count;
62 _planeCount += obj._planes.Count;
63 }
64
65 return CollisionHeader.Size + _pointCount * 8 + _planeCount * ColPlane.Size +
66 Children.Count * ColObject.Size;
67 }
Definition: CollisionDef.cs:99
const int Size
Definition: CollisionDef.cs:100

◆ OnInitialize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.U8EntryNode.

32 {
33 base.OnInitialize();
34
35 _unk1 = Header->_unk1;
36
37 return Header->_numObjects > 0;
38 }
bshort _numObjects
Definition: CollisionDef.cs:15
bshort _unk1
Definition: CollisionDef.cs:16

◆ OnPopulate()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

41 {
42 ColObject* obj = Header->Objects;
43 for (int i = Header->_numObjects; i-- > 0;)
44 {
45 new CollisionObject().Initialize(this, new DataSource(obj++, ColObject.Size));
46 }
47 }
ColObject * Objects
Definition: CollisionDef.cs:54

◆ OnRebuild()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

103 {
104 CollisionHeader* header = (CollisionHeader*) address;
105 *header = new CollisionHeader(_pointCount, _planeCount, Children.Count, _unk1);
106
107 BVec2* pPoint = header->Points;
108 ColPlane* pPlane = header->Planes;
109 ColObject* pObj = header->Objects;
110
111 int iPoint = 0, iPlane = 0;
112 int lind, rind, llink, rlink, tmp;
113 int cPoint, cPlane;
114
115 lind = 0;
116 rind = 0;
117
118 CollisionPlane current, next;
119 CollisionLink link;
120 foreach (CollisionObject obj in Children)
121 {
122 //Sets bounds and entry indices
123 obj.Prepare();
124
125 cPoint = iPoint;
126 cPlane = iPlane;
127 foreach (CollisionPlane plane in obj._planes)
128 {
129 if (plane._encodeIndex != -1)
130 {
131 continue;
132 }
133
134 current = next = plane;
135
136 Top:
137 //Update variables, moving to next plane and links
138 llink = current._encodeIndex;
139 current = next;
140 next = null;
141 rlink = -1;
142
143 //Get left point index, and encode where necessary
144 if ((link = current._linkLeft)._encodeIndex == -1)
145 {
146 pPoint[link._encodeIndex = lind = iPoint++] = link._rawValue;
147 }
148 else
149 {
150 lind = link._encodeIndex;
151 }
152
153 //Get right point index and encode.
154 if ((link = current._linkRight)._encodeIndex == -1)
155 {
156 pPoint[link._encodeIndex = rind = iPoint++] = link._rawValue;
157 }
158 else
159 {
160 rind = link._encodeIndex;
161 }
162
163 //Right-link planes by finding next available
164 if (link != null)
165 {
166 foreach (CollisionPlane p in link._members)
167 {
168 if (p == current || p._linkLeft != link)
169 {
170 continue; //We only want to go left-to-right!
171 }
172
173 //Determine if entry has been encoded yet
174 if ((tmp = p._encodeIndex) != -1)
175 {
176 if (pPlane[tmp]._link1 != -1)
177 {
178 continue; //Already linked, try again
179 }
180
181 pPlane[rlink = tmp]._link1 = (short) iPlane; //Left link, which means the end!
182 }
183 else
184 {
185 next = p;
186 rlink = iPlane + 1;
187 }
188
189 break;
190 }
191 }
192
193 //Create entry
194 pPlane[current._encodeIndex = iPlane++] = new ColPlane(lind, rind, llink, rlink, current._type,
195 current._typeFlags, current._materialFlags, current._material);
196
197 //Traverse
198 if (next != null)
199 {
200 goto Top;
201 }
202 }
203
204 *pObj++ = new ColObject(cPlane, iPlane - cPlane, cPoint, iPoint - cPoint, obj._boxMin, obj._boxMax,
205 obj._modelName, obj._boneName,
206 obj._unk1, obj._unk2, obj._unk3, (int) obj._flags, obj._unk5, obj._unk6, obj._boneIndex);
207 }
208 }
Definition: BigEndianTypes.cs:336
Definition: CollisionDef.cs:59
bshort _link1
Definition: CollisionDef.cs:64
Definition: CollisionDef.cs:10
ColPlane * Planes
Definition: CollisionDef.cs:53
BVec2 * Points
Definition: CollisionDef.cs:52

◆ Render()

void BrawlLib.SSBB.ResourceNodes.CollisionNode.Render ( )
inline
211 {
212 GL.Disable(EnableCap.Lighting);
213 GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
214 GL.Enable(EnableCap.CullFace);
215 GL.CullFace(CullFaceMode.Front);
216
217 foreach (CollisionObject obj in Children)
218 {
219 obj.Render();
220 }
221 }

Property Documentation

◆ AllowedChildTypes

override Type [] BrawlLib.SSBB.ResourceNodes.CollisionNode.AllowedChildTypes
get

◆ IsRendering

bool BrawlLib.SSBB.ResourceNodes.CollisionNode.IsRendering
getset
22 {
23 get => _render;
24 set => _render = value;
25 }

◆ ResourceFileType

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

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