Ejemplo n.º 1
0
        private void withTextureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string FILE_NAME = "./EarthTextureSmall.bmp";

            if (File.Exists(FILE_NAME))
            {
                Bitmap bitmap = (Bitmap)Image.FromFile(FILE_NAME);
                viewer3D.AddTexture(bitmap);
                Scene3D scene = new Scene3D();
                scene.LightList.Add(light);
                sphere = new Sphere3D();
                sphere.Generate(new List <double>()
                {
                    2, 64, 64
                });
                sphere.AmbientColor  = Color.FromArgb(255, 255, 255);
                sphere.DiffuseColor  = Color.FromArgb(255, 255, 255);
                sphere.SpecularColor = Color.White;
                sphere.Shininess     = 20;
                sphere.ShowVertices  = false;
                sphere.ShowWireFrame = false;
                sphere.ShowSurfaces  = true;
                sphere.UseLight      = true;
                sphere.ShadingModel  = ShadingModel.Smooth;
                sphere.SetTexture(1);
                scene.AddObject(sphere);
                viewer3D.Scene = scene;
                viewer3D.Invalidate();
            }
        }
Ejemplo n.º 2
0
        private void surfacesWireframeAndVerticesSmoothShadingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sphere = new Sphere3D();
            sphere.Generate(new List <double>()
            {
                2, 64, 64
            });
            Scene3D scene = new Scene3D();

            scene.LightList.Add(light);
            scene.AddObject(sphere);
            sphere.AmbientColor  = Color.FromArgb(0, 255, 0);
            sphere.DiffuseColor  = Color.FromArgb(0, 255, 0);
            sphere.SpecularColor = Color.White;
            sphere.Shininess     = 20;
            sphere.SetUniformColor(Color.White); // This color is used ONLY for the wireframe.
            sphere.ShowVertices   = true;
            sphere.ShowWireFrame  = true;
            sphere.ShowSurfaces   = true;
            sphere.WireFrameWidth = 1.5f;
            sphere.VertexSize     = 2.5f;
            sphere.UseLight       = true;
            sphere.ShadingModel   = ShadingModel.Smooth;
            sphere.Alpha          = 0.5f;
            viewer3D.Scene        = scene;
        }
Ejemplo n.º 3
0
        private void noLightToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Scene3D scene = new Scene3D();

            scene.AddObject(sphere);
            sphere = new Sphere3D();
            sphere.Generate(new List <double>()
            {
                2, 64, 64
            });
            sphere.SetUniformColor(Color.FromArgb(0, 255, 0));
            scene.LightList           = new List <Light>();
            viewer3D.Scene            = scene;
            viewer3D.UseSmoothShading = false;
        }
Ejemplo n.º 4
0
        private void verticesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sphere = new Sphere3D();
            sphere.Generate(new List <double>()
            {
                2, 64, 64
            });
            Scene3D scene = new Scene3D();

            scene.AddObject(sphere);
            sphere.ShowVertices  = true;
            sphere.ShowWireFrame = false;
            sphere.ShowSurfaces  = false;
            sphere.VertexSize    = 2f;
            viewer3D.Scene       = scene;
        }
Ejemplo n.º 5
0
        private void wireframeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sphere = new Sphere3D();
            sphere.Generate(new List <double>()
            {
                2, 64, 64
            });
            Scene3D scene = new Scene3D();

            scene.AddObject(sphere);
            sphere.SetUniformColor(Color.FromArgb(255, 255, 255));
            sphere.ShowVertices   = false;
            sphere.ShowWireFrame  = true;
            sphere.ShowSurfaces   = false;
            sphere.WireFrameWidth = 1f;
            viewer3D.Scene        = scene;
        }
Ejemplo n.º 6
0
        private void lightSmoothShadingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sphere = new Sphere3D();
            sphere.Generate(new List <double>()
            {
                2, 64, 64
            });
            sphere.AmbientColor  = Color.FromArgb(0, 255, 0);
            sphere.DiffuseColor  = Color.FromArgb(0, 255, 0);
            sphere.SpecularColor = Color.White;
            sphere.Shininess     = 20;
            Scene3D scene = new Scene3D();

            scene.AddObject(sphere);
            scene.LightList.Add(light);
            viewer3D.Scene            = scene;
            viewer3D.UseSmoothShading = true;
        }
Ejemplo n.º 7
0
        private void surfacesNoLightToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sphere = new Sphere3D();
            sphere.Generate(new List <double>()
            {
                2, 64, 64
            });
            Scene3D scene = new Scene3D();

            scene.LightList.Add(light);
            scene.AddObject(sphere);
            sphere.SetUniformColor(Color.FromArgb(0, 255, 0));
            sphere.ShowVertices  = false;
            sphere.ShowWireFrame = false;
            sphere.ShowSurfaces  = true;
            sphere.UseLight      = false;
            sphere.ShadingModel  = ShadingModel.Flat;
            scene.LightList      = new List <Light>();
            viewer3D.Scene       = scene;
        }
Ejemplo n.º 8
0
        private void translucentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sphere = new Sphere3D();
            sphere.Generate(new List <double>()
            {
                2, 64, 64
            });
            Scene3D scene = new Scene3D();

            scene.LightList.Add(light);
            scene.AddObject(sphere);
            sphere.AmbientColor  = Color.FromArgb(255, 255, 255);
            sphere.DiffuseColor  = Color.FromArgb(255, 255, 255);
            sphere.SpecularColor = Color.White;
            sphere.Shininess     = 20;
            sphere.ShowVertices  = false;
            sphere.ShowWireFrame = false;
            sphere.ShowSurfaces  = true;
            sphere.UseLight      = true;
            sphere.ShadingModel  = ShadingModel.Smooth;
            sphere.SetAlpha(0.5f);
            Sphere3D smallSphere = new Sphere3D();

            smallSphere.Generate(new List <double>()
            {
                1.5, 64, 64
            });
            smallSphere.AmbientColor  = Color.FromArgb(0, 0, 255);
            smallSphere.DiffuseColor  = Color.FromArgb(0, 0, 255);
            smallSphere.SpecularColor = Color.White;
            smallSphere.Shininess     = 20;
            smallSphere.SetUniformColor(Color.White); // This color is used ONLY for the wireframe.
            smallSphere.ShowVertices  = false;
            smallSphere.ShowWireFrame = false;
            smallSphere.ShowSurfaces  = true;
            smallSphere.UseLight      = true;
            smallSphere.ShadingModel  = ShadingModel.Smooth;
            scene.AddObject(smallSphere);
            scene.SortForTranslucence();
            viewer3D.Scene = scene;
        }
Ejemplo n.º 9
0
        private void surfacesSmoothShadingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sphere = new Sphere3D();
            sphere.Generate(new List <double>()
            {
                2, 64, 64
            });
            Scene3D scene = new Scene3D();

            scene.LightList.Add(light);
            scene.AddObject(sphere);
            sphere.AmbientColor  = Color.FromArgb(0, 255, 0);
            sphere.DiffuseColor  = Color.FromArgb(0, 255, 0);
            sphere.SpecularColor = Color.White;
            sphere.Shininess     = 20;
            sphere.ShowVertices  = false;
            sphere.ShowWireFrame = false;
            sphere.ShowSurfaces  = true;
            sphere.UseLight      = true;
            sphere.ShadingModel  = ShadingModel.Smooth;
            viewer3D.Scene       = scene;
        }
