2019-07-12 00:23:47 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2019-07-12 00:46:45 +00:00
|
|
|
|
using System.Windows.Forms;
|
2019-07-16 21:35:21 +00:00
|
|
|
|
using Toolbox.Library;
|
|
|
|
|
using Toolbox.Library.Forms;
|
2019-07-12 00:23:47 +00:00
|
|
|
|
using SuperBMDLib.Materials;
|
|
|
|
|
|
|
|
|
|
namespace FirstPlugin
|
|
|
|
|
{
|
|
|
|
|
public class BMDMaterialWrapper : STGenericMaterial
|
|
|
|
|
{
|
2019-07-13 00:13:27 +00:00
|
|
|
|
public Material Material;
|
2019-07-12 00:23:47 +00:00
|
|
|
|
SuperBMDLib.Model ParentModel;
|
|
|
|
|
|
2019-07-13 01:48:56 +00:00
|
|
|
|
public bool isTransparent
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (Material.Flag & 3) == 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-12 00:23:47 +00:00
|
|
|
|
public BMDMaterialWrapper(Material mat, SuperBMDLib.Model model)
|
|
|
|
|
{
|
|
|
|
|
Material = mat;
|
|
|
|
|
ParentModel = model;
|
|
|
|
|
|
2019-07-12 00:46:45 +00:00
|
|
|
|
Text = mat.Name;
|
|
|
|
|
|
2019-07-12 00:23:47 +00:00
|
|
|
|
int textureUnit = 1;
|
|
|
|
|
if (mat.TextureIndices[0] != -1)
|
|
|
|
|
{
|
|
|
|
|
int texIndex = mat.TextureIndices[0];
|
|
|
|
|
|
2019-07-12 21:53:57 +00:00
|
|
|
|
BMDTextureMap matTexture = new BMDTextureMap(this);
|
|
|
|
|
matTexture.TextureIndex = texIndex;
|
2019-07-12 00:23:47 +00:00
|
|
|
|
matTexture.Name = ParentModel.Textures[texIndex].Name;
|
|
|
|
|
matTexture.Type = STGenericMatTexture.TextureType.Diffuse;
|
|
|
|
|
matTexture.textureUnit = textureUnit++;
|
2019-07-13 01:53:00 +00:00
|
|
|
|
|
2019-08-06 19:57:36 +00:00
|
|
|
|
matTexture.WrapModeS = ConvertWrapMode(ParentModel.Textures[texIndex].WrapS);
|
|
|
|
|
matTexture.WrapModeT = ConvertWrapMode(ParentModel.Textures[texIndex].WrapT);
|
|
|
|
|
matTexture.MinFilter = ConvertMinFilter(ParentModel.Textures[texIndex].MinFilter);
|
|
|
|
|
matTexture.MagFilter = ConvertMagFilter(ParentModel.Textures[texIndex].MagFilter);
|
2019-07-12 00:23:47 +00:00
|
|
|
|
|
|
|
|
|
TextureMaps.Add(matTexture);
|
2019-07-12 00:46:45 +00:00
|
|
|
|
|
|
|
|
|
foreach (var textureIndex in mat.TextureIndices)
|
|
|
|
|
{
|
|
|
|
|
if (textureIndex != -1)
|
|
|
|
|
Nodes.Add(ParentModel.Textures[textureIndex].Name);
|
|
|
|
|
}
|
2019-07-12 00:23:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-06 19:57:36 +00:00
|
|
|
|
private STTextureWrapMode ConvertWrapMode(BinaryTextureImage.WrapModes wrapMode)
|
|
|
|
|
{
|
|
|
|
|
switch (wrapMode)
|
|
|
|
|
{
|
|
|
|
|
case BinaryTextureImage.WrapModes.Repeat: return STTextureWrapMode.Repeat;
|
|
|
|
|
case BinaryTextureImage.WrapModes.MirroredRepeat: return STTextureWrapMode.Mirror;
|
|
|
|
|
case BinaryTextureImage.WrapModes.ClampToEdge: return STTextureWrapMode.Clamp;
|
|
|
|
|
default:
|
|
|
|
|
return STTextureWrapMode.Repeat;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private STTextureMinFilter ConvertMinFilter(BinaryTextureImage.FilterMode filterMode)
|
|
|
|
|
{
|
|
|
|
|
switch (filterMode)
|
|
|
|
|
{
|
|
|
|
|
case BinaryTextureImage.FilterMode.Linear: return STTextureMinFilter.Linear;
|
|
|
|
|
case BinaryTextureImage.FilterMode.LinearMipmapLinear: return STTextureMinFilter.Linear;
|
|
|
|
|
case BinaryTextureImage.FilterMode.LinearMipmapNearest: return STTextureMinFilter.LinearMipMapNearest;
|
|
|
|
|
case BinaryTextureImage.FilterMode.Nearest: return STTextureMinFilter.Nearest;
|
|
|
|
|
case BinaryTextureImage.FilterMode.NearestMipmapLinear: return STTextureMinFilter.NearestMipmapLinear;
|
|
|
|
|
case BinaryTextureImage.FilterMode.NearestMipmapNearest: return STTextureMinFilter.NearestMipmapNearest;
|
|
|
|
|
default:
|
|
|
|
|
return STTextureMinFilter.Linear;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private STTextureMagFilter ConvertMagFilter(BinaryTextureImage.FilterMode filterMode)
|
|
|
|
|
{
|
|
|
|
|
switch (filterMode)
|
|
|
|
|
{
|
|
|
|
|
case BinaryTextureImage.FilterMode.Linear: return STTextureMagFilter.Linear;
|
|
|
|
|
case BinaryTextureImage.FilterMode.LinearMipmapLinear: return STTextureMagFilter.Linear;
|
|
|
|
|
case BinaryTextureImage.FilterMode.LinearMipmapNearest: return STTextureMagFilter.Linear;
|
|
|
|
|
case BinaryTextureImage.FilterMode.Nearest: return STTextureMagFilter.Nearest;
|
|
|
|
|
case BinaryTextureImage.FilterMode.NearestMipmapLinear: return STTextureMagFilter.Nearest;
|
|
|
|
|
case BinaryTextureImage.FilterMode.NearestMipmapNearest: return STTextureMagFilter.Nearest;
|
|
|
|
|
default:
|
|
|
|
|
return STTextureMagFilter.Linear;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-12 00:46:45 +00:00
|
|
|
|
public override void OnClick(TreeView treeView)
|
|
|
|
|
{
|
|
|
|
|
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.GetActiveContent(typeof(STPropertyGrid));
|
|
|
|
|
if (editor == null)
|
|
|
|
|
{
|
|
|
|
|
editor = new STPropertyGrid();
|
|
|
|
|
LibraryGUI.LoadEditor(editor);
|
|
|
|
|
}
|
|
|
|
|
editor.Text = Text;
|
|
|
|
|
editor.Dock = DockStyle.Fill;
|
|
|
|
|
editor.LoadProperty(Material, null);
|
|
|
|
|
}
|
2019-07-12 00:23:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|