BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Properties | List of all members
BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode Class Reference
Inheritance diagram for BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode:
BrawlLib.SSBB.ResourceNodes.MDL0EntryNode BrawlLib.Imaging.IImageSource BrawlLib.SSBB.ResourceNodes.ResourceNode

Public Types

enum  IndirectMethod
 

Public Member Functions

 MDL0MaterialNode ()
 
void UpdateAsMetal ()
 
bool CheckIfMetal ()
 
override bool OnInitialize ()
 
override void OnPopulate ()
 
override int OnCalculateSize (bool force)
 
override void OnRebuild (VoidPtr address, int length, bool force)
 
override void Export (string outPath)
 
override void SignalPropertyChange ()
 
void UseProgram (MDL0ObjectNode node, bool forceRemake=false)
 
void ApplyViewportLighting (ModelPanelViewport viewport)
 
void GenerateShadowMaterial ()
 
void GenerateSpyMaterial ()
 
override void Replace (string fileName)
 
override void Remove ()
 
void Remove (bool removeAttached)
 
Bitmap GetImage (int index)
 
override void SignalPropertyChange ()
 
- 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 ()
 
Bitmap GetImage (int index)
 

Public Attributes

bool _updating
 
byte _indirectMethod1
 
byte _indirectMethod2
 
byte _indirectMethod3
 
byte _indirectMethod4
 
byte _activeStages
 
byte _activeIndStages
 
byte _depthTestBeforeTexture
 
sbyte _normMapRefLight1 = -1
 
sbyte _normMapRefLight2 = -1
 
sbyte _normMapRefLight3 = -1
 
sbyte _normMapRefLight4 = -1
 
sbyte _lightSetIndex = 20
 
sbyte _fogIndex = 4
 
CullMode _cull = CullMode.Cull_Inside
 
uint _texMtxFlags
 
LightChannel _chan1
 
LightChannel _chan2
 
List< MDL0ObjectNode_objects = new List<MDL0ObjectNode>()
 
List< XFDataXFCmds = new List<XFData>()
 
GXAlphaFunction _alphaFunc = GXAlphaFunction.Default
 
ZMode _zMode = ZMode.Default
 
BlendMode _blendMode = BlendMode.Default
 
ConstantAlpha _constantAlpha = ConstantAlpha.Default
 
MatTevColorBlock _tevColorBlock = MatTevColorBlock.Default
 
MatTevKonstBlock _tevKonstBlock = MatTevKonstBlock.Default
 
MatIndMtxBlock _indMtx = MatIndMtxBlock.Default
 
string _vertexShaderSource
 
int _vertexShaderHandle
 
string _fragShaderSource
 
int _fragShaderHandle
 
int _programHandle
 
bool _internalForceRemake
 
TextureFrameState[] _indirectFrameStates = new TextureFrameState[3]
 
Vector4 amb1
 
Vector4 amb2
 
Vector4 clr1
 
Vector4 clr2
 
Vector4 k1
 
Vector4 k2
 
Vector4 k3
 
Vector4 k4
 
Vector4 c1
 
Vector4 c2
 
Vector4 c3
 
bool _scn0Applied
 
Vector4 _ambientLight
 
FogAnimationFrame _fog
 
GLSLLightFrame[] _lights = new GLSLLightFrame[8]
 
- Public Attributes inherited from BrawlLib.SSBB.ResourceNodes.MDL0EntryNode
int _entryIndex
 
- 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
 

Properties

override ResourceType ResourceFileType [get]
 
override bool AllowDuplicateNames [get]
 
UserDataCollection UserEntries [get, set]
 
MDL0ObjectNode[] Objects [get]
 
GXColorS10 ConstantColor0 [get, set]
 
GXColorS10 ConstantColor1 [get, set]
 
GXColorS10 ConstantColor2 [get, set]
 
GXColorS10 ConstantColor3 [get, set]
 
GXColorS10 Color0 [get, set]
 
GXColorS10 Color1 [get, set]
 
GXColorS10 Color2 [get, set]
 
MDL0ShaderNode ShaderNode [get, set]
 
string Shader [get, set]
 
byte Ref0 [get, set]
 
AlphaCompare Comp0 [get, set]
 
AlphaOp Logic [get, set]
 
byte Ref1 [get, set]
 
AlphaCompare Comp1 [get, set]
 
bool CompareBeforeTexture [get, set]
 
bool EnableDepthTest [get, set]
 
bool EnableDepthUpdate [get, set]
 
GXCompare DepthFunction [get, set]
 
bool EnableBlend [get, set]
 
bool EnableBlendLogic [get, set]
 
BlendFactor SrcFactor [get, set]
 
GXLogicOp BlendLogicOp [get, set]
 
BlendFactor DstFactor [get, set]
 
bool Subtract [get, set]
 
bool ConstantAlphaEnabled [get, set]
 
byte ConstantAlphaValue [get, set]
 
IndirectMethod IndirectMethodTex1 [get, set]
 
IndirectMethod IndirectMethodTex2 [get, set]
 
IndirectMethod IndirectMethodTex3 [get, set]
 
IndirectMethod IndirectMethodTex4 [get, set]
 
IndTexScale IndirectTex1ScaleS [get, set]
 
IndTexScale IndirectTex1ScaleT [get, set]
 
IndTexScale IndirectTex2ScaleS [get, set]
 
IndTexScale IndirectTex2ScaleT [get, set]
 
IndTexScale IndirectTex3ScaleS [get, set]
 
IndTexScale IndirectTex3ScaleT [get, set]
 
IndTexScale IndirectTex4ScaleS [get, set]
 
IndTexScale IndirectTex4ScaleT [get, set]
 
LightChannel LightChannel0 [get]
 
LightChannel LightChannel1 [get]
 
LightingChannelFlags C1Flags [get, set]
 
RGBAPixel C1MaterialColor [get, set]
 
RGBAPixel C1AmbientColor [get, set]
 
GXColorSrc C1ColorMaterialSource [get, set]
 
bool C1ColorEnabled [get, set]
 
GXColorSrc C1ColorAmbientSource [get, set]
 
GXDiffuseFn C1ColorDiffuseFunction [get, set]
 
GXAttnFn C1ColorAttenuation [get, set]
 
MatChanLights C1ColorLights [get, set]
 
GXColorSrc C1AlphaMaterialSource [get, set]
 
bool C1AlphaEnabled [get, set]
 
GXColorSrc C1AlphaAmbientSource [get, set]
 
GXDiffuseFn C1AlphaDiffuseFunction [get, set]
 
GXAttnFn C1AlphaAttenuation [get, set]
 
MatChanLights C1AlphaLights [get, set]
 
LightingChannelFlags C2Flags [get, set]
 
RGBAPixel C2MaterialColor [get, set]
 
RGBAPixel C2AmbientColor [get, set]
 
GXColorSrc C2ColorMaterialSource [get, set]
 
bool C2ColorEnabled [get, set]
 
GXColorSrc C2ColorAmbientSource [get, set]
 
GXDiffuseFn C2ColorDiffuseFunction [get, set]
 
GXAttnFn C2ColorAttenuation [get, set]
 
MatChanLights C2ColorLights [get, set]
 
GXColorSrc C2AlphaMaterialSource [get, set]
 
bool C2AlphaEnabled [get, set]
 
GXColorSrc C2AlphaAmbientSource [get, set]
 
GXDiffuseFn C2AlphaDiffuseFunction [get, set]
 
GXAttnFn C2AlphaAttenuation [get, set]
 
MatChanLights C2AlphaLights [get, set]
 
TexMatrixMode TextureMatrixMode [get, set]
 
bool XLUMaterial [get, set]
 
int ID [get]
 
int ActiveShaderStages [get, set]
 
int IndirectShaderStages [get, set]
 
CullMode CullMode [get, set]
 
sbyte LightSetIndex [get, set]
 
sbyte FogIndex [get, set]
 
sbyte NormMapRefLight1 [get, set]
 
sbyte NormMapRefLight2 [get, set]
 
sbyte NormMapRefLight3 [get, set]
 
sbyte NormMapRefLight4 [get, set]
 
bool IsMetal [get]
 
MDL0MaterialNode MetalMaterial [get]
 
int ImageCount [get]
 
- Properties inherited from BrawlLib.SSBB.ResourceNodes.MDL0EntryNode
MDL0Node Model [get]
 
BRRESNode BRESNode [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]
 
