This commit is contained in:
2026-03-07 07:48:16 +03:00
parent a998771486
commit 95daf12fc5
48 changed files with 4613 additions and 66 deletions

View File

@@ -10,4 +10,4 @@ Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd data\\textures\\scenes\\cemetery\\grass_01.png
map_Kd data/textures/scenes/cemetery/grass_01.png

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

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,4 @@
<Scene>
<StaticMesh filename="zavod_walls.obj" shader="lightmapped"/>
<StaticMesh filename="zavod_floor.obj" shader="lightmapped"/>
</Scene>

View File

@@ -0,0 +1,53 @@
<Level>
<LevelDescription>
<SceneFile filename="zavod.scene"/>
<Skybox name="skybox/sky_01.dae"/>
</LevelDescription>
<Entities>
<Entity classname="actor_player">
<Position x="1.0" y="2.0" z="1.0" />
<IsDisableled value="false" />
</Entity>
<Entity classname="Entity">
<Position x="10.04" y="1.39" z="-0.83" />
<Model filename="data/models/figure_box.obj" />
<IsDisableled value="false" />
<Physics value="true" />
</Entity>
<Entity classname="Light">
<Position x="11.56" y="1.39" z="-4.14" />
<IsDisableled value="false" />
<Color r="0.7" g="0.5" b="0.5"/>
<Radius value="5"/>
</Entity>
<Entity classname="Light">
<Position x="9.40" y="1.39" z="-3.93" />
<IsDisableled value="false" />
<Color r="100" g="0" b="0"/>
<Radius value="1"/>
</Entity>
<Entity classname="Light">
<Position x="1.72" y="1.39" z="-0.37" />
<IsDisableled value="false" />
<Color r="0.7" g="0.5" b="0.5"/>
<Radius value="5"/>
</Entity>
<Entity classname="Light">
<Position x="6.33" y="1.39" z="-0.37" />
<IsDisableled value="false" />
<Color r="0.7" g="0.5" b="0.5"/>
<Radius value="5"/>
</Entity>
</Entities>
</Level>

View File

@@ -0,0 +1,13 @@
# Blender MTL File: 'zavod.blend'
# Material Count: 1
newmtl concrete_floor
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/concrete/concrete_floor_1.tga

View File

