extras; samples: Fixed warnings
[sdk] / samples / 3D / walkAround / walkAround.ec
index 437370b..0006983 100644 (file)
@@ -25,7 +25,7 @@ class WalkAroundApp : GuiApplication
          diffTime = time - lastTime;
          lastTime = time;
          GetMouseState(&buttons, &xd, &yd);
-         if(form)
+         if(form && form.active)
          {
             bool updateCamera = false;
             float speed = 50;
@@ -106,17 +106,20 @@ class WalkAroundForm : Window
    hasClose = true;
    clientSize = { 632, 438 };
 
-   Array<Material> materials { size = 8 };
+   Array<Material> materials { };
    Array<int> map { size = width * height };
    Array<int> elv { size = width * height };
    Array<Cube> cubes { };
 
+   BitmapResource spotTex { ":spot_tex.png", window = this };
    Material sideMat { opacity = 0.5f, diffuse = teal, ambient = teal, flags = { doubleSided = true, translucent = true } };
-   Material cow1Mat { opacity = 1.0f, diffuse = skyBlue, ambient = skyBlue };
-   Material cow2Mat { opacity = 1.0f, diffuse = lightGray, ambient = lightGray };
+   Material cow1Mat { opacity = 1.0f, diffuse = white, ambient = white };
+   Material cow2Mat { opacity = 1.0f, power = 20, diffuse = goldenrod, ambient = goldenrod, specular = goldenrod };
+   Material cow3Mat { opacity = 1.0f, power = 20, diffuse = goldenrod, ambient = goldenrod, specular = goldenrod };
    Object cowModel { };
    Object cow1 { };
    Object cow2 { };
+   Object cow3 { };
    Cube cube { };
    Array<Bitmap> textures { };
    bool acquiredInput;
@@ -132,7 +135,7 @@ class WalkAroundForm : Window
       int i;
       for(i = 0; i < map.count; i++)
       {
-         int num = map[i] = GetRandom(0, 7);
+         map[i] = GetRandom(0, 7);
          elv[i] = GetRandom(1, 100);
       }
    }
@@ -141,22 +144,35 @@ class WalkAroundForm : Window
    {
       Bitmap textureFile { };
       int i, x, y;
-      PrimitiveGroup group;
 
       cowModel.Load(":cow.3DS", null, displaySystem);
+      cowModel.Merge(displaySystem);
+      cowModel.mesh.ApplyMaterial(null);
 
       cow1.Duplicate(cowModel);
       cow1.transform.position = { -20, -50, 10 };
       cow1.transform.scaling = { 20, 20, 20 };
       cow1.transform.orientation = Euler { yaw = 135 };
       cow1.UpdateTransform();
+      cow1.material = cow1Mat;
+      cow1Mat.baseMap = spotTex.bitmap;
 
       cow2.Duplicate(cowModel);
       cow2.transform.position = { 60, -42, -5 };
       cow2.transform.scaling = { 20, 20, 20 };
       cow2.transform.orientation = Euler { yaw = 225 };
       cow2.UpdateTransform();
+      cow2.material = cow2Mat;
 
+      cow3.Duplicate(cowModel);
+      cow3.transform.position = { 120, -89, 13 };
+      cow3.transform.scaling = { 20, 20, 20 };
+      cow3.transform.orientation = Euler { yaw = 185 };
+      cow3.UpdateTransform();
+      cow3.material = cow3Mat;
+      cow3Mat.baseMap = spotTex.bitmap;
+
+      materials.size = 8;
       if(textureFile.Load(":texture1.pcx", null, null))
       {
          int count = 8;
@@ -186,8 +202,6 @@ class WalkAroundForm : Window
          {
             int ix = y * width + x;
             int num = map[ix];
-            int xs = -((tileSize+gap) * width) / 2;
-            int ys = -((tileSize+gap) * height) / 2;
             float h = elv[ix];
             Cube cube { };
 
@@ -218,6 +232,7 @@ class WalkAroundForm : Window
       cowModel.Free(displaySystem);
       cow1.Free(displaySystem);
       cow2.Free(displaySystem);
+      cow3.Free(displaySystem);
       cubes.Free();
    }
 
@@ -239,6 +254,7 @@ class WalkAroundForm : Window
 
       display.DrawObject(cow1);
       display.DrawObject(cow2);
+      display.DrawObject(cow3);
 
       display.SetCamera(surface, null);