Ejemplo n.º 10
0
    private void RenderCollision <T>(Type type) where T : Collider
    {
        T[]   colliders = UnityEngine.Object.FindObjectsOfType <T>();
        Color color     = ColliderColor(type);

        AddToRenderList(colliders);

        switch (type)
        {
        case Type.Boxes:
            Box3D.Render(colliderList, color, EdgeAlpha, color, FaceAlpha, IsSet(Flags.NoDepth));
            Box3D.Render(triggerList, triggerColor, EdgeAlpha, triggerColor, FaceAlpha, IsSet(Flags.NoDepth));
            break;

        case Type.Spheres:
            Sphere3D.Render(colliderList, color, EdgeAlpha, color, FaceAlpha, IsSet(Flags.NoDepth));
            Sphere3D.Render(triggerList, triggerColor, EdgeAlpha, triggerColor, FaceAlpha, IsSet(Flags.NoDepth));
            break;

        case Type.Capsules:
            Capsule3D.Render(colliderList, color, EdgeAlpha, color, FaceAlpha, IsSet(Flags.NoDepth));
            Capsule3D.Render(triggerList, triggerColor, EdgeAlpha, triggerColor, FaceAlpha, IsSet(Flags.NoDepth));
            break;

        case Type.Meshes:
            Mesh3D.Render(colliderList, color, EdgeAlpha, color, FaceAlpha, IsSet(Flags.NoDepth));
            Mesh3D.Render(triggerList, triggerColor, EdgeAlpha, triggerColor, FaceAlpha, IsSet(Flags.NoDepth));
            break;

        case Type.Characters:
            Character3D.Render(colliderList, color, EdgeAlpha, color, FaceAlpha, IsSet(Flags.NoDepth));
            Character3D.Render(triggerList, triggerColor, EdgeAlpha, triggerColor, FaceAlpha, IsSet(Flags.NoDepth));
            guiColliderCount[(int)Type.Capsules] += colliderList.Count + triggerList.Count;
            break;
        }

        guiColliderCount[(int)type] += colliderList.Count + triggerList.Count;
    }
Ejemplo n.º 11
0
        public Eye(string name, int sgn)
        {
            Object3DList = new List <Object3D>();

            //Body
            _eyeball = new Sphere3D {
                Object3DList = new List <Object3D>()
            };
            _eyeball.Generate(new List <double> {
                0.105, 32, 32
            });
            _eyeball.AmbientColor  = Color.FromArgb(255, 255, 255);
            _eyeball.DiffuseColor  = Color.FromArgb(255, 255, 255);
            _eyeball.SpecularColor = Color.White;
            _eyeball.Shininess     = 20;
            _eyeball.Name          = name;
            _eyeball.Move(sgn * 0.20, 0.4, 0.7);

            //Iris
            _iris = new Sphere3D {
                Object3DList = new List <Object3D>()
            };
            _iris.Generate(new List <double> {
                0.06, 32, 32
            });
            _iris.AmbientColor  = Color.FromArgb(0, 0, 255);
            _iris.DiffuseColor  = Color.FromArgb(0, 0, 255);
            _iris.SpecularColor = Color.Blue;
            _iris.Move(0, 0.05, 0);

            //Pupil
            _pupil = new Sphere3D();
            _pupil.Generate(new List <double> {
                .03, 32, 32
            });
            _pupil.AmbientColor  = Color.FromArgb(0, 0, 0);
            _pupil.DiffuseColor  = Color.FromArgb(0, 0, 0);
            _pupil.SpecularColor = Color.Black;
            _pupil.Move(0, 0.035, 0);
            _pupil.Shininess = 20;

            //Eyelid
            _lid = new SphereSegment3D();
            _lid.Generate(new List <double> {
                0.108, 32, 32, .01
            });
            _lid.AmbientColor  = Color.DarkSalmon;
            _lid.DiffuseColor  = Color.Black;
            _lid.SpecularColor = Color.DarkSalmon;
            _lid.Move(sgn * 0.20, 0.4, 0.7); //Same as eyeball
            _lid.Move(sgn * 0.01, 0.016, 0);
            _lid.RotateX(40);
            _lid.RotateZ(-sgn * 25);

            //Eyebrow - not part of eyeball
            _eyeBrow = new TorusSector3D();
            _eyeBrow.Generate(new List <double>()
            {
                0.15, 0.02, 32, 32, 0, Math.PI
            });
            _eyeBrow.AmbientColor  = Color.DeepPink;
            _eyeBrow.DiffuseColor  = Color.DeepPink;
            _eyeBrow.SpecularColor = Color.DeepPink;
            _eyeBrow.Move(sgn * 0.2, 0.3, 0.8);
            _eyeBrow.RotateY(-sgn * 25);
            _eyeBrow.RotateX(15);

            //Setup
            Object3DList.Add(_eyeball);
            Object3DList.Add(_lid);
            Object3DList.Add(_eyeBrow);
            _eyeball.Object3DList.Add(_iris);
            _iris.Object3DList.Add(_pupil);
        }
        private void Initialize()
        {
            randomNumberGenerator = new Random();
            string faceFileName = Path.GetDirectoryName(Application.ExecutablePath) + DEFAULT_RELATIVE_FACE_FILE_NAME;

            if (File.Exists(faceFileName))
            {
                face      = (Face)ObjectXmlSerializer.ObtainSerializedObject(faceFileName, typeof(Face));
                face.Name = "Face";
                face.Generate(new List <double> {
                    128
                });
                face.Visible       = true;
                face.SpecularColor = Color.OrangeRed;
                face.Shininess     = 50;

                // A lot of ugly hard-coding here, but OK - just for demonstration:
                face.Object3DList = new List <Object3D>();

                Sphere3D leftEyeBulb = new Sphere3D();
                leftEyeBulb.Generate(new List <double>()
                {
                    0.07, 64, 64
                });
                leftEyeBulb.AmbientColor  = Color.White;
                leftEyeBulb.DiffuseColor  = Color.White;
                leftEyeBulb.SpecularColor = Color.White;
                leftEyeBulb.Shininess     = 50;
                leftEyeBulb.ShowSurfaces  = true;
                // leftEyeBulb.Move(-0.1375, -0.403, 1.145);
                leftEyeBulb.ShadingModel = ShadingModel.Smooth;
                leftEyeBulb.UseLight     = true;
                leftEyeBulb.Name         = "LeftEye";
                leftEyeBulb.Object3DList = new List <Object3D>();

                SphereSegment3D leftEyeIris = new SphereSegment3D();
                leftEyeIris.Generate(new List <double>()
                {
                    0.07, 32, 32, Math.PI / 3
                });
                leftEyeIris.AmbientColor  = Color.Green;
                leftEyeIris.DiffuseColor  = Color.Green;
                leftEyeIris.SpecularColor = Color.White;
                leftEyeIris.Shininess     = 50;
                leftEyeIris.ShowSurfaces  = true;
                //   leftEyeIris.Move(-0.1375, -0.407, 0.145);
                leftEyeIris.Move(0, -0.005, 0);
                leftEyeIris.RotateX(90);
                SphereSegment3D leftEyePupil = new SphereSegment3D();
                leftEyePupil.Generate(new List <double>()
                {
                    0.07, 16, 32, Math.PI / 2 - 0.2
                });
                leftEyePupil.AmbientColor  = Color.Black;
                leftEyePupil.DiffuseColor  = Color.Black;
                leftEyePupil.SpecularColor = Color.White;
                leftEyePupil.Shininess     = 50;
                leftEyePupil.ShowSurfaces  = true;
                leftEyePupil.Move(0, -0.01, 0);
                leftEyePupil.RotateX(90); // , 0, 0);
                                          //   leftEyePupil.RotateX(Math.PI / 2);
                                          //  leftEyePupil.Translate(-0.1375, -0.4758, 0.0725);
                leftEyePupil.ShadingModel = ShadingModel.Smooth;
                leftEyePupil.UseLight     = true;
                SphereSegment3D leftEyeLid = new SphereSegment3D();
                leftEyeLid.Name = "LeftEyeLid";
                leftEyeLid.Generate(new List <double>()
                {
                    0.07, 32, 32, 0.0
                });
                leftEyeLid.AmbientColor  = Color.FromArgb(255, 205, 148); // Typical skin color approximation
                leftEyeLid.DiffuseColor  = Color.FromArgb(255, 205, 148); // Typical skin color approximation
                leftEyeLid.SpecularColor = Color.White;
                leftEyeLid.Shininess     = 50;
                leftEyeLid.ShowSurfaces  = true;
                leftEyeLid.RotateX(-36);
                leftEyeLid.Move(0, -0.015, 0);
                leftEyeBulb.Object3DList.Add(leftEyeIris);
                leftEyeBulb.Object3DList.Add(leftEyePupil);
                leftEyeBulb.Object3DList.Add(leftEyeLid);
                face.Object3DList.Add(leftEyeBulb);

                Sphere3D rightEyeBulb = new Sphere3D();
                rightEyeBulb.Generate(new List <double>()
                {
                    0.07, 64, 64
                });
                rightEyeBulb.AmbientColor  = Color.White;
                rightEyeBulb.DiffuseColor  = Color.White;
                rightEyeBulb.SpecularColor = Color.White;
                rightEyeBulb.Shininess     = 50;
                rightEyeBulb.ShowSurfaces  = true;
                //  rightEyeBulb.Move(0.1375, -0.403, 0.145);
                rightEyeBulb.ShadingModel = ShadingModel.Smooth;
                rightEyeBulb.UseLight     = true;
                rightEyeBulb.Name         = "RightEye";
                rightEyeBulb.Object3DList = new List <Object3D>();
                face.Object3DList.Add(rightEyeBulb);
                SphereSegment3D rightEyeIris = new SphereSegment3D();
                rightEyeIris.Generate(new List <double>()
                {
                    0.07, 32, 32, Math.PI / 3
                });
                rightEyeIris.AmbientColor  = Color.Green;
                rightEyeIris.DiffuseColor  = Color.Green;
                rightEyeIris.SpecularColor = Color.White;
                rightEyeIris.Shininess     = 50;
                rightEyeIris.ShowSurfaces  = true;
                rightEyeIris.RotateX(90); //  , 0, 0);
                rightEyeIris.Move(0, -0.005, 0);
                //   rightEyeIris.RotateX(Math.PI / 2);
                //   rightEyeIris.Translate(0.1375, -0.4715, 0.075);
                rightEyeIris.ShadingModel = ShadingModel.Smooth;
                rightEyeIris.UseLight     = true;
                SphereSegment3D rightEyePupil = new SphereSegment3D();
                rightEyePupil.Generate(new List <double>()
                {
                    0.07, 16, 32, Math.PI / 2 - 0.2
                });
                rightEyePupil.AmbientColor  = Color.Black;
                rightEyePupil.DiffuseColor  = Color.Black;
                rightEyePupil.SpecularColor = Color.White;
                rightEyePupil.Shininess     = 50;
                rightEyePupil.ShowSurfaces  = true;
                rightEyePupil.RotateX(90); //, 0, 0);
                rightEyePupil.Move(0, -0.01, 0);
                //  rightEyePupil.RotateX(Math.PI / 2);
                //  rightEyePupil.Translate(0.1375, -0.4758, 0.0725);
                rightEyePupil.ShadingModel = ShadingModel.Smooth;
                rightEyePupil.UseLight     = true;
                SphereSegment3D rightEyeLid = new SphereSegment3D();
                rightEyeLid.Name = "RightEyeLid";
                rightEyeLid.Generate(new List <double>()
                {
                    0.07, 32, 32, 0.0
                });
                rightEyeLid.AmbientColor  = Color.FromArgb(255, 205, 148); // Typical skin color approximation
                rightEyeLid.DiffuseColor  = Color.FromArgb(255, 205, 148); // Typical skin color approximation
                rightEyeLid.SpecularColor = Color.White;
                rightEyeLid.Shininess     = 50;
                rightEyeLid.ShowSurfaces  = true;
                rightEyeLid.RotateX(-36); // , 0, 0);
                rightEyeLid.Move(0, -0.015, 0);
                rightEyeBulb.Object3DList.Add(rightEyeIris);
                rightEyeBulb.Object3DList.Add(rightEyePupil);
                rightEyeBulb.Object3DList.Add(rightEyeLid);

                TorusSector3D leftEyebrow = new TorusSector3D();
                leftEyebrow.Name = "LeftEyebrow";
                leftEyebrow.Generate(new List <double> {
                    0.15, 0.01, 30, 30, 3 * Math.PI / 2 - 0.60, 3 * Math.PI / 2 + 0.40
                });
                leftEyebrow.AmbientColor  = Color.Black;
                leftEyebrow.DiffuseColor  = Color.Black;
                leftEyebrow.SpecularColor = Color.White;
                leftEyebrow.Shininess     = 50;
                leftEyebrow.ShowSurfaces  = true;
                leftEyebrow.RotateZ(-11);
                TorusSector3D rightEyebrow = new TorusSector3D();
                rightEyebrow.Name = "RightEyebrow";
                rightEyebrow.Generate(new List <double> {
                    0.15, 0.01, 30, 30, 3 * Math.PI / 2 - 0.60, 3 * Math.PI / 2 + 0.40
                });
                rightEyebrow.AmbientColor  = Color.Black;
                rightEyebrow.DiffuseColor  = Color.Black;
                rightEyebrow.SpecularColor = Color.White;
                rightEyebrow.Shininess     = 50;
                rightEyebrow.ShowSurfaces  = true;
                rightEyebrow.RotateZ(11);
                face.Object3DList.Add(leftEyebrow);
                face.Object3DList.Add(rightEyebrow);

                face.Move(0, 0, -0.5);
                leftEyeBulb.Move(-0.1375, -0.403, 0.645);
                rightEyeBulb.Move(0.1375, -0.403, 0.645);
                leftEyebrow.Move(-0.11, -0.325, 0.73);
                rightEyebrow.Move(0.11, -0.325, 0.73);

                // Close eyes to start with:
                leftEyeLid.RotateX(120);
                rightEyeLid.RotateX(120);
                leftEyebrow.Move(0, -0.005, -0.02);
                rightEyebrow.Move(0, -0.005, -0.02);
                eyesClosed = true;

                Scene3D scene = new Scene3D();
                Light   light = new Light();
                light.IsOn     = true;
                light.Position = new List <float>()
                {
                    0.0f, -3.0f, 1f, 1.0f
                };
                scene.LightList.Add(light);
                scene.AddObject(face);
                viewer3D.Scene           = scene;
                viewer3D.ShowWorldAxes   = false; // true;
                viewer3D.CameraDistance  = 0.8;
                viewer3D.CameraLatitude  = Math.PI / 24;
                viewer3D.CameraLongitude = -Math.PI / 2;
                //  viewer3D.Invalidate();
                viewer3D.StartAnimation();
            }

            normalThreadRunning = true;
            normalThread        = new Thread(new ThreadStart(NormalLoop));
            normalThread.Start();
        }
