Example #1
0
        public static void Init(Group *self)
        {
            self->tag = Tag.Group;

            Vec3.Zero(self->pos);
            Vec2.One(self->scl);
            self->rot = 0;
            self->isTransformDirty = true;
            self->isDepthDirty     = true;

            Mat2D.Identity(self->mat);
            Mat2D.Identity(self->concatMat);
            self->parentMat = null;

            PtrLst.Init(&self->childLst);
        }
Example #2
0
        void ConstrainRotation(BoneChain fk, float rotation)
        {
            ActorBone           bone        = fk.m_Bone;
            Mat2D               parentWorld = bone.Parent.WorldTransform;
            Mat2D               transform   = bone.Transform;
            TransformComponents c           = fk.m_TransformComponents;

            if (rotation == 0.0f)
            {
                Mat2D.Identity(transform);
            }
            else
            {
                Mat2D.FromRotation(transform, rotation);
            }
            // Translate
            transform[4] = c.X;
            transform[5] = c.Y;
            // Scale
            float scaleX = c.ScaleX;
            float scaleY = c.ScaleY;

            transform[0] *= scaleX;
            transform[1] *= scaleX;
            transform[2] *= scaleY;
            transform[3] *= scaleY;
            // Skew
            float skew = c.Skew;

            if (skew != 0.0)
            {
                transform[2] = transform[0] * skew + transform[2];
                transform[3] = transform[1] * skew + transform[3];
            }

            Mat2D.Multiply(bone.WorldTransform, parentWorld, transform);
        }