@@ -0,0 +1,839 @@
# Blender v2.93.9 OBJ File: 'zavod.blend'
# www.blender.org
o Cube
v -1.000000 0.000000 2.000000
v -1.000000 0.000000 -2.000000
v 9.000000 0.000000 2.000000
v 9.000000 0.000000 -2.000000
v 14.000000 0.000000 -2.000000
v 14.000000 0.000000 2.000000
v 9.000000 0.000000 -8.000000
v 14.000000 0.000000 -8.000000
v -1.000000 0.000000 0.000000
v 4.000000 0.000000 -2.000000
v 9.000000 0.000000 0.000000
v 4.000000 0.000000 2.000000
v 14.000000 0.000000 0.000000
v 11.500000 0.000000 -2.000000
v 11.500000 0.000000 2.000000
v 11.500000 0.000000 -8.000000
v 9.000000 0.000000 -5.000000
v 14.000000 0.000000 -5.000000
v 11.500000 0.000000 -5.000000
v 11.500000 0.000000 0.000000
v 4.000000 0.000000 0.000000
v -1.000000 0.000000 1.000000
v 1.500000 0.000000 -2.000000
v 9.000000 0.000000 -1.000000
v 6.500000 0.000000 2.000000
v 14.000000 0.000000 -1.000000
v 12.750000 0.000000 -2.000000
v 10.250000 0.000000 2.000000
v 12.750000 0.000000 -8.000000
v 9.000000 0.000000 -6.500000
v 14.000000 0.000000 -6.500000
v -1.000000 0.000000 -1.000000
v 6.500000 0.000000 -2.000000
v 9.000000 0.000000 1.000000
v 1.500000 0.000000 2.000000
v 14.000000 0.000000 1.000000
v 10.250000 0.000000 -2.000000
v 12.750000 0.000000 2.000000
v 10.250000 0.000000 -8.000000
v 9.000000 0.000000 -3.500000
v 14.000000 0.000000 -3.500000
v 11.500000 0.000000 -6.500000
v 11.500000 0.000000 -3.500000
v 10.250000 0.000000 -5.000000
v 12.750000 0.000000 -5.000000
v 12.750000 0.000000 0.000000
v 10.250000 0.000000 0.000000
v 11.500000 0.000000 -1.000000
v 11.500000 0.000000 1.000000
v 6.500000 0.000000 0.000000
v 1.500000 0.000000 0.000000
v 4.000000 0.000000 -1.000000
v 4.000000 0.000000 1.000000
v 1.500000 0.000000 1.000000
v 1.500000 0.000000 -1.000000
v 6.500000 0.000000 -1.000000
v 10.250000 0.000000 1.000000
v 10.250000 0.000000 -1.000000
v 12.750000 0.000000 -1.000000
v 12.750000 0.000000 -3.500000
v 10.250000 0.000000 -3.500000
v 10.250000 0.000000 -6.500000
v 12.750000 0.000000 -6.500000
v 12.750000 0.000000 1.000000
v 6.500000 0.000000 1.000000
v -1.000000 0.000000 1.500000
v 0.250000 0.000000 -2.000000
v 9.000000 0.000000 -1.500000
v 7.750000 0.000000 2.000000
v 14.000000 0.000000 -1.500000
v 13.375000 0.000000 -2.000000
v 9.625000 0.000000 2.000000
v 13.375000 0.000000 -8.000000
v 9.000000 0.000000 -7.250000
v 14.000000 0.000000 -7.250000
v -1.000000 0.000000 -0.500000
v 5.250000 0.000000 -2.000000
v 9.000000 0.000000 0.500000
v 2.750000 0.000000 2.000000
v 14.000000 0.000000 0.500000
v 10.875000 0.000000 -2.000000
v 12.125000 0.000000 2.000000
v 10.875000 0.000000 -8.000000
v 9.000000 0.000000 -4.250000
v 14.000000 0.000000 -4.250000
v 11.500000 0.000000 -7.250000
v 11.500000 0.000000 -4.250000
v 9.625000 0.000000 -5.000000
v 12.125000 0.000000 -5.000000
v 13.375000 0.000000 0.000000
v 10.875000 0.000000 0.000000
v 11.500000 0.000000 -1.500000
v 11.500000 0.000000 0.500000
v 7.750000 0.000000 0.000000
v 2.750000 0.000000 0.000000
v 4.000000 0.000000 -1.500000
v 4.000000 0.000000 0.500000
v -1.000000 0.000000 0.500000
v 2.750000 0.000000 -2.000000
v 9.000000 0.000000 -0.500000
v 5.250000 0.000000 2.000000
v 14.000000 0.000000 -0.500000
v 12.125000 0.000000 -2.000000
v 10.875000 0.000000 2.000000
v 12.125000 0.000000 -8.000000
v 9.000000 0.000000 -5.750000
v 14.000000 0.000000 -5.750000
v -1.000000 0.000000 -1.500000
v 7.750000 0.000000 -2.000000
v 9.000000 0.000000 1.500000
v 0.250000 0.000000 2.000000
v 14.000000 0.000000 1.500000
v 9.625000 0.000000 -2.000000
v 13.375000 0.000000 2.000000
v 9.625000 0.000000 -8.000000
v 9.000000 0.000000 -2.750000
v 14.000000 0.000000 -2.750000
v 11.500000 0.000000 -5.750000
v 11.500000 0.000000 -2.750000
v 10.875000 0.000000 -5.000000
v 13.375000 0.000000 -5.000000
v 12.125000 0.000000 0.000000
v 9.625000 0.000000 0.000000
v 11.500000 0.000000 -0.500000
v 11.500000 0.000000 1.500000
v 5.250000 0.000000 0.000000
v 0.250000 0.000000 0.000000
v 4.000000 0.000000 -0.500000
v 4.000000 0.000000 1.500000
v 2.750000 0.000000 1.000000
v 0.250000 0.000000 1.000000
v 1.500000 0.000000 0.500000
v 1.500000 0.000000 1.500000
v 2.750000 0.000000 -1.000000
v 0.250000 0.000000 -1.000000
v 1.500000 0.000000 -1.500000
v 1.500000 0.000000 -0.500000
v 7.750000 0.000000 -1.000000
v 5.250000 0.000000 -1.000000
v 6.500000 0.000000 -1.500000
v 6.500000 0.000000 -0.500000
v 10.875000 0.000000 1.000000
v 9.625000 0.000000 1.000000
v 10.250000 0.000000 0.500000
v 10.250000 0.000000 1.500000
v 10.875000 0.000000 -1.000000
v 9.625000 0.000000 -1.000000
v 10.250000 0.000000 -1.500000
v 10.250000 0.000000 -0.500000
v 13.375000 0.000000 -1.000000
v 12.125000 0.000000 -1.000000
v 12.750000 0.000000 -1.500000
v 12.750000 0.000000 -0.500000
v 12.750000 0.000000 -4.250000
v 12.750000 0.000000 -2.750000
v 12.125000 0.000000 -3.500000
v 13.375000 0.000000 -3.500000
v 10.250000 0.000000 -4.250000
v 10.250000 0.000000 -2.750000
v 9.625000 0.000000 -3.500000
v 10.875000 0.000000 -3.500000
v 10.250000 0.000000 -7.250000
v 10.250000 0.000000 -5.750000
v 9.625000 0.000000 -6.500000
v 10.875000 0.000000 -6.500000
v 12.750000 0.000000 -7.250000
v 12.750000 0.000000 -5.750000
v 12.125000 0.000000 -6.500000
v 13.375000 0.000000 -6.500000
v 13.375000 0.000000 1.000000
v 12.125000 0.000000 1.000000
v 12.750000 0.000000 0.500000
v 12.750000 0.000000 1.500000
v 7.750000 0.000000 1.000000
v 5.250000 0.000000 1.000000
v 6.500000 0.000000 0.500000
v 6.500000 0.000000 1.500000
v 5.250000 0.000000 1.500000
v 5.250000 0.000000 0.500000
v 7.750000 0.000000 0.500000
v 12.125000 0.000000 1.500000
v 12.125000 0.000000 0.500000
v 13.375000 0.000000 0.500000
v 13.375000 0.000000 -5.750000
v 12.125000 0.000000 -5.750000
v 12.125000 0.000000 -7.250000
v 10.875000 0.000000 -5.750000
v 9.625000 0.000000 -5.750000
v 9.625000 0.000000 -7.250000
v 10.875000 0.000000 -2.750000
v 9.625000 0.000000 -2.750000
v 9.625000 0.000000 -4.250000
v 13.375000 0.000000 -2.750000
v 12.125000 0.000000 -2.750000
v 12.125000 0.000000 -4.250000
v 12.125000 0.000000 -0.500000
v 12.125000 0.000000 -1.500000
v 13.375000 0.000000 -1.500000
v 9.625000 0.000000 -0.500000
v 9.625000 0.000000 -1.500000
v 10.875000 0.000000 -1.500000
v 9.625000 0.000000 1.500000
v 9.625000 0.000000 0.500000
v 10.875000 0.000000 0.500000
v 5.250000 0.000000 -0.500000
v 5.250000 0.000000 -1.500000
v 7.750000 0.000000 -1.500000
v 0.250000 0.000000 -0.500000
v 0.250000 0.000000 -1.500000
v 2.750000 0.000000 -1.500000
v 0.250000 0.000000 1.500000
v 0.250000 0.000000 0.500000
v 2.750000 0.000000 0.500000
v 2.750000 0.000000 1.500000
v 2.750000 0.000000 -0.500000
v 7.750000 0.000000 -0.500000
v 10.875000 0.000000 1.500000
v 10.875000 0.000000 -0.500000
v 13.375000 0.000000 -0.500000
v 13.375000 0.000000 -4.250000
v 10.875000 0.000000 -4.250000
v 10.875000 0.000000 -7.250000
v 13.375000 0.000000 -7.250000
v 13.375000 0.000000 1.500000
v 7.750000 0.000000 1.500000
vt -0.002083 -0.972778
vt 0.500000 -0.771944
vt -0.002083 -0.771944
vt 2.257292 -0.972778
vt 2.508333 -0.771944
vt 2.257292 -0.771944
vt 2.508333 2.742639
vt 2.257292 3.043889
vt 2.257292 2.742639
vt 1.504167 2.742639
vt 1.253125 3.043889
vt 1.253125 2.742639
vt 1.504167 1.537639
vt 1.253125 1.838889
vt 1.253125 1.537639
vt 2.508333 1.537639
vt 2.257292 1.838889
vt 2.257292 1.537639
vt 2.257292 -0.169444
vt 2.508333 0.031389
vt 2.257292 0.031389
vt 1.253125 -0.169444
vt 1.504167 0.031389
vt 1.253125 0.031389
vt 1.253125 -0.972778
vt 1.504167 -0.771944
vt 1.253125 -0.771944
vt -0.002083 -0.169444
vt 0.500000 0.031389
vt -0.002083 0.031389
vt -2.010417 -0.169444
vt -1.508333 0.031389
vt -2.010417 0.031389
vt -2.010417 -0.972778
vt -1.508333 -0.771944
vt -2.010417 -0.771944
vt -2.010417 -0.571111
vt -1.508333 -0.370278
vt -2.010417 -0.370278
vt -3.014583 -0.571111
vt -2.512500 -0.370278
vt -3.014583 -0.370278
vt -3.014583 -0.972778
vt -2.512500 -0.771944
vt -3.014583 -0.771944
vt -2.010417 0.232222
vt -1.508333 0.433056
vt -2.010417 0.433056
vt -3.014583 0.232222
vt -2.512500 0.433056
vt -3.014583 0.433056
vt -3.014583 -0.169444
vt -2.512500 0.031389
vt -3.014583 0.031389
vt -0.002083 0.232222
vt 0.500000 0.433056
vt -0.002083 0.433056
vt -1.006250 0.232222
vt -0.504167 0.433056
vt -1.006250 0.433056
vt -1.006250 -0.169444
vt -0.504167 0.031389
vt -1.006250 0.031389
vt 1.253125 -0.571111
vt 1.504167 -0.370278
vt 1.253125 -0.370278
vt 0.751042 -0.571111
vt 1.002083 -0.370278
vt 0.751042 -0.370278
vt 0.751042 -0.972778
vt 1.002083 -0.771944
vt 0.751042 -0.771944
vt 1.253125 0.232222
vt 1.504167 0.433056
vt 1.253125 0.433056
vt 0.751042 0.232222
vt 1.002083 0.433056
vt 0.751042 0.433056
vt 0.751042 -0.169444
vt 1.002083 0.031389
vt 0.751042 0.031389
vt 2.257292 0.232222
vt 2.508333 0.433056
vt 2.257292 0.433056
vt 1.755208 0.232222
vt 2.006250 0.433056
vt 1.755208 0.433056
vt 1.755208 -0.169444
vt 2.006250 0.031389
vt 1.755208 0.031389
vt 2.006250 1.537639
vt 1.755208 1.838889
vt 1.755208 1.537639
vt 2.006250 0.935139
vt 1.755208 1.236389
vt 1.755208 0.935139
vt 2.508333 0.935139
vt 2.257292 1.236389
vt 2.257292 0.935139
vt 1.002083 1.537639
vt 0.751042 1.838889
vt 0.751042 1.537639
vt 1.002083 0.935139
vt 0.751042 1.236389
vt 0.751042 0.935139
vt 1.504167 0.935139
vt 1.253125 1.236389
vt 1.253125 0.935139
vt 1.002083 2.742639
vt 0.751042 3.043889
vt 0.751042 2.742639
vt 1.002083 2.140139
vt 0.751042 2.441389
vt 0.751042 2.140139
vt 1.504167 2.140139
vt 1.253125 2.441389
vt 1.253125 2.140139
vt 2.006250 2.742639
vt 1.755208 3.043889
vt 1.755208 2.742639
vt 2.006250 2.140139
vt 1.755208 2.441389
vt 1.755208 2.140139
vt 2.508333 2.140139
vt 2.257292 2.441389
vt 2.257292 2.140139
vt 2.257292 -0.571111
vt 2.508333 -0.370278
vt 2.257292 -0.370278
vt 1.755208 -0.571111
vt 2.006250 -0.370278
vt 1.755208 -0.370278
vt 1.755208 -0.972778
vt 2.006250 -0.771944
vt 1.755208 -0.771944
vt -0.002083 -0.571111
vt 0.500000 -0.370278
vt -0.002083 -0.370278
vt -1.006250 -0.571111
vt -0.504167 -0.370278
vt -1.006250 -0.370278
vt -1.006250 -0.972778
vt -0.504167 -0.771944
vt -1.006250 -0.771944
vt -0.504167 -0.571111
vt -1.508333 -0.571111
vt -1.508333 -0.972778
vt -0.504167 -0.169444
vt -1.508333 -0.169444
vt 0.500000 -0.169444
vt 2.006250 -0.571111
vt 1.504167 -0.571111
vt 1.504167 -0.972778
vt 2.006250 -0.169444
vt 1.504167 -0.169444
vt 2.508333 -0.169444
vt 2.006250 2.441389
vt 2.006250 1.838889
vt 2.508333 1.838889
vt 1.504167 2.441389
vt 1.504167 1.838889
vt 1.504167 3.043889
vt 1.002083 2.441389
vt 1.002083 1.838889
vt 0.500000 2.441389
vt 0.500000 2.140139
vt 0.500000 1.838889
vt 0.500000 3.043889
vt 0.500000 2.742639
vt 1.002083 1.236389
vt 1.253125 0.633889
vt 1.002083 0.633889
vt 1.504167 0.633889
vt 0.500000 1.236389
vt 0.500000 0.935139
vt 0.751042 0.633889
vt 0.500000 0.633889
vt 0.500000 1.537639
vt 2.006250 1.236389
vt 2.257292 0.633889
vt 2.006250 0.633889
vt 2.508333 0.633889
vt 1.504167 1.236389
vt 1.755208 0.633889
vt 2.006250 0.232222
vt 1.504167 0.232222
vt 1.002083 0.232222
vt 0.500000 0.232222
vt 1.002083 -0.571111
vt 0.500000 -0.571111
vt 0.500000 -0.972778
vt 1.002083 -0.169444
vt -0.504167 0.232222
vt -1.508333 0.232222
vt -0.504167 0.633889
vt -1.006250 0.633889
vt -1.508333 0.633889
vt -0.002083 0.633889
vt -2.512500 0.232222
vt -3.516666 0.031389
vt -3.516666 0.232222
vt -3.516666 -0.169444
vt -2.512500 0.633889
vt -3.014583 0.633889
vt -3.516666 0.433056
vt -3.516666 0.633889
vt -2.010417 0.633889
vt -2.512500 -0.571111
vt -3.516666 -0.771944
vt -3.516666 -0.571111
vt -3.516666 -0.972778
vt -2.512500 -0.169444
vt -3.516666 -0.370278
vt -2.512500 -0.972778
vt 1.002083 -0.972778
vt 2.508333 0.232222
vt 2.508333 1.236389
vt 1.002083 3.043889
vt 2.006250 3.043889
vt 2.508333 2.441389
vt 2.508333 -0.571111
vt 2.006250 -0.972778
vt -0.504167 -0.972778
vt 2.508333 -0.972778
vt 2.508333 3.043889
vn 0.0000 1.0000 0.0000
s off
f 69/1/1 110/2/1 225/3/1
f 114/4/1 112/5/1 224/6/1
f 75/7/1 73/8/1 223/9/1
f 86/10/1 83/11/1 222/12/1
f 87/13/1 120/14/1 221/15/1
f 85/16/1 121/17/1 220/18/1
f 90/19/1 102/20/1 219/21/1
f 91/22/1 124/23/1 218/24/1
f 104/25/1 125/26/1 217/27/1
f 94/28/1 100/29/1 216/30/1
f 95/31/1 128/32/1 215/33/1
f 79/34/1 129/35/1 214/36/1
f 130/37/1 97/38/1 213/39/1
f 131/40/1 132/41/1 212/42/1
f 111/43/1 133/44/1 211/45/1
f 134/46/1 96/47/1 210/48/1
f 135/49/1 136/50/1 209/51/1
f 127/52/1 137/53/1 208/54/1
f 138/55/1 68/56/1 207/57/1
f 139/58/1 140/59/1 206/60/1
f 126/61/1 141/62/1 205/63/1
f 142/64/1 93/65/1 204/66/1
f 143/67/1 144/68/1 203/69/1
f 72/70/1 145/71/1 202/72/1
f 146/73/1 92/74/1 201/75/1
f 147/76/1 148/77/1 200/78/1
f 123/79/1 149/80/1 199/81/1
f 150/82/1 70/83/1 198/84/1
f 151/85/1 152/86/1 197/87/1
f 122/88/1 153/89/1 196/90/1
f 154/91/1 89/92/1 195/93/1
f 155/94/1 156/95/1 194/96/1
f 117/97/1 157/98/1 193/99/1
f 158/100/1 88/101/1 192/102/1
f 159/103/1 160/104/1 191/105/1
f 119/106/1 161/107/1 190/108/1
f 162/109/1 115/110/1 189/111/1
f 163/112/1 164/113/1 188/114/1
f 118/115/1 165/116/1 187/117/1
f 166/118/1 105/119/1 186/120/1
f 167/121/1 168/122/1 185/123/1
f 107/124/1 169/125/1 184/126/1
f 170/127/1 80/128/1 183/129/1
f 171/130/1 172/131/1 182/132/1
f 82/133/1 173/134/1 181/135/1
f 174/136/1 78/137/1 180/138/1
f 175/139/1 176/140/1 179/141/1
f 101/142/1 177/143/1 178/144/1
f 178/144/1 65/145/1 175/139/1
f 129/35/1 175/139/1 53/146/1
f 12/147/1 178/144/1 129/35/1
f 179/141/1 50/148/1 126/61/1
f 97/38/1 126/61/1 21/149/1
f 53/146/1 179/141/1 97/38/1
f 180/138/1 11/150/1 94/28/1
f 176/140/1 94/28/1 50/148/1
f 65/145/1 180/138/1 176/140/1
f 181/135/1 64/151/1 171/130/1
f 125/26/1 171/130/1 49/152/1
f 15/153/1 181/135/1 125/26/1
f 182/132/1 46/154/1 122/88/1
f 93/65/1 122/88/1 20/155/1
f 49/152/1 182/132/1 93/65/1
f 183/129/1 13/156/1 90/19/1
f 172/131/1 90/19/1 46/154/1
f 64/151/1 183/129/1 172/131/1
f 184/126/1 63/157/1 167/121/1
f 121/17/1 167/121/1 45/158/1
f 18/159/1 184/126/1 121/17/1
f 185/123/1 42/160/1 118/115/1
f 89/92/1 118/115/1 19/161/1
f 45/158/1 185/123/1 89/92/1
f 186/120/1 16/162/1 86/10/1
f 168/122/1 86/10/1 42/160/1
f 63/157/1 186/120/1 168/122/1
f 187/117/1 62/163/1 163/112/1
f 120/14/1 163/112/1 44/164/1
f 19/161/1 187/117/1 120/14/1
f 188/114/1 30/165/1 106/166/1
f 88/101/1 106/166/1 17/167/1
f 44/164/1 188/114/1 88/101/1
f 189/111/1 7/168/1 74/169/1
f 164/113/1 74/169/1 30/165/1
f 62/163/1 189/111/1 164/113/1
f 190/108/1 61/170/1 159/103/1
f 81/171/1 159/103/1 37/172/1
f 14/173/1 190/108/1 81/171/1
f 191/105/1 40/174/1 116/175/1
f 113/176/1 116/175/1 4/177/1
f 37/172/1 191/105/1 113/176/1
f 192/102/1 17/167/1 84/178/1
f 160/104/1 84/178/1 40/174/1
f 61/170/1 192/102/1 160/104/1
f 193/99/1 60/179/1 155/94/1
f 71/180/1 155/94/1 27/181/1
f 5/182/1 193/99/1 71/180/1
f 194/96/1 43/183/1 119/106/1
f 103/184/1 119/106/1 14/173/1
f 27/181/1 194/96/1 103/184/1
f 195/93/1 19/161/1 87/13/1
f 156/95/1 87/13/1 43/183/1
f 60/179/1 195/93/1 156/95/1
f 196/90/1 59/185/1 151/85/1
f 124/23/1 151/85/1 48/186/1
f 20/155/1 196/90/1 124/23/1
f 197/87/1 27/181/1 103/184/1
f 92/74/1 103/184/1 14/173/1
f 48/186/1 197/87/1 92/74/1
f 198/84/1 5/182/1 71/180/1
f 152/86/1 71/180/1 27/181/1
f 59/185/1 198/84/1 152/86/1
f 199/81/1 58/187/1 147/76/1
f 100/29/1 147/76/1 24/188/1
f 11/150/1 199/81/1 100/29/1
f 200/78/1 37/172/1 113/176/1
f 68/56/1 113/176/1 4/177/1
f 24/188/1 200/78/1 68/56/1
f 201/75/1 14/173/1 81/171/1
f 148/77/1 81/171/1 37/172/1
f 58/187/1 201/75/1 148/77/1
f 202/72/1 57/189/1 143/67/1
f 110/2/1 143/67/1 34/190/1
f 3/191/1 202/72/1 110/2/1
f 203/69/1 47/192/1 123/79/1
f 78/137/1 123/79/1 11/150/1
f 34/190/1 203/69/1 78/137/1
f 204/66/1 20/155/1 91/22/1
f 144/68/1 91/22/1 47/192/1
f 57/189/1 204/66/1 144/68/1
f 205/63/1 56/193/1 139/58/1
f 128/32/1 139/58/1 52/194/1
f 21/149/1 205/63/1 128/32/1
f 206/60/1 33/195/1 77/196/1
f 96/47/1 77/196/1 10/197/1
f 52/194/1 206/60/1 96/47/1
f 207/57/1 4/177/1 109/198/1
f 140/59/1 109/198/1 33/195/1
f 56/193/1 207/57/1 140/59/1
f 208/54/1 55/199/1 135/49/1
f 76/200/1 135/49/1 32/201/1
f 9/202/1 208/54/1 76/200/1
f 209/51/1 23/203/1 67/204/1
f 108/205/1 67/204/1 2/206/1
f 32/201/1 209/51/1 108/205/1
f 210/48/1 10/197/1 99/207/1
f 136/50/1 99/207/1 23/203/1
f 55/199/1 210/48/1 136/50/1
f 211/45/1 54/208/1 131/40/1
f 66/209/1 131/40/1 22/210/1
f 1/211/1 211/45/1 66/209/1
f 212/42/1 51/212/1 127/52/1
f 98/213/1 127/52/1 9/202/1
f 22/210/1 212/42/1 98/213/1
f 213/39/1 21/149/1 95/31/1
f 132/41/1 95/31/1 51/212/1
f 54/208/1 213/39/1 132/41/1
f 214/36/1 53/146/1 130/37/1
f 133/44/1 130/37/1 54/208/1
f 35/214/1 214/36/1 133/44/1
f 215/33/1 52/194/1 134/46/1
f 137/53/1 134/46/1 55/199/1
f 51/212/1 215/33/1 137/53/1
f 216/30/1 24/188/1 138/55/1
f 141/62/1 138/55/1 56/193/1
f 50/148/1 216/30/1 141/62/1
f 217/27/1 49/152/1 142/64/1
f 145/71/1 142/64/1 57/189/1
f 28/215/1 217/27/1 145/71/1
f 218/24/1 48/186/1 146/73/1
f 149/80/1 146/73/1 58/187/1
f 47/192/1 218/24/1 149/80/1
f 219/21/1 26/216/1 150/82/1
f 153/89/1 150/82/1 59/185/1
f 46/154/1 219/21/1 153/89/1
f 220/18/1 45/158/1 154/91/1
f 157/98/1 154/91/1 60/179/1
f 41/217/1 220/18/1 157/98/1
f 221/15/1 44/164/1 158/100/1
f 161/107/1 158/100/1 61/170/1
f 43/183/1 221/15/1 161/107/1
f 222/12/1 39/218/1 162/109/1
f 165/116/1 162/109/1 62/163/1
f 42/160/1 222/12/1 165/116/1
f 223/9/1 29/219/1 166/118/1
f 169/125/1 166/118/1 63/157/1
f 31/220/1 223/9/1 169/125/1
f 224/6/1 36/221/1 170/127/1
f 173/134/1 170/127/1 64/151/1
f 38/222/1 224/6/1 173/134/1
f 225/3/1 34/190/1 174/136/1
f 177/143/1 174/136/1 65/145/1
f 25/223/1 225/3/1 177/143/1
f 69/1/1 3/191/1 110/2/1
f 114/4/1 6/224/1 112/5/1
f 75/7/1 8/225/1 73/8/1
f 86/10/1 16/162/1 83/11/1
f 87/13/1 19/161/1 120/14/1
f 85/16/1 18/159/1 121/17/1
f 90/19/1 13/156/1 102/20/1
f 91/22/1 20/155/1 124/23/1
f 104/25/1 15/153/1 125/26/1
f 94/28/1 11/150/1 100/29/1
f 95/31/1 21/149/1 128/32/1
f 79/34/1 12/147/1 129/35/1
f 130/37/1 53/146/1 97/38/1
f 131/40/1 54/208/1 132/41/1
f 111/43/1 35/214/1 133/44/1
f 134/46/1 52/194/1 96/47/1
f 135/49/1 55/199/1 136/50/1
f 127/52/1 51/212/1 137/53/1
f 138/55/1 24/188/1 68/56/1
f 139/58/1 56/193/1 140/59/1
f 126/61/1 50/148/1 141/62/1
f 142/64/1 49/152/1 93/65/1
f 143/67/1 57/189/1 144/68/1
f 72/70/1 28/215/1 145/71/1
f 146/73/1 48/186/1 92/74/1
f 147/76/1 58/187/1 148/77/1
f 123/79/1 47/192/1 149/80/1
f 150/82/1 26/216/1 70/83/1
f 151/85/1 59/185/1 152/86/1
f 122/88/1 46/154/1 153/89/1
f 154/91/1 45/158/1 89/92/1
f 155/94/1 60/179/1 156/95/1
f 117/97/1 41/217/1 157/98/1
f 158/100/1 44/164/1 88/101/1
f 159/103/1 61/170/1 160/104/1
f 119/106/1 43/183/1 161/107/1
f 162/109/1 39/218/1 115/110/1
f 163/112/1 62/163/1 164/113/1
f 118/115/1 42/160/1 165/116/1
f 166/118/1 29/219/1 105/119/1
f 167/121/1 63/157/1 168/122/1
f 107/124/1 31/220/1 169/125/1
f 170/127/1 36/221/1 80/128/1
f 171/130/1 64/151/1 172/131/1
f 82/133/1 38/222/1 173/134/1
f 174/136/1 34/190/1 78/137/1
f 175/139/1 65/145/1 176/140/1
f 101/142/1 25/223/1 177/143/1
f 178/144/1 177/143/1 65/145/1
f 129/35/1 178/144/1 175/139/1
f 12/147/1 101/142/1 178/144/1
f 179/141/1 176/140/1 50/148/1
f 97/38/1 179/141/1 126/61/1
f 53/146/1 175/139/1 179/141/1
f 180/138/1 78/137/1 11/150/1
f 176/140/1 180/138/1 94/28/1
f 65/145/1 174/136/1 180/138/1
f 181/135/1 173/134/1 64/151/1
f 125/26/1 181/135/1 171/130/1
f 15/153/1 82/133/1 181/135/1
f 182/132/1 172/131/1 46/154/1
f 93/65/1 182/132/1 122/88/1
f 49/152/1 171/130/1 182/132/1
f 183/129/1 80/128/1 13/156/1
f 172/131/1 183/129/1 90/19/1
f 64/151/1 170/127/1 183/129/1
f 184/126/1 169/125/1 63/157/1
f 121/17/1 184/126/1 167/121/1
f 18/159/1 107/124/1 184/126/1
f 185/123/1 168/122/1 42/160/1
f 89/92/1 185/123/1 118/115/1
f 45/158/1 167/121/1 185/123/1
f 186/120/1 105/119/1 16/162/1
f 168/122/1 186/120/1 86/10/1
f 63/157/1 166/118/1 186/120/1
f 187/117/1 165/116/1 62/163/1
f 120/14/1 187/117/1 163/112/1
f 19/161/1 118/115/1 187/117/1
f 188/114/1 164/113/1 30/165/1
f 88/101/1 188/114/1 106/166/1
f 44/164/1 163/112/1 188/114/1
f 189/111/1 115/110/1 7/168/1
f 164/113/1 189/111/1 74/169/1
f 62/163/1 162/109/1 189/111/1
f 190/108/1 161/107/1 61/170/1
f 81/171/1 190/108/1 159/103/1
f 14/173/1 119/106/1 190/108/1
f 191/105/1 160/104/1 40/174/1
f 113/176/1 191/105/1 116/175/1
f 37/172/1 159/103/1 191/105/1
f 192/102/1 88/101/1 17/167/1
f 160/104/1 192/102/1 84/178/1
f 61/170/1 158/100/1 192/102/1
f 193/99/1 157/98/1 60/179/1
f 71/180/1 193/99/1 155/94/1
f 5/182/1 117/97/1 193/99/1
f 194/96/1 156/95/1 43/183/1
f 103/184/1 194/96/1 119/106/1
f 27/181/1 155/94/1 194/96/1
f 195/93/1 89/92/1 19/161/1
f 156/95/1 195/93/1 87/13/1
f 60/179/1 154/91/1 195/93/1
f 196/90/1 153/89/1 59/185/1
f 124/23/1 196/90/1 151/85/1
f 20/155/1 122/88/1 196/90/1
f 197/87/1 152/86/1 27/181/1
f 92/74/1 197/87/1 103/184/1
f 48/186/1 151/85/1 197/87/1
f 198/84/1 70/83/1 5/182/1
f 152/86/1 198/84/1 71/180/1
f 59/185/1 150/82/1 198/84/1
f 199/81/1 149/80/1 58/187/1
f 100/29/1 199/81/1 147/76/1
f 11/150/1 123/79/1 199/81/1
f 200/78/1 148/77/1 37/172/1
f 68/56/1 200/78/1 113/176/1
f 24/188/1 147/76/1 200/78/1
f 201/75/1 92/74/1 14/173/1
f 148/77/1 201/75/1 81/171/1
f 58/187/1 146/73/1 201/75/1
f 202/72/1 145/71/1 57/189/1
f 110/2/1 202/72/1 143/67/1
f 3/191/1 72/70/1 202/72/1
f 203/69/1 144/68/1 47/192/1
f 78/137/1 203/69/1 123/79/1
f 34/190/1 143/67/1 203/69/1
f 204/66/1 93/65/1 20/155/1
f 144/68/1 204/66/1 91/22/1
f 57/189/1 142/64/1 204/66/1
f 205/63/1 141/62/1 56/193/1
f 128/32/1 205/63/1 139/58/1
f 21/149/1 126/61/1 205/63/1
f 206/60/1 140/59/1 33/195/1
f 96/47/1 206/60/1 77/196/1
f 52/194/1 139/58/1 206/60/1
f 207/57/1 68/56/1 4/177/1
f 140/59/1 207/57/1 109/198/1
f 56/193/1 138/55/1 207/57/1
f 208/54/1 137/53/1 55/199/1
f 76/200/1 208/54/1 135/49/1
f 9/202/1 127/52/1 208/54/1
f 209/51/1 136/50/1 23/203/1
f 108/205/1 209/51/1 67/204/1
f 32/201/1 135/49/1 209/51/1
f 210/48/1 96/47/1 10/197/1
f 136/50/1 210/48/1 99/207/1
f 55/199/1 134/46/1 210/48/1
f 211/45/1 133/44/1 54/208/1
f 66/209/1 211/45/1 131/40/1
f 1/211/1 111/43/1 211/45/1
f 212/42/1 132/41/1 51/212/1
f 98/213/1 212/42/1 127/52/1
f 22/210/1 131/40/1 212/42/1
f 213/39/1 97/38/1 21/149/1
f 132/41/1 213/39/1 95/31/1
f 54/208/1 130/37/1 213/39/1
f 214/36/1 129/35/1 53/146/1
f 133/44/1 214/36/1 130/37/1
f 35/214/1 79/34/1 214/36/1
f 215/33/1 128/32/1 52/194/1
f 137/53/1 215/33/1 134/46/1
f 51/212/1 95/31/1 215/33/1
f 216/30/1 100/29/1 24/188/1
f 141/62/1 216/30/1 138/55/1
f 50/148/1 94/28/1 216/30/1
f 217/27/1 125/26/1 49/152/1
f 145/71/1 217/27/1 142/64/1
f 28/215/1 104/25/1 217/27/1
f 218/24/1 124/23/1 48/186/1
f 149/80/1 218/24/1 146/73/1
f 47/192/1 91/22/1 218/24/1
f 219/21/1 102/20/1 26/216/1
f 153/89/1 219/21/1 150/82/1
f 46/154/1 90/19/1 219/21/1
f 220/18/1 121/17/1 45/158/1
f 157/98/1 220/18/1 154/91/1
f 41/217/1 85/16/1 220/18/1
f 221/15/1 120/14/1 44/164/1
f 161/107/1 221/15/1 158/100/1
f 43/183/1 87/13/1 221/15/1
f 222/12/1 83/11/1 39/218/1
f 165/116/1 222/12/1 162/109/1
f 42/160/1 86/10/1 222/12/1
f 223/9/1 73/8/1 29/219/1
f 169/125/1 223/9/1 166/118/1
f 31/220/1 75/7/1 223/9/1
f 224/6/1 112/5/1 36/221/1
f 173/134/1 224/6/1 170/127/1
f 38/222/1 114/4/1 224/6/1
f 225/3/1 110/2/1 34/190/1
f 177/143/1 225/3/1 174/136/1
f 25/223/1 69/1/1 225/3/1

Binary file not shown.

View File

@@ -0,0 +1,13 @@
# Blender MTL File: 'zavod.blend'
# Material Count: 1
newmtl concrete_walls
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/concrete/concrete_wall_bunker_1.tga

File diff suppressed because it is too large Load Diff

Binary file not shown.

BIN
data/models/metal_door.iqm Normal file

Binary file not shown.

View File

@@ -0,0 +1,12 @@
# Blender 4.0.2 MTL File: 'scene.blend'
# www.blender.org
newmtl Material.002
Ns 250.000000
Ka 1.000000 1.000000 1.000000
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/metal/metal_rust_01.jpg

View File

@@ -27,6 +27,8 @@ function actor_player:on_init()
local ent = engine.create_entity("weapon_ump")
engine.add_entity_to_world(ent)
self.m_weapon_entity_id = ent:get_id()
--engine.play_sound_3d("data/sounds/test/test_music_64Kbps.mp3", 0.0, 0.0, 0.0)
end
function actor_player:on_shutdown()
@@ -88,7 +90,10 @@ function actor_player:update_player_movement(dt)
local up_x, up_y, up_z = camera.get_up()
local front_x, front_y, front_z = camera.get_front()
front_y = 0.0
if not self:is_noclip() then
front_y = 0.0
end
local final_front_x, final_front_y, final_front_z = vec3_normalize(front_x, front_y, front_z)
local cross_x, cross_y, cross_z = vec3_cross(final_front_x, final_front_y, final_front_z,
@@ -128,6 +133,15 @@ function actor_player:update_player_movement(dt)
local vel_y = dir_y * speed
local vel_z = dir_z * speed
if self:is_noclip() then
if (movement & EMovementDir_None) ~= 0 then
self:set_velocity(vel_x, vel_y, vel_z)
else
self:set_velocity(0, 0, 0)
end
return
end
if self:on_ground() then
self:set_velocity(vel_x, current_vel_y, vel_z)
@@ -142,6 +156,8 @@ function actor_player:update_player_movement(dt)
local air_vel_z = current_vel_z + dir_z * speed * AIR_CONTROL * dt
self:set_velocity(air_vel_x, current_vel_y, air_vel_z)
end
end
local g_yaw = 0.0

View File

@@ -4,7 +4,7 @@ local BLUE_COLOR = { 0.0, 0.0, 1.0, 1.0 }
local BLACK_COLOR = { 0.0, 0.0, 0.0, 1.0 }
local WHITE_COLOR = { 1.0, 1.0, 1.0, 1.0 }
local draw_test_hud = true
local draw_test_hud = false
local draw_debug_string = false
local debug_string_text = ""
local debug_string_time = 0.0

View File

@@ -11,20 +11,16 @@ 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 = 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;
//vec3 color = texture2D(u_albedoTexture, v_texcoord).rgb;
//color = color * ( u_sunAmbientColor.rgb + v_finalColor.x );
//color = color + v_finalColor.y;
vec3 color = texture2D(u_albedoTexture, v_texcoord).rgb * v_finalColor;
gl_FragColor = vec4(color.x, color.y, color.z, 1.0);
}