Ejemplo n.º 13
0
        public static void DoStarsEffect(
            this FireworkStars fx, IPoint3D p, Map map, int radius, int sound, int[] stars, int[] hues)
        {
            if (fx == FireworkStars.None || stars == null || stars.Length == 0)
            {
                return;
            }

            radius = Math.Max(0, Math.Min(10, radius));

            if (hues.Length == 0)
            {
                hues = new int[9];

                hues.SetAll(i => Utility.RandomBrightHue());
            }

            switch (fx)
            {
            case FireworkStars.Peony:
            {
                var shape = new Sphere3D(p, radius, true);

                shape.ForEach(
                    b =>
                    new MovingEffectInfo(
                        p, b, map, stars.GetRandom(), hues.GetRandom(), Utility.RandomMinMax(4, 6), EffectRender.LightenMore)
                    .MovingImpact(
                        e =>
                    {
                        if (sound > 0 && Utility.RandomDouble() <= 0.25)
                        {
                            Effects.PlaySound(b, map, sound);
                        }
                    }));
            }
            break;

            case FireworkStars.Chrysanthemum:
            {
                var shape = new Disc3D(p, radius, false);

                shape.ForEach(
                    b =>
                    new MovingEffectInfo(
                        p, b, map, stars.GetRandom(), hues.GetRandom(), Utility.RandomMinMax(4, 6), EffectRender.LightenMore)
                    .MovingImpact(
                        e =>
                    {
                        if (sound > 0 && Utility.RandomDouble() <= 0.25)
                        {
                            Effects.PlaySound(b, map, sound);
                        }
                    }));
            }
            break;

            case FireworkStars.Dahlia:
            {
                var shape = new Cylendar3D(p, radius, true, false);

                shape.ForEach(
                    b =>
                    new MovingEffectInfo(
                        p, b, map, stars.GetRandom(), hues.GetRandom(), Utility.RandomMinMax(6, 8), EffectRender.LightenMore)
                    .MovingImpact(
                        e =>
                    {
                        if (sound > 0 && Utility.RandomDouble() <= 0.25)
                        {
                            Effects.PlaySound(b, map, sound);
                        }
                    }));
            }
            break;

            case FireworkStars.Willow:
            {
                var shape = new Disc3D(p, radius, true);

                shape.ForEach(
                    b =>
                    new MovingEffectInfo(
                        p, b, map, stars.GetRandom(), hues.GetRandom(), Utility.RandomMinMax(6, 8), EffectRender.LightenMore)
                    .MovingImpact(
                        e =>
                    {
                        if (Utility.RandomDouble() < 0.66)
                        {
                            return;
                        }

                        int zL = b.Z;
                        int zR = b.GetWorldTop(map).Z;

                        if (zL <= zR || zL < p.Z)
                        {
                            return;
                        }

                        int zDiff = zL - zR;

                        if (zDiff < 30)
                        {
                            return;
                        }

                        Point3D t = b.Clone3D(0, 0, -(zDiff / 2));

                        new MovingEffectInfo(b, t, map, e.EffectID, e.Hue, Math.Max(1, e.Speed / 2), e.Render).Send();

                        if (sound > 0 && Utility.RandomDouble() <= 0.25)
                        {
                            Effects.PlaySound(b, map, sound);
                        }
                    }));
            }
            break;

            case FireworkStars.BloomFlower:
            {
                var shape = new Ring3D(p, radius);

                shape.ForEach(
                    b =>
                    new MovingEffectInfo(
                        p, b, map, stars.GetRandom(), hues.GetRandom(), Utility.RandomMinMax(6, 8), EffectRender.LightenMore)
                    .MovingImpact(
                        e =>
                    {
                        if (Utility.RandomDouble() < 0.66)
                        {
                            return;
                        }

                        Point3D t = b.Clone3D(Utility.RandomMinMax(-3, 3), Utility.RandomMinMax(-3, 3), Utility.RandomMinMax(-10, 10));

                        new MovingEffectInfo(b, t, map, e.EffectID, e.Hue, e.Speed, e.Render).Send();

                        if (sound > 0 && Utility.RandomDouble() <= 0.25)
                        {
                            Effects.PlaySound(b, map, sound);
                        }
                    }));
            }
            break;

            case FireworkStars.Ring:
            {
                var shape = new Ring3D(p, radius);

                shape.ForEach(
                    b =>
                    new MovingEffectInfo(
                        p, b, map, stars.GetRandom(), hues.GetRandom(), Utility.RandomMinMax(6, 8), EffectRender.LightenMore)
                    .MovingImpact(
                        e =>
                    {
                        int zL = b.Z;
                        int zR = b.GetWorldTop(map).Z;

                        if (zL <= zR || zL < p.Z)
                        {
                            return;
                        }

                        int zDiff = zL - zR;

                        if (zDiff < 30)
                        {
                            return;
                        }

                        Point3D t = b.Clone3D(0, 0, -(zDiff / 2));

                        new MovingEffectInfo(b, t, map, e.EffectID, e.Hue, 2, e.Render).Send();

                        if (sound > 0 && Utility.RandomDouble() <= 0.25)
                        {
                            Effects.PlaySound(b, map, sound);
                        }
                    }));
            }
            break;

            case FireworkStars.Crossette:
            {
                var shape = new Plane3D(p, radius, true);

                shape.ForEach(
                    b =>
                    new MovingEffectInfo(
                        p, b, map, stars.GetRandom(), hues.GetRandom(), Utility.RandomMinMax(6, 8), EffectRender.LightenMore)
                    .MovingImpact(
                        e =>
                    {
                        if (Utility.RandomDouble() < 0.33)
                        {
                            return;
                        }

                        Point3D t = b.Clone3D(Utility.RandomMinMax(-5, 5), Utility.RandomMinMax(-5, 5));

                        new MovingEffectInfo(b, t, map, e.EffectID, e.Hue, e.Speed, e.Render).Send();

                        if (sound > 0 && Utility.RandomDouble() <= 0.25)
                        {
                            Effects.PlaySound(b, map, sound);
                        }
                    }));
            }
            break;
            }
        }
