clym Posted January 9, 2018 Report Share Posted January 9, 2018 Hi there, I'm currently trying to work with the .scon (json) file type that Spriter exports and I'm slightly confused by some of it's translation... Q: (Using Spriter release 11) - For the root bone, the X & Y positions found in the timeline array are the same as in the editor. - However the child bones X&Y position in the .scon seem to be very different to the editor and I can't figure out if the position is relative to the end X&Y of the parent/root bone? Or something else. any info on that would be great! Let me know if you need an aditional info/pics I'm finding the bone info under: entity[0].animation[0].timeline[0].key[0].bone.angle Thanks, Clym Quote Link to comment Share on other sites More sharing options...
lucid Posted January 9, 2018 Report Share Posted January 9, 2018 hello @clym , it's relative to the end parent x&y. Quote Link to comment Share on other sites More sharing options...
clym Posted January 9, 2018 Author Report Share Posted January 9, 2018 Hi @lucid many thanks for your speedy reply! That's also what I thought originally although the numbers aren't coming out the same...maybe i'm doing something wrong. Let me give an example of just 2 bones: bone1 (root): X: 0, Y: 0, angle: 43.688, width: 149.44399. Using Cos and Sin method, the X+Y of the end is about: X: 108, Y: 103 (Math.cos(angle*(Math.PI/180))*width and Math.sin(angle*(Math.PI/180))*width) - which when I check in editor by manually placing a bone at those coordinates it seems correct. (Although Y is actually negative -103 vs 103 but that's fine). bone2 (parented to root): (in editor): X:190.322, Y: -182.258. (in .scon): X: 263.515, Y: 0.33074. Now even if we took just the Y value of bone 2: 103 + 0.33074 does not equal -182.258 or 182.258. Even if I do: 103 - 0.33074 it still remains no where near that -182 mark! If I go for the X: 108 + 263 = 371 or 108 - 263 = -155 or 263 - 108 = 155. So as you can see no matter what I try it still is no where near the editor values of X:190. I've attached some pics hopefully that all makes some sense! Any light shed would be amazing! Thanks Clym Quote Link to comment Share on other sites More sharing options...
lucid Posted January 9, 2018 Report Share Posted January 9, 2018 The editor numbers are absolute rather than relative. Quote Link to comment Share on other sites More sharing options...
clym Posted January 9, 2018 Author Report Share Posted January 9, 2018 46 minutes ago, lucid said: The editor numbers are absolute rather than relative. Yes relative to the x&y of the end of the root bone? Is the root bone x+y absolute? If so... If i take the x of the end root bone and + the "relative" value to that...it comes to 371 in the example I gave. Vs it actually needs to be x:190 not 371! Any ideas how to convert that relative number to an absolute one? cheers Quote Link to comment Share on other sites More sharing options...
lucid Posted January 9, 2018 Report Share Posted January 9, 2018 Just thought of a couple of things it could be. First, since Spriter uses only rigid transformations, apply the xScale and yScale before applying the angle. Also, in your original post, you used 'width' and 'height' in your formulas. You would use xScale and yScale. Width is only for if you want to draw the actual bone itself. Quote Link to comment Share on other sites More sharing options...
clym Posted January 9, 2018 Author Report Share Posted January 9, 2018 12 minutes ago, lucid said: Just thought of a couple of things it could be. First, since Spriter uses only rigid transformations, apply the xScale and yScale before applying the angle. Also, in your original post, you used 'width' and 'height' in your formulas. You would use xScale and yScale. Width is only for if you want to draw the actual bone itself. I've attached an image to show that I'm trying to get the "???" x + y value. Yeah I used the length (or width) of the root bone found in "obj_info" as "w:149" line 110 in the attached file - and the angle to find the x+y end position using basic trigonometry. The end x&y position of the root bone comes out correct (tested in the editor by creating a new bone with no parent). The xScale and yScale are default 1, for all the bones so I don't think that even showed up in the .scon file. I'll attach that file ... Even If I did apply that I'm not sure how that would change? for example 371*1 = still 371. Cheers, boneTest4.scon Quote Link to comment Share on other sites More sharing options...
lucid Posted January 9, 2018 Report Share Posted January 9, 2018 Ah! I see. I totally misunderstood what you mean by 'end X&Y of the parent/root bone'. I thought you meant the x and y of the parent after any transformations, which is the correct method. You just transform the child bones and sprites from the parent's x and y values after they've been transformed by their parents. There's no need to calculate the endpoints with the bone width unless you want to draw the bones on screen. Quote Link to comment Share on other sites More sharing options...
clym Posted January 10, 2018 Author Report Share Posted January 10, 2018 4 hours ago, lucid said: Ah! I see. I totally misunderstood what you mean by 'end X&Y of the parent/root bone'. I thought you meant the x and y of the parent after any transformations, which is the correct method. You just transform the child bones and sprites from the parent's x and y values after they've been transformed by their parents. There's no need to calculate the endpoints with the bone width unless you want to draw the bones on screen. Hmm so in the example given, you're saying bone_001's X&Y position will be that of the parent? At frame 1 the parent bone (bone_000) x&y = 0, so bone_001's x&y is therefore 0? I'm not quite sure I follow how that would work? Is there somewhere that has .scon reference so I know what each part is referring to? Cheers Quote Link to comment Share on other sites More sharing options...
lucid Posted January 10, 2018 Report Share Posted January 10, 2018 It's the same as what you started with, but the pivot of your rotation is the base of the parent bone, not the endpoint of the parent bone. Quote Link to comment Share on other sites More sharing options...
clym Posted January 10, 2018 Author Report Share Posted January 10, 2018 3 hours ago, lucid said: It's the same as what you started with, but the pivot of your rotation is the base of the parent bone, not the endpoint of the parent bone. OOooh I got it thank you!! So the reason I was messing up was on the example I gave, the angle was set to 43....once I set it to 0 degrees the X&Y were correct!! Then I apply the rotation based on the parent X+Y & parent Angle vs what I was doing which was trying to find the X+Y using the parent end point haha. Thank you for your patience!! Cheers @lucid Quote Link to comment Share on other sites More sharing options...
lucid Posted January 10, 2018 Report Share Posted January 10, 2018 No problem. Glad to help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.