View File

@@ -23,20 +23,21 @@ uniform vec4 u_cameraPos;
#define u_ligthRadius u_sunDirection.w
// Calculate blinn-phong per-vertex lighting
float CalcPhongLighting( vec3 worldPos, vec3 normal, vec3 lightPos ) {
vec3 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 );
float spec = pow( max( dot( normal, halfVec ), 0.0 ), 32.0 );
v_finalColor.x = diff;
float lightlength = length( lightPos - worldPos );
float attenuation = max( 0.0, 1.0 - lightlength / u_ligthRadius );
float spec = pow( max( dot( normal, halfVec ), 0.0 ), 128.0 ) * 1.0;
diff = diff * attenuation;
spec = spec * attenuation;
v_finalColor.y = spec;
return diff + spec;
return u_sunAmbientColor.rgb + (u_sunColor.rgb * diff) + (u_sunColor.rgb * spec);
}
void main() {
@@ -44,10 +45,7 @@ void main() {
v_normal = vec3( mat3(u_modelMatrix) * a_normal );
v_texcoord = a_texcoord;
CalcPhongLighting( v_position, v_normal, u_ligthPosition );
//v_finalColor = u_sunAmbientColor.rgb + CalcPhongLighting( v_position, v_normal, u_ligthPosition );
v_finalColor = CalcPhongLighting( v_position, v_normal, u_ligthPosition );
gl_Position = u_modelViewProjection * vec4(a_position, 1);
}

View File

@@ -0,0 +1,63 @@
#version 120
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_texcoord;
attribute vec4 a_boneIds;
attribute vec4 a_weights;
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;
uniform vec4 u_sunDirection;
uniform vec4 u_sunColor;
uniform vec4 u_sunAmbientColor;
uniform vec4 u_cameraPos;
uniform mat4 u_boneMatrices[128];
// #TODO: should use own uniforms
#define u_ligthPosition u_sunDirection.xyz
#define u_ligthRadius u_sunDirection.w
// Calculate blinn-phong per-vertex lighting
vec3 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 );
float spec = pow( max( dot( normal, halfVec ), 0.0 ), 32.0 );
float lightlength = length( lightPos - worldPos );
float attenuation = max( 0.0, 1.0 - lightlength / u_ligthRadius );
diff = diff * attenuation;
spec = spec * attenuation;
return u_sunAmbientColor.rgb + (u_sunColor.rgb * diff) + (u_sunColor.rgb * spec);
}
void main() {
// calculate bone transform
mat4 skinMatrix = a_weights.x * u_boneMatrices[ int( a_boneIds.x ) ]
+ a_weights.y * u_boneMatrices[ int( a_boneIds.y ) ]
+ a_weights.z * u_boneMatrices[ int( a_boneIds.z ) ]
+ a_weights.w * u_boneMatrices[ int( a_boneIds.w ) ];
// Position
v_position = vec3( skinMatrix * vec4( a_position, 1.0 ) );
v_position = vec3( u_modelMatrix * vec4( v_position, 1.0 ) );
v_normal = vec3( mat3(u_modelMatrix) * a_normal );
v_texcoord = a_texcoord;
v_finalColor = CalcPhongLighting( v_position, v_normal, u_ligthPosition );
gl_Position = u_projectionMatrix * u_viewMatrix * vec4( v_position, 1.0 );
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 KiB

View File

@@ -111,6 +111,8 @@ struct ExampleAppConsole
Commands.push_back("r_scene_debug_draw");
Commands.push_back("r_show_stats");
Commands.push_back("r_entity_debug_draw");
Commands.push_back("r_light_debug_draw");
Commands.push_back("noclip");
Commands.push_back("map");
Commands.push_back("quit");
AutoScroll = true;
@@ -290,12 +292,12 @@ struct ExampleAppConsole
void ExecCommand(const char* command_line)
{
AddLog("# %s\n", command_line);
static char extracted[1024];
const char* full_command_line = command_line;
if (const char* arg = strchr(command_line, ' '))
{
static char extracted[1024];
strncpy(extracted, command_line, arg - command_line);
command_line = extracted;
@@ -348,6 +350,15 @@ struct ExampleAppConsole
extern bool g_debugEntityDraw;
g_debugEntityDraw = !g_debugEntityDraw;
}
else if (Stricmp(command_line, "R_LIGHT_DEBUG_DRAW") == 0)
{
extern bool g_debugDrawLights;
g_debugDrawLights = !g_debugDrawLights;
}
else if (Stricmp(command_line, "NOCLIP") == 0)
{
toggleNoclip();
}
else if (Stricmp(command_line, "MAP") == 0)
{
GetEngine()->NewGame(full_command_line + 4);
@@ -363,6 +374,8 @@ struct ExampleAppConsole
// On command input, we scroll to bottom even if AutoScroll==false
ScrollToBottom = true;
extracted[0] = '\0';
}
// In C++11 you'd be better off using lambdas for this sort of forwarding callbacks
@@ -674,6 +687,14 @@ void Engine::Frame()
if (s_showConsole)
UpdateConsole();
// update sound
Camera* camera = g_cameraManager.GetActiveCamera();
if (camera)
{
g_soundSystem.SetListenerPosition(camera->GetPosition().x, camera->GetPosition().y, camera->GetPosition().z);
g_soundSystem.SetListenerDirection(camera->GetFront().x, camera->GetFront().y, camera->GetFront().z);
}
// update physics
if (g_PhysicsWorld)
g_PhysicsWorld->Step(dt);
@@ -766,7 +787,8 @@ void Engine::NewGame(const char* mapname)
g_render->LoadSceneXML(mapname);
CloseConsole();
if (s_showConsole)
CloseConsole();
// after initializing client scene and collision system - we initialize the server game
g_game->InitForNewMap(mapname);

View File

@@ -5,7 +5,8 @@
REGISTER_ENTITY(ActorBase);
ActorBase::ActorBase()
ActorBase::ActorBase() :
m_noclip(false)
{
}
@@ -242,6 +243,40 @@ bool ActorBase::OnGround()
return false;
}
void ActorBase::SetNoclip(bool noclip)
{
static int mask1 = -1, mask2 = -1;
m_noclip = noclip;
if (noclip)
{
if (mask1 == -1)
{
mask1 = m_rigidBody->getBroadphaseHandle()->m_collisionFilterGroup;
mask2 = m_rigidBody->getBroadphaseHandle()->m_collisionFilterMask;
}
m_rigidBody->getBroadphaseHandle()->m_collisionFilterGroup = 0;
m_rigidBody->getBroadphaseHandle()->m_collisionFilterMask = 0;
g_PhysicsWorld->GetWorld()->getPairCache()->cleanProxyFromPairs(m_rigidBody->getBroadphaseHandle(), g_PhysicsWorld->GetWorld()->getDispatcher());
m_rigidBody->setCollisionFlags(m_rigidBody->getCollisionFlags() |/* btCollisionObject::CF_KINEMATIC_OBJECT |*/ btCollisionObject::CF_NO_CONTACT_RESPONSE);
m_rigidBody->setGravity(btVector3(0.0f, 0.f, 0.f));
}
else
{
m_rigidBody->getBroadphaseHandle()->m_collisionFilterGroup = mask1;
m_rigidBody->getBroadphaseHandle()->m_collisionFilterMask = mask2;
// m_rigidBody->setCollisionFlags(m_rigidBody->getCollisionFlags() & ~btCollisionObject::CF_KINEMATIC_OBJECT);
m_rigidBody->setCollisionFlags(m_rigidBody->getCollisionFlags() & ~btCollisionObject::CF_NO_CONTACT_RESPONSE);
m_rigidBody->setGravity(g_PhysicsWorld->GetWorld()->getGravity());
}
}
void ActorBase::RegisterFunctions()
{
m_luaObject.Register("activate_camera", *this, &ActorBase::Lua_ActivateCamera);
@@ -253,6 +288,7 @@ void ActorBase::RegisterFunctions()
m_luaObject.Register("get_action", *this, &ActorBase::Lua_GetAction);
m_luaObject.Register("get_movement", *this, &ActorBase::Lua_GetMovement);
m_luaObject.Register("on_ground", *this, &ActorBase::Lua_OnGround);
m_luaObject.Register("is_noclip", *this, &ActorBase::Lua_IsNoclip);
//m_luaObject.RegisterDirect("activate_camera", &ActorBase_ActivateCamera);
//m_luaObject.RegisterDirect("update_camera_look", &ActorBase_UpdateCameraLook);
@@ -332,6 +368,12 @@ int ActorBase::Lua_OnGround(LuaPlus::LuaState* state)
return 1;
}
int ActorBase::Lua_IsNoclip(LuaPlus::LuaState* state)
{
state->PushBoolean(m_noclip);
return 1;
}
int ActorBase::GenAction()
{
int action = -1;

View File

@@ -37,6 +37,8 @@ public:
bool OnGround();
void SetNoclip(bool noclip);
// Lua bindings
virtual void RegisterFunctions();
@@ -50,6 +52,7 @@ public:
int Lua_GetAction(LuaPlus::LuaState* state);
int Lua_GetMovement(LuaPlus::LuaState* state);
int Lua_OnGround(LuaPlus::LuaState* state);
int Lua_IsNoclip(LuaPlus::LuaState* state);
private:
int GenAction();
@@ -58,7 +61,7 @@ private:
private:
Camera m_camera;
bool m_noclip;
};

View File

@@ -11,6 +11,10 @@
#include "world.h"
#include "game_object.h"
#include "soundsystem.h"
#include "animation.h"
#include "scenemanager.h"
#include "game_world_objects.h"
#include "actor_base.h"
#include <pugixml.hpp>
@@ -27,6 +31,7 @@ public:
public:
void PlaySound2D(const std::string& filename);
void PlaySound3D(const std::string& filename, const glm::vec3& pos);
void CacheSound(const std::string& filename);
private:
@@ -57,6 +62,24 @@ void GameSoundSystem::PlaySound2D(const std::string& filename)
g_soundSystem.Play(it->second, false);
}
void GameSoundSystem::PlaySound3D(const std::string& filename, const glm::vec3& pos)
{
auto it = m_sounds.find(filename);
if (it == m_sounds.end())
{
CacheSound(filename);
it = m_sounds.find(filename);
}
SDL_assert(it != m_sounds.end());
// .hack due unimplemented sound sources^
if (g_soundSystem.IsPlaying(it->second))
g_soundSystem.Stop(it->second);
g_soundSystem.Play3D(it->second, pos.x, pos.y, pos.z, true);
}
void GameSoundSystem::CacheSound(const std::string& filename)
{
m_sounds.emplace(filename, g_soundSystem.LoadSound(filename.c_str()));
@@ -82,6 +105,11 @@ void enginePlaySound(const char* filename)
GameSoundSystem::GetInstance().PlaySound2D(filename);
}
void enginePlaySound3D(const char* filename, float x, float y, float z)
{
GameSoundSystem::GetInstance().PlaySound3D(filename, glm::vec3(x, y, z));
}
LuaPlus::LuaObject engineCreateEntity(const char* classname)
{
Entity* entity = static_cast<Entity*>(g_game->Lua_CreateEntity(classname));
@@ -157,6 +185,7 @@ void registerEngine()
engineTable.RegisterDirect("add_entity_to_world", &engineAddEntityToWorld);
engineTable.RegisterDirect("get_entity_from_id", &engineGetEntityFromID);
engineTable.RegisterDirect("play_sound", &enginePlaySound);
engineTable.RegisterDirect("play_sound_3d", &enginePlaySound3D);
engineTable.RegisterDirect("get_delta", &engineGetDelta);
engineTable.RegisterDirect("trace_ray", &engineTraceRay);
@@ -231,6 +260,20 @@ void registerInput()
inputTable.RegisterDirect("get_lock_mouse", &inputGetLock);
}
void toggleNoclip()
{
static bool s_noclip = false;
s_noclip = !s_noclip;
LuaPlus::LuaObject player = GetLuaState().GetGlobal("g_player");
if (player.IsTable())
{
ActorBase* actor = (ActorBase*)player["__object"].GetLightUserdata();
actor->SetNoclip(s_noclip);
}
}
int cameraGetPos(LuaPlus::LuaState* state)
{
glm::vec3 v = glm::vec3(0.0f);
@@ -494,6 +537,16 @@ void Game::LoadLevelXML(const char* mapname)
entity->LoadModel(filename);
}
pugi::xml_node animation = entitynode.child("Animation");
if (animation)
{
const char* name = animation.attribute("name").as_string();
int mode = animation.attribute("mode").as_int();
SkeletonInstance* skeleton = entity->GetSkeletonInstance();
if (skeleton)
skeleton->PlayAnimation(skeleton->FindAnimation(name), mode);
}
pugi::xml_node physics = entitynode.child("Physics");
if (physics)
{
@@ -502,6 +555,10 @@ void Game::LoadLevelXML(const char* mapname)
entity->CreateTestBody();
}
Light* light = dynamic_cast<Light*>(entity); // BAD!!!
if (light)
light->InitFromXML(entitynode);
entity->Init();
//IEntityBase* entity = g_entityManager->CreateEntity(classname.as_string());

