aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/extantz/CDemo.cpp904
-rw-r--r--src/extantz/CDemo.h65
-rw-r--r--src/extantz/camera.c251
3 files changed, 591 insertions, 629 deletions
diff --git a/src/extantz/CDemo.cpp b/src/extantz/CDemo.cpp
index 0ca40f1..7151b5f 100644
--- a/src/extantz/CDemo.cpp
+++ b/src/extantz/CDemo.cpp
@@ -6,505 +6,491 @@
6#include "extantzCamera.h" 6#include "extantzCamera.h"
7#include "CDemo.h" 7#include "CDemo.h"
8 8
9
10CDemo::CDemo(GLData *gld, bool a) 9CDemo::CDemo(GLData *gld, bool a)
11: additive(a), 10 : additive(a),
12 device(gld->device), 11 device(gld->device),
13 currentScene(0), 12 currentScene(0),
14 quakeLevelMesh(0), quakeLevelNode(0), skyboxNode(0), model1(0), model2(0), 13 quakeLevelMesh(0), quakeLevelNode(0), skyboxNode(0), model1(0), model2(0),
15 campFire(0), metaSelector(0), mapSelector(0), sceneStartTime(0), 14 campFire(0), metaSelector(0), mapSelector(0), sceneStartTime(0),
16 timeForThisScene(0) 15 timeForThisScene(0)
17{ 16{
18} 17}
19 18
20
21CDemo::~CDemo() 19CDemo::~CDemo()
22{ 20{
23 if (mapSelector) 21 if (mapSelector) mapSelector->drop();
24 mapSelector->drop(); 22 if (metaSelector) metaSelector->drop();
25
26 if (metaSelector)
27 metaSelector->drop();
28} 23}
29 24
30
31void CDemo::setup(GLData *gld) 25void CDemo::setup(GLData *gld)
32{ 26{
33 device = gld->device; 27 device = gld->device;
34 IrrlichtDevice *device = gld->device; 28 IrrlichtDevice *device = gld->device;
35// IVideoDriver *driver = gld->driver; 29// IVideoDriver *driver = gld->driver;
36// ISceneManager *smgr = gld->smgr; 30// ISceneManager *smgr = gld->smgr;
37 31
38 if (device->getFileSystem()->existFile("irrlicht.dat")) 32 if (device->getFileSystem()->existFile("irrlicht.dat")) device->getFileSystem()->addFileArchive("irrlicht.dat");
39 device->getFileSystem()->addFileArchive("irrlicht.dat"); 33 else device->getFileSystem()->addFileArchive("media/Irrlicht/irrlicht.dat");
40 else 34 if (device->getFileSystem()->existFile("map-20kdm2.pk3")) device->getFileSystem()->addFileArchive("map-20kdm2.pk3");
41 device->getFileSystem()->addFileArchive("media/Irrlicht/irrlicht.dat"); 35 else device->getFileSystem()->addFileArchive("media/Irrlicht/map-20kdm2.pk3");
42 if (device->getFileSystem()->existFile("map-20kdm2.pk3")) 36
43 device->getFileSystem()->addFileArchive("map-20kdm2.pk3"); 37 sceneStartTime = device->getTimer()->getTime();
44 else 38 timeForThisScene = 0;
45 device->getFileSystem()->addFileArchive("media/Irrlicht/map-20kdm2.pk3"); 39 loadSceneData();
46
47 sceneStartTime = device->getTimer()->getTime();
48 timeForThisScene = 0;
49 loadSceneData();
50} 40}
51 41
52
53void CDemo::preDraw(GLData *gld, u32 now) 42void CDemo::preDraw(GLData *gld, u32 now)
54{ 43{
55 if (((now - sceneStartTime) > timeForThisScene) && (timeForThisScene != -1)) 44 if (((now - sceneStartTime) > timeForThisScene) && (timeForThisScene != -1)) switchToNextScene(gld);
56 switchToNextScene(gld); 45 createParticleImpacts();
57
58 createParticleImpacts();
59} 46}
60 47
61
62bool CDemo::OnEvent(const SEvent& event) 48bool CDemo::OnEvent(const SEvent& event)
63{ 49{
64 if (!device) 50 if (!device) return false;
65 return false; 51
66 52 if ((((event.EventType == EET_KEY_INPUT_EVENT) && (event.KeyInput.Key == KEY_SPACE) &&
67 if (( ((event.EventType == EET_KEY_INPUT_EVENT) && (event.KeyInput.Key == KEY_SPACE) && (event.KeyInput.PressedDown == false)) || 53 (event.KeyInput.PressedDown == false)) ||
68 ((event.EventType == EET_MOUSE_INPUT_EVENT) && (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)) ) && (currentScene == 3)) 54 ((event.EventType == EET_MOUSE_INPUT_EVENT) && (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP))) && (currentScene == 3))
69 { 55 {
70 shoot(); 56 shoot();
71 } 57 }
72 else 58 else if (device->getSceneManager()->getActiveCamera())
73 if (device->getSceneManager()->getActiveCamera()) 59 {
74 { 60 device->getSceneManager()->getActiveCamera()->OnEvent(event);
75 device->getSceneManager()->getActiveCamera()->OnEvent(event); 61 return true;
76 return true; 62 }
77 } 63
78 64 return false;
79 return false;
80} 65}
81 66
82
83void CDemo::switchToNextScene(GLData *gld) 67void CDemo::switchToNextScene(GLData *gld)
84{ 68{
85 currentScene++; 69 currentScene++;
86 if (currentScene > 3) 70 if (currentScene > 3) currentScene = 1;
87 currentScene = 1; 71
88 72 scene::ISceneManager *sm = device->getSceneManager();
89 scene::ISceneManager* sm = device->getSceneManager(); 73 scene::ISceneNodeAnimator *sa = 0;
90 scene::ISceneNodeAnimator* sa = 0; 74 scene::ICameraSceneNode *camera = 0;
91 scene::ICameraSceneNode* camera = 0; 75
92 76 camera = sm->getActiveCamera();
93 camera = sm->getActiveCamera(); 77
94 78 switch (currentScene)
95 switch(currentScene) 79 {
96 { 80 case 1 : // panorama camera
97 case 1: // panorama camera 81 {
98 { 82 core::array<core::vector3df> points, points2;
99 core::array<core::vector3df> points, points2; 83
100 84 points.push_back(core::vector3df(-931.473755f, 900.0f, 2000.0f)); // -49873
101 points.push_back(core::vector3df(-931.473755f, 900.0f, 2000.0f)); // -49873 85 points.push_back(core::vector3df(-931.473755f, 900.0f, 2000.0f)); // -49873
102 points.push_back(core::vector3df(-931.473755f, 900.0f, 2000.0f)); // -49873 86 points.push_back(core::vector3df(-931.473755f, 700.0f, 1750.0f)); // -49873
103 points.push_back(core::vector3df(-931.473755f, 700.0f, 1750.0f)); // -49873 87 points.push_back(core::vector3df(-931.473755f, 500.0f, 1500.0f)); // -49873
104 points.push_back(core::vector3df(-931.473755f, 500.0f, 1500.0f)); // -49873 88 points.push_back(core::vector3df(-931.473755f, 300.0f, 1250.0f)); // -49873
105 points.push_back(core::vector3df(-931.473755f, 300.0f, 1250.0f)); // -49873 89 points.push_back(core::vector3df(-931.473755f, 200.0f, 1000.0f)); // -49873
106 points.push_back(core::vector3df(-931.473755f, 200.0f, 1000.0f)); // -49873 90 points.push_back(core::vector3df(-931.473755f, 138.300003f, 987.279114f)); // -49873
107 points.push_back(core::vector3df(-931.473755f, 138.300003f, 987.279114f)); // -49873 91 points.push_back(core::vector3df(-847.902222f, 136.757553f, 915.792725f)); // -50559
108 points.push_back(core::vector3df(-847.902222f, 136.757553f, 915.792725f)); // -50559 92 points.push_back(core::vector3df(-748.680420f, 152.254501f, 826.418945f)); // -51964
109 points.push_back(core::vector3df(-748.680420f, 152.254501f, 826.418945f)); // -51964 93 points.push_back(core::vector3df(-708.428406f, 213.569580f, 784.466675f)); // -53251
110 points.push_back(core::vector3df(-708.428406f, 213.569580f, 784.466675f)); // -53251 94 points.push_back(core::vector3df(-686.217651f, 288.141174f, 762.965576f)); // -54015
111 points.push_back(core::vector3df(-686.217651f, 288.141174f, 762.965576f)); // -54015 95 points.push_back(core::vector3df(-679.685059f, 365.095612f, 756.551453f)); // -54733
112 points.push_back(core::vector3df(-679.685059f, 365.095612f, 756.551453f)); // -54733 96 points.push_back(core::vector3df(-671.317871f, 447.360107f, 749.394592f)); // -55588
113 points.push_back(core::vector3df(-671.317871f, 447.360107f, 749.394592f)); // -55588 97 points.push_back(core::vector3df(-669.468445f, 583.335632f, 747.711853f)); // -56178
114 points.push_back(core::vector3df(-669.468445f, 583.335632f, 747.711853f)); // -56178 98 points.push_back(core::vector3df(-667.611267f, 727.313232f, 746.018250f)); // -56757
115 points.push_back(core::vector3df(-667.611267f, 727.313232f, 746.018250f)); // -56757 99 points.push_back(core::vector3df(-665.853210f, 862.791931f, 744.436096f)); // -57859
116 points.push_back(core::vector3df(-665.853210f, 862.791931f, 744.436096f)); // -57859 100 points.push_back(core::vector3df(-642.649597f, 1026.047607f, 724.259827f)); // -59705
117 points.push_back(core::vector3df(-642.649597f, 1026.047607f, 724.259827f)); // -59705 101 points.push_back(core::vector3df(-517.793884f, 838.396790f, 490.326050f)); // -60983
118 points.push_back(core::vector3df(-517.793884f, 838.396790f, 490.326050f)); // -60983 102 points.push_back(core::vector3df(-474.387299f, 715.691467f, 344.639984f)); // -61629
119 points.push_back(core::vector3df(-474.387299f, 715.691467f, 344.639984f)); // -61629 103 points.push_back(core::vector3df(-444.600250f, 601.155701f, 180.938095f)); // -62319
120 points.push_back(core::vector3df(-444.600250f, 601.155701f, 180.938095f)); // -62319 104 points.push_back(core::vector3df(-414.808899f, 479.691406f, 4.866660f)); // -63048
121 points.push_back(core::vector3df(-414.808899f, 479.691406f, 4.866660f)); // -63048 105 points.push_back(core::vector3df(-410.418945f, 429.642242f, -134.332687f)); // -63757
122 points.push_back(core::vector3df(-410.418945f, 429.642242f, -134.332687f)); // -63757 106 points.push_back(core::vector3df(-399.837585f, 411.498383f, -349.350983f)); // -64418
123 points.push_back(core::vector3df(-399.837585f, 411.498383f, -349.350983f)); // -64418 107 points.push_back(core::vector3df(-390.756653f, 403.970093f, -524.454407f)); // -65005
124 points.push_back(core::vector3df(-390.756653f, 403.970093f, -524.454407f)); // -65005 108 points.push_back(core::vector3df(-334.864227f, 350.065491f, -732.397400f)); // -65701
125 points.push_back(core::vector3df(-334.864227f, 350.065491f, -732.397400f)); // -65701 109 points.push_back(core::vector3df(-195.253387f, 349.577209f, -812.475891f)); // -66335
126 points.push_back(core::vector3df(-195.253387f, 349.577209f, -812.475891f)); // -66335 110 points.push_back(core::vector3df(16.255573f, 363.743134f, -833.800415f)); // -67170
127 points.push_back(core::vector3df(16.255573f, 363.743134f, -833.800415f)); // -67170 111 points.push_back(core::vector3df(234.940964f, 352.957825f, -820.150696f)); // -67939
128 points.push_back(core::vector3df(234.940964f, 352.957825f, -820.150696f)); // -67939 112 points.push_back(core::vector3df(436.797668f, 349.236450f, -816.914185f)); // -68596
129 points.push_back(core::vector3df(436.797668f, 349.236450f, -816.914185f)); // -68596 113 points.push_back(core::vector3df(575.236206f, 356.244812f, -719.788513f)); // -69166
130 points.push_back(core::vector3df(575.236206f, 356.244812f, -719.788513f)); // -69166 114 points.push_back(core::vector3df(594.131042f, 387.173828f, -609.675598f)); // -69744
131 points.push_back(core::vector3df(594.131042f, 387.173828f, -609.675598f)); // -69744 115 points.push_back(core::vector3df(617.615234f, 412.002899f, -326.174072f)); // -70640
132 points.push_back(core::vector3df(617.615234f, 412.002899f, -326.174072f)); // -70640 116 points.push_back(core::vector3df(606.456848f, 403.221954f, -104.179291f)); // -71390
133 points.push_back(core::vector3df(606.456848f, 403.221954f, -104.179291f)); // -71390 117 points.push_back(core::vector3df(610.958252f, 407.037750f, 117.209778f)); // -72085
134 points.push_back(core::vector3df(610.958252f, 407.037750f, 117.209778f)); // -72085 118 points.push_back(core::vector3df(597.956909f, 395.167877f, 345.942200f)); // -72817
135 points.push_back(core::vector3df(597.956909f, 395.167877f, 345.942200f)); // -72817 119 points.push_back(core::vector3df(587.383118f, 391.444519f, 566.098633f)); // -73477
136 points.push_back(core::vector3df(587.383118f, 391.444519f, 566.098633f)); // -73477 120 points.push_back(core::vector3df(559.572449f, 371.991333f, 777.689453f)); // -74124
137 points.push_back(core::vector3df(559.572449f, 371.991333f, 777.689453f)); // -74124 121 points.push_back(core::vector3df(423.753204f, 329.990051f, 925.859741f)); // -74941
138 points.push_back(core::vector3df(423.753204f, 329.990051f, 925.859741f)); // -74941 122 points.push_back(core::vector3df(247.520050f, 252.818954f, 935.311829f)); // -75651
139 points.push_back(core::vector3df(247.520050f, 252.818954f, 935.311829f)); // -75651 123 points.push_back(core::vector3df(114.756012f, 199.799759f, 805.014160f));
140 points.push_back(core::vector3df(114.756012f, 199.799759f, 805.014160f)); 124 points.push_back(core::vector3df(96.783348f, 181.639481f, 648.188110f));
141 points.push_back(core::vector3df(96.783348f, 181.639481f, 648.188110f)); 125 points.push_back(core::vector3df(97.865623f, 138.905975f, 484.812561f));
142 points.push_back(core::vector3df(97.865623f, 138.905975f, 484.812561f)); 126 points.push_back(core::vector3df(99.612457f, 102.463669f, 347.603210f));
143 points.push_back(core::vector3df(99.612457f, 102.463669f, 347.603210f)); 127 points.push_back(core::vector3df(99.0f, 95.0f, 347.0f));
144 points.push_back(core::vector3df(99.0f, 95.0f, 347.0f)); 128 points.push_back(core::vector3df(99.0f, 90.0f, 347.0f));
145 points.push_back(core::vector3df(99.0f, 90.0f, 347.0f)); 129 points.push_back(core::vector3df(99.0f, 85.0f, 347.0f));
146 points.push_back(core::vector3df(99.0f, 85.0f, 347.0f)); 130 points.push_back(core::vector3df(99.0f, 80.0f, 347.0f));
147 points.push_back(core::vector3df(99.0f, 80.0f, 347.0f)); 131 points.push_back(core::vector3df(99.0f, 75.0f, 347.0f));
148 points.push_back(core::vector3df(99.0f, 75.0f, 347.0f)); 132 points.push_back(core::vector3df(99.0f, 75.0f, 347.0f));
149 points.push_back(core::vector3df(99.0f, 75.0f, 347.0f)); 133 points.push_back(core::vector3df(99.0f, 75.0f, 347.0f));
150 points.push_back(core::vector3df(99.0f, 75.0f, 347.0f)); 134 timeForThisScene = (points.size() - 2) * 1000;
151 timeForThisScene = (points.size() - 2) * 1000; 135 camera = sm->addCameraSceneNode(0, points[0], core::vector3df(0, 400, 0));
152 camera = sm->addCameraSceneNode(0, points[0], core::vector3df(0, 400, 0)); 136 sa = sm->createFollowSplineAnimator(device->getTimer()->getTime(), points, 1.0f, 0.6f, false, false);
153 sa = sm->createFollowSplineAnimator(device->getTimer()->getTime(), points, 1.0f, 0.6f, false, false); 137 camera->addAnimator(sa);
154 camera->addAnimator(sa); 138 sa->drop();
155 sa->drop(); 139 break;
156 } 140 }
157 break; 141
158 142 case 2 : // panorama camera
159 case 2: // panorama camera 143 {
160 { 144 core::array<core::vector3df> points;
161 core::array<core::vector3df> points; 145
162 146 camera->setTarget(core::vector3df(100, 145, -80));
163 camera->setTarget(core::vector3df(100, 145, -80)); 147
164 148 points.push_back(core::vector3df(99.0f, 75.0f, 347.0f));
165 points.push_back(core::vector3df(99.0f, 75.0f, 347.0f)); 149 points.push_back(core::vector3df(100.0f, 75.0f, 347.0f));
166 points.push_back(core::vector3df(100.0f, 75.0f, 347.0f)); 150 points.push_back(core::vector3df(105.0f, 75.0f, 347.0f));
167 points.push_back(core::vector3df(105.0f, 75.0f, 347.0f)); 151 points.push_back(core::vector3df(110.0f, 70.0f, 347.0f));
168 points.push_back(core::vector3df(110.0f, 70.0f, 347.0f)); 152 points.push_back(core::vector3df(115.0f, 70.0f, -160.0f));
169 points.push_back(core::vector3df(115.0f, 70.0f, -160.0f)); 153 points.push_back(core::vector3df(120.0f, 70.0f, -160.0f));
170 points.push_back(core::vector3df(120.0f, 70.0f, -160.0f)); 154 points.push_back(core::vector3df(125.0f, 65.0f, -160.0f));
171 points.push_back(core::vector3df(125.0f, 65.0f, -160.0f)); 155 points.push_back(core::vector3df(130.0f, 65.0f, -160.0f));
172 points.push_back(core::vector3df(130.0f, 65.0f, -160.0f)); 156 points.push_back(core::vector3df(135.0f, 65.0f, -160.0f));
173 points.push_back(core::vector3df(135.0f, 65.0f, -160.0f)); 157 points.push_back(core::vector3df(150.0f, 170.0f, -160.0f));
174 points.push_back(core::vector3df(150.0f, 170.0f, -160.0f)); 158 points.push_back(core::vector3df(150.0f, 170.0f, -160.0f));
175 points.push_back(core::vector3df(150.0f, 170.0f, -160.0f)); 159 points.push_back(core::vector3df(150.0f, 170.0f, -160.0f));
176 points.push_back(core::vector3df(150.0f, 170.0f, -160.0f)); 160 timeForThisScene = (points.size() - 2) * 1000;
177 timeForThisScene = (points.size() - 2) * 1000; 161 sa = sm->createFollowSplineAnimator(device->getTimer()->getTime(), points, 1.0f, 0.6f, false, false);
178 sa = sm->createFollowSplineAnimator(device->getTimer()->getTime(), points, 1.0f, 0.6f, false, false); 162 camera->addAnimator(sa);
179 camera->addAnimator(sa); 163 sa->drop();
180 sa->drop(); 164 break;
181 } 165 }
182 break; 166
183 167 case 3 : // interactive, go around
184 case 3: // interactive, go around 168 {
185 { 169 if (camera)
186 if (camera) 170 {
187 { 171 sm->setActiveCamera(0);
188 sm->setActiveCamera(0); 172 camera->remove();
189 camera->remove(); 173 camera = 0;
190 camera = 0; 174 }
191 } 175 timeForThisScene = -1;
192 timeForThisScene = -1; 176
193 177 gld->camera = addExtantzCamera(sm, NULL, -1);
194 gld->camera = addExtantzCamera(sm, NULL, -1); 178 camera = gld->camera;
195 camera = gld->camera; 179 camera->setPosition(core::vector3df(108, 140, -140));
196 camera->setPosition(core::vector3df(108, 140, -140)); 180 camera->setFarValue(5000.0f);
197 camera->setFarValue(5000.0f); 181 gld->move = getCameraMove(gld->camera);
198 gld->move = getCameraMove(gld->camera); 182
199 183 scene::ISceneNodeAnimatorCollisionResponse *collider =
200 scene::ISceneNodeAnimatorCollisionResponse* collider = 184 sm->createCollisionResponseAnimator(metaSelector, camera,
201 sm->createCollisionResponseAnimator(metaSelector, camera, core::vector3df(25, 50, 25), core::vector3df(0, quakeLevelMesh ? -10.f : 0.0f, 0), core::vector3df(0, 45, 0), 0.005f); 185 core::vector3df(25, 50, 25), core::vector3df(0, quakeLevelMesh ? -10.f : 0.0f, 0), core::vector3df(0, 45, 0), 0.005f);
202 camera->addAnimator(collider); 186 camera->addAnimator(collider);
203 collider->drop(); 187 collider->drop();
204 } 188 break;
205 break; 189 }
206 } 190 } // switch
207 191
208 sceneStartTime = device->getTimer()->getTime(); 192 sceneStartTime = device->getTimer()->getTime();
209} 193}
210 194
211
212void CDemo::loadSceneData() 195void CDemo::loadSceneData()
213{ 196{
214 // load quake level 197 // load quake level
215 198
216 video::IVideoDriver* driver = device->getVideoDriver(); 199 video::IVideoDriver *driver = device->getVideoDriver();
217 scene::ISceneManager* sm = device->getSceneManager(); 200 scene::ISceneManager *sm = device->getSceneManager();
218 201
219 // Quake3 Shader controls Z-Writing 202 // Quake3 Shader controls Z-Writing
220 sm->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); 203 sm->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
221 204
222 quakeLevelMesh = (scene::IQ3LevelMesh*) sm->getMesh("maps/20kdm2.bsp"); 205 quakeLevelMesh = (scene::IQ3LevelMesh *)sm->getMesh("maps/20kdm2.bsp");
223 206
224 if (quakeLevelMesh) 207 if (quakeLevelMesh)
225 { 208 {
226 u32 i; 209 u32 i;
227 210
228 //move all quake level meshes (non-realtime) 211 // move all quake level meshes (non-realtime)
229 core::matrix4 m; 212 core::matrix4 m;
230 m.setTranslation(core::vector3df(-1300,-70,-1249)); 213 m.setTranslation(core::vector3df(-1300, -70, -1249));
231 214
232 for (i = 0; i != scene::quake3::E_Q3_MESH_SIZE; ++i) 215 for (i = 0; i != scene::quake3::E_Q3_MESH_SIZE; ++i) sm->getMeshManipulator()->transform(quakeLevelMesh->getMesh(i), m);
233 sm->getMeshManipulator()->transform(quakeLevelMesh->getMesh(i), m); 216
234 217 quakeLevelNode = sm->addOctreeSceneNode(quakeLevelMesh->getMesh(scene::quake3::E_Q3_MESH_GEOMETRY));
235 quakeLevelNode = sm->addOctreeSceneNode(quakeLevelMesh->getMesh( scene::quake3::E_Q3_MESH_GEOMETRY)); 218 if (quakeLevelNode)
236 if (quakeLevelNode) 219 {
237 { 220 // quakeLevelNode->setPosition(core::vector3df(-1300, -70, -1249));
238 //quakeLevelNode->setPosition(core::vector3df(-1300, -70, -1249)); 221 quakeLevelNode->setVisible(true);
239 quakeLevelNode->setVisible(true); 222
240 223 // create map triangle selector
241 // create map triangle selector 224 mapSelector = sm->createOctreeTriangleSelector(quakeLevelMesh->getMesh(0), quakeLevelNode, 128);
242 mapSelector = sm->createOctreeTriangleSelector(quakeLevelMesh->getMesh(0), quakeLevelNode, 128); 225
243 226 // if not using shader and no gamma it's better to use more lighting, because
244 // if not using shader and no gamma it's better to use more lighting, because 227 // quake3 level are usually dark
245 // quake3 level are usually dark 228 quakeLevelNode->setMaterialType(video::EMT_LIGHTMAP_M4);
246 quakeLevelNode->setMaterialType(video::EMT_LIGHTMAP_M4); 229
247 230 // set additive blending if wanted
248 // set additive blending if wanted 231 if (additive) quakeLevelNode->setMaterialType(video::EMT_LIGHTMAP_ADD);
249 if (additive) 232 }
250 quakeLevelNode->setMaterialType(video::EMT_LIGHTMAP_ADD); 233
251 } 234 // the additional mesh can be quite huge and is unoptimized
252 235 scene::IMesh *additional_mesh = quakeLevelMesh->getMesh(scene::quake3::E_Q3_MESH_ITEMS);
253 // the additional mesh can be quite huge and is unoptimized 236
254 scene::IMesh *additional_mesh = quakeLevelMesh->getMesh(scene::quake3::E_Q3_MESH_ITEMS); 237 for (i = 0; i != additional_mesh->getMeshBufferCount(); ++i)
255 238 {
256 for (i = 0; i != additional_mesh->getMeshBufferCount(); ++i) 239 scene::IMeshBuffer *meshBuffer = additional_mesh->getMeshBuffer(i);
257 { 240 const video::SMaterial &material = meshBuffer->getMaterial();
258 scene::IMeshBuffer *meshBuffer = additional_mesh->getMeshBuffer(i); 241
259 const video::SMaterial &material = meshBuffer->getMaterial(); 242 // ! The ShaderIndex is stored in the material parameter
260 243 s32 shaderIndex = (s32)material.MaterialTypeParam2;
261 //! The ShaderIndex is stored in the material parameter 244
262 s32 shaderIndex = (s32) material.MaterialTypeParam2; 245 // the meshbuffer can be rendered without additional support, or it has no shader
263 246 const scene::quake3::IShader *shader = quakeLevelMesh->getShader(shaderIndex);
264 // the meshbuffer can be rendered without additional support, or it has no shader 247 if (0 == shader) continue;
265 const scene::quake3::IShader *shader = quakeLevelMesh->getShader(shaderIndex); 248 // Now add the MeshBuffer(s) with the current Shader to the Manager
266 if (0 == shader) 249 sm->addQuake3SceneNode(meshBuffer, shader);
267 { 250 }
268 continue; 251 }
269 } 252
270 // Now add the MeshBuffer(s) with the current Shader to the Manager 253 // load sydney model and create 2 instances
271 sm->addQuake3SceneNode(meshBuffer, shader); 254
272 } 255 scene::IAnimatedMesh *mesh = 0;
273 } 256 mesh = sm->getMesh("media/Irrlicht/sydney.md2");
274 257 if (mesh)
275 // load sydney model and create 2 instances 258 {
276 259 model1 = sm->addAnimatedMeshSceneNode(mesh);
277 scene::IAnimatedMesh *mesh = 0; 260 if (model1)
278 mesh = sm->getMesh("media/Irrlicht/sydney.md2"); 261 {
279 if (mesh) 262 model1->setMaterialTexture(0, driver->getTexture("media/Irrlicht/sydney.bmp"));
280 { 263 model1->setPosition(core::vector3df(100, 40, -80));
281 model1 = sm->addAnimatedMeshSceneNode(mesh); 264 model1->setScale(core::vector3df(2, 2, 2));
282 if (model1) 265 model1->setMD2Animation(scene::EMAT_STAND);
283 { 266 model1->setMaterialFlag(video::EMF_LIGHTING, true);
284 model1->setMaterialTexture(0, driver->getTexture("media/Irrlicht/sydney.bmp")); 267 model1->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
285 model1->setPosition(core::vector3df(100, 40, -80)); 268 model1->addShadowVolumeSceneNode();
286 model1->setScale(core::vector3df(2, 2, 2)); 269 }
287 model1->setMD2Animation(scene::EMAT_STAND); 270
288 model1->setMaterialFlag(video::EMF_LIGHTING, true); 271 model2 = sm->addAnimatedMeshSceneNode(mesh);
289 model1->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true); 272 if (model2)
290 model1->addShadowVolumeSceneNode(); 273 {
291 } 274 model2->setMaterialTexture(0, driver->getTexture("media/Irrlicht/spheremap.jpg"));
292 275 model2->setPosition(core::vector3df(180, 15, -60));
293 model2 = sm->addAnimatedMeshSceneNode(mesh); 276 model2->setScale(core::vector3df(2, 2, 2));
294 if (model2) 277 model2->setMD2Animation(scene::EMAT_RUN);
295 { 278 model2->setMaterialFlag(video::EMF_LIGHTING, false);
296 model2->setMaterialTexture(0, driver->getTexture("media/Irrlicht/spheremap.jpg")); 279 model2->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
297 model2->setPosition(core::vector3df(180, 15, -60)); 280 model2->setMaterialType(video::EMT_SPHERE_MAP);
298 model2->setScale(core::vector3df(2, 2, 2)); 281 model2->addShadowVolumeSceneNode();
299 model2->setMD2Animation(scene::EMAT_RUN); 282 }
300 model2->setMaterialFlag(video::EMF_LIGHTING, false); 283 }
301 model2->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true); 284
302 model2->setMaterialType(video::EMT_SPHERE_MAP); 285 scene::ISceneNodeAnimator *anim = 0;
303 model2->addShadowVolumeSceneNode(); 286
304 } 287 // create sky box
305 } 288 driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
306 289 skyboxNode = sm->addSkyBoxSceneNode(
307 scene::ISceneNodeAnimator *anim = 0; 290 driver->getTexture("media/Irrlicht/irrlicht2_up.jpg"),
308 291 driver->getTexture("media/Irrlicht/irrlicht2_dn.jpg"),
309 // create sky box 292 driver->getTexture("media/Irrlicht/irrlicht2_lf.jpg"),
310 driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); 293 driver->getTexture("media/Irrlicht/irrlicht2_rt.jpg"),
311 skyboxNode = sm->addSkyBoxSceneNode( 294 driver->getTexture("media/Irrlicht/irrlicht2_ft.jpg"),
312 driver->getTexture("media/Irrlicht/irrlicht2_up.jpg"), 295 driver->getTexture("media/Irrlicht/irrlicht2_bk.jpg"));
313 driver->getTexture("media/Irrlicht/irrlicht2_dn.jpg"), 296 driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
314 driver->getTexture("media/Irrlicht/irrlicht2_lf.jpg"), 297
315 driver->getTexture("media/Irrlicht/irrlicht2_rt.jpg"), 298 // create walk-between-portals animation
316 driver->getTexture("media/Irrlicht/irrlicht2_ft.jpg"), 299 core::vector3df waypoint[2];
317 driver->getTexture("media/Irrlicht/irrlicht2_bk.jpg")); 300 waypoint[0].set(-150, 40, 100);
318 driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true); 301 waypoint[1].set(350, 40, 100);
319 302
320 // create walk-between-portals animation 303 if (model2)
321 core::vector3df waypoint[2]; 304 {
322 waypoint[0].set(-150, 40, 100); 305 anim = device->getSceneManager()->createFlyStraightAnimator(waypoint[0], waypoint[1], 2000, true);
323 waypoint[1].set(350, 40, 100); 306 model2->addAnimator(anim);
324 307 anim->drop();
325 if (model2) 308 }
326 { 309
327 anim = device->getSceneManager()->createFlyStraightAnimator(waypoint[0], waypoint[1], 2000, true); 310 // create animation for portals;
328 model2->addAnimator(anim); 311 core::array<video::ITexture *> textures;
329 anim->drop(); 312
330 } 313 for (s32 g = 1; g < 8; ++g)
331 314 {
332 // create animation for portals; 315 core::stringc tmp("media/Irrlicht/portal");
333 core::array<video::ITexture*> textures; 316 tmp += g;
334 for (s32 g=1; g<8; ++g) 317 tmp += ".bmp";
335 { 318 video::ITexture *t = driver->getTexture(tmp);
336 core::stringc tmp("media/Irrlicht/portal"); 319 textures.push_back(t);
337 tmp += g; 320 }
338 tmp += ".bmp"; 321
339 video::ITexture* t = driver->getTexture(tmp); 322 anim = sm->createTextureAnimator(textures, 100);
340 textures.push_back(t); 323
341 } 324 // create portals
342 325 scene::IBillboardSceneNode *bill = 0;
343 anim = sm->createTextureAnimator(textures, 100); 326
344 327 for (int r = 0; r < 2; ++r)
345 // create portals 328 {
346 scene::IBillboardSceneNode* bill = 0; 329 bill = sm->addBillboardSceneNode(0, core::dimension2d<f32>(100, 100), waypoint[r] + core::vector3df(0, 20, 0));
347 for (int r = 0; r < 2; ++r) 330 bill->setMaterialFlag(video::EMF_LIGHTING, false);
348 { 331 bill->setMaterialTexture(0, driver->getTexture("media/Irrlicht/portal1.bmp"));
349 bill = sm->addBillboardSceneNode(0, core::dimension2d<f32>(100, 100), waypoint[r]+ core::vector3df(0, 20, 0)); 332 bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
350 bill->setMaterialFlag(video::EMF_LIGHTING, false); 333 bill->addAnimator(anim);
351 bill->setMaterialTexture(0, driver->getTexture("media/Irrlicht/portal1.bmp")); 334 }
352 bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); 335
353 bill->addAnimator(anim); 336 anim->drop();
354 } 337
355 338 // create circle flying dynamic light with transparent billboard attached
356 anim->drop(); 339 scene::ILightSceneNode *light = 0;
357 340
358 // create circle flying dynamic light with transparent billboard attached 341 light = sm->addLightSceneNode(0, core::vector3df(0, 0, 0), video::SColorf(1.0f, 1.0f, 1.f, 1.0f), 500.f);
359 scene::ILightSceneNode *light = 0; 342 anim = sm->createFlyCircleAnimator(core::vector3df(100, 150, 80), 80.0f, 0.0005f);
360 343
361 light = sm->addLightSceneNode(0, core::vector3df(0, 0, 0), video::SColorf(1.0f, 1.0f, 1.f, 1.0f), 500.f); 344 light->addAnimator(anim);
362 anim = sm->createFlyCircleAnimator(core::vector3df(100, 150, 80), 80.0f, 0.0005f); 345 anim->drop();
363 346
364 light->addAnimator(anim); 347 bill = device->getSceneManager()->addBillboardSceneNode(light, core::dimension2d<f32>(40, 40));
365 anim->drop(); 348 bill->setMaterialFlag(video::EMF_LIGHTING, false);
366 349 bill->setMaterialTexture(0, driver->getTexture("media/Irrlicht/particlewhite.bmp"));
367 bill = device->getSceneManager()->addBillboardSceneNode(light, core::dimension2d<f32>(40, 40)); 350 bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
368 bill->setMaterialFlag(video::EMF_LIGHTING, false); 351
369 bill->setMaterialTexture(0, driver->getTexture("media/Irrlicht/particlewhite.bmp")); 352 // create meta triangle selector with all triangles selectors in it.
370 bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); 353 metaSelector = sm->createMetaTriangleSelector();
371 354 metaSelector->addTriangleSelector(mapSelector);
372 // create meta triangle selector with all triangles selectors in it. 355
373 metaSelector = sm->createMetaTriangleSelector(); 356 // create camp fire
374 metaSelector->addTriangleSelector(mapSelector); 357 campFire = sm->addParticleSystemSceneNode(false);
375 358 campFire->setPosition(core::vector3df(100, 120, 600));
376 // create camp fire 359 campFire->setScale(core::vector3df(2, 2, 2));
377 campFire = sm->addParticleSystemSceneNode(false); 360
378 campFire->setPosition(core::vector3df(100, 120, 600)); 361 scene::IParticleEmitter *em =
379 campFire->setScale(core::vector3df(2, 2, 2)); 362 campFire->createBoxEmitter(core::aabbox3d<f32>(-7, 0, -7, 7, 1, 7),
380 363 core::vector3df(0.0f, 0.06f, 0.0f), 80, 100,
381 scene::IParticleEmitter *em = campFire->createBoxEmitter(core::aabbox3d<f32>(-7, 0, -7, 7, 1, 7), core::vector3df(0.0f, 0.06f, 0.0f), 80, 100, video::SColor(1, 255, 255, 255), video::SColor(1, 255, 255, 255), 800, 2000); 364 video::SColor(1, 255, 255, 255),
382 em->setMinStartSize(core::dimension2d<f32>(20.0f, 10.0f)); 365 video::SColor(1, 255, 255, 255), 800, 2000);
383 em->setMaxStartSize(core::dimension2d<f32>(20.0f, 10.0f)); 366 em->setMinStartSize(core::dimension2d<f32>(20.0f, 10.0f));
384 campFire->setEmitter(em); 367 em->setMaxStartSize(core::dimension2d<f32>(20.0f, 10.0f));
385 em->drop(); 368 campFire->setEmitter(em);
386 369 em->drop();
387 scene::IParticleAffector *paf = campFire->createFadeOutParticleAffector(); 370
388 campFire->addAffector(paf); 371 scene::IParticleAffector *paf = campFire->createFadeOutParticleAffector();
389 paf->drop(); 372 campFire->addAffector(paf);
390 373 paf->drop();
391 campFire->setMaterialFlag(video::EMF_LIGHTING, false); 374
392 campFire->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false); 375 campFire->setMaterialFlag(video::EMF_LIGHTING, false);
393 campFire->setMaterialTexture(0, driver->getTexture("media/Irrlicht/fireball.bmp")); 376 campFire->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
394 campFire->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); 377 campFire->setMaterialTexture(0, driver->getTexture("media/Irrlicht/fireball.bmp"));
378 campFire->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
395} 379}
396 380
397
398void CDemo::shoot() 381void CDemo::shoot()
399{ 382{
400 scene::ISceneManager *sm = device->getSceneManager(); 383 scene::ISceneManager *sm = device->getSceneManager();
401 scene::ICameraSceneNode *camera = sm->getActiveCamera(); 384 scene::ICameraSceneNode *camera = sm->getActiveCamera();
402 385
403 if ((!camera) || (!mapSelector)) 386 if ((!camera) || (!mapSelector)) return;
404 return; 387
405 388 SParticleImpact imp;
406 SParticleImpact imp; 389 imp.when = 0;
407 imp.when = 0; 390
408 391 // get line of camera
409 // get line of camera 392 core::vector3df start = camera->getPosition();
410 core::vector3df start = camera->getPosition(); 393 core::vector3df end = (camera->getTarget() - start);
411 core::vector3df end = (camera->getTarget() - start); 394 end.normalize();
412 end.normalize(); 395 start += end * 8.0f;
413 start += end * 8.0f; 396 end = start + (end * camera->getFarValue());
414 end = start + (end * camera->getFarValue()); 397
415 398 core::triangle3df triangle;
416 core::triangle3df triangle; 399
417 400 core::line3d<f32> line(start, end);
418 core::line3d<f32> line(start, end); 401
419 402 // get intersection point with map
420 // get intersection point with map 403 scene::ISceneNode *hitNode;
421 scene::ISceneNode* hitNode; 404 if (sm->getSceneCollisionManager()->getCollisionPoint(line, mapSelector, end, triangle, hitNode))
422 if (sm->getSceneCollisionManager()->getCollisionPoint(line, mapSelector, end, triangle, hitNode)) 405 {
423 { 406 // collides with wall
424 // collides with wall 407 core::vector3df out = triangle.getNormal();
425 core::vector3df out = triangle.getNormal(); 408 out.setLength(0.03f);
426 out.setLength(0.03f); 409
427 410 imp.when = 1;
428 imp.when = 1; 411 imp.outVector = out;
429 imp.outVector = out; 412 imp.pos = end;
430 imp.pos = end; 413 }
431 } 414 else
432 else 415 {
433 { 416 // doesnt collide with wall
434 // doesnt collide with wall 417 core::vector3df start = camera->getPosition();
435 core::vector3df start = camera->getPosition(); 418 core::vector3df end = (camera->getTarget() - start);
436 core::vector3df end = (camera->getTarget() - start); 419 end.normalize();
437 end.normalize(); 420 start += end * 8.0f;
438 start += end * 8.0f; 421 end = start + (end * camera->getFarValue());
439 end = start + (end * camera->getFarValue()); 422 }
440 } 423
441 424 // create fire ball
442 // create fire ball 425 scene::ISceneNode *node = 0;
443 scene::ISceneNode *node = 0; 426 node = sm->addBillboardSceneNode(0, core::dimension2d<f32>(25, 25), start);
444 node = sm->addBillboardSceneNode(0, core::dimension2d<f32>(25, 25), start); 427
445 428 node->setMaterialFlag(video::EMF_LIGHTING, false);
446 node->setMaterialFlag(video::EMF_LIGHTING, false); 429 node->setMaterialTexture(0, device->getVideoDriver()->getTexture("media/Irrlicht/fireball.bmp"));
447 node->setMaterialTexture(0, device->getVideoDriver()->getTexture("media/Irrlicht/fireball.bmp")); 430 node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
448 node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); 431
449 432 f32 length = (f32)(end - start).getLength();
450 f32 length = (f32)(end - start).getLength(); 433 const f32 speed = 0.6f;
451 const f32 speed = 0.6f; 434 u32 time = (u32)(length / speed);
452 u32 time = (u32) (length / speed); 435
453 436 scene::ISceneNodeAnimator *anim = 0;
454 scene::ISceneNodeAnimator *anim = 0; 437
455 438 // set flight line
456 // set flight line 439 anim = sm->createFlyStraightAnimator(start, end, time);
457 anim = sm->createFlyStraightAnimator(start, end, time); 440 node->addAnimator(anim);
458 node->addAnimator(anim); 441 anim->drop();
459 anim->drop(); 442
460 443 anim = sm->createDeleteAnimator(time);
461 anim = sm->createDeleteAnimator(time); 444 node->addAnimator(anim);
462 node->addAnimator(anim); 445 anim->drop();
463 anim->drop(); 446
464 447 if (imp.when)
465 if (imp.when) 448 {
466 { 449 // create impact note
467 // create impact note 450 imp.when = device->getTimer()->getTime() + (time - 100);
468 imp.when = device->getTimer()->getTime() + (time - 100); 451 Impacts.push_back(imp);
469 Impacts.push_back(imp); 452 }
470 }
471} 453}
472 454
473
474void CDemo::createParticleImpacts() 455void CDemo::createParticleImpacts()
475{ 456{
476 u32 now = device->getTimer()->getTime(); 457 u32 now = device->getTimer()->getTime();
477 scene::ISceneManager *sm = device->getSceneManager(); 458 scene::ISceneManager *sm = device->getSceneManager();
459
460 for (s32 i = 0; i < (s32)Impacts.size(); ++i)
461 if (now > Impacts[i].when)
462 {
463 // create smoke particle system
464 scene::IParticleSystemSceneNode *pas = 0;
478 465
479 for (s32 i = 0; i < (s32) Impacts.size(); ++i) 466 pas = sm->addParticleSystemSceneNode(false, 0, -1, Impacts[i].pos);
480 if (now > Impacts[i].when)
481 {
482 // create smoke particle system
483 scene::IParticleSystemSceneNode *pas = 0;
484 467
485 pas = sm->addParticleSystemSceneNode(false, 0, -1, Impacts[i].pos); 468 pas->setParticleSize(core::dimension2d<f32>(10.0f, 10.0f));
486 469
487 pas->setParticleSize(core::dimension2d<f32>(10.0f, 10.0f)); 470 scene::IParticleEmitter *em =
471 pas->createBoxEmitter(core::aabbox3d<f32>(-5, -5, -5, 5, 5, 5),
472 Impacts[i].outVector, 20, 40,
473 video::SColor(50, 255, 255, 255),
474 video::SColor(50, 255, 255, 255), 1200, 1600, 20);
475 pas->setEmitter(em);
476 em->drop();
488 477
489 scene::IParticleEmitter* em = pas->createBoxEmitter(core::aabbox3d<f32>(-5, -5, -5, 5, 5, 5), Impacts[i].outVector, 20, 40, video::SColor(50, 255, 255, 255), video::SColor(50, 255, 255, 255), 1200, 1600, 20); 478 scene::IParticleAffector *paf = campFire->createFadeOutParticleAffector();
490 pas->setEmitter(em); 479 pas->addAffector(paf);
491 em->drop(); 480 paf->drop();
492 481
493 scene::IParticleAffector *paf = campFire->createFadeOutParticleAffector(); 482 pas->setMaterialFlag(video::EMF_LIGHTING, false);
494 pas->addAffector(paf); 483 pas->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
495 paf->drop(); 484 pas->setMaterialTexture(0, device->getVideoDriver()->getTexture("media/Irrlicht/smoke.bmp"));
485 pas->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
496 486
497 pas->setMaterialFlag(video::EMF_LIGHTING, false); 487 scene::ISceneNodeAnimator *anim = sm->createDeleteAnimator(2000);
498 pas->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false); 488 pas->addAnimator(anim);
499 pas->setMaterialTexture(0, device->getVideoDriver()->getTexture("media/Irrlicht/smoke.bmp")); 489 anim->drop();
500 pas->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
501 490
502 scene::ISceneNodeAnimator *anim = sm->createDeleteAnimator(2000); 491 // delete entry
503 pas->addAnimator(anim); 492 Impacts.erase(i);
504 anim->drop(); 493 i--;
494 }
505 495
506 // delete entry
507 Impacts.erase(i);
508 i--;
509 }
510} 496}
diff --git a/src/extantz/CDemo.h b/src/extantz/CDemo.h
index 035c01f..0558a95 100644
--- a/src/extantz/CDemo.h
+++ b/src/extantz/CDemo.h
@@ -5,7 +5,7 @@
5#define __C_DEMO_H_INCLUDED__ 5#define __C_DEMO_H_INCLUDED__
6 6
7#ifdef _IRR_WINDOWS_ 7#ifdef _IRR_WINDOWS_
8#include <windows.h> 8 #include <windows.h>
9#endif 9#endif
10 10
11const int CAMERA_COUNT = 7; 11const int CAMERA_COUNT = 7;
@@ -14,50 +14,49 @@ class CDemo : public IEventReceiver
14{ 14{
15public: 15public:
16 16
17 CDemo(GLData *gld, bool additive); 17 CDemo(GLData *gld, bool additive);
18 18
19 ~CDemo(); 19 ~CDemo();
20 20
21 void setup(GLData *gld); 21 void setup(GLData *gld);
22 void preDraw(GLData *gld, u32 now); 22 void preDraw(GLData *gld, u32 now);
23 23
24 virtual bool OnEvent(const SEvent& event); 24 virtual bool OnEvent(const SEvent& event);
25 25
26private: 26private:
27 27
28 void createLoadingScreen(); 28 void createLoadingScreen();
29 void loadSceneData(); 29 void loadSceneData();
30 void switchToNextScene(GLData *gld); 30 void switchToNextScene(GLData *gld);
31 void shoot(); 31 void shoot();
32 void createParticleImpacts(); 32 void createParticleImpacts();
33 33
34 bool additive; 34 bool additive;
35 IrrlichtDevice *device; 35 IrrlichtDevice *device;
36 36
37 struct SParticleImpact 37 struct SParticleImpact
38 { 38 {
39 u32 when; 39 u32 when;
40 core::vector3df pos; 40 core::vector3df pos;
41 core::vector3df outVector; 41 core::vector3df outVector;
42 }; 42 };
43 43
44 int currentScene; 44 int currentScene;
45 45
46 scene::IQ3LevelMesh* quakeLevelMesh; 46 scene::IQ3LevelMesh *quakeLevelMesh;
47 scene::ISceneNode* quakeLevelNode; 47 scene::ISceneNode *quakeLevelNode;
48 scene::ISceneNode* skyboxNode; 48 scene::ISceneNode *skyboxNode;
49 scene::IAnimatedMeshSceneNode* model1; 49 scene::IAnimatedMeshSceneNode *model1;
50 scene::IAnimatedMeshSceneNode* model2; 50 scene::IAnimatedMeshSceneNode *model2;
51 scene::IParticleSystemSceneNode* campFire; 51 scene::IParticleSystemSceneNode *campFire;
52 52
53 scene::IMetaTriangleSelector* metaSelector; 53 scene::IMetaTriangleSelector *metaSelector;
54 scene::ITriangleSelector* mapSelector; 54 scene::ITriangleSelector *mapSelector;
55 55
56 s32 sceneStartTime; 56 s32 sceneStartTime;
57 s32 timeForThisScene; 57 s32 timeForThisScene;
58 58
59 core::array<SParticleImpact> Impacts; 59 core::array<SParticleImpact> Impacts;
60}; 60};
61 61
62#endif 62#endif // ifndef __C_DEMO_H_INCLUDED__
63
diff --git a/src/extantz/camera.c b/src/extantz/camera.c
index 41ce25c..e566fbb 100644
--- a/src/extantz/camera.c
+++ b/src/extantz/camera.c
@@ -1,94 +1,83 @@
1#include "extantz.h" 1#include "extantz.h"
2 2
3
4static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) 3static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
5{ 4{
6 GLData *gld = data; 5 globals *ourGlobals = data;
7 Evas_Event_Key_Down *ev = event_info; 6 GLData *gld = &ourGlobals->gld;
7 Evas_Event_Key_Down *ev = event_info;
8 8
9 if (gld->move) 9 if (gld->move)
10 { 10 {
11 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called. 11 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
12 12
13 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ... 13 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ...
14 // TODO - make this a hash lookup dammit. 14 // TODO - make this a hash lookup dammit.
15 if (0 == strcmp(ev->key, "Escape")) 15 if (0 == strcmp(ev->key, "Escape"))
16 { 16 {
17 }
18 else if (0 == strcmp(ev->key, "Left"))
19 gld->move->r = 2.0;
20 else if (0 == strcmp(ev->key, "Right"))
21 gld->move->r = -2.0;
22 else if (0 == strcmp(ev->key, "Up"))
23 gld->move->x = 2.0;
24 else if (0 == strcmp(ev->key, "Down"))
25 gld->move->x = -2.0;
26 else if (0 == strcmp(ev->key, "Prior"))
27 gld->move->z = -2.0;
28 else if (0 == strcmp(ev->key, "Next"))
29 gld->move->z = 2.0;
30 else if (0 == strcmp(ev->key, "Home"))
31 gld->move->y = 2.0;
32 else if (0 == strcmp(ev->key, "End"))
33 gld->move->y = -2.0;
34 else if (0 == strcmp(ev->key, "space"))
35 gld->move->jump = 1.0;
36 else
37 printf("Unexpected down keystroke - %s\n", ev->key);
38 } 17 }
39 else 18 else if (0 == strcmp(ev->key, "Left")) gld->move->r = 2.0;
40 printf("Camera input not ready\n"); 19 else if (0 == strcmp(ev->key, "Right")) gld->move->r = -2.0;
20 else if (0 == strcmp(ev->key, "Up")) gld->move->x = 2.0;
21 else if (0 == strcmp(ev->key, "Down")) gld->move->x = -2.0;
22 else if (0 == strcmp(ev->key, "Prior")) gld->move->z = -2.0;
23 else if (0 == strcmp(ev->key, "Next")) gld->move->z = 2.0;
24 else if (0 == strcmp(ev->key, "Home")) gld->move->y = 2.0;
25 else if (0 == strcmp(ev->key, "End")) gld->move->y = -2.0;
26 else if (0 == strcmp(ev->key, "space")) gld->move->jump = 1.0;
27 else printf("Unexpected down keystroke - %s\n", ev->key);
28 }
29 else printf("Camera input not ready\n");
41} 30}
42 31
43/* SL / OS camera controls 32/* SL / OS camera controls
44 up / down / w / s moves avatar forward / backward 33 * up / down / w / s moves avatar forward / backward
45 shifted version does the same 34 * shifted version does the same
46 double tap triggers run mode / or fast fly mode 35 * double tap triggers run mode / or fast fly mode
47 Running backwards turns your avatar to suit, walking does not. 36 * Running backwards turns your avatar to suit, walking does not.
48 left / right / a / d rotates avatar left / right, strafes in mouselook 37 * left / right / a / d rotates avatar left / right, strafes in mouselook
49 shifted version turns the avatar to walk sideways, so not really a strafe. 38 * shifted version turns the avatar to walk sideways, so not really a strafe.
50 So not sure if the "strafe" in mouse look turns the avatar as well? 39 * So not sure if the "strafe" in mouse look turns the avatar as well?
51 PgDn / c crouch while it is held down move up in flight mode 40 * PgDn / c crouch while it is held down move up in flight mode
52 PgUp jump move down in flight mode 41 * PgUp jump move down in flight mode
53 Home toggle flying 42 * Home toggle flying
54 End Nothing? 43 * End Nothing?
55 Esc return to third person view 44 * Esc return to third person view
56 m toggle mouse look 45 * m toggle mouse look
57 mouse wheel move view closer / further away from current focused object or avatar 46 * mouse wheel move view closer / further away from current focused object or avatar
58 Alt left click focus on some other object 47 * Alt left click focus on some other object
59 Ins ??? 48 * Ins ???
60 Del ??? 49 * Del ???
61 BS ??? 50 * BS ???
62 Tab ??? 51 * Tab ???
63 52 *
64 Mouse look is just first person view, moving mouse looks left / right / up / down. 53 * Mouse look is just first person view, moving mouse looks left / right / up / down.
65 Not sure if the avatar rotates with left / right, but that's likely. 54 * Not sure if the avatar rotates with left / right, but that's likely.
66 55 *
67 mouse moves With the left mouse button held down - 56 * mouse moves With the left mouse button held down -
68 left / right up / down 57 * left / right up / down
69 --------------------------------- 58 * ---------------------------------
70 for avatar swings avatar around zoom in and out of avatar 59 * for avatar swings avatar around zoom in and out of avatar
71 for object nothing 60 * for object nothing
72 alt orbit left / right zoom in and out 61 * alt orbit left / right zoom in and out
73 alt ctrl orbit left / right orbit up / down 62 * alt ctrl orbit left / right orbit up / down
74 alt shift orbit left / right zoom in and out 63 * alt shift orbit left / right zoom in and out
75 alt ctrl shift shift view left / right / up / down 64 * alt ctrl shift shift view left / right / up / down
76 ctrl Nothing? 65 * ctrl Nothing?
77 shift Nothing? 66 * shift Nothing?
78 ctrl shift Nothing? 67 * ctrl shift Nothing?
79 68 *
80 Need to also consider when looking at a moving object / avatar. 69 * Need to also consider when looking at a moving object / avatar.
81 70 *
82 I think there are other letter keys that duplicate arrow keys and such. I'll look for them later, but I don't use them. 71 * I think there are other letter keys that duplicate arrow keys and such. I'll look for them later, but I don't use them.
83 No idea what the function keys are mapped to, but think it's various non camera stuff. 72 * No idea what the function keys are mapped to, but think it's various non camera stuff.
84 I'm damn well leaving the Win/Command and Menu keys for the OS / window manager. lol 73 * I'm damn well leaving the Win/Command and Menu keys for the OS / window manager. lol
85 Keypad keys? Not interested, I don't have them. 74 * Keypad keys? Not interested, I don't have them.
86 Print Screen / SysRq, Pause / Break, other oddball keys, also not interested. 75 * Print Screen / SysRq, Pause / Break, other oddball keys, also not interested.
87 NOTE - gonna have an easily programmable "bind key to command" thingy, like E17s, so that can deal with other keys. 76 * NOTE - gonna have an easily programmable "bind key to command" thingy, like E17s, so that can deal with other keys.
88 Should even let them be saveable so people can swap them with other people easily. 77 * Should even let them be saveable so people can swap them with other people easily.
89 78 *
90 TODO - implement things like space mouse, sixaxis, phone as controller, joysticks, data gloves, etc. 79 * TODO - implement things like space mouse, sixaxis, phone as controller, joysticks, data gloves, etc.
91*/ 80 */
92 81
93/* A moveRotate array of floats. 82/* A moveRotate array of floats.
94 * X, Y, Z, and whatever the usual letters are for rotations. lol 83 * X, Y, Z, and whatever the usual letters are for rotations. lol
@@ -106,77 +95,65 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void
106 95
107static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info) 96static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
108{ 97{
109 GLData *gld = data; 98 globals *ourGlobals = data;
110 Evas_Event_Key_Up *ev = event_info; 99 GLData *gld = &ourGlobals->gld;
100 Evas_Event_Key_Up *ev = event_info;
111 101
112 if (gld->move) 102 if (gld->move)
113 { 103 {
114 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called. 104 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
115 105
116 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ... 106 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ...
117 // TODO - make this a hash lookup dammit. 107 // TODO - make this a hash lookup dammit.
118 if (0 == strcmp(ev->key, "Escape")) 108 if (0 == strcmp(ev->key, "Escape"))
119 { 109 {
120 }
121 else if (0 == strcmp(ev->key, "Left"))
122 gld->move->r = 0.0;
123 else if (0 == strcmp(ev->key, "Right"))
124 gld->move->r = 0.0;
125 else if (0 == strcmp(ev->key, "Up"))
126 gld->move->x = 0.0;
127 else if (0 == strcmp(ev->key, "Down"))
128 gld->move->x = 0.0;
129 else if (0 == strcmp(ev->key, "Prior"))
130 gld->move->z = 0.0;
131 else if (0 == strcmp(ev->key, "Next"))
132 gld->move->z = 0.0;
133 else if (0 == strcmp(ev->key, "Home"))
134 gld->move->y = 0.0;
135 else if (0 == strcmp(ev->key, "End"))
136 gld->move->y = 0.0;
137 else if (0 == strcmp(ev->key, "space"))
138 gld->move->jump = 0.0;
139 else
140 printf("Unexpected up keystroke - %s\n", ev->key);
141 } 110 }
142 else 111 else if (0 == strcmp(ev->key, "Left")) gld->move->r = 0.0;
143 printf("Camera input not ready\n"); 112 else if (0 == strcmp(ev->key, "Right")) gld->move->r = 0.0;
113 else if (0 == strcmp(ev->key, "Up")) gld->move->x = 0.0;
114 else if (0 == strcmp(ev->key, "Down")) gld->move->x = 0.0;
115 else if (0 == strcmp(ev->key, "Prior")) gld->move->z = 0.0;
116 else if (0 == strcmp(ev->key, "Next")) gld->move->z = 0.0;
117 else if (0 == strcmp(ev->key, "Home")) gld->move->y = 0.0;
118 else if (0 == strcmp(ev->key, "End")) gld->move->y = 0.0;
119 else if (0 == strcmp(ev->key, "space")) gld->move->jump = 0.0;
120 else printf("Unexpected up keystroke - %s\n", ev->key);
121 }
122 else printf("Camera input not ready\n");
144} 123}
145 124
146// Elm style event callback. 125// Elm style event callback.
147static Eina_Bool _cb_event_GL(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info) 126static Eina_Bool _cb_event_GL(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info)
148{ 127{
149 GLData *gld = data; 128 Eina_Bool processed = EINA_FALSE;
150 Eina_Bool processed = EINA_FALSE;
151 129
152 switch (type) 130 switch (type)
131 {
132 case EVAS_CALLBACK_KEY_DOWN :
153 { 133 {
154 case EVAS_CALLBACK_KEY_DOWN : 134 _on_camera_input_down(data, evas_object_evas_get(obj), obj, event_info);
155 { 135 processed = EINA_TRUE;
156 _on_camera_input_down(gld, evas_object_evas_get(obj), obj, event_info); 136 break;
157 processed = EINA_TRUE; 137 }
158 break;
159 }
160
161 case EVAS_CALLBACK_KEY_UP :
162 {
163 _on_camera_input_up(gld, evas_object_evas_get(obj), obj, event_info);
164 processed = EINA_TRUE;
165 break;
166 }
167 138
168 default : 139 case EVAS_CALLBACK_KEY_UP :
169 printf("Unknown GL input event.\n"); 140 {
141 _on_camera_input_up(data, evas_object_evas_get(obj), obj, event_info);
142 processed = EINA_TRUE;
143 break;
170 } 144 }
171 145
172 return processed; 146 default :
173} 147 printf("Unknown GL input event.\n");
148 } /* switch */
174 149
150 return processed;
151}
175 152
176void cameraAdd(Evas_Object *win, GLData *gld) 153void cameraAdd(globals *ourGlobals, Evas_Object *win)
177{ 154{
178 // In this code, we are making our own camera, so grab it's input when we are focused. 155 // In this code, we are making our own camera, so grab it's input when we are focused.
179 evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld); 156 evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, ourGlobals);
180 evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld); 157 evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, ourGlobals);
181 elm_object_event_callback_add(win, _cb_event_GL, gld); 158 elm_object_event_callback_add(win, _cb_event_GL, ourGlobals);
182} 159}