mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 20:43:09 +00:00
Fix orientation cube texture conflict finally!
This commit is contained in:
parent
e3f720289b
commit
713370881f
12 changed files with 54 additions and 22 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -194,7 +194,7 @@ namespace FirstPlugin
|
||||||
SetDefaultTextureAttributes(mat, shader);
|
SetDefaultTextureAttributes(mat, shader);
|
||||||
|
|
||||||
GL.ActiveTexture(TextureUnit.Texture0 + 1);
|
GL.ActiveTexture(TextureUnit.Texture0 + 1);
|
||||||
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.Id);
|
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID);
|
||||||
|
|
||||||
GL.Uniform1(shader["debugOption"], 2);
|
GL.Uniform1(shader["debugOption"], 2);
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ namespace FirstPlugin
|
||||||
|
|
||||||
GL.ActiveTexture(TextureUnit.Texture10);
|
GL.ActiveTexture(TextureUnit.Texture10);
|
||||||
GL.Uniform1(shader["UVTestPattern"], 10);
|
GL.Uniform1(shader["UVTestPattern"], 10);
|
||||||
GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.Id);
|
GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.RenderableTex.TexID);
|
||||||
|
|
||||||
foreach (STGenericMatTexture matex in mat.TextureMaps)
|
foreach (STGenericMatTexture matex in mat.TextureMaps)
|
||||||
{
|
{
|
||||||
|
@ -233,13 +233,12 @@ namespace FirstPlugin
|
||||||
public static int BindTexture(STGenericMatTexture tex)
|
public static int BindTexture(STGenericMatTexture tex)
|
||||||
{
|
{
|
||||||
GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1);
|
GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1);
|
||||||
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.Id);
|
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID);
|
||||||
|
|
||||||
string activeTex = tex.Name;
|
string activeTex = tex.Name;
|
||||||
|
|
||||||
foreach (var bcresTexContainer in PluginRuntime.bcresTexContainers)
|
foreach (var bcresTexContainer in PluginRuntime.bcresTexContainers)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (bcresTexContainer.ResourceNodes.ContainsKey(activeTex))
|
if (bcresTexContainer.ResourceNodes.ContainsKey(activeTex))
|
||||||
{
|
{
|
||||||
TXOBWrapper txob = (TXOBWrapper)bcresTexContainer.ResourceNodes[activeTex];
|
TXOBWrapper txob = (TXOBWrapper)bcresTexContainer.ResourceNodes[activeTex];
|
||||||
|
@ -248,6 +247,7 @@ namespace FirstPlugin
|
||||||
txob.LoadOpenGLTexture();
|
txob.LoadOpenGLTexture();
|
||||||
|
|
||||||
BindGLTexture(tex, txob.RenderableTex.TexID);
|
BindGLTexture(tex, txob.RenderableTex.TexID);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tex.textureUnit + 1;
|
return tex.textureUnit + 1;
|
||||||
|
|
|
@ -238,6 +238,33 @@ namespace FirstPlugin
|
||||||
|
|
||||||
public void CenterCamera(GL_ControlModern control)
|
public void CenterCamera(GL_ControlModern control)
|
||||||
{
|
{
|
||||||
|
Vector3 minVector = new Vector3(0);
|
||||||
|
Vector3 maxVector = new Vector3(0);
|
||||||
|
if (models.Count != 0)
|
||||||
|
{
|
||||||
|
minVector = models[0].MinPosition;
|
||||||
|
maxVector = models[0].MaxPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 translation = control.CameraPosition;
|
||||||
|
|
||||||
|
float minSize = Math.Min(Math.Min(minVector.X, minVector.Y), minVector.Z);
|
||||||
|
float maxSize = Math.Max(Math.Max(maxVector.X, maxVector.Y), maxVector.Z);
|
||||||
|
float scale = (10f / (maxSize - minSize)); //Try to adjust to screen
|
||||||
|
if (maxSize - minSize == 0) scale = 1;
|
||||||
|
|
||||||
|
Matrix4 centerMatrix = Matrix4.CreateTranslation(
|
||||||
|
-(minVector.X + maxVector.X) / 2,
|
||||||
|
-(minVector.Y + maxVector.Y) / 2,
|
||||||
|
-(minVector.Z + maxVector.Z) / 2);
|
||||||
|
Matrix4 translationMatrix = Matrix4.CreateTranslation(
|
||||||
|
(-translation.X / 50) / scale,
|
||||||
|
(translation.Y / 50) / scale,
|
||||||
|
control.CameraDistance / scale);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
control.CameraPosition = centerMatrix.ExtractTranslation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector4 GenerateBoundingSphere(IEnumerable<Vector4> boundingSpheres)
|
public static Vector4 GenerateBoundingSphere(IEnumerable<Vector4> boundingSpheres)
|
||||||
|
@ -463,7 +490,7 @@ namespace FirstPlugin
|
||||||
SetDefaultTextureAttributes(mat, shader);
|
SetDefaultTextureAttributes(mat, shader);
|
||||||
|
|
||||||
GL.ActiveTexture(TextureUnit.Texture0 + 1);
|
GL.ActiveTexture(TextureUnit.Texture0 + 1);
|
||||||
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.Id);
|
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID);
|
||||||
|
|
||||||
GL.ActiveTexture(TextureUnit.Texture11);
|
GL.ActiveTexture(TextureUnit.Texture11);
|
||||||
GL.Uniform1(shader["weightRamp1"], 11);
|
GL.Uniform1(shader["weightRamp1"], 11);
|
||||||
|
@ -478,7 +505,7 @@ namespace FirstPlugin
|
||||||
|
|
||||||
GL.ActiveTexture(TextureUnit.Texture10);
|
GL.ActiveTexture(TextureUnit.Texture10);
|
||||||
GL.Uniform1(shader["UVTestPattern"], 10);
|
GL.Uniform1(shader["UVTestPattern"], 10);
|
||||||
GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.Id);
|
GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.RenderableTex.TexID);
|
||||||
|
|
||||||
GL.Uniform1(shader["normalMap"], 0);
|
GL.Uniform1(shader["normalMap"], 0);
|
||||||
GL.Uniform1(shader["BakeShadowMap"], 0);
|
GL.Uniform1(shader["BakeShadowMap"], 0);
|
||||||
|
@ -550,7 +577,7 @@ namespace FirstPlugin
|
||||||
public static int BindTexture(MatTexture tex, bool IsWiiU)
|
public static int BindTexture(MatTexture tex, bool IsWiiU)
|
||||||
{
|
{
|
||||||
GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1);
|
GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1);
|
||||||
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.Id);
|
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID);
|
||||||
|
|
||||||
string activeTex = tex.Name;
|
string activeTex = tex.Name;
|
||||||
if (tex.animatedTexName != "")
|
if (tex.animatedTexName != "")
|
||||||
|
|
Binary file not shown.
|
@ -67,7 +67,7 @@ namespace Switch_Toolbox.Library.Forms
|
||||||
comboBox2.Items.Clear();
|
comboBox2.Items.Clear();
|
||||||
|
|
||||||
if (RenderTools.defaultTex != null)
|
if (RenderTools.defaultTex != null)
|
||||||
texid = RenderTools.defaultTex.Id;
|
texid = RenderTools.defaultTex.RenderableTex.TexID;
|
||||||
|
|
||||||
foreach (var item in Textures)
|
foreach (var item in Textures)
|
||||||
comboBox2.Items.Add(item.texture.Text);
|
comboBox2.Items.Add(item.texture.Text);
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace Switch_Toolbox.Library.Forms.test
|
||||||
comboBox2.Items.Clear();
|
comboBox2.Items.Clear();
|
||||||
|
|
||||||
if (RenderTools.defaultTex != null)
|
if (RenderTools.defaultTex != null)
|
||||||
texid = RenderTools.defaultTex.Id;
|
texid = RenderTools.defaultTex.RenderableTex.TexID;
|
||||||
|
|
||||||
foreach (var item in Textures)
|
foreach (var item in Textures)
|
||||||
comboBox2.Items.Add(item.texture.Text);
|
comboBox2.Items.Add(item.texture.Text);
|
||||||
|
|
|
@ -124,6 +124,7 @@ namespace Switch_Toolbox.Library.Rendering
|
||||||
|
|
||||||
TexID = loadImage(this);
|
TexID = loadImage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int loadImage(RenderableTex t)
|
public static int loadImage(RenderableTex t)
|
||||||
{
|
{
|
||||||
if (!t.GLInitialized)
|
if (!t.GLInitialized)
|
||||||
|
@ -149,6 +150,12 @@ namespace Switch_Toolbox.Library.Rendering
|
||||||
|
|
||||||
return texID;
|
return texID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Bind()
|
||||||
|
{
|
||||||
|
GL.BindTexture(TextureTarget.Texture2D, TexID);
|
||||||
|
}
|
||||||
|
|
||||||
private static int getImageSize(RenderableTex t)
|
private static int getImageSize(RenderableTex t)
|
||||||
{
|
{
|
||||||
switch (t.pixelInternalFormat)
|
switch (t.pixelInternalFormat)
|
||||||
|
|
|
@ -23,18 +23,18 @@ namespace Switch_Toolbox.Library
|
||||||
brdfpbr != null);
|
brdfpbr != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Texture2D defaulttex;
|
public static STGenericTexture defaulttex;
|
||||||
public static Texture2D defaultTex
|
public static STGenericTexture defaultTex
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (defaulttex == null)
|
if (defaulttex == null)
|
||||||
{
|
{
|
||||||
defaulttex = new Texture2D();
|
defaulttex = new GenericBitmapTexture(Properties.Resources.DefaultTexture);
|
||||||
defaultTex.LoadImageData(Properties.Resources.DefaultTexture);
|
defaulttex.LoadOpenGLTexture();
|
||||||
|
defaulttex.RenderableTex.Bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaulttex;
|
return defaulttex;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
|
@ -77,18 +77,16 @@ namespace Switch_Toolbox.Library
|
||||||
specularpbr = value;
|
specularpbr = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static Texture2D uvtestPattern;
|
public static STGenericTexture uvtestPattern;
|
||||||
public static Texture2D uvTestPattern
|
public static STGenericTexture uvTestPattern
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (uvtestPattern == null)
|
if (uvtestPattern == null)
|
||||||
{
|
{
|
||||||
uvtestPattern = new Texture2D();
|
uvTestPattern = new GenericBitmapTexture(Properties.Resources.UVPattern);
|
||||||
uvtestPattern.LoadImageData(Properties.Resources.UVPattern);
|
uvTestPattern.LoadOpenGLTexture();
|
||||||
uvtestPattern.TextureWrapR = TextureWrapMode.Repeat;
|
uvTestPattern.RenderableTex.Bind();
|
||||||
uvtestPattern.TextureWrapS = TextureWrapMode.Repeat;
|
|
||||||
uvtestPattern.TextureWrapT = TextureWrapMode.Repeat;
|
|
||||||
}
|
}
|
||||||
return uvtestPattern;
|
return uvtestPattern;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue