Jump to content
  • Advertisement
Sign in to follow this  
The Vaseline Slug

short array to float(angles)

This topic is 2610 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I'm trying to work out how to convert the angles of a joint in a skelton that is stored in 3 shorts.
I've done a little reading and have found out it is common for 3D assets to store some of the data in shorts to save disk space etc.

The shorts(int16) have the following values.

[font="Times New Roman"]-6967, -6967, -22097[/font] (x,y,z)

These values when converted to double should equal these values.

[font="Times New Roman"]-90.00, -90.00, -55.00 (x,y,z)[/font]


I tried just converting them from shorts to float using the following code:

inline double expandToFloat(short input) {
return ((double)input) * 1000 / 32,767;
}

Which did not work correct. So I did a little more research and have come to the conclusion it has something to do with: atan2
But I've not been able to work it out / find any examples that seam to work correct.


And no this is not homework, I'm writing a converter that converts a binary format to .ma (Maya acsii)

Any help on this would be great, from documentation on how to do this or pointing in the right direction.

Thx Tom. (sorry if wrong section)

Share this post


Link to post
Share on other sites
Advertisement
2D Functions -> Function Finder, Text Data Editor, enter short value [space] double value on each line.

Share this post


Link to post
Share on other sites

2D Functions -> Function Finder, Text Data Editor, enter short value [space] double value on each line.


arr yer I get it, great website !

But as I'm looking for the x,y,z rotation of a joint should I not be looking in 3D functions ?

I tried my data with both 2D & 3D but didnt see any that came out correct.

Thanks for the help so far.

Share this post


Link to post
Share on other sites

[quote name='Mussi' timestamp='1319470186' post='4876332']
2D Functions -> Function Finder, Text Data Editor, enter short value [space] double value on each line.


arr yer I get it, great website !

But as I'm looking for the x,y,z rotation of a joint should I not be looking in 3D functions ?

I tried my data with both 2D & 3D but didnt see any that came out correct.

Thanks for the help so far.
[/quote]

You're looking for a relation between a short angle representation and a double angle representation. double = Func(short), so that's 2D, unless the value of a single component is derived from multiple components. Could you maybe post some more data points?

Also, where is this binary data coming from?

Share this post


Link to post
Share on other sites

[quote name='The Vaseline Slug' timestamp='1319478405' post='4876375']
[quote name='Mussi' timestamp='1319470186' post='4876332']
2D Functions -> Function Finder, Text Data Editor, enter short value [space] double value on each line.


arr yer I get it, great website !

But as I'm looking for the x,y,z rotation of a joint should I not be looking in 3D functions ?

I tried my data with both 2D & 3D but didnt see any that came out correct.

Thanks for the help so far.
[/quote]

You're looking for a relation between a short angle representation and a double angle representation. double = Func(short), so that's 2D, unless the value of a single component is derived from multiple components. Could you maybe post some more data points?

Also, where is this binary data coming from?
[/quote]

Here is another set of data.

[font="Times New Roman"]0.00, 90.00, 0.00
0, 23170, 0
[/font]
As you can see all 3 values are used in combination somehow to work out the angles.

Not like X = some_function(x);


The binary data I'm just getting from a hex editor, from one of my converted models (that's how I know what the angle should be)


Edit: I'm just using a debugger on the host application that loads the file, and I'm reversing the function that processes the angles.

Here is a snippet:



v9 = atan2(
1.0 - (st.y * st.y + st.y * st.y) - v3,
v4 + v4 - (st.z * st.x + st.z * st.x));


v5 = st.y * st.x + st.z * st.dunno;
v10 = asin(v5 + v5);
v6 = st.z * st.y;

v1 = atan2(
1.0 - (st.x * st.x + st.x * st.x) - v3,
st.x * st.dunno + st.x * st.dunno - (v6 + v6));


if ( PI - fabs(v9) < 0.001 )
v9 = 0.0;
if ( PI - fabs(v1) < 0.001 )
v1 = 0.0;


it's not that tidy as I'm converting asm to c++, will tidy up when fully working :/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!