Beispiel #1
0
            public Task ApplyGpose(ActorViewModel actor, Vector rootPos, Configuration config)
            {
                if (actor.ModelObject?.Transform != null)
                {
                    if (this.Position != null)
                    {
                        actor.ModelObject.Transform.Position = rootPos + (Vector)this.Position;
                    }

                    if (this.Rotation != null)
                    {
                        actor.ModelObject.Transform.Rotation = (Quaternion)this.Rotation;
                    }

                    if (this.Scale != null)
                    {
                        actor.ModelObject.Transform.Scale = (Vector)this.Scale;
                    }
                }

                if (this.Pose != null)
                {
                    throw new NotImplementedException();
                    ////await this.Pose.Apply(actor, config.Pose);
                }

                return(Task.CompletedTask);
            }
Beispiel #2
0
            public async Task ApplyGpose(ActorViewModel actor, Vector rootPos, Configuration config)
            {
                if (actor.ModelObject?.Transform != null)
                {
                    if (this.Position != null)
                    {
                        actor.ModelObject.Transform.Position = rootPos + (Vector)this.Position;
                    }

                    if (this.Rotation != null)
                    {
                        actor.ModelObject.Transform.Rotation = (Quaternion)this.Rotation;
                    }

                    if (this.Scale != null)
                    {
                        actor.ModelObject.Transform.Scale = (Vector)this.Scale;
                    }
                }

                if (this.Pose != null)
                {
                    await this.Pose.Apply(actor, config.Pose);
                }
            }
Beispiel #3
0
            public void FromActor(ActorViewModel actor, SkeletonVisual3d skeleton, Vector rootPos, Configuration config)
            {
                if (actor.ModelObject?.Transform != null)
                {
                    if (config.IncludeActorPosition)
                    {
                        this.Position = rootPos - actor.ModelObject.Transform.Position;
                    }

                    if (config.IncludeActorRotation)
                    {
                        this.Rotation = actor.ModelObject.Transform.Rotation;
                    }

                    if (config.IncludeActorScale)
                    {
                        this.Scale = actor.ModelObject.Transform.Scale;
                    }
                }

                this.Pose = new PoseFile();
                this.Pose.WriteToFile(actor, skeleton, config.Pose);

                this.Character = new CharacterFile();
                this.Character.WriteToFile(actor, config.Character);
            }
Beispiel #4
0
        public void WriteTransform(ModelVisual3D root, bool writeChildren = true)
        {
            if (!this.IsEnabled)
            {
                return;
            }

            // Apply the current values to the visual tree
            this.rotation.Rotation = new QuaternionRotation3D(this.Rotation.ToMedia3DQuaternion());
            this.position.OffsetX  = this.Position.X;
            this.position.OffsetY  = this.Position.Y;
            this.position.OffsetZ  = this.Position.Z;

            // convert the values in the tree to character-relative space
            MatrixTransform3D transform = (MatrixTransform3D)this.TransformToAncestor(root);

            Quaternion rotation = transform.Matrix.ToQuaternion();

            rotation.Invert();

            CmVector position = default;

            position.X = (float)transform.Matrix.OffsetX;
            position.Y = (float)transform.Matrix.OffsetY;
            position.Z = (float)transform.Matrix.OffsetZ;

            // and push those values to the game memory
            this.ViewModel.Position = position;
            this.ViewModel.Scale    = this.Scale;
            this.ViewModel.Rotation = rotation.ToCmQuaternion();

            if (writeChildren)
            {
                foreach (Visual3D child in this.Children)
                {
                    if (child is BoneVisual3d childBone)
                    {
                        childBone.WriteTransform(root);
                    }
                }
            }
        }