- Properties inherited from BrawlLib.Imaging.IImageSource
int ImageCount [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 Member Functions inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
void ForceReplacedEvent ()
 
virtual void MergeInternal ()
 
- Events inherited from BrawlLib.SSBB.ResourceNodes.ResourceNode
SelectEventHandler SelectChild
 
EventHandler UpdateProps
 
MoveEventHandler MovedUp
 
ResourceEventHandler Disposing
 
ResourceChildEventHandler ChildAdded
 
ResourceChildInsertEventHandler ChildInserted
 

Member Enumeration Documentation

◆ IndirectMethod

829 {
830 Warp = 0,
831 NormalMap,
832 NormalMapSpecular,
833 Fur,
834 Reserved0,
835 Reserved1,
836 User0,
837 User1
838 }

Constructor & Destructor Documentation

◆ MDL0MaterialNode()

BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.MDL0MaterialNode ( )
inline
30 {
31 _chan1 = new LightChannel(
32 63,
33 new RGBAPixel(128, 128, 128, 255),
34 new RGBAPixel(255, 255, 255, 255),
35 new LightChannelControl(true, GXColorSrc.Register, GXColorSrc.Register, GXDiffuseFn.Clamped,
36 GXAttnFn.Spotlight),
37 new LightChannelControl(true, GXColorSrc.Register, GXColorSrc.Register, GXDiffuseFn.Clamped,
38 GXAttnFn.Spotlight),
39 this);
40 _chan2 = new LightChannel(
41 15,
42 new RGBAPixel(0, 0, 0, 255),
43 new RGBAPixel(),
44 0,
45 0,
46 this);
47 }
LightChannel _chan1
Definition: MDL0MaterialNode.cs:86
LightChannel _chan2
Definition: MDL0MaterialNode.cs:86
GXDiffuseFn
Definition: MDL0MaterialNode.cs:2902
GXColorSrc
Definition: MDL0MaterialNode.cs:2882
GXAttnFn
Definition: MDL0MaterialNode.cs:2909
Definition: PixelTypes.cs:327

Member Function Documentation

◆ ApplyViewportLighting()

void BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ApplyViewportLighting ( ModelPanelViewport  viewport)
inline
2323 {
2324 //TODO: support 8 built-in lights instead of just one, and fog?
2325 //(like an SCN0 built into the program)
2326 if (!_scn0Applied)
2327 {
2328 bool pointLight = viewport._posLight._w != 0.0f;
2329 _lights[0] = new GLSLLightFrame(
2330 viewport._lightEnabled,
2331 pointLight ? LightType.Point : LightType.Directional,
2332 new Vector3(viewport._posLight._x, viewport._posLight._y, viewport._posLight._z),
2333 new Vector3(),
2334 viewport.Diffuse,
2335 pointLight
2336 ? SCN0LightNode.GetLightDistCoefs(viewport.LightPosition._x, 0.5f, DistAttnFn.Medium)
2337 : new Vector3(1.0f, 0.0f, 0.0f),
2338 new Vector3(1.0f, 0.0f, 0.0f),
2339 true,
2340 viewport.Specular,
2341 SCN0LightNode.GetSpecShineDistCoefs(64.0f));
2342 _ambientLight = viewport.Ambient;
2343 }
2344 }
Vector4 Diffuse
Definition: modelpanelviewport.cs:288
Vector4 LightPosition
Definition: modelpanelviewport.cs:262
bool _lightEnabled
Definition: modelpanelviewport.cs:80
Vector4 Specular
Definition: modelpanelviewport.cs:300
Vector4 Ambient
Definition: modelpanelviewport.cs:228
GLSLLightFrame[] _lights
Definition: MDL0MaterialNode.cs:2261
bool _scn0Applied
Definition: MDL0MaterialNode.cs:2258
Vector4 _ambientLight
Definition: MDL0MaterialNode.cs:2259
LightType
Definition: SCN0.cs:358
DistAttnFn
Definition: Enum.cs:602
Definition: Vector3.cs:40
float _x
Definition: Vector4.cs:13
float _z
Definition: Vector4.cs:13
float _y
Definition: Vector4.cs:13
Definition: AnimationFrame.cs:385

◆ CheckIfMetal()

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.CheckIfMetal ( )
inline
1487 {
1488 if (Model != null && Model._autoMetal)
1489 {
1490 if (!_updating)
1491 {
1492 if (IsMetal)
1493 {
1494 if (MessageBox.Show(null,
1495 "This model is currently set to automatically modify metal materials.\nYou cannot make changes unless you turn it off.\nDo you want to turn it off?",
1496 "", MessageBoxButtons.YesNo) == DialogResult.Yes)
1497 {
1498 Model._autoMetal = false;
1499 }
1500 else
1501 {
1502 return true;
1503 }
1504 }
1505 }
1506 }
1507
1508 return false;
1509 }
MDL0Node Model
Definition: MDL0GroupNode.cs:28
bool _updating
Definition: MDL0MaterialNode.cs:27
bool IsMetal
Definition: MDL0MaterialNode.cs:1511
bool _autoMetal
Definition: MDL0Node.cs:47

◆ Export()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

1898 {
1899 StringTable table = new StringTable();
1900 GetStrings(table);
1901 int dataLen = CalculateSize(false);
1902 int totalLen = dataLen + table.GetTotalSize();
1903
1904 using (FileStream stream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite,
1905 FileShare.None, 8, FileOptions.RandomAccess))
1906 {
1907 stream.SetLength(totalLen);
1908 using (FileMap map = FileMap.FromStream(stream))
1909 {
1910 Rebuild(map.Address, dataLen, false);
1911 table.WriteTable(map.Address + dataLen);
1912 PostProcess(map.Address, map.Address, table);
1913 ((MDL0Material*) map.Address)->_pad = (byte) Model._version;
1914 }
1915 }
1916 }
Definition: FileMap.cs:10
static FileMap FromStream(FileStream stream)
Definition: FileMap.cs:117
VoidPtr Address
Definition: FileMap.cs:16
int _version
Definition: BRRESNode.cs:1045
virtual void Rebuild()
Definition: ResourceNode.cs:987
virtual int CalculateSize(bool force)
Definition: ResourceNode.cs:1161
Definition: MDL0.cs:1165

◆ GenerateShadowMaterial()

void BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.GenerateShadowMaterial ( )
inline
2351 {
2352 //HardcodedFiles.CreateShadowMaterial();
2353 //ReplaceRaw(FileMap.FromFile(ShadowMaterial.Name));
2354 Name = "MShadow1";
2355
2356 EnableBlend = true;
2357 LightChannel0.MaterialColor = new Vector4(255 * 255, 255 * 255, 255 * 255, 255 * 255);
2358 LightChannel0.Color.Enabled = false;
2359 LightChannel0.Color.MaterialSource = (GXColorSrc) 1;
2360 LightChannel0.Alpha.Enabled = false;
2361 LightChannel0.Alpha.MaterialSource = (GXColorSrc) 1;
2362 XLUMaterial = true;
2363 LightSetIndex = -1;
2364 _tevColorBlock.TevReg1Lo.AG = 70;
2365 CompareBeforeTexture = true;
2366 EnableDepthUpdate = false;
2367
2368 Children?.Clear();
2369
2370 addShadowReference();
2371 }
sbyte LightSetIndex
Definition: MDL0MaterialNode.cs:1231
bool EnableDepthUpdate
Definition: MDL0MaterialNode.cs:498
bool XLUMaterial
Definition: MDL0MaterialNode.cs:1133
bool EnableBlend
Definition: MDL0MaterialNode.cs:532
bool CompareBeforeTexture
Definition: MDL0MaterialNode.cs:468
virtual string Name
Definition: ResourceNode.cs:223
List< ResourceNode > Children
Definition: ResourceNode.cs:262
Definition: Vector4.cs:12

◆ GenerateSpyMaterial()

void BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.GenerateSpyMaterial ( )
inline
2398 {
2399 //HardcodedFiles.CreateSpyMaterial();
2400 //ReplaceRaw(FileMap.FromFile(SpyMaterial.Name));
2401 Name = "Spycloak";
2402
2403 LightSetIndex = -1;
2404 FogIndex = -1;
2405 _tevColorBlock.TevReg1Lo.RB = 255;
2406 _tevColorBlock.TevReg1Hi0.RB = 255;
2407 _tevColorBlock.TevReg1Hi0.AG = 255;
2409
2410 LightChannel1._matColor.Red = 255;
2411 LightChannel1._matColor.Blue = 255;
2412 LightChannel1._matColor.Green = 255;
2413
2414 LightChannel0.Color.Enabled = false;
2415 LightChannel0.Alpha.Enabled = false;
2416
2417 CompareBeforeTexture = true;
2418
2419 Children?.Clear();
2420
2421 addSpyReferences();
2422 }
sbyte FogIndex
Definition: MDL0MaterialNode.cs:1249
int IndirectShaderStages
Definition: MDL0MaterialNode.cs:1192

◆ GetImage()

Bitmap BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.GetImage ( int  index)
inline

Implements BrawlLib.Imaging.IImageSource.

2497 {
2498 return ((IImageSource) Children?.Where(o => o is IImageSource i && i.ImageCount > 0).ToArray()[index])
2499 .GetImage(0);
2500 }
Definition: IImageSource.cs:7
int ImageCount
Definition: IImageSource.cs:8

◆ OnCalculateSize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

1637 {
1638 int temp, size;
1639
1640 //Add header and tex matrices size at start
1641 size = 0x414 + (Model._version >= 10 ? 4 : 0);
1642
1643 //Add children size
1644 size += Children.Count * MDL0TextureRef.Size;
1645
1646 //Add user entries, if there are any
1647 size += _userEntries.GetSize();
1648
1649 //Set temp align offset
1650 temp = size;
1651
1652 //Align data to an offset divisible by 0x20 using data length.
1653 size = size.Align(0x10) + _dataAlign;
1654 if ((size + _mdlOffset) % 0x20 != 0)
1655 {
1656 size += size - 0x10 >= temp ? -0x10 : 0x10;
1657 }
1658
1659 //Reset data alignment
1660 _dataAlign = 0;
1661
1662 //Add display list and XF flags
1663 size += 0x180;
1664
1665 return size;
1666 }
int GetSize()
Definition: UserData.cs:123
Definition: MDL0.cs:1758
const int Size
Definition: MDL0.cs:1759

◆ OnInitialize()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

