Example #1
0
        /// <summary>
        /// Create a local coordinate axis for the current bone.
        /// </summary>
        public void CreateLocalCoodinateAxis()
        {
            PMXVector3 targetLocation;

            if (this.HasChildBone)
            {
                if (this.ChildBone == this)
                {
                    return;
                }
                targetLocation = this.ChildBone.Position;
            }
            else
            {
                targetLocation = this.Position + this.ChildVector;
            }

            PMXVector3 direction = targetLocation - this.Position;

            PMXVector3 zAxis = (new PMXVector3(0, 1, 0)).CrossProduct(direction);

            if (zAxis.Z > 0)
            {
                zAxis *= -1.0f;
            }

            /*float dotProduct = direction.DotProduct(zAxis);
             * Console.WriteLine(dotProduct.ToString());*/

            this.LocalCoordinates  = true;
            this.LocalCoordinatesX = direction.Normalize();
            this.LocalCoordinatesZ = zAxis.Normalize();
        }
Example #2
0
        /// <summary>
        /// Parses PMD Twist data if available.
        /// </summary>
        public void ParsePMDTwist()
        {
            if (!this._isPMDTwist || this.Parent == null)
            {
                return;
            }
            this._isPMDTwist = false;
            PMXBone p = this.Parent;

            PMXVector3 targetLocation;

            if (p.HasChildBone)
            {
                if (p.ChildBone == this)
                {
                    return;
                }
                targetLocation = p.ChildBone.Position;
            }
            else
            {
                targetLocation = p.Position + p.ChildVector;
            }

            PMXVector3 direction = targetLocation - this.Position;

            direction = direction.Normalize();

            this.FixedAxis = true;
            this.AxisLimit = direction;
        }