Author Topic: G3D model conversion  (Read 3016 times)

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
G3D model conversion
« on: 13 March 2011, 08:29:49 »
As of svn rev #1852 there is a new commandline option to convert one or more G3D models into the latest G3D format (v4) which has been the latest version for a long time (most people likely didn't know this). Beyond that, this conversion optionally allows converting all textures in the model to the specified texture format (like png). Doing a sample on megapack cut the entire folder disk size from 823 MB to 775 MB. Also i added more fault tolerant texture loading and better details when error are encountered when loading models.

To convert a faction, techtree or individual file just pass the path to the command like this:

Code: [Select]
glest.bin --convert-models=techs/megapack_new/=png
where the first part after --convert-models= is the path to the model or a folder containing models (this is recursive) and =png is the optional texture format to convert model textures to when saving.

Enjoy!

ultifd

  • Airship
  • ********
  • Posts: 4,443
  • The Glest Video Guy :) The one and only. :P
    • View Profile
    • My Youtube Channel
Re: G3D model conversion
« Reply #1 on: 13 March 2011, 09:13:27 »
Awesome, you finished! When do you think you'll replace the megapack with PNG then? Just before the final release? Also did you convert the tilesets too? If not, I wonder how much space we'l save after we do that. Maybe one day I'll try converting every single Glest Mod and see how much space I'd save!  :D

On a related note, I got this error when compiling SVN HEAD:
(click to show/hide)

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: G3D model conversion
« Reply #2 on: 14 March 2011, 03:17:24 »
Posts about future support for DDS and other texture formats have been moved to the appropriate thread.  Feel free to continue that discussion over there, where it's already happening.  Have a nice day.

https://forum.megaglest.org/index.php?topic=6665

As of svn rev #1852 there is a new commandline option to convert one or more G3D models into the latest G3D format (v4) which has been the latest version for a long time (most people likely didn't know this).
I'm just curious, but is there a difference other than size?

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: G3D model conversion
« Reply #3 on: 14 March 2011, 03:22:20 »
The v4 format stores more textures per mesh defined as follows (per mesh) and only for v4 (older versions had 1 texture per mesh):

enum MeshTexture{
   mtDiffuse,
   mtSpecular,
   mtNormal,
   mtReflection,
   mtColorMask,

   meshTextureCount
};

I don't know yet exactly how its used as i was just working on conversion of file format and did not look how it uses it for rendering. By the way in my example below I mentioned a directory called megapack_new which i created myself to test converting some models. The latest svn now also supports saving screenshots and model textures using jpg, but of course it only makes sense for non alpha channel textures (however much smaller file sizes than the other formats).

Thanks

james876

  • Guest
Re: G3D model conversion
« Reply #4 on: 14 March 2011, 04:00:36 »
This command can not be achieved under the windows7 compression conversion, thank you! megapack_new directory without any compression converted files.

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: G3D model conversion
« Reply #5 on: 14 March 2011, 06:06:06 »
1) why convert TGA/BMP to PNG?  It will increase download sizes and increase load-times surely?  And it will only improve on-disk size whilst MG isn't merged and gets the physfs support in GAE, which seems a small window.

2) why convert G3D v3 to v4?  The v3 model by definition is not using any of the features enabled by v4, and it's not as though anyone can hand-edit a G3D, they have to be reexported to change the feature-set they use.
« Last Edit: 14 March 2011, 06:08:53 by will »

james876

  • Guest
Re: G3D model conversion
« Reply #6 on: 14 March 2011, 12:45:04 »
windows do not execute this command under the model of conversion and compression, thank you!
D:\trunk\data\glest_game>glest_game.exe --convert-models=techs/megapack_new/=png
v3.4.1-dev-VC++: 1500-Mar 13 2011 9:52:00, SVN: [$Rev: 1692 $], [STREFLOP]
About to convert model(s) [techs/megapack_new/]
About to convert using texture format [png]
megapack_new directory without any files. Why?

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: G3D model conversion
« Reply #7 on: 14 March 2011, 15:06:48 »
I think this tool is only meant as a help for modders. I ( personally ) have no plans to use this globally without thinking....

@will tga->png is useful, because the tga format used in glest is uncompressed!
I also think that its maybe not a good idea to touch bitmaps as they are typically very small and used for icons only.

Looking at the old glest formats I would prefer to only have one version of the g3d format. There really is just a very small amount of models using the old format. Lets get rid of them.

@james876 I think you must use "\" instead of "/" in the path like this:
Code: [Select]
D:\trunk\data\glest_game>glest_game.exe --convert-models=techs\megapack_new\=png
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: G3D model conversion
« Reply #8 on: 14 March 2011, 17:12:33 »
No the problem is that james does not understand how to use the command. There will be no megapack_new folder for him, and no point in explaining this if he did not pick that up since its not intended for him to use.

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: G3D model conversion
« Reply #9 on: 14 March 2011, 17:47:27 »
@will tga->png is useful, because the tga format used in glest is uncompressed!

so the motivation is to save disk-space?

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: G3D model conversion
« Reply #10 on: 14 March 2011, 17:53:21 »
Although it'll be a moot point after the merge, I guess it should be useful for the time being.

james876

  • Guest
Re: G3D model conversion
« Reply #11 on: 15 March 2011, 01:23:49 »
@titi: Thank you titi sense of help, but no effect!
 @ softcoder: I have megapack_new directory, but why can not normal compression data? please tell me how can I use this command, thank you!

 

anything