Migrated to use Levels in hexworld, move tile-related types to Diamond
This commit is contained in:
@@ -55,6 +55,10 @@
|
||||
<Compile Include="Buffers\SubArray.cs" />
|
||||
<Compile Include="Buffers\VertexDataAttribute.cs" />
|
||||
<Compile Include="GLObject.cs" />
|
||||
<Compile Include="Level\Level.cs" />
|
||||
<Compile Include="Level\TileData.cs" />
|
||||
<Compile Include="Level\TileGroup.cs" />
|
||||
<Compile Include="Level\TileInfo.cs" />
|
||||
<Compile Include="Mesh.cs" />
|
||||
<Compile Include="Shaders\Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
110
Diamond/Level/Level.cs
Normal file
110
Diamond/Level/Level.cs
Normal file
@@ -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<ObjVertex>[] _meshes;
|
||||
private TileGroup[] _tileGroups;
|
||||
|
||||
private GLBuffer<TileData> _tileBuffer;
|
||||
private GLBuffer<ObjVertex> _vertexBuffer;
|
||||
|
||||
private void InitializeBuffers()
|
||||
{
|
||||
_tileBuffer = new GLBuffer<TileData>(BufferTarget.ArrayBuffer, BufferUsageHint.DynamicDraw);
|
||||
_tileBuffer.Data(_allTiles);
|
||||
|
||||
_vertexBuffer = new GLBuffer<ObjVertex>(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw);
|
||||
_vertexBuffer.Data(_allVertices);
|
||||
}
|
||||
|
||||
public static Level LoadLevel(string file)
|
||||
{
|
||||
var level = JsonConvert.DeserializeObject<Level>(File.ReadAllText(file));
|
||||
|
||||
var dir = Path.GetDirectoryName(file);
|
||||
|
||||
|
||||
// region assemble mesh map
|
||||
var meshes = new Dictionary<string, Mesh<ObjVertex>>();
|
||||
|
||||
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<string, List<TileData>>();
|
||||
|
||||
foreach (var tileInfo in level.TileInfos)
|
||||
{
|
||||
var meshName = tileInfo.Mesh;
|
||||
if (!groupDict.ContainsKey(meshName))
|
||||
groupDict[meshName] = new List<TileData>();
|
||||
groupDict[meshName].Add(tileInfo.TileData);
|
||||
}
|
||||
|
||||
var groupList = new List<TileGroup>();
|
||||
var tileSubArrayList = new List<SubArray<TileData>>();
|
||||
|
||||
foreach (var kvp in groupDict)
|
||||
{
|
||||
var sa = new SubArray<TileData>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using OpenTK;
|
||||
|
||||
namespace hexworld
|
||||
namespace Diamond.Level
|
||||
{
|
||||
[VertexData(Divisor = 1)]
|
||||
public struct TileData
|
||||
16
Diamond/Level/TileGroup.cs
Normal file
16
Diamond/Level/TileGroup.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Diamond.Buffers;
|
||||
|
||||
namespace Diamond.Level
|
||||
{
|
||||
internal class TileGroup
|
||||
{
|
||||
public SubArray<TileData> Tiles;
|
||||
public Mesh<ObjVertex> Mesh;
|
||||
|
||||
public TileGroup(SubArray<TileData> tiles, Mesh<ObjVertex> mesh)
|
||||
{
|
||||
Tiles = tiles;
|
||||
Mesh = mesh;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Diamond/Level/TileInfo.cs
Normal file
21
Diamond/Level/TileInfo.cs
Normal file
@@ -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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<ObjVertex>[] _meshes;
|
||||
private TileGroup[] _tileGroups;
|
||||
|
||||
private GLBuffer<TileData> _tileBuffer;
|
||||
private GLBuffer<ObjVertex> _vertexBuffer;
|
||||
|
||||
private void InitializeBuffers()
|
||||
{
|
||||
_tileBuffer = new GLBuffer<TileData>(BufferTarget.ArrayBuffer, BufferUsageHint.DynamicDraw);
|
||||
_tileBuffer.Data(_allTiles);
|
||||
|
||||
_vertexBuffer = new GLBuffer<ObjVertex>(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw);
|
||||
_vertexBuffer.Data(_allVertices);
|
||||
}
|
||||
|
||||
public static Level LoadLevel(string file)
|
||||
{
|
||||
var level = JsonConvert.DeserializeObject<Level>(File.ReadAllText(file));
|
||||
|
||||
var dir = Path.GetDirectoryName(file);
|
||||
|
||||
|
||||
// region assemble mesh map
|
||||
var meshes = new Dictionary<string, Mesh<ObjVertex>>();
|
||||
|
||||
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<string, List<TileData>>();
|
||||
|
||||
foreach (var tileInfo in level.TileInfos)
|
||||
{
|
||||
var meshName = tileInfo.Mesh;
|
||||
if (!groupDict.ContainsKey(meshName))
|
||||
groupDict[meshName] = new List<TileData>();
|
||||
groupDict[meshName].Add(tileInfo.TileData);
|
||||
}
|
||||
|
||||
var groupList = new List<TileGroup>();
|
||||
var tileSubArrayList = new List<SubArray<TileData>>();
|
||||
|
||||
foreach (var kvp in groupDict)
|
||||
{
|
||||
var sa = new SubArray<TileData>(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<TileData> Tiles;
|
||||
public Mesh<ObjVertex> Mesh;
|
||||
|
||||
public TileGroup(SubArray<TileData> tiles, Mesh<ObjVertex> mesh)
|
||||
{
|
||||
Tiles = tiles;
|
||||
Mesh = mesh;
|
||||
}
|
||||
}
|
||||
|
||||
public class HexRender : GameWindow
|
||||
{
|
||||
#region Fields
|
||||
|
||||
@@ -51,28 +51,12 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="TileData.cs" />
|
||||
<Compile Include="HexRender.cs" />
|
||||
<Compile Include="Driver.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="res\data_tile_gray.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="res\data_tile_table.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="res\data_tile_stone.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="res\data_vert_sides.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="res\data_vert_panels.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="OpenTK.dll.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="res\door.obj">
|
||||
@@ -84,21 +68,9 @@
|
||||
<None Include="res\obj.fs.glsl">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="res\s.fs.glsl">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="res\obj.vs.glsl">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="res\s.vs.glsl">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="res\data_vert_cubes.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="res\data_tile_grass.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="res\table.obj">
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
|
||||
@@ -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 } },
|
||||
]
|
||||
@@ -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 } },
|
||||
]
|
||||
@@ -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 } },
|
||||
]
|
||||
@@ -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 } },
|
||||
]
|
||||
@@ -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 } },
|
||||
]
|
||||
@@ -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 } },
|
||||
]
|
||||
@@ -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 } },
|
||||
]
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user