Lights
This commit is contained in:
@@ -26,6 +26,8 @@ namespace VoxelIsometricRenderer
|
||||
public static int Frames = 0;
|
||||
public static double TotalRamUsage = 0;
|
||||
public static double RamUsage = 0;
|
||||
public static int width;
|
||||
public static int height;
|
||||
public Terrain4()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -58,11 +60,13 @@ namespace VoxelIsometricRenderer
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
for (int k = 0; k < 16; k++) {
|
||||
if (i < 10 && k < 10 && rnd.Next(0, 3) > 0) TestChunk.CreateBlock(new int[] { rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13) }, 0, new BlockState(false, BlockType.Ground, true), i, j, k);
|
||||
if (i < 5 && k < 5 && rnd.Next(0, 3) > 0) TestChunk.CreateBlock(new int[] { rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13), rnd.Next(0, 13) }, 0, new BlockState(false, BlockType.Ground, true), i, j, k);
|
||||
else TestChunk.CreateAir(i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
LightingManager.Lights.Add(new LightSource(LightShape.Sphere,12,12,12, 5, 18, 5, new float[] {0.8f,0.0f,0.0f},64));
|
||||
LightingManager.Lights.Add(new LightSource(LightShape.Sphere,12,12,12, 5, 8, 5, new float[] {0.0f,0.0f,0.6f},64));
|
||||
TestChunk.GenerateLightMap();
|
||||
TestChunk.CalculateCull();
|
||||
MainThread = new Thread(Runtime);
|
||||
@@ -84,9 +88,25 @@ namespace VoxelIsometricRenderer
|
||||
LightingFrameTime = Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds;
|
||||
LightingManager.UpdateLighting();
|
||||
//LightingManager.sunAngles[0] += 5f;
|
||||
// LightingManager.sunAngles[1] += 1f;
|
||||
//LightingManager.sunAngles[1] += 1f;
|
||||
}
|
||||
if (Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds - SecondFrameTime > 1000) {
|
||||
int[] pos = LightingManager.Lights[0].GetPosition();
|
||||
int[] pos2 = LightingManager.Lights[1].GetPosition();
|
||||
if (up && pos[0] > 0)
|
||||
{
|
||||
pos[0]--;
|
||||
pos2[1]--;
|
||||
}
|
||||
else if (up) up = false;
|
||||
else if (pos[0] < 10)
|
||||
{
|
||||
pos[0]++;
|
||||
pos2[1]++;
|
||||
}
|
||||
else up = true;
|
||||
//LightingManager.Lights[0].SetPosition(pos);
|
||||
//LightingManager.Lights[1].SetPosition(pos2);
|
||||
TotalRamUsage = Math.Round(System.Diagnostics.Process.GetCurrentProcess().WorkingSet64 / 1000000.0);
|
||||
RamUsage = Math.Round(GC.GetTotalMemory(false) / 1000000.0);
|
||||
SecondFrameTime = Process.GetCurrentProcess().TotalProcessorTime.TotalMilliseconds;
|
||||
@@ -112,6 +132,8 @@ namespace VoxelIsometricRenderer
|
||||
Display.Top = 0;
|
||||
Display.Width = Width;
|
||||
Display.Height = Height;
|
||||
width = Width;
|
||||
height = Height;
|
||||
}
|
||||
private void ResizeAspectRatio(object sender, EventArgs e)
|
||||
{
|
||||
@@ -125,24 +147,48 @@ namespace VoxelIsometricRenderer
|
||||
|
||||
private void KeyDownEvent(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Up) scale += 0.25f;
|
||||
if (e.KeyCode == Keys.Down) scale -= 0.25f;
|
||||
if (e.KeyCode == Keys.W)
|
||||
if (e.KeyCode == Keys.Add) scale += 0.25f;
|
||||
if (e.KeyCode == Keys.Subtract) scale -= 0.25f;
|
||||
if (e.KeyCode == Keys.Up)
|
||||
{
|
||||
LightingManager.sunAngles[1] += 10f;
|
||||
}
|
||||
if (e.KeyCode == Keys.S)
|
||||
if (e.KeyCode == Keys.Down)
|
||||
{
|
||||
LightingManager.sunAngles[1] -= 10f;
|
||||
}
|
||||
if (e.KeyCode == Keys.A)
|
||||
if (e.KeyCode == Keys.Left)
|
||||
{
|
||||
LightingManager.sunAngles[0] += 10f;
|
||||
}
|
||||
if (e.KeyCode == Keys.D)
|
||||
if (e.KeyCode == Keys.Right)
|
||||
{
|
||||
LightingManager.sunAngles[0] += 10f;
|
||||
}
|
||||
if (e.KeyCode == Keys.W)
|
||||
{
|
||||
PlayerObject.IncrementPos(2, 1);
|
||||
}
|
||||
if (e.KeyCode == Keys.S)
|
||||
{
|
||||
PlayerObject.IncrementPos(2, -1);
|
||||
}
|
||||
if (e.KeyCode == Keys.A)
|
||||
{
|
||||
PlayerObject.IncrementPos(0, 1);
|
||||
}
|
||||
if (e.KeyCode == Keys.D)
|
||||
{
|
||||
PlayerObject.IncrementPos(0, -1);
|
||||
}
|
||||
if (e.KeyCode == Keys.Space)
|
||||
{
|
||||
PlayerObject.IncrementPos(1, 1);
|
||||
}
|
||||
if (e.KeyCode == Keys.ShiftKey)
|
||||
{
|
||||
PlayerObject.IncrementPos(1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
private void KeyUpEvent(object sender, KeyEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user