This commit is contained in:
2026-03-05 01:42:40 +03:00
parent 2815369bb8
commit 4290e99c61
31 changed files with 2285 additions and 99 deletions

View File

@@ -1,16 +1,4 @@
<Scene>
<StaticMesh filename="graveyard_fence.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_001.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_002.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_003.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_004.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_005.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_006.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_007.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_008.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_009.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_010.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_011.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_012.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_fence_013.obj" shader="lightmapped"/>
<StaticMesh filename="graveyard_terrain.obj" shader="lightmapped"/>
</Scene>

View File

@@ -5,7 +5,8 @@
</LevelDescription>
<Entities>
<Entity classname="TempPlayer">
<Entity classname="actor_player">
<Position x="1.0" y="5.0" z="1.0" />
<IsDisableled value="false" />
</Entity>
</Entities>

Binary file not shown.

View File

@@ -0,0 +1,13 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl graveyard_terrain
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd data\\textures\\scenes\\cemetery\\grass_01.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -5,10 +5,7 @@
</LevelDescription>
<Entities>
<Entity classname="TempPlayer">
<IsDisableled value="false" />
</Entity>
<Entity classname="game_object">
<Entity classname="actor_player">
<IsDisableled value="false" />
</Entity>
</Entities>

View File

@@ -0,0 +1,40 @@
-- базовый класс актора
actor_base = inherit_table(game_object)
-- инициализация FSM
function actor_base:on_init()
game_object.on_init(self)
end
function actor_base:on_shutdown()
game_object.on_shutdown(self)
end
function actor_base:on_update(dt)
game_object.on_update(self, dt)
end
-- игрок
actor_player = inherit_table(actor_base)
function actor_player:on_init()
actor_base.on_init(self)
self:create_body()
self:activate_camera()
end
function actor_player:on_shutdown()
actor_base.on_shutdown(self)
end
function actor_player:on_update(dt)
actor_base.on_update(self, dt)
self:update_camera_look()
--self:update_camera_movement(dt)
self:update_body_movement(dt)
end

View File

@@ -1,13 +1,19 @@
-- Game initialization script
-- загружаем скрипты
load_script("game_utils.lua")
load_script("game_object.lua")
load_script("test_object.lua")
load_script("actors/actor_player.lua")
-- глобальная таблица сущностей
g_entity_table = {
-- Lua class -- CPP class -- Description
-- Lua class -- CPP class -- Description
{ "game_object", "Entity", "Test Lua Entity" }
{ "actor_player", "ActorBase", "Player entity" },
-- Simple entity
{ "test_object", "Entity", "Test entity" },
}

View File

@@ -0,0 +1,18 @@
-- http://lua-users.org/wiki/InheritanceTutorial
function merge_table( baseClass, newClass )
for k, v in pairs( baseClass ) do
if type( v ) == "table" then
newClass[ k ] = newClass[ k ] or {}
merge_table( v, newClass[ k ] )
else
newClass[ k ] = v
end
end
end
function inherit_table( baseClass )
local newClass = {}
merge_table( baseClass, newClass )
return newClass
end

View File

@@ -0,0 +1,16 @@
-- тестовый класс
test_object = inherit_table(game_object)
function test_object:on_init()
game_object.on_init(self)
self:load_model("data/models/scene_walls.obj")
self.m_test = 0.0
end
function test_object:on_update(dt)
game_object.on_update(self, dt)
self:set_position(self.m_test, 0.0, 0.0)
self.m_test = self.m_test + ( 0.2 * dt )
end

View File

@@ -5,14 +5,26 @@ varying vec3 v_normal;
varying vec2 v_texcoord;
varying vec3 v_finalColor;
uniform sampler2D u_albedoTexture;
uniform vec4 u_customColor;
uniform vec4 u_sunAmbientColor;
uniform sampler2D u_albedoTexture;
void main() {
//gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
//gl_FragColor = u_customColor * vec4(v_finalColor, 1.0) * texture2D(u_albedoTexture, v_texcoord);
//gl_FragColor = vec4(v_finalColor, 1.0) * texture2D(u_albedoTexture, v_texcoord);
gl_FragColor = texture2D(u_albedoTexture, v_texcoord);
//gl_FragColor = texture2D(u_albedoTexture, v_texcoord);
//gl_FragColor = vec4( v_normal, 1.0 );
//gl_FragColor = texture2D(u_albedoTexture, v_texcoord);
// !!! NO AREF
// vec3 color = texture2D(u_albedoTexture, v_texcoord).rgb * v_finalColor;
vec3 color = texture2D(u_albedoTexture, v_texcoord).rgb;
color = color * ( u_sunAmbientColor.rgb + v_finalColor.x );
color = color + v_finalColor.y;
gl_FragColor = vec4(color.x, color.y, color.z, 1.0);
}

