コード例 #1
0
        public void Initialize(ModelNodeDefinition[] newNodes)
        {
            if (this.nodes == newNodes && this.nodes != null)
            {
                return;
            }

            this.nodes = newNodes ?? GetDefaultNodeDefinitions();

            if (nodeTransformations == null || nodeTransformations.Length < this.nodes.Length)
                nodeTransformations = new ModelNodeTransformation[this.nodes.Length];

            for (int index = 0; index < nodes.Length; index++)
            {
                nodeTransformations[index].ParentIndex = nodes[index].ParentIndex;
                nodeTransformations[index].Transform = nodes[index].Transform;
                nodeTransformations[index].Flags = nodes[index].Flags;
                nodeTransformations[index].RenderingEnabledRecursive = true;
            }
        }
コード例 #2
0
ファイル: PlayingAnimation.cs プロジェクト: releed/paradox
        /// <summary>
        /// Filters the animation to the specified sub-trees given by <see cref="roots"/>.
        /// </summary>
        /// <param name="nodes">The node hierarchy.</param>
        /// <param name="roots">The node roots of sub-trees that should be active (others will be filtered out).</param>
        public void FilterNodes(ModelNodeDefinition[] nodes, params string[] roots)
        {
            // Initialize list of factors (matching nodes list)
            var nodeFactors = new float[nodes.Length];
            for (int index = 0; index < nodes.Length; index++)
            {
                var node = nodes[index];
                if (roots.Contains(node.Name)
                    || (node.ParentIndex != -1 && nodeFactors[node.ParentIndex] == 1.0f))
                {
                    nodeFactors[index] = 1.0f;
                }
            }

            //Make sure Evaluator is populated
            //TODO this is not optimal, but since evaluators are being pooled there is no other safe way
            if (Evaluator == null)
            {
                Evaluator = AnimationComponent.Blender.CreateEvaluator(Clip);
            }

            // Update animation channel factors
            var blenderChannels = Evaluator.BlenderChannels;
            var channels = Evaluator.Channels.Items;
            for (int index = 0; index < blenderChannels.Count; index++)
            {
                var blenderChannel = blenderChannels[index];

                // Find node index
                var nodeName = MeshAnimationUpdater.GetNodeName(blenderChannel.PropertyName);
                var nodeIndex = nodes.IndexOf(x => x.Name == nodeName);

                if (nodeIndex != -1)
                {
                    // Update factor
                    channels[index].Factor *= nodeFactors[nodeIndex];
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModelViewHierarchyUpdater" /> class.
 /// </summary>
 /// <param name="newNodes">The new nodes.</param>
 public ModelViewHierarchyUpdater(ModelNodeDefinition[] newNodes)
 {
     Initialize(newNodes);
 }
コード例 #4
0
        /// <summary>
        /// Filters the animation to the specified sub-trees given by <see cref="roots"/>.
        /// </summary>
        /// <param name="nodes">The node hierarchy.</param>
        /// <param name="roots">The node roots of sub-trees that should be active (others will be filtered out).</param>
        public void FilterNodes(ModelNodeDefinition[] nodes, params string[] roots)
        {
            // Initialize list of factors (matching nodes list)
            var nodeFactors = new float[nodes.Length];
            for (int index = 0; index < nodes.Length; index++)
            {
                var node = nodes[index];
                if (roots.Contains(node.Name)
                    || (node.ParentIndex != -1 && nodeFactors[node.ParentIndex] == 1.0f))
                {
                    nodeFactors[index] = 1.0f;
                }
            }

            // Update animation channel factors
            var blenderChannels = Evaluator.BlenderChannels;
            var channels = Evaluator.Channels.Items;
            for (int index = 0; index < blenderChannels.Count; index++)
            {
                var blenderChannel = blenderChannels[index];

                // Find node index
                var nodeName = MeshAnimationUpdater.GetNodeName(blenderChannel.PropertyName);
                var nodeIndex = nodes.IndexOf(x => x.Name == nodeName);

                if (nodeIndex != -1)
                {
                    // Update factor
                    channels[index].Factor *= nodeFactors[nodeIndex];
                }
            }
        }