Skip to main content
GameDev.net gamedev.net
🔒 Locked

short array to float(angles)

Started by The Vaseline Slug Oct 24, 2011 at 12:59 PM 5 replies 1.2k views
Original Post
The Vaseline Slug
The Vaseline Slug
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)
Mussi
Mussi
http://zunzun.com/ allows you to find a fitting function to your data, it's easy and browser based. I'm interested in why the conversion isn't linear .
Mussi
Mussi
2D Functions -> Function Finder, Text Data Editor, enter short value [space] double value on each line.
The Vaseline Slug
The Vaseline Slug

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.
Mussi
Mussi

[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?
The Vaseline Slug
The Vaseline Slug

[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 :/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.