本文整理汇总了C#中Spine.Bone类的典型用法代码示例。如果您正苦于以下问题:C# Bone类的具体用法?C# Bone怎么用?C# Bone使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bone类属于Spine命名空间,在下文中一共展示了Bone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bone
/// <param name="parent">May be null.</param>
public Bone(BoneData data, Bone parent)
{
if (data == null) throw new ArgumentNullException("data cannot be null.");
this.data = data;
this.parent = parent;
SetToSetupPose();
}
示例2: Slot
public Slot (SlotData data, Bone bone) {
if (data == null) throw new ArgumentNullException("data cannot be null.");
if (bone == null) throw new ArgumentNullException("bone cannot be null.");
this.data = data;
this.bone = bone;
SetToSetupPose();
}
示例3: Skeleton
public Skeleton (SkeletonData data) {
if (data == null) throw new ArgumentNullException("data cannot be null.");
this.data = data;
bones = new ExposedList<Bone>(data.bones.Count);
foreach (BoneData boneData in data.bones) {
Bone parent = boneData.parent == null ? null : bones.Items[data.bones.IndexOf(boneData.parent)];
Bone bone = new Bone(boneData, this, parent);
if (parent != null) parent.children.Add(bone);
bones.Add(bone);
}
slots = new ExposedList<Slot>(data.slots.Count);
drawOrder = new ExposedList<Slot>(data.slots.Count);
foreach (SlotData slotData in data.slots) {
Bone bone = bones.Items[data.bones.IndexOf(slotData.boneData)];
Slot slot = new Slot(slotData, bone);
slots.Add(slot);
drawOrder.Add(slot);
}
ikConstraints = new ExposedList<IkConstraint>(data.ikConstraints.Count);
foreach (IkConstraintData ikConstraintData in data.ikConstraints)
ikConstraints.Add(new IkConstraint(ikConstraintData, this));
transformConstraints = new ExposedList<TransformConstraint>(data.transformConstraints.Count);
foreach (TransformConstraintData transformConstraintData in data.transformConstraints)
transformConstraints.Add(new TransformConstraint(transformConstraintData, this));
UpdateCache();
UpdateWorldTransform();
}
示例4: Bone
/** @param parent May be null. */
public Bone(BoneData data, Bone parent)
{
if (data == null) throw new ArgumentNullException("data cannot be null.");
Data = data;
Parent = parent;
SetToBindPose();
}
示例5: 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) {
float parentRotation = (!bone.data.inheritRotation || bone.parent == null) ? 0 : bone.parent.worldRotation;
float rotation = bone.rotation;
float rotationIK = (float)Math.Atan2(targetY - bone.worldY, targetX - bone.worldX) * radDeg;
if (bone.worldFlipX != (bone.worldFlipY != Bone.yDown)) rotationIK = -rotationIK;
rotationIK -= parentRotation;
bone.rotationIK = rotation + (rotationIK - rotation) * alpha;
}
示例6: Bone
/// <param name="parent">May be null.</param>
public Bone (BoneData data, Skeleton skeleton, Bone parent) {
if (data == null) throw new ArgumentNullException("data", "data cannot be null.");
if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
this.data = data;
this.skeleton = skeleton;
this.parent = parent;
SetToSetupPose();
}
示例7: Start
void Start() {
if (speedReference == null)
speedReference = transform;
skeletonAnimation = GetComponent<SkeletonAnimation>();
bone = SpineBone.GetBone(boneName, skeletonAnimation);
skeletonAnimation.UpdateLocal += UpdateLocal;
lastPosition = speedReference.position;
}
示例8: 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) {
float parentRotation = bone.parent == null ? 0 : bone.parent.WorldRotationX;
float rotation = bone.rotation;
float rotationIK = MathUtils.Atan2(targetY - bone.worldY, targetX - bone.worldX) * MathUtils.radDeg - parentRotation;
if (bone.worldSignX != bone.worldSignY) rotationIK = 360 - rotationIK;
if (rotationIK > 180) rotationIK -= 360;
else if (rotationIK < -180) rotationIK += 360;
bone.UpdateWorldTransform(bone.x, bone.y, rotation + (rotationIK - rotation) * alpha, bone.scaleX, bone.scaleY);
}
示例9: IkConstraint
public IkConstraint (IkConstraintData data, Skeleton skeleton) {
this.data = data;
mix = data.mix;
bendDirection = data.bendDirection;
bones = new List<Bone>(data.bones.Count);
foreach (BoneData boneData in data.bones)
bones.Add(skeleton.FindBone(boneData.name));
target = skeleton.FindBone(data.target.name);
}
示例10: Slot
public Slot(SlotData data, Skeleton skeleton, Bone bone)
{
if (data == null) throw new ArgumentNullException("data cannot be null.");
if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
if (bone == null) throw new ArgumentNullException("bone cannot be null.");
Data = data;
Skeleton = skeleton;
Bone = bone;
SetToSetupPose();
}
示例11: TransformConstraint
public TransformConstraint (TransformConstraintData data, Skeleton skeleton) {
if (data == null) throw new ArgumentNullException("data cannot be null.");
if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
this.data = data;
translateMix = data.translateMix;
x = data.x;
y = data.y;
bone = skeleton.FindBone(data.bone.name);
target = skeleton.FindBone(data.target.name);
}
示例12: IkConstraint
public IkConstraint (IkConstraintData data, Skeleton skeleton) {
if (data == null) throw new ArgumentNullException("data cannot be null.");
if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
this.data = data;
mix = data.mix;
bendDirection = data.bendDirection;
bones = new ExposedList<Bone>(data.bones.Count);
foreach (BoneData boneData in data.bones)
bones.Add(skeleton.FindBone(boneData.name));
target = skeleton.FindBone(data.target.name);
}
示例13: 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);
}
示例14: Start
void Start()
{
clock = GetComponent<SkeletonAnimation>();
clockState = clock.state;
clockState.TimeScale = 1.0f;
clockState.SetAnimation(0, "loop", true);
armLong = clock.skeleton.FindBone ("arm-long");
armShort = clock.skeleton.FindBone ("arm-short");
needle = clock.skeleton.FindBone ("needle");
Debug.Log (armLong);
Debug.Log (armShort);
Debug.Log (needle);
}
示例15: ComputeWorldVertices
/// <param name="worldVertices">Must have at least the same length as this attachment's vertices.</param>
public void ComputeWorldVertices (Bone bone, float[] worldVertices) {
float x = bone.skeleton.x + bone.worldX, y = bone.skeleton.y + bone.worldY;
float m00 = bone.m00;
float m01 = bone.m01;
float m10 = bone.m10;
float m11 = bone.m11;
float[] vertices = this.vertices;
for (int i = 0, n = vertices.Length; i < n; i += 2) {
float px = vertices[i];
float py = vertices[i + 1];
worldVertices[i] = px * m00 + py * m01 + x;
worldVertices[i + 1] = px * m10 + py * m11 + y;
}
}