コード例 #1
0
        public void AddLightMesh()
        {
            Direct3D.Material mat = new Direct3D.Material();
            mat.Diffuse           = Color.Yellow;
            mat.Ambient           = Color.Yellow;
            mat.Specular          = Color.Yellow;
            mat.SpecularSharpness = 1;

            Direct3D.Material matoff = new Direct3D.Material();
            matoff.Diffuse           = Color.DarkGray;
            matoff.Ambient           = Color.DarkGray;
            matoff.Specular          = Color.DarkGray;
            matoff.SpecularSharpness = 1;
            Mesh m  = Mesh.Sphere(Device, 0.2f, 10, 4);
            Mesh mp = Mesh.Box(Device, 0.2f, 0.2f, 0.2f);

            MeshBox mb;

            for (int i = 0; i < Device.Lights.Count; i++)
            {
                Light l = Device.Lights[i];
                if (!l.Enabled)
                {
                    mb = new MeshBox("Light", m, 1, matoff);
                }
                else
                {
                    mb = new MeshBox("Light", m, 1, mat);
                }

                Vector3 v = l.Position;

                mb.Transform = MeshTransform.Translation(v);
                this.Meshes.Add(mb);

                if (!l.Enabled)
                {
                    mb = new MeshBox("Light", mp, 1, matoff);
                }
                else
                {
                    mb = new MeshBox("Light", mp, 1, mat);
                }
                mb.Transform = MeshTransform.Translation(l.Position + 0.4f * l.Direction);
                this.Meshes.Add(mb);

                if (!l.Enabled)
                {
                    mb = new MeshBox("Light", mp, 1, matoff);
                }
                else
                {
                    mb = new MeshBox("Light", mp, 1, mat);
                }
                mb.Transform = MeshTransform.Translation(l.Position + 0.5f * l.Direction);
                this.Meshes.Add(mb);
            }
        }
コード例 #2
0
        public void AddAxisMesh()
        {
            Direct3D.Material mat = new Direct3D.Material();
            mat.Diffuse           = Color.Red;
            mat.Ambient           = mat.Diffuse;
            mat.Specular          = mat.Diffuse;
            mat.SpecularSharpness = 1;



            Mesh    m  = Mesh.Cylinder(device, 0.001f, 0.001f, 1, 6, 1);
            MeshBox mb = new MeshBox("Axis", m, 1, mat);

            mb.Transform = MeshTransform.Translation(new Vector3(0, 0, 0));
            mb.Wire      = false;
            this.Meshes.Add(mb);

            mat.Diffuse  = Color.Green;
            mat.Ambient  = mat.Diffuse;
            mat.Specular = mat.Diffuse;
            m            = Mesh.Cylinder(device, 0.001f, 0.001f, 1, 6, 1);
            mb           = new MeshBox("Axis", m, 1, mat);
            mb.Transform = MeshTransform.RotationYawPitchRoll(
                0,
                -Math.PI / 2.0,
                0
                );
            mb.Wire = false;
            this.Meshes.Add(mb);

            mat.Diffuse  = Color.Blue;
            mat.Ambient  = mat.Diffuse;
            mat.Specular = mat.Diffuse;
            m            = Mesh.Cylinder(device, 0.001f, 0.001f, 1, 6, 1);
            mb           = new MeshBox("Axis", m, 1, mat);
            mb.Transform = MeshTransform.RotationYawPitchRoll(
                -Math.PI / 2.0,
                0,
                0
                );
            mb.Wire = false;
            this.Meshes.Add(mb);
        }