Hello.

I working on a script parser that takes the raw .nk file and do some magic.
The v7 roto format stores the animated float values using hexadecimal
literals
(http://docs.thefoundry.co.uk/nuke/70/ndkdevguide/advanced/rotoformat.html),
something like this:

x41200000 (this is 10)
x43b40000 (this is 1054.123456)

after some research on the interwebs  I managed to found a way to convert
these back to float using this function:

def hex2float(s):
      #s is a string like x4000000, we need only the 4000000 part:
      s = str(s.group().lstrip()[1:])
      bins = ''.join(chr(int(s[x:x+2], 16)) for x in range(0, len(s), 2))
      return str(struct.unpack('>f', bins)[0])

But I'm running into some precision loss after the conversion, for example
x43b40000 is originally 1054.123456, after conversion using the function
above 1054.12341309

Any tips on this kind of conversions?

Thanks in advance,
--
Magno Borgo
www.boundaryvfx.com
www.borgo.tv
Brasil:Curitiba:GMT= -3
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to