1544 {
1545 MDL0Material* header = Header;
1546
1547 _initVersion = header->_pad != 0 && _replaced ? header->_pad : Model._version;
1548
1549 if (_name == null && header->_stringOffset != 0)
1550 {
1551 _name = header->ResourceString;
1552 }
1553
1554 //Get XF Commands
1555 XFCmds = XFData.Parse((byte*) header->DisplayLists(_initVersion) + 0xE0);
1556
1557 _usageFlags = header->_usageFlags;
1558
1563
1568
1572
1573 _lightSetIndex = header->_lightSet;
1574 _fogIndex = header->_fogSet;
1575
1576 _cull = (CullMode) (int) header->_cull;
1577
1578 if (!_replaced && (-header->_mdl0Offset + header->DisplayListOffset(_initVersion)) % 0x20 != 0)
1579 {
1580 Model._errors.Add("Material " + Index + " has an improper align offset.");
1581 }
1582
1583 MatModeBlock* mode = header->DisplayLists(_initVersion);
1584 _alphaFunc = mode->AlphaFunction;
1585 _zMode = mode->ZMode;
1586 _blendMode = mode->BlendMode;
1588
1589 _tevColorBlock = *header->TevColorBlock(_initVersion);
1590 _tevKonstBlock = *header->TevKonstBlock(_initVersion);
1591 _indMtx = *header->IndMtxBlock(_initVersion);
1592
1593 MDL0TexSRTData* TexMatrices = header->TexMatrices(_initVersion);
1594 _texMtxFlags = TexMatrices->_mtxFlags;
1595
1596 MDL0MaterialLighting* Light = header->Light(_initVersion);
1597
1598 (_chan1 = Light->Channel1)._parent = this;
1599 (_chan2 = Light->Channel2)._parent = this;
1600
1601 (_userEntries = new UserDataCollection()).Read(header->UserData(_initVersion), WorkingUncompressed);
1602
1603 return true;
1604 }
BlendMode _blendMode
Definition: MDL0MaterialNode.cs:92
ZMode _zMode
Definition: MDL0MaterialNode.cs:91
byte _indirectMethod1
Definition: MDL0MaterialNode.cs:66
MatIndMtxBlock _indMtx
Definition: MDL0MaterialNode.cs:96
List< XFData > XFCmds
Definition: MDL0MaterialNode.cs:88
sbyte _normMapRefLight3
Definition: MDL0MaterialNode.cs:77
uint _texMtxFlags
Definition: MDL0MaterialNode.cs:84
ConstantAlpha _constantAlpha
Definition: MDL0MaterialNode.cs:93
sbyte _normMapRefLight4
Definition: MDL0MaterialNode.cs:78
byte _indirectMethod4
Definition: MDL0MaterialNode.cs:69
CullMode _cull
Definition: MDL0MaterialNode.cs:83
sbyte _lightSetIndex
Definition: MDL0MaterialNode.cs:79
byte _depthTestBeforeTexture
Definition: MDL0MaterialNode.cs:72
sbyte _fogIndex
Definition: MDL0MaterialNode.cs:80
MatTevColorBlock _tevColorBlock
Definition: MDL0MaterialNode.cs:94
byte _indirectMethod2
Definition: MDL0MaterialNode.cs:67
byte _activeStages
Definition: MDL0MaterialNode.cs:70
MatTevKonstBlock _tevKonstBlock
Definition: MDL0MaterialNode.cs:95
CullMode CullMode
Definition: MDL0MaterialNode.cs:1211
sbyte _normMapRefLight1
Definition: MDL0MaterialNode.cs:75
byte _activeIndStages
Definition: MDL0MaterialNode.cs:71
sbyte _normMapRefLight2
Definition: MDL0MaterialNode.cs:76
GXAlphaFunction _alphaFunc
Definition: MDL0MaterialNode.cs:90
byte _indirectMethod3
Definition: MDL0MaterialNode.cs:68
List< string > _errors
Definition: MDL0Node.cs:51
bool _replaced
Definition: ResourceNode.cs:827
ResourceNode _parent
Definition: ResourceNode.cs:142
string _name
Definition: ResourceNode.cs:139
int Index
Definition: ResourceNode.cs:301
DataSource WorkingUncompressed
Definition: ResourceNode.cs:183
Definition: XF.cs:26
static unsafe List< XFData > Parse(VoidPtr address)
Definition: XF.cs:68
bint _cull
Definition: MDL0.cs:1195
MatTevColorBlock * TevColorBlock(int version)
Definition: MDL0.cs:1288
sbyte _fogSet
Definition: MDL0.cs:1200
byte _indirectMethod2
Definition: MDL0.cs:1203
byte _pad
Definition: MDL0.cs:1201
sbyte _lightSet
Definition: MDL0.cs:1199
MDL0MaterialLighting * Light(int version)
Definition: MDL0.cs:1267
MDL0TexSRTData * TexMatrices(int version)
Definition: MDL0.cs:1261
byte _numIndTexStages
Definition: MDL0.cs:1194
sbyte _normMapRefLight2
Definition: MDL0.cs:1207
byte _indirectMethod4
Definition: MDL0.cs:1205
string ResourceString
Definition: MDL0.cs:1305
MatTevKonstBlock * TevKonstBlock(int version)
Definition: MDL0.cs:1293
UserData * UserData(int version)
Definition: MDL0.cs:1273
byte _depthTestBeforeTexture
Definition: MDL0.cs:1198
bint _mdl0Offset
Definition: MDL0.cs:1167
MatIndMtxBlock * IndMtxBlock(int version)
Definition: MDL0.cs:1299
sbyte _normMapRefLight3
Definition: MDL0.cs:1208
Bin32 _usageFlags
Definition: MDL0.cs:1170
int DisplayListOffset(int version)
Definition: MDL0.cs:1225
sbyte _normMapRefLight1
Definition: MDL0.cs:1206
byte _activeTEVStages
Definition: MDL0.cs:1193
bint _stringOffset
Definition: MDL0.cs:1168
byte _indirectMethod1
Definition: MDL0.cs:1202
MatModeBlock * DisplayLists(int version)
Definition: MDL0.cs:1283
byte _indirectMethod3
Definition: MDL0.cs:1204
sbyte _normMapRefLight4
Definition: MDL0.cs:1209
LightChannel Channel1
Definition: MDL0.cs:1137
LightChannel Channel2
Definition: MDL0.cs:1150
Definition: MDL0.cs:1046
buint _mtxFlags
Definition: MDL0.cs:1069
Definition: MDL0.cs:1418
BlendMode BlendMode
Definition: MDL0.cs:1445
GXAlphaFunction AlphaFunction
Definition: MDL0.cs:1437
ConstantAlpha ConstantAlpha
Definition: MDL0.cs:1447
ZMode ZMode
Definition: MDL0.cs:1439

◆ OnPopulate()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

1607 {
1608 MDL0TextureRef* first = Header->First;
1609 for (int i = 0; i < Header->_numTextures; i++)
1610 {
1611 new MDL0MaterialRefNode().Initialize(this, first++, MDL0TextureRef.Size);
1612 }
1613 }
bint _numTextures
Definition: MDL0.cs:1213
MDL0TextureRef * First
Definition: MDL0.cs:1223

◆ OnRebuild()

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

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

1669 {
1670 MDL0Node model = Model;
1671 MDL0Material* header = (MDL0Material*) address;
1672
1673 //Set offsets
1674 header->_dataLen = length;
1675
1676 int addr = 0x414, displayListOffset = length - 0x180;
1677 if (model._version >= 10)
1678 {
1679 addr += 4;
1680
1681 header->_dataOffset2 = 0; //Fur Data not supported
1682 header->_dataOffset3 = displayListOffset;
1683 }
1684 else
1685 {
1686 header->_dataOffset2 = displayListOffset;
1687 }
1688
1689 header->_matRefOffset = Children.Count > 0 ? addr : 0;
1690
1691 //Check for user entries
1692 if (_userEntries.Count > 0)
1693 {
1694 addr += Children.Count * 0x34;
1695 if (model._version >= 10)
1696 {
1697 header->_dataOffset2 = addr;
1698 }
1699 else
1700 {
1701 header->_dataOffset1 = addr;
1702 }
1703
1704 _userEntries.Write(header->UserData(model._version));
1705 }
1706 else
1707 {
1708 header->_dataOffset1 = 0;
1709 }
1710
1711 ushort i1 = 0x1040, i2 = 0x1050, mtx = 0;
1712 if (Model._isImport)
1713 {
1714 //Set default texgen flags
1715 for (int i = 0; i < Children.Count; i++, mtx += 3, i1++, i2++)
1716 {
1717 MDL0MaterialRefNode node = (MDL0MaterialRefNode) Children[i];
1718
1719 node._bindState = TextureFrameState.Neutral;
1720 node._texMatrixEffect.TextureMatrix = Matrix34.Identity;
1721 node._texMatrixEffect.SCNCamera = -1;
1722 node._texMatrixEffect.SCNLight = -1;
1723 node._texMatrixEffect.MapMode = MappingMethod.TexCoord;
1724
1725 node._dualTexFlags = new XFDualTex(mtx, 0);
1726 node._texMtxFlags = new XFTexMtxInfo(
1727 TexProjection.ST,
1728 TexInputForm.AB11,
1729 TexTexgenType.Regular,
1730 TexSourceRow.TexCoord0,
1731 5, 0);
1732
1733 XFCmds.Add(new XFData(i1, node._texMtxFlags._data));
1734 XFCmds.Add(new XFData(i2, node._dualTexFlags.Value));
1735 }
1736 }
1737
1738 //Set header values
1739 header->_numTextures = Children.Count;
1740 header->_numTexGens = (byte) Children.Count;
1741 header->_index = Index;
1745
1746 byte lights = 0;
1748 {
1749 lights++;
1750 }
1751
1753 {
1754 lights++;
1755 }
1756
1757 header->_numLightChans = lights;
1758
1759 header->_lightSet = _lightSetIndex;
1760 header->_fogSet = _fogIndex;
1761 header->_pad = 0;
1762
1763 header->_cull = (int) _cull;
1764 header->_usageFlags = _usageFlags;
1765
1770
1775
1776 //Generate layer flags and write texture matrices
1777 MDL0TexSRTData* TexSettings = header->TexMatrices(model._version);
1778 *TexSettings = MDL0TexSRTData.Default;
1779
1780 //Usage flags. Each set of 4 bits represents one texture layer.
1781 uint layerFlags = 0;
1782
1783 //Loop through references in reverse so that layerflags is set in the right order
1784 for (int i = Children.Count - 1; i >= 0; i--)
1785 {
1786 MDL0MaterialRefNode node = (MDL0MaterialRefNode) Children[i];
1787
1788 TexFlags flags = TexFlags.Enabled;
1789
1790 //Check for non-default values
1791 if (node._bindState.Scale == new Vector2(1))
1792 {
1793 flags |= TexFlags.FixedScale;
1794 }
1795
1796 if (node._bindState.Rotate == 0)
1797 {
1798 flags |= TexFlags.FixedRot;
1799 }
1800
1801 if (node._bindState.Translate == new Vector2(0))
1802 {
1803 flags |= TexFlags.FixedTrans;
1804 }
1805
1806 TexSettings->SetTexSRT(node._bindState, node.Index);
1807 TexSettings->SetTexMatrices(node._texMatrixEffect, node.Index);
1808
1809 layerFlags = (layerFlags << 4) | (byte) flags;
1810 }
1811
1812 TexSettings->_layerFlags = layerFlags;
1813 TexSettings->_mtxFlags = _texMtxFlags;
1814
1815 //Write lighting flags
1816 MDL0MaterialLighting* Light = header->Light(model._version);
1817
1818 Light->Channel1 = _chan1;
1819 Light->Channel2 = _chan2;
1820
1821 //The shader offset will be written later
1822
1823 //Rebuild references
1824 MDL0TextureRef* mRefs = header->First;
1825 foreach (MDL0MaterialRefNode n in Children)
1826 {
1827 n.Rebuild(mRefs++, MDL0TextureRef.Size, true);
1828 }
1829
1830 //Set Display Lists
1831 *header->TevKonstBlock(model._version) = _tevKonstBlock;
1832 *header->TevColorBlock(model._version) = _tevColorBlock;
1833 *header->IndMtxBlock(model._version) = _indMtx;
1834
1835 MatModeBlock* mode = header->DisplayLists(model._version);
1836 *mode = MatModeBlock.Default;
1837 if (model._isImport)
1838 {
1839 _alphaFunc = mode->AlphaFunction;
1840 _zMode = mode->ZMode;
1841 _blendMode = mode->BlendMode;
1843 }
1844 else
1845 {
1846 mode->AlphaFunction = _alphaFunc;
1847 mode->ZMode = _zMode;
1848 mode->BlendMode = _blendMode;
1850 }
1851
1852 //Write XF flags
1853 i1 = 0x1040;
1854 i2 = 0x1050;
1855 mtx = 0;
1856 byte* xfData = (byte*) header->DisplayLists(model._version) + 0xE0;
1857 foreach (MDL0MaterialRefNode mr in Children)
1858 {
1859 //Tex Mtx
1860 *xfData++ = 0x10;
1861 *(bushort*) xfData = 0;
1862 xfData += 2;
1863 *(bushort*) xfData = i1++;
1864 xfData += 2;
1865 *(buint*) xfData = mr._texMtxFlags._data._data;
1866 xfData += 4;
1867
1868 //Dual Tex
1869 *xfData++ = 0x10;
1870 *(bushort*) xfData = 0;
1871 xfData += 2;
1872 *(bushort*) xfData = i2++;
1873 xfData += 2;
1874 *(buint*) xfData = new XFDualTex(mtx, mr._dualTexFlags._normalEnable).Value;
1875 xfData += 4;
1876
1877 mtx += 3;
1878 }
1879 }
bool RasterAlphaEnabled
Definition: MDL0MaterialNode.cs:2573
bool RasterColorEnabled
Definition: MDL0MaterialNode.cs:2552
bool _isImport
Definition: MDL0Node.cs:47
void Write(VoidPtr userDataAddr)
Definition: UserData.cs:145
MappingMethod
Definition: MDL0MaterialRefNode.cs:1024
TexFlags
Definition: MDL0.cs:1037
TexInputForm
Definition: Enum.cs:560
TexSourceRow
Definition: Enum.cs:574
TexProjection
Definition: Enum.cs:554
TexTexgenType
Definition: Enum.cs:566
Definition: Matrix34.cs:15
static readonly Matrix34 Identity
Definition: Matrix34.cs:16
Definition: Vector2.cs:10
Definition: BigEndianTypes.cs:59
Definition: BigEndianTypes.cs:192
Definition: FrameState.cs:105
static readonly TextureFrameState Neutral
Definition: FrameState.cs:244
byte _numLightChans
Definition: MDL0.cs:1192
byte _numTexGens
Definition: MDL0.cs:1191
bint _matRefOffset
Definition: MDL0.cs:1214
bint _dataLen
Definition: MDL0.cs:1166
bint _index
Definition: MDL0.cs:1169
void SetTexSRT(TextureSRT value, int Index)
Definition: MDL0.cs:1105
buint _layerFlags
Definition: MDL0.cs:1068
static readonly MDL0TexSRTData Default
Definition: MDL0.cs:1047
void SetTexMatrices(TexMtxEffect value, int Index)
Definition: MDL0.cs:1115
static readonly MatModeBlock Default
Definition: MDL0.cs:1421
Definition: XF.cs:199
uint Value
Definition: XF.cs:223

