本文整理汇总了C#中Spine.Skeleton.UpdateWorldTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Skeleton.UpdateWorldTransform方法的具体用法?C# Skeleton.UpdateWorldTransform怎么用?C# Skeleton.UpdateWorldTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spine.Skeleton
的用法示例。
在下文中一共展示了Skeleton.UpdateWorldTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: LoadContent
protected override void LoadContent()
{
Effect spriteBatchEffect = Content.Load<Effect>("SpriteBatchEffect");
spriteBatch = new SpriteBatchEx(GraphicsDevice, spriteBatchEffect);
Bone.yDown = true;
skeletonData = Content.Load<SkeletonData>("spineboy/spineboy");
skeleton = new Skeleton(skeletonData);
skeleton.SetSlotsToSetupPose();
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
animationState = new AnimationState(stateData);
animationState.SetAnimation(0, "walk", true);
skeleton.UpdateWorldTransform();
}
示例3: Avatar
public Avatar(string AnimationFile)
{
SkeletonRenderer = new SkeletonRenderer(Vector3.UnitY, Vector3.UnitZ);
String name = AnimationFile;
Atlas atlas = new Atlas(name + ".atlas", new OpenTKTextureLoader());
SkeletonJson json = new SkeletonJson(atlas);
Skeleton = new Skeleton(json.ReadSkeletonData(name + ".json"));
Skeleton.SetSlotsToSetupPose();
// Define mixing between animations.
StateData = new AnimationStateData(Skeleton.Data);
State = new AnimationState(StateData);
Skeleton.X = 0;
Skeleton.Y = 0;
Skeleton.UpdateWorldTransform();
}
示例4: LoadContent
protected override void LoadContent()
{
skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
Texture2D texture = Util.LoadTexture(GraphicsDevice, "data/goblins.png");
Atlas atlas = new Atlas("data/goblins.atlas", texture, texture.Width, texture.Height);
SkeletonJson json = new SkeletonJson(atlas);
skeleton = new Skeleton(json.ReadSkeletonData("data/goblins.json"));
skeleton.SetSkin("goblingirl");
skeleton.SetSlotsToBindPose(); // Without this the skin attachments won't be attached. See SetSkin.
animation = skeleton.Data.FindAnimation("walk");
skeleton.RootBone.X = 320;
skeleton.RootBone.Y = 440;
skeleton.UpdateWorldTransform();
}
示例5: LoadContent
protected override void LoadContent () {
skeletonRenderer = new SkeletonMeshRenderer(GraphicsDevice);
skeletonRenderer.PremultipliedAlpha = true;
// String name = "spineboy";
// String name = "goblins-mesh";
String name = "raptor";
bool binaryData = true;
Atlas atlas = new Atlas(assetsFolder + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
float scale = 1;
if (name == "spineboy") scale = 0.6f;
if (name == "raptor") scale = 0.5f;
SkeletonData skeletonData;
if (binaryData) {
SkeletonBinary binary = new SkeletonBinary(atlas);
binary.Scale = scale;
skeletonData = binary.ReadSkeletonData(assetsFolder + name + ".skel");
} else {
SkeletonJson json = new SkeletonJson(atlas);
json.Scale = scale;
skeletonData = json.ReadSkeletonData(assetsFolder + name + ".json");
}
skeleton = new Skeleton(skeletonData);
if (name == "goblins-mesh") skeleton.SetSkin("goblin");
// Define mixing between animations.
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
state = new AnimationState(stateData);
if (name == "spineboy") {
stateData.SetMix("run", "jump", 0.2f);
stateData.SetMix("jump", "run", 0.4f);
// Event handling for all animations.
state.Start += Start;
state.End += End;
state.Complete += Complete;
state.Event += Event;
state.SetAnimation(0, "test", false);
TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
entry.End += End; // Event handling for queued animations.
state.AddAnimation(0, "run", true, 0);
} else if (name == "raptor") {
state.SetAnimation(0, "walk", true);
state.SetAnimation(1, "empty", false);
state.AddAnimation(1, "gungrab", false, 2);
} else {
state.SetAnimation(0, "walk", true);
}
skeleton.X = 400;
skeleton.Y = 590;
skeleton.UpdateWorldTransform();
headSlot = skeleton.FindSlot("head");
}
示例6: ParseRotateTimeline
static void ParseRotateTimeline (Skeleton skeleton, RotateTimeline timeline, AnimationClip clip) {
var boneData = skeleton.Data.Bones[timeline.BoneIndex];
var bone = skeleton.Bones[timeline.BoneIndex];
AnimationCurve curve = new AnimationCurve();
float endTime = timeline.Frames[(timeline.FrameCount * 2) - 2];
float currentTime = timeline.Frames[0];
List<Keyframe> keys = new List<Keyframe>();
float rotation = timeline.Frames[1] + boneData.Rotation;
keys.Add(new Keyframe(timeline.Frames[0], rotation, 0, 0));
int listIndex = 1;
int frameIndex = 1;
int f = 2;
float[] frames = timeline.Frames;
skeleton.SetToSetupPose();
float lastTime = 0;
float angle = rotation;
while (currentTime < endTime) {
int pIndex = listIndex - 1;
float curveType = timeline.GetCurveType(frameIndex - 1);
if (curveType == 0) {
//linear
Keyframe pk = keys[pIndex];
float time = frames[f];
rotation = frames[f + 1] + boneData.Rotation;
angle += Mathf.DeltaAngle(angle, rotation);
float r = angle;
float rOut = (r - pk.value) / (time - pk.time);
pk.outTangent = rOut;
keys.Add(new Keyframe(time, r, rOut, 0));
keys[pIndex] = pk;
currentTime = time;
timeline.Apply(skeleton, lastTime, currentTime, null, 1);
lastTime = time;
listIndex++;
} else if (curveType == 1) {
//stepped
Keyframe pk = keys[pIndex];
float time = frames[f];
rotation = frames[f + 1] + boneData.Rotation;
angle += Mathf.DeltaAngle(angle, rotation);
float r = angle;
float rOut = float.PositiveInfinity;
pk.outTangent = rOut;
keys.Add(new Keyframe(time, r, rOut, 0));
keys[pIndex] = pk;
currentTime = time;
timeline.Apply(skeleton, lastTime, currentTime, null, 1);
lastTime = time;
listIndex++;
} else if (curveType == 2) {
//bezier
Keyframe pk = keys[pIndex];
float time = frames[f];
timeline.Apply(skeleton, lastTime, currentTime, null, 1);
skeleton.UpdateWorldTransform();
rotation = frames[f + 1] + boneData.Rotation;
angle += Mathf.DeltaAngle(angle, rotation);
float r = angle;
int steps = Mathf.FloorToInt((time - pk.time) / bakeIncrement);
for (int i = 1; i <= steps; i++) {
currentTime += bakeIncrement;
if (i == steps)
currentTime = time;
timeline.Apply(skeleton, lastTime, currentTime, null, 1);
skeleton.UpdateWorldTransform();
pk = keys[listIndex - 1];
//.........这里部分代码省略.........
示例7: ExtractSkinnedMeshAttachment
static Mesh ExtractSkinnedMeshAttachment (string name, SkinnedMeshAttachment attachment, int slotIndex, SkeletonData skeletonData, List<Transform> boneList, Mesh mesh = null) {
Skeleton skeleton = new Skeleton(skeletonData);
skeleton.UpdateWorldTransform();
float[] floatVerts = new float[attachment.UVs.Length];
attachment.ComputeWorldVertices(skeleton.Slots[slotIndex], floatVerts);
Vector2[] uvs = ExtractUV(attachment.UVs);
Vector3[] verts = ExtractVerts(floatVerts);
int[] triangles = attachment.Triangles;
Color color = new Color(attachment.R, attachment.G, attachment.B, attachment.A);
if (mesh == null)
mesh = new Mesh();
mesh.triangles = new int[0];
mesh.vertices = verts;
mesh.uv = uvs;
mesh.triangles = triangles;
Color[] colors = new Color[verts.Length];
for (int i = 0; i < verts.Length; i++)
colors[i] = color;
mesh.colors = colors;
mesh.name = name;
mesh.RecalculateNormals();
mesh.RecalculateBounds();
//Handle weights and binding
Dictionary<int, BoneWeightContainer> weightTable = new Dictionary<int, BoneWeightContainer>();
System.Text.StringBuilder warningBuilder = new System.Text.StringBuilder();
int[] bones = attachment.Bones;
float[] weights = attachment.Weights;
for (int w = 0, v = 0, b = 0, n = bones.Length; v < n; w += 2) {
int nn = bones[v++] + v;
for (; v < nn; v++, b += 3) {
Transform boneTransform = boneList[bones[v]];
int vIndex = w / 2;
float weight = weights[b + 2];
BoneWeightContainer container;
if (weightTable.ContainsKey(vIndex))
container = weightTable[vIndex];
else {
container = new BoneWeightContainer();
weightTable.Add(vIndex, container);
}
container.Add(boneTransform, weight);
}
}
BoneWeight[] boneWeights = new BoneWeight[weightTable.Count];
for (int i = 0; i < weightTable.Count; i++) {
BoneWeight bw = new BoneWeight();
var container = weightTable[i];
var pairs = container.pairs.OrderByDescending(pair => pair.weight).ToList();
for (int b = 0; b < pairs.Count; b++) {
if (b > 3) {
if (warningBuilder.Length == 0)
warningBuilder.Insert(0, "[SkinnedMeshAttachment " + name + "]\r\nUnity only supports 4 weight influences per vertex! The 4 strongest influences will be used.\r\n");
warningBuilder.AppendFormat("{0} ignored on vertex {1}!\r\n", pairs[b].bone.name, i);
continue;
}
int boneIndex = boneList.IndexOf(pairs[b].bone);
float weight = pairs[b].weight;
switch (b) {
case 0:
bw.boneIndex0 = boneIndex;
bw.weight0 = weight;
break;
case 1:
bw.boneIndex1 = boneIndex;
bw.weight1 = weight;
break;
case 2:
bw.boneIndex2 = boneIndex;
bw.weight2 = weight;
break;
case 3:
bw.boneIndex3 = boneIndex;
bw.weight3 = weight;
break;
}
}
boneWeights[i] = bw;
//.........这里部分代码省略.........
示例8: LoadContent
public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice)
{
blankTex = content.Load<Texture2D>("blank");
skeletonRenderer = new SkeletonRenderer(graphicsDevice);
Atlas atlas = new Atlas(graphicsDevice, Path.Combine(content.RootDirectory, "spinegirl.atlas"));
SkeletonJson json = new SkeletonJson(atlas);
skeleton = new Skeleton(json.readSkeletonData("spinegirl", File.ReadAllText(Path.Combine(content.RootDirectory, "spinegirl.json"))));
skeleton.SetSkin("default");
skeleton.SetSlotsToBindPose();
Animations.Add("walk", skeleton.Data.FindAnimation("walk"));
Animations.Add("jump", skeleton.Data.FindAnimation("jump"));
Animations.Add("crawl", skeleton.Data.FindAnimation("crawl"));
Animations.Add("fall", skeleton.Data.FindAnimation("fall"));
Animations.Add("grab", skeleton.Data.FindAnimation("grab"));
Animations.Add("climb", skeleton.Data.FindAnimation("climb"));
Animations.Add("turnvalve", skeleton.Data.FindAnimation("turnvalve"));
skeleton.RootBone.X = Position.X;
skeleton.RootBone.Y = Position.Y;
skeleton.RootBone.ScaleX = Scale;
skeleton.RootBone.ScaleY = Scale;
skeleton.UpdateWorldTransform();
}
示例9: LoadContent
protected override void LoadContent()
{
skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
Atlas atlas = new Atlas(GraphicsDevice, "data/spineboy.atlas");
SkeletonJson json = new SkeletonJson(atlas);
skeleton = new Skeleton(json.readSkeletonData("spineboy", File.ReadAllText("data/spineboy.json")));
animation = skeleton.Data.FindAnimation("walk");
skeleton.RootBone.X = 320;
skeleton.RootBone.Y = 440;
skeleton.UpdateWorldTransform();
}
示例10: LoadContent
public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice)
{
//blankTex = content.Load<Texture2D>("blank");
skeletonRenderer = new SkeletonRenderer(graphicsDevice);
Atlas atlas = new Atlas(graphicsDevice, "dude/dude.atlas", content);
SkeletonJson json = new SkeletonJson(atlas);
skeleton = new Skeleton(json.readSkeletonData("dude", File.ReadAllText(Path.Combine(content.RootDirectory, "dude/dude.json"))));
skeleton.SetSkin("default");
skeleton.SetSlotsToBindPose();
Color topColor = Color.Navy;
Color bottomColor = Color.Navy;
Color shoesColor = Color.DarkGray;
Vector3 skinColor = SkinTone().ToVector3();
Vector3 hairColor = HairColor().ToVector3();
foreach (Slot s in skeleton.Slots)
{
if (s.Data.Name == "torso" ||
s.Data.Name == "arm-back-upper" ||
s.Data.Name == "arm-back-lower" ||
s.Data.Name == "arm-upper" ||
s.Data.Name == "arm-lower")
{
s.Data.R = topColor.R;
s.Data.G = topColor.G;
s.Data.B = topColor.B;
}
if (s.Data.Name == "leg-left" ||
s.Data.Name == "leg-right")
{
s.Data.R = bottomColor.R;
s.Data.G = bottomColor.G;
s.Data.B = bottomColor.B;
}
if (s.Data.Name == "foot-left" ||
s.Data.Name == "foot-right")
{
s.Data.R = shoesColor.R;
s.Data.G = shoesColor.G;
s.Data.B = shoesColor.B;
}
if (s.Data.Name == "head" ||
s.Data.Name == "hand" ||
s.Data.Name == "hand-copy")
{
s.Data.R = skinColor.X;
s.Data.G = skinColor.Y;
s.Data.B = skinColor.Z;
}
if (s.Data.Name == "hair")
{
s.Data.R = hairColor.X;
s.Data.G = hairColor.Y;
s.Data.B = hairColor.Z;
}
}
skeleton.SetSkin("default");
skeleton.SetSlotsToBindPose();
Animations.Add("walk", skeleton.Data.FindAnimation("walk"));
Animations.Add("punch-hold", skeleton.Data.FindAnimation("punch-hold"));
Animations.Add("punch-release", skeleton.Data.FindAnimation("punch-release"));
Animations.Add("knockback", skeleton.Data.FindAnimation("knockback"));
Animations.Add("pickup", skeleton.Data.FindAnimation("pickup"));
Animations.Add("knockout", skeleton.Data.FindAnimation("knockout"));
Animations.Add("panic", skeleton.Data.FindAnimation("panic"));
skeleton.RootBone.X = Position.X;
skeleton.RootBone.Y = Position.Y;
skeleton.RootBone.ScaleX = Scale;
skeleton.RootBone.ScaleY = Scale;
skeleton.UpdateWorldTransform();
skeleton.SetAttachment("melee-item", null);
skeleton.SetAttachment("hat", (IsCoPilot || IsPlayer) ? "Pilot-Hat" : null);
skeleton.SetAttachment("hair", (Helper.Random.Next(2) == 0 ? "Hair-Male" : "Hair-Female"));
skeleton.SetAttachment("chute", null);
HasParachute = false;
//skeleton.FindSlot("fist-item").A = 0f;
}
示例11: LoadContent
public void LoadContent(SkeletonRenderer sr, Texture2D bt, Atlas atlas, string json)
{
blankTex = bt;
skeletonRenderer =sr;
SkeletonJson skjson = new SkeletonJson(atlas);
skeleton = new Skeleton(skjson.readSkeletonData("robo", json));
tint = new Color(0.5f + ((float)rand.NextDouble() * 0.5f), 0.5f + ((float)rand.NextDouble() * 0.5f), 0.5f + ((float)rand.NextDouble() * 0.5f));
skeleton.R = tint.ToVector3().X;
skeleton.G = tint.ToVector3().Y;
skeleton.B = tint.ToVector3().Z;
foreach (Slot s in skeleton.Slots)
{
if (s.Data.Name != "melee-item" && s.Data.Name != "projectile-item" && s.Data.Name != "fist-item")
{
s.Data.R = skeleton.R;
s.Data.G = skeleton.G;
s.Data.B = skeleton.B;
}
}
skeleton.SetSkin("default");
skeleton.SetSlotsToBindPose();
Animations.Add("walk", skeleton.Data.FindAnimation("walk"));
Animations.Add("punch-hold", skeleton.Data.FindAnimation("punch-hold"));
Animations.Add("punch-release", skeleton.Data.FindAnimation("punch-release"));
Animations.Add("knockback", skeleton.Data.FindAnimation("knockback"));
Animations.Add("pickup", skeleton.Data.FindAnimation("pickup"));
Animations.Add("knockout", skeleton.Data.FindAnimation("knockout"));
skeleton.RootBone.X = Position.X;
skeleton.RootBone.Y = Position.Y;
skeleton.RootBone.ScaleX = Scale;
skeleton.RootBone.ScaleY = Scale;
skeleton.UpdateWorldTransform();
skeleton.FindSlot("fist-item").A = 0f;
fistSound = AudioController.effects["fist"].CreateInstance();
fistSound.IsLooped = true;
fistSound.Volume = 0f;
fistSound.Pitch = -1f;
fistSound.Play();
}
示例12: LoadContent
protected override void LoadContent()
{
skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
Atlas atlas = new Atlas(GraphicsDevice, "data/goblins.atlas");
SkeletonJson json = new SkeletonJson(atlas);
skeleton = new Skeleton(json.readSkeletonData("goblins", File.ReadAllText("data/goblins.json")));
skeleton.SetSkin("goblingirl");
skeleton.SetSlotsToBindPose();
animation = skeleton.Data.FindAnimation("walk");
skeleton.RootBone.X = 320;
skeleton.RootBone.Y = 440;
skeleton.UpdateWorldTransform();
}
示例13: BuildSkeleton
// build the sprite and slots with the skeleton data
private void BuildSkeleton(SkeletonData skeletonData)
{
skeleton = new Skeleton(skeletonData);
skeleton.UpdateWorldTransform();
// check if there are multiple skins loaded
if(skeleton.Data.Skins.Count > 0){
// load the first skin as default
SetSkin(skeleton.Data.Skins[0].Name);
}
// build all the child sprites in the container, add them based on the slot draw order and create using the default slot/attachment
for(int i = 0; i < skeleton.DrawOrder.Count; i++){
GSpineSlot slot = new GSpineSlot(skeleton.DrawOrder[i]);
slots.Add(slot);
AddChild(slot);
}
AnimationStateData animationStateData = new AnimationStateData(skeleton.Data);
animation = new Spine.AnimationState(animationStateData);
}
示例14: LoadContent
protected override void LoadContent()
{
skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
Atlas atlas = new Atlas("data/goblins.atlas", new XnaTextureLoader(GraphicsDevice));
SkeletonJson json = new SkeletonJson(atlas);
skeleton = new Skeleton(json.ReadSkeletonData("data/goblins.json"));
skeleton.SetSkin("goblingirl");
skeleton.SetSlotsToBindPose(); // Without this the skin attachments won't be attached. See SetSkin.
skeleton.SetAttachment("left hand item", "spear");
animation = skeleton.Data.FindAnimation("walk");
skeleton.RootBone.X = 320;
skeleton.RootBone.Y = 440;
skeleton.UpdateWorldTransform();
}
示例15: Draw
public void Draw(Skeleton skeleton, Color color)
{
beginSkeletonRenderer();
Vector4 colorBefore = new Vector4(skeleton.R, skeleton.G, skeleton.B, skeleton.A);
updateColor(ref color);
tintSkeleton(skeleton, color);
if (Camera != null)
{
float previousX = skeleton.RootBone.X;
float previousY = skeleton.RootBone.Y;
float previousScaleX = skeleton.RootBone.ScaleX;
float previousScaleY = skeleton.RootBone.ScaleY;
Vector2 position = Camera.TranslateVector(new Vector2(previousX, previousY));
skeleton.RootBone.X = position.X;
skeleton.RootBone.Y = position.Y;
skeleton.RootBone.ScaleX *= Camera.Scale.X;
skeleton.RootBone.ScaleY *= Camera.Scale.Y;
skeleton.UpdateWorldTransform();
skeletonRenderer.Draw(skeleton);
skeleton.RootBone.X = previousX;
skeleton.RootBone.Y = previousY;
skeleton.RootBone.ScaleX = previousScaleX;
skeleton.RootBone.ScaleY = previousScaleY;
skeleton.UpdateWorldTransform();
}
else
skeletonRenderer.Draw(skeleton);
skeleton.R = colorBefore.X;
skeleton.G = colorBefore.Y;
skeleton.B = colorBefore.Z;
skeleton.A = colorBefore.W;
}