public void foldData(Vector3 vec, Vector3 point, float angle, Board b) { foreach (Player p in players) { p.foldData(vec, point, angle, b.PointInBeforeFold(p.getCenter()), b.PointInAfterFold(p.getCenter())); } }
// I changed it so the axis and the point will be relevent to the closest point - Tom public void foldData(float angle, Board b) { int i = 0; while (i<players.Count()) { if (b.PointInAfterFold(players.ElementAt(i).getCenter()) || b.PointInBeforeFold(players.ElementAt(i).getCenter())) players.ElementAt(i).foldData(angle, b.State); i++; } }
public void preFoldData(Vector3 foldp1, Vector3 foldp2, Vector3 axis, Board b) { Matrix checkMatrix; Vector3 check; float rotantionAngle; foreach (Player p in players) { if (b.PointInBeforeFold(p.getCenter())) { rotantionAngle = MathHelper.PiOver2; checkMatrix = Matrix.Identity; checkMatrix *= Matrix.CreateFromAxisAngle(axis, rotantionAngle); check = Vector3.Transform(p.getCenter(), checkMatrix); // where the point will be after rotation if (check.Y > 0.0f) // if it is in the right deriction p.preFoldData(axis, (foldp1 + foldp2) / 2, true, false); else // not in the right deriction p.preFoldData(-axis, (foldp1 + foldp2) / 2, true, false); } else if (b.PointInAfterFold(p.getCenter())) { rotantionAngle = -1.5f * MathHelper.PiOver2; checkMatrix = Matrix.Identity; checkMatrix *= Matrix.CreateTranslation(-p.getCenter()); checkMatrix *= Matrix.CreateRotationZ(MathHelper.Pi); checkMatrix *= Matrix.CreateTranslation(p.getCenter()); checkMatrix *= Matrix.CreateTranslation(-(foldp1 + foldp2) / 2); checkMatrix *= Matrix.CreateFromAxisAngle(axis, rotantionAngle); checkMatrix *= Matrix.CreateTranslation((foldp1 + foldp2) / 2); check = Vector3.Transform(p.getCenter(), checkMatrix); // where the point will be after rotation if (check.Y > 0.0f) // if it is in the right deriction p.preFoldData(axis, (foldp1 + foldp2) / 2, false, true); else // not in the right deriction p.preFoldData(-axis, (foldp1 + foldp2) / 2, false, true); } } }