pretty all in there, except for points counting:

- guns reloading
- randomized routes for aircraft
- added terrain
- added 3d sounds for flyby
- beautified
This commit is contained in:
ottona 2018-11-15 15:37:22 +01:00
parent e67f92d413
commit 61d4b4fe39
15 changed files with 434585 additions and 636919 deletions

View File

@ -1,73 +1,8 @@
# Blender MTL File: 'SU35S.blend' # Blender MTL File: 'None'
# Material Count: 36 # Material Count: 25
newmtl Gum
Ns 23.529412
Ka 1.000000 1.000000 1.000000
Kd 0.015136 0.015136 0.015136
Ks 0.021014 0.021014 0.021014
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Killermachine01
Ns 92.156863
Ka 1.000000 1.000000 1.000000
Kd 0.512000 0.512000 0.512000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd C:/Users/Psychedelic/Desktop/FGear.png
newmtl Killermachine01_NONE
Ns 92.156863
Ka 1.000000 1.000000 1.000000
Kd 0.512000 0.512000 0.512000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd C:/Users/Psychedelic/Desktop/FGear.png
newmtl KillermachineSu
Ns 92.156863
Ka 1.000000 1.000000 1.000000
Kd 0.512000 0.512000 0.512000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd C:/Users/Psychedelic/Desktop/FGear.png
newmtl Material_#145
Ns 92.156863
Ka 1.000000 1.000000 1.000000
Kd 0.512000 0.512000 0.512000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd C:/Users/Psychedelic/Desktop/FGear.png
newmtl Steel
Ns 190.196078
Ka 0.200000 0.200000 0.200000
Kd 0.088054 0.088054 0.088054
Ks 0.250000 0.250000 0.250000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 3
map_Kd C:/Users/Psychedelic/Desktop/FGear.png
newmtl capony newmtl capony
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000 Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -79,7 +14,7 @@ map_Kd C:/Users/Psychedelic/Desktop/Tex_23119_0.png
map_Ks C:/Users/Psychedelic/Desktop/Tex_23119_0.png map_Ks C:/Users/Psychedelic/Desktop/Tex_23119_0.png
newmtl fuse_back newmtl fuse_back
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.510968 0.510968 0.510968 Kd 0.510968 0.510968 0.510968
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -87,20 +22,8 @@ Ke 0.000000 0.000000 0.000000
Ni 1.000000 Ni 1.000000
d 1.000000 d 1.000000
illum 2 illum 2
map_Kd C:/Users/Psychedelic/Archive/Blender/Air Force (2013) by Teschmacher/Su27_tex02_2013.bmp.png map_Kd Teschmacher/Su27_tex02_2013.bmp.png
map_Ks C:/Users/Psychedelic/Archive/Blender/Air Force (2013) by Teschmacher/Su27_tex02_2013.bmp.png map_Ks Teschmacher/Su27_tex02_2013.bmp.png
newmtl fuse_back_NONE
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.510968 0.510968 0.510968
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd C:/Users/Psychedelic/Archive/Blender/Air Force (2013) by Teschmacher/Su27_tex02_2013.bmp.png
map_Ks C:/Users/Psychedelic/Archive/Blender/Air Force (2013) by Teschmacher/Su27_tex02_2013.bmp.png
newmtl glass newmtl glass
Ns 978.431373 Ns 978.431373
@ -114,7 +37,7 @@ illum 2
refl C:/Users/Psychedelic/Desktop/Raptor/cloud2.png refl C:/Users/Psychedelic/Desktop/Raptor/cloud2.png
newmtl glass1 newmtl glass1
Ns 939.215686 Ns 937.254902
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.039217 0.045141 0.053445 Kd 0.039217 0.045141 0.053445
Ks 1.000000 1.000000 1.000000 Ks 1.000000 1.000000 1.000000
@ -136,30 +59,8 @@ illum 2
map_Kd C:/Users/Psychedelic/Desktop/Raptor/cloud2.png map_Kd C:/Users/Psychedelic/Desktop/Raptor/cloud2.png
refl C:/Users/Psychedelic/Desktop/Raptor/cloud2.png refl C:/Users/Psychedelic/Desktop/Raptor/cloud2.png
newmtl gum
Ns 17.647059
Ka 1.000000 1.000000 1.000000
Kd 0.021768 0.021768 0.021768
Ks 0.008694 0.008694 0.008694
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd C:/Users/Psychedelic/Archive/Blender/Air Force (2013) by Teschmacher/Su27_tex02_2013.bmp.png
newmtl gum_NONE
Ns 17.647059
Ka 1.000000 1.000000 1.000000
Kd 0.021768 0.021768 0.021768
Ks 0.008694 0.008694 0.008694
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd C:/Users/Psychedelic/Archive/Blender/Air Force (2013) by Teschmacher/Su27_tex02_2013.bmp.png
newmtl keel_stab newmtl keel_stab
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000 Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -167,11 +68,11 @@ Ke 0.000000 0.000000 0.000000
Ni 1.000000 Ni 1.000000
d 1.000000 d 1.000000
illum 2 illum 2
map_Kd C:/Users/Psychedelic/Archive/Blender/Air Force (2013) by Teschmacher/Su27_tex06_2013.bmp.png map_Kd Teschmacher/Su27_tex06_2013.bmp.png
map_Ks C:/Users/Psychedelic/Archive/Blender/Air Force (2013) by Teschmacher/Su27_tex06_2013.bmp.png map_Ks Teschmacher/Su27_tex06_2013.bmp.png
newmtl kreslo newmtl kreslo
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000 Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -183,7 +84,7 @@ map_Kd C:/Users/Psychedelic/Archive/Blender/PNG/su-27_k36.bmp.png
map_Ks C:/Users/Psychedelic/Archive/Blender/PNG/su-27_k36.bmp.png map_Ks C:/Users/Psychedelic/Archive/Blender/PNG/su-27_k36.bmp.png
newmtl lamp newmtl lamp
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000 Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -205,7 +106,7 @@ d 0.700000
illum 2 illum 2
newmtl misc newmtl misc
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000 Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -217,7 +118,7 @@ map_Kd C:/Users/Psychedelic/Desktop/Flanker-E/PNG/su27_tex07.bmp.png
map_Ks C:/Users/Psychedelic/Desktop/Flanker-E/PNG/su27_tex07.bmp.png map_Ks C:/Users/Psychedelic/Desktop/Flanker-E/PNG/su27_tex07.bmp.png
newmtl nose newmtl nose
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.242558 0.242558 0.242558 Kd 0.242558 0.242558 0.242558
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -229,7 +130,7 @@ map_Kd C:/Users/Psychedelic/Desktop/Flanker-E/PNG/su27_tex07.bmp.png
map_Ks C:/Users/Psychedelic/Desktop/Flanker-E/PNG/su27_tex07.bmp.png map_Ks C:/Users/Psychedelic/Desktop/Flanker-E/PNG/su27_tex07.bmp.png
newmtl nose1 newmtl nose1
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.510968 0.510968 0.510968 Kd 0.510968 0.510968 0.510968
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -241,7 +142,7 @@ map_Kd C:/Users/Psychedelic/Desktop/Su33_tex01.bmp.png
map_Ks C:/Users/Psychedelic/Desktop/Su33_tex01.bmp.png map_Ks C:/Users/Psychedelic/Desktop/Su33_tex01.bmp.png
newmtl nose1_1 newmtl nose1_1
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.513600 0.513600 0.513600 Kd 0.513600 0.513600 0.513600
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -249,11 +150,11 @@ Ke 0.000000 0.000000 0.000000
Ni 1.000000 Ni 1.000000
d 1.000000 d 1.000000
illum 2 illum 2
map_Kd /tmp/Air Force (2013) by Teschmacher/Originals/Su27_tex01_2013.bmp.png map_Kd Teschmacher/Originals/Su27_tex01_2013.bmp.png
map_Ks /tmp/Air Force (2013) by Teschmacher/Originals/Su27_tex01_2013.bmp.png map_Ks Teschmacher/Originals/Su27_tex01_2013.bmp.png
newmtl numberL newmtl numberL
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.510968 0.510968 0.510968 Kd 0.510968 0.510968 0.510968
Ks 0.000000 0.000000 0.000000 Ks 0.000000 0.000000 0.000000
@ -265,7 +166,7 @@ map_Kd C:/Users/Psychedelic/Archive/Blender/PNG/Su-27_numbers_red.png
map_d C:/Users/Psychedelic/Archive/Blender/PNG/Su-27_numbers_red.png map_d C:/Users/Psychedelic/Archive/Blender/PNG/Su-27_numbers_red.png
newmtl numberR newmtl numberR
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.510968 0.510968 0.510968 Kd 0.510968 0.510968 0.510968
Ks 0.000000 0.000000 0.000000 Ks 0.000000 0.000000 0.000000
@ -278,7 +179,7 @@ map_Ka C:/Users/Psychedelic/Archive/Blender/PNG/Su-27_numbers_red.png
map_d C:/Users/Psychedelic/Archive/Blender/PNG/Su-27_numbers_red.png map_d C:/Users/Psychedelic/Archive/Blender/PNG/Su-27_numbers_red.png
newmtl pilon newmtl pilon
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.515325 0.515325 0.515325 Kd 0.515325 0.515325 0.515325
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -290,7 +191,7 @@ map_Kd C:/Users/Psychedelic/Archive/Blender/PNG/su27_pylon.bmp.png
map_Ks C:/Users/Psychedelic/Archive/Blender/PNG/su27_pylon.bmp.png map_Ks C:/Users/Psychedelic/Archive/Blender/PNG/su27_pylon.bmp.png
newmtl pilon2 newmtl pilon2
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000 Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -302,7 +203,7 @@ map_Kd C:/Users/Psychedelic/Archive/Blender/PNG/Su27_pylon2.png
map_Ks C:/Users/Psychedelic/Archive/Blender/PNG/Su27_pylon2.png map_Ks C:/Users/Psychedelic/Archive/Blender/PNG/Su27_pylon2.png
newmtl pilot newmtl pilot
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000 Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -339,7 +240,7 @@ map_Ka C:/Users/Psychedelic/Desktop/Flanker-E/PNG/Tex_3306_0.png
map_Ks C:/Users/Psychedelic/Desktop/Flanker-E/PNG/Tex_3306_0.png map_Ks C:/Users/Psychedelic/Desktop/Flanker-E/PNG/Tex_3306_0.png
newmtl sopla newmtl sopla
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.515325 0.515325 0.515325 Kd 0.515325 0.515325 0.515325
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -354,7 +255,7 @@ map_Ks C:/Users/Psychedelic/Archive/Blender/PNG/Su-27_detail.png
map_d C:/Users/Psychedelic/Desktop/Flanker-E/PNG/Su-27_detail_nrm.tif map_d C:/Users/Psychedelic/Desktop/Flanker-E/PNG/Su-27_detail_nrm.tif
newmtl vozduh newmtl vozduh
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.513684 0.513684 0.513684 Kd 0.513684 0.513684 0.513684
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -362,35 +263,11 @@ Ke 0.000000 0.000000 0.000000
Ni 1.000000 Ni 1.000000
d 1.000000 d 1.000000
illum 2 illum 2
map_Kd C:/Users/Psychedelic/Desktop/Air Force (2013) by Teschmacher/Su27_tex05_2013.bmp.png map_Kd Teschmacher/Su27_tex05_2013.bmp.png
map_Ks C:/Users/Psychedelic/Desktop/Air Force (2013) by Teschmacher/Su27_tex05_2013.bmp.png map_Ks Teschmacher/Su27_tex05_2013.bmp.png
newmtl wing_R
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.513684 0.513684 0.513684
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd C:/Users/Psychedelic/Desktop/Flanker-E/Air Force (2013) by Teschmacher/Su27_tex03_2013.bmp.png
map_Ks C:/Users/Psychedelic/Desktop/Flanker-E/Air Force (2013) by Teschmacher/Su27_tex03_2013.bmp.png
newmtl wing_R_FGear.png
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.513684 0.513684 0.513684
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd C:/Users/Psychedelic/Desktop/FGear.png
map_Ks C:/Users/Psychedelic/Desktop/Flanker-E/Air Force (2013) by Teschmacher/Su27_tex03_2013.bmp.png
newmtl wing_R_Su27_tex03_2013.bmp.png newmtl wing_R_Su27_tex03_2013.bmp.png
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.513684 0.513684 0.513684 Kd 0.513684 0.513684 0.513684
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -398,11 +275,11 @@ Ke 0.000000 0.000000 0.000000
Ni 1.000000 Ni 1.000000
d 1.000000 d 1.000000
illum 2 illum 2
map_Kd C:/Users/Psychedelic/Desktop/Flanker-E/Air Force (2013) by Teschmacher/Su27_tex03_2013.bmp.png map_Kd Teschmacher/Su27_tex03_2013.bmp.png
map_Ks C:/Users/Psychedelic/Desktop/Flanker-E/Air Force (2013) by Teschmacher/Su27_tex03_2013.bmp.png map_Ks Teschmacher/Su27_tex03_2013.bmp.png
newmtl wing_l newmtl wing_l
Ns 96.078431 Ns 94.117647
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000 Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
@ -410,8 +287,8 @@ Ke 0.000000 0.000000 0.000000
Ni 1.000000 Ni 1.000000
d 1.000000 d 1.000000
illum 2 illum 2
map_Kd C:/Users/Psychedelic/Desktop/Flanker-E/Air Force (2013) by Teschmacher/Su27_tex04_2013.bmp.png map_Kd Teschmacher/Su27_tex04_2013.bmp.png
map_Ks C:/Users/Psychedelic/Desktop/Flanker-E/Air Force (2013) by Teschmacher/Su27_tex04_2013.bmp.png map_Ks Teschmacher/Su27_tex04_2013.bmp.png
newmtl wing_r newmtl wing_r
Ns 92.156863 Ns 92.156863