Ejemplo n.º 14
0
        public override void CheckKeyBoard()
        {
            base.CheckKeyBoard();


            if (GameWindow.Keyboard[Key.F10] && coolDown == 0)
            {
                Bitmap bitmapScreenShot = Tools.GrabScreenshot(GameWindow);

                bitmapScreenShot.Save("ScreenShots\\screenshot.bmp");

                coolDown = 20;
            }

            if (GameWindow.Keyboard[Key.Space] && coolDown == 0)
            {
                Shapes3D["pointSprites"].Position =
                    new Vector3(0, 50, 0);
                coolDown = 20;
            }

            if (GameWindow.Keyboard[Key.F] && coolDown == 0)
            {
                Shapes3D["sphereEnvCubeMap"].Position =
                    new Vector3(TargetPosition.X,
                                0.05f,
                                TargetPosition.Y);
                coolDown = 20;
            }

            if (GameWindow.Keyboard[Key.C] && coolDown == 0)
            {
                File.WriteAllText("cmera.txt",
                                  "position: " + Camera.Position +
                                  "quaternion: " + Camera.Quaternion);
                coolDown = 20;
            }

            if (GameWindow.Keyboard[Key.F11] && coolDown == 0)
            {
                Audio.Play(2, Vector3.Zero, true);
                coolDown = 20;
            }

            if (GameWindow.Keyboard[Key.F12] && coolDown == 0)
            {
                MyGame.Debug  = String.Empty;
                MyGame.Debug1 = String.Empty;
                coolDown      = 5;
            }

            if (GameWindow.Keyboard[Key.F3] && coolDown == 0)
            {
                TextRender.Visible = !TextRender.Visible;
                coolDown           = 10;
            }

            if (GameWindow.Keyboard[Key.F1] && coolDown == 0)
            {
                Vector3 v1 = new Vector3(Camera.CameraUVW.Row0);
                Vector3 v2 = new Vector3(Camera.CameraUVW.Row0.X,
                                         0f, Camera.CameraUVW.Row0.Z);

                v2.Normalize();

                float CameraUangle = Vector3.Dot(v2, v1);

                Vector3 axis = new Vector3(Camera.CameraUVW.Row2.X,
                                           Camera.CameraUVW.Row2.Y,
                                           Camera.CameraUVW.Row2.Z);

                float angle = (float)Math.Acos(Convert.ToDouble(CameraUangle));

                if (Camera.CameraUVW.Row0.Y > 0)
                {
                    Camera.Rotate(axis, angle);
                }
                else
                {
                    Camera.Rotate(axis, -angle);
                }


                coolDown = 20;
            }



            if (GameWindow.Keyboard[Key.I] &&
                (MyGame.TableXAngle < MathHelper.
                 DegreesToRadians(MyGame.MaxTableAngle)))
            {
                MyGame.TableXAngle += MyGame.DeltaTableAngle;
            }

            if (GameWindow.Keyboard[Key.K] &&
                (MyGame.TableXAngle > -MathHelper.
                 DegreesToRadians(MyGame.MaxTableAngle)))
            {
                MyGame.TableXAngle -= MyGame.DeltaTableAngle;
            }

            if (GameWindow.Keyboard[Key.J] &&
                (MyGame.TableZAngle < MathHelper.
                 DegreesToRadians(MyGame.MaxTableAngle)))
            {
                MyGame.TableZAngle += MyGame.DeltaTableAngle;
            }

            if (GameWindow.Keyboard[Key.L] &&
                (MyGame.TableZAngle > -MathHelper.
                 DegreesToRadians(MyGame.MaxTableAngle)))
            {
                MyGame.TableZAngle -= MyGame.DeltaTableAngle;
            }

            if (GameWindow.Keyboard[Key.Q])
            {
                Camera.TranslateLC(0, 0, 5f);
            }
            if (GameWindow.Keyboard[Key.A])
            {
                Camera.TranslateLC(0, 0, -5f);
            }


            if (GameWindow.Keyboard[Key.X])
            {
                Camera.Position = new Vector3(Camera.Position.X,
                                              -5f + Camera.Position.Y,
                                              Camera.Position.Z);
            }

            if (GameWindow.Keyboard[Key.LShift])
            {
                Camera.Position = new Vector3(Camera.Position.X,
                                              5f + Camera.Position.Y,
                                              Camera.Position.Z);
            }

            float speed = 2f;

            if (GameWindow.Keyboard[Key.Keypad8] && coolDown == 0)
            {
                Shapes3D["sphereEnvCubeMap"].Physic.Vuvw
                    = new Vector3(Shapes3D["sphereEnvCubeMap"].Physic.Vuvw.X,
                                  Shapes3D["sphereEnvCubeMap"].Physic.Vuvw.Y,
                                  -speed);

                coolDown = 5;
            }
            if (GameWindow.Keyboard[Key.Keypad2] && coolDown == 0)
            {
                Shapes3D["sphereEnvCubeMap"].Physic.Vuvw =
                    new Vector3(0, 0, speed);

                coolDown = 5;
            }
            if (GameWindow.Keyboard[Key.Keypad4] && coolDown == 0)
            {
                Shapes3D["sphereEnvCubeMap"].Physic.Vxyz =
                    new Vector3(-speed, 0, 0);

                coolDown = 5;
            }
            if (GameWindow.Keyboard[Key.Keypad6] && coolDown == 0)
            {
                Shapes3D["sphereEnvCubeMap"].Physic.Vxyz =
                    new Vector3(speed, 0, 0);

                coolDown = 5;
            }


            if (GameWindow.Keyboard[Key.Number6] && coolDown == 0)
            {
                ShadowMap.LightView.TranslateWC(-10, 0, 0);
                ShadowMap.UpdateView();

                Shapes3D["sphereEnvCubeMap"].ShadowMatrix =
                    ShadowMap.ShadowMatrix;

                coolDown = 30;
            }
            if (GameWindow.Keyboard[Key.Number7] && coolDown == 0)
            {
                ShadowMap.LightView.TranslateWC(10, 0, 0);
                ShadowMap.UpdateView();

                Shapes3D["sphereEnvCubeMap"].ShadowMatrix =
                    ShadowMap.ShadowMatrix;

                coolDown = 30;
            }



            if (GameWindow.Keyboard[Key.KeypadPlus] && coolDown == 0)
            {
                Vector4 tempV4 = new Vector4(SunLightPosition.X,
                                             SunLightPosition.Y,
                                             SunLightPosition.Z,
                                             0);
                tempV4 = Vector4.Transform(tempV4, Matrix4.CreateRotationY(0.05f));

                SunLightPosition = tempV4.Xyz;
            }
            if (GameWindow.Keyboard[Key.KeypadMinus] && coolDown == 0)
            {
                Vector4 tempV4 = new Vector4(SunLightPosition.X,
                                             SunLightPosition.Y,
                                             SunLightPosition.Z,
                                             0);
                tempV4 = Vector4.Transform(tempV4, Matrix4.CreateRotationY(-0.05f));

                SunLightPosition = tempV4.Xyz;
            }

            if (GameWindow.Keyboard[Key.KeypadMultiply] && coolDown == 0)
            {
                CubesHaveNormalMap = !CubesHaveNormalMap;
                coolDown           = 10;
            }

            if (GameWindow.Keyboard[Key.KeypadDecimal] && coolDown == 0)
            {
                Shapes3D.Remove("sphereEnvCubeMap");

                ToggleSmooth = !ToggleSmooth;

                Shape3D sphere1 = new Sphere3D(new Vector3(-45f, 1.5f, -45f), 1.5f,
                                               Color4.Gold, Textures["sphere_texture"], ToggleSmooth);
                sphere1.Physic.Mass      = 10f;
                sphere1.Physic.Vxyz      = Vector3.Zero;
                sphere1.ShadowMatrix     = ShadowMap.ShadowMatrix;
                sphere1.TextureShadowMap = ShadowMap.DepthTexture;
                sphere1.Bounding.R       = 1.5f;
                sphere1.Load();
                Shapes3D.Add("sphereEnvCubeMap", sphere1);



                coolDown = 10;
            }

            if (GameWindow.Keyboard[Key.M] && coolDown == 0)
            {
                MyGame.MultiView = !MyGame.MultiView;

                if (MyGame.MultiView)
                {
                    MyGame.Width  = 800;
                    MyGame.Height = (int)(MyGame.Width / aspectRatio);
                }
                else
                {
                    MyGame.Width  = GameWindow.Width;
                    MyGame.Height = GameWindow.Height;
                }

                MyGame.ProjectionMatrix =
                    Matrix4.CreatePerspectiveFieldOfView(
                        MathHelper.PiOver4,
                        MyGame.Width / (float)MyGame.Height,
                        0.5f,
                        1000f);

                //ShadowMap.ProjectionMatrixLightView = MyGame.ProjectionMatrix;
                ShadowMap.UpdateView();

                foreach (var item in Shapes3D)
                {
                    item.Value.ShadowMatrix = ShadowMap.ShadowMatrix;
                }

                coolDown = 30;
            }
            //if (Keyboard[Key.S]) Shapes3D["sphere"].
            //        VertexBuffer.SerializeBufer(@"Models\sphere.xml");

            if (GameWindow.Keyboard[Key.T])
            {
                Tools.
                GenerateModelFrom3DS(@"Models\sphere3D.x3d");
            }
        }
