Skip to content

Commit

Permalink
Another massive update
Browse files Browse the repository at this point in the history
  • Loading branch information
gecko0307 committed Nov 4, 2015
1 parent 9e9f720 commit 3c3e721
Show file tree
Hide file tree
Showing 46 changed files with 409 additions and 45 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Atrium will provide high level of interactivity, featuring fully dynamic world w

Screenshots
-----------
[![Screenshot1](/screenshots/004_thumb.jpg)](/screenshots/004.jpg)
[![Screenshot1](/screenshots/005_thumb.jpg)](/screenshots/005.jpg)
[![Screenshot1](/screenshots/006_thumb.jpg)](/screenshots/006.jpg)
[![Screenshot1](/screenshots/007_thumb.jpg)](/screenshots/007.jpg)

Tech details
------------
Expand Down
Binary file removed data/default/items/box green.png
Binary file not shown.
Binary file added data/default/items/door.blend
Binary file not shown.
Binary file added data/default/items/door.dgl2
Binary file not shown.
Binary file removed data/default/items/emit green.png
Binary file not shown.
2 changes: 1 addition & 1 deletion data/default/shaders/hblur.fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main(void)
}

total /= (radius * 2.0 + 1.0);
total *= 0.75;
total *= 0.8;

gl_FragColor = total;
//gl_FragColor.a = 1.0;
Expand Down
2 changes: 1 addition & 1 deletion data/default/shaders/vblur.fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main(void)
}

total /= (radius * 2.0 + 1.0);
total *= 0.75;
total *= 0.8;

gl_FragColor = total;
//gl_FragColor.a = 0.1;
Expand Down
Binary file removed data/default/ui/pause.xcf
Binary file not shown.
Binary file added data/default/weapons/gravity-gun-2.blend
Binary file not shown.
Binary file added data/default/weapons/gravity-gun-2.dgl2
Binary file not shown.
Binary file removed data/levels/corridor/ceiling001.png
Binary file not shown.
Binary file removed data/levels/corridor/ceiling001.xcf
Binary file not shown.
Binary file removed data/levels/corridor/corridor.blend
Binary file not shown.
Binary file removed data/levels/corridor/corridor.dgl2
Binary file not shown.
Binary file removed data/levels/corridor/floor001.png
Binary file not shown.
Binary file removed data/levels/corridor/floor001.xcf
Binary file not shown.
Binary file removed data/levels/corridor/green.png
Binary file not shown.
Binary file removed data/levels/corridor/lightmap.png
Binary file not shown.
Binary file removed data/levels/corridor/lightmap2.png
Binary file not shown.
Binary file removed data/levels/corridor/lightmap3.png
Binary file not shown.
Binary file removed data/levels/corridor/wall001.png
Binary file not shown.
Binary file removed data/levels/corridor/wall001.xcf
Binary file not shown.
Binary file removed data/levels/corridor/window.png
Binary file not shown.
Binary file added data/levels/new/brick-normal 0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/levels/new/brick-normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/levels/new/dummy-glow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/levels/new/dummy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/levels/new/walls.blend
Binary file not shown.
Binary file modified data/levels/new/walls.dgl2
Binary file not shown.
2 changes: 1 addition & 1 deletion dgl/core/layer.d
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Layer: EventListener, Drawable
if (type == LayerType.Layer2D)
glOrtho(0, eventManager.windowWidth, 0, eventManager.windowHeight, 0, 1);
else
gluPerspective(60, aspectRatio, 0.1, 400.0);
gluPerspective(60, aspectRatio, 0.1, 30.0);
glMatrixMode(GL_MODELVIEW);

glLoadIdentity();
Expand Down
13 changes: 12 additions & 1 deletion dgl/graphics/lightmanager.d
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class LightManager: Modifier3D, Drawable
uint maxLightsPerObject = 4;
bool lightsVisible = false;
bool lightsOn = true;
bool useUpdateTreshold = false;
Vector3f referencePoint = Vector3f(0, 0, 0);
float updateThreshold = 400.0f;