1071130
res/SU35S.obj

File diff suppressed because it is too large Load Diff

BIN
res/detailmap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
res/fontlucida.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
res/heightmap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
res/heightmap2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -1,30 +1,39 @@
#include "Aircraft.hpp" #include "Aircraft.hpp"
#include <iostream> #include <iostream>
#include <cAudio/cAudio.h>
#include "Globals.hpp" #include "Globals.hpp"
using namespace irr; using namespace irr;
using namespace irr::core; using namespace irr::core;
Aircraft::Aircraft() Aircraft::Aircraft(const line3df &flightLine, u32 flightTimeMillis)
: flightDuration(flightTimeMillis)
, flightStarted(Globals::getDevice()->getTimer()->getRealTime())
{ {
model = Globals::getSceneManager()->addMeshSceneNode(Globals::getSceneManager()->getMesh("../res/SU35S.obj")); model = Globals::getSceneManager()->addMeshSceneNode(Globals::getSceneManager()->getMesh("../res/SU35S.obj"));
model->setPosition(vector3df(25.f, 0.f, 0.f)); model->setPosition(vector3df(25.f, 0.f, 0.f));
a = Globals::getSceneManager()->createFlyStraightAnimator(vector3df(100.f, 100.f, -1000.f), a = Globals::getSceneManager()->createFlyStraightAnimator(flightLine.start,
vector3df(100.f, 100.f, 1000.f), flightLine.end,
32000, flightTimeMillis,
false, false,
false); false);
auto dvec = (flightLine.end - flightLine.start).normalize();
f64 rotBy = vector2df(dvec.X, dvec.Z).getAngleTrig();
model->setRotation(vector3df(0.f, -rotBy, 0.f));
model->addAnimator(a); model->addAnimator(a);
std::cout << "Aircraft" << std::endl; flybySound = Globals::getAudioManager()->create("flybySound", "../res/flyby.wav", false);
//std::cout << "Aircraft from " << flightTimeMillis << ' ' << flightLine.start.Y << " to " << flightLine.end.X << ' ' << flightLine.end.Y << " at " << flightLine.start.Z << std::endl;
} }
Aircraft::~Aircraft() Aircraft::~Aircraft()
{ {
a->drop();
Globals::getSceneManager()->addToDeletionQueue(model); Globals::getSceneManager()->addToDeletionQueue(model);
std::cout << "~Aircraft" << std::endl; std::cout << "~Aircraft" << std::endl;
} }
@ -55,3 +64,25 @@ bool Aircraft::evalShot(const irr::core::line3df &shotline)
} }
return hit; return hit;
} }
void Aircraft::update(u32 curMS)
{
if (!flybySound->isPlaying())
{
u32 curTime = curMS;
curTime -= flightStarted;
if (curTime > flightDuration / 2 - 4000 && curTime < flightDuration / 2)
{
auto p = model->getAbsolutePosition();
flybySound->play3d(cAudio::cVector3(p.X, p.Y, p.Z));
//std::cout << "PLAY!" << std::endl;
// flybySound->play2d();
}
}
else
{
auto p = model->getAbsolutePosition();
flybySound->move(cAudio::cVector3(p.X, p.Y, p.Z));
}
}

