/// <summary>
        /// Initializes a new instance of the <see cref="SkinnedModelSceneInstance"/> class.
        /// </summary>
        /// <param name="template">The <see cref="ModelScene"/> which serves as this instance's template.</param>
        /// <param name="parentModelInstance">The <see cref="SkinnedModelInstance"/> which represents this scene's parent model.</param>
        public SkinnedModelSceneInstance(ModelScene template, SkinnedModelInstance parentModelInstance)
        {
            Contract.Require(template, nameof(template));
            Contract.Require(parentModelInstance, nameof(parentModelInstance));

            this.Template            = template;
            this.ParentModelInstance = parentModelInstance;
            this.Nodes = new SkinnedModelNodeInstanceCollection(template.Nodes.Select(x => new SkinnedModelNodeInstance(x, parentModelInstance, this, null)));
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SkinInstance"/> class.
        /// </summary>
        /// <param name="template">The <see cref="Skin"/> which serves as this instance's template.</param>
        /// <param name="parentModelInstance">The <see cref="SkinnedModelInstance"/> which represents this skin's parent model.</param>
        public SkinInstance(Skin template, SkinnedModelInstance parentModelInstance)
        {
            Contract.Require(template, nameof(template));
            Contract.Require(parentModelInstance, nameof(parentModelInstance));

            this.Template            = template;
            this.ParentModelInstance = parentModelInstance;

            this.boneTransforms = new Matrix[template.Joints.Count];
            Reset();
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SkinnedModelInstanceNodeManager"/> class.
        /// </summary>
        /// <param name="instance">The <see cref="SkinnedModelInstance"/> that owns this manager.</param>
        public SkinnedModelInstanceNodeManager(SkinnedModelInstance instance)
        {
            Contract.Require(instance, nameof(instance));

            this.nodes = new SkinnedModelNodeInstance[instance.Template.TotalNodeCount];
            instance.TraverseNodes((node, state) =>
            {
                var array = ((SkinnedModelNodeInstance[])state);
                array[node.Template.LogicalIndex] = node;
            }, this.nodes);
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SkinnedAnimationController"/> class.
        /// </summary>
        /// <param name="model">The model instance that owns this manager.</param>
        /// <param name="tracks">The number of animation tracks to allocate for the model instance.</param>
        public SkinnedAnimationController(SkinnedModelInstance model, Int32 tracks)
        {
            Contract.Require(model, nameof(model));

            this.model          = model;
            this.tracks         = new SkinnedAnimationTrack[tracks];
            this.nodeAnimations = new AnimationPosition?[tracks];
            this.ordering       = new Int64[tracks];

            for (var i = 0; i < tracks; i++)
            {
                this.tracks[i] = new SkinnedAnimationTrack(model);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SkinnedModelNodeInstance"/> class.
        /// </summary>
        /// <param name="template">The <see cref="ModelNode"/> which serves as this instance's template.</param>
        /// <param name="parentModelInstance">The <see cref="SkinnedModelInstance"/> which represents this node's parent model.</param>
        /// <param name="parentModelSceneInstance">The <see cref="SkinnedModelSceneInstance"/> which represents this node's parent scene.</param>
        /// <param name="parentModelNodeInstance">The <see cref="SkinnedModelNodeInstance"/> which represents this node's parent node.</param>
        public SkinnedModelNodeInstance(ModelNode template, SkinnedModelInstance parentModelInstance, SkinnedModelSceneInstance parentModelSceneInstance, SkinnedModelNodeInstance parentModelNodeInstance)
        {
            Contract.Require(template, nameof(template));
            Contract.Require(parentModelInstance, nameof(parentModelInstance));
            Contract.Require(parentModelSceneInstance, nameof(parentModelSceneInstance));

            this.Template                 = template;
            this.ParentModelInstance      = parentModelInstance;
            this.ParentModelSceneInstance = parentModelSceneInstance;
            this.ParentModelNodeInstance  = parentModelNodeInstance;
            this.Children                 = new SkinnedModelNodeInstanceCollection(template.Children.Select(x => new SkinnedModelNodeInstance(x, parentModelInstance, parentModelSceneInstance, this)));
            this.LocalTransform           = template.Transform.Clone();

            if (this.Template.ParentModel is SkinnedModel skinnedModel)
            {
                var skinTemplate = skinnedModel.Skins.TryGetSkinByNode(template.LogicalIndex);
                if (skinTemplate != null)
                {
                    this.Skin = parentModelInstance.Skins[skinTemplate.LogicalIndex];
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SkinnedAnimationTrack"/> class.
        /// </summary>
        /// <param name="model">The model that owns this track.</param>
        public SkinnedAnimationTrack(SkinnedModelInstance model)
        {
            Contract.Require(model, nameof(model));

            this.Model = model;
        }