Skip to content

Commit

Permalink
Asset manager fixes, activate/deactivate FirstPersonView
Browse files Browse the repository at this point in the history
  • Loading branch information
gecko0307 committed Jun 8, 2017
1 parent ccf1595 commit 49b4d5f
Show file tree
Hide file tree
Showing 66 changed files with 23,927 additions and 23,899 deletions.
Empty file modified src/dagon/core/application.d
100755 → 100644
Empty file.
899 changes: 453 additions & 446 deletions src/dagon/core/event.d
100755 → 100644

Large diffs are not rendered by default.

Empty file modified src/dagon/core/interfaces.d
100755 → 100644
Empty file.
Empty file modified src/dagon/core/keycodes.d
100755 → 100644
Empty file.
Empty file modified src/dagon/core/ownership.d
100755 → 100644
Empty file.
Empty file modified src/dagon/core/vfs.d
100755 → 100644
Empty file.
Empty file modified src/dagon/graphics/animmodel.d
100755 → 100644
Empty file.
Empty file modified src/dagon/graphics/environment.d
100755 → 100644
Empty file.
Empty file modified src/dagon/graphics/fpcamera.d
100755 → 100644
Empty file.
60 changes: 44 additions & 16 deletions src/dagon/graphics/fpview.d
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import dlib.core.memory;
import dlib.math.vector;
import dlib.math.matrix;

import derelict.sdl2.sdl;

import dagon.core.ownership;
import dagon.core.event;

Expand All @@ -12,7 +14,10 @@ import dagon.graphics.view;

