当前位置: 首页>>代码示例>>C#>>正文


C# Bone.UpdateWorldTransform方法代码示例

本文整理汇总了C#中Spine.Bone.UpdateWorldTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Bone.UpdateWorldTransform方法的具体用法?C# Bone.UpdateWorldTransform怎么用?C# Bone.UpdateWorldTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Spine.Bone的用法示例。


在下文中一共展示了Bone.UpdateWorldTransform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetExtractionBone

	static Bone GetExtractionBone () {
		if (extractionBone != null)
			return extractionBone;

		SkeletonData skelData = new SkeletonData();
		BoneData data = new BoneData("temp", null);
		data.ScaleX = 1;
		data.ScaleY = 1;
		data.Length = 100;

		skelData.Bones.Add(data);

		Skeleton skeleton = new Skeleton(skelData);

		Bone bone = new Bone(data, skeleton, null);
		bone.UpdateWorldTransform();

		extractionBone = bone;

		return extractionBone;
	}
开发者ID:wenhaoisbad,项目名称:kxsm,代码行数:21,代码来源:SkeletonBaker.cs

示例2: Apply


//.........这里部分代码省略.........
				offset2 = 180;
			} else
				offset2 = 0;
			Bone pp = parent.parent;
			float tx, ty, dx, dy;
			if (pp == null) {
				tx = targetX - px;
				ty = targetY - py;
				dx = child.worldX - px;
				dy = child.worldY - py;
			} else {
				float a = pp.a, b = pp.b, c = pp.c, d = pp.d, invDet = 1 / (a * d - b * c);
				float wx = pp.worldX, wy = pp.worldY, x = targetX - wx, y = targetY - wy;
				tx = (x * d - y * b) * invDet - px;
				ty = (y * a - x * c) * invDet - py;
				x = child.worldX - wx;
				y = child.worldY - wy;
				dx = (x * d - y * b) * invDet - px;
				dy = (y * a - x * c) * invDet - py;
			}
			float l1 = (float)Math.Sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
			if (Math.Abs(psx - psy) <= 0.0001f) {
				l2 *= psx;
				float cos = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2);
				if (cos < -1) cos = -1;
				else if (cos > 1) cos = 1;
				a2 = (float)Math.Acos(cos) * bendDir;
				float a = l1 + l2 * cos, o = l2 * MathUtils.Sin(a2);
				a1 = MathUtils.Atan2(ty * a - tx * o, tx * a + ty * o);
			} else {
				cy = 0;
				float a = psx * l2, b = psy * l2, ta = MathUtils.Atan2(ty, tx);
				float aa = a * a, bb = b * b, ll = l1 * l1, dd = tx * tx + ty * ty;
				float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa;
				float d = c1 * c1 - 4 * c2 * c0;
				if (d >= 0) {
					float q = (float)Math.Sqrt(d);
					if (c1 < 0) q = -q;
					q = -(c1 + q) / 2;
					float r0 = q / c2, r1 = c0 / q;
					float r = Math.Abs(r0) < Math.Abs(r1) ? r0 : r1;
					if (r * r <= dd) {
						float y1 = (float)Math.Sqrt(dd - r * r) * bendDir;
						a1 = ta - MathUtils.Atan2(y1, r);
						a2 = MathUtils.Atan2(y1 / psy, (r - l1) / psx);
						goto outer;
					}
				}
				float minAngle = 0, minDist = float.MaxValue, minX = 0, minY = 0;
				float maxAngle = 0, maxDist = 0, maxX = 0, maxY = 0;
				float x = l1 + a, dist = x * x;
				if (dist > maxDist) {
					maxAngle = 0;
					maxDist = dist;
					maxX = x;
				}
				x = l1 - a;
				dist = x * x;
				if (dist < minDist) {
					minAngle = MathUtils.PI;
					minDist = dist;
					minX = x;
				}
				float angle = (float)Math.Acos(-a * l1 / (aa - bb));
				x = a * MathUtils.Cos(angle) + l1;
				float y = b * MathUtils.Sin(angle);
				dist = x * x + y * y;
				if (dist < minDist) {
					minAngle = angle;
					minDist = dist;
					minX = x;
					minY = y;
				}
				if (dist > maxDist) {
					maxAngle = angle;
					maxDist = dist;
					maxX = x;
					maxY = y;
				}
				if (dd <= (minDist + maxDist) / 2) {
					a1 = ta - MathUtils.Atan2(minY * bendDir, minX);
					a2 = minAngle * bendDir;
				} else {
					a1 = ta - MathUtils.Atan2(maxY * bendDir, maxX);
					a2 = maxAngle * bendDir;
				}
			}
		outer:
			float offset = MathUtils.Atan2(cy, child.x) * sign2;
			a1 = (a1 - offset) * MathUtils.radDeg + offset1;
			a2 = (a2 + offset) * MathUtils.radDeg * sign2 + offset2;
			if (a1 > 180) a1 -= 360;
			else if (a1 < -180) a1 += 360;
			if (a2 > 180) a2 -= 360;
			else if (a2 < -180) a2 += 360;
			float rotation = parent.rotation;
			parent.UpdateWorldTransform(parent.x, parent.y, rotation + (a1 - rotation) * alpha, parent.scaleX, parent.scaleY);
			rotation = child.rotation;
			child.UpdateWorldTransform(child.x, cy, rotation + (a2 - rotation) * alpha, child.scaleX, child.scaleY);
		}
开发者ID:czlc,项目名称:spine-runtimes,代码行数:101,代码来源:IkConstraint.cs

示例3: Apply

		/// <summary>Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified
		/// in the world coordinate system.</summary>
		static public void Apply (Bone bone, float targetX, float targetY, float alpha) {
			Bone pp = bone.parent;
			float id = 1 / (pp.a * pp.d - pp.b * pp.c);
			float x = targetX - pp.worldX, y = targetY - pp.worldY;
			float tx = (x * pp.d - y * pp.b) * id - bone.x, ty = (y * pp.a - x * pp.c) * id - bone.y;
			float rotationIK = MathUtils.Atan2(ty, tx) * MathUtils.radDeg - bone.shearX - bone.rotation;
			if (bone.scaleX < 0) rotationIK += 180;
			if (rotationIK > 180)
				rotationIK -= 360;
			else if (rotationIK < -180) rotationIK += 360;
			bone.UpdateWorldTransform(bone.x, bone.y, bone.rotation + rotationIK * alpha, bone.scaleX, bone.scaleY,
				bone.shearX, bone.shearY);
		}
开发者ID:Colorwen,项目名称:spine-runtimes,代码行数:15,代码来源:IkConstraint.cs


注:本文中的Spine.Bone.UpdateWorldTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。