Ejemplo n.º 15
0
        private void Initialize()
        {
            randomNumberGenerator = new Random();
            string faceFileName  = Path.GetDirectoryName(Application.ExecutablePath) + FROG_RELATIVE_FACE_FILE_NAME;
            string mouthFileName = Path.GetDirectoryName(Application.ExecutablePath) + FROG_RELATIVE_MOUTH_FILE_NAME;
            string eyeFileName   = Path.GetDirectoryName(Application.ExecutablePath) + FROG_RELATIVE_EYE_FILE_NAME;

            if (File.Exists(faceFileName))
            {
                face      = (Face)ObjectSerializerLibrary.ObjectXmlSerializer.ObtainSerializedObject(faceFileName, typeof(Face));
                face.Name = "Face";
                face.Generate(new List <double> {
                    128
                });
                face.Visible       = true;
                face.SpecularColor = Color.White;
                face.Shininess     = 50;
                face.AmbientColor  = Color.Green;
                // A lot of ugly hard-coding here, but OK - just for demonstration:
                face.Object3DList = new List <Object3D>();

                SphereSegment3D mouth = new SphereSegment3D();
                mouth.Name = "Mouth";
                mouth.Generate(new List <double>()
                {
                    0.85, 16, 16, 0.3
                });
                mouth.AmbientColor  = Color.White;
                mouth.DiffuseColor  = Color.White;
                mouth.SpecularColor = Color.White;
                mouth.RotateX(180);
                mouth.Shininess    = 50;
                mouth.ShowSurfaces = true;
                //mouth.RotateX(-36);
                mouth.Move(0, -0.1f, 0.85f);
                face.Object3DList.Add(mouth);



                #region generateLeftEye
                Sphere3D leftEyeBulb = new Sphere3D();
                leftEyeBulb.Generate(new List <double>()
                {
                    0.20, 64, 64
                });
                leftEyeBulb.AmbientColor  = Color.Yellow;
                leftEyeBulb.DiffuseColor  = Color.White;
                leftEyeBulb.SpecularColor = Color.White;
                leftEyeBulb.Shininess     = 50;
                leftEyeBulb.ShowSurfaces  = true;
                // x z y
                leftEyeBulb.Move(-0.60, 0.34, 0.29);
                leftEyeBulb.ShadingModel = ShadingModel.Smooth;
                leftEyeBulb.UseLight     = true;
                leftEyeBulb.Name         = "LeftEye";
                leftEyeBulb.Object3DList = new List <Object3D>();


                SphereSegment3D leftEyePupil = new SphereSegment3D();
                leftEyePupil.Generate(new List <double>()
                {
                    0.25, 16, 32, Math.PI / 2 - 0.2
                });
                leftEyePupil.AmbientColor  = Color.Black;
                leftEyePupil.DiffuseColor  = Color.Black;
                leftEyePupil.SpecularColor = Color.White;
                leftEyePupil.Shininess     = 50;
                leftEyePupil.ShowSurfaces  = true;
                leftEyePupil.Move(0, 0.05, 0);
                leftEyePupil.RotateX(90); // , 0, 0);
                                          //   leftEyePupil.RotateX(Math.PI / 2);
                                          //  leftEyePupil.Translate(-0.1375, -0.4758, 0.0725);
                leftEyePupil.ShadingModel = ShadingModel.Smooth;
                leftEyePupil.UseLight     = true;


                SphereSegment3D leftEyePupilExtended = new SphereSegment3D();
                leftEyePupilExtended.Generate(new List <double>()
                {
                    0.25, 16, 32, Math.PI / 2 - 0.2
                });
                leftEyePupilExtended.AmbientColor  = Color.Black;
                leftEyePupilExtended.DiffuseColor  = Color.Black;
                leftEyePupilExtended.SpecularColor = Color.White;
                leftEyePupilExtended.Shininess     = 50;
                leftEyePupilExtended.ShowSurfaces  = true;
                leftEyePupilExtended.Move(0, 0.05, 0);
                leftEyePupilExtended.RotateZ(13);
                leftEyePupilExtended.RotateX(87); // , 0, 0);
                //   leftEyePupilExtended.RotateX(Math.PI / 2);
                //  leftEyePupilExtended.Translate(-0.1375, -0.4758, 0.0725);
                leftEyePupilExtended.ShadingModel = ShadingModel.Smooth;
                leftEyePupilExtended.UseLight     = true;


                SphereSegment3D leftEyeLid = new SphereSegment3D();
                leftEyeLid.Name = "LeftEyeLid";
                leftEyeLid.Generate(new List <double>()
                {
                    0.21, 32, 32, 0.0
                });
                leftEyeLid.AmbientColor  = Color.Green; // Typical skin color approximation
                leftEyeLid.DiffuseColor  = Color.Green; // Typical skin color approximation
                leftEyeLid.SpecularColor = Color.White;
                leftEyeLid.Shininess     = 50;
                leftEyeLid.ShowSurfaces  = true;
                leftEyeLid.RotateX(0);
                leftEyeLid.Move(0, 0, 0);
                leftEyeBulb.Object3DList.Add(leftEyePupil);
                leftEyeBulb.Object3DList.Add(leftEyePupilExtended);
                leftEyeBulb.Object3DList.Add(leftEyeLid);
                face.Object3DList.Add(leftEyeBulb);


                SphereSegment3D lowerLeftEyeLid = new SphereSegment3D();
                lowerLeftEyeLid.Name = "LowerLeftEyeLid";
                lowerLeftEyeLid.Generate(new List <double>()
                {
                    0.21, 32, 32, 0.0
                });
                lowerLeftEyeLid.AmbientColor  = Color.Green; // Typical skin color approximation
                lowerLeftEyeLid.DiffuseColor  = Color.Green; // Typical skin color approximation
                lowerLeftEyeLid.SpecularColor = Color.White;
                lowerLeftEyeLid.Shininess     = 50;
                lowerLeftEyeLid.ShowSurfaces  = true;
                lowerLeftEyeLid.RotateX(0);
                lowerLeftEyeLid.RotateY(180);
                lowerLeftEyeLid.Move(0, 0, 0);
                leftEyeBulb.Object3DList.Add(lowerLeftEyeLid);

                //face.Object3DList.Add(leftEyeBulb);
                #endregion
                #region generateRightEye
                Sphere3D rightEyeBulb = new Sphere3D();
                rightEyeBulb.Generate(new List <double>()
                {
                    0.20, 64, 64
                });
                rightEyeBulb.AmbientColor  = Color.Yellow;
                rightEyeBulb.DiffuseColor  = Color.White;
                rightEyeBulb.SpecularColor = Color.White;
                rightEyeBulb.Shininess     = 50;
                rightEyeBulb.ShowSurfaces  = true;
                // x z y
                rightEyeBulb.Move(0.60, 0.34, 0.29);
                rightEyeBulb.ShadingModel = ShadingModel.Smooth;
                rightEyeBulb.UseLight     = true;
                rightEyeBulb.Name         = "RightEye";
                rightEyeBulb.Object3DList = new List <Object3D>();


                SphereSegment3D rightEyePupil = new SphereSegment3D();
                rightEyePupil.Generate(new List <double>()
                {
                    0.25, 16, 32, Math.PI / 2 - 0.2
                });
                rightEyePupil.AmbientColor  = Color.Black;
                rightEyePupil.DiffuseColor  = Color.Black;
                rightEyePupil.SpecularColor = Color.White;
                rightEyePupil.Shininess     = 50;
                rightEyePupil.ShowSurfaces  = true;
                rightEyePupil.Move(0, 0.05, 0);
                rightEyePupil.RotateX(90); // , 0, 0);
                                           //   rightEyePupil.RotateX(Math.PI / 2);
                                           //  rightEyePupil.Translate(-0.1375, -0.4758, 0.0725);
                rightEyePupil.ShadingModel = ShadingModel.Smooth;
                rightEyePupil.UseLight     = true;


                SphereSegment3D rightEyePupilExtended = new SphereSegment3D();
                rightEyePupilExtended.Generate(new List <double>()
                {
                    0.25, 16, 32, Math.PI / 2 - 0.2
                });
                rightEyePupilExtended.AmbientColor  = Color.Black;
                rightEyePupilExtended.DiffuseColor  = Color.Black;
                rightEyePupilExtended.SpecularColor = Color.White;
                rightEyePupilExtended.Shininess     = 50;
                rightEyePupilExtended.ShowSurfaces  = true;
                rightEyePupilExtended.Move(0, 0.05, 0);
                rightEyePupilExtended.RotateZ(13);
                rightEyePupilExtended.RotateX(93); // , 0, 0);
                                                   //   rightEyePupilExtended.RotateX(Math.PI / 2);
                                                   //  rightEyePupilExtended.Translate(-0.1375, -0.4758, 0.0725);
                rightEyePupilExtended.ShadingModel = ShadingModel.Smooth;
                rightEyePupilExtended.UseLight     = true;


                SphereSegment3D rightEyeLid = new SphereSegment3D();
                rightEyeLid.Name = "RightEyeLid";
                rightEyeLid.Generate(new List <double>()
                {
                    0.21, 32, 32, 0.0
                });
                rightEyeLid.AmbientColor  = Color.Green; // Typical skin color approximation
                rightEyeLid.DiffuseColor  = Color.Green; // Typical skin color approximation
                rightEyeLid.SpecularColor = Color.White;
                rightEyeLid.Shininess     = 50;
                rightEyeLid.ShowSurfaces  = true;
                rightEyeLid.RotateX(0);
                rightEyeLid.Move(0, 0, 0);
                rightEyeBulb.Object3DList.Add(rightEyePupil);
                rightEyeBulb.Object3DList.Add(rightEyePupilExtended);
                rightEyeBulb.Object3DList.Add(rightEyeLid);
                face.Object3DList.Add(rightEyeBulb);


                SphereSegment3D lowerRightEyeLid = new SphereSegment3D();
                lowerRightEyeLid.Name = "LowerRightEyeLid";
                lowerRightEyeLid.Generate(new List <double>()
                {
                    0.21, 32, 32, 0.0
                });
                lowerRightEyeLid.AmbientColor  = Color.Green; // Typical skin color approximation
                lowerRightEyeLid.DiffuseColor  = Color.Green; // Typical skin color approximation
                lowerRightEyeLid.SpecularColor = Color.White;
                lowerRightEyeLid.Shininess     = 50;
                lowerRightEyeLid.ShowSurfaces  = true;
                lowerRightEyeLid.RotateX(0);
                lowerRightEyeLid.RotateY(180);
                lowerRightEyeLid.Move(0, 0, 0);
                rightEyeBulb.Object3DList.Add(lowerRightEyeLid);

                #endregion
                face.Move(0, 0, -0.5);
                leftEyeBulb.Move(-0.1375, -0.403, 0.645);
                rightEyeBulb.Move(0.1375, -0.403, 0.645);

                // Close eyes to start with:
                leftEyeLid.RotateX(0);
                rightEyeLid.RotateX(0);
                eyesClosed = true;


                Scene3D scene = new Scene3D();
                Light   light = new Light();
                light.IsOn     = true;
                light.Position = new List <float>()
                {
                    0.0f, -3.0f, 1f, 1.0f
                };
                scene.LightList.Add(light);
                scene.AddObject(face);



                viewer3D.Scene           = scene;
                viewer3D.ShowWorldAxes   = false; // true;
                viewer3D.CameraDistance  = 1.8;
                viewer3D.CameraLatitude  = 0.3;
                viewer3D.CameraLongitude = -1.3; //-Math.PI / 2;

                //viewer3D.Invalidate();

                viewer3D.StartAnimation();
            }

            normalThreadRunning = true;
            normalThread        = new Thread(new ThreadStart(NormalLoop));
            normalThread.Start();
        }
