Skip to content

Commit

Permalink
I am an idiot
Browse files Browse the repository at this point in the history
  • Loading branch information
WholesomeIsland committed Mar 3, 2021
1 parent 957238e commit ffceaa0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
1 change: 0 additions & 1 deletion Hello Quad/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Abstractions;
using Silk.NET.OpenGL;
using Silk.NET.Windowing;
using Silk.NET.Windowing;
using System.Drawing;

namespace Hello_Quad
Expand Down
1 change: 0 additions & 1 deletion Helo Quad Abstractions/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Abstractions;
using Silk.NET.OpenGL;
using Silk.NET.Windowing;
using Silk.NET.Windowing;
using System.Drawing;

namespace Helo_Quad_Abstractions
Expand Down
7 changes: 2 additions & 5 deletions Model Loading/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using Abstractions;
using Silk.NET.OpenGL;
using Silk.NET.OpenGL;
using Silk.NET.Windowing;
using Abstractions.Model.GL;
using System.Drawing;
using System.Collections.Generic;
using Texture = Abstractions.Texture;
using Matrix4x4 = Abstractions.math.Matrix4x4;
using System.Numerics;
using System;
Expand Down Expand Up @@ -111,7 +108,7 @@ static void Main(string[] args)
}
};
}
model = new GLModel(GL.GetApi(window), "gun.obj", "Shader.vert", "Shader.frag", false);
model = new GLModel(GL.GetApi(window), "gun.obj", "Shader.vert", "Shader.frag", false, new[] {Assimp.TextureType.Diffuse});
cam = new Camera(new Vector3(0, 0, -10), new Vector3(0, 0, 1), new Vector3(0, 1, 0), 800 / 600);
};
window.Closing += () => {
Expand Down
2 changes: 1 addition & 1 deletion Model.Sdk/Model.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageProjectUrl>https://www.github.com/Wholesomeisland/CommonOpenGLAbstractions</PackageProjectUrl>
<RepositoryUrl>https://www.github.com/Wholesomeisland/CommonOpenGLAbstractions</RepositoryUrl>
<PackageTags>OpenGL Silk.NET</PackageTags>
<Version>2.0.0</Version>
<Version>2.2.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
23 changes: 11 additions & 12 deletions Model.Sdk/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ public class GLModel
public List<GLObjTextured> objs;
string vertPath, fragPath;
bool isDynamic;
void processNode(Node node, Scene scene)
void processNode(Node node, Scene scene, TextureType[] texturesToLoad)
{
for (int i = 0; i < node.MeshCount; i++)
{
Mesh mesh = scene.Meshes[i];
meshes.Add(mesh);
objs.Add(processMesh(mesh, scene));
objs.Add(processMesh(mesh, scene, texturesToLoad));
}
for (int i = 0; i < node.ChildCount; i++)
{
processNode(node.Children[i], scene);
processNode(node.Children[i], scene, texturesToLoad);
}
}
GLObjTextured processMesh(Mesh mesh, Scene scene)
GLObjTextured processMesh(Mesh mesh, Scene scene, TextureType[] texturesToLoad)
{
List<Vertex> vlist = new List<Vertex>();
List<uint> ind = new List<uint>();
Expand All @@ -60,12 +60,11 @@ GLObjTextured processMesh(Mesh mesh, Scene scene)
}
}
var matIndex = scene.Materials[mesh.MaterialIndex];
List<Texture> diffTex = LoadTextures(matIndex, TextureType.Diffuse);
List<Texture> specTex = LoadTextures(matIndex, TextureType.Specular);
List<Texture> normTex = LoadTextures(matIndex, TextureType.Normals);
tex.AddRange(diffTex);
tex.AddRange(specTex);
tex.AddRange(normTex);
foreach (var item in texturesToLoad)
{
List<Texture> Tex = LoadTextures(matIndex, item);
tex.AddRange(Tex);
}
return new GLObjTextured(gl, vlistToflist(vlist).ToArray(), ind.ToArray(), vertPath, fragPath, isDynamic, tex);
}
List<Texture> LoadTextures(Material mat, TextureType type)
Expand Down Expand Up @@ -96,7 +95,7 @@ List<float> vlistToflist(List<Vertex> vlist)
}
return retval;
}
public GLModel(Silk.NET.OpenGL.GL _gl, string ModelName, string vertPath, string FragPath, bool isDynamic)
public GLModel(Silk.NET.OpenGL.GL _gl, string ModelName, string vertPath, string FragPath, bool isDynamic, TextureType[] texturesToLoad)
{
this.vertPath = vertPath;
this.fragPath = FragPath;
Expand All @@ -106,7 +105,7 @@ public GLModel(Silk.NET.OpenGL.GL _gl, string ModelName, string vertPath, string
objs = new List<GLObjTextured>();
var ctx = new AssimpContext();
model = ctx.ImportFile(ModelName, PostProcessSteps.Triangulate | PostProcessSteps.GenerateSmoothNormals | PostProcessSteps.FlipUVs | PostProcessSteps.CalculateTangentSpace);
processNode(model.RootNode, model);
processNode(model.RootNode, model,texturesToLoad);
}
public void SetMatrix4(string name, Abstractions.math.Matrix4x4 matrix)
{
Expand Down

0 comments on commit ffceaa0

Please sign in to comment.