Light addLight(Light light)
{
Expand All @@ -66,7 +69,15 @@ class LightManager: Modifier3D, Drawable
void bind(Object3D obj, double dt)
{
glEnable(GL_LIGHTING);
apply(obj.getPosition);

Vector3f objPos = obj.getPosition;
if (useUpdateTreshold)
{
if ((objPos - referencePoint).lengthsqr < updateThreshold)
apply(objPos);
}
else
apply(objPos);
}

void unbind(Object3D obj)
Expand Down
7 changes: 7 additions & 0 deletions dgl/graphics/material.d
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Material: Modifier
bool shadeless = false;
bool useTextures = true;
bool additiveBlending = false;
bool doubleSided = false;

this()
{
Expand Down Expand Up @@ -107,6 +108,9 @@ class Material: Modifier
glDisable(GL_LIGHTING);
glColor4f(diffuseColor.r, diffuseColor.g, diffuseColor.b, diffuseColor.a);
}

if (doubleSided)
glDisable(GL_CULL_FACE);

if (useTextures)
foreach(i, tex; textures)
Expand Down Expand Up @@ -136,6 +140,9 @@ class Material: Modifier
tex.unbind();
}
}

if (doubleSided)
glEnable(GL_CULL_FACE);

glActiveTextureARB(GL_TEXTURE0_ARB);

Expand Down
2 changes: 2 additions & 0 deletions dgl/graphics/shadow.d
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ class ShadowMap: Drawable
if (castScene)
{
dgl.graphics.material.useDimLight = true;
castScene.lighted = false;
castScene.draw(dt);
castScene.lighted = true;
dgl.graphics.material.useDimLight = false;
}