View File

@ -1,18 +1,26 @@
#include <irrlicht.h> #include <irrlicht.h>
namespace cAudio
{
class IAudioSource;
}
class Aircraft class Aircraft
{ {
public: public:
Aircraft(); Aircraft(const irr::core::line3df &flightLine, irr::u32 flightTimeMillis);
~Aircraft(); ~Aircraft();
bool evalShot(const irr::core::line3df&); bool evalShot(const irr::core::line3df&);
bool isGood() const; bool isGood() const;
bool isTerminated() const; bool isTerminated() const;
void update(irr::u32 curMS);
private: private:
Aircraft();
irr::scene::IMeshSceneNode *model; irr::scene::IMeshSceneNode *model;
irr::scene::ISceneNodeAnimator *a; irr::scene::ISceneNodeAnimator *a;
bool healthy; bool healthy;
class cAudio::IAudioSource* flybySound;
irr::u32 flightDuration, flightStarted;
}; };

View File

@ -3,6 +3,7 @@
#include "Aircraft.hpp" #include "Aircraft.hpp"
using namespace irr; using namespace irr;
using namespace irr::core;
Dispatcher::Dispatcher() Dispatcher::Dispatcher()
: active(false) : active(false)
@ -27,15 +28,15 @@ void Dispatcher::execute()
if (active && (curTime - lastDispatchMS) > 10000) if (active && (curTime - lastDispatchMS) > 10000)
{ {
auto a = std::make_shared<Aircraft>(); dispatchAircraft();
aircrafts.push_back(a);
lastDispatchMS = curTime; lastDispatchMS = curTime;
} }
//cleanup // loopdidoo & cleanup
auto a = aircrafts.begin(); auto a = aircrafts.begin();
while (a < aircrafts.end()) while (a < aircrafts.end())
{ {
(*a)->update(curTime);
if ((*a)->isTerminated()) if ((*a)->isTerminated())
{ {
a = aircrafts.erase(a); a = aircrafts.erase(a);
@ -68,3 +69,24 @@ bool Dispatcher::evalShot(const core::line3df& l)
return ret; return ret;
} }
void Dispatcher::dispatchAircraft()
{
IRandomizer *rand = Globals::getDevice()->getRandomizer();
// rand dir vector around 0/0
vector2df dVec(1.f, 0.f);
dVec.rotateBy(rand->frand() * 360.f, vector2df(0.f, 0.f));
dVec.normalize();
vector2df nVec(dVec.Y, -dVec.X);
f32 d = rand->frand() * 500.f;
f32 alt = 50.f + rand->frand() * 500.f;
// start/end 2km off our pos, displaced by d * nVec to the side
vector2df start = dVec * -2000.f + nVec * d;
vector2df end = dVec * 2000.f + nVec * d;
line3df l;
l.start = vector3df(start.X, alt, start.Y);
l.end = vector3df(end.X, alt, end.Y);
aircrafts.push_back(std::make_shared<Aircraft>(l, 30000 + static_cast<u32>(rand->frand() * 30000.f)));
}

View File

@ -21,4 +21,5 @@ private:
Aircrafts aircrafts; Aircrafts aircrafts;
bool active; bool active;
void dispatchAircraft();
}; };

