Ejemplo n.º 1
0
        public void SetAngle(IKMember father)
        {
            float    angle = currentAngle;
            IKMember a;
            IKMember b;

            if (fprn1 != null)
            {
                IKMember node0 = fprn1;
                IKMember node1 = fprn2;
                float    node2 = fprangle1;

                if (node1 == father)
                {
                    a     = node1;
                    b     = node0;
                    angle = (float)(2 * Math.PI - node2);
                }
                else
                {
                    a     = node0;
                    b     = node1;
                    angle = node2;
                }

                float ax     = a.skin.position.X - skin.position.X;
                float ay     = a.skin.position.Y - skin.position.Y;
                float aangle = (float)Math.Atan2(ay, ax);

                b.skin.position.X = skin.position.X + (float)Math.Cos(aangle + angle) * distance;
                b.skin.position.Y = skin.position.Y + (float)Math.Sin(aangle + angle) * distance;
            }
        }
Ejemplo n.º 2
0
        public void MakeMove(IKMember child, IKMember father)
        {
            if (!IKLocked)
            {
                float dy = child.skin.position.Y - father.skin.position.Y;
                float dx = child.skin.position.X - father.skin.position.X;
                float a1 = (float)Math.Atan2(dy, dx);

                currentAngle = a1;

                child.skin.position.X = father.skin.position.X + (float)Math.Cos(a1) * distance;
                child.skin.position.Y = father.skin.position.Y + (float)Math.Sin(a1) * distance;
                //child.skin.rotation = (float)((Math.PI * a1) * 180 / Math.PI);
            }
            else
            {
                // Locked angle code ?
                child.skin.position.X = father.skin.position.X + (float)Math.Cos(lockedAngle) * distance;
                child.skin.position.Y = father.skin.position.Y + (float)Math.Sin(lockedAngle) * distance;
            }
        }
Ejemplo n.º 3
0
        public void move(float _x, float _y, IKMember father)
        {
            if (father == null)
            {
                //skin.x = _x;
                //skin.y = _y;
                skin.position.X = _x;
                skin.position.Y = _y;
            }
            else
            {
                MakeMove(this, father);
            }

            // SetAngle(father);

            for (int i = 0; i < nnb.Count; i++)
            {
                if (nnb[i] != father)
                {
                    nnb[i].move(_x, _y, this);
                }
            }
        }
Ejemplo n.º 4
0
        public void CreateParasite(int numParts)
        {
            // Create the Tail
            tail          = new ParasiteTail(theSprite, 1.0f);
            tail.position = new Vector2(150 + (50 * numParts), 100);

            // Create Body Parts
            for (int i = 0; i < numParts; i++)
            {
                ParasiteBodyPart bodyPart = new ParasiteBodyPart(theSprite, 1f);
                bodyPart.position = new Vector2(150 + (50 * i), 100);
                bodyparts.Add(bodyPart);
            }

            // Create the Head
            head          = new ParasiteHead(theSprite, 1);
            head.position = new Vector2(100, 100);

            // IKPoints

            theParasite.Add(head);

            IKMember headIK = new IKMember(head, 10);
            IKMember lastIK = headIK;

            head.AddIKPoint(headIK);

            for (int i = 0; i < bodyparts.Count; i++)
            {
                ParasiteBodyPart bodyPart = bodyparts[i];

                theParasite.Add(bodyPart);

                IKMember ik = new IKMember(bodyPart, 10);

                if (i != 0)
                {
                    ik.addNeighbour(lastIK);
                }

                lastIK.addNeighbour(ik);

                bodyPart.AddIKPoint(ik);

                lastIK = ik;
            }

            // Uncomment for Rad Wiggle Motion!
            // currentIK = new IKMember(tail, 1);

            //currentIK = new IKMember(tail, 10);
            theParasite.Add(tail);

            IKMember tailIK = new IKMember(tail, 10);

            tailIK.addNeighbour(lastIK);
            lastIK.addNeighbour(tailIK);

            tail.AddIKPoint(tailIK);

            tail.initTail();
        }
Ejemplo n.º 5
0
 public void AddIKPoint(IKMember thePoint)
 {
     IKPoint = thePoint;
 }
Ejemplo n.º 6
0
 public void RemoveAngleConstraint()
 {
     fprn1     = null;
     fprn2     = null;
     fprangle1 = 0;
 }
Ejemplo n.º 7
0
 public void AddAngleConstraint(IKMember n1, float angle1, IKMember n2)
 {
     fprn1     = n1;
     fprn2     = n2;
     fprangle1 = angle1;
 }
Ejemplo n.º 8
0
 public void addNeighbour(IKMember neighbour)
 {
     nnb.Add(neighbour);
 }