View File

@@ -13,34 +13,41 @@ uniform mat4 u_modelMatrix;
uniform mat4 u_viewMatrix;
uniform mat4 u_projectionMatrix;
uniform mat4 u_modelViewProjection;
uniform vec4 u_sunDirection;
uniform vec4 u_sunColor;
uniform vec4 u_sunAmbientColor;
uniform vec4 u_cameraPos;
vec3 CalcOmniLight()
{
vec3 lightPos = vec3(0.1, 2.1, 0.1);
float d = distance(lightPos, v_position);
vec3 L = normalize(lightPos-v_position);
vec3 N = normalize(v_normal);
vec3 col = vec3( max(0, dot(N, L) / d) );
col = col * 0.8 + 0.2;
return col;
}
// #TODO: should use own uniforms
#define u_ligthPosition u_sunDirection.xyz
#define u_ligthRadius u_sunDirection.w
vec3 CalcDirLight()
{
vec3 lightPos = vec3(5.0, 10.0, 1.0);
//lightPos = -lightPos;
// Calculate blinn-phong per-vertex lighting
float CalcPhongLighting( vec3 worldPos, vec3 normal, vec3 lightPos ) {
vec3 lightDir = normalize( lightPos - worldPos );
vec3 viewDir = normalize( u_cameraPos.xyz - worldPos );
vec3 halfVec = normalize( lightDir + viewDir );
float diff = max( dot( normal, lightDir ), 0.0 );
vec3 L = normalize(lightPos);
vec3 N = normalize(v_normal);
vec3 col = vec3( max(0, dot(N, L)) );
col = col * 0.8 + 0.2;
return col;
v_finalColor.x = diff;
float spec = pow( max( dot( normal, halfVec ), 0.0 ), 128.0 ) * 1.0;
v_finalColor.y = spec;
return diff + spec;
}
void main() {
v_position = vec3( u_modelMatrix * vec4(a_position, 1.0) );
v_normal = vec3( mat3(u_modelMatrix) * a_normal );
v_texcoord = a_texcoord;
v_finalColor = CalcDirLight();
CalcPhongLighting( v_position, v_normal, u_ligthPosition );
//v_finalColor = u_sunAmbientColor.rgb + CalcPhongLighting( v_position, v_normal, u_ligthPosition );
gl_Position = u_modelViewProjection * vec4(a_position, 1);
}

View File

@@ -0,0 +1,18 @@
#version 120
varying vec3 v_position;
varying vec3 v_normal;
varying vec2 v_texcoord;
varying vec3 v_finalColor;
uniform sampler2D u_albedoTexture;
uniform vec4 u_customColor;
void main() {
//gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
//gl_FragColor = u_customColor * vec4(v_finalColor, 1.0) * texture2D(u_albedoTexture, v_texcoord);
//gl_FragColor = vec4(v_finalColor, 1.0) * texture2D(u_albedoTexture, v_texcoord);
gl_FragColor = texture2D(u_albedoTexture, v_texcoord);
//gl_FragColor = vec4( v_normal, 1.0 );
//gl_FragColor = texture2D(u_albedoTexture, v_texcoord);
}

View File

@@ -0,0 +1,46 @@
#version 120
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_texcoord;
varying vec3 v_position;
varying vec3 v_normal;
varying vec2 v_texcoord;
varying vec3 v_finalColor;
uniform mat4 u_modelMatrix;
uniform mat4 u_viewMatrix;
uniform mat4 u_projectionMatrix;
uniform mat4 u_modelViewProjection;
vec3 CalcOmniLight()
{
vec3 lightPos = vec3(0.1, 2.1, 0.1);
float d = distance(lightPos, v_position);
vec3 L = normalize(lightPos-v_position);
vec3 N = normalize(v_normal);
vec3 col = vec3( max(0, dot(N, L) / d) );
col = col * 0.8 + 0.2;
return col;
}
vec3 CalcDirLight()
{
vec3 lightPos = vec3(5.0, 10.0, 1.0);
//lightPos = -lightPos;
vec3 L = normalize(lightPos);
vec3 N = normalize(v_normal);
vec3 col = vec3( max(0, dot(N, L)) );
col = col * 0.8 + 0.2;
return col;
}
void main() {
v_position = vec3( u_modelMatrix * vec4(a_position, 1.0) );
v_normal = vec3( mat3(u_modelMatrix) * a_normal );
v_texcoord = a_texcoord;
v_finalColor = CalcDirLight();
gl_Position = u_modelViewProjection * vec4(a_position, 1);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB