Skip to content

Commit e924e8f

Browse files
committed
Some refactoring and minor changes
1 parent 8f3330b commit e924e8f

21 files changed

+174
-97
lines changed

bin/data/base/shaders/bump.fp

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
uniform sampler2D tex;
22
uniform sampler2D nmap;
33
uniform sampler2D disp;
4-
/*uniform sampler2D occ;*/
4+
uniform sampler2D occ;
55
uniform sampler2D spec;
66
uniform vec3 LightAtten;
77
uniform vec4 LightColor;
@@ -39,15 +39,16 @@ void main(void)
3939
/*else*/
4040
/* atten_frag = 1.0;*/
4141

42-
float height = texture2D(disp, vUV).r * 0.04 - 0.02;
43-
vec2 uvp = vUV + (eye.xy * height);
42+
/*float height = texture2D(disp, vUV).r * 0.04 - 0.02;*/
43+
/*vec2 uvp = vUV + (eye.xy * height);*/
44+
vec2 uvp = vUV;
4445

4546
vec4 texel = texture2D(tex, uvp);
4647
/*vec4 texel = vec4(0.0f, 0.0f, 0.0f, 1.0f); // this line + white light for pencil sketch shader*/
4748
if(texel.a < 0.5)
4849
discard;
4950
vec3 bump = normalize(texture2D(nmap, uvp).rgb * 2.0 - 1.0);
50-
/*float occ = texture2D(occ, uvp).r;*/
51+
float occ = texture2D(occ, uvp).r;
5152

5253
/*float ambient = 0.1;*/
5354
float diffuse = max(dot(light, bump), 0.0) * 1.0;
@@ -57,7 +58,7 @@ void main(void)
5758
if(shine > EPSILON)
5859
{
5960
shine = 1.0 / shine;
60-
specular = pow(clamp(dot(reflect(-eye, bump), light), 0.0, 1.0), shine) * 1.0; // 1.0
61+
specular = pow(clamp(dot(reflect(-eye, bump), light), 0.0, 1.0), shine) * 0.25; // 1.0
6162
}
6263
else
6364
specular = 0.0f;
@@ -69,7 +70,7 @@ void main(void)
6970
/*vec4 fog_color = vec4(0.0, 0.0, 0.0, 1.0);*/
7071
/*float fog_factor = eye_dist / 20.0f;*/
7172

72-
vec4 lit = color_frag * /*occ **/ LightColor;
73+
vec4 lit = color_frag * occ * LightColor;
7374

7475
gl_FragColor = lit;
7576
/*gl_FragColor = mix(lit, fog_color, clamp(fog_factor,0.0,1.0));*/

bin/data/base/shaders/bump.vp

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
attribute vec3 tangent;
3-
attribute vec3 bitangent;
3+
attribute vec3 binormal;
44
uniform mat4 ViewMatrix;
55
uniform vec4 Light;
66
/*uniform vec3 LightAtten;*/
77
/*uniform vec3 LightColor;*/
88
/*varying vec3 vTangent;*/
9-
/*varying vec3 vBitangent;*/
9+
/*varying vec3 vBinormal;*/
1010
varying vec2 vUV;
1111
varying vec3 vLightDir;
1212
varying vec3 vLight;
@@ -21,17 +21,17 @@ void main(void)
2121
vUV = gl_MultiTexCoord0;
2222

2323
vec3 vTangent = normalize(gl_NormalMatrix * tangent);
24-
vec3 vBitangent = normalize(gl_NormalMatrix * bitangent);
24+
vec3 vBinormal = normalize(gl_NormalMatrix * binormal);
2525
vec3 vNormal = normalize(gl_NormalMatrix * gl_Normal);
26-
/*vBitangent = cross(vTangent, vNormal);*/
26+
/*vBinormal = cross(vTangent, vNormal);*/
2727

2828
vec3 vVertex = gl_ModelViewMatrix * gl_Vertex;
2929

30-
mat3 tspace = mat3(vTangent,vBitangent,vNormal);
30+
mat3 tspace = mat3(vTangent,vBinormal,vNormal);
3131
/*mat3 tspace = mat3(*/
32-
/* vTangent.x, vBitangent.x, vNormal.x,*/
33-
/* vTangent.y, vBitangent.y, vNormal.y,*/
34-
/* vTangent.z, vBitangent.z, vNormal.z*/
32+
/* vTangent.x, vBinormal.x, vNormal.x,*/
33+
/* vTangent.y, vBinormal.y, vNormal.y,*/
34+
/* vTangent.z, vBinormal.z, vNormal.z*/
3535
/*);*/
3636
vViewDir = -vVertex;
3737
vViewDir *= tspace;

qor.make

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ ifeq ($(config),release)
6464
endif
6565

6666
OBJECTS := \
67-
$(OBJDIR)/Shadow.o \
6867
$(OBJDIR)/Filesystem.o \
6968
$(OBJDIR)/NodeFactory.o \
7069
$(OBJDIR)/Scene.o \
@@ -88,6 +87,7 @@ OBJECTS := \
8887
$(OBJDIR)/Physics.o \
8988
$(OBJDIR)/Node.o \
9089
$(OBJDIR)/Settings.o \
90+
$(OBJDIR)/ShadowBuffer.o \
9191
$(OBJDIR)/Developer.o \
9292
$(OBJDIR)/Graphics.o \
9393
$(OBJDIR)/Light.o \
@@ -171,9 +171,6 @@ $(GCH): $(PCH)
171171
$(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
172172
endif
173173

174-
$(OBJDIR)/Shadow.o: src/Shadow.cpp
175-
@echo $(notdir $<)
176-
$(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
177174
$(OBJDIR)/Filesystem.o: src/Filesystem.cpp
178175
@echo $(notdir $<)
179176
$(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
@@ -243,6 +240,9 @@ $(OBJDIR)/Node.o: src/Node.cpp
243240
$(OBJDIR)/Settings.o: src/Settings.cpp
244241
@echo $(notdir $<)
245242
$(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
243+
$(OBJDIR)/ShadowBuffer.o: src/ShadowBuffer.cpp
244+
@echo $(notdir $<)
245+
$(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
246246
$(OBJDIR)/Developer.o: src/Developer.cpp
247247
@echo $(notdir $<)
248248
$(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"

qor.vcxproj

+7-4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
<ClInclude Include="src\Version.h" />
117117
<ClInclude Include="src\Physics.h" />
118118
<ClInclude Include="src\Filesystem.h" />
119+
<ClInclude Include="src\MeshTypeParser.h" />
119120
<ClInclude Include="src\IPartitioner.h" />
120121
<ClInclude Include="src\Settings.h" />
121122
<ClInclude Include="src\NodeAttributes.h" />
@@ -145,9 +146,10 @@
145146
<ClInclude Include="src\Batch.h" />
146147
<ClInclude Include="src\IPhysicsObject.h" />
147148
<ClInclude Include="src\Shader.h" />
149+
<ClInclude Include="src\ShadowBuffer.h" />
148150
<ClInclude Include="src\IRenderable.h" />
149151
<ClInclude Include="src\Inventory.h" />
150-
<ClInclude Include="src\Shadow.h" />
152+
<ClInclude Include="src\Zone.h" />
151153
<ClInclude Include="src\Node.h" />
152154
<ClInclude Include="src\DummyPartitioner.h" />
153155
<ClInclude Include="src\DynamicTyping.h" />
@@ -157,6 +159,8 @@
157159
<ClInclude Include="src\Actor.h" />
158160
<ClInclude Include="src\Input.h" />
159161
<ClInclude Include="src\Viewmodel.h" />
162+
<ClInclude Include="src\Sky.h" />
163+
<ClInclude Include="src\Terrain.h" />
160164
<ClInclude Include="src\Mesh.h" />
161165
<ClInclude Include="src\ParticleSystem.h" />
162166
<ClInclude Include="src\TrackerNode.h" />
@@ -169,7 +173,6 @@
169173
<ClInclude Include="src\IStaticInstance.h" />
170174
<ClInclude Include="src\Util.h" />
171175
<ClInclude Include="src\IFallible.h" />
172-
<ClInclude Include="src\AITypeParser.h" />
173176
<ClInclude Include="src\LuaScript\LuaState.h" />
174177
<ClInclude Include="src\transition\TransitionState.h" />
175178
<ClInclude Include="src\transition\TransitionInfo.h" />
@@ -186,8 +189,6 @@
186189
<ClInclude Include="src\math\matrixstack.h" />
187190
</ItemGroup>
188191
<ItemGroup>
189-
<ClCompile Include="src\Shadow.cpp">
190-
</ClCompile>
191192
<ClCompile Include="src\Filesystem.cpp">
192193
</ClCompile>
193194
<ClCompile Include="src\NodeFactory.cpp">
@@ -234,6 +235,8 @@
234235
</ClCompile>
235236
<ClCompile Include="src\Settings.cpp">
236237
</ClCompile>
238+
<ClCompile Include="src\ShadowBuffer.cpp">
239+
</ClCompile>
237240
<ClCompile Include="src\Developer.cpp">
238241
</ClCompile>
239242
<ClCompile Include="src\Graphics.cpp">

src/Batch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define BATCH_H
33

44
// Graphics polygon batch
5-
// Used for emulation of immediate mode
5+
// Used for alternative to immediate mode
66

77
#include <vector>
88
#include "math/common.h"

src/Light.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class Light : public Indicator
2121

2222
Light():
2323
m_Type(POINT),
24-
m_Atten(glm::vec3(1.0f, 0.0f, 0.0f))
24+
m_Atten(glm::vec3(1.0f, 0.0f, 0.0f)),
25+
m_LightFlags(0)
2526
{
2627
// TODO: Use light cutoffs for AABB, instead of temp:
2728
m_Box.min = glm::vec3(-0.5f);
@@ -88,6 +89,13 @@ class Light : public Indicator
8889

8990
virtual const AABB* box(unsigned int flags = 0) const { return &m_Box; }
9091
virtual AABB* box(unsigned int flags = 0) { return &m_Box; }
92+
93+
void lightFlags(unsigned int flags) {
94+
m_LightFlags = flags;
95+
}
96+
unsigned int lightFlags() const {
97+
return m_LightFlags;
98+
}
9199

92100
private:
93101

@@ -96,6 +104,10 @@ class Light : public Indicator
96104
Color m_Specular;
97105
glm::vec3 m_Atten; // c, l, q
98106
Type m_Type;
107+
enum eLightFlags {
108+
F_CAST_SHADOWS = BIT(0)
109+
};
110+
unsigned int m_LightFlags;
99111

100112
AABB m_Box;
101113
};

src/Mesh.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <assimp/assimp.hpp>
55
#include <assimp/aiScene.h>
66
#include <assimp/aiPostProcess.h>
7-
#include "AITypeParser.h"
7+
#include "MeshTypeParser.h"
88
#include "Util.h"
99

1010
#include <iostream>
@@ -118,7 +118,7 @@ bool Mesh :: load(std::string fn, ResourceCache<Texture>& rmap)
118118
}
119119

120120
for(unsigned int i = 0; i < aiscene->mNumMeshes; i++)
121-
loadAIMesh(aiscene->mMeshes[i]);
121+
loadModel(aiscene->mMeshes[i]);
122122

123123
return true;
124124
}
@@ -221,7 +221,7 @@ void Mesh :: render(unsigned int flags, float quality) const
221221
}*/
222222
}
223223

224-
bool Mesh :: loadAIMesh(const aiMesh* aimesh)
224+
bool Mesh :: loadModel(const aiMesh* aimesh)
225225
{
226226
name = aimesh->mName.data;
227227

@@ -231,18 +231,18 @@ bool Mesh :: loadAIMesh(const aiMesh* aimesh)
231231
{
232232
bitangents.resize(aimesh->mNumVertices);
233233
for(unsigned int j=0; j<aimesh->mNumVertices; j++)
234-
AITypeParser::parseVector(bitangents[j], aimesh->mBitangents[j]);
234+
MeshTypeParser::parseVector(bitangents[j], aimesh->mBitangents[j]);
235235

236236
tangents.resize(aimesh->mNumVertices);
237237
for(unsigned int j=0; j<aimesh->mNumVertices; j++)
238-
AITypeParser::parseVector(tangents[j], aimesh->mTangents[j]);
238+
MeshTypeParser::parseVector(tangents[j], aimesh->mTangents[j]);
239239
}
240240

241241
if(aimesh->mNormals)
242242
{
243243
normals.resize(aimesh->mNumVertices);
244244
for(unsigned int j=0; j<aimesh->mNumVertices; j++)
245-
AITypeParser::parseVector(normals[j], aimesh->mNormals[j]);
245+
MeshTypeParser::parseVector(normals[j], aimesh->mNormals[j]);
246246
}
247247

248248
if(aimesh->HasTextureCoords(0))
@@ -251,14 +251,14 @@ bool Mesh :: loadAIMesh(const aiMesh* aimesh)
251251
UVs[0].resize(aimesh->mNumVertices);
252252
for(unsigned int j=0; j<aimesh->mNumVertices; j++)
253253
{
254-
AITypeParser::parseVector(UVs[0][j], aimesh->mTextureCoords[0][j]);
255-
//AITypeParser::parseVector(UVs[1][j], aimesh_lmap->mTextureCoords[0][j]);
254+
MeshTypeParser::parseVector(UVs[0][j], aimesh->mTextureCoords[0][j]);
255+
//MeshTypeParser::parseVector(UVs[1][j], aimesh_lmap->mTextureCoords[0][j]);
256256
}
257257
}
258258

259259
vertices.resize(aimesh->mNumVertices);
260260
for(unsigned int j=0; j<aimesh->mNumVertices; j++){
261-
AITypeParser::parseVector(vertices[j], aimesh->mVertices[j]);
261+
MeshTypeParser::parseVector(vertices[j], aimesh->mVertices[j]);
262262
//vertices[j] *= MESH_SCALE;
263263
}
264264
}

src/Mesh.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
#include <assimp/assimp.hpp>
1313
#include <assimp/aiScene.h>
1414
#include <assimp/aiPostProcess.h>
15-
#include "Shadow.h"
1615
#include "Light.h"
1716
#include "IRealtime.h"
18-
class Shadow;
1917
class Light;
2018

2119
class Mesh : public IRealtime
@@ -58,8 +56,6 @@ class Mesh : public IRealtime
5856
Mesh(std::string n = "", float minlod = 0.1f);
5957
Mesh(std::string fn, ResourceCache<Texture>& tex_map, std::string override_name = "", float minlod = 0.1f);
6058
virtual ~Mesh();
61-
62-
//Shadow generateShadow();
6359

6460
Mesh* getLOD(float quality = 1.0f) const;
6561

@@ -70,11 +66,7 @@ class Mesh : public IRealtime
7066
};
7167
virtual void logic(unsigned int advance);
7268
void render(unsigned int flags = 0, float quality = 1.0f) const;
73-
Shadow* getShadow(Node* node, Light* light){
74-
75-
}
76-
77-
bool loadAIMesh(const aiMesh* aimesh);
69+
bool loadModel(const aiMesh* aimesh);
7870

7971
bool good() const { return !vertices.empty(); } // this could be improved, but it works for now
8072

src/AITypeParser.h renamed to src/MeshTypeParser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <assimp/aiScene.h>
77
#include <assimp/aiPostProcess.h>
88

9-
namespace AITypeParser
9+
namespace MeshTypeParser
1010
{
1111
inline void parseVector(glm::vec3& v, const aiVector3D& aiv) {
1212
v = glm::vec3(aiv.x, aiv.y, aiv.z);

src/Navigation.h

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Waypoint
7171
m_ulStartTime = Freq::get().getElapsedTime(); //ms
7272
m_ulAlarmTime = m_ulStartTime + time.get();
7373
}
74+
7475
virtual ~Waypoint() {}
7576

7677
virtual void poll() {
@@ -94,6 +95,10 @@ class Waypoint
9495
T& position() {
9596
return m_Position;
9697
}
98+
99+
void interp(std::function<T (const T&, const T&, float)> func) {
100+
m_Interpolation = func;
101+
}
97102
};
98103

99104
template<class T>

0 commit comments

Comments
 (0)