2019-07-11 23:38:29 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Switch_Toolbox.Library.Rendering;
|
2019-07-12 21:53:57 +00:00
|
|
|
|
using Switch_Toolbox.Library;
|
2019-07-11 23:38:29 +00:00
|
|
|
|
using GL_EditorFramework.GL_Core;
|
|
|
|
|
using GL_EditorFramework.Interfaces;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics.OpenGL;
|
2019-07-13 00:13:27 +00:00
|
|
|
|
using SuperBMDLib.Materials.Enums;
|
2019-07-11 23:38:29 +00:00
|
|
|
|
|
|
|
|
|
namespace FirstPlugin
|
|
|
|
|
{
|
|
|
|
|
public class BMD_Renderer : GenericModelRenderer
|
|
|
|
|
{
|
2019-07-12 21:53:57 +00:00
|
|
|
|
public List<BMDTextureWrapper> TextureList = new List<BMDTextureWrapper>();
|
|
|
|
|
|
2019-07-11 23:38:29 +00:00
|
|
|
|
public override void OnRender(GLControl control)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2019-07-12 21:53:57 +00:00
|
|
|
|
|
2019-07-13 00:13:27 +00:00
|
|
|
|
public override void SetRenderData(STGenericMaterial mat, ShaderProgram shader, STGenericObject m)
|
|
|
|
|
{
|
|
|
|
|
var bmdMaterial = (BMDMaterialWrapper)mat;
|
|
|
|
|
|
|
|
|
|
switch (bmdMaterial.Material.CullMode)
|
|
|
|
|
{
|
|
|
|
|
case CullMode.None:
|
|
|
|
|
GL.Disable(EnableCap.CullFace);
|
|
|
|
|
break;
|
|
|
|
|
case CullMode.Back:
|
|
|
|
|
GL.CullFace(CullFaceMode.Back);
|
|
|
|
|
break;
|
|
|
|
|
case CullMode.Front:
|
|
|
|
|
GL.CullFace(CullFaceMode.Front);
|
|
|
|
|
break;
|
|
|
|
|
case CullMode.All:
|
|
|
|
|
GL.CullFace(CullFaceMode.FrontAndBack);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-12 21:53:57 +00:00
|
|
|
|
public override int BindTexture(STGenericMatTexture tex, ShaderProgram shader)
|
|
|
|
|
{
|
|
|
|
|
GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1);
|
|
|
|
|
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID);
|
|
|
|
|
|
|
|
|
|
string activeTex = tex.Name;
|
|
|
|
|
|
|
|
|
|
foreach (var texture in TextureList)
|
|
|
|
|
{
|
|
|
|
|
if (TextureList.IndexOf(texture) == ((BMDTextureMap)tex).TextureIndex)
|
|
|
|
|
{
|
|
|
|
|
BindGLTexture(tex, shader, TextureList[((BMDTextureMap)tex).TextureIndex]);
|
|
|
|
|
return tex.textureUnit + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tex.textureUnit + 1;
|
|
|
|
|
}
|
2019-07-11 23:38:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|