◆ Remove() [1/2]

override void BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Remove ( )
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

2458 {
2459 Remove(ShaderNode != null && ShaderNode.Materials.Length == 1 &&
2460 MessageBox.Show("Do you want to remove this material's shader?", "", MessageBoxButtons.YesNo) ==
2461 DialogResult.Yes);
2462 }
override void Remove()
Definition: MDL0MaterialNode.cs:2457
MDL0ShaderNode ShaderNode
Definition: MDL0MaterialNode.cs:338
MDL0MaterialNode[] Materials
Definition: MDL0ShaderNode.cs:16

◆ Remove() [2/2]

void BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Remove ( bool  removeAttached)
inline
2465 {
2466 if (Parent != null)
2467 {
2468 if (removeAttached)
2469 {
2470 ShaderNode?.Remove();
2471 }
2472
2473 ShaderNode = null;
2474
2475 foreach (MDL0MaterialRefNode r in Children)
2476 {
2477 r.TextureNode = null;
2478 r.PaletteNode = null;
2479 }
2480
2482 }
2483
2484 base.Remove();
2485 }
void CheckTextures()
Definition: MDL0Node.cs:414
virtual void Remove()
Definition: ResourceNode.cs:741
ResourceNode Parent
Definition: ResourceNode.cs:245

◆ Replace()

override void BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Replace ( string  fileName)
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.ResourceNode.

2451 {
2452 base.Replace(fileName);
2453
2455 }

◆ SignalPropertyChange()

override void BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.SignalPropertyChange ( )
inlinevirtual

Reimplemented from BrawlLib.SSBB.ResourceNodes.MDL0EntryNode.

1925 {
1926 _fragShaderSource = null;
1927 _vertexShaderSource = null;
1928
1929 if (Model != null && Model.AutoMetalMaterials && !IsMetal)
1930 {
1932 }
1933
1934 base.SignalPropertyChange();
1935 }
string _vertexShaderSource
Definition: MDL0MaterialNode.cs:1937
string _fragShaderSource
Definition: MDL0MaterialNode.cs:1939
void GenerateMetalMaterials()
Definition: MDL0Node.cs:454
bool AutoMetalMaterials
Definition: MDL0Node.cs:63

◆ UpdateAsMetal()

void BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.UpdateAsMetal ( )
inline
1334 {
1335 if (!IsMetal)
1336 {
1337 return;
1338 }
1339
1340 _updating = true;
1341 if (ShaderNode != null && ShaderNode._autoMetal && ShaderNode._texCount == Children.Count)
1342 {
1343 //ShaderNode.DefaultAsMetal(Children.Count);
1344 }
1345 else
1346 {
1347 bool found = false;
1348 foreach (MDL0ShaderNode s in Model._shadList)
1349 {
1350 if (s._autoMetal && s._texCount == Children.Count)
1351 {
1352 ShaderNode = s;
1353 found = true;
1354 }
1355 else
1356 {
1357 if (s.Stages == 4)
1358 {
1359 foreach (MDL0MaterialNode y in s._materials)
1360 {
1361 if (!y.IsMetal || y.Children.Count != Children.Count)
1362 {
1363 goto NotFound;
1364 }
1365 }
1366
1367 ShaderNode = s;
1368 found = true;
1369 goto End;
1370 NotFound:
1371 continue;
1372 }
1373 }
1374 }
1375
1376 End:
1377 if (!found)
1378 {
1379 MDL0ShaderNode shader = new MDL0ShaderNode();
1380 Model._shadGroup.AddChild(shader);
1381 shader.DefaultAsMetal(Children.Count);
1382 ShaderNode = shader;
1383 }
1384 }
1385
1386 if (MetalMaterial != null)
1387 {
1388 Name = MetalMaterial.Name + "_ExtMtl";
1389 _activeStages = 4;
1390
1391 if (Children.Count - 1 != MetalMaterial.Children.Count)
1392 {
1393 //Remove all children
1394 for (int i = 0; i < Children.Count; i++)
1395 {
1396 ((MDL0MaterialRefNode) Children[i]).TextureNode = null;
1397 ((MDL0MaterialRefNode) Children[i]).PaletteNode = null;
1398 RemoveChild(Children[i--]);
1399 }
1400
1401 //Start over
1402 for (int i = 0; i <= MetalMaterial.Children.Count; i++)
1403 {
1404 MDL0MaterialRefNode mr = new MDL0MaterialRefNode();
1405
1406 AddChild(mr);
1407 mr.Texture = "metal00";
1408
1409 mr._bindState = TextureFrameState.Neutral;
1410 mr._texMatrixEffect.TextureMatrix = Matrix34.Identity;
1411 mr._texMatrixEffect.SCNCamera = -1;
1412 mr._texMatrixEffect.SCNLight = -1;
1413
1414 XFTexMtxInfo info = new XFTexMtxInfo
1415 {
1416 Projection = TexProjection.STQ,
1417 InputForm = TexInputForm.ABC1,
1418 TexGenType = TexTexgenType.Regular,
1419 SourceRow = TexSourceRow.Normals,
1420 EmbossSource = 5,
1421 EmbossLight = 0
1422 };
1423
1424 if (i == MetalMaterial.Children.Count)
1425 {
1426 mr._minFltr = 5;
1427 mr._magFltr = 1;
1428 mr._lodBias = -2;
1429 mr.HasTextureMatrix = true;
1430 info.Projection = TexProjection.STQ;
1431 info.InputForm = TexInputForm.ABC1;
1432 info.SourceRow = TexSourceRow.Normals;
1433 mr.Normalize = true;
1434 mr.MapMode = MappingMethod.EnvCamera;
1435 }
1436 else
1437 {
1438 info.Projection = TexProjection.ST;
1439 info.InputForm = TexInputForm.AB11;
1440 info.SourceRow = TexSourceRow.TexCoord0 + i;
1441 mr.Normalize = false;
1442 mr.MapMode = MappingMethod.TexCoord;
1443 }
1444
1445 info.TexGenType = TexTexgenType.Regular;
1446 info.EmbossSource = 5;
1447 info.EmbossLight = 0;
1448
1449 mr._texMtxFlags = info;
1450 }
1451
1452 _chan1 = new LightChannel(63, new RGBAPixel(128, 128, 128, 255), new RGBAPixel(255, 255, 255, 255),
1453 0, 0, this);
1454 C1ColorEnabled = true;
1456 C1ColorAttenuation = GXAttnFn.Spotlight;
1457 C1AlphaEnabled = true;
1459 C1AlphaAttenuation = GXAttnFn.Spotlight;
1460
1461 _chan2 = new LightChannel(63, new RGBAPixel(255, 255, 255, 255), new RGBAPixel(), 0, 0, this);
1462 C2ColorEnabled = true;
1464 C2ColorAttenuation = GXAttnFn.Specular;
1466 C2AlphaAttenuation = GXAttnFn.Specular;
1467
1470
1472 //_numLights = 2;
1473 CompareBeforeTexture = true;
1477 _normMapRefLight4 = -1;
1478
1480 }
1481 }
1482
1483 _updating = false;
1484 }
GXDiffuseFn C1AlphaDiffuseFunction
Definition: MDL0MaterialNode.cs:963
GXDiffuseFn C2AlphaDiffuseFunction
Definition: MDL0MaterialNode.cs:1085
GXAttnFn C2ColorAttenuation
Definition: MDL0MaterialNode.cs:1045
bool C1ColorEnabled
Definition: MDL0MaterialNode.cs:899
bool C2ColorEnabled
Definition: MDL0MaterialNode.cs:1021
MDL0MaterialNode()
Definition: MDL0MaterialNode.cs:29
GXAttnFn C1ColorAttenuation
Definition: MDL0MaterialNode.cs:923
MDL0MaterialNode MetalMaterial
Definition: MDL0MaterialNode.cs:1515
GXDiffuseFn C1ColorDiffuseFunction
Definition: MDL0MaterialNode.cs:915
GXAttnFn C2AlphaAttenuation
Definition: MDL0MaterialNode.cs:1093
bool C1AlphaEnabled
Definition: MDL0MaterialNode.cs:947
override void SignalPropertyChange()
Definition: MDL0MaterialNode.cs:1924
GXAttnFn C1AlphaAttenuation
Definition: MDL0MaterialNode.cs:971
GXDiffuseFn C2ColorDiffuseFunction
Definition: MDL0MaterialNode.cs:1037
MDL0GroupNode _shadGroup
Definition: MDL0Node.cs:291
List< ResourceNode > _shadList
Definition: MDL0Node.cs:305
int _texCount
Definition: MDL0ShaderNode.cs:469
bool _autoMetal
Definition: MDL0ShaderNode.cs:468
virtual void AddChild(ResourceNode child)
Definition: ResourceNode.cs:757
virtual void RemoveChild(ResourceNode child)
Definition: ResourceNode.cs:746