View File

@ -14,8 +14,10 @@ using namespace irr::core;
FireUnit::FireUnit() FireUnit::FireUnit()
: aziTurnCoeffSmooth(0.f) : aziTurnCoeffSmooth(0.f)
, elevTurnCoeffSmooth(0.f) , elevTurnCoeffSmooth(0.f)
, flashCount(0) , fireCount(0)
, fireBtnPressed(false) , fireBtnPressed(false)
, stripsRemaining(5)
, reloading(false)
{ {
turretAzimuth = Globals::getSceneManager()->addEmptySceneNode(); turretAzimuth = Globals::getSceneManager()->addEmptySceneNode();
turretElevation = Globals::getSceneManager()->addMeshSceneNode(Globals::getSceneManager()->getMesh("../res/guns.obj"), turretAzimuth); turretElevation = Globals::getSceneManager()->addMeshSceneNode(Globals::getSceneManager()->getMesh("../res/guns.obj"), turretAzimuth);
@ -71,19 +73,13 @@ bool FireUnit::OnEvent(const SEvent& e)
{ {
if (!fireBtnPressed) if (!fireBtnPressed)
{ {
shotline.start = cam->getAbsolutePosition(); if (!reloading && stripsRemaining > 0 && fireCount == 0)
shotline.end = cam->getTarget() - shotline.start; {
shotline.end.normalize(); fireSound->play2d();
shotline.end *= 4000.f; fireCount = 16;
fireSound->play2d(); stripsRemaining--;
/*vector3df lineEnd = cam->getTarget(); }
lineEnd.normalize();
lineEnd += 4000.f;
shotline.end = shotline.start + lineEnd;*/
Globals::getDispatcher()->evalShot(shotline);
fireBtnPressed = true; fireBtnPressed = true;
flashCount = 16;
} }
} }
else else
@ -93,7 +89,11 @@ bool FireUnit::OnEvent(const SEvent& e)
if (e.JoystickEvent.IsButtonPressed(2)) if (e.JoystickEvent.IsButtonPressed(2))
{ {
// sec trigger pressed if (!reloading)
{
reloadUntil = Globals::getDevice()->getTimer()->getRealTime() + 15000;
reloading = true;
}
} }
else else
{ {
@ -128,6 +128,16 @@ bool FireUnit::OnEvent(const SEvent& e)
return false; return false;
} }
u32 FireUnit::getRoundsRemaining() const
{
return stripsRemaining * 16 + fireCount;
}
bool FireUnit::isReloading() const
{
return reloading;
}
void FireUnit::draw() void FireUnit::draw()
{ {
@ -146,11 +156,17 @@ void FireUnit::draw()
matA.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; matA.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
drv->setMaterial(matA); drv->setMaterial(matA);
if (flashCount > 0) if (fireCount > 0)
{ {
mflashL->setVisible(flashCount % 4 == 2); shotline.start = cam->getAbsolutePosition();
mflashR->setVisible(flashCount % 4 == 0); shotline.end = cam->getTarget() - shotline.start;
flashCount--; shotline.end.normalize();
shotline.end *= 4000.f;
Globals::getDispatcher()->evalShot(shotline);
mflashL->setVisible(fireCount % 4 == 2);
mflashR->setVisible(fireCount % 4 == 0);
fireCount--;
} }
else else
{ {
@ -158,6 +174,14 @@ void FireUnit::draw()
mflashR->setVisible(false); mflashR->setVisible(false);
} }
if (reloading)
{
if (Globals::getDevice()->getTimer()->getRealTime() > reloadUntil)
{
reloading = false;
stripsRemaining = 5;
}
}
//drv->draw3DLine(shotline.start, shotline.end); //drv->draw3DLine(shotline.start, shotline.end);
//cout << tgt.X << ' ' << tgt.Y << ' ' << tgt.Z << endl; //cout << tgt.X << ' ' << tgt.Y << ' ' << tgt.Z << endl;
} }

View File

@ -15,6 +15,8 @@ public:
~FireUnit(); ~FireUnit();
bool OnEvent(const irr::SEvent&); bool OnEvent(const irr::SEvent&);
irr::u32 getRoundsRemaining() const;
bool isReloading() const;
void draw(); void draw();
private: private:
@ -26,8 +28,11 @@ private:
irr::core::line3df shotline; irr::core::line3df shotline;
irr::scene::IBillboardSceneNode *mflashL, *mflashR; irr::scene::IBillboardSceneNode *mflashL, *mflashR;
irr::u32 flashCount; irr::u32 fireCount;
bool fireBtnPressed; bool fireBtnPressed;
irr::u32 stripsRemaining;
bool reloading;
irr::u32 reloadUntil;
class cAudio::IAudioSource* fireSound; class cAudio::IAudioSource* fireSound;
}; };

View File

@ -24,6 +24,14 @@ FlaSimApp::FlaSimApp()
drv->getTexture("../res/sky0.jpg"), drv->getTexture("../res/sky0.jpg"),
drv->getTexture("../res/sky2.jpg") drv->getTexture("../res/sky2.jpg")
); );
auto t = sman->addTerrainSceneNode("../res/heightmap.png");
t->setScale(vector3df(1.f, .1f, 1.f));
auto move = t->getTerrainCenter();
move.Y += 10.f;
t->setPosition(-move);
t->setMaterialFlag(EMF_FOG_ENABLE, true);
t->setMaterialTexture(0, drv->getTexture("../res/detailmap.png"));
drv->setFog(video::SColor(0, 99, 122, 193), EFT_FOG_EXP, 100.f, 300.f);
scene::ILightSceneNode *sun = sman->addLightSceneNode(); scene::ILightSceneNode *sun = sman->addLightSceneNode();
sun->setLightType(ELT_DIRECTIONAL); sun->setLightType(ELT_DIRECTIONAL);
@ -96,4 +104,11 @@ void FlaSimApp::drawScreenSpace()
drv->draw3DLine(vector3df(0.f, 0.f, 0.f), vector3df(1.f, 0.f, 0.f), video::SColor(255, 255, 0, 0)); drv->draw3DLine(vector3df(0.f, 0.f, 0.f), vector3df(1.f, 0.f, 0.f), video::SColor(255, 255, 0, 0));
drv->draw3DLine(vector3df(0.f, 0.f, 0.f), vector3df(0.f, 1.f, 0.f), video::SColor(255, 0, 255, 0)); drv->draw3DLine(vector3df(0.f, 0.f, 0.f), vector3df(0.f, 1.f, 0.f), video::SColor(255, 0, 255, 0));
drv->draw3DLine(vector3df(0.f, 0.f, 0.f), vector3df(0.f, 0.f, 1.f), video::SColor(255, 0, 0, 255)); drv->draw3DLine(vector3df(0.f, 0.f, 0.f), vector3df(0.f, 0.f, 1.f), video::SColor(255, 0, 0, 255));
core::stringw info = L"RNDS REMAIN: ";
if (fireUnit.isReloading())
info += L"[RELOADING]";
else
info += fireUnit.getRoundsRemaining();
Globals::getFont()->draw(info, core::recti(10, 10, 100, 100), video::SColor(255, 255, 255, 255));
} }

