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; } }
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; } }
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); } } }
public void RemoveAngleConstraint() { fprn1 = null; fprn2 = null; fprangle1 = 0; }
public void AddAngleConstraint(IKMember n1, float angle1, IKMember n2) { fprn1 = n1; fprn2 = n2; fprangle1 = angle1; }
public void addNeighbour(IKMember neighbour) { nnb.Add(neighbour); }
public void CreateParasite(int numParts) { // Create the Tail tail = new ParasiteTail(Game, PhysicsOverlord.GetInstance().GetID(), theSprite, 1.0f); tail.Position = new Vector2(50 * numParts, 100); tail.relativeGravity = gravity; // Create Body Parts for (int i = 0; i < numParts; i++) { ParasiteBodyPart bodyPart = new ParasiteBodyPart(Game, PhysicsOverlord.GetInstance().GetID(), theSprite, 1f); bodyPart.Position = new Vector2(50 * i, 100); bodyparts.Add(bodyPart); bodyPart.relativeGravity = gravity; } // Create the Head head = new ParasiteHead(Game, PhysicsOverlord.GetInstance().GetID(), theSprite, 1); head.Position = new Vector2(100, 100); head.relativeGravity = gravity; // 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(); }
public void AddIKPoint(IKMember thePoint) { IKPoint = thePoint; }