BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Properties | List of all members
BrawlLib.Wii.Models.Influence Class Reference
Inheritance diagram for BrawlLib.Wii.Models.Influence:
BrawlLib.Modeling.IMatrixNode

Public Member Functions

override string ToString ()
 
void AddWeight (BoneWeight weight)
 
void RemoveWeight (BoneWeight weight)
 
void SetWeights (List< BoneWeight > newWeights)
 
void Normalize ()
 
Influence Clone ()
 
 Influence ()
 
 Influence (List< BoneWeight > weights)
 
 Influence (IBoneNode bone)
 
void CalcMatrix ()
 
override int GetHashCode ()
 
override bool Equals (object obj)
 
bool Equals (Influence inf)
 

Static Public Member Functions

static int Compare (Influence i1, Influence i2)
 
static bool operator== (Influence i1, Influence i2)
 
static bool operator!= (Influence i1, Influence i2)
 

Properties

List< BoneWeightWeights [get]
 Don't modify this array! More...
 
List< IMatrixNodeUserUsers [get, set]
 
int NodeIndex [get]
 
Matrix Matrix [get]
 
Matrix InverseMatrix [get]
 
bool IsPrimaryNode [get]
 
bool IsWeighted [get]
 
IBoneNode Bone [get]
 
- Properties inherited from BrawlLib.Modeling.IMatrixNode
List< IMatrixNodeUserUsers [get, set]
 
int NodeIndex [get]
 
Matrix Matrix [get]
 
Matrix InverseMatrix [get]
 
bool IsPrimaryNode [get]
 
List< BoneWeightWeights [get]
 

Constructor & Destructor Documentation

◆ Influence() [1/3]

BrawlLib.Wii.Models.Influence.Influence ( )
inline
232 {
233 _weights = new List<BoneWeight>();
234 }

◆ Influence() [2/3]

BrawlLib.Wii.Models.Influence.Influence ( List< BoneWeight weights)
inline
237 {
238 _weights = weights;
239 foreach (BoneWeight b in _weights)
240 {
241 if (b.Bone != null && !b.Bone.LinkedInfluences.Contains(this))
242 {
243 b.Bone.LinkedInfluences.Add(this);
244 }
245 }
246 }

◆ Influence() [3/3]

BrawlLib.Wii.Models.Influence.Influence ( IBoneNode  bone)
inline
249 {
250 _weights = new List<BoneWeight> {new BoneWeight(bone)};
251 if (!bone.LinkedInfluences.Contains(this))
252 {
253 bone.LinkedInfluences.Add(this);
254 }
255 }
List< Influence > LinkedInfluences
Definition: IBoneNode.cs:22

Member Function Documentation

◆ AddWeight()

void BrawlLib.Wii.Models.Influence.AddWeight ( BoneWeight  weight)
inline
120 {
121 _weights.Add(weight);
122 if (weight.Bone != null && !weight.Bone.LinkedInfluences.Contains(this))
123 {
124 weight.Bone.LinkedInfluences.Add(this);
125 }
126 }

◆ CalcMatrix()

void BrawlLib.Wii.Models.Influence.CalcMatrix ( )
inline
272 {
273 if (IsWeighted)
274 {
275 _matrix = Matrix.InfluenceMatrix(_weights);
276 _invMatrix = Matrix.ReverseInfluenceMatrix(_weights);
277 }
278 else if (_weights.Count == 1 && Bone != null)
279 {
280 _matrix = Bone.Matrix;
281 _invMatrix = Bone.InverseMatrix;
282 }
283 else
284 {
285 _invMatrix = _matrix = Matrix.Identity;
286 }
287 }
IBoneNode Bone
Definition: InfluenceManager.cs:229
bool IsWeighted
Definition: InfluenceManager.cs:228
Matrix Matrix
Definition: IMatrixNode.cs:12
Matrix InverseMatrix
Definition: IMatrixNode.cs:13
Definition: Matrix.cs:14
static Matrix InfluenceMatrix(List< BoneWeight > weights)
Definition: Matrix.cs:383
static Matrix ReverseInfluenceMatrix(List< BoneWeight > weights)
Definition: Matrix.cs:397
static readonly Matrix Identity
Definition: Matrix.cs:15

◆ Clone()

Influence BrawlLib.Wii.Models.Influence.Clone ( )
inline
193 {
194 Influence i = new Influence();
195 foreach (BoneWeight b in _weights)
196 {
197 i.AddWeight(new BoneWeight(b.Bone, b.Weight) {Locked = b.Locked});
198 }
199
200 return i;
201 }
Influence()
Definition: InfluenceManager.cs:231

◆ Compare()

static int BrawlLib.Wii.Models.Influence.Compare ( Influence  i1,
Influence  i2 
)
inlinestatic
290 {
291 if (i1._weights.Count < i2._weights.Count)
292 {
293 return -1;
294 }
295
296 if (i1._weights.Count > i2._weights.Count)
297 {
298 return 1;
299 }
300
301 if (i1.Users.Count > i2.Users.Count)
302 {
303 return -1;
304 }
305
306 if (i1.Users.Count < i2.Users.Count)
307 {
308 return 1;
309 }
310
311 return 0;
312 }

◆ Equals() [1/2]

bool BrawlLib.Wii.Models.Influence.Equals ( Influence  inf)
inline
330 {
331 bool found;
332
333 if (ReferenceEquals(this, inf))
334 {
335 return true;
336 }
337
338 if (ReferenceEquals(inf, null))
339 {
340 return false;
341 }
342
343 if (_weights.Count != inf._weights.Count)
344 {
345 return false;
346 }
347
348 foreach (BoneWeight w1 in _weights)
349 {
350 found = false;
351 foreach (BoneWeight w2 in inf._weights)
352 {
353 if (w1 == w2)
354 {
355 found = true;
356 break;
357 }
358 }
359
360 if (!found)
361 {
362 return false;
363 }
364 }
365
366 return true;
367 }

◆ Equals() [2/2]

override bool BrawlLib.Wii.Models.Influence.Equals ( object  obj)
inline
320 {
321 if (obj is Influence)
322 {
323 return Equals(obj as Influence);
324 }
325
326 return false;
327 }
override bool Equals(object obj)
Definition: InfluenceManager.cs:319

◆ GetHashCode()

override int BrawlLib.Wii.Models.Influence.GetHashCode ( )
inline
315 {
316 return base.GetHashCode();
317 }

◆ Normalize()

void BrawlLib.Wii.Models.Influence.Normalize ( )
inline
163 {
164 //Denominator and numerator to convert each unlocked weight with
165 float denom = 0.0f, num = 1.0f;
166
167 foreach (BoneWeight b in Weights)
168 {
169 if (b.Locked)
170 {
171 num -= b.Weight;
172 }
173 else
174 {
175 denom += b.Weight;
176 }
177 }
178
179 //Don't do anything if all weights are locked
180 if (denom != 0.0f && num != 0.0f)
181 {
182 foreach (BoneWeight b in Weights)
183 {
184 if (!b.Locked) //Only normalize unlocked weights used in the calculation
185 {
186 b.Weight = (float) Math.Round(b.Weight / denom * num, 7);
187 }
188 }
189 }
190 }
List< BoneWeight > Weights
Don't modify this array!
Definition: InfluenceManager.cs:111

◆ operator!=()

static bool BrawlLib.Wii.Models.Influence.operator!= ( Influence  i1,
Influence  i2 
)
inlinestatic
375 {
376 return !i1.Equals(i2);
377 }

◆ operator==()

static bool BrawlLib.Wii.Models.Influence.operator== ( Influence  i1,
Influence  i2 
)
inlinestatic
370 {
371 return i1.Equals(i2);
372 }

◆ RemoveWeight()

void BrawlLib.Wii.Models.Influence.RemoveWeight ( BoneWeight  weight)
inline
129 {
130 if (_weights.Contains(weight))
131 {
132 _weights.Remove(weight);
133 if (weight.Bone != null && weight.Bone.LinkedInfluences.Contains(this))
134 {
135 weight.Bone.LinkedInfluences.Remove(this);
136 }
137 }
138 }

◆ SetWeights()

void BrawlLib.Wii.Models.Influence.SetWeights ( List< BoneWeight newWeights)
inline
141 {
142 foreach (BoneWeight b in _weights)
143 {
144 if (b.Bone != null && b.Bone.LinkedInfluences.Contains(this))
145 {
146 b.Bone.LinkedInfluences.Remove(this);
147 }
148 }
149
150 _weights = newWeights;
151 foreach (BoneWeight b in _weights)
152 {
153 if (b.Bone != null && !b.Bone.LinkedInfluences.Contains(this))
154 {
155 b.Bone.LinkedInfluences.Add(this);
156 }
157 }
158 }

◆ ToString()

override string BrawlLib.Wii.Models.Influence.ToString ( )
inline
98 {
99 return "";
100 }

Property Documentation

◆ Bone

IBoneNode BrawlLib.Wii.Models.Influence.Bone
get

◆ InverseMatrix

Matrix BrawlLib.Wii.Models.Influence.InverseMatrix
get

Implements BrawlLib.Modeling.IMatrixNode.

208 {
209 get
210 {
211 if (_invMatrix == null)
212 {
213 try
214 {
215 _invMatrix = Matrix.Invert(_matrix);
216 }
217 catch
218 {
219 _invMatrix = Matrix.Identity;
220 }
221 }
222
223 return (Matrix) _invMatrix;
224 }
225 }
Matrix Invert()
Definition: Matrix.cs:1474

◆ IsPrimaryNode

bool BrawlLib.Wii.Models.Influence.IsPrimaryNode
get

◆ IsWeighted

bool BrawlLib.Wii.Models.Influence.IsWeighted
get

◆ Matrix

Matrix BrawlLib.Wii.Models.Influence.Matrix
get

◆ NodeIndex

int BrawlLib.Wii.Models.Influence.NodeIndex
get

◆ Users

List<IMatrixNodeUser> BrawlLib.Wii.Models.Influence.Users
getset

Implements BrawlLib.Modeling.IMatrixNode.

114 {
115 get => _references;
116 set => _references = value;
117 }

◆ Weights

List<BoneWeight> BrawlLib.Wii.Models.Influence.Weights
get

Don't modify this array!

Implements BrawlLib.Modeling.IMatrixNode.


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