Ejemplo n.º 1
0
        void SCHEMA2SCENE.ApplyTo(Scene dstScene, Schema2SceneBuilder context)
        {
            if (!(Content is SCHEMA2NODE schema2Target))
            {
                return;
            }

            // a skinned mesh is controlled indirectly by its bones,
            // so we need to create a dummy container for it:
            var skinnedMeshNode = dstScene.CreateNode();

            skinnedMeshNode.Name   = _NodeName;
            skinnedMeshNode.Extras = _NodeExtras;

            if (_MeshPoseWorldTransform.HasValue)
            {
                var dstNodes = new Node[_Joints.Count];

                for (int i = 0; i < dstNodes.Length; ++i)
                {
                    var(joints, inverseBindMatrix) = _Joints[i];

                    System.Diagnostics.Debug.Assert(!inverseBindMatrix.HasValue);

                    dstNodes[i] = context.GetNode(joints);
                }

                #if DEBUG
                for (int i = 0; i < dstNodes.Length; ++i)
                {
                    var(joints, inverseBindMatrix) = _Joints[i];
                    System.Diagnostics.Debug.Assert(dstNodes[i].WorldMatrix == joints.WorldMatrix);
                }
                #endif

                skinnedMeshNode.WithSkinBinding(_MeshPoseWorldTransform.Value.Matrix, dstNodes);
            }
            else
            {
                var skinnedJoints = _Joints
                                    .Select(j => (context.GetNode(j.Joint), j.InverseBindMatrix.Value))
                                    .ToArray();

                skinnedMeshNode.WithSkinBinding(skinnedJoints);
            }

            // set skeleton
            // var root = _Joints[0].Joint.Root;
            // skinnedMeshNode.Skin.Skeleton = context.GetNode(root);

            schema2Target.ApplyTo(skinnedMeshNode, context);
            Schema2SceneBuilder.SetMorphAnimation(skinnedMeshNode, this.Morphings);
        }
Ejemplo n.º 2
0
        void SCHEMA2SCENE.Setup(Scene dstScene, Schema2SceneBuilder context)
        {
            if (!(Content is SCHEMA2NODE schema2Target))
            {
                return;
            }

            var skinnedMeshNode = dstScene.CreateNode();

            skinnedMeshNode.Name = _NodeName;

            if (_TargetBindMatrix.HasValue)
            {
                var dstNodes = new Node[_Joints.Count];

                for (int i = 0; i < dstNodes.Length; ++i)
                {
                    var(joints, inverseBindMatrix) = _Joints[i];

                    System.Diagnostics.Debug.Assert(!inverseBindMatrix.HasValue);

                    dstNodes[i] = context.GetNode(joints);
                }

                #if DEBUG
                for (int i = 0; i < dstNodes.Length; ++i)
                {
                    var(joints, inverseBindMatrix) = _Joints[i];
                    System.Diagnostics.Debug.Assert(dstNodes[i].WorldMatrix == joints.WorldMatrix);
                }
                #endif

                skinnedMeshNode.WithSkinBinding(_TargetBindMatrix.Value, dstNodes);
            }
            else
            {
                var skinnedJoints = _Joints
                                    .Select(j => (context.GetNode(j.Joints), j.InverseBindMatrix.Value))
                                    .ToArray();

                skinnedMeshNode.WithSkinBinding(skinnedJoints);
            }

            // set skeleton
            // var root = _Joints[0].Joint.Root;
            // skinnedMeshNode.Skin.Skeleton = context.GetNode(root);

            schema2Target.Setup(skinnedMeshNode, context);

            context.SetMorphAnimation(skinnedMeshNode, this.Morphings);
        }
Ejemplo n.º 3
0
        void SCHEMA2SCENE.ApplyTo(Scene dstScene, Schema2SceneBuilder context)
        {
            if (Content is SCHEMA2NODE schema2Target)
            {
                var dstNode = context.GetNode(_Node);

                schema2Target.ApplyTo(dstNode, context);

                Schema2SceneBuilder.SetMorphAnimation(dstNode, this.Morphings);

                System.Diagnostics.Debug.Assert(dstNode.WorldMatrix == this.GetPoseWorldMatrix(), "Transform mismatch!");
            }
        }
Ejemplo n.º 4
0
        void SCHEMA2SCENE.Setup(Scene dstScene, Schema2SceneBuilder context)
        {
            if (!(Content is SCHEMA2NODE schema2Target))
            {
                return;
            }

            var dstNode = context.GetNode(_Node);

            schema2Target.Setup(dstNode, context);

            context.SetMorphAnimation(dstNode, this.Morphings);
        }
Ejemplo n.º 5
0
        public void ApplyTo(Scene dstScene, Schema2SceneBuilder context)
        {
            System.Diagnostics.Debug.Assert(_Children.Count > 0);

            if (_ParentNode == null)
            {
                _AddInstances(dstScene, context);
                return;
            }
            else
            {
                var dstNode = context.GetNode(_ParentNode);

                if (Schema2SceneBuilder.HasContent(dstNode))
                {
                    dstNode = dstNode.CreateNode();
                }

                _AddInstances(dstNode, context);
                return;
            }
        }