diff --git a/Diamond/Diamond.csproj b/Diamond/Diamond.csproj index 6cd34ea..37e24f4 100644 --- a/Diamond/Diamond.csproj +++ b/Diamond/Diamond.csproj @@ -55,6 +55,10 @@ + + + + diff --git a/Diamond/Level/Level.cs b/Diamond/Level/Level.cs new file mode 100644 index 0000000..e5ab0df --- /dev/null +++ b/Diamond/Level/Level.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using Diamond.Buffers; +using Diamond.Shaders; +using Newtonsoft.Json; +using OpenTK.Graphics.OpenGL4; + +namespace Diamond.Level +{ + public class Level + { + [JsonProperty("models")] + private string[] MeshNames { get; set; } + + [JsonProperty("tiles")] + private TileInfo[] TileInfos { get; set; } + + private TileData[] _allTiles; + private ObjVertex[] _allVertices; + + private Mesh[] _meshes; + private TileGroup[] _tileGroups; + + private GLBuffer _tileBuffer; + private GLBuffer _vertexBuffer; + + private void InitializeBuffers() + { + _tileBuffer = new GLBuffer(BufferTarget.ArrayBuffer, BufferUsageHint.DynamicDraw); + _tileBuffer.Data(_allTiles); + + _vertexBuffer = new GLBuffer(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw); + _vertexBuffer.Data(_allVertices); + } + + public static Level LoadLevel(string file) + { + var level = JsonConvert.DeserializeObject(File.ReadAllText(file)); + + var dir = Path.GetDirectoryName(file); + + + // region assemble mesh map + var meshes = new Dictionary>(); + + foreach (var meshPath in level.MeshNames) + { + var objects = Mesh.FromObj(Path.Combine(dir, meshPath)); + Debug.WriteLine(string.Join("\n", objects.Select(o => o.Name))); + foreach (var mesh in objects) + { + meshes[mesh.Name] = mesh; + } + } + + // region store all used meshes + level._meshes = meshes.Values.ToArray(); + // join meshes + level._allVertices = Mesh.Join(level._meshes); + Debug.WriteLine(level._allVertices.Length); + Debug.WriteLine(level._meshes[1].Vertices.Length); + Debug.WriteLine(level._meshes[1].Vertices.Offset); + + var groupDict = new Dictionary>(); + + foreach (var tileInfo in level.TileInfos) + { + var meshName = tileInfo.Mesh; + if (!groupDict.ContainsKey(meshName)) + groupDict[meshName] = new List(); + groupDict[meshName].Add(tileInfo.TileData); + } + + var groupList = new List(); + var tileSubArrayList = new List>(); + + foreach (var kvp in groupDict) + { + var sa = new SubArray(kvp.Value.ToArray()); + groupList.Add(new TileGroup(sa, meshes[kvp.Key])); + tileSubArrayList.Add(sa); + } + + level._tileGroups = groupList.ToArray(); + + level._allTiles = SubArray.Join(tileSubArrayList); + + level.InitializeBuffers(); + + return level; + } + + public void Draw() + { + if (Program.Current == null) + throw new Exception("cant render without a shader."); + + Program.Current.SetAttribPointers(_vertexBuffer); + Program.Current.SetAttribPointers(_tileBuffer); + + foreach (var tileGroup in _tileGroups) + { + tileGroup.Mesh.DrawInstanced(tileGroup.Tiles); + } + } + } +} \ No newline at end of file diff --git a/hexworld/TileData.cs b/Diamond/Level/TileData.cs similarity index 94% rename from hexworld/TileData.cs rename to Diamond/Level/TileData.cs index 4e386b2..ae16c46 100644 --- a/hexworld/TileData.cs +++ b/Diamond/Level/TileData.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using OpenTK; -namespace hexworld +namespace Diamond.Level { [VertexData(Divisor = 1)] public struct TileData diff --git a/Diamond/Level/TileGroup.cs b/Diamond/Level/TileGroup.cs new file mode 100644 index 0000000..32b20a0 --- /dev/null +++ b/Diamond/Level/TileGroup.cs @@ -0,0 +1,16 @@ +using Diamond.Buffers; + +namespace Diamond.Level +{ + internal class TileGroup + { + public SubArray Tiles; + public Mesh Mesh; + + public TileGroup(SubArray tiles, Mesh mesh) + { + Tiles = tiles; + Mesh = mesh; + } + } +} \ No newline at end of file diff --git a/Diamond/Level/TileInfo.cs b/Diamond/Level/TileInfo.cs new file mode 100644 index 0000000..1cbb3a6 --- /dev/null +++ b/Diamond/Level/TileInfo.cs @@ -0,0 +1,21 @@ +using Newtonsoft.Json; +using OpenTK; + +namespace Diamond.Level +{ + internal class TileInfo + { + [JsonProperty("mesh")] + public string Mesh { get; set; } + + [JsonProperty("pos")] + public Vector3 Position { get; set; } + + public TileData TileData => new TileData(Position); + + public override string ToString() + { + return $"Mesh: {Mesh}, Position: {Position}"; + } + } +} \ No newline at end of file diff --git a/hexworld/HexRender.cs b/hexworld/HexRender.cs index 1006a86..e0c5095 100644 --- a/hexworld/HexRender.cs +++ b/hexworld/HexRender.cs @@ -1,146 +1,14 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; using System.Drawing; -using System.IO; -using System.Linq; -using Diamond; -using Diamond.Buffers; +using Diamond.Level; using Diamond.Shaders; using Diamond.Textures; -using Newtonsoft.Json; using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL4; namespace hexworld { - public class Level - { - [JsonProperty("models")] - private string[] MeshNames { get; set; } - - [JsonProperty("tiles")] - private TileInfo[] TileInfos { get; set; } - - private TileData[] _allTiles; - private ObjVertex[] _allVertices; - - private Mesh[] _meshes; - private TileGroup[] _tileGroups; - - private GLBuffer _tileBuffer; - private GLBuffer _vertexBuffer; - - private void InitializeBuffers() - { - _tileBuffer = new GLBuffer(BufferTarget.ArrayBuffer, BufferUsageHint.DynamicDraw); - _tileBuffer.Data(_allTiles); - - _vertexBuffer = new GLBuffer(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw); - _vertexBuffer.Data(_allVertices); - } - - public static Level LoadLevel(string file) - { - var level = JsonConvert.DeserializeObject(File.ReadAllText(file)); - - var dir = Path.GetDirectoryName(file); - - - // region assemble mesh map - var meshes = new Dictionary>(); - - foreach (var meshPath in level.MeshNames) - { - var objects = Mesh.FromObj(Path.Combine(dir, meshPath)); - Debug.WriteLine(string.Join("\n", objects.Select(o => o.Name))); - foreach (var mesh in objects) - { - meshes[mesh.Name] = mesh; - } - } - - // region store all used meshes - level._meshes = meshes.Values.ToArray(); - // join meshes - level._allVertices = Mesh.Join(level._meshes); - Debug.WriteLine(level._allVertices.Length); - Debug.WriteLine(level._meshes[1].Vertices.Length); - Debug.WriteLine(level._meshes[1].Vertices.Offset); - - var groupDict = new Dictionary>(); - - foreach (var tileInfo in level.TileInfos) - { - var meshName = tileInfo.Mesh; - if (!groupDict.ContainsKey(meshName)) - groupDict[meshName] = new List(); - groupDict[meshName].Add(tileInfo.TileData); - } - - var groupList = new List(); - var tileSubArrayList = new List>(); - - foreach (var kvp in groupDict) - { - var sa = new SubArray(kvp.Value.ToArray()); - groupList.Add(new TileGroup(sa, meshes[kvp.Key])); - tileSubArrayList.Add(sa); - } - - level._tileGroups = groupList.ToArray(); - - level._allTiles = SubArray.Join(tileSubArrayList); - - level.InitializeBuffers(); - - return level; - } - - public void Draw() - { - if (Program.Current == null) - throw new Exception("cant render without a shader."); - - Program.Current.SetAttribPointers(_vertexBuffer); - Program.Current.SetAttribPointers(_tileBuffer); - - foreach (var tileGroup in _tileGroups) - { - tileGroup.Mesh.DrawInstanced(tileGroup.Tiles); - } - } - } - - public class TileInfo - { - [JsonProperty("mesh")] - public string Mesh { get; set; } - - [JsonProperty("pos")] - public Vector3 Position { get; set; } - - public TileData TileData => new TileData(Position); - - public override string ToString() - { - return $"Mesh: {Mesh}, Position: {Position}"; - } - } - - public class TileGroup - { - public SubArray Tiles; - public Mesh Mesh; - - public TileGroup(SubArray tiles, Mesh mesh) - { - Tiles = tiles; - Mesh = mesh; - } - } - public class HexRender : GameWindow { #region Fields diff --git a/hexworld/hexworld.csproj b/hexworld/hexworld.csproj index 24fc3e1..e54f5e3 100644 --- a/hexworld/hexworld.csproj +++ b/hexworld/hexworld.csproj @@ -51,28 +51,12 @@ - - - Always - - - Always - - - Always - - - Always - - - Always - @@ -84,21 +68,9 @@ Always - - Always - Always - - Always - - - Always - - - Always - Designer Always diff --git a/hexworld/res/data_tile_grass.json b/hexworld/res/data_tile_grass.json deleted file mode 100644 index ae3b19b..0000000 --- a/hexworld/res/data_tile_grass.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { "pos": { "x": -2, "y": -2, "z": 0 } }, - { "pos": { "x": -2, "y": -1, "z": 0 } }, - { "pos": { "x": -2, "y": 0, "z": 0 } }, - { "pos": { "x": -2, "y": 1, "z": 0 } }, - { "pos": { "x": -2, "y": 2, "z": 0 } }, - { "pos": { "x": 2, "y": -2, "z": 0 } }, - { "pos": { "x": 2, "y": -1, "z": 0 } }, - { "pos": { "x": 2, "y": 0, "z": 0 } }, - { "pos": { "x": 2, "y": 1, "z": 0 } }, - { "pos": { "x": 2, "y": 2, "z": 0 } }, - { "pos": { "x": -1, "y": -2, "z": 0 } }, - { "pos": { "x": -1, "y": 2, "z": 0 } }, - { "pos": { "x": 0, "y": -2, "z": 0 } }, - { "pos": { "x": 0, "y": 2, "z": 0 } }, - { "pos": { "x": 1, "y": -2, "z": 0 } }, - { "pos": { "x": 1, "y": 2, "z": 0 } }, -] \ No newline at end of file diff --git a/hexworld/res/data_tile_gray.json b/hexworld/res/data_tile_gray.json deleted file mode 100644 index faa6954..0000000 --- a/hexworld/res/data_tile_gray.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { "pos": { "x": 0, "y": 0, "z": 0 } }, - { "pos": { "x": -1, "y": -1, "z": 0 } }, - { "pos": { "x": 0, "y": -1, "z": 0 } }, - { "pos": { "x": 1, "y": -1, "z": 0 } }, - { "pos": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": 0, "y": 0, "z": 0 } }, - { "pos": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": -1, "y": 1, "z": 0 } }, - { "pos": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": 1, "y": 1, "z": 0 } }, -] \ No newline at end of file diff --git a/hexworld/res/data_tile_stone.json b/hexworld/res/data_tile_stone.json deleted file mode 100644 index 254eb42..0000000 --- a/hexworld/res/data_tile_stone.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { "pos": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": 0, "y": 1, "z": 1 } }, - { "pos": { "x": 0, "y": -1, "z": 1 } }, - { "pos": { "x": -1, "y": 0, "z": 1 } }, - { "pos": { "x": 1, "y": 0, "z": 1 } }, -] \ No newline at end of file diff --git a/hexworld/res/data_tile_table.json b/hexworld/res/data_tile_table.json deleted file mode 100644 index 7048bf1..0000000 --- a/hexworld/res/data_tile_table.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { "pos": { "x": 3, "y": 3, "z": 1 } }, - { "pos": { "x": -3, "y": 3, "z": 1 } }, - { "pos": { "x": 3, "y": -3, "z": 1 } }, - { "pos": { "x": -3, "y": -3, "z": 1 } }, -] \ No newline at end of file diff --git a/hexworld/res/data_vert_cubes.json b/hexworld/res/data_vert_cubes.json deleted file mode 100644 index e137050..0000000 --- a/hexworld/res/data_vert_cubes.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { "pos": { "x": .5, "y": .5, "z": -.5 }, "uv": { "x": 1, "y": .5 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": -.5 }, "uv": { "x": 1, "y": .5 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": -.5 }, "uv": { "x": 1, "y": .5 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": -.5 }, "uv": { "x": 1, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": -.5 }, "uv": { "x": 1, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 0, "y": 0 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": 0, "y": .5 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": 0, "y": .5 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": .5, "y": .0 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": .5, "y": -.5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": -.5, "y": -.5, "z": -.5 }, "uv": { "x": 0, "y": .5 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": -.5, "y": .5, "z": -.5 }, "uv": { "x": 0, "y": 0 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": -.5, "y": .5, "z": -.5 }, "uv": { "x": 0, "y": 0 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": .5, "y": .5, "z": -.5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": .5, "y": -.5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 0, "z": -1 } }, -] \ No newline at end of file diff --git a/hexworld/res/data_vert_panels.json b/hexworld/res/data_vert_panels.json deleted file mode 100644 index cd2aa46..0000000 --- a/hexworld/res/data_vert_panels.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { "pos": { "x": .5, "y": .5, "z": .3 }, "uv": { "x": 1, "y": .1 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .3 }, "uv": { "x": .5, "y": .1 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .3 }, "uv": { "x": 1, "y": .1 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .3 }, "uv": { "x": 1, "y": .1 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": .3 }, "uv": { "x": .5, "y": .1 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": .3 }, "uv": { "x": .5, "y": .1 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .3 }, "uv": { "x": .5, "y": .1 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .3 }, "uv": { "x": 1, "y": .1 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .3 }, "uv": { "x": .5, "y": .1 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": .3 }, "uv": { "x": .5, "y": .1 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": .3 }, "uv": { "x": .5, "y": .1 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .3 }, "uv": { "x": 1, "y": .1 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 0, "y": 0 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": 0, "y": .5 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": 0, "y": .5 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": .5, "y": .0 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": .5, "y": -.5, "z": .3 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": -.5, "y": -.5, "z": .3 }, "uv": { "x": 0, "y": .5 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": -.5, "y": .5, "z": .3 }, "uv": { "x": 0, "y": 0 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": -.5, "y": .5, "z": .3 }, "uv": { "x": 0, "y": 0 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": .5, "y": .5, "z": .3 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": .5, "y": -.5, "z": .3 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 0, "z": -1 } }, -] \ No newline at end of file diff --git a/hexworld/res/data_vert_sides.json b/hexworld/res/data_vert_sides.json deleted file mode 100644 index e3df8a5..0000000 --- a/hexworld/res/data_vert_sides.json +++ /dev/null @@ -1,43 +0,0 @@ -[ - { "pos": { "x": .5, "y": .5, "z": -.5 }, "uv": { "x": .25, "y": .5 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": .25, "y": 0 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": 0, "y": 0 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": 0, "y": 0 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": -.5 }, "uv": { "x": 0, "y": .5 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": -.5 }, "uv": { "x": .25, "y": .5 }, "norm": { "x": 1, "y": 0, "z": 0 } }, - - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": -.5 }, "uv": { "x": .75, "y": .5 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": -.5 }, "uv": { "x": .75, "y": .5 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": .75, "y": 0 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": -1, "y": 0, "z": 0 } }, - - { "pos": { "x": .5, "y": .5, "z": -.5 }, "uv": { "x": .25, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": .5, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": .25, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": .5, "z": -.5 }, "uv": { "x": .25, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": .75, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": -.5 }, "uv": { "x": .75, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": -.5, "y": -.5, "z": -.5 }, "uv": { "x": .75, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": -.5 }, "uv": { "x": 1, "y": .5 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": 1, "y": 0 }, "norm": { "x": 0, "y": 1, "z": 0 } }, - - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": .25, "y": .5 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": -.5, "y": .5, "z": .5 }, "uv": { "x": 0, "y": .5 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": 0, "y": 1 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": -.5, "y": -.5, "z": .5 }, "uv": { "x": 0, "y": 1 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": .5, "y": -.5, "z": .5 }, "uv": { "x": .25, "y": 1 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - { "pos": { "x": .5, "y": .5, "z": .5 }, "uv": { "x": .25, "y": .5 }, "norm": { "x": 0, "y": 0, "z": 1 } }, - - { "pos": { "x": .5, "y": -.5, "z": -.5 }, "uv": { "x": .5, "y": 1 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": -.5, "y": -.5, "z": -.5 }, "uv": { "x": .25, "y": 1 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": -.5, "y": .5, "z": -.5 }, "uv": { "x": .25, "y": .5 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": -.5, "y": .5, "z": -.5 }, "uv": { "x": .25, "y": .5 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": .5, "y": .5, "z": -.5 }, "uv": { "x": .5, "y": .5 }, "norm": { "x": 0, "y": 0, "z": -1 } }, - { "pos": { "x": .5, "y": -.5, "z": -.5 }, "uv": { "x": .5, "y": 1 }, "norm": { "x": 0, "y": 0, "z": -1 } }, -] \ No newline at end of file diff --git a/hexworld/res/s.fs.glsl b/hexworld/res/s.fs.glsl deleted file mode 100644 index 6990dbd..0000000 --- a/hexworld/res/s.fs.glsl +++ /dev/null @@ -1,13 +0,0 @@ -#version 440 - -in vec2 vcoord; -in float light; - -uniform sampler2D tex; - -void main () -{ - vec4 color = texture(tex, vcoord); - color.xyz *= light; - gl_FragColor = clamp(color, 0, 1); -} \ No newline at end of file diff --git a/hexworld/res/s.vs.glsl b/hexworld/res/s.vs.glsl deleted file mode 100644 index a3bb41c..0000000 --- a/hexworld/res/s.vs.glsl +++ /dev/null @@ -1,22 +0,0 @@ -#version 440 - -in vec3 locpos; -in vec3 glbpos; -in vec2 coord; -in vec3 norm; - -out vec2 vcoord; -out float light; - -uniform mat4 view; -uniform mat4 proj; - -void main () -{ - mat4 pv = proj * view; - vec3 position = glbpos + locpos; - gl_Position = pv * vec4(position, 1); - vcoord = coord; - - light = dot(vec3(0, 0, 1), norm) / 2 + .5; -} \ No newline at end of file