public void Default() { Name = "NewRef"; _minFltr = 1; _magFltr = 1; UWrapMode = MatWrapMode.Repeat; VWrapMode = MatWrapMode.Repeat; _bindState = TextureFrameState.Neutral; _texMatrixEffect.TextureMatrix = Matrix34.Identity; _texMatrixEffect.SCNCamera = -1; _texMatrixEffect.SCNLight = -1; _texMatrixEffect.MapMode = MappingMethod.TexCoord; _texMtxFlags = new XFTexMtxInfo() { Projection = TexProjection.ST, InputForm = TexInputForm.AB11, TexGenType = TexTexgenType.Regular, SourceRow = TexSourceRow.TexCoord0, EmbossSource = 5, EmbossLight = 0 }; _texture = Model.FindOrCreateTexture(_name); _texture._references.Add(this); }
public void Default() { Name = "NewRef"; Index1 = Index; Index2 = Index; _minFltr = 1; _magFltr = 1; UWrapMode = WrapMode.Repeat; VWrapMode = WrapMode.Repeat; _flags = (TexFlags)0xF; _texFlags.TexScale = new Vector2(1); _bindState._scale = new Vector3(1); _texMatrix.TexMtx = Matrix43.Identity; _texMatrix.TexUnk1 = -1; _texMatrix.TexUnk2 = -1; _texMatrix.TexUnk4 = 1; _projection = (int)TexProjection.ST; _inputForm = (int)TexInputForm.AB11; _texGenType = (int)TexTexgenType.Regular; _sourceRow = (int)TexSourceRow.TexCoord0; _embossSource = 4; _embossLight = 2; getTexMtxVal(); _texture = Model.FindOrCreateTexture(_name); _texture._references.Add(this); }
internal override void Bind(GLContext ctx) { if (_texture != null) { _texture.Prepare(ctx, this); } if (PAT0Texture != null) { if (!PAT0Textures.ContainsKey(PAT0Texture)) { PAT0Textures[PAT0Texture] = new MDL0TextureNode(PAT0Texture) { Source = null, palette = PAT0Palette != null?RootNode.FindChildByType(PAT0Palette, true, ResourceNodes.ResourceType.PLT0) as PLT0Node : null } } ; PAT0Textures[PAT0Texture].Prepare(ctx, this); } }
internal void ApplyPAT0Texture(PAT0TextureNode node, int index) { PAT0TextureEntryNode prev = null; if (node != null && index != 0 && node.Children.Count > 0) { foreach (PAT0TextureEntryNode next in node.Children) { if (next.Index == 0) { prev = next; continue; } if (prev.key <= index - 1 && next.key > index - 1) { break; } prev = next; } PAT0Texture = prev.Texture; PAT0Palette = prev.Palette; if (!PAT0Textures.ContainsKey(PAT0Texture)) { TEX0Node texture = RootNode.FindChildByType(PAT0Texture, true, ResourceNodes.ResourceType.TEX0) as TEX0Node; if (texture != null) { PAT0Textures[PAT0Texture] = new MDL0TextureNode(texture.Name) { Source = texture, palette = PAT0Palette != null?RootNode.FindChildByType(PAT0Palette, true, ResourceNodes.ResourceType.PLT0) as PLT0Node : null } } ; } return; } else { PAT0Texture = PAT0Palette = null; } }
internal void Bind(int prog) { if (!String.IsNullOrEmpty(PAT0Texture)) { if (!PAT0Textures.ContainsKey(PAT0Texture)) { PAT0Textures[PAT0Texture] = new MDL0TextureNode(PAT0Texture) { Source = null, _palette = !String.IsNullOrEmpty(PAT0Palette) ? RootNode.FindChildByType(PAT0Palette, true, ResourceNodes.ResourceType.PLT0) as PLT0Node : null } } ; MDL0TextureNode t = PAT0Textures[PAT0Texture]; t.Bind(); t.Prepare(this, prog, PAT0Palette); } else if (_texture != null) { _texture.Prepare(this, prog); } }
public static int Compare(MDL0TextureNode t1, MDL0TextureNode t2) { return(String.Compare(t1.Name, t2.Name, false)); }
internal void Bind(TKContext ctx, int prog) { if (!String.IsNullOrEmpty(PAT0Texture)) { if (!PAT0Textures.ContainsKey(PAT0Texture)) PAT0Textures[PAT0Texture] = new MDL0TextureNode(PAT0Texture) { Source = null, palette = !String.IsNullOrEmpty(PAT0Palette) ? RootNode.FindChildByType(PAT0Palette, true, ResourceNodes.ResourceType.PLT0) as PLT0Node : null }; MDL0TextureNode t = PAT0Textures[PAT0Texture]; t.Bind(ctx); t.Prepare(this, prog); } else if (_texture != null) _texture.Prepare(this, prog); }
internal void ApplyPAT0Texture(PAT0TextureNode node, int index) { PAT0TextureEntryNode prev = null; if (node != null && index != 0 && node.Children.Count > 0) { foreach (PAT0TextureEntryNode next in node.Children) { if (next.Index == 0) { prev = next; continue; } if (prev._frame <= index - 1 && next._frame > index - 1) break; prev = next; } PAT0Texture = prev.Texture; PAT0Palette = prev.Palette; if (!PAT0Textures.ContainsKey(PAT0Texture)) { TEX0Node texture = RootNode.FindChildByType(PAT0Texture, true, ResourceNodes.ResourceType.TEX0) as TEX0Node; if (texture != null) PAT0Textures[PAT0Texture] = new MDL0TextureNode(texture.Name) { Source = texture, palette = !String.IsNullOrEmpty(PAT0Palette) ? RootNode.FindChildByType(PAT0Palette, true, ResourceNodes.ResourceType.PLT0) as PLT0Node : null }; } return; } else PAT0Texture = PAT0Palette = null; }
public override bool OnInitialize() { MDL0TextureRef* header = Header; _texPtr = header->_texPtr; _pltPtr = header->_pltPtr; _index1 = header->_index1; _index2 = header->_index2; _uWrap = header->_uWrap; _vWrap = header->_vWrap; _minFltr = header->_minFltr; _magFltr = header->_magFltr; _lodBias = header->_lodBias; _maxAniso = header->_maxAniso; _clampBias = header->_clampBias == 1; _texelInterp = header->_texelInterp == 1; _pad = header->_pad; if (header->_texOffset != 0) { if (_replaced && header->_texOffset >= Parent.WorkingUncompressed.Length) Name = null; else { if (_replaced) Name = header->TextureName; else _name = header->TextureName; _texture = Model.FindOrCreateTexture(_name); _texture._references.Add(this); } } if (header->_pltOffset != 0) { if (_replaced && header->_pltOffset >= Parent.WorkingUncompressed.Length) _palette = null; else { string name = header->PaletteName; _palette = Model.FindOrCreatePalette(name); _palette._references.Add(this); } } int len = ((MDL0MaterialNode)Parent).XFCommands.Length; if (len != 0 && Index * 2 < len) { TexMtxFlags = new XFTexMtxInfo(((MDL0MaterialNode)Parent).XFCommands[Index * 2].values[0]); DualTexFlags = new XFDualTex(((MDL0MaterialNode)Parent).XFCommands[Index * 2 + 1].values[0]); getValues(); } //if (PaletteNode == null && TextureNode != null) //{ // if (TextureNode.Source == null) // TextureNode.GetSource(); // if (TextureNode.Source is TEX0Node && ((TEX0Node)TextureNode.Source).HasPalette) // { // Model._errors.Add("A palette was not set to texture reference " + Index + " in material " + Parent.Index + " (" + Parent.Name + ")."); // PaletteNode = Model.FindOrCreatePalette(TextureNode.Name); // SignalPropertyChange(); // } //} MDL0TexSRTData* TexSettings = ((MDL0MaterialNode)Parent).Header->TexMatrices(((MDL0MaterialNode)Parent)._initVersion); _texFlags = TexSettings->GetTexFlags(Index); _texMatrix = TexSettings->GetTexMatrices(Index); _flags = (TexFlags)((((MDL0MaterialNode)Parent)._layerFlags >> (4 * Index)) & 0xF); _bindState = new FrameState( new Vector3(_texFlags.TexScale._x, _texFlags.TexScale._y, 1), new Vector3(_texFlags.TexRotation, 0, 0), new Vector3(_texFlags.TexTranslation._x, _texFlags.TexTranslation._y, 0)); return false; }
public void Default() { Name = "NewRef"; _minFltr = 1; _magFltr = 1; UWrapMode = WrapMode.Repeat; VWrapMode = WrapMode.Repeat; _flags = (TexFlags)0xF; _texFlags.TexScale = new Vector2(1); _bindState._scale = new Vector3(1); _texMatrix.TexMtx = Matrix43.Identity; _texMatrix.SCNCamera = -1; _texMatrix.SCNLight = -1; _texMatrix.Identity = 1; _projection = (int)TexProjection.ST; _inputForm = (int)TexInputForm.AB11; _texGenType = (int)TexTexgenType.Regular; _sourceRow = (int)TexSourceRow.TexCoord0; _embossSource = 4; _embossLight = 2; getTexMtxVal(); _texture = Model.FindOrCreateTexture(_name); _texture._references.Add(this); }
protected override bool OnInitialize() { MDL0TextureRef *header = Header; _unk2 = header->_unk2; _unk3 = header->_unk3; _index1 = header->_index1; _index2 = header->_index2; _uWrap = header->_uWrap; _vWrap = header->_vWrap; _minFltr = header->_minFltr; _magFltr = header->_magFltr; _float = header->_lodBias; _unk10 = header->_unk10; _unk11 = header->_unk11 == 1; _unk12 = header->_unk12 == 1; _unk13 = header->_unk13; if (header->_stringOffset != 0) { if (!Material._replaced) { _name = header->ResourceString; } else { _name = Material._name + "_Texture" + Index; } _texture = Model.FindOrCreateTexture(_name); _texture._references.Add(this); } if (header->_secondaryOffset != 0) { string name; if (!Material._replaced) { name = header->SecondaryTexture; } else { name = Material._name + "_Texture" + Index; } _palette = Model.FindOrCreatePalette(name); _palette._references.Add(this); } if (((MDL0MaterialNode)Parent).XFCommands.Length != 0) { TexMtxFlags = new XFTexMtxInfo(((MDL0MaterialNode)Parent).XFCommands[Index * 2].values[0]); DualTexFlags = new XFDualTex(((MDL0MaterialNode)Parent).XFCommands[Index * 2 + 1].values[0]); getValues(); } //if (PaletteNode == null && TextureNode != null) //{ // if (TextureNode.Source == null) // TextureNode.GetSource(); // if (TextureNode.Source is TEX0Node && ((TEX0Node)TextureNode.Source).HasPalette) // { // Model._errors.Add("A palette was not set to texture reference " + Index + " in material " + Parent.Index + " (" + Parent.Name + ")."); // PaletteNode = Model.FindOrCreatePalette(TextureNode.Name); // SignalPropertyChange(); // } //} MDL0MtlTexSettings *TexSettings = ((MDL0MaterialNode)Parent).Header->TexMatrices(Model._version); _texFlags = TexSettings->GetTexFlags(Index); _texMatrix = TexSettings->GetTexMatrices(Index); _flags = (TexFlags)((((MDL0MaterialNode)Parent)._layerFlags >> (4 * Index)) & 0xF); _bindState = new FrameState( new Vector3(_texFlags.TexScale._x, _texFlags.TexScale._y, 1), new Vector3(_texFlags.TexRotation, 0, 0), new Vector3(_texFlags.TexTranslation._x, _texFlags.TexTranslation._y, 0)); return(false); }
public MDL0TextureNode FindOrCreateTexture(string name) { if (_texGroup == null) AddChild(_texGroup = new MDL0GroupNode(MDLResourceType.Textures), false); else foreach (MDL0TextureNode n in _texGroup.Children) if (n._name == name) return n; MDL0TextureNode node = new MDL0TextureNode(name); _texGroup.AddChild(node, false); return node; }
public override bool OnInitialize() { MDL0TextureRef *header = Header; _uWrap = header->_uWrap; _vWrap = header->_vWrap; _minFltr = header->_minFltr; _magFltr = header->_magFltr; _lodBias = header->_lodBias; _maxAniso = header->_maxAniso; _clampBias = header->_clampBias == 1; _texelInterp = header->_texelInterp == 1; if (header->_texOffset != 0) { if (_replaced && header->_texOffset >= Parent.WorkingUncompressed.Length) { Name = null; } else { if (_replaced) { Name = header->TextureName; } else { _name = header->TextureName; } _texture = Model.FindOrCreateTexture(_name); _texture._references.Add(this); } } if (header->_pltOffset != 0) { if (_replaced && header->_pltOffset >= Parent.WorkingUncompressed.Length) { _palette = null; } else { string name = header->PaletteName; _palette = Model.FindOrCreatePalette(name); _palette._references.Add(this); } } int len = Material.XFCmds.Count; if (len != 0 && Index * 2 + 1 < len) { _texMtxFlags = new XFTexMtxInfo(Material.XFCmds[Index * 2]._values[0]); _dualTexFlags = new XFDualTex(Material.XFCmds[Index * 2 + 1]._values[0]); } //if (PaletteNode == null && TextureNode != null) //{ // if (TextureNode.Source == null) // TextureNode.GetSource(); // if (TextureNode.Source is TEX0Node && ((TEX0Node)TextureNode.Source).HasPalette) // { // Model._errors.Add("A palette was not set to texture reference " + Index + " in material " + Parent.Index + " (" + Parent.Name + ")."); // PaletteNode = Model.FindOrCreatePalette(TextureNode.Name); // SignalPropertyChange(); // } //} MDL0TexSRTData *TexSettings = Material.Header->TexMatrices(Material._initVersion); _texMatrixEffect = TexSettings->GetTexMatrices(Index); _bindState = TexSettings->GetTexSRT(Index); _bindState.MatrixMode = Material.TextureMatrixMode; return(false); }
public override bool OnInitialize() { MDL0TextureRef *header = Header; _texPtr = header->_texPtr; _pltPtr = header->_pltPtr; _index1 = header->_index1; _index2 = header->_index2; _uWrap = header->_uWrap; _vWrap = header->_vWrap; _minFltr = header->_minFltr; _magFltr = header->_magFltr; _lodBias = header->_lodBias; _maxAniso = header->_maxAniso; _clampBias = header->_clampBias == 1; _texelInterp = header->_texelInterp == 1; _pad = header->_pad; if (header->_texOffset != 0) { if (_replaced && header->_texOffset >= Parent.WorkingUncompressed.Length) { Name = null; } else { if (_replaced) { Name = header->TextureName; } else { _name = header->TextureName; } _texture = Model.FindOrCreateTexture(_name); _texture._references.Add(this); } } if (header->_pltOffset != 0) { if (_replaced && header->_pltOffset >= Parent.WorkingUncompressed.Length) { _palette = null; } else { string name = header->PaletteName; _palette = Model.FindOrCreatePalette(name); _palette._references.Add(this); } } int len = ((MDL0MaterialNode)Parent).XFCommands.Length; if (len != 0 && Index * 2 < len) { TexMtxFlags = new XFTexMtxInfo(((MDL0MaterialNode)Parent).XFCommands[Index * 2].values[0]); DualTexFlags = new XFDualTex(((MDL0MaterialNode)Parent).XFCommands[Index * 2 + 1].values[0]); getValues(); } //if (PaletteNode == null && TextureNode != null) //{ // if (TextureNode.Source == null) // TextureNode.GetSource(); // if (TextureNode.Source is TEX0Node && ((TEX0Node)TextureNode.Source).HasPalette) // { // Model._errors.Add("A palette was not set to texture reference " + Index + " in material " + Parent.Index + " (" + Parent.Name + ")."); // PaletteNode = Model.FindOrCreatePalette(TextureNode.Name); // SignalPropertyChange(); // } //} MDL0TexSRTData *TexSettings = ((MDL0MaterialNode)Parent).Header->TexMatrices(((MDL0MaterialNode)Parent)._initVersion); _texFlags = TexSettings->GetTexFlags(Index); _texMatrix = TexSettings->GetTexMatrices(Index); _flags = (TexFlags)((((MDL0MaterialNode)Parent)._layerFlags >> (4 * Index)) & 0xF); _bindState = new FrameState( new Vector3(_texFlags.TexScale._x, _texFlags.TexScale._y, 1), new Vector3(_texFlags.TexRotation, 0, 0), new Vector3(_texFlags.TexTranslation._x, _texFlags.TexTranslation._y, 0)); return(false); }
public static int Compare(MDL0TextureNode t1, MDL0TextureNode t2) { return String.Compare(t1.Name, t2.Name, false); }
private void lstTextures_SelectedValueChanged(object sender, EventArgs e) { if (_selectedTexture != null) _selectedTexture.Selected = false; if ((_selectedTexture = lstTextures.SelectedItem as MDL0TextureNode) != null) { _selectedTexture.Selected = true; overObjPnl.Invalidate(); overTexPnl.Invalidate(); if (_mainWindow.syncTexObjToolStripMenuItem.Checked) _selectedTexture.ObjOnly = true; TargetTexRef = _selectedPolygon != null ? _selectedPolygon.UsableMaterialNode.FindChild(_selectedTexture.Name, true) as MDL0MaterialRefNode : null; } if (!_updating) _mainWindow.ModelPanel.Invalidate(); }