View File

@ -15,6 +15,7 @@ Globals::Globals()
sman = dev->getSceneManager(); sman = dev->getSceneManager();
dispatcher = new Dispatcher(); dispatcher = new Dispatcher();
audioManager = cAudio::createAudioManager(true); audioManager = cAudio::createAudioManager(true);
font = dev->getGUIEnvironment()->getFont("../res/fontlucida.png");
} }
Globals::~Globals() Globals::~Globals()
@ -69,3 +70,11 @@ Dispatcher* Globals::getDispatcher()
return instance->dispatcher; return instance->dispatcher;
} }
gui::IGUIFont *Globals::getFont()
{
if (!instance)
instance = new Globals();
return instance->font;
}

View File

@ -18,6 +18,10 @@ namespace irr
{ {
class IVideoDriver; class IVideoDriver;
} }
namespace gui
{
class IGUIFont;
}
} }
@ -29,6 +33,7 @@ public:
static class irr::video::IVideoDriver* getVideoDriver(); static class irr::video::IVideoDriver* getVideoDriver();
static cAudio::IAudioManager* getAudioManager(); static cAudio::IAudioManager* getAudioManager();
static class Dispatcher* getDispatcher(); static class Dispatcher* getDispatcher();
static class irr::gui::IGUIFont *getFont();
static void shutdown(); static void shutdown();
@ -42,5 +47,6 @@ private:
class irr::video::IVideoDriver* drv; class irr::video::IVideoDriver* drv;
class cAudio::IAudioManager *audioManager; class cAudio::IAudioManager *audioManager;
class Dispatcher *dispatcher; class Dispatcher *dispatcher;
class irr::gui::IGUIFont *font;
}; };
#endif // GLOBALS_HPP #endif // GLOBALS_HPP