Fix orientation cube texture conflict finally!

This commit is contained in:
KillzXGaming 2019-05-13 17:17:36 -04:00
parent e3f720289b
commit 713370881f
12 changed files with 54 additions and 22 deletions

Binary file not shown.

View file

@ -194,7 +194,7 @@ namespace FirstPlugin
SetDefaultTextureAttributes(mat, shader);
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);
@ -209,7 +209,7 @@ namespace FirstPlugin
GL.ActiveTexture(TextureUnit.Texture10);
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)
{
@ -233,13 +233,12 @@ namespace FirstPlugin
public static int BindTexture(STGenericMatTexture tex)
{
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;
foreach (var bcresTexContainer in PluginRuntime.bcresTexContainers)
{
if (bcresTexContainer.ResourceNodes.ContainsKey(activeTex))
{
TXOBWrapper txob = (TXOBWrapper)bcresTexContainer.ResourceNodes[activeTex];
@ -248,6 +247,7 @@ namespace FirstPlugin
txob.LoadOpenGLTexture();
BindGLTexture(tex, txob.RenderableTex.TexID);
break;
}
}
return tex.textureUnit + 1;

View file

@ -238,6 +238,33 @@ namespace FirstPlugin
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)
@ -463,7 +490,7 @@ namespace FirstPlugin
SetDefaultTextureAttributes(mat, shader);
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.Uniform1(shader["weightRamp1"], 11);
@ -478,7 +505,7 @@ namespace FirstPlugin
GL.ActiveTexture(TextureUnit.Texture10);
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["BakeShadowMap"], 0);
@ -550,7 +577,7 @@ namespace FirstPlugin
public static int BindTexture(MatTexture tex, bool IsWiiU)
{
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;
if (tex.animatedTexName != "")

View file

@ -67,7 +67,7 @@ namespace Switch_Toolbox.Library.Forms
comboBox2.Items.Clear();
if (RenderTools.defaultTex != null)
texid = RenderTools.defaultTex.Id;
texid = RenderTools.defaultTex.RenderableTex.TexID;
foreach (var item in Textures)
comboBox2.Items.Add(item.texture.Text);

View file

@ -67,7 +67,7 @@ namespace Switch_Toolbox.Library.Forms.test
comboBox2.Items.Clear();
if (RenderTools.defaultTex != null)
texid = RenderTools.defaultTex.Id;
texid = RenderTools.defaultTex.RenderableTex.TexID;
foreach (var item in Textures)
comboBox2.Items.Add(item.texture.Text);

View file

@ -124,6 +124,7 @@ namespace Switch_Toolbox.Library.Rendering
TexID = loadImage(this);
}
public static int loadImage(RenderableTex t)
{
if (!t.GLInitialized)
@ -149,6 +150,12 @@ namespace Switch_Toolbox.Library.Rendering
return texID;
}
public void Bind()
{
GL.BindTexture(TextureTarget.Texture2D, TexID);
}
private static int getImageSize(RenderableTex t)
{
switch (t.pixelInternalFormat)

View file

@ -24,17 +24,17 @@ namespace Switch_Toolbox.Library
}
}
private static Texture2D defaulttex;
public static Texture2D defaultTex
public static STGenericTexture defaulttex;
public static STGenericTexture defaultTex
{
get
{
if (defaulttex == null)
{
defaulttex = new Texture2D();
defaultTex.LoadImageData(Properties.Resources.DefaultTexture);
defaulttex = new GenericBitmapTexture(Properties.Resources.DefaultTexture);
defaulttex.LoadOpenGLTexture();
defaulttex.RenderableTex.Bind();
}
return defaulttex;
}
set
@ -77,18 +77,16 @@ namespace Switch_Toolbox.Library
specularpbr = value;
}
}
public static Texture2D uvtestPattern;
public static Texture2D uvTestPattern
public static STGenericTexture uvtestPattern;
public static STGenericTexture uvTestPattern
{
get
{
if (uvtestPattern == null)
{
uvtestPattern = new Texture2D();
uvtestPattern.LoadImageData(Properties.Resources.UVPattern);
uvtestPattern.TextureWrapR = TextureWrapMode.Repeat;
uvtestPattern.TextureWrapS = TextureWrapMode.Repeat;
uvtestPattern.TextureWrapT = TextureWrapMode.Repeat;
uvTestPattern = new GenericBitmapTexture(Properties.Resources.UVPattern);
uvTestPattern.LoadOpenGLTexture();
uvTestPattern.RenderableTex.Bind();
}
return uvtestPattern;
}

Binary file not shown.

Binary file not shown.