◆ UseProgram()

void BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.UseProgram ( MDL0ObjectNode  node,
bool  forceRemake = false 
)
inline
1945 {
1946 forceRemake = forceRemake || ShaderGenerator._forceRecompile;
1947
1948 //If a rendering property has been changed, the shaders need to be regenerated
1949 bool updateVert = string.IsNullOrEmpty(_vertexShaderSource) || forceRemake;
1950 bool updateMatFrag = string.IsNullOrEmpty(_fragShaderSource) || forceRemake;
1951 bool updateShaderFrag = ShaderNode != null && ShaderNode._fragShaderSource == null || forceRemake;
1952 bool updateProgram = _programHandle <= 0 ||
1953 updateVert || _vertexShaderHandle <= 0 ||
1954 updateMatFrag || updateShaderFrag || _fragShaderHandle <= 0 ||
1956
1957 if (updateShaderFrag)
1958 {
1960 {
1961 m._internalForceRemake = true;
1962 }
1963 }
1964
1965 _internalForceRemake = false;
1966
1967 if (updateProgram)
1968 {
1969#if !DEBUG
1970 try
1971 {
1972#endif
1973 if (_programHandle > 0)
1974 {
1975 if (_vertexShaderHandle > 0)
1976 {
1977 DeleteShader(ref _vertexShaderHandle);
1978 }
1979
1980 if (_fragShaderHandle > 0)
1981 {
1982 DeleteShader(ref _fragShaderHandle);
1983 }
1984
1985 GL.DeleteProgram(_programHandle);
1986 _programHandle = 0;
1987 }
1988
1990
1991 if (updateShaderFrag)
1992 {
1993 ShaderNode._fragShaderSource = ShaderGenerator.GenTEVFragShader();
1994 }
1995
1996 if (updateVert)
1997 {
1999 }
2000
2001 if (updateMatFrag)
2002 {
2004 }
2005
2006 string combineFrag = ShaderGenerator.CombineFragShader(
2008 ShaderNode == null ? null : ShaderNode._fragShaderSource,
2010
2011 GenShader(ref _vertexShaderHandle, _vertexShaderSource, true);
2012 GenShader(ref _fragShaderHandle, combineFrag, false);
2013
2015
2016 _programHandle = GL.CreateProgram();
2017
2018 GL.AttachShader(_programHandle, _vertexShaderHandle);
2019 GL.AttachShader(_programHandle, _fragShaderHandle);
2020
2021 GL.LinkProgram(_programHandle);
2022
2023#if DEBUG
2024 GL.GetProgram(_programHandle, ProgramParameter.LinkStatus, out int status);
2025 if (status == 0)
2026 {
2027 string log = GL.GetProgramInfoLog(_programHandle);
2028 Console.WriteLine(log);
2029 }
2030#else
2031 }
2032 catch (Exception e)
2033 {
2034 MessageBox.Show(e.ToString());
2035 }
2036#endif
2037 }
2038
2039 GL.UseProgram(_programHandle);
2041 }
int _fragShaderHandle
Definition: MDL0MaterialNode.cs:1940
int _vertexShaderHandle
Definition: MDL0MaterialNode.cs:1938
int _programHandle
Definition: MDL0MaterialNode.cs:1941
bool _internalForceRemake
Definition: MDL0MaterialNode.cs:1942
int ActiveShaderStages
Definition: MDL0MaterialNode.cs:1177
string[] _fragShaderSource
Definition: MDL0ShaderNode.cs:43
Definition: ShaderGenerator.cs:11
static void SetTarget(MDL0MaterialNode mat)
Definition: ShaderGenerator.cs:1585
static void ClearTarget()
Definition: ShaderGenerator.cs:1591
static string[] GenTEVFragShader()
Definition: ShaderGenerator.cs:819
static string GenVertexShader()
Definition: ShaderGenerator.cs:166
static string GenMaterialFragShader()
Definition: ShaderGenerator.cs:277
static void SetUniforms(MDL0MaterialNode mat)
Definition: ShaderGenerator.cs:81
static string CombineFragShader(string matSource, string[] shaderStages, int stageCount)
Definition: ShaderGenerator.cs:1599
static bool _forceRecompile
Definition: ShaderGenerator.cs:29

Member Data Documentation

◆ _activeIndStages

byte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._activeIndStages

◆ _activeStages

byte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._activeStages

◆ _alphaFunc

GXAlphaFunction BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._alphaFunc = GXAlphaFunction.Default

◆ _ambientLight

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._ambientLight

◆ _blendMode

BlendMode BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._blendMode = BlendMode.Default

◆ _chan1

LightChannel BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._chan1

◆ _chan2

LightChannel BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._chan2

◆ _constantAlpha

ConstantAlpha BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._constantAlpha = ConstantAlpha.Default

◆ _cull

CullMode BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._cull = CullMode.Cull_Inside

◆ _depthTestBeforeTexture

byte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._depthTestBeforeTexture

◆ _fog

FogAnimationFrame BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._fog

◆ _fogIndex

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._fogIndex = 4

◆ _fragShaderHandle

int BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._fragShaderHandle

◆ _fragShaderSource

string BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._fragShaderSource

◆ _indirectFrameStates

TextureFrameState [] BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._indirectFrameStates = new TextureFrameState[3]

◆ _indirectMethod1

byte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._indirectMethod1

◆ _indirectMethod2

byte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._indirectMethod2

◆ _indirectMethod3

byte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._indirectMethod3

◆ _indirectMethod4

byte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._indirectMethod4

◆ _indMtx

MatIndMtxBlock BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._indMtx = MatIndMtxBlock.Default

◆ _internalForceRemake

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._internalForceRemake

◆ _lights

GLSLLightFrame [] BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._lights = new GLSLLightFrame[8]

◆ _lightSetIndex

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._lightSetIndex = 20

◆ _normMapRefLight1

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._normMapRefLight1 = -1

◆ _normMapRefLight2

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._normMapRefLight2 = -1

◆ _normMapRefLight3

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._normMapRefLight3 = -1

◆ _normMapRefLight4

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._normMapRefLight4 = -1

◆ _objects

List<MDL0ObjectNode> BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._objects = new List<MDL0ObjectNode>()

◆ _programHandle

int BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._programHandle

◆ _scn0Applied

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._scn0Applied

◆ _tevColorBlock

MatTevColorBlock BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._tevColorBlock = MatTevColorBlock.Default

◆ _tevKonstBlock

MatTevKonstBlock BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._tevKonstBlock = MatTevKonstBlock.Default

◆ _texMtxFlags

uint BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._texMtxFlags

◆ _updating

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._updating

◆ _vertexShaderHandle

int BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._vertexShaderHandle

◆ _vertexShaderSource

string BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._vertexShaderSource

◆ _zMode

ZMode BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode._zMode = ZMode.Default

◆ amb1

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.amb1

◆ amb2

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.amb2

◆ c1

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.c1

◆ c2

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.c2

◆ c3

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.c3

◆ clr1

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.clr1

◆ clr2

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.clr2

◆ k1

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.k1

◆ k2

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.k2

◆ k3

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.k3

◆ k4

Vector4 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.k4

◆ XFCmds

List<XFData> BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.XFCmds = new List<XFData>()

Property Documentation

◆ ActiveShaderStages

int BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ActiveShaderStages
getset
1177 {
1178 get => _activeStages;
1179 set
1180 {
1181 if (!CheckIfMetal())
1182 {
1183 _activeStages = (byte) (value > ShaderNode.Stages ? ShaderNode.Stages : value < 1 ? 1 : value);
1185 }
1186 }
1187 }
bool CheckIfMetal()
Definition: MDL0MaterialNode.cs:1486
byte Stages
Definition: MDL0ShaderNode.cs:15

◆ AllowDuplicateNames

override bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.AllowDuplicateNames
get

◆ BlendLogicOp

GXLogicOp BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.BlendLogicOp
getset
582 {
583 get => _blendMode.LogicOp;
584 set
585 {
586 if (!CheckIfMetal())
587 {
588 _blendMode.LogicOp = value;
590 }
591 }
592 }
GXLogicOp LogicOp
Definition: BP.cs:162

◆ C1AlphaAmbientSource

GXColorSrc BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1AlphaAmbientSource
getset
955 {
957 set => _chan1.AlphaAmbientSource = value;
958 }
GXColorSrc AlphaAmbientSource
Definition: MDL0MaterialNode.cs:2835

◆ C1AlphaAttenuation

GXAttnFn BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1AlphaAttenuation
getset
971 {
973 set => _chan1.AlphaAttenuation = value;
974 }
GXAttnFn AlphaAttenuation
Definition: MDL0MaterialNode.cs:2859

◆ C1AlphaDiffuseFunction

GXDiffuseFn BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1AlphaDiffuseFunction
getset
963 {
965 set => _chan1.AlphaDiffuseFunction = value;
966 }
GXDiffuseFn AlphaDiffuseFunction
Definition: MDL0MaterialNode.cs:2847

◆ C1AlphaEnabled

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1AlphaEnabled
getset
947 {
948 get => _chan1.AlphaEnabled;
949 set => _chan1.AlphaEnabled = value;
950 }
bool AlphaEnabled
Definition: MDL0MaterialNode.cs:2823

◆ C1AlphaLights

MatChanLights BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1AlphaLights
getset
979 {
980 get => _chan1.AlphaLights;
981 set => _chan1.AlphaLights = value;
982 }
MatChanLights AlphaLights
Definition: MDL0MaterialNode.cs:2871

◆ C1AlphaMaterialSource

GXColorSrc BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1AlphaMaterialSource
getset
939 {
941 set => _chan1.AlphaMaterialSource = value;
942 }
GXColorSrc AlphaMaterialSource
Definition: MDL0MaterialNode.cs:2811

◆ C1AmbientColor

RGBAPixel BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1AmbientColor
getset
883 {
884 get => _chan1.AmbientColor;
885 set => _chan1.AmbientColor = value;
886 }
RGBAPixel AmbientColor
Definition: MDL0MaterialNode.cs:2701

◆ C1ColorAmbientSource

GXColorSrc BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1ColorAmbientSource
getset
907 {
909 set => _chan1.ColorAmbientSource = value;
910 }
GXColorSrc ColorAmbientSource
Definition: MDL0MaterialNode.cs:2763

◆ C1ColorAttenuation

GXAttnFn BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1ColorAttenuation
getset
923 {
925 set => _chan1.ColorAttenuation = value;
926 }
GXAttnFn ColorAttenuation
Definition: MDL0MaterialNode.cs:2787

◆ C1ColorDiffuseFunction

GXDiffuseFn BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1ColorDiffuseFunction
getset
915 {
917 set => _chan1.ColorDiffuseFunction = value;
918 }
GXDiffuseFn ColorDiffuseFunction
Definition: MDL0MaterialNode.cs:2775

◆ C1ColorEnabled

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1ColorEnabled
getset
899 {
900 get => _chan1.ColorEnabled;
901 set => _chan1.ColorEnabled = value;
902 }
bool ColorEnabled
Definition: MDL0MaterialNode.cs:2751

◆ C1ColorLights

MatChanLights BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1ColorLights
getset
931 {
932 get => _chan1.ColorLights;
933 set => _chan1.ColorLights = value;
934 }
MatChanLights ColorLights
Definition: MDL0MaterialNode.cs:2799

◆ C1ColorMaterialSource

GXColorSrc BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1ColorMaterialSource
getset
891 {
893 set => _chan1.ColorMaterialSource = value;
894 }
GXColorSrc ColorMaterialSource
Definition: MDL0MaterialNode.cs:2739

◆ C1Flags

LightingChannelFlags BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1Flags
getset
865 {
866 get => _chan1.Flags;
867 set => _chan1.Flags = value;
868 }
LightingChannelFlags Flags
Definition: MDL0MaterialNode.cs:2677

◆ C1MaterialColor

RGBAPixel BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C1MaterialColor
getset
874 {
875 get => _chan1.MaterialColor;
876 set => _chan1.MaterialColor = value;
877 }
RGBAPixel MaterialColor
Definition: MDL0MaterialNode.cs:2689

◆ C2AlphaAmbientSource

GXColorSrc BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2AlphaAmbientSource
getset
1077 {
1079 set => _chan2.AlphaAmbientSource = value;
1080 }

◆ C2AlphaAttenuation

GXAttnFn BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2AlphaAttenuation
getset
1093 {
1094 get => _chan2.AlphaAttenuation;
1095 set => _chan2.AlphaAttenuation = value;
1096 }

◆ C2AlphaDiffuseFunction

GXDiffuseFn BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2AlphaDiffuseFunction
getset
1085 {
1087 set => _chan2.AlphaDiffuseFunction = value;
1088 }

◆ C2AlphaEnabled

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2AlphaEnabled
getset
1069 {
1070 get => _chan2.AlphaEnabled;
1071 set => _chan2.AlphaEnabled = value;
1072 }

◆ C2AlphaLights

MatChanLights BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2AlphaLights
getset
1101 {
1102 get => _chan2.AlphaLights;
1103 set => _chan2.AlphaLights = value;
1104 }

◆ C2AlphaMaterialSource

GXColorSrc BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2AlphaMaterialSource
getset
1061 {
1063 set => _chan2.AlphaMaterialSource = value;
1064 }

◆ C2AmbientColor

RGBAPixel BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2AmbientColor
getset
1005 {
1006 get => _chan2.AmbientColor;
1007 set => _chan2.AmbientColor = value;
1008 }

◆ C2ColorAmbientSource

GXColorSrc BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2ColorAmbientSource
getset
1029 {
1031 set => _chan2.ColorAmbientSource = value;
1032 }

◆ C2ColorAttenuation

GXAttnFn BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2ColorAttenuation
getset
1045 {
1046 get => _chan2.ColorAttenuation;
1047 set => _chan2.ColorAttenuation = value;
1048 }

◆ C2ColorDiffuseFunction

GXDiffuseFn BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2ColorDiffuseFunction
getset
1037 {
1039 set => _chan2.ColorDiffuseFunction = value;
1040 }

◆ C2ColorEnabled

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2ColorEnabled
getset
1021 {
1022 get => _chan2.ColorEnabled;
1023 set => _chan2.ColorEnabled = value;
1024 }

◆ C2ColorLights

MatChanLights BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2ColorLights
getset
1053 {
1054 get => _chan2.ColorLights;
1055 set => _chan2.ColorLights = value;
1056 }

◆ C2ColorMaterialSource

GXColorSrc BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2ColorMaterialSource
getset
1013 {
1015 set => _chan2.ColorMaterialSource = value;
1016 }

◆ C2Flags

LightingChannelFlags BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2Flags
getset
987 {
988 get => _chan2.Flags;
989 set => _chan2.Flags = value;
990 }

◆ C2MaterialColor

RGBAPixel BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.C2MaterialColor
getset
996 {
997 get => _chan2.MaterialColor;
998 set => _chan2.MaterialColor = value;
999 }

◆ Color0

GXColorS10 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Color0
getset
236 {
237 get => new GXColorS10
238 {
240 G = _tevColorBlock.TevReg1Hi0.AG
241 };
242 set
243 {
244 if (!CheckIfMetal())
245 {
246 _tevColorBlock.TevReg1Lo.RB = value.R;
247 _tevColorBlock.TevReg1Lo.AG = value.A;
248
249 //High values are always the same...
250 _tevColorBlock.TevReg1Hi0.RB =
251 _tevColorBlock.TevReg1Hi1.RB =
252 _tevColorBlock.TevReg1Hi2.RB = value.B;
253 _tevColorBlock.TevReg1Hi0.AG =
254 _tevColorBlock.TevReg1Hi1.AG =
255 _tevColorBlock.TevReg1Hi2.AG = value.G;
256
257 c1 = value;
258
260 }
261 }
262 }
Vector4 c1
Definition: MDL0MaterialNode.cs:2159
Definition: PixelTypes.cs:759
ColorReg TevReg1Lo
Definition: MDL0.cs:1473
ColorReg TevReg1Hi0
Definition: MDL0.cs:1475
short AG
Definition: BP.cs:972
short RB
Definition: BP.cs:962

◆ Color1

GXColorS10 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Color1
getset
269 {
270 get => new GXColorS10
271 {
273 G = _tevColorBlock.TevReg2Hi0.AG
274 };
275 set
276 {
277 if (!CheckIfMetal())
278 {
279 _tevColorBlock.TevReg2Lo.RB = value.R;
280 _tevColorBlock.TevReg2Lo.AG = value.A;
281
282 //High values are always the same...
283 _tevColorBlock.TevReg2Hi0.RB =
284 _tevColorBlock.TevReg2Hi1.RB =
285 _tevColorBlock.TevReg2Hi2.RB = value.B;
286 _tevColorBlock.TevReg2Hi0.AG =
287 _tevColorBlock.TevReg2Hi1.AG =
288 _tevColorBlock.TevReg2Hi2.AG = value.G;
289
290 c2 = value;
291
293 }
294 }
295 }
Vector4 c2
Definition: MDL0MaterialNode.cs:2159
ColorReg TevReg2Hi0
Definition: MDL0.cs:1484
ColorReg TevReg2Lo
Definition: MDL0.cs:1482

◆ Color2

GXColorS10 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Color2
getset
302 {
303 get => new GXColorS10
304 {
306 G = _tevColorBlock.TevReg3Hi0.AG
307 };
308 set
309 {
310 if (!CheckIfMetal())
311 {
312 _tevColorBlock.TevReg3Lo.RB = value.R;
313 _tevColorBlock.TevReg3Lo.AG = value.A;
314
315 //High values are always the same...
316 _tevColorBlock.TevReg3Hi0.RB =
317 _tevColorBlock.TevReg3Hi1.RB =
318 _tevColorBlock.TevReg3Hi2.RB = value.B;
319 _tevColorBlock.TevReg3Hi0.AG =
320 _tevColorBlock.TevReg3Hi1.AG =
321 _tevColorBlock.TevReg3Hi2.AG = value.G;
322
323 c3 = value;
324
326 }
327 }
328 }
Vector4 c3
Definition: MDL0MaterialNode.cs:2159
ColorReg TevReg3Hi0
Definition: MDL0.cs:1493
ColorReg TevReg3Lo
Definition: MDL0.cs:1491

◆ Comp0

AlphaCompare BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Comp0
getset
406 {
407 get => _alphaFunc.Comp0;
408 set
409 {
410 if (!CheckIfMetal())
411 {
412 _alphaFunc.Comp0 = value;
414 }
415 }
416 }
AlphaCompare Comp0
Definition: BP.cs:46

◆ Comp1

AlphaCompare BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Comp1
getset
448 {
449 get => _alphaFunc.Comp1;
450 set
451 {
452 if (!CheckIfMetal())
453 {
454 _alphaFunc.Comp1 = value;
456 }
457 }
458 }
AlphaCompare Comp1
Definition: BP.cs:52

◆ CompareBeforeTexture

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.CompareBeforeTexture
getset
468 {
469 get => _depthTestBeforeTexture != 0;
470 set
471 {
472 if (!CheckIfMetal())
473 {
474 _depthTestBeforeTexture = (byte) (value ? 1 : 0);
476 }
477 }
478 }

◆ ConstantAlphaEnabled

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ConstantAlphaEnabled
getset
629 {
630 get => _constantAlpha.Enable != 0;
631 set
632 {
633 if (!CheckIfMetal())
634 {
635 _constantAlpha.Enable = (byte) (value ? 1 : 0);
637 }
638 }
639 }

◆ ConstantAlphaValue

byte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ConstantAlphaValue
getset
644 {
645 get => _constantAlpha.Value;
646 set
647 {
648 if (!CheckIfMetal())
649 {
650 _constantAlpha.Value = value;
652 }
653 }
654 }
byte Value
Definition: BP.cs:998

◆ ConstantColor0

GXColorS10 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ConstantColor0
getset
127 {
128 get => new GXColorS10
129 {
131 G = _tevKonstBlock.TevReg0Hi.AG
132 };
133 set
134 {
135 if (!CheckIfMetal())
136 {
137 _tevKonstBlock.TevReg0Lo.RB = value.R;
138 _tevKonstBlock.TevReg0Lo.AG = value.A;
139 _tevKonstBlock.TevReg0Hi.RB = value.B;
140 _tevKonstBlock.TevReg0Hi.AG = value.G;
141 k1 = value;
143 }
144 }
145 }
Vector4 k1
Definition: MDL0MaterialNode.cs:2159
ColorReg TevReg0Lo
Definition: MDL0.cs:1528
ColorReg TevReg0Hi
Definition: MDL0.cs:1530

◆ ConstantColor1

GXColorS10 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ConstantColor1
getset
152 {
153 get => new GXColorS10
154 {
156 G = _tevKonstBlock.TevReg1Hi.AG
157 };
158 set
159 {
160 if (!CheckIfMetal())
161 {
162 _tevKonstBlock.TevReg1Lo.RB = value.R;
163 _tevKonstBlock.TevReg1Lo.AG = value.A;
164 _tevKonstBlock.TevReg1Hi.RB = value.B;
165 _tevKonstBlock.TevReg1Hi.AG = value.G;
166 k2 = value;
168 }
169 }
170 }
Vector4 k2
Definition: MDL0MaterialNode.cs:2159
ColorReg TevReg1Lo
Definition: MDL0.cs:1532
ColorReg TevReg1Hi
Definition: MDL0.cs:1534

◆ ConstantColor2

GXColorS10 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ConstantColor2
getset
177 {
178 get => new GXColorS10
179 {
181 G = _tevKonstBlock.TevReg2Hi.AG
182 };
183 set
184 {
185 if (!CheckIfMetal())
186 {
187 _tevKonstBlock.TevReg2Lo.RB = value.R;
188 _tevKonstBlock.TevReg2Lo.AG = value.A;
189 _tevKonstBlock.TevReg2Hi.RB = value.B;
190 _tevKonstBlock.TevReg2Hi.AG = value.G;
191 k3 = value;
193 }
194 }
195 }
Vector4 k3
Definition: MDL0MaterialNode.cs:2159
ColorReg TevReg2Lo
Definition: MDL0.cs:1536
ColorReg TevReg2Hi
Definition: MDL0.cs:1538

◆ ConstantColor3

GXColorS10 BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ConstantColor3
getset
202 {
203 get => new GXColorS10
204 {
206 G = _tevKonstBlock.TevReg3Hi.AG
207 };
208 set
209 {
210 if (!CheckIfMetal())
211 {
212 _tevKonstBlock.TevReg3Lo.RB = value.R;
213 _tevKonstBlock.TevReg3Lo.AG = value.A;
214 _tevKonstBlock.TevReg3Hi.RB = value.B;
215 _tevKonstBlock.TevReg3Hi.AG = value.G;
216 k4 = value;
218 }
219 }
220 }
Vector4 k4
Definition: MDL0MaterialNode.cs:2159
ColorReg TevReg3Hi
Definition: MDL0.cs:1542
ColorReg TevReg3Lo
Definition: MDL0.cs:1540

◆ CullMode

CullMode BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.CullMode
getset
1211 {
1212 get => _cull;
1213 set
1214 {
1215 if (!CheckIfMetal())
1216 {
1217 _cull = value;
1219 }
1220 }
1221 }

◆ DepthFunction

GXCompare BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.DepthFunction
getset
513 {
514 get => _zMode.DepthFunction;
515 set
516 {
517 if (!CheckIfMetal())
518 {
519 _zMode.DepthFunction = value;
521 }
522 }
523 }
GXCompare DepthFunction
Definition: BP.cs:89

◆ DstFactor

BlendFactor BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.DstFactor
getset
596 {
597 get => _blendMode.DstFactor;
598 set
599 {
600 if (!CheckIfMetal())
601 {
602 _blendMode.DstFactor = value;
604 }
605 }
606 }
BlendFactor DstFactor
Definition: BP.cs:144

◆ EnableBlend

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.EnableBlend
getset
532 {
533 get => _blendMode.EnableBlend;
534 set
535 {
536 if (!CheckIfMetal())
537 {
538 _blendMode.EnableBlend = value;
540 }
541 }
542 }
bool EnableBlend
Definition: BP.cs:114

◆ EnableBlendLogic

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.EnableBlendLogic
getset
546 {
548 set
549 {
550 if (!CheckIfMetal())
551 {
552 _blendMode.EnableLogicOp = value;
554 }
555 }
556 }
bool EnableLogicOp
Definition: BP.cs:120

◆ EnableDepthTest

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.EnableDepthTest
getset
484 {
485 get => _zMode.EnableDepthTest;
486 set
487 {
488 if (!CheckIfMetal())
489 {
490 _zMode.EnableDepthTest = value;
492 }
493 }
494 }
bool EnableDepthTest
Definition: BP.cs:77

◆ EnableDepthUpdate

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.EnableDepthUpdate
getset
498 {
500 set
501 {
502 if (!CheckIfMetal())
503 {
504 _zMode.EnableDepthUpdate = value;
506 }
507 }
508 }
bool EnableDepthUpdate
Definition: BP.cs:83

◆ FogIndex

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.FogIndex
getset
1249 {
1250 get => _fogIndex;
1251 set
1252 {
1253 if (!CheckIfMetal())
1254 {
1255 _fogIndex = value;
1257
1259 }
1260 }
1261 }
void UpdateAsMetal()
Definition: MDL0MaterialNode.cs:1333

◆ ID

int BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ID
get

◆ ImageCount

int BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ImageCount
get

◆ IndirectMethodTex1

IndirectMethod BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectMethodTex1
getset
662 {
664 set
665 {
666 if (!CheckIfMetal())
667 {
668 _indirectMethod1 = (byte) value;
670 }
671 }
672 }
IndirectMethod
Definition: MDL0MaterialNode.cs:829

◆ IndirectMethodTex2

IndirectMethod BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectMethodTex2
getset
676 {
678 set
679 {
680 if (!CheckIfMetal())
681 {
682 _indirectMethod2 = (byte) value;
684 }
685 }
686 }

◆ IndirectMethodTex3

IndirectMethod BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectMethodTex3
getset
690 {
692 set
693 {
694 if (!CheckIfMetal())
695 {
696 _indirectMethod3 = (byte) value;
698 }
699 }
700 }

◆ IndirectMethodTex4

IndirectMethod BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectMethodTex4
getset
704 {
706 set
707 {
708 if (!CheckIfMetal())
709 {
710 _indirectMethod4 = (byte) value;
712 }
713 }
714 }

◆ IndirectShaderStages

int BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectShaderStages
getset
1192 {
1193 get => _activeIndStages;
1194 set
1195 {
1196 if (!CheckIfMetal())
1197 {
1198 _activeIndStages = (byte) (value > 4 ? 4 : value < 0 ? 0 : value);
1200 }
1201 }
1202 }

◆ IndirectTex1ScaleS

IndTexScale BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectTex1ScaleS
getset
718 {
719 get => _indMtx.SS0val.S_Scale0;
720 set
721 {
722 if (!CheckIfMetal())
723 {
724 _indMtx.SS0val.S_Scale0 = value;
726 }
727 }
728 }
RAS1_SS SS0val
Definition: MDL0.cs:1356
IndTexScale S_Scale0
Definition: BP.cs:919

◆ IndirectTex1ScaleT

IndTexScale BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectTex1ScaleT
getset
732 {
733 get => _indMtx.SS0val.T_Scale0;
734 set
735 {
736 if (!CheckIfMetal())
737 {
738 _indMtx.SS0val.T_Scale0 = value;
740 }
741 }
742 }
IndTexScale T_Scale0
Definition: BP.cs:925

◆ IndirectTex2ScaleS

IndTexScale BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectTex2ScaleS
getset
746 {
747 get => _indMtx.SS0val.S_Scale1;
748 set
749 {
750 if (!CheckIfMetal())
751 {
752 _indMtx.SS0val.S_Scale1 = value;
754 }
755 }
756 }
IndTexScale S_Scale1
Definition: BP.cs:931

◆ IndirectTex2ScaleT

IndTexScale BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectTex2ScaleT
getset
760 {
761 get => _indMtx.SS0val.T_Scale1;
762 set
763 {
764 if (!CheckIfMetal())
765 {
766 _indMtx.SS0val.T_Scale1 = value;
768 }
769 }
770 }
IndTexScale T_Scale1
Definition: BP.cs:937

◆ IndirectTex3ScaleS

IndTexScale BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectTex3ScaleS
getset
774 {
775 get => _indMtx.SS1val.S_Scale0;
776 set
777 {
778 if (!CheckIfMetal())
779 {
780 _indMtx.SS1val.S_Scale0 = value;
782 }
783 }
784 }
RAS1_SS SS1val
Definition: MDL0.cs:1359

◆ IndirectTex3ScaleT

IndTexScale BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectTex3ScaleT
getset
788 {
789 get => _indMtx.SS1val.T_Scale0;
790 set
791 {
792 if (!CheckIfMetal())
793 {
794 _indMtx.SS1val.T_Scale0 = value;
796 }
797 }
798 }

◆ IndirectTex4ScaleS

IndTexScale BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectTex4ScaleS
getset
802 {
803 get => _indMtx.SS1val.S_Scale1;
804 set
805 {
806 if (!CheckIfMetal())
807 {
808 _indMtx.SS1val.S_Scale1 = value;
810 }
811 }
812 }

◆ IndirectTex4ScaleT

IndTexScale BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IndirectTex4ScaleT
getset
816 {
817 get => _indMtx.SS1val.T_Scale1;
818 set
819 {
820 if (!CheckIfMetal())
821 {
822 _indMtx.SS1val.T_Scale1 = value;
824 }
825 }
826 }

◆ IsMetal

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.IsMetal
get

◆ LightChannel0

LightChannel BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.LightChannel0
get

◆ LightChannel1

LightChannel BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.LightChannel1
get

◆ LightSetIndex

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.LightSetIndex
getset
1231 {
1232 get => _lightSetIndex;
1233 set
1234 {
1235 if (!CheckIfMetal())
1236 {
1237 _lightSetIndex = value;
1238
1240
1242 }
1243 }
1244 }

◆ Logic

AlphaOp BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Logic
getset
420 {
421 get => _alphaFunc.Logic;
422 set
423 {
424 if (!CheckIfMetal())
425 {
426 _alphaFunc.Logic = value;
428 }
429 }
430 }
AlphaOp Logic
Definition: BP.cs:58

◆ MetalMaterial

MDL0MaterialNode BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.MetalMaterial
get
1515 {
1516 get
1517 {
1518 foreach (MDL0MaterialNode t in Model._matList)
1519 {
1520 if (!IsMetal)
1521 {
1522 if (t.Name.StartsWith(Name) && t.IsMetal && Name.Length + 7 == t.Name.Length)
1523 {
1524 return t;
1525 }
1526 }
1527 else if (Name.StartsWith(t.Name) && !t.IsMetal && t.Name.Length + 7 == Name.Length)
1528 {
1529 return t;
1530 }
1531 }
1532
1533 return null;
1534 }
1535 }
List< ResourceNode > _matList
Definition: MDL0Node.cs:304

◆ NormMapRefLight1

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.NormMapRefLight1
getset
1267 {
1268 get => _normMapRefLight1;
1269 set
1270 {
1271 if (!CheckIfMetal())
1272 {
1273 _normMapRefLight1 = value;
1275 }
1276 }
1277 }

◆ NormMapRefLight2

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.NormMapRefLight2
getset
1283 {
1284 get => _normMapRefLight2;
1285 set
1286 {
1287 if (!CheckIfMetal())
1288 {
1289 _normMapRefLight1 = value;
1291 }
1292 }
1293 }

◆ NormMapRefLight3

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.NormMapRefLight3
getset
1299 {
1300 get => _normMapRefLight3;
1301 set
1302 {
1303 if (!CheckIfMetal())
1304 {
1305 _normMapRefLight1 = value;
1307 }
1308 }
1309 }

◆ NormMapRefLight4

sbyte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.NormMapRefLight4
getset
1315 {
1316 get => _normMapRefLight4;
1317 set
1318 {
1319 if (!CheckIfMetal())
1320 {
1321 _normMapRefLight1 = value;
1323 }
1324 }
1325 }

◆ Objects

MDL0ObjectNode [] BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Objects
get
103 {
104 get
105 {
106 if (!IsMetal)
107 {
108 return _objects.ToArray();
109 }
110
111 return MetalMaterial == null ? null : MetalMaterial._objects.ToArray();
112 }
113 }
List< MDL0ObjectNode > _objects
Definition: MDL0MaterialNode.cs:87

◆ Ref0

byte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Ref0
getset
392 {
393 get => _alphaFunc._ref0;
394 set
395 {
396 if (!CheckIfMetal())
397 {
398 _alphaFunc._ref0 = value;
400 }
401 }
402 }
byte _ref0
Definition: BP.cs:43

◆ Ref1

byte BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Ref1
getset
434 {
435 get => _alphaFunc._ref1;
436 set
437 {
438 if (!CheckIfMetal())
439 {
440 _alphaFunc._ref1 = value;
442 }
443 }
444 }
byte _ref1
Definition: BP.cs:43

◆ ResourceFileType

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

◆ Shader

string BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Shader
getset
360 {
361 get => _shader == null ? null : _shader.Name;
362 set
363 {
364 if (CheckIfMetal())
365 {
366 return;
367 }
368
369 if (string.IsNullOrEmpty(value))
370 {
371 ShaderNode = null;
372 }
373 else
374 {
375 MDL0ShaderNode node = Model.FindChild($"Shaders/{value}", false) as MDL0ShaderNode;
376 if (node != null)
377 {
378 ShaderNode = node;
379 }
380 }
381
383 }
384 }
override string Name
Definition: MDL0ShaderNode.cs:473
ResourceNode FindChild(string path)
Definition: ResourceNode.cs:1342

◆ ShaderNode

MDL0ShaderNode BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.ShaderNode
getset
338 {
339 get => _shader;
340 set
341 {
342 if (_shader == value)
343 {
344 return;
345 }
346
347 _shader?._materials.Remove(this);
348
349 if ((_shader = value) != null)
350 {
351 _shader._materials.Add(this);
352 ActiveShaderStages = _shader.Stages;
353 }
354 }
355 }
List< MDL0MaterialNode > _materials
Definition: MDL0ShaderNode.cs:19

◆ SrcFactor

BlendFactor BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.SrcFactor
getset
568 {
569 get => _blendMode.SrcFactor;
570 set
571 {
572 if (!CheckIfMetal())
573 {
574 _blendMode.SrcFactor = value;
576 }
577 }
578 }
BlendFactor SrcFactor
Definition: BP.cs:150

◆ Subtract

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.Subtract
getset
610 {
611 get => _blendMode.Subtract;
612 set
613 {
614 if (!CheckIfMetal())
615 {
616 _blendMode.Subtract = value;
618 }
619 }
620 }
bool Subtract
Definition: BP.cs:156

◆ TextureMatrixMode

TexMatrixMode BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.TextureMatrixMode
getset
1113 {
1114 get => (TexMatrixMode) _texMtxFlags;
1115 set
1116 {
1117 if (!CheckIfMetal())
1118 {
1119 _texMtxFlags = (uint) value;
1120 foreach (MDL0MaterialRefNode r in Children)
1121 {
1122 r._bindState.MatrixMode = r._frameState.MatrixMode = value;
1123 }
1124
1126 }
1127 }
1128 }
TexMatrixMode
Definition: MDL0.cs:204

◆ UserEntries

UserDataCollection BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.UserEntries
getset
54 {
55 get => _userEntries;
56 set
57 {
58 _userEntries = value;
60 }
61 }

◆ XLUMaterial

bool BrawlLib.SSBB.ResourceNodes.MDL0MaterialNode.XLUMaterial
getset
1133 {
1134 get => _usageFlags[31];
1135 set
1136 {
1137 if (!CheckIfMetal())
1138 {
1139 //Forget all these checks.
1140 //We'll let the user have complete freedom, as I've seen objects use materials
1141 //as XLU when this bool wasn't on anyway.
1142
1143 //bool prev = _usageFlags[31];
1144 _usageFlags[31] = value;
1145
1146 //string message = "";
1147 //for (int i = 0; i < _objects.Count; i++)
1148 // _objects[i].EvalMaterials(ref message);
1149
1150 //if (message.Length != 0)
1151 // if (MessageBox.Show(null, "Are you sure you want to continue?\nThe following objects will no longer use this material:\n" + message, "Continue?", MessageBoxButtons.YesNo) == DialogResult.No)
1152 // {
1153 // _changed = false;
1154 // _usageFlags[31] = prev;
1155 // return;
1156 // }
1157
1158 //message = "";
1159 //for (int i = 0; i < _objects.Count; i++)
1160 // _objects[i].FixMaterials(ref message);
1161
1162 //if (message.Length != 0)
1163 // MessageBox.Show("The following objects no longer use this material:\n" + message);
1164
1166 }
1167 }
1168 }

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