Ejemplo n.º 16
0
        public static Dictionary <string, Shape3D> LoadShapes(ShadowMap shadowMap, MyGameLevel gameLevel)
        {
            Dictionary <string, Shape3D> shapes3D = new Dictionary <string, Shape3D>();

            //float deltaRot = MathHelper.PiOver6 / 20;

            shadowMapG = shadowMap;

            //textures
            current_texture = gameLevel.Textures["current_texture"];

            int cube_texture = gameLevel.Textures["cube_texture"];

            sphere_texture = gameLevel.Textures["sphere_texture"];

            int sky_texture = gameLevel.Textures["sky_texture"];

            bump_texture = gameLevel.Textures["bump_texture"];

            int target_texture = gameLevel.Textures["target_texture"];


            // create texture matrix
            Matrix4 ProjectionMatrixTex = Matrix4.CreateOrthographic(110, 110, -1, 1);

            Matrix4 ScaleBiasMatrix = new Matrix4(new Vector4(0.5f, 0.0f, 0.0f, 0.0f),
                                                  new Vector4(0.0f, 0.5f, 0.0f, 0.0f),
                                                  new Vector4(0.0f, 0.0f, 0.5f, 0.0f),
                                                  new Vector4(0.5f, 0.5f, 0.5f, 1f));

            Matrix4 texMatrix = ProjectionMatrixTex * ScaleBiasMatrix;

            Camera tex = new Camera();

            tex.Position = new Vector3(0, -10, 0);
            tex.Rotate(new Vector3(tex.CameraUVW.Row0), MathHelper.PiOver2);

            tex.Update();

            texMatrix  = tex.View * texMatrix;
            texMatrixG = texMatrix;

            #region panels

            Shape3D basePanel = new Panel3D(new Vector3(0f, 0f, 0), 0f, 0f, 0f, Color4.Chocolate, current_texture);

            // initialize shaders
            string vs = File.ReadAllText("Shaders\\vShader_UV_Normal_panel.txt");
            string fs = File.ReadAllText("Shaders\\fShader_UV_Normal_panel_base.txt");
            Shader shaderBasePanel = new Shader(ref vs, ref fs, basePanel);
            basePanel.Shader = shaderBasePanel;
            basePanel.Scale(55);
            //basePanel.Bounding = new Bounding(basePanel, 100, 1, 100);
            basePanel.Physic.Mass = 100000000f;
            basePanel.RotateU(-MathHelper.PiOver2);
            //basePanel.Position = new Vector3(0f, -20f, 0f);
            basePanel.TextureShadowMap     = shadowMap.DepthTexture;
            basePanel.ShadowMatrix         = shadowMap.ShadowMatrix;
            basePanel.TextureBumpMap       = bump_texture;
            basePanel.TexMatrix            = texMatrix;
            basePanel.Collision            = false;
            basePanel.Material.HasSpecular = false;
            basePanel.Load();
            shapes3D.Add("basePanel", basePanel);



            /*
             * Shape3D leftPanel = new Panel3D(Vector3.Zero, 0f, 0f, 0f, Color4.Chocolate, current_texture);
             * leftPanel.Scale(2, 52, 0);
             * leftPanel.RotateZ(-MathHelper.PiOver2);
             * leftPanel.RotateY(MathHelper.PiOver2);
             *
             * leftPanel.Position = new Vector3(-52, 2, 0);
             * leftPanel.TextureShadowMap = shadowMap.DepthTexture;
             * leftPanel.TexMatrix = texMatrix;
             * leftPanel.Collision = false;
             * leftPanel.Load();
             * shapes3D.Add("leftPanel", leftPanel);
             *
             * Shape3D rightPanel = new Panel3D(Vector3.Zero, 0f, 0f, 0f, Color4.Chocolate, current_texture);
             * rightPanel.Scale(2, 52, 0);
             * rightPanel.RotateZ(-MathHelper.PiOver2);
             * rightPanel.RotateY(-MathHelper.PiOver2);
             *
             * rightPanel.Position = new Vector3(52, 2, 0);
             * rightPanel.TextureShadowMap = shadowMap.DepthTexture;
             * rightPanel.TexMatrix = texMatrix;
             * rightPanel.Collision = false;
             * rightPanel.Load();
             * shapes3D.Add("rightPanel", rightPanel);
             *
             * Shape3D topPanel = new Panel3D(Vector3.Zero, 0f, 0f, 0f, Color4.Chocolate, current_texture);
             * topPanel.Scale(52, 2, 0);
             * //topPanel.RotateZ(-MathHelper.PiOver2);
             * //topPanel.RotateY(-MathHelper.PiOver2);
             *
             * topPanel.Position = new Vector3(0, 2, -52);
             * topPanel.TextureShadowMap = shadowMap.DepthTexture;
             * topPanel.TexMatrix = texMatrix;
             * topPanel.Collision = false;
             * topPanel.Load();
             * shapes3D.Add("topPanel", topPanel);
             *
             * Shape3D bottomPanel = new Panel3D(Vector3.Zero, 0f, 0f, 0f, Color4.Black);
             * bottomPanel.Scale(52, 2, 0);
             * //topPanel.RotateZ(-MathHelper.PiOver2);
             * //topPanel.RotateY(-MathHelper.PiOver2);
             *
             * bottomPanel.Position = new Vector3(0, 2, 52);
             * //bottomPanel.TextureShadowMap = shadowMap.DepthTexture;
             * bottomPanel.Collision = false;
             * bottomPanel.Load();
             * shapes3D.Add("bottomPanel", bottomPanel);
             */
            #endregion

            /*
             * Shape3D sphere1 = new Sphere3D(new Vector3(20f, 2f, 5f), 2, Color4.Gold, sphere_texture);
             * //sphere.Scale(10f);
             * sphere1.Physic.Mass = 10f;
             * sphere1.Physic.Vuvw = new Vector3(-0.05f, 0f, 0.0f);
             * //sphere1.Physic.AVuvw = new Vector3(0, 0, sphere1.Physic.Vuvw.X / 2);
             * sphere1.TextureShadowMap = shadowMap.DepthTexture;
             * sphere1.Load();
             * shapes3D.Add("sphere1", sphere1);
             *
             * Shape3D sphere2 = new Sphere3D(new Vector3(10f, 2f, 5f), 2, Color4.Gold, sphere_texture);
             * //sphere.Scale(10f);
             * sphere2.Physic.Mass = 10f;
             * sphere2.Physic.Vuvw = new Vector3(0.05f, 0f, 0.0f);
             * sphere2.TextureShadowMap = shadowMap.DepthTexture;
             * sphere2.Load();
             * shapes3D.Add("sphere2", sphere2);
             *
             * Shape3D sphere3 = new Sphere3D(new Vector3(0f, 2f, 0f), 2, Color4.Gold, sphere_texture);
             * //sphere3.Scale(3f);
             * sphere3.Physic.Mass = 1000000000f;
             * //sphere3.Bounding = new Bounding(sphere3, 20, 20, 20);
             * sphere3.Physic.Vuvw = new Vector3(0.0f, 0f, 0.0f);
             * sphere3.TextureShadowMap = shadowMap.DepthTexture;
             * sphere3.Load();
             * shapes3D.Add("sphere3", sphere3);
             */

            Shape3D target =
                new Panel3D(new Vector3(gameLevel.TargetPosition.X,
                                        0.05f,
                                        gameLevel.TargetPosition.Y),
                            0f, 0f, 0f,
                            Color4.Chocolate,
                            target_texture);
            string vst          = File.ReadAllText("Shaders\\vShader_UV_Normal_panel.txt");
            string fst          = File.ReadAllText("Shaders\\fShader_UV_Normal_panel_.txt");
            Shader shaderTarget = new Shader(ref vst, ref fst, target);
            target.Shader = shaderTarget;
            target.Scale(3f);
            target.Bounding    = new Bounding(target, 3f);
            target.Physic.Mass = 100000000f;
            target.RotateU(-MathHelper.PiOver3);
            target.TextureShadowMap = shadowMap.DepthTexture;
            target.ShadowMatrix     = shadowMap.ShadowMatrix;
            //target.TextureBumpMap = bump_texture;
            //target.TexMatrix = texMatrix;
            target.Collision      = true;
            target.IsShadowCaster = false;
            target.Load();
            shapes3D.Add("target", target);

            string[] lines =
                File.ReadAllLines("levels\\" + gameLevel.Name + ".csv");

            foreach (var item in lines)
            {
                string[] lineStrings = item.Split(';');
                int      xBlock      = Convert.ToInt32(lineStrings[0]);
                int      yBlock      = Convert.ToInt32(lineStrings[1]);
                string   blockName   = lineStrings[2];

                insertBlocks(xBlock, yBlock, blockName, shapes3D);
            }

            /*
             * Shape3D cube = new NRCGL.Shapes.Cube3D(new Vector3(-48f, 6f, 48f), Color4.AliceBlue, current_texture);
             * cube.Physic.Mass = 100;
             * cube.Physic.Vxyz = Vector3.Zero;
             * cube.Bounding = new Bounding(cube, 20, 2, 20);
             * cube.Scale(2, 6, 2);
             * cube.TextureShadowMap = shadowMap.DepthTexture;
             * cube.TexMatrix = texMatrix;
             * cube.Load();
             * shapes3D.Add("cube", cube);
             */
            Shape3D skyBox = new NRCGL.Shapes.SkyBox(new Vector3(-30f, 50f, 30f), Color4.AliceBlue, sky_texture);
            skyBox.Scale(500);
            skyBox.Collision = false;
            skyBox.Load();
            shapes3D.Add("skyBox", skyBox);

            /*
             * Shape3D shpereEnvCubeMap = new Sphere3DEnvCubeMap(new Vector3(-45f, 1f, -45f), 1f);
             * shpereEnvCubeMap.Physic.Mass = 10f;
             * shpereEnvCubeMap.Physic.Vxyz = Vector3.Zero;
             * shpereEnvCubeMap.ShadowMatrix = shadowMap.ShadowMatrix;
             * shpereEnvCubeMap.Load();
             * shapes3D.Add("sphereEnvCubeMap", shpereEnvCubeMap);
             */
            Shape3D sphere1 = new Sphere3D(new Vector3(-45f, 1.5f, -45f), 1.5f, Color4.Gold, sphere_texture);
            sphere1.Physic.Mass      = 10f;
            sphere1.Physic.Vxyz      = Vector3.Zero;
            sphere1.ShadowMatrix     = shadowMap.ShadowMatrix;
            sphere1.TextureShadowMap = shadowMap.DepthTexture;
            sphere1.Bounding.R       = 1.5f;
            sphere1.Load();
            shapes3D.Add("sphereEnvCubeMap", sphere1);

            //Shape3D sphere2 = new Sphere3D(new Vector3(-30f, 5f, -30f), 1.5f, new Color4(1f, 1f, 0.3f, 1f));
            //string vs2 = File.ReadAllText("Shaders\\vShader_Color_Normal1.txt");
            //string fs2 = File.ReadAllText("Shaders\\fShader_Color_Normal1.txt");
            //Shader Shader2 = new Shader(ref vs, ref fs, sphere2);
            //sphere2.Shader = Shader2;
            //sphere2.Collision = false;
            //sphere2.IsShadowCaster = false;
            //sphere2.Physic.Mass = 10f;
            //sphere2.Physic.Vxyz = Vector3.Zero;
            //sphere2.ShadowMatrix = shadowMap.ShadowMatrix;
            //sphere2.TextureShadowMap = shadowMap.DepthTexture;
            //sphere2.Bounding.R = 1.5f;
            //sphere2.Load();
            //shapes3D.Add("pointLight", sphere2);

            //Shape3D shpereEnvCubeMap = new Sphere3DEnvCubeMap(new Vector3(0f, 30f, 0f), 10f);
            //shpereEnvCubeMap.Collision = false;
            //shpereEnvCubeMap.IsShadowCaster = false;
            //shpereEnvCubeMap.Physic.Mass = 10f;
            //shpereEnvCubeMap.Physic.Vxyz = Vector3.Zero;
            //shpereEnvCubeMap.ShadowMatrix = shadowMap.ShadowMatrix;
            ////shpereEnvCubeMap.TextureShadowMap = shadowMap.DepthTexture;
            //shpereEnvCubeMap.Load();
            //shapes3D.Add("sphereEnvM", shpereEnvCubeMap);

            //Shape3D torus = new Torus3D(new Vector3(0f, 40f, 0f), 10f, Color4.Green);
            //torus.Collision = false;
            //torus.IsShadowCaster = true;
            //torus.Physic.Mass = 10f;
            //torus.Physic.Vxyz = Vector3.Zero;
            //torus.ShadowMatrix = shadowMap.ShadowMatrix;
            //torus.Load();
            //torus.VertexBuffer.DrawMode = OpenTK.Graphics.OpenGL4.BeginMode.Lines;
            //shapes3D.Add("pointSprites", torus);

            //Shape3D torus = new Torus3D(new Vector3(0f, 40f, 0f), 10f, Color4.Green);
            //torus.Collision = false;
            //torus.IsShadowCaster = true;
            //torus.Physic.Mass = 10f;
            //torus.Physic.Vxyz = Vector3.Zero;
            //torus.ShadowMatrix = shadowMap.ShadowMatrix;
            //torus.Load();
            //torus.VertexBuffer.DrawMode = OpenTK.Graphics.OpenGL4.BeginMode.Lines;
            //shapes3D.Add("pointSprites", torus);

            // point sprites
            //Shape3D pointSprites =
            //    new PointSprites("pointSprites", new Vector3(0, 40, 0), 0,
            //        gameLevel.Textures["pointsprites_texture"]);
            //pointSprites.IsShadowCaster = false;
            //pointSprites.ShadowMatrix = shadowMap.ShadowMatrix;
            //pointSprites.Collision = false;
            //pointSprites.Load();
            //shapes3D.Add("pointSprites", pointSprites);

            Shape3D torus = new Torus3D(new Vector3(0f, 40f, 0f), 10f, Color4.Green);
            torus.Collision      = false;
            torus.IsShadowCaster = true;
            torus.Physic.Mass    = 10f;
            torus.Physic.Vxyz    = Vector3.Zero;
            torus.ShadowMatrix   = shadowMap.ShadowMatrix;
            torus.Load();
            torus.VertexBuffer.DrawMode = OpenTK.Graphics.OpenGL4.BeginMode.Lines;
            torus.LifeTime = new LifeTime(400);
            // actions
            torus.ShapeActions = new Queue <ShapeAction>();
            torus.ShapeActions.Enqueue(new ShapeAction(
                                           new Action <Shape3D, LifeTime>(
                                               (shape, lifeTime) => {
                shape.RotateY(0.1f);

                shape.Scale(5 + Tween.Solve(
                                Tween.Function.Cubic,
                                Tween.Ease.InOut,
                                0f,
                                5f,
                                lifeTime.Max,
                                lifeTime.Counter));
            }),
                                           new LifeTime(200)));

            torus.ShapeActions.Enqueue(new ShapeAction(
                                           new Action <Shape3D, LifeTime>(
                                               (shape, lifeTime) => {
                shape.RotateX(Tween.Solve(
                                  Tween.Function.Elastic,
                                  Tween.Ease.Out,
                                  0f,
                                  0.08f,
                                  lifeTime.Max,
                                  lifeTime.Counter));

                shape.Scale(10 - Tween.Solve(
                                Tween.Function.Quadratic,
                                Tween.Ease.Out,
                                0f,
                                5f,
                                lifeTime.Max,
                                lifeTime.Counter));
            }),
                                           new LifeTime(200)));
            torus.Name = "notTableTorus";
            shapes3D.Add(torus.Name, torus);



            Shape3D pointSprites =
                new PointSprites("pointSprites", new Vector3(0, 50, 0), 0,
                                 gameLevel.Textures["pointsprites_texture"]);
            pointSprites.IsShadowCaster = false;
            pointSprites.ShadowMatrix   = shadowMap.ShadowMatrix;
            pointSprites.Collision      = false;
            pointSprites.IsVisible      = false;
            pointSprites.Load();
            shapes3D.Add("pointSprites", pointSprites);

            return(shapes3D);
        }