Esempio n. 1
0
        /// <summary>
        /// Initializes the varibles and sets default values.
        /// </summary>
        /// <param name="device">A copy of the rendering device.</param>
        /// <param name="effect">A copy of the effect class.</param>
        public Model(Device device, Effect effect)
        {
            VertexElement[] vElements = new VertexElement[]
            {
                new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
                new VertexElement(0, 12, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
                new VertexElement(0, 20, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0),
                new VertexElement(0, 32, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Tangent, 0),
                VertexElement.VertexDeclarationEnd
            };

            this.device = device;
            objLoader   = new ObjLoader(device);
            xLoader     = new XLoader(device);
            model       = new Mesh(1, 1, MeshFlags.Managed | MeshFlags.Use32Bit, vElements, device);
            min         = max = 0;
            enabled     = false;
            pathname    = "";

            // Initialize the texture classes and set the shader variables.
            ambientTexture  = new TextureClass(device, effect, "ambientMap", "useAmbientMap");
            diffuseTexture  = new TextureClass(device, effect, "diffuseMap", "useDiffuseMap");
            emissiveTexture = new EmissiveClass(device, effect);
            specularTexture = new SpecularClass(device, effect, "specularMap", "useSpecularMap");
            normalTexture   = new NormalClass(device, effect, "normalMap", "useNormalMap");
        }
Esempio n. 2
0
        public GroundPlane(Device device, Effect effect)
        {
            VertexElement[] vElements = new VertexElement[]
            {
                new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
                new VertexElement(0, 12, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
                new VertexElement(0, 20, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0),
                new VertexElement(0, 32, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Tangent, 0),
                VertexElement.VertexDeclarationEnd
            };

            this.device = device;
            objLoader = new ObjLoader(device);
            xLoader = new XLoader(device);
            model = new Mesh(1, 1, MeshFlags.Managed | MeshFlags.Use32Bit, vElements, device);
            min = max = 0;
            enabled = false;
            pathname = "";
            uvScale = 1.0f;
            minValue = 0.0f;
            size = 10.0f;

            // Initialize the texture classes and set the shader variables.
            ambientTexture = new TextureClass(device, effect, "ambientMap", "useAmbientMap");
            diffuseTexture = new TextureClass(device, effect, "diffuseMap", "useDiffuseMap");
            emissiveTexture = new EmissiveClass(device, effect);
            specularTexture = new SpecularClass(device, effect, "specularMap", "useSpecularMap");
            normalTexture = new NormalClass(device, effect, "normalMap", "useNormalMap");

            CreateGroundPlane(minValue, size, uvScale);
        }