class FirstPersonView: EventListener, View
{
FirstPersonCamera camera;
FirstPersonCamera camera;
int oldMouseX = 0;
int oldMouseY = 0;
bool _active = false;

this(EventManager emngr, Vector3f camPos, Owner owner)
{
Expand All @@ -24,22 +29,46 @@ class FirstPersonView: EventListener, View
void update(double dt)
{
processEvents();

int hWidth = eventManager.windowWidth / 2;
int hHeight = eventManager.windowHeight / 2;
float turn_m = -(hWidth - eventManager.mouseX) * 0.1f;
float pitch_m = (hHeight - eventManager.mouseY) * 0.1f;
camera.pitch += pitch_m;
camera.turn += turn_m;
float pitchLimitMax = 60.0f;
float pitchLimitMin = -60.0f;
if (camera.pitch > pitchLimitMax)
camera.pitch = pitchLimitMax;
else if (camera.pitch < pitchLimitMin)
camera.pitch = pitchLimitMin;
eventManager.setMouseToCenter();

if (_active)
{
float turn_m = (eventManager.mouseRelX) * 0.2f;
float pitch_m = (eventManager.mouseRelY) * 0.2f;

camera.pitch += pitch_m;
camera.turn += turn_m;
float pitchLimitMax = 60.0f;
float pitchLimitMin = -60.0f;
if (camera.pitch > pitchLimitMax)
camera.pitch = pitchLimitMax;
else if (camera.pitch < pitchLimitMin)
camera.pitch = pitchLimitMin;
}

camera.update(dt);
}

void active(bool v)
{
if (v)
{
oldMouseX = eventManager.mouseX;
oldMouseY = eventManager.mouseY;
SDL_SetRelativeMouseMode(1);
}
else
{
SDL_SetRelativeMouseMode(0);
eventManager.setMouse(oldMouseX, eventManager.windowHeight - oldMouseY);
}

_active = v;
}

bool active()
{
return _active;
}

Matrix4x4f viewMatrix()
{
Expand All @@ -51,4 +80,3 @@ class FirstPersonView: EventListener, View
return camera.invViewMatrix();
}
}

8 changes: 4 additions & 4 deletions src/dagon/graphics/freeview.d
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Freeview: EventListener, View

override void onMouseButtonDown(int button)
{
if (button == MB_MIDDLE)
if (button == MB_LEFT)
{
prevMouseX = eventManager.mouseX;
prevMouseY = eventManager.mouseY;
Expand All @@ -65,20 +65,20 @@ class Freeview: EventListener, View
{
processEvents();

if (eventManager.mouseButtonPressed[MB_MIDDLE] && eventManager.keyPressed[KEY_LSHIFT])
if (eventManager.mouseButtonPressed[MB_LEFT] && eventManager.keyPressed[KEY_LSHIFT])
{
float shift_x = (eventManager.mouseX - prevMouseX) * 0.1f;
float shift_y = (eventManager.mouseY - prevMouseY) * 0.1f;
Vector3f trans = camera.getUpVector * shift_y + camera.getRightVector * shift_x;
camera.translateTarget(trans);
}
else if (eventManager.mouseButtonPressed[MB_MIDDLE] && eventManager.keyPressed[KEY_LCTRL])
else if (eventManager.mouseButtonPressed[MB_LEFT] && eventManager.keyPressed[KEY_LCTRL])
{
float shift_x = (eventManager.mouseX - prevMouseX);
float shift_y = (eventManager.mouseY - prevMouseY);
camera.zoom((shift_x + shift_y) * 0.1f);
}
else if (eventManager.mouseButtonPressed[MB_MIDDLE])
else if (eventManager.mouseButtonPressed[MB_LEFT])
{
float turn_m = (eventManager.mouseX - prevMouseX);
float pitch_m = -(eventManager.mouseY - prevMouseY);
Expand Down
Empty file modified src/dagon/graphics/genericmaterial.d
100755 → 100644
Empty file.
Empty file modified src/dagon/graphics/light.d
100755 → 100644
Empty file.
24 changes: 12 additions & 12 deletions src/dagon/graphics/material.d
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import dagon.core.ownership;
import dagon.graphics.texture;
import dagon.graphics.rc;

enum
{
CBlack = Color4f(0.0f, 0.0f, 0.0f, 1.0f),
CWhite = Color4f(1.0f, 1.0f, 1.0f, 1.0f),
CRed = Color4f(1.0f, 0.0f, 0.0f, 1.0f),
COrange = Color4f(1.0f, 0.5f, 0.0f, 1.0f),
CYellow = Color4f(1.0f, 1.0f, 0.0f, 1.0f),
CGreen = Color4f(0.0f, 1.0f, 0.0f, 1.0f),
CCyan = Color4f(0.0f, 1.0f, 1.0f, 1.0f),
CBlue = Color4f(0.0f, 0.0f, 1.0f, 1.0f),
CPurple = Color4f(0.5f, 0.0f, 1.0f, 1.0f),
CMagenta = Color4f(1.0f, 0.0f, 1.0f, 1.0f)
enum
{
CBlack = Color4f(0.0f, 0.0f, 0.0f, 1.0f),
CWhite = Color4f(1.0f, 1.0f, 1.0f, 1.0f),
CRed = Color4f(1.0f, 0.0f, 0.0f, 1.0f),
COrange = Color4f(1.0f, 0.5f, 0.0f, 1.0f),
CYellow = Color4f(1.0f, 1.0f, 0.0f, 1.0f),
CGreen = Color4f(0.0f, 1.0f, 0.0f, 1.0f),
CCyan = Color4f(0.0f, 1.0f, 1.0f, 1.0f),
CBlue = Color4f(0.0f, 0.0f, 1.0f, 1.0f),
CPurple = Color4f(0.5f, 0.0f, 1.0f, 1.0f),
CMagenta = Color4f(1.0f, 0.0f, 1.0f, 1.0f)
}

enum MaterialInputType
Expand Down
Empty file modified src/dagon/graphics/mesh.d
100755 → 100644
Empty file.
Empty file modified src/dagon/graphics/rc.d
100755 → 100644
Empty file.
Empty file modified src/dagon/graphics/shapes.d
100755 → 100644
Empty file.
Loading

0 comments on commit 49b4d5f

Please sign in to comment.