Expand Down
16 changes: 8 additions & 8 deletions dgl/graphics/tbcamera.d
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ final class TrackballCamera: Modifier, Camera
this()
{
center = Vector3f(0.0f, 0.0f, 0.0f);
rotPitch = rotation(Vector3f(1.0f,0.0f,0.0f), 0.0f);
rotTurn = rotation(Vector3f(0.0f,1.0f,0.0f), 0.0f);
rotRoll = rotation(Vector3f(0.0f,0.0f,1.0f), 0.0f);
rotPitch = rotationQuaternion(Vector3f(1.0f,0.0f,0.0f), 0.0f);
rotTurn = rotationQuaternion(Vector3f(0.0f,1.0f,0.0f), 0.0f);
rotRoll = rotationQuaternion(Vector3f(0.0f,0.0f,1.0f), 0.0f);
transform = Matrix4x4f.identity;
distance = 10.0f;

Expand All @@ -116,13 +116,13 @@ final class TrackballCamera: Modifier, Camera

glPushMatrix();

rotPitch = rotation(Vector3f(1.0f,0.0f,0.0f), degtorad(rotPitchTheta));
rotTurn = rotation(Vector3f(0.0f,1.0f,0.0f), degtorad(rotTurnTheta));
rotRoll = rotation(Vector3f(0.0f,0.0f,1.0f), degtorad(rotRollTheta));
rotPitch = rotationQuaternion(Vector3f(1.0f,0.0f,0.0f), degtorad(rotPitchTheta));
rotTurn = rotationQuaternion(Vector3f(0.0f,1.0f,0.0f), degtorad(rotTurnTheta));
rotRoll = rotationQuaternion(Vector3f(0.0f,0.0f,1.0f), degtorad(rotRollTheta));

Quaternionf q = rotPitch * rotTurn * rotRoll;
Matrix4x4f rotationMatrix = q.toMatrix4x4();
transform = translationMatrix(Vector3f(0.0f, 0.0f, -distance)) * rotationMatrix * translationMatrix(center);
Matrix4x4f rot = q.toMatrix4x4();
transform = translationMatrix(Vector3f(0.0f, 0.0f, -distance)) * rot * translationMatrix(center);
glLoadMatrixf(transform.arrayof.ptr);

transform.invert();
Expand Down
31 changes: 20 additions & 11 deletions dgl/graphics/ubershader.d
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ private string _uberFragmentShader = q{
uniform bool bumpEnabled;
uniform bool parallaxEnabled;

const float parallaxScale = 0.05;
const float parallaxScale = 0.06;
const float parallaxBias = -0.03;
const float lightRadiusSqr = 7.0;
const float lightRadiusSqr = 8.5;
const float wrapFactor = 0.5;
const float shadowBrightness = 0.3;
const float shininess = 32.0;
const float edgeWidth = 0.3;
const float edgeWidth = 0.4;

float texture2DCompare(sampler2D depths, vec2 uv, float compare)
{
Expand Down Expand Up @@ -124,14 +124,22 @@ private string _uberFragmentShader = q{
gl_FragColor = gl_FrontMaterial.diffuse;
return;
}


// Fog term
/*
const vec4 fogColor = vec4(0.1, 0.2, 0.2, 1.0);
float fogDistance = gl_FragCoord.w * 20.0; //1.0 - (gl_FragCoord.z / gl_FragCoord.w) / 4000.0;
fogDistance = (fogDistance > 10.0)? fogDistance : 1.0;
float fog = clamp(fogDistance, 0.0, 1.0);
*/

// Shadow term
vec4 shadowCoordinateWdivide = shadowCoord / shadowCoord.w ;
float shadow;
if (shadowCoord.w > 0.0)
{
shadowCoordinateWdivide.z *= 1.005;
shadow = texture2DShadowLerp(dgl_Texture7, vec2(512.0, 512.0),
shadow = texture2DShadowLerp(dgl_Texture7, vec2(1024.0, 1024.0),
shadowCoordinateWdivide.st, shadowCoordinateWdivide.z);
}
shadow += shadowBrightness;
Expand Down Expand Up @@ -162,7 +170,7 @@ private string _uberFragmentShader = q{
float attenuation;
vec3 L;

vec4 col = vec4(0.05, 0.05, 0.05, 1.0);
vec4 col = vec4(0.02, 0.02, 0.02, 1.0);

float diffuse;
float specular;
Expand All @@ -181,7 +189,8 @@ private string _uberFragmentShader = q{
if (gl_LightSource[i].position.w < 2.0)
{
//vec4 Ca = gl_LightSource[i].ambient;
vec4 Cd = gl_FrontMaterial.diffuse * gl_LightSource[i].diffuse;
vec4 Md = gl_FrontMaterial.diffuse;
vec4 Cd = Md * gl_LightSource[i].diffuse;
vec4 Cs = gl_FrontMaterial.specular * gl_LightSource[i].specular;

vec3 positionToLightSource = vec3(gl_LightSource[i].position.xyz - position);
Expand All @@ -205,19 +214,19 @@ private string _uberFragmentShader = q{
// Edge term
edgeScale = edgeBias(1.0 - dot(E, N), edgeWidth);
edgeScale = max(0.5, edgeScale * 2.0);
rim = edgeScale * diffuse;
rim = edgeScale * 1.5;

// Blinn-Phong specular term
H = normalize(L + E);
NH = dot(N, H);
specular = max(pow(NH, shininess), 0.0);

col += ((Cd*diffuse) + (Cs*specular) + (Cr*rim)) * attenuation;
col += ((Cd*diffuse) + (Cs*specular*3.0) + (Cr*Md*rim)) * attenuation;
}
}

col *= 0.9;
gl_FragColor = tex * col * shadow + emit;
col *= 0.85;
gl_FragColor = (tex * col * shadow + emit); //mix(fogColor, (tex * col * shadow + emit), fog);
gl_FragColor.a = 1.0;
}
};
Expand Down
2 changes: 1 addition & 1 deletion game.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
enableShadows = "1";
shadowMapSize = "512";
shadowMapSize = "1024";
enableShaders = "1";
enableGlow = "1";

Expand Down
32 changes: 27 additions & 5 deletions game/character.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CharacterController: Freeable //, CollisionDispatcher
Vector3f rotation;
float newContactSlopeFactor = 1.0f;
RigidBody floorBody;
bool flyMode = false;

this(PhysicsWorld world, Vector3f pos, float mass, Geometry geom)
{
Expand All @@ -54,6 +55,20 @@ class CharacterController: Freeable //, CollisionDispatcher

//rbody.collisionDispatchers.append(this);
}

void enableGravity(bool mode)
{
flyMode = !mode;

if (mode)
{
rbody.gravity = Vector3f(0.0f, -artificalGravity, 0.0f);
}
else
{
rbody.gravity = Vector3f(0, 0, 0);
}
}

void onNewContact(RigidBody b, Contact c)
{
Expand All @@ -74,7 +89,7 @@ class CharacterController: Freeable //, CollisionDispatcher
Vector3f velocityChange = targetVelocity - rbody.linearVelocity;
velocityChange.x = clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange);
velocityChange.z = clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange);
if (clampY)
if (clampY && !flyMode)
velocityChange.y = 0;
else
velocityChange.y = clamp(velocityChange.y, -maxVelocityChange, maxVelocityChange);
Expand All @@ -90,9 +105,16 @@ class CharacterController: Freeable //, CollisionDispatcher

if (onGround && floorBody && speed == 0.0f && jSpeed == 0.0f)
rbody.linearVelocity = floorBody.linearVelocity;

speed = 0.0f;
jSpeed = 0.0f;
if (!flyMode)
{
speed = 0.0f;
jSpeed = 0.0f;
}
else
{
speed *= 0.95f;
jSpeed *= 0.95f;
}
}

bool checkOnGround()
Expand Down Expand Up @@ -124,7 +146,7 @@ class CharacterController: Freeable //, CollisionDispatcher

void jump(float height)
{
if (onGround)
if (onGround || flyMode)
{
jSpeed = jumpSpeed(height);
rbody.linearVelocity.y = jSpeed;
Expand Down
12 changes: 11 additions & 1 deletion game/gravitygun.d
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class GravityGun: Weapon, CollisionDispatcher
rm.lm.addLight(light);

tesla = New!TeslaEffect(this, glowTexture, light);
tesla.start = Vector3f(0, 0.1f, -0.5f);
tesla.start = Vector3f(0, 0.075f, -0.5f);
tesla.width = 5.0f;
tesla.color = teslaColor;

Expand All @@ -72,6 +72,15 @@ class GravityGun: Weapon, CollisionDispatcher
sparks.secondaryColor = Color4f(1.0f, 0.0f, 0.0f, 0.0f);
}

override void enableGravity(bool mode)
{
super.enableGravity(mode);
if (mode)
sparks.gravityVector = Vector3f(0, -1, 0);
else
sparks.gravityVector = Vector3f(0, 0, 0);
}

override void draw(double dt)
{
sparks.draw(dt);
Expand Down Expand Up @@ -255,6 +264,7 @@ class GravityGun: Weapon, CollisionDispatcher
{
if (shootedBody)
{
sparks.reset(objPos, -camDir);
shootedBody.applyImpulse(camDir * 200.0f, shootedBody.position);
unsetShootedBody();
}
Expand Down
4 changes: 3 additions & 1 deletion game/physicsentity.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import dmech;

class PhysicsEntity: Entity
{
RigidBody rbody;
ShapeComponent shape;
Light light;
bool highlight = false;

this(Drawable d, ShapeComponent s)
this(Drawable d, RigidBody b, ShapeComponent s)
{
if (s)
super(d, s.position);
else
super(d, Vector3f(0, 0, 0));
rbody = b;
shape = s;
}

Expand Down
Loading

0 comments on commit 3c3e721

Please sign in to comment.