本文整理汇总了C#中Spine.Skeleton类的典型用法代码示例。如果您正苦于以下问题:C# Skeleton类的具体用法?C# Skeleton怎么用?C# Skeleton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Skeleton类属于Spine命名空间,在下文中一共展示了Skeleton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnimationPlayer
public AnimationPlayer(SkeletonData skeletonData)
{
this.skeletonData = skeletonData;
skeleton = new Skeleton(skeletonData);
skeleton.SetSlotsToSetupPose();
animationDataPool = new ObjectPool<AnimationData>(() => new AnimationData(), 10);
}
示例2: Update
public void Update (Skeleton skeleton, bool updateAabb) {
ExposedList<BoundingBoxAttachment> boundingBoxes = BoundingBoxes;
ExposedList<Polygon> polygons = Polygons;
ExposedList<Slot> slots = skeleton.slots;
int slotCount = slots.Count;
boundingBoxes.Clear();
for (int i = 0, n = polygons.Count; i < n; i++)
polygonPool.Add(polygons.Items[i]);
polygons.Clear();
for (int i = 0; i < slotCount; i++) {
Slot slot = slots.Items[i];
BoundingBoxAttachment boundingBox = slot.attachment as BoundingBoxAttachment;
if (boundingBox == null) continue;
boundingBoxes.Add(boundingBox);
Polygon polygon = null;
int poolCount = polygonPool.Count;
if (poolCount > 0) {
polygon = polygonPool.Items[poolCount - 1];
polygonPool.RemoveAt(poolCount - 1);
} else
polygon = new Polygon();
polygons.Add(polygon);
int count = boundingBox.Vertices.Length;
polygon.Count = count;
if (polygon.Vertices.Length < count) polygon.Vertices = new float[count];
boundingBox.ComputeWorldVertices(slot, polygon.Vertices);
}
if (updateAabb) aabbCompute();
}
示例3: Animation
public Animation(string AnimationFile)
{
skeletonRenderer = new SkeletonRenderer();
String name = AnimationFile;
Atlas atlas = new Atlas("Data/" + name + ".atlas", new GLImpTextureLoader());
SkeletonJson json = new SkeletonJson(atlas);
skeleton = new Skeleton(json.ReadSkeletonData("Data/" + name + ".json"));
skeleton.SetSlotsToSetupPose();
// Define mixing between animations.
stateData = new AnimationStateData(skeleton.Data);
state = new AnimationState(stateData);
//state.SetAnimation("idle", true);
skeleton.X = 0;
skeleton.Y = 0.1f;
skeleton.UpdateWorldTransform();
drawtime = new Stopwatch();
drawtime.Start();
Program.MiddleDrawQueue += Draw;
}
示例4: Start
void Start () {
// Make sure you get these AnimationState and Skeleton references in Start or Later. Getting and using them in Awake is not guaranteed by default execution order.
skeletonAnimation = GetComponent<SkeletonAnimation>();
spineAnimationState = skeletonAnimation.state;
skeleton = skeletonAnimation.skeleton;
StartCoroutine(DoDemoRoutine());
}
示例5: 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();
}
示例6: Entity
public Entity(Skeleton skeleton, Vector2 position)
: this(position)
{
Skeleton = skeleton;
skeletonBoundingBox = ResourceManager.GetSkeletonBoundingBox(skeleton.Data.Name);
AnimationState = new AnimationState(new AnimationStateData(skeleton.Data));
RenderShadow = true;
}
示例7: SkeletonSpatial
public SkeletonSpatial(GraphicsDevice device, string contentPath, string skin)
{
if (!_registered.TryGetValue(contentPath, out _record))
_record = Load(device, contentPath);
_skeleton = new Skeleton(_record.Data);
_skeleton.SetSkin(skin);
_skeleton.SetSlotsToBindPose();
}
示例8: Draw
public void Draw (Skeleton skeleton) {
var drawOrder = skeleton.DrawOrder;
var drawOrderItems = skeleton.DrawOrder.Items;
float skeletonR = skeleton.R, skeletonG = skeleton.G, skeletonB = skeleton.B, skeletonA = skeleton.A;
for (int i = 0, n = drawOrder.Count; i < n; i++) {
Slot slot = drawOrderItems[i];
RegionAttachment regionAttachment = slot.Attachment as RegionAttachment;
if (regionAttachment != null) {
BlendState blend = slot.Data.BlendMode == BlendMode.additive ? BlendState.Additive : defaultBlendState;
if (device.BlendState != blend) {
End();
device.BlendState = blend;
}
RegionItem item = batcher.NextItem();
AtlasRegion region = (AtlasRegion)regionAttachment.RendererObject;
item.texture = (Texture2D)region.page.rendererObject;
Color color;
float a = skeletonA * slot.A;
if (premultipliedAlpha)
color = new Color(skeletonR * slot.R * a, skeletonG * slot.G * a, skeletonB * slot.B * a, a);
else
color = new Color(skeletonR * slot.R, skeletonG * slot.G, skeletonB * slot.B, a);
item.vertexTL.Color = color;
item.vertexBL.Color = color;
item.vertexBR.Color = color;
item.vertexTR.Color = color;
float[] vertices = this.vertices;
regionAttachment.ComputeWorldVertices(slot.Bone, vertices);
item.vertexTL.Position.X = vertices[RegionAttachment.X1];
item.vertexTL.Position.Y = vertices[RegionAttachment.Y1];
item.vertexTL.Position.Z = 0;
item.vertexBL.Position.X = vertices[RegionAttachment.X2];
item.vertexBL.Position.Y = vertices[RegionAttachment.Y2];
item.vertexBL.Position.Z = 0;
item.vertexBR.Position.X = vertices[RegionAttachment.X3];
item.vertexBR.Position.Y = vertices[RegionAttachment.Y3];
item.vertexBR.Position.Z = 0;
item.vertexTR.Position.X = vertices[RegionAttachment.X4];
item.vertexTR.Position.Y = vertices[RegionAttachment.Y4];
item.vertexTR.Position.Z = 0;
float[] uvs = regionAttachment.UVs;
item.vertexTL.TextureCoordinate.X = uvs[RegionAttachment.X1];
item.vertexTL.TextureCoordinate.Y = uvs[RegionAttachment.Y1];
item.vertexBL.TextureCoordinate.X = uvs[RegionAttachment.X2];
item.vertexBL.TextureCoordinate.Y = uvs[RegionAttachment.Y2];
item.vertexBR.TextureCoordinate.X = uvs[RegionAttachment.X3];
item.vertexBR.TextureCoordinate.Y = uvs[RegionAttachment.Y3];
item.vertexTR.TextureCoordinate.X = uvs[RegionAttachment.X4];
item.vertexTR.TextureCoordinate.Y = uvs[RegionAttachment.Y4];
}
}
}
示例9: 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.");
this.data = data;
this.skeleton = skeleton;
this.bone = bone;
SetToSetupPose();
}
示例10: Apply
/** Poses the skeleton at the specified time for this animation. */
public void Apply(Skeleton skeleton, float time, bool loop)
{
if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
if (loop && Duration != 0) time %= Duration;
List<Timeline> timelines = Timelines;
for (int i = 0, n = timelines.Count; i < n; i++)
timelines[i].Apply(skeleton, time, 1);
}
示例11: DrawPackage
public DrawPackage(Vector2 pPosition, float pPositionZ, Rectangle pCollisionBox, Color pDebugColor, Skeleton pSkeleton, float pAlpha = 1f)
{
mPosition = pPosition;
mPositionZ = pPositionZ;
mCollisionBox = pCollisionBox;
mDebugColor = pDebugColor;
mSkeleton = pSkeleton;
mAlpha = pAlpha;
Spine = true;
}
示例12: 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);
}
示例13: 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);
}
示例14: DrawSlots
private void DrawSlots(Skeleton skeleton)
{
isNormalTriangleWindingOrder = skeleton.FlipX ^ skeleton.FlipY;
List<Slot> drawOrder = skeleton.DrawOrder;
foreach (Slot slot in drawOrder)
{
var attachment = slot.Attachment as RegionAttachment;
if (attachment != null)
DrawSlot(skeleton, attachment, slot);
}
}
示例15: Draw
public void Draw(Skeleton skeleton, Vector3 Position)
{
List<Slot> DrawOrder = skeleton.DrawOrder;
float depth = Z;
float depth_offset = 0.0001f;
for (int i = 0; i < DrawOrder.Count; i++) {
Slot slot = DrawOrder[i];
RegionAttachment regionAttachment = slot.Attachment as RegionAttachment;
if (regionAttachment != null) {
SpriteBatchItem item = new SpriteBatchItem();
AtlasRegion region = (AtlasRegion)regionAttachment.RendererObject;
item.Texture = (int)region.page.rendererObject;
byte r = (byte)(skeleton.R * slot.R * 255);
byte g = (byte)(skeleton.G * slot.G * 255);
byte b = (byte)(skeleton.B * slot.B * 255);
byte a = (byte)(skeleton.A * slot.A * 255);
item.vertexTL.Color = Color.FromArgb(a, r, g, b);
item.vertexBL.Color = Color.FromArgb(a, r, g, b);
item.vertexBR.Color = Color.FromArgb(a, r, g, b);
item.vertexTR.Color = Color.FromArgb(a, r, g, b);
float[] vertices = this.vertices;
regionAttachment.ComputeWorldVertices(skeleton.X, skeleton.Y, slot.Bone, vertices);
item.vertexTL.Position.X = vertices[RegionAttachment.X1];
item.vertexTL.Position.Y = vertices[RegionAttachment.Y1];
item.vertexTL.Position.Z = depth;
item.vertexBL.Position.X = vertices[RegionAttachment.X2];
item.vertexBL.Position.Y = vertices[RegionAttachment.Y2];
item.vertexBL.Position.Z = depth;
item.vertexBR.Position.X = vertices[RegionAttachment.X3];
item.vertexBR.Position.Y = vertices[RegionAttachment.Y3];
item.vertexBR.Position.Z = depth;
item.vertexTR.Position.X = vertices[RegionAttachment.X4];
item.vertexTR.Position.Y = vertices[RegionAttachment.Y4];
item.vertexTR.Position.Z = depth;
float[] uvs = regionAttachment.UVs;
item.vertexTL.TextureCoordinate.X = uvs[RegionAttachment.X1];
item.vertexTL.TextureCoordinate.Y = uvs[RegionAttachment.Y1];
item.vertexBL.TextureCoordinate.X = uvs[RegionAttachment.X2];
item.vertexBL.TextureCoordinate.Y = uvs[RegionAttachment.Y2];
item.vertexBR.TextureCoordinate.X = uvs[RegionAttachment.X3];
item.vertexBR.TextureCoordinate.Y = uvs[RegionAttachment.Y3];
item.vertexTR.TextureCoordinate.X = uvs[RegionAttachment.X4];
item.vertexTR.TextureCoordinate.Y = uvs[RegionAttachment.Y4];
this.DrawItem(item);
depth += depth_offset;
}
}
}