Example #1
0
        private void _Init()
        {
            _glPanel3D = new GLPanel3D(Colors.Black);
            _glPanel3D.RotationSensitivity = 0.2f;
            GD_3D.Children.Add(_glPanel3D);

            _meshModel = new GLMeshModel3D()
            {
                Mode = GLPrimitiveMode.GL_TRIANGLES
            };

            _meshModel.AddMaterial(new DiffuseMaterial()
            {
                Color = Colors.White
            }, MaterialOption.Front);
            _meshModel.AddMaterial(new SpecularMaterial()
            {
                Color = Colors.White, SpecularPower = 128
            }, MaterialOption.Front);
            _visual3D       = new GLVisual3D();
            _visual3D.Model = _meshModel;
            _glPanel3D.AddVisual(_visual3D);
            _glPanel3D.AddLight(new AmbientLight(Colors.White, 0.2f));
            _glPanel3D.AddLight(new DirectionLight(Colors.White, new Vector3F(1, 0, 0), 0.15f, 0.1f));
            _glPanel3D.AddLight(new DirectionLight(Colors.White, new Vector3F(-1, 0, 0), 0.15f, 0.1f));
            _glPanel3D.AddLight(new DirectionLight(Colors.White, new Vector3F(0, 1, 0), 0.15f, 0.1f));
            _glPanel3D.AddLight(new DirectionLight(Colors.White, new Vector3F(0, -1, 0), 0.15f, 0.1f));
            _glPanel3D.AddLight(new DirectionLight(Colors.White, new Vector3F(0, 0, 1), 0.15f, 0.1f));
            _glPanel3D.AddLight(new DirectionLight(Colors.White, new Vector3F(0, 0, -1), 0.15f, 0.1f));
        }
Example #2
0
        private void _InitModel()
        {
            var model3D = new GLMeshModel3D()
            {
                Mode = GLPrimitiveMode.GL_TRIANGLES
            };

            model3D.SetPoints(new List <Point3F>()
            {
                new Point3F(0, 0, 0), new Point3F(100, 0, 0), new Point3F(0, 100, 0), new Point3F(100, 100, 0),
                new Point3F(0, 0, 0), new Point3F(0, 0, 100), new Point3F(0, 100, 0), new Point3F(0, 100, 100),
                new Point3F(0, 0, 0), new Point3F(100, 0, 0), new Point3F(0, 0, 100), new Point3F(100, 0, 100),
                new Point3F(100, 0, 0), new Point3F(100, 100, 100), new Point3F(100, 0, 100), new Point3F(100, 100, 0),
                new Point3F(0, 0, 100), new Point3F(100, 0, 100), new Point3F(0, 100, 100), new Point3F(100, 100, 100),
                new Point3F(0, 100, 0), new Point3F(0, 100, 100), new Point3F(100, 100, 0), new Point3F(100, 100, 100),
            });
            model3D.SetNormals(new List <Vector3F>()
            {
                new Vector3F(0, 0, -1), new Vector3F(0, 0, -1), new Vector3F(0, 0, -1), new Vector3F(0, 0, -1),
                new Vector3F(-1, 0, 0), new Vector3F(-1, 0, 0), new Vector3F(-1, 0, 0), new Vector3F(-1, 0, 0),
                new Vector3F(0, -1, 0), new Vector3F(0, -1, 0), new Vector3F(0, -1, 0), new Vector3F(0, -1, 0),
                new Vector3F(1, 0, 0), new Vector3F(1, 0, 0), new Vector3F(1, 0, 0), new Vector3F(1, 0, 0),
                new Vector3F(0, 0, 1), new Vector3F(0, 0, 1), new Vector3F(0, 0, 1), new Vector3F(0, 0, 1),
                new Vector3F(0, 1, 0), new Vector3F(0, 1, 0), new Vector3F(0, 1, 0), new Vector3F(0, 1, 0),
            });
            model3D.SetIndices(new List <uint>()
            {
                0, 2, 1, 1, 2, 3,
                4, 5, 6, 6, 5, 7,
                8, 9, 10, 9, 11, 10,
                12, 13, 14, 12, 15, 13,
                16, 17, 18, 19, 18, 17,
                20, 21, 22, 22, 21, 23,
            });

            //_model3D.AddMaterial(new EmissiveMaterial() { Color = Colors.Gray }, MaterialOption.Both);
            model3D.AddMaterial(new DiffuseMaterial()
            {
                Color = Colors.White
            }, MaterialOption.Both);
            model3D.AddMaterial(new SpecularMaterial()
            {
                Color = Colors.White, SpecularPower = 128
            }, MaterialOption.Both);
            _visual3D       = new GLVisual3D();
            _visual3D.Model = model3D;
            _glPanel3D.AddVisual(_visual3D);
            _glPanel3D.AddLight(new AmbientLight(Colors.White));
            //_glPanel3D.AddLight(new DirectionLight(Colors.White, new Vector3F(-1, -1, -1)));
            _pointLight = new PointLight(Colors.White, new Point3F(70, -40, 200));
            _glPanel3D.AddLight(_pointLight);
            //_glPanel3D.AddLight(new SpotLight(Colors.White, new Point3F(50, 50, 150), new Vector3F(0, 0, -1)) { InnerConeAngle = 20, OuterConeAngle = 80 });
        }