public LocalToWorld ( float localX, float localY, float &worldX, float &worldY ) : void | ||
localX | float | |
localY | float | |
worldX | float | |
worldY | float | |
return | void |
public void ComputeWorldPosition(Bone bone, out float ox, out float oy) { bone.LocalToWorld(this.x, this.y, out ox, out oy); }
void ApplyRelativeWorld() { float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; Bone target = this.target; float ta = target.a, tb = target.b, tc = target.c, td = target.d; float degRadReflect = ta * td - tb * tc > 0 ? MathUtils.DegRad : -MathUtils.DegRad; float offsetRotation = data.offsetRotation * degRadReflect, offsetShearY = data.offsetShearY * degRadReflect; var bones = this.bones; for (int i = 0, n = bones.Count; i < n; i++) { Bone bone = bones.Items[i]; bool modified = false; if (rotateMix != 0) { float a = bone.a, b = bone.b, c = bone.c, d = bone.d; float r = MathUtils.Atan2(tc, ta) + offsetRotation; if (r > MathUtils.PI) { r -= MathUtils.PI2; } else if (r < -MathUtils.PI) { r += MathUtils.PI2; } r *= rotateMix; float cos = MathUtils.Cos(r), sin = MathUtils.Sin(r); bone.a = cos * a - sin * c; bone.b = cos * b - sin * d; bone.c = sin * a + cos * c; bone.d = sin * b + cos * d; modified = true; } if (translateMix != 0) { float tx, ty; //Vector2 temp = this.temp; target.LocalToWorld(data.offsetX, data.offsetY, out tx, out ty); //target.localToWorld(temp.set(data.offsetX, data.offsetY)); bone.worldX += tx * translateMix; bone.worldY += ty * translateMix; modified = true; } if (scaleMix > 0) { float s = ((float)Math.Sqrt(ta * ta + tc * tc) - 1 + data.offsetScaleX) * scaleMix + 1; bone.a *= s; bone.c *= s; s = ((float)Math.Sqrt(tb * tb + td * td) - 1 + data.offsetScaleY) * scaleMix + 1; bone.b *= s; bone.d *= s; modified = true; } if (shearMix > 0) { float r = MathUtils.Atan2(td, tb) - MathUtils.Atan2(tc, ta); if (r > MathUtils.PI) { r -= MathUtils.PI2; } else if (r < -MathUtils.PI) { r += MathUtils.PI2; } float b = bone.b, d = bone.d; r = MathUtils.Atan2(d, b) + (r - MathUtils.PI / 2 + offsetShearY) * shearMix; float s = (float)Math.Sqrt(b * b + d * d); bone.b = MathUtils.Cos(r) * s; bone.d = MathUtils.Sin(r) * s; modified = true; } if (modified) { bone.appliedValid = false; } } }
public void Update() { Bone bone = this.bone; Bone target = this.target; if (rotateMix > 0) { float a = bone.a, b = bone.b, c = bone.c, d = bone.d; float r = MathUtils.Atan2(target.c, target.a) - MathUtils.Atan2(c, a) + offsetRotation * MathUtils.degRad; if (r > MathUtils.PI) { r -= MathUtils.PI2; } else if (r < -MathUtils.PI) { r += MathUtils.PI2; } r *= rotateMix; float cos = MathUtils.Cos(r), sin = MathUtils.Sin(r); bone.a = cos * a - sin * c; bone.b = cos * b - sin * d; bone.c = sin * a + cos * c; bone.d = sin * b + cos * d; } if (scaleMix > 0) { float bs = (float)Math.Sqrt(bone.a * bone.a + bone.c * bone.c); float ts = (float)Math.Sqrt(target.a * target.a + target.c * target.c); float s = bs > 0.00001f ? (bs + (ts - bs + offsetScaleX) * scaleMix) / bs : 0; bone.a *= s; bone.c *= s; bs = (float)Math.Sqrt(bone.b * bone.b + bone.d * bone.d); ts = (float)Math.Sqrt(target.b * target.b + target.d * target.d); s = bs > 0.00001f ? (bs + (ts - bs + offsetScaleY) * scaleMix) / bs : 0; bone.b *= s; bone.d *= s; } if (shearMix > 0) { float b = bone.b, d = bone.d; float by = MathUtils.Atan2(d, b); float r = MathUtils.Atan2(target.d, target.b) - MathUtils.Atan2(target.c, target.a) - (by - MathUtils.Atan2(bone.c, bone.a)); if (r > MathUtils.PI) { r -= MathUtils.PI2; } else if (r < -MathUtils.PI) { r += MathUtils.PI2; } r = by + (r + offsetShearY * MathUtils.degRad) * shearMix; float s = (float)Math.Sqrt(b * b + d * d); bone.b = MathUtils.Cos(r) * s; bone.d = MathUtils.Sin(r) * s; } float translateMix = this.translateMix; if (translateMix > 0) { float tx, ty; target.LocalToWorld(offsetX, offsetY, out tx, out ty); bone.worldX += (tx - bone.worldX) * translateMix; bone.worldY += (ty - bone.worldY) * translateMix; } }
void ApplyRelativeWorld() { float mixRotate = this.mixRotate, mixX = this.mixX, mixY = this.mixY, mixScaleX = this.mixScaleX, mixScaleY = this.mixScaleY, mixShearY = this.mixShearY; bool translate = mixX != 0 || mixY != 0; Bone target = this.target; float ta = target.a, tb = target.b, tc = target.c, td = target.d; float degRadReflect = ta * td - tb * tc > 0 ? MathUtils.DegRad : -MathUtils.DegRad; float offsetRotation = data.offsetRotation * degRadReflect, offsetShearY = data.offsetShearY * degRadReflect; var bones = this.bones.Items; for (int i = 0, n = this.bones.Count; i < n; i++) { Bone bone = bones[i]; if (mixRotate != 0) { float a = bone.a, b = bone.b, c = bone.c, d = bone.d; float r = MathUtils.Atan2(tc, ta) + offsetRotation; if (r > MathUtils.PI) { r -= MathUtils.PI2; } else if (r < -MathUtils.PI) // { r += MathUtils.PI2; } r *= mixRotate; float cos = MathUtils.Cos(r), sin = MathUtils.Sin(r); bone.a = cos * a - sin * c; bone.b = cos * b - sin * d; bone.c = sin * a + cos * c; bone.d = sin * b + cos * d; } if (translate) { float tx, ty; //Vector2 temp = this.temp; target.LocalToWorld(data.offsetX, data.offsetY, out tx, out ty); //target.localToWorld(temp.set(data.offsetX, data.offsetY)); bone.worldX += tx * mixX; bone.worldY += ty * mixY; } if (mixScaleX != 0) { float s = ((float)Math.Sqrt(ta * ta + tc * tc) - 1 + data.offsetScaleX) * mixScaleX + 1; bone.a *= s; bone.c *= s; } if (mixScaleY != 0) { float s = ((float)Math.Sqrt(tb * tb + td * td) - 1 + data.offsetScaleY) * mixScaleY + 1; bone.b *= s; bone.d *= s; } if (mixShearY > 0) { float r = MathUtils.Atan2(td, tb) - MathUtils.Atan2(tc, ta); if (r > MathUtils.PI) { r -= MathUtils.PI2; } else if (r < -MathUtils.PI) // { r += MathUtils.PI2; } float b = bone.b, d = bone.d; r = MathUtils.Atan2(d, b) + (r - MathUtils.PI / 2 + offsetShearY) * mixShearY; float s = (float)Math.Sqrt(b * b + d * d); bone.b = MathUtils.Cos(r) * s; bone.d = MathUtils.Sin(r) * s; } bone.UpdateAppliedTransform(); } }
private void ApplyRelativeWorld() { float rotateMix = this.rotateMix; float translateMix = this.translateMix; float scaleMix = this.scaleMix; float shearMix = this.shearMix; Bone target = this.target; float a = target.a; float b = target.b; float c = target.c; float d = target.d; float num9 = (((a * d) - (b * c)) <= 0f) ? -0.01745329f : 0.01745329f; float num10 = this.data.offsetRotation * num9; float num11 = this.data.offsetShearY * num9; ExposedList <Bone> bones = this.bones; int index = 0; int count = bones.Count; while (index < count) { Bone bone2 = bones.Items[index]; bool flag = false; if (rotateMix != 0f) { float num14 = bone2.a; float num15 = bone2.b; float num16 = bone2.c; float num17 = bone2.d; float radians = MathUtils.Atan2(c, a) + num10; if (radians > 3.141593f) { radians -= 6.283185f; } else if (radians < -3.141593f) { radians += 6.283185f; } radians *= rotateMix; float num19 = MathUtils.Cos(radians); float num20 = MathUtils.Sin(radians); bone2.a = (num19 * num14) - (num20 * num16); bone2.b = (num19 * num15) - (num20 * num17); bone2.c = (num20 * num14) + (num19 * num16); bone2.d = (num20 * num15) + (num19 * num17); flag = true; } if (translateMix != 0f) { target.LocalToWorld(this.data.offsetX, this.data.offsetY, out float num21, out float num22); bone2.worldX += num21 * translateMix; bone2.worldY += num22 * translateMix; flag = true; } if (scaleMix > 0f) { float num23 = (((((float)Math.Sqrt((double)((a * a) + (c * c)))) - 1f) + this.data.offsetScaleX) * scaleMix) + 1f; bone2.a *= num23; bone2.c *= num23; num23 = (((((float)Math.Sqrt((double)((b * b) + (d * d)))) - 1f) + this.data.offsetScaleY) * scaleMix) + 1f; bone2.b *= num23; bone2.d *= num23; flag = true; } if (shearMix > 0f) { float radians = MathUtils.Atan2(d, b) - MathUtils.Atan2(c, a); if (radians > 3.141593f) { radians -= 6.283185f; } else if (radians < -3.141593f) { radians += 6.283185f; } float x = bone2.b; float y = bone2.d; radians = MathUtils.Atan2(y, x) + (((radians - 1.570796f) + num11) * shearMix); float num27 = (float)Math.Sqrt((double)((x * x) + (y * y))); bone2.b = MathUtils.Cos(radians) * num27; bone2.d = MathUtils.Sin(radians) * num27; flag = true; } if (flag) { bone2.appliedValid = false; } index++; } }
private void ApplyRelativeWorld() { float num = rotateMix; float num2 = translateMix; float num3 = scaleMix; float num4 = shearMix; Bone bone = target; float a = bone.a; float b = bone.b; float c = bone.c; float d = bone.d; float num5 = (!(a * d - b * c > 0f)) ? (-(float)Math.PI / 180f) : ((float)Math.PI / 180f); float num6 = data.offsetRotation * num5; float num7 = data.offsetShearY * num5; ExposedList <Bone> exposedList = bones; int i = 0; for (int count = exposedList.Count; i < count; i++) { Bone bone2 = exposedList.Items[i]; bool flag = false; if (num != 0f) { float a2 = bone2.a; float b2 = bone2.b; float c2 = bone2.c; float d2 = bone2.d; float num8 = MathUtils.Atan2(c, a) + num6; if (num8 > (float)Math.PI) { num8 -= (float)Math.PI * 2f; } else if (num8 < -(float)Math.PI) { num8 += (float)Math.PI * 2f; } num8 *= num; float num9 = MathUtils.Cos(num8); float num10 = MathUtils.Sin(num8); bone2.a = num9 * a2 - num10 * c2; bone2.b = num9 * b2 - num10 * d2; bone2.c = num10 * a2 + num9 * c2; bone2.d = num10 * b2 + num9 * d2; flag = true; } if (num2 != 0f) { bone.LocalToWorld(data.offsetX, data.offsetY, out float worldX, out float worldY); bone2.worldX += worldX * num2; bone2.worldY += worldY * num2; flag = true; } if (num3 > 0f) { float num11 = ((float)Math.Sqrt(a * a + c * c) - 1f + data.offsetScaleX) * num3 + 1f; bone2.a *= num11; bone2.c *= num11; num11 = ((float)Math.Sqrt(b * b + d * d) - 1f + data.offsetScaleY) * num3 + 1f; bone2.b *= num11; bone2.d *= num11; flag = true; } if (num4 > 0f) { float num12 = MathUtils.Atan2(d, b) - MathUtils.Atan2(c, a); if (num12 > (float)Math.PI) { num12 -= (float)Math.PI * 2f; } else if (num12 < -(float)Math.PI) { num12 += (float)Math.PI * 2f; } float b3 = bone2.b; float d3 = bone2.d; num12 = MathUtils.Atan2(d3, b3) + (num12 - (float)Math.PI / 2f + num7) * num4; float num13 = (float)Math.Sqrt(b3 * b3 + d3 * d3); bone2.b = MathUtils.Cos(num12) * num13; bone2.d = MathUtils.Sin(num12) * num13; flag = true; } if (flag) { bone2.appliedValid = false; } } }
public void Update() { float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; Bone target = this.target; float ta = target.a, tb = target.b, tc = target.c, td = target.d; ExposedList <Bone> bones = this.bones; for (int i = 0, n = bones.Count; i < n; i++) { Bone bone = bones.Items[i]; if (rotateMix > 0) { float a = bone.a, b = bone.b, c = bone.c, d = bone.d; float r = (float)Math.Atan2(tc, ta) - (float)Math.Atan2(c, a) + data.offsetRotation * MathUtils.degRad; if (r > MathUtils.PI) { r -= MathUtils.PI2; } else if (r < -MathUtils.PI) { r += MathUtils.PI2; } r *= rotateMix; float cos = MathUtils.Cos(r), sin = MathUtils.Sin(r); bone.a = cos * a - sin * c; bone.b = cos * b - sin * d; bone.c = sin * a + cos * c; bone.d = sin * b + cos * d; } if (translateMix > 0) { float tempx, tempy; target.LocalToWorld(data.offsetX, data.offsetY, out tempx, out tempy); bone.worldX += (tempx - bone.worldX) * translateMix; bone.worldY += (tempy - bone.worldY) * translateMix; } if (scaleMix > 0) { float bs = (float)Math.Sqrt(bone.a * bone.a + bone.c * bone.c); float ts = (float)Math.Sqrt(ta * ta + tc * tc); float s = bs > 0.00001f ? (bs + (ts - bs + data.offsetScaleX) * scaleMix) / bs : 0; bone.a *= s; bone.c *= s; bs = (float)Math.Sqrt(bone.b * bone.b + bone.d * bone.d); ts = (float)Math.Sqrt(tb * tb + td * td); s = bs > 0.00001f ? (bs + (ts - bs + data.offsetScaleY) * scaleMix) / bs : 0; bone.b *= s; bone.d *= s; } if (shearMix > 0) { float b = bone.b, d = bone.d; float by = MathUtils.Atan2(d, b); float r = MathUtils.Atan2(td, tb) - MathUtils.Atan2(tc, ta) - (by - MathUtils.Atan2(bone.c, bone.a)); if (r > MathUtils.PI) { r -= MathUtils.PI2; } else if (r < -MathUtils.PI) { r += MathUtils.PI2; } r = by + (r + data.offsetShearY * MathUtils.degRad) * shearMix; float s = (float)Math.Sqrt(b * b + d * d); bone.b = MathUtils.Cos(r) * s; bone.d = MathUtils.Sin(r) * s; } } }
public void Update() { float num = this.rotateMix; float num2 = this.translateMix; float num3 = this.scaleMix; float num4 = this.shearMix; Bone bone = this.target; float a = bone.a; float b = bone.b; float c = bone.c; float d = bone.d; ExposedList <Bone> exposedList = this.bones; int i = 0; int count = exposedList.Count; while (i < count) { Bone bone2 = exposedList.Items[i]; if (num > 0f) { float a2 = bone2.a; float b2 = bone2.b; float c2 = bone2.c; float d2 = bone2.d; float num5 = (float)Math.Atan2((double)c, (double)a) - (float)Math.Atan2((double)c2, (double)a2) + this.data.offsetRotation * 0.0174532924f; if (num5 > 3.14159274f) { num5 -= 6.28318548f; } else if (num5 < -3.14159274f) { num5 += 6.28318548f; } num5 *= num; float num6 = MathUtils.Cos(num5); float num7 = MathUtils.Sin(num5); bone2.a = num6 * a2 - num7 * c2; bone2.b = num6 * b2 - num7 * d2; bone2.c = num7 * a2 + num6 * c2; bone2.d = num7 * b2 + num6 * d2; } if (num2 > 0f) { float num8; float num9; bone.LocalToWorld(this.data.offsetX, this.data.offsetY, out num8, out num9); bone2.worldX += (num8 - bone2.worldX) * num2; bone2.worldY += (num9 - bone2.worldY) * num2; } if (num3 > 0f) { float num10 = (float)Math.Sqrt((double)(bone2.a * bone2.a + bone2.c * bone2.c)); float num11 = (float)Math.Sqrt((double)(a * a + c * c)); float num12 = (num10 <= 1E-05f) ? 0f : ((num10 + (num11 - num10 + this.data.offsetScaleX) * num3) / num10); bone2.a *= num12; bone2.c *= num12; num10 = (float)Math.Sqrt((double)(bone2.b * bone2.b + bone2.d * bone2.d)); num11 = (float)Math.Sqrt((double)(b * b + d * d)); num12 = ((num10 <= 1E-05f) ? 0f : ((num10 + (num11 - num10 + this.data.offsetScaleY) * num3) / num10)); bone2.b *= num12; bone2.d *= num12; } if (num4 > 0f) { float b3 = bone2.b; float d3 = bone2.d; float num13 = MathUtils.Atan2(d3, b3); float num14 = MathUtils.Atan2(d, b) - MathUtils.Atan2(c, a) - (num13 - MathUtils.Atan2(bone2.c, bone2.a)); if (num14 > 3.14159274f) { num14 -= 6.28318548f; } else if (num14 < -3.14159274f) { num14 += 6.28318548f; } num14 = num13 + (num14 + this.data.offsetShearY * 0.0174532924f) * num4; float num15 = (float)Math.Sqrt((double)(b3 * b3 + d3 * d3)); bone2.b = MathUtils.Cos(num14) * num15; bone2.d = MathUtils.Sin(num14) * num15; } i++; } }
public void Update() { float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; Bone target = this.target; float ta = target.a, tb = target.b, tc = target.c, td = target.d; float degRadReflect = (ta * td - tb * tc > 0) ? MathUtils.DegRad : -MathUtils.DegRad; float offsetRotation = data.offsetRotation * degRadReflect, offsetShearY = data.offsetShearY * degRadReflect; var bones = this.bones; var bonesItems = bones.Items; for (int i = 0, n = bones.Count; i < n; i++) { Bone bone = bonesItems[i]; bool modified = false; if (rotateMix != 0) { float a = bone.a, b = bone.b, c = bone.c, d = bone.d; float r = MathUtils.Atan2(tc, ta) - MathUtils.Atan2(c, a) + offsetRotation; if (r > MathUtils.PI) { r -= MathUtils.PI2; } else if (r < -MathUtils.PI) { r += MathUtils.PI2; } r *= rotateMix; float cos = MathUtils.Cos(r), sin = MathUtils.Sin(r); bone.a = cos * a - sin * c; bone.b = cos * b - sin * d; bone.c = sin * a + cos * c; bone.d = sin * b + cos * d; modified = true; } if (translateMix != 0) { float tempx, tempy; target.LocalToWorld(data.offsetX, data.offsetY, out tempx, out tempy); bone.worldX += (tempx - bone.worldX) * translateMix; bone.worldY += (tempy - bone.worldY) * translateMix; modified = true; } if (scaleMix > 0) { float s = (float)Math.Sqrt(bone.a * bone.a + bone.c * bone.c); float ts = (float)Math.Sqrt(ta * ta + tc * tc); if (s > 0.00001f) { s = (s + (ts - s + data.offsetScaleX) * scaleMix) / s; } bone.a *= s; bone.c *= s; s = (float)Math.Sqrt(bone.b * bone.b + bone.d * bone.d); ts = (float)Math.Sqrt(tb * tb + td * td); if (s > 0.00001f) { s = (s + (ts - s + data.offsetScaleY) * scaleMix) / s; } bone.b *= s; bone.d *= s; modified = true; } if (shearMix > 0) { float b = bone.b, d = bone.d; float by = MathUtils.Atan2(d, b); float r = MathUtils.Atan2(td, tb) - MathUtils.Atan2(tc, ta) - (by - MathUtils.Atan2(bone.c, bone.a)); if (r > MathUtils.PI) { r -= MathUtils.PI2; } else if (r < -MathUtils.PI) { r += MathUtils.PI2; } r = by + (r + offsetShearY) * shearMix; float s = (float)Math.Sqrt(b * b + d * d); bone.b = MathUtils.Cos(r) * s; bone.d = MathUtils.Sin(r) * s; modified = true; } if (modified) { bone.appliedValid = false; } } }