View File

@@ -23,8 +23,9 @@ public:
extern Game* g_game;
void registerCamera();
void registerInput();
void toggleNoclip();
#endif
void registerCamera();
void registerInput();

View File

@@ -134,6 +134,11 @@ bool Entity::GetVisible()
return true;
}
SkeletonInstance* Entity::GetSkeletonInstance()
{
return m_skeleton;
}
void Entity::UpdateSkeleton(float dt)
{
if (m_model && m_skeleton)

View File

@@ -77,6 +77,7 @@ public:
void SetVisible(bool visible);
bool GetVisible();
SkeletonInstance* GetSkeletonInstance();
void UpdateSkeleton(float dt);
void Init();

View File

@@ -0,0 +1,51 @@
#include "core.h"
#include "game_world_objects.h"
#include "debugrender.h"
#include "scenemanager.h" // BAD!
bool g_debugDrawLights = false;
REGISTER_ENTITY(Light);
Light::Light()
{
m_dlight = nullptr;
}
Light::~Light()
{
}
void Light::Render()
{
if (!m_dlight)
return;
m_dlight->position = m_position;
if (g_debugDrawLights)
{
g_debugRender->DrawSphere(m_dlight->position, m_dlight->radius, m_dlight->color);
}
}
void Light::InitFromXML(const pugi::xml_node& node)
{
m_dlight = DLightManager::GetInstance()->AllocLight();
SDL_assert_always(m_dlight);
m_dlight->position = m_position;
pugi::xml_node color = node.child("Color");
if (color)
{
m_dlight->color.r = color.attribute("r").as_float();
m_dlight->color.g = color.attribute("g").as_float();
m_dlight->color.b = color.attribute("b").as_float();
}
pugi::xml_node radius = node.child("Radius");
if (radius)
{
m_dlight->radius = radius.attribute("value").as_float();
}
}

View File

@@ -0,0 +1,26 @@
#ifndef GAME_WORLD_OBJECTS_H
#define GAME_WORLD_OBJECTS_H
#include <pugixml.hpp>
#include "game_object.h"
struct DLight;
// #TODO: Inheritance from Entity is needed for expose to lua, but did
// light need to have a animation stuff?
class Light : public Entity
{
public:
Light();
~Light();
void Render() override;
void InitFromXML(const pugi::xml_node& node);
private:
DLight* m_dlight;
};
#endif // !GAME_WORLD_OBJECTS_H

View File

@@ -95,6 +95,51 @@ void DebugRender::DrawBoundingBox(const BoundingBox& box, const glm::vec3& color
DrawLine(p5, p7, color);
}
void DebugRender::DrawSphere(const glm::vec3& origin, float radius, const glm::vec3& color)
{
#ifndef M_PI
#define M_PI 3.14159265358979323846 // pi
#endif // !M_PI
const int kSegments = 16;
const float kStep = 2.0f * M_PI / (float)kSegments;
#undef M_PI
// XY
for (int i = 0; i < kSegments; i++)
{
float theta = i * kStep;
float theta2 = (i + 1) * kStep;
glm::vec3 p1 = origin + glm::vec3(cos(theta) * radius, sin(theta) * radius, 0.0f);
glm::vec3 p2 = origin + glm::vec3(cos(theta2) * radius, sin(theta2) * radius, 0.0f);
DrawLine(p1, p2, color);
}
// XZ
for (int i = 0; i < kSegments; i++)
{
float theta = i * kStep;
float theta2 = (i + 1) * kStep;
glm::vec3 p1 = origin + glm::vec3(cos(theta) * radius, 0.0f, sin(theta) * radius);
glm::vec3 p2 = origin + glm::vec3(cos(theta2) * radius, 0.0f, sin(theta2) * radius);
DrawLine(p1, p2, color);
}
// YZ
for (int i = 0; i < kSegments; i++)
{
float theta = i * kStep;
float theta2 = (i + 1) * kStep;
glm::vec3 p1 = origin + glm::vec3(0.0f, cos(theta) * radius, sin(theta) * radius);
glm::vec3 p2 = origin + glm::vec3(0.0f, cos(theta2) * radius, sin(theta2) * radius);
DrawLine(p1, p2, color);
}
}
void DebugRender::RenderFrame()
{
if (!g_drawDebug)

View File

@@ -23,6 +23,7 @@ public:
void DrawAxis(const glm::vec3& vec);
void DrawLine(const glm::vec3& from, const glm::vec3& to, const glm::vec3& color);
void DrawBoundingBox(const BoundingBox& box, const glm::vec3& color);
void DrawSphere(const glm::vec3& origin, float radius, const glm::vec3& color);
void RenderFrame();

View File

@@ -14,9 +14,13 @@
#include "texturesmanager.h"
#include "iqm.h"
#include "debugrender.h"
#include "scenemanager.h"
#include "camera.h"
extern Shader* g_unlitShader;
extern Shader* g_unlitSkinnedShader;
extern Shader* g_litShader;
extern Shader* g_litSkinnedShader;
static std::string getFileNameWithoutExtension(const std::string& filename)
{
@@ -285,7 +289,7 @@ void Model::LoadIqm(const char* filename)
//mesh.m_indices = indices;
mesh.vb = g_renderDevice->CreateVertexBuffer(vertices.data(), pMesh->num_vertexes * sizeof(SkinnedMeshVertex), true);
mesh.vbcount = pMesh->num_vertexes;
mesh.ib = g_renderDevice->CreateIndexBuffer(indices.data(), pMesh->num_triangles * sizeof(iqmtriangle), false);
mesh.ib = g_renderDevice->CreateIndexBuffer(indices.data(), pMesh->num_triangles * 3 * sizeof(uint), false);
mesh.ibcount = pMesh->num_triangles * 3;
@@ -611,8 +615,28 @@ void Model::Draw(const glm::mat4& model, SkeletonInstance* instance /*= nullptr*
{
SDL_assert(g_unlitShader);
glm::vec3 pos = model[3];
Shader* shader = instance ? g_unlitSkinnedShader : g_unlitShader;
DLight* light = nullptr;
float lastDistSq = FLT_MAX;
for (int i = 0; i < DLightManager::GetInstance()->GetNumLights(); i++)
{
float distSq = glm::length2(pos - DLightManager::GetInstance()->GetDLight(i)->position );
if (distSq <= lastDistSq)
{
lastDistSq = distSq;
light = DLightManager::GetInstance()->GetDLight(i);
}
}
if (light)
shader = instance ? g_litSkinnedShader : g_litShader;
for (int i = 0; i < m_meshes.size(); i++)
{
ModelData_t& m_data = m_meshes[i];
@@ -624,23 +648,7 @@ void Model::Draw(const glm::mat4& model, SkeletonInstance* instance /*= nullptr*
g_renderDevice->SetDepthTest(true);
g_renderDevice->SetDepthWrite(true);
bool isTransparent = false;
if (isTransparent)
{
// Enable blending
g_renderDevice->SetBlending(true);
g_renderDevice->SetBlendingFunction(BF_SRC_ALPHA, BF_ONE_MINUS_SRC_ALPHA);
glm::vec4 color = glm::vec4(1.f, 1.f, 1.f, .5f);
g_shaderSystem->SetUniformFloat4(shader, UNIFORM_CUSTOM_COLOR, glm::value_ptr(color));
}
else
{
g_renderDevice->SetBlending(false);
//glm::vec4 color = glm::vec4(1.f, 1.f, 1.f, 1.f);
//g_shaderSystem->SetUniformFloat4(shader, UNIFORM_CUSTOM_COLOR, glm::value_ptr(color));
}
g_renderDevice->SetBlending(false);
g_renderDevice->SetVerticesBuffer(m_data.vb);
if (m_data.ib)
@@ -657,6 +665,37 @@ void Model::Draw(const glm::mat4& model, SkeletonInstance* instance /*= nullptr*
g_shaderSystem->SetUniformMatrix(shader, UNIFORM_MVP_MATRIX, &mvp[0]);
Camera* camera = g_cameraManager.GetActiveCamera();
if (camera && shader->HasUniform(UNIFORM_CAMERA_POS))
{
glm::vec4 campos = glm::vec4(camera->GetPosition(), 1.0f);
g_shaderSystem->SetUniformFloat4(shader, UNIFORM_CAMERA_POS, &campos);
}
if (shader->HasUniform(UNIFORM_SUN_DIRECTION))
{
glm::vec4 lightPos = glm::vec4(0.0f, 0.0f, 0.0f, 0.0f);
if (light)
lightPos = glm::vec4(light->position, light->radius);
g_shaderSystem->SetUniformFloat4(shader, UNIFORM_SUN_DIRECTION, &lightPos);
}
if (shader->HasUniform(UNIFORM_SUN_COLOR))
{
glm::vec4 lightColor = glm::vec4(0.0f, 0.0f, 0.0f, 0.0f);
if (light)
lightColor = glm::vec4(light->color, 1.0f);
g_shaderSystem->SetUniformFloat4(shader, UNIFORM_SUN_COLOR, &lightColor);
}
if (shader->HasUniform(UNIFORM_SUN_AMBIENT))
{
glm::vec4 lightColor = glm::vec4(0.1f);
g_shaderSystem->SetUniformFloat4(shader, UNIFORM_SUN_AMBIENT, &lightColor);
}
if (!m_data.m_AlbedoTexture)
m_data.m_AlbedoTexture = g_texturesManager->LoadTexture2D("MustBeEvilHackButDontCare");

View File

@@ -64,6 +64,11 @@ void ModelSystem::Init()
// Load unlighted skinned model generic shader
g_unlitSkinnedShader = g_shaderSystem->CreateShader("unlit_generic_skin", "data/shaders/unlit_generic_skin.vs", "data/shaders/unlit_generic.ps",
g_skinnedVertexLayout, sizeof(g_skinnedVertexLayout) / sizeof(g_skinnedVertexLayout[0]));
// Load lighted skinned model generic shader
g_litSkinnedShader = g_shaderSystem->CreateShader("lit_generic_skin", "data/shaders/lit_generic_skin.vs", "data/shaders/lit_generic.ps",
g_skinnedVertexLayout, sizeof(g_skinnedVertexLayout) / sizeof(g_skinnedVertexLayout[0]));
}
void ModelSystem::Shutdown()

View File

@@ -67,7 +67,7 @@ void APIENTRY GL_DebugOutput(GLenum source,
if (type == GL_DEBUG_TYPE_ERROR_ARB)
{
bool debug = true;
__debugbreak();
//__debugbreak();
}
}
@@ -78,7 +78,7 @@ Render::Render() :
m_pGLContext(nullptr),
m_pStretchedPicVBuf(nullptr),
m_usingVAO(false),
m_showStats(true)
m_showStats(false)
{
m_viewMatrix = glm::identity<glm::mat4>();
m_projectionMatrix = glm::identity<glm::mat4>();
@@ -310,6 +310,13 @@ void Render::RenderStats()
snprintf(buffer, sizeof(buffer), "numModels: %d", g_NumModels);
ImGui::GetForegroundDrawList()->AddText(ImVec2(0.0f, 30.0f), 0xffffffff, buffer);
Camera* camera = g_cameraManager.GetActiveCamera();
if (camera)
{
snprintf(buffer, sizeof(buffer), "cam pos: %.2f %.2f %.2f", camera->GetPosition().x, camera->GetPosition().y, camera->GetPosition().z);
ImGui::GetForegroundDrawList()->AddText(ImVec2(0.0f, 45.0f), 0xffffffff, buffer);
}
}
void Render::Present(bool vsync)
@@ -319,6 +326,8 @@ void Render::Present(bool vsync)
SDL_GL_SwapWindow(m_pWindow);
// reset stats
ResetStates();
g_NumModels = 0;
}

View File

@@ -250,4 +250,11 @@ struct SkinnedMeshVertex
glm::vec4 weights;
};
struct DLight
{
glm::vec3 position;
glm::vec3 color;
float radius;
};
#endif

View File

@@ -205,6 +205,8 @@ SceneManager* g_sceneManager;
SceneManager::SceneManager()
{
m_sceneLoaded = false;
DLightManager::GetInstance()->Clear();
}
SceneManager::~SceneManager()
@@ -214,6 +216,8 @@ SceneManager::~SceneManager()
void SceneManager::loadScene(const char* filename)
{
unloadIfScenePresent();
char filenameBuffer[kMaxPathLength];
snprintf(filenameBuffer, kMaxPathLength, "data/levels/%s/%s.xml", filename, filename);
@@ -478,6 +482,8 @@ void SceneManager::unloadScene()
m_sceneMeshes.clear();
DLightManager::GetInstance()->Clear();
m_sceneLoaded = false;
}
@@ -777,7 +783,14 @@ void SceneStaticMesh::LoadMtl(const char* filename)
char stupidBuffer[1000];
fgets(stupidBuffer, 1000, file);
const char* textureFilename = stupidBuffer + 1;
char* textureFilename = stupidBuffer + 1;
int str_len = strlen(textureFilename);
if (textureFilename[str_len - 1] == '\n')
textureFilename[str_len - 1] = '\0';
m_albedoTexture = g_texturesManager->LoadTexture2D(textureFilename, true);
}
@@ -799,7 +812,7 @@ void SceneStaticMesh::LoadMtl(const char* filename)
static glm::mat4 s_identity = glm::mat4(1.0f);
void R_SceneStaticMesh_BindShader(const glm::mat4& worldMatrix, Texture2D* albedoTexture)
void R_SceneStaticMesh_BindShader(const glm::mat4& worldMatrix, Texture2D* albedoTexture, DLight* light)
{
extern Shader* g_unlitShader;
extern Shader* g_litShader;
@@ -807,7 +820,7 @@ void R_SceneStaticMesh_BindShader(const glm::mat4& worldMatrix, Texture2D* albed
SDL_assert(g_unlitShader);
SDL_assert(g_litShader);
Shader* shader = g_litShader;
Shader* shader = light ? g_litShader : g_unlitShader;
g_shaderSystem->SetShader(shader);
@@ -825,17 +838,22 @@ void R_SceneStaticMesh_BindShader(const glm::mat4& worldMatrix, Texture2D* albed
if (shader->HasUniform(UNIFORM_SUN_DIRECTION))
{
glm::vec4 lightPos = glm::vec4(1.0f, 1.0f, 1.0f, 0.0f);
// g_debugRender->DrawAxis(glm::vec3(lightPos));
Camera* camera = g_cameraManager.GetActiveCamera();
if (camera)
lightPos = glm::vec4(camera->GetPosition(), 1.0f);
glm::vec4 lightPos = glm::vec4(0.0f, 0.0f, 0.0f, 0.0f);
if (light)
lightPos = glm::vec4(light->position, light->radius);
g_shaderSystem->SetUniformFloat4(shader, UNIFORM_SUN_DIRECTION, &lightPos);
}
if (shader->HasUniform(UNIFORM_SUN_COLOR))
{
glm::vec4 lightColor = glm::vec4(0.0f, 0.0f, 0.0f, 0.0f);
if (light)
lightColor = glm::vec4(light->color, 1.0f);
g_shaderSystem->SetUniformFloat4(shader, UNIFORM_SUN_COLOR, &lightColor);
}
if (shader->HasUniform(UNIFORM_SUN_AMBIENT))
{
glm::vec4 lightColor = glm::vec4(0.1f);
@@ -854,14 +872,149 @@ void SceneStaticMesh::RenderObjects()
g_renderDevice->SetCullFace(true);
g_renderDevice->SetDepthTest(true);
g_renderDevice->SetDepthWrite(true);
g_renderDevice->SetBlending(false);
g_renderDevice->SetVerticesBuffer(m_vb);
int numlights = DLightManager::GetInstance()->GetNumLights();
if (!numlights)
{
g_renderDevice->SetVerticesBuffer(m_vb);
R_SceneStaticMesh_BindShader(s_identity, m_albedoTexture);
R_SceneStaticMesh_BindShader(s_identity, m_albedoTexture, nullptr);
g_renderDevice->DrawArrays(PT_TRIANGLES, 0, m_vbcount);
g_renderDevice->DrawArrays(PT_TRIANGLES, 0, m_vbcount);
g_NumModels++;
g_NumModels++;
}
else
{
// first pass
g_renderDevice->SetVerticesBuffer(m_vb);
R_SceneStaticMesh_BindShader(s_identity, m_albedoTexture, DLightManager::GetInstance()->GetDLight(0));
g_renderDevice->DrawArrays(PT_TRIANGLES, 0, m_vbcount);
g_NumModels++; // overdraw YAAAY
if (numlights > 1)
{
// fragment passed, can turn off depth write
g_renderDevice->SetDepthWrite(false);
// testing only written fragments
glDepthFunc(GL_EQUAL);
// additive blending
g_renderDevice->SetBlending(true);
g_renderDevice->SetBlendingFunction(BF_ONE, BF_ONE);
glBlendFunc(GL_ONE, GL_ONE);
for (int i = 1; i < numlights; i++)
{
g_renderDevice->SetVerticesBuffer(m_vb);
R_SceneStaticMesh_BindShader(s_identity, m_albedoTexture, DLightManager::GetInstance()->GetDLight(i));
g_renderDevice->DrawArrays(PT_TRIANGLES, 0, m_vbcount);
g_NumModels++; // overdraw YAAAY
}
g_renderDevice->SetBlending(false);
glDepthFunc(GL_LESS);
}
}
}
DLightManager* DLightManager::GetInstance()
{
static DLightManager instance;
return &instance;
}
DLight* DLightManager::AllocLight()
{
return &m_dlights[m_numdlights++];
}
void DLightManager::Clear()
{
memset(m_dlights, 0, sizeof(m_dlights));
m_numdlights = 0;
}
DLight* DLightManager::GetDLight(int index)
{
if (index >= m_numdlights)
Core::Error("DLightManager::GetDLight: index is out of range");
return &m_dlights[index];
}
int DLightManager::GetNumLights()
{
return m_numdlights;
}
//void R_SceneStaticMesh_BindShader(const glm::mat4& worldMatrix, Texture2D* albedoTexture)
//{
// extern Shader* g_unlitShader;
// extern Shader* g_litShader;
//
// SDL_assert(g_unlitShader);
// SDL_assert(g_litShader);
//
// Shader* shader = g_litShader;
//
// g_shaderSystem->SetShader(shader);
//
// g_shaderSystem->SetUniformMatrix(shader, UNIFORM_MODEL_MATRIX, &worldMatrix[0]);
//
// glm::mat4 mvp = g_render->GetProjectionMatrix() * g_render->GetViewMatrix() * worldMatrix;
// g_shaderSystem->SetUniformMatrix(shader, UNIFORM_MVP_MATRIX, &mvp[0]);
//
// Camera* camera = g_cameraManager.GetActiveCamera();
// if (camera && shader->HasUniform(UNIFORM_CAMERA_POS))
// {
// glm::vec4 campos = glm::vec4(camera->GetPosition(), 1.0f);
// g_shaderSystem->SetUniformFloat4(shader, UNIFORM_CAMERA_POS, &campos);
// }
//
// if (shader->HasUniform(UNIFORM_SUN_DIRECTION))
// {
// glm::vec4 lightPos = glm::vec4(1.0f, 1.0f, 1.0f, 0.0f);
//
// // g_debugRender->DrawAxis(glm::vec3(lightPos));
//
// Camera* camera = g_cameraManager.GetActiveCamera();
// if (camera)
// lightPos = glm::vec4(camera->GetPosition(), 1.0f);
//
// g_shaderSystem->SetUniformFloat4(shader, UNIFORM_SUN_DIRECTION, &lightPos);
// }
//
// if (shader->HasUniform(UNIFORM_SUN_AMBIENT))
// {
// glm::vec4 lightColor = glm::vec4(0.1f);
// g_shaderSystem->SetUniformFloat4(shader, UNIFORM_SUN_AMBIENT, &lightColor);
// }
//
// g_texturesManager->SetTexture(0, albedoTexture);
// g_shaderSystem->SetUniformSampler(shader, SAMPLER_ALBEDO, 0);
//}
//
//void SceneStaticMesh::RenderObjects()
//{
// glFrontFace(GL_CCW);
// glDepthFunc(GL_LESS);
//
// g_renderDevice->SetCullFace(true);
// g_renderDevice->SetDepthTest(true);
// g_renderDevice->SetDepthWrite(true);
//
// g_renderDevice->SetBlending(false);
//
// g_renderDevice->SetVerticesBuffer(m_vb);
//
// R_SceneStaticMesh_BindShader(s_identity, m_albedoTexture);
//
// g_renderDevice->DrawArrays(PT_TRIANGLES, 0, m_vbcount);
//
// g_NumModels++;
//}

View File

@@ -31,6 +31,25 @@ private:
Texture2D* m_albedoTexture;
};
const int kMaxDLight = 1024;
class DLightManager
{
public:
static DLightManager* GetInstance();
public:
DLight* AllocLight();
void Clear();
DLight* GetDLight(int index);
int GetNumLights();
private:
DLight m_dlights[kMaxDLight];
int m_numdlights;
};
class SceneManager
{
public:

View File

@@ -39,6 +39,9 @@ void SoundSystem::Init()
ma_uint32 uiSampleRate = ma_engine_get_sample_rate(&m_engine);
Msg("Sound sampling rate: %d\n", uiSampleRate);
// Initialize listener
SetListenerPosition(0.0f, 0.0f, 0.0f);
m_inited = true;
}
@@ -91,6 +94,15 @@ void SoundSystem::Play(SoundHandle handle, bool bLoop)
ma_sound_set_looping(&m_sounds[handle], true);
}
void SoundSystem::Play3D(SoundHandle handle, float x, float y, float z, bool bLoop)
{
if ( !m_inited )
return;
Play(handle, bLoop);
ma_sound_set_position(&m_sounds[handle], x, y, z);
}
void SoundSystem::Stop(SoundHandle handle)
{
if ( !m_inited )
@@ -121,4 +133,20 @@ void SoundSystem::SetMasterVolume(float volume)
float SoundSystem::GetMasterVolume()
{
return ma_engine_get_volume(&m_engine);
}
}
void SoundSystem::SetListenerPosition(float _x, float _y, float _z)
{
if ( !m_inited )
return;
ma_engine_listener_set_position(&m_engine, 0, _x, _y, _z);
}
void SoundSystem::SetListenerDirection(float _x, float _y, float _z)
{
if ( !m_inited )
return;
ma_engine_listener_set_direction(&m_engine, 0, _x, _y, _z);
}

View File

@@ -19,6 +19,7 @@ public:
SoundHandle LoadSound(const char* filename);
void Play(SoundHandle handle, bool bLoop);
void Play3D(SoundHandle handle, float x, float y, float z, bool bLoop);
void Stop(SoundHandle handle);
bool IsPlaying(SoundHandle handle);
@@ -26,6 +27,9 @@ public:
void SetMasterVolume(float volume);
float GetMasterVolume();
void SetListenerPosition(float _x, float _y, float _z);
void SetListenerDirection(float _x, float _y, float _z);
private:
ma_sound m_sounds[MAX_SOUNDS];
ma_engine m_engine;