Jump to content
  • Advertisement
Sign in to follow this  
Samurai Jack

Maxscript write float fo file precision

This topic is 4613 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

Greetings! I have trouble when writing vertices or any kind of vectors/floats to ascii text files. The problem is whenever i write some values (take a box for example) they get messed up like this: x y z 0.012300 0.631000 0.e-1231 3.212300 -0.001000 0.00e-1231 What are those "e" values, is it possible to tell to have 4 decimal places and not 6?! Thank you in advance!

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
from der_ton's doom3 md5 export script (www.doom3world.org):


fn printfloat flt =
--maxscript doesn't provide a way to format float output that I know of. It seems that Doom3 does not understand the <x>e<y> notation of floats
--if you plan to use this in your scripts, note that this function doesn't check against a large number passed in
(
--if (abs flt)>10.0 then return flt -- this could be used to gain some speed.
--else
local numdigits = 10
(
str = ""
if flt<0 then str += "-"
flt2 = abs flt
str += ((flt2 as integer) as string)
flt2 -= (flt2 as integer)
str +="."
for i=1 to numdigits do
(
flt2 *=10.0
str += ((flt2 as integer) as string)
flt2 -= (flt2 as integer)
)
return str
)
)


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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!