Пример #1
0
        /// <summary>
        /// Draws the model, using the current drawing parameters.
        /// </summary>
        public void Draw()
        {
            // Set the world matrix as the root transform of the model.
            xnaModel.Root.Transform = Rotation;

            // Look up combined bone matrices for the entire model.
            xnaModel.CopyAbsoluteBoneTransformsTo(boneTransforms);

            // Draw the model.
            foreach (ModelMesh mesh in xnaModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World      = boneTransforms[mesh.ParentBone.Index];
                    effect.View       = View;
                    effect.Projection = Projection;

                    SetEffectLights(effect, Lights);
                    SetEffectPerPixelLightingEnabled(effect);

                    effect.TextureEnabled = IsTextureEnabled;
                }

                mesh.Draw();
            }
        }
Пример #2
0
Файл: Game.cs Проект: YashC/IXVI
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            m_spriteBatch     = new SpriteBatch(GraphicsDevice);
            m_model           = Content.Load <Model> ("Models\\test.dgn.i.2010");
            m_gameState.Model = m_model;
            m_modelExtents    = m_model.GetBoundingBox();

            float   groundWidth   = 10.0f * (m_modelExtents.Max.X - m_modelExtents.Min.X);
            float   groundDepth   = 10.0f * (m_modelExtents.Max.Z - m_modelExtents.Min.Z);
            float   groundOriginX = m_modelExtents.Min.X + (groundWidth * 0.5f);
            float   groundOriginZ = m_modelExtents.Min.Z + (groundDepth * 0.5f);
            float   groundOriginY = m_modelExtents.Min.Y;
            Vector3 groundOrigin  = new Vector3(0.0f, 0.0f, 0.0f);

            //Copy model and transform to HUDComponent
            headsUpDisplay.Model      = m_model;
            headsUpDisplay.Transforms = new Matrix[m_model.Bones.Count];
            m_model.CopyAbsoluteBoneTransformsTo(headsUpDisplay.Transforms);


            m_quad = new Quad(groundOrigin, Vector3.Up, Vector3.Forward, m_gameState.FarClip, m_gameState.FarClip);

            // Allocate the transform matrix array.
            m_gameState.BoneTransforms = new Matrix[m_model.Bones.Count];

            //Avatar
            m_avatar = Content.Load <Model> ("Avatar\\dude");

            // Look up our custom skinning information.
            SkinningData skinningData = m_avatar.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            animationPlayer = new AnimationPlayer(skinningData);

            m_clip = skinningData.AnimationClips["Take 001"];
            animationPlayer.StartClip(m_clip);

            // TODO: Load any ResourceManagementMode.Automatic content
            m_texture    = Content.Load <Texture2D> (@"Textures\GreenOnBlackGrid");
            m_quadEffect = new BasicEffect(m_graphics.GraphicsDevice);
            m_quadEffect.EnableDefaultLighting();


            m_quadEffect.World          = Matrix.CreateTranslation(Vector3.Zero);
            m_quadEffect.TextureEnabled = true;
            m_quadEffect.Texture        = m_texture;

            //m_kinectVideo = new Texture2D (GraphicsDevice, 640, 480);
        }