forked from adoptware/pinball
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlight.cpp
69 lines (60 loc) · 1.81 KB
/
light.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/***************************************************************************
Simple test. A cube should be visible in the middle of the screen.
The arrow keys rotates the cube.
***************************************************************************/
#include <iostream>
#include "Private.h"
#include "Engine.h"
#include "Camera.h"
#include "BigSphere.h"
#include "KeyRotBehavior.h"
#include "Keyboard.h"
#include "Light.h"
#include "Polygon.h"
#include "Shape3D.h"
/** Main */
int main(int argc, char *argv[]) {
cerr << "Simple emilia test." << endl;
// Create the engine.
Engine* engine = new Engine(argc, argv);
engine->setLightning(0.5f, 0.0f);
// Add a camera. Move it a bit.
Camera* camera = new Camera();
Group* groupCamera = new Group();
engine->add(groupCamera);
groupCamera->setCamera(camera);
groupCamera->setTranslation(0, 0, 3);
engine->setEngineCamera(groupCamera);
// Add a sphere
BigSphere* sphere = new BigSphere(1, 3, 1, 1, 1, 1);
sphere->setProperty(EM_SHAPE3D_SPECULAR);
Group* groupSphere = new Group();
engine->add(groupSphere);
groupSphere->addShape3D(sphere);
// Add a light
BigSphere* li = new BigSphere(1, 0, 1, 1, 1, 1);
li->setProperty(EM_SHAPE3D_ALWAYSLIT);
Light* lightR = new Light(2, 0, 0, 1, 0, 0);
Group* groupLightR1 = new Group();
Group* groupLightR2 = new Group();
engine->add(groupLightR1);
groupLightR1->add(groupLightR2);
groupLightR2->addShape3D(li);
groupLightR2->setLight(lightR);
groupLightR2->setTranslation(10, 0, 0);
engine->addLight(lightR);
// Add a behavior to the light
KeyRotBehavior* keyRBeh = new KeyRotBehavior();
groupLightR1->setBehavior(keyRBeh);
while (!Keyboard::isKeyDown(SDLK_ESCAPE)) {
engine->tick();
engine->render();
engine->swap();
// SDL_Delay(50);
}
engine->stopEngine();
return 0;
}
#if EM_USE_ALLEGRO
END_OF_MAIN();
#endif