예제 #1
0
        // "DrawModel()": Draws the model and textures for the model.
        public void DrawModel(modelMatrix modMatrix, ModelObject theModel)
        {
            Matrix[] transforms = new Matrix[theModel.model.Bones.Count];
            theModel.model.CopyAbsoluteBoneTransformsTo(transforms);
            int j = 0;

            foreach (ModelMesh mesh in theModel.model.Meshes)
            {
                foreach (Effect currentEffect in mesh.Effects)
                {
                    Matrix wMatrix = transforms[mesh.ParentBone.Index] * modMatrix.worldMatrix; // Model + motion.
                    //Matrix wMatrix = transforms[mesh.ParentBone.Index]; // Model draw only.
                    currentEffect.CurrentTechnique = currentEffect.Techniques["Textured"];      // Specifies the loading of textures onto model.
                    currentEffect.Parameters["xWorld"].SetValue(wMatrix);
                    currentEffect.Parameters["xView"].SetValue(modMatrix.viewMatrix);
                    currentEffect.Parameters["xProjection"].SetValue(modMatrix.projectionMatrix);
                    currentEffect.Parameters["xEnableLighting"].SetValue(true);                  // Enables lighting.
                    currentEffect.Parameters["xLightDirection"].SetValue(new Vector3(3, -2, 5)); // Sets the direction of the light.
                    currentEffect.Parameters["xAmbient"].SetValue(0.5f);
                    currentEffect.Parameters["xTexture"].SetValue(theModel.textures[j++]);       // Apply the textures.
                }
                mesh.Draw();                                                                     // Draws the mesh.
            }
        }
예제 #2
0
        // "DrawModel()": Draws the model and textures for the model.
        public void DrawModel(modelMatrix modMatrix, ModelObject theModel)
        {
            Matrix[] transforms = new Matrix[theModel.model.Bones.Count];
            theModel.model.CopyAbsoluteBoneTransformsTo(transforms);
            int j = 0;

            foreach (ModelMesh mesh in theModel.model.Meshes)
            {
                foreach (Effect currentEffect in mesh.Effects)
                {
                    Matrix wMatrix = transforms[mesh.ParentBone.Index] * modMatrix.worldMatrix; // Model + motion.
                    //Matrix wMatrix = transforms[mesh.ParentBone.Index]; // Model draw only.
                    currentEffect.CurrentTechnique = currentEffect.Techniques["Textured"]; // Specifies the loading of textures onto model.
                    currentEffect.Parameters["xWorld"].SetValue(wMatrix);
                    currentEffect.Parameters["xView"].SetValue(modMatrix.viewMatrix);
                    currentEffect.Parameters["xProjection"].SetValue(modMatrix.projectionMatrix);
                    currentEffect.Parameters["xEnableLighting"].SetValue(true); // Enables lighting.
                    currentEffect.Parameters["xLightDirection"].SetValue(new Vector3(3, -2, 5)); // Sets the direction of the light.
                    currentEffect.Parameters["xAmbient"].SetValue(0.5f);
                    currentEffect.Parameters["xTexture"].SetValue(theModel.textures[j++]); // Apply the textures.
                }
                mesh.Draw(); // Draws the mesh.
            }
        }