cleaned all trailing white space from source files.
[sdk] / samples / 3D / Test3D / Test3D.ec
1 import "ecere"
2
3 class MyApp : GuiApplication
4 {
5    driver = "OpenGL";
6    // driver = "Direct3D";
7 };
8
9 Camera camera
10 {
11    fixed,
12    position = Vector3D { 0, 0, -300 },
13    orientation = Euler { 0, 0, 0 },
14    fov = 53;
15 };
16
17 Light light
18 {
19    //diffuse = white;
20    specular = white;
21    orientation = Euler { pitch = 10, yaw = 30 };
22 };
23
24 Light light2
25 {
26    diffuse = white;
27    //specular = white;
28    orientation = Euler { pitch = 20, yaw = -30 };
29 };
30
31 class Test3D : Window
32 {
33    text = "Form1";
34    background = black;
35    borderStyle = sizable;
36    hasMaximize = true;
37    hasMinimize = true;
38    hasClose = true;
39    size = { 640, 480 };
40
41    BitmapResource texture { "http://www.ecere.com/images/knot.png", window = this };
42    Sphere sphere { };
43    Cube cube { };
44    Material sphereMat { diffuse = white, ambient = blue, specular = red, power = 8 };
45    Material cubeMat { opacity = 1.0f, diffuse = white, ambient = white, flags = { doubleSided = true, translucent = true } };
46
47    bool OnLoadGraphics()
48    {
49       sphere.Create(displaySystem);
50       sphere.mesh.ApplyMaterial(sphereMat);
51       sphere.transform.scaling = { 75, 75, 75 };
52       sphere.transform.position = { 100, 0, 0 };
53       sphere.UpdateTransform();
54
55       cubeMat.baseMap = texture.bitmap;
56
57       cube.Create(displaySystem);
58       cube.mesh.ApplyMaterial(cubeMat);
59       cube.mesh.ApplyTranslucency(cube);
60       cube.transform.scaling = { 100, 100, 100 };
61       cube.transform.position = { -100, 0, 0 };
62       cube.transform.orientation = Euler { 50, 50 };
63       cube.UpdateTransform();
64       return true;
65    }
66
67    void OnResize(int w, int h)
68    {
69       camera.Setup(w, h, null);
70    }
71
72    void OnRedraw(Surface surface)
73    {
74       surface.Clear(depthBuffer);
75       camera.Update();
76       display.SetLight(0, light);
77       display.SetLight(1, light2);
78       display.fogDensity = 0;
79       display.SetCamera(surface, camera);
80       display.DrawObject(cube);
81       display.DrawObject(sphere);
82       display.SetCamera(surface, null);
83    }
84 }
85
86 Test3D test3D {};