/// <summary>
        /// Draws the trunk using the specified world, view, and projection matrices.
        /// </summary>
        /// <param name="world">World matrix.</param>
        /// <param name="view">View matrix.</param>
        /// <param name="projection">Projection matrix.</param>
        /// <param name="forward">if set to <c>true</c> [forward].</param>
        /// <param name="depth">if set to <c>true</c> [depth].</param>
        /// <exception cref="InvalidOperationException">If no trunk effect is set.</exception>
        ///
        /// <exception cref="InvalidOperationException">If no skeleton is set.</exception>
        /// <remarks>
        /// This method sets all the appropriate effect parameters.
        /// </remarks>
        public void DrawTrunk(Matrix world, Matrix view, Matrix projection, bool forward, bool depth = false)
        {
            if (skeleton == null)
            {
                throw new InvalidOperationException("A skeleton must be set before trunk can be rendered.");
            }

            if (trunkEffect == null)
            {
                throw new InvalidOperationException("TrunkEffect must be set before trunk can be rendered.");
            }

            trunkEffect.Parameters["World"].SetValue(world);
            trunkEffect.Parameters["View"].SetValue(view);
            trunkEffect.Parameters["Projection"].SetValue(projection);

            skeleton.CopyBoneBindingMatricesTo(bindingMatrices, animationState.BoneRotations);
            trunkEffect.Parameters["Bones"].SetValue(bindingMatrices);

            trunkEffect.Parameters["Texture"].SetValue(trunkTexture);

            if (forward)
            {
                trunkEffect.CurrentTechnique = trunkEffect.Techniques["TechniqueForward"];
            }
            else
            {
                trunkEffect.CurrentTechnique = trunkEffect.Techniques["TechniqueDeferred"];
            }

            trunk.Draw(trunkEffect, depth);
        }
Example #2
0
        /// <summary>
        /// Draws the trunk using the specified world, view, and projection matrices.
        /// </summary>
        /// <param name="world">World matrix.</param>
        /// <param name="view">View matrix.</param>
        /// <param name="projection">Projection matrix.</param>
        /// <exception cref="InvalidOperationException">If no trunk effect is set.</exception>
        /// <exception cref="InvalidOperationException">If no skeleton is set.</exception>
        /// <remarks>
        /// This method sets all the appropriate effect parameters.
        /// </remarks>
        public void DrawTrunk(Matrix world, Matrix view, Matrix projection)
        {
            if (skeleton == null)
            {
                throw new InvalidOperationException("A skeleton must be set before trunk can be rendered.");
            }

            if (trunkEffect == null)
            {
                throw new InvalidOperationException("TrunkEffect must be set before trunk can be rendered.");
            }

            trunkEffect.Parameters["World"].SetValue(world);
            trunkEffect.Parameters["View"].SetValue(view);
            trunkEffect.Parameters["Projection"].SetValue(projection);

            skeleton.CopyBoneBindingMatricesTo(bindingMatrices, animationState.BoneRotations);
            trunkEffect.Parameters["Bones"].SetValue(bindingMatrices);

            trunkEffect.Parameters["Texture"].SetValue(trunkTexture);

            trunk.Draw(trunkEffect);
        }