MegaGlest Forum

Modding and game content creation => Tools => Topic started by: titi on 23 February 2011, 13:57:30

Title: exporter/Blender 2.5/2.6 series
Post by: titi on 23 February 2011, 13:57:30
UPDATE: latest Version of the G3d-Exporter can always be found here:
https://github.com/MegaGlest/megaglest-source/tree/master/source/tools/glexemel

If it's not working/up to date, try this, as this is the place Yggdrasil places it:
http://sourceforge.net/p/glestae/glestae/ci/master/tree/source/glexemel/g3d_support.py?format=raw

------------------------------
Omega mentioned here that the exporter would not work with blender 2.5 Series. ( https://forum.megaglest.org/index.php?topic=6583.msg67658#msg67658 )

Is this right? What are the problems?
Someone already has a workaround/fix ( if there are Problems? )
Title: Re: exporter/Blender 2.5 series
Post by: softcoder on 23 February 2011, 16:10:17
I spent a weekend looking at porting the importer to 2.5. Here is summary of the problems for all plugins moving to 2.5:

1) Python version is now 3.x (many changes required to plugin code)
2) Blender API has TOTALLY CHANGED meaning much of the code must be redesigned and the API is not yet stable because they are still changing it.

With that said I am able to import G3D's into Blender 2.5 without Textures and Animation Sequences, but thats as far as i got.
Title: Re: exporter/Blender 2.5 series
Post by: John.d.h on 23 February 2011, 17:08:45
I'm pretty sure Blender's key system has changed significantly, too.  Things that couldn't be animated in 2.49 can be in 2.5, so watch out for that.
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 23 February 2011, 19:26:12
Isn't 2.5.x still a beta though? Better off waiting until it becomes a stable official release.
Title: Re: exporter/Blender 2.5 series
Post by: Gabbe on 24 February 2011, 15:08:03
Hey im sure i replied to this! oh well, what Omega said.

Current workaround if you are using the 2.5 is really model in 2.5 and animate in 2.49
Title: Re: exporter/Blender 2.5 series
Post by: gameboy on 28 March 2011, 13:19:45
Oh crap, 2.56 is too awesome :( oh well, I'm hoping if it comes to it, someone could export for me :)
Title: Re: exporter/Blender 2.5 series
Post by: -Archmage- on 28 March 2011, 17:19:31
I really do not like 2.5, as they flipped the GUI all over, and took out needed things like after you spacebar>add>object>cylinder, it adds one without asking how many rings/stuff you want. I tried right-clicking the object, and I looked for ways to set it but I saw none. Also right-clicking a border between to panels didn't let me split or anything like that....
Title: Re: exporter/Blender 2.5 series
Post by: ElimiNator on 28 March 2011, 19:43:08
I really do not like 2.5, as they flipped the GUI all over, and took out needed things like after you spacebar>add>object>cylinder, it adds one without asking how many rings/stuff you want. I tried right-clicking the object, and I looked for ways to set it but I saw none. Also right-clicking a border between to panels didn't let me split or anything like that....
Yah, every release you have to re-learn blender.
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 29 March 2011, 01:29:36
My two bits:
I dislike how much they changed the GUI because now all that years of knowledge is about half obsolete, though I do think 2.5.x has potential (I still don't understand why such a major change is 2.5.x instead of 3.x). However, I don't think my preference should matter. I say we maintain exporters for both versions of Blender, as  newer Blender versions don't actually offer any new features that can be used in G3D, besides possible different (easier?) ways of creating models. Thus, maintain exporters for both 2.4.x and 2.5.x, so both our old time modders and new prospective modellers can both experience the best of Glest. :)
Title: Re: exporter/Blender 2.5 series
Post by: gameboy on 29 March 2011, 14:02:58
Its not hard to re-learn you know. And I think the changes are worth it. Some quick research on the website and you'll be up to speed. The 'space bar' add function is now mapped to 'shift+A' as the space bar is used for something else. By clicking on the corners you can separate and merge workspaces and to change the number of faces on a newly added object you can add the stuff in the tools panel which u can get by pressing T.
I really recommend 2.5x to the older version :)
Title: Re: exporter/Blender 2.5 series
Post by: -Archmage- on 29 March 2011, 17:19:16
Its not hard to re-learn you know. And I think the changes are worth it. Some quick research on the website and you'll be up to speed. The 'space bar' add function is now mapped to 'shift+A' as the space bar is used for something else. By clicking on the corners you can separate and merge workspaces and to change the number of faces on a newly added object you can add the stuff in the tools panel which u can get by pressing T.
I really recommend 2.5x to the older version :)

See all those changes are trivial and a waste of time as far as I'm concerned. The new interface colors are nice, though. :P
Title: Re: exporter/Blender 2.5 series
Post by: gameboy on 30 March 2011, 03:05:38
:) fine, don't say i didn't tell you ;) Its a lot faster and smoother too! Jst explore a bit and u'll see all ur dreams for Blender come true :P
Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 16 April 2011, 10:58:35
Now that 2.5 is officially out of beta with 2.57, will this be updated?

2.57 is really cool! I've been playing around with it. They've added in a few of the old things back aswell, like the way you split screens etc.
I'd love to do my glest'in with it.
Title: Re: exporter/Blender 2.5 series
Post by: softcoder on 16 April 2011, 16:11:20
When i have time I may look into this, I do have the importer converted so that it imports a non textured non animated g3d (which is a start). ITs a lot of work since many things changed in the API and it will take time to relearn it.
Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 17 April 2011, 11:30:47
Well, I'd be extremely thankful if you would.  :angel:

I've realised many new things in 2.5 which would be so handy, one thing I'm pretty stoked for now is live UV wraping, it would save so much time when recycling human models!
Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 22 July 2011, 14:06:17
Is it alright if I bump this topic?
Blender has released 2.8a which has been the second stable release past 2.5. To any people who said they didn't like 2.5 please give this a go, they've returned many of the controls back to 2.4.
Is this still being worked on? if the devs are unsure how to write the script, maybe we could ask someone on the blender forums if they're willing to do it for us?
I hope this isn't being forgotten about.
Title: Re: exporter/Blender 2.5 series
Post by: will on 22 July 2011, 14:28:09
(And when porting, fix the two-sided export?)
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 23 July 2011, 15:31:28
loveheaven made one (animations missing):
https://forum.megaglest.org/index.php?topic=7230.msg73922#msg73922

I would really like to add it to our git so it doesn't get lost but it kinda lacks a license... have to contact him.
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 24 July 2011, 05:05:24
loveheaven made one (animations missing):
https://forum.megaglest.org/index.php?topic=7230.msg73922#msg73922

I would really like to add it to our git so it doesn't get lost but it kinda lacks a license... have to contact him.
The problem is, no animations = nearly useless. The majority of models will be animated, and thus must be exported as so. We really need that script to be expanded before it will be of use.
Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 24 July 2011, 10:49:23
Hmmmm, what is actually the issue with the animations?
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 24 July 2011, 22:23:29
Hmmmm, what is actually the issue with the animations?
There is no issue, the script maker simply didn't include a way to export them.
Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 31 July 2011, 05:44:32
So it's just a question of fixing it, not how to fix it? Alrighty, good.
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 1 August 2011, 05:19:35
So it's just a question of fixing it, not how to fix it? Alrighty, good.
Well, think of it like if multiplayer was removed in MegaGlest, it's suddenly useless until we add the multiplayer. Animations are to G3D as Multiplayer is to MegaGlest, and just like multiplayer, animations are a difficult part of the script. I think the entire reason that they aren't in the script was that the script writing didn't know how to add them. Though, the inactivity shows that it's unlikely to be updated, so if any individual wishes to give it a shot, go ahead.
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 11 August 2011, 14:35:25
I have the feeling we all need glasses... Especially me because i just noticed now that loveheaven posted an _import_ script, no export at all. Sorry if i confused someone.
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 11 August 2011, 21:31:50
I have the feeling we all need glasses... Especially me because i just noticed now that loveheaven posted an _import_ script, no export at all. Sorry if i confused someone.
...

 :P
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 1 November 2011, 23:19:39
now we're on it we really need a new exporter for 2.5
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 8 November 2011, 11:04:23
I had some time the other day and started hacking on it. It's based on loveheaven's import script and not finished yet. Animation is missing and some other things are wrong (two sided, alpha). Expect problems.

You can get the script here:
http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD
Just install it as addon and enable it. I only briefly tested it on blender 2.60a with an imported archmage model.

Can someone please provide a blend file with texture and animation? Otherwise i can't finish it.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 8 November 2011, 17:52:12
im currently looking for one of my models, worst case senari il just texture a cube and animate it to spin

EDIT: Aparantly i need to orintate myself about animation again, if anyone can provide a animaiton before me please do so.

Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 8 November 2011, 19:36:42
There a box with UV and Animation

http://hotfile.com/dl/134526683/91e85a4/box_uv_ani.7z.html (http://hotfile.com/dl/134526683/91e85a4/box_uv_ani.7z.html)

EDIT: Texture wiev does not work, but it is textured and when rendered it shows up
EDIT2: Alpha defines teamcolour in the image file.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 9 November 2011, 08:09:22
Yggdrasil, Can you use my box?, if you need anything elles please let me know.
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 9 November 2011, 21:37:17
Thanks. I added animation support (at least i hope so) but your cube looks a bit weird. Texture seems to be wrong too. Do you have another model which is textured correctly in blender (texture view)? Exporting an imported archmage model looks correct.

Btw, customcolor aka 'make alpha appear in teamcolor' is now always enabled. How do you set it in blender? Or was it always on?

PS: The link above always points to the newest version of the script.
Title: Re: exporter/Blender 2.5 series
Post by: John.d.h on 10 November 2011, 19:39:28
Currently in the 2.49 version, it is set by making the object single or double sided. This is definitely not the right way. I don't have a copy of 2.5 on hand but 2.49 has a switch in the map-to section of the material settings for that. Alternatively, the main material section has a switch for using the alpha channel in tex face images, so I think that would also be suitable.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 11 November 2011, 01:42:43
Thanks. I added animation support (at least i hope so) but your cube looks a bit weird. Texture seems to be wrong too. Do you have another model which is textured correctly in blender (texture view)? Exporting an imported archmage model looks correct.

Btw, customcolor aka 'make alpha appear in teamcolor' is now always enabled. How do you set it in blender? Or was it always on?

PS: The link above always points to the newest version of the script.

I will try to fix the texture on the cube, i will also download the script and test out the exporter.

PS: as far i am aware, The game engine was the one making the team colurs appear, with just default blender settings. just be sure that your texture had alpha in it.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 11 November 2011, 02:52:25
Allright, i gave a shot couldnt get the export to work.

1. The script is listed under both Export and import, Neither works for me.
2. I use Windows 64 bit.
3. i use Blender version 2.59, Unkown Bit version can't find that info, (currently download 2.60 and testing with that).
4.When exporting my models,it does use the glexml.exe and converts the file however the converted file is ALLWAYS and ONLY 7Kb.
5. i tried the script also in Blender 2.57 in this version the script won't activate in the control interface.

this is the error i get when trying to open the exported model in the .g3d format.
http://pastebin.com/PJ5KT4jv

this is in both 2.59, and 260a

In Blender 2.60a, I get that the exported .g3d file is 7Kb if i Ctrl-T them,(that means making every triangles.)
however one time i got a larger file out of it.

EDIT:2.60a Importing work i tried the Archmage like you and it worked, but i could not export him again.

EDIT2:
This is the output from megaglestg3dviewer When i tro to open a Initate.g3d file i have IMPORTED From game Folder then EXPORTED (with a resulting file size of..134KB.
the Original File size is 126

TEH OUTPUT
http://pastebin.com/ZKuvY7tN

I can't however remeber when my glexml.exe file is from, it might be old and outdated, but it havent been updated in a loooong time anyways

Also if a try to export a cube made of triangles it gives this error in blenders command promt.

Code: [Select]
Now Exporting File: C:\Users\Frederick\Desktop\Cube.g3d
Traceback (most recent call last):
  File "C:\Program Files (x86)\Blender Foundation\Blender\2.60\scripts\addons\ex
portg3d.py", line 607, in execute
    G3DSaver(self.filepath, context)
  File "C:\Program Files (x86)\Blender Foundation\Blender\2.60\scripts\addons\ex
portg3d.py", line 495, in G3DSaver
    texname = bpy.path.basename(material.active_texture.image.filepath)
AttributeError: 'Texture' object has no attribute 'image'

So, Summariation

2.60a:
Importing Works but have some quirks when i imported some of my own models it sorta imports some weird ghost particles or something like that model file link is here
(click to show/hide)
Propetary model mind you. So i grant you liscense to use it for study purposes.( just so you can feel secure about it :).
Also this model have correct textureing in blenders texture view.

Exporting does not work with, and the Megaglest_g3dviewer comes with the bad allocation something error wich i have listed above.

Done with edits for this time.



Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 11 November 2011, 10:20:41
Nice word Yggdrasil! I would help but seems CFS got there first. 
I've been waiting for this a long time now, thank you :).

Currently in the 2.49 version, it is set by making the object single or double sided. This is definitely not the right way. I don't have a copy of 2.5 on hand but 2.49 has a switch in the map-to section of the material settings for that. Alternatively, the main material section has a switch for using the alpha channel in tex face images, so I think that would also be suitable.

I agree with this, if it's not too much work that is.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 11 November 2011, 11:17:21
I do not know about the material thing, but I make team colours by adding Alpha to the texture.png
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 11 November 2011, 15:07:25
Just to make something clear: The script is for the newest version of blender 2.60a. I won't fix it for older versions. It contains both an importer and an exporter for g3d. glexemel isn't needed anymore. Everything is done in python.

In Blender 2.60a, I get that the exported .g3d file is 7Kb if i Ctrl-T them,(that means making every triangles.)
however one time i got a larger file out of it.
All faces need to be triangles otherwise they're ignored. There is no warning shown yet as i haven't found an easy way to do that.

EDIT:2.60a Importing work i tried the Archmage like you and it worked, but i could not export him again.
There was a problem with the mesh count if you deleted a mesh before exporting. Should be fixed now.

This is the output from megaglestg3dviewer When i tro to open a Initate.g3d file i have IMPORTED From game Folder then EXPORTED (with a resulting file size of..134KB.
the Original File size is 126

TEH OUTPUT
http://pastebin.com/ZKuvY7tN
Looks like the texture couldn't be found. I'm no MG dev... In GAE you get a default texture.

Also if a try to export a cube made of triangles it gives this error in blenders command promt.
Code: [Select]
Now Exporting File: C:\Users\Frederick\Desktop\Cube.g3d
Traceback (most recent call last):
  File "C:\Program Files (x86)\Blender Foundation\Blender\2.60\scripts\addons\ex
portg3d.py", line 607, in execute
    G3DSaver(self.filepath, context)
  File "C:\Program Files (x86)\Blender Foundation\Blender\2.60\scripts\addons\ex
portg3d.py", line 495, in G3DSaver
    texname = bpy.path.basename(material.active_texture.image.filepath)
AttributeError: 'Texture' object has no attribute 'image'
I added a check to make sure the active texture in the (first) material is an image texture. Texture is ignored if it's not the case.

Importing Works but have some quirks when i imported some of my own models it sorta imports some weird ghost particles or something like that model file link is here
(click to show/hide)
Works fine for me. I don't see any "particles".

Currently in the 2.49 version, it is set by making the object single or double sided. This is definitely not the right way. I don't have a copy of 2.5 on hand but 2.49 has a switch in the map-to section of the material settings for that. Alternatively, the main material section has a switch for using the alpha channel in tex face images, so I think that would also be suitable.
Do you mean something like that (Face Textures):
(http://img444.imageshack.us/img444/6013/glest3.png)
It's in the material's options. There's another one hidden behind the tooltip regarding face texture alpha. I don't know what's really meant with face texture. If i have a texture ofcourse it should replace the other color. I don't really get the point of this option. Anyway should i use that one?
Title: Re: exporter/Blender 2.5 series
Post by: John.d.h on 11 November 2011, 17:36:34
Regarding triangles, is there a way to have the export script automatically convert quads to triangles? Quads are vastly easier to work with because they preserve edge loops.
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 11 November 2011, 20:29:59
Alright, this was in need of testing, so I brought out Blender 2.60a (I downloaded it a while ago, and have been meaning to fully (re)learn it, the lack of an exporter was the biggest hurdle).

Firstly, to install the script, I placed it in %installation_directory%/Blender 2.60a/2.60/scripts/addons, then in Blender, go to user preferences > addons > Import-export, and find "G3D Mesh Importer" (that should really be renamed to "Exporter") and tick the checkbox. Note that this, like all user preferences, will only persist for the current session unless you create a new default session (with Ctrl+U, which will make the current window locations, user settings, model, etc, the default).

Anyway, I encountered a few problems. Firstly, I was unable to get the texture on my cube to export correctly when I tried, despite it rendering correctly (F12), and being set to map to "UV" (though with past exporters, they always exported the texture coords by the UV, regardless of what you have set for Blender's internal renderer. The image is very much properly linked as it would be necessary with the older exporter. It still does export, but the UV coords (which tell where each point of the 3D model's faces should be "mapped" to the 2D image) seem messed up, as seen in the image to to the right (the left cube is the G3D viewer, the right cube is the rendered Blender version, showing how it should look).

In addition, when I tried to apply bone animation (which the majority of animated models will use), the exporter totally ignored the bones and exported the mesh as though they didn't exist, yet the G3D viewer recognizes there are multiple frames, just the exact same unchanged model in every frame. I think this may be because you were working with an imported archmage. Imported models use shape keys, instead of bones (since bones are not preserved in the G3D model). This sadly is a huge limitation, as bones are crucial for glest modeling.

And of course, here is the zip file from my test, containing the blend file with a textured and animated cube, the PNG for the texture (Blender defaults to PNG now!), and the exported G3D:

[big]Download ZIP (http://www.mediafire.com/?jz7tokgab06fgya) (60.5 KB)[/big]
(http://img706.imageshack.us/img706/4623/unledajc.png)
Title: Re: exporter/Blender 2.5 series
Post by: John.d.h on 11 November 2011, 22:26:44
Just to clarify, the game has never recognized bones and the exporter is agnostic regarding animation methods. It has only ever cared about where each vertex is located on each frame.
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 12 November 2011, 14:36:18
I made some more fixes and added support for armature animation. Both cubes, Coldfusionstorm's and Omega's, work now. An imported archmage model works too. customcolor is still hardcoded.

Regarding triangles, is there a way to have the export script automatically convert quads to triangles? Quads are vastly easier to work with because they preserve edge loops.
Yeah, i can do that if it's needed. But don't expect the importer to make quads again.
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 12 November 2011, 18:40:58
I made some more fixes and added support for armature animation. Both cubes, Coldfusionstorm's and Omega's, work now. An imported archmage model works too. customcolor is still hardcoded.
Awesome job! I can confirm that both the textures and animations worked flawlessly.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 13 November 2011, 07:20:52
Thanks Yggdrasil!
 :thumbup:

:).

If there was a larger ! sign i would use it,

EDIT:would you look at that, there is!
Title: Re: exporter/Blender 2.5 series
Post by: titi on 16 November 2011, 13:07:45
Thanks Yggdrasil!!!!!
Man how could I have missed this great news? I must test it! ( but I still have my problems with the new blender  :angel: )
Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 18 November 2011, 06:47:09
Great news! Finally able to un-install Blender 2.49b from my computer is great feeling. :)
Title: Re: exporter/Blender 2.5 series
Post by: softcoder on 18 November 2011, 08:16:19
Great job Yggdrasil, that was definitely not an easy achievement!
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 19 November 2011, 15:35:39
Hui, looks like this was needed.

I added support for quads. They are converted on the fly to triangles. For customcolor aka 'alpha appears in teamcolor' you have to check 'face texture alpha' in the material's options. It's normally greyed out but you can still click it. 'double sided' is in Object Data -> Normals of the mesh. In most cases you won't need it. Only things like the cape of the archmage model need it.

The only thing which is still completely untested is an animated model with multiple meshes. The importer doesn't support animations. Can someone please test it?
Title: Re: exporter/Blender 2.5 series
Post by: John.d.h on 19 November 2011, 17:20:25
Awesome! Just what many of us have been waiting for.  :D
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 22 November 2011, 12:49:15
I just tought about it, and the work you made with this is impressive, you removed the need for a entire programe added animations, and made it all into ONE script!, Modelling have never been this easy for Glest!.
Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 28 November 2011, 02:24:55
Sorry for this noob question.... But don't I need a .py file? All I get when I click Yggdrasil's link is a big page of code...
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 28 November 2011, 03:20:07
Sorry for this noob question.... But don't I need a .py file? All I get when I click Yggdrasil's link is a big page of code...
Uh, that is the python file. Save it as .py and place it in the scripts/addons folder, then enable it in the addons menu of user preferences.
Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 28 November 2011, 03:26:57
Sorry for this noob question.... But don't I need a .py file? All I get when I click Yggdrasil's link is a big page of code...
Uh, that is the python file. Save it as .py and place it in the scripts/addons folder, then enable it in the addons menu of user preferences.

Yes I got that... just how do I save it as .py file  :-[? Sorry. I haven't really touched Blender scripts before.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 28 November 2011, 11:19:44
You need to mark the entire code section and copy paste it into a .txt document, when you have done that rename the file to blender_exporter_v2.5.py

any name tho should be fine as long as the file ending is .py

Then put it into the /blender/script/addon

folder
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 29 November 2011, 01:23:15
Sorry for this noob question.... But don't I need a .py file? All I get when I click Yggdrasil's link is a big page of code...
Uh, that is the python file. Save it as .py and place it in the scripts/addons folder, then enable it in the addons menu of user preferences.

Yes I got that... just how do I save it as .py file  :-[? Sorry. I haven't really touched Blender scripts before.
Save it in any text editor? Just like xml, c++, etc etc.
Title: Re: exporter/Blender 2.5 series
Post by: softcoder on 6 December 2011, 05:04:51
I just tried this script (From this URL: http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD (http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD)) and when importing g3d's into blender 2.57 (the latest release) i see no proper animation sequences when i 'play' the model. Has anyone been able to confirm animations work (without them this is kindof useless).

Thanks
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 6 December 2011, 05:56:41
I just tried this script (From this URL: http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD (http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD)) and when importing g3d's into blender 2.57 (the latest release) i see no proper animation sequences when i 'play' the model. Has anyone been able to confirm animations work (without them this is kindof useless).

Thanks
Wait, no longer? When did it ever import animations? There was shape keys in the past, but they were pretty useless, and G3D doesn't contain bones (yet another reason why MD5 should replace it), so those can't be imported.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 6 December 2011, 08:36:18
Im pretty sure _importing_ bones just dosnt work
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 6 December 2011, 11:34:23
I haven't touched the importer in any way besides tiny fixes because they still make small changes to their API. It's still the importer from loveheaven which doesn't support animations. There's no way to restore the armature but as Omega said, shape keys are probably possible.

Btw, the latest Blender is 2.60a. Please use that one.
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 25 December 2011, 23:36:07
Sorry for double post.

I made another fix. I switched the values of the mesh properties teamcolor and double sided. The format spec described in this thread:
https://forum.megaglest.org/index.php?topic=713
is wrong. Every glest has it the other way around, even vanilla. This is probably one cause why the old exporter used double sided to trigger teamcolor.

Can some moderator please edit the old post by martino and change it to this:
Code: [Select]
enum MeshPropertyFlag{
mpfCustomColor= 1,
mpfTwoSided= 2
};

Here the link again:
http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD
(Right-click 'Save As', name it g3d_support.py, in blender: File->User Preferences -> Addons -> Install Addon (bottom), pick the downloaded file, enable it)
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 26 December 2011, 02:08:07
I made another fix. I switched the values of the mesh properties teamcolor and double sided. The format spec described in this thread:
https://forum.megaglest.org/index.php?topic=713
is wrong. Every glest has it the other way around, even vanilla. This is probably one cause why the old exporter used double sided to trigger teamcolor.

Can some moderator please edit the old post by martino and change it to this:
Code: [Select]
enum MeshPropertyFlag{
mpfCustomColor= 1,
mpfTwoSided= 2
};

Here the link again:
http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD
Done.

(Right-click 'Save As', name it g3d_support.py, in blender: File->User Preferences -> Addons -> Install Addon (bottom), pick the downloaded file, enable it)
Oh, and the wiki has a new page (https://docs.megaglest.org/G3D support) detailing this script, including installation and preparation.
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 2 January 2012, 15:25:36
I worked a bit on the importer. I fixed the mesh properties as they were wrong there too and added all frames as shape keys to the meshes. However there's still no animation as i've no clue how to do that. If someone knows a way how one gets an animation out of the shape keys and can give me a step by step instruction how it's done in the GUI, i might be able get this into the python script.

Otherwise one could add a special case where the exporter exports shape keys as frames, but that sounds quite hacky.
Title: Re: exporter/Blender 2.5 series
Post by: John.d.h on 29 January 2012, 22:44:00
I've finally started playing around with the newer Blender versions, so this script has been very good to have.  I've noticed two shortcomings so far, though: it doesn't seem to respect object scaling, and it exports all meshes instead of just what you select, so (AFAIK) there's no way to have a particular mesh present in one animation but not another without using separate files (like how the worker switches between an axe and a hammer).

By the way, where's the option that toggles transparency vs. team color?  This new UI is still over my head. :confused: (Edit: found it (https://docs.megaglest.org/G3D_support).)
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 4 February 2012, 16:36:27
I changed the script to respect your selection. If nothing is selected it's still exporting all meshes.

I don't really know what you mean with scaling and how i should fix it. Could you please provide a blend file which illustrates this problem?
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 4 February 2012, 17:40:43
I changed the script to respect your selection. If nothing is selected it's still exporting all meshes.
Cool, I updated the wiki page (https://docs.megaglest.org/G3D support) and its links.
Title: Re: exporter/Blender 2.5 series
Post by: John.d.h on 5 February 2012, 01:47:08
I changed the script to respect your selection. If nothing is selected it's still exporting all meshes.
Perfect. :)

Quote
I don't really know what you mean with scaling and how i should fix it. Could you please provide a blend file which illustrates this problem?
If you scale or move something in object mode, the export script acts as if the change weren't made... or at least that's what I was experiencing with one of my blend files.  When I tried it on a new scene, scaling a moving a cube in object mode, it stayed moved and scaled properly in the g3d.  Upon further testing, it seems that the exporter does take the object-mode transformations into account, but they have a tendency to turn out wrong.  Basically, this makes it so you have to apply all your object data before exporting, which isn't a big problem but isn't exactly ideal either.  This also makes it so you can't reliably use object transformations for animation -- i.e. if you want to make a wheel rotate, it needs an armature.

In the first screen shot, you see the gallowglass as he normally is.  In the second, his weapon is moved down.  In the third, the two versions when exported.  Instead of being moved down by about a foot, it is moved forward by a few inches.

(http://media.use.com/images/s_1/d79baa7561d94dcaf112_1.jpg) (http://www.use.com/d79baa7561d94dcaf112?p=1) (http://media.use.com/images/s_1/d79baa7561d94dcaf112_2.jpg) (http://www.use.com/d79baa7561d94dcaf112?p=2) (http://media.use.com/images/s_1/d79baa7561d94dcaf112_3.jpg) (http://www.use.com/d79baa7561d94dcaf112?p=3)
(click for full size)

The blend file with both g3ds for comparison: http://www.mediafire.com/?rlxedj2xh9i3c43
Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 5 February 2012, 02:57:10
Maybe it's because the script is using the center of the scene as the center of the G3D, unlike the old script which used the center of the active object?

Edit: No, actually thats probably not it...... hmmmmmm.
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 5 February 2012, 13:34:44
Thanks John.d.h. I pushed a fix, but i'm not sure if this is correct for all possible transformations. Let me know if something is still wrong.
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 29 April 2012, 14:28:30
I added some more error handling to the script (checking for object mode and texture unwrap). Warnings and errors are now displayed in blender. Should prevent you from making stupid mistakes. If an error occurs there might be a partly written g3d file waiting for deletion. I don't really want to change the script to check everything beforehand.

Here the link again:
http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD
(Right-click 'Save As', name it g3d_support.py, in blender: File->User Preferences -> Addons -> Install Addon (bottom), pick the downloaded file, enable it)
Title: Re: exporter/Blender 2.5 series
Post by: MuwuM on 24 May 2012, 22:15:23
I got an error using 2.63 with the Blender 2.6x script (http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD (http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD))

Code: [Select]
    G3DSaver(self.filepath, context, self)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.63\scripts\ad
dons\source_glexemel_g3d_support.py", line 534, in G3DSaver
    for face in mesh.faces:
AttributeError: 'Mesh' object has no attribute 'faces'

Now Exporting File: C:\Glest-mods\untitled.g3d
Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.63\scripts\ad
dons\source_glexemel_g3d_support.py", line 683, in execute
    G3DSaver(self.filepath, context, self)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.63\scripts\ad
dons\source_glexemel_g3d_support.py", line 534, in G3DSaver
    for face in mesh.faces:
AttributeError: 'Mesh' object has no attribute 'faces'
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 24 May 2012, 22:45:13
Im pretty sure i had this too, Im REALLY REALLY busy tho, so it might get some time before i get a actual output or confirmation on this. from my side.
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 25 May 2012, 10:44:15
API changes ftw. They probably had to because of their new BMesh system supporting n-sided polygons. I pushed a fix which hopefully works for all cases. As i only have a few models this is quite untested, especially n-polygons with n > 4. This fix breaks the script for Blender versions older than 2.63.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 25 May 2012, 16:54:09
Nice yggdrasil, But when you uhmm, say oushed the fix, where exactly?
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 25 May 2012, 17:01:01
Nice yggdrasil, But when you uhmm, say oushed the fix, where exactly?
Same link, bro. That's the link to the "head" version, which is always up to date. The diff can be seen here (http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blobdiff;f=source/glexemel/g3d_support.py;h=7a9336bd73ad728e9b6fa46c3fc74ab1fcef8a08;hp=f3d6564f96147c2cb5f5885ef9071c107e2d4c63;hb=af742d511477cfd4947a426e2027e1bbb7cbebda;hpb=33ea21bcc69741e9179efae452d1f4046e2893b5).
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 16 June 2012, 23:23:07
I've updated the exporter to add a new panel for g3d mesh properties. If you open the mesh properties and scroll down you'll find a new panel labeled 'G3D properties' which contains 'team color' and 'non-selectable'. So, please take note that you have to use 'team color' from now on and not 'face texture alpha'. 'non-selectable' makes a mesh non-selectable, surprise, surprise. It's the same as in g3dhack and currently only supported by GAE. Other engines should ignore it.

Here the link again:
http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD
(Right-click 'Save As', name it g3d_support.py, in blender: File->User Preferences -> Addons -> Install Addon (bottom), pick the downloaded file, enable it)
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 17 June 2012, 08:33:58
IM pretty sure the non-select flag also works in MG, i just used the G3D hack the other day, and it def made clicking on one of my buildings/units easier
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 29 June 2012, 23:57:22
Placebo effect?

For people not finding the properties panel (remember you need at least blender 2.63):
(http://img835.imageshack.us/img835/7703/g3dprops.png)

And i pushed a very tiny update...
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 5 July 2012, 13:23:00
The flag does not work in MG, must have been a coincidence, just the day after the problem was back :(, Could we please support his feature in Megaglest too?.
Title: Re: exporter/Blender 2.5 series
Post by: titi on 16 July 2012, 19:10:22
@Coldfusionstorm: done, please test ...

@Yggdrasil: We try to keep a copy of teh blender exporter in the MG repository too, because we want to deliver it with MG.
Where do we find the latest version ?
Is it here?: https://docs.megaglest.org/Exportscript

And do you know if this is compatible with MegaGlests g3d format?
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 16 July 2012, 20:01:16
@Yggdrasil: We try to keep a copy of teh blender exporter in the MG repository too, because we want to deliver it with MG.
Where do we find the latest version ?
Is it here?: https://docs.megaglest.org/Exportscript

And do you know if this is compatible with MegaGlests g3d format?
Yes to all three questions.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 17 July 2012, 15:00:49
@Coldfusionstorm: done, please test ...

@Yggdrasil: We try to keep a copy of teh blender exporter in the MG repository too, because we want to deliver it with MG.
Where do we find the latest version ?
Is it here?: https://docs.megaglest.org/Exportscript

And do you know if this is compatible with MegaGlests g3d format?

i also wrote in your other thread titi, il test it out as soon as possible!
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 20 September 2012, 19:20:21
I updated the importer and exporter. It's now possible to export imported models with animations, but you have to use a workaround to make it work. After importing you have to click into the list of shape keys for each mesh you imported. After that the animation should work normally and you can export the meshes again. I probably forgot to update/recalculate something but i can't find a way to trigger it. You have to live with this workaround for now.

I also fixed a bug in the exporter which reduces the exported vertex count in some cases considerable. If you have a big model with many vertices, it's probably a good idea to re-export.

Here the link again:
http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD
(Right-click 'Save As', name it g3d_support.py, in blender: File->User Preferences -> Addons -> Install Addon (bottom), pick the downloaded file, enable it)
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 20 September 2012, 22:39:32
I updated the importer and exporter. It's now possible to export imported models with animations, but you have to use a workaround to make it work. After importing you have to click into the list of shape keys for each mesh you imported. After that the animation should work normally and you can export the meshes again. I probably forgot to update/recalculate something but i can't find a way to trigger it. You have to live with this workaround for now.
Nice work, Yggdrasil. It's a very unusual work around, but beats nothing. Should make modifying older mods much more bearable.
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 8 December 2012, 15:53:51
I got rid of the workaround and added a new option to the exporter to run g3dviewer directly after export (see left side when exporting). Hover over it to read the tooltip.
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 9 December 2012, 14:39:15
Yggdrasil, You rock!.! :thumbup:
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 17 December 2012, 15:12:29
FYI: To get "notified" about changes in the script, use the feed at the bottom right on the following page:
http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob;f=source/glexemel/g3d_support.py;hb=HEAD
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 20 December 2012, 17:15:42
Added another option to exporter and importer to rotate mesh from default blender orientation to glest orientation, or vice versa.

Here the link again:
http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD
(Right-click 'Save As', name it g3d_support.py, in blender: File->User Preferences -> Addons -> Install Addon (bottom), pick the downloaded file, enable it)
Title: Re: exporter/Blender 2.5 series
Post by: -Archmage- on 20 December 2012, 19:51:15
Yggdrasil :thumbup:

What can you do to an imported model and still export it with it's animations? And are there any steps you have to take or could I just import>export and boom animated?
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 21 December 2012, 12:02:37
I don't know. I'm no modeler. You're probably limited by the shape keys. I only tested it with importing a model and then directly export it again. If the animation still works correctly in blender, it should export just fine. At least that's the goal. Always keep your blend files...
Title: Re: exporter/Blender 2.5 series
Post by: atze on 22 December 2012, 03:23:47
Thank you Yggdrasil, that is a very useful supplement.  :thumbup:  :)
Title: Re: exporter/Blender 2.5 series
Post by: MightyMic on 9 January 2013, 03:02:22
Yggdrasil, is there a way to make the script default to having "rotate to glest orientation" checked?
I like working in blender's default axes better than glest's default axes
Title: Re: exporter/Blender 2.5 series
Post by: -Archmage- on 9 January 2013, 10:29:03
Yggdrasil, is there a way to make the script default to having "rotate to glest orientation" checked?
I like working in blender's default axes better than glest's default axes

I would suggest you just get used to it. It's one click when you export.
Title: Re: exporter/Blender 2.5 series
Post by: Omega on 9 January 2013, 13:45:55
And to be fair, you only have to click it once per blend file.
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 12 January 2013, 18:45:22
Change line 757 to:
Code: [Select]
default=True)(replaces False with True)

I made it default to false mainly because it's a new option and modifies the mesh. Maybe not everyone wants to use it. I don't know how your workflow in blender looks like. If the majority of the modelers use this option, it should be enabled by default. Opinions?
Title: Re: exporter/Blender 2.5 series
Post by: Psychedelic_hands on 22 January 2013, 03:02:56
I mainly model in blenders default orientation yeah.

Great work Yggdrasil! Good to see the exporter getting some well needed love.
Title: Re: exporter/Blender 2.5 series
Post by: MightyMic on 22 January 2013, 03:44:07
Forgot to say thanks, yggdrasil :thumbup:
You're the man

I made it default to false mainly because it's a new option and modifies the mesh. Maybe not everyone wants to use it. I don't know how your workflow in blender looks like. If the majority of the modelers use this option, it should be enabled by default. Opinions?
I like using default orientation, but if anyone is opposed to it, I'm fine with editing the line after downloading
Title: Re: exporter/Blender 2.5 series
Post by: Coldfusionstorm on 27 January 2013, 13:16:44
Thanks for keeping this script up to date and so well maintained Yggdrasil

Thanks Yggdrasil  :thumbup:
Title: Re: exporter/Blender 2.5 series
Post by: softcoder on 27 January 2013, 17:21:34
May i also say "thank you yggdrasil" working on the script is awesome for everyone.

:)
Title: Re: exporter/Blender 2.5 series
Post by: Yggdrasil on 20 February 2013, 15:07:52
Thanks for the kind words.

I somehow forgot to mention the last update here:
Quote
Importer and exporter now support multiple texture slots. The first slot in the
material is the diffuse map, second and third slot are specular and normal map.
Other slots are ignored. All textures share the same coordinates.
The option to rotate the mesh is now enabled by default in importer and
exporter.

Only GAE knows about these slots currently, MG should ignore it (hopefully). If you only have a diffuse map you should get the same g3d as before.

Here the link again:
http://glestae.git.sourceforge.net/git/gitweb.cgi?p=glestae/glestae;a=blob_plain;f=source/glexemel/g3d_support.py;hb=HEAD
(Right-click 'Save As', name it g3d_support.py, in blender: File->User Preferences -> Addons -> Install Addon (bottom), pick the downloaded file, enable it)
Title: Re: exporter/Blender 2.5 series
Post by: titi on 28 February 2013, 20:12:53
Thank you so much!!!
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 10 April 2013, 08:56:06
please make the following change in your script too. The opacity is set to 1.0 if it was 0.0 . It makes no sense to export non visible objects ( because fully transparent ), but having this replacmenet makes moddeling much more easy in blender, because you can set the transparency of the material to 0 to see the alpha effect of the textures in the 3dview too.

http://sourceforge.net/apps/trac/megaglest/changeset/4221

in case trac is down if you read this:
Code: [Select]
trunk/source/shared_lib/sources/graphics/model.cpp
r4057 r4219
771 771         specularPower= meshHeader.specularPower;
772 772         opacity= meshHeader.opacity;
773
  773         if(opacity==0){
  774                 printf("found a mesh with opacity=0 in header, using opacity=1 to see it now \n");
  775                 printf("file: %s\n",modelFile.c_str());
  776                 opacity=1.0f;
  777         }
774 778         textureFlags= meshHeader.textures;
775 779
Title: Re: exporter/Blender 2.5/2.6 series
Post by: Yggdrasil on 10 August 2013, 10:15:52
Sounds quite hacky. Isn't there a better way?

I mean you magically set it from invisible to fully opaque. Invisible objects are probably useless, but still...
Title: Re: exporter/Blender 2.5/2.6 series
Post by: Omega on 10 August 2013, 18:19:08
I mean you magically set it from invisible to fully opaque. Invisible objects are probably useless, but still...
Are they really useless? I feel they could be used to help the selection of units. For example, the Undead faction used a "ghost" unit that was pretty much just particle effects. The model as I remember it was a small cube, which made it difficult to select the unit. A larger, invisible cube would have worked better. Of course, we could still mimic invisibility with a transparent texture, but setting the model transparent could remove the need for a texture entirely.
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 12 August 2013, 09:12:36
What Omega says is right, selection is a reason why fully transparent object might be good. The problem is that exporting invisible object is mainly done by accident.
For example if you want to see something like a tree with all transparent parts in blender you have to set full transparency on the object, just to see the transparency effect of the texture. And if you later export, you see nothing in the 3gd-viewer.

Its not the format or exporters fault, its more something not so good in blender itself. To help out with this I decided to add this. You can still get a transparent object by setting the transparency to 0.00001 or so ......

Maybe its a good idea to add an explicit switch "fully transparent" to the exporter options in blender. By this you can be sure to not export fully transparent by accident, but we keep the option to make it fully transparent if it was the modders intention.
Title: Re: exporter/Blender 2.5/2.6 series
Post by: Yggdrasil on 16 August 2013, 08:23:02
Mhmm, yeah, i think i'll add an option 'fully opaque' which always sets the opacity of the mesh to 1.0 on export, ignoring what's set in materials.
Title: Re: exporter/Blender 2.5/2.6 series
Post by: Yggdrasil on 18 August 2013, 11:25:54
Code: [Select]
added new option 'fully opaque' to blender addon

This new option is a mesh property located in the G3D properties panel. If
enabled it sets the opacity of the mesh to 1.0, ignoring what's set as alpha in
materials which is normally used for the opacity. This allows the modder to set
alpha in materials to 0 and see the alpha effects of the texture in the 3D view
of blender.

The link has changed:
http://sourceforge.net/p/glestae/glestae/ci/master/tree/source/glexemel/g3d_support.py?format=raw
(Right-click 'Save As', name it g3d_support.py, in blender: File->User Preferences -> Addons -> Install Addon (bottom), pick the downloaded file, enable it)
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 23 August 2013, 09:53:06
uh I missed this when you wrote it.
But thanks a lot, I will try it when I am at home.
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 4 December 2013, 21:16:07
atze told me about a strange behaviour of the g3d importer. the last frame always looked like the first frame and the first frame was missing.

I looked at the importers code and found out that the reason is line 427:   
Code: [Select]
for i in range(1,header.framecount-1):
If you remove the "-1" all works as expected. But I am not too sure if there are cases that make trouble which might be the reason this was once added. Can you comment on this Yggdrasil ?
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 7 December 2013, 14:16:22
I think Ifound a serious problem with the current G3D exporter resulting in g3ds with too many Vertices. Somehow many vertices are duplictaed when exporting. Looking at the code of the exporter this has something to do with textures and UV-Coordinates and duplicating vertices. The problem is it duplicates much too often!  Blender and the g3d viewer typically show a very different number of vertices for a model. You can see the problem too if you reimport the g3d into blender.. If you do so you can remove double vertices from the model and there are many of them!

In the code ( g3d_support.py ) this is around line 630 and line 650.
Is this a problem of the g3d exporter or is this a general problem of the g3d exporter?

More vertices are for sure not a good idea regarding performance :-/

Here is a model for testing: http://titi.megaglest.org/bugs/brainbug/
Title: Re: exporter/Blender 2.5/2.6 series
Post by: will on 7 December 2013, 14:42:52
Do these vertices get removed if you optimise in silnarm's g3d_hack?

I'm just guessing but perhaps towsided meshes are why?
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 8 December 2013, 01:32:40
Me and willvarfar looked at it again. In the exporter the vertices are somehow duplicated. Only thing not 100% clear now is, is it right or wrong?

Current state is: I commented out all this duplication thing and  I get a ( for me ) proper looking model.
But following the logic ( in the code and what willvarfar told me ) there is a need to duplicate vertices if they have different texture coordinates. Looking at the UV Layout of my model this is maybe needed.
But following this logic, why do i get  proper ( and smaller ) g3d when I get I export without maybe needed duplication ?

all needed files are here:
http://titi.megaglest.org/bugs/brainbug/

brainbug6.g3d is the original export with current exporter
brainbug7.g3d was exported with the vertice duplication commented out ( and I don't see a problem )

blender states the model has 791 faces
brainbug6.g3d has 941 vertices ( according to g3d viewer )
brainbug7.g3d has 791 faces as blender states it and I don't see any problems with it.

Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 8 December 2013, 12:11:00
OK after thinking a bit about it here are more tests:

here is the model http://titi.megaglest.org/g3dtest/g3dtest.blend ( texture is here: http://titi.megaglest.org/g3dtest/g3dtest.png )
looking like this in blender:
(click to show/hide)
Blender states that it has 8 Verts.

Exporting with all vertice duplication switched off results in something broken:
http://titi.megaglest.org/g3dtest/g3dtest_org.g3d
Looks broken like this in the G3dViewer:
(click to show/hide)
This has 8 vertices

Exporting with current g3dexporter without any modification results in:
http://titi.megaglest.org/g3dtest/g3dtest_org.g3d
This looks like this in the G3dViewer:
(click to show/hide)
This has 32 vertices

After removing dublicate vertices with G3dHack:
http://titi.megaglest.org/g3dtest/g3dtest_g3dhack.g3d
This looks like this in the G3dViewer:
(click to show/hide)
This has 24 vertices.

( all data can be found here: http://titi.megaglest.org/g3dtest/ )

Update: The big differences in the number  displayed by blender and by g3dviewer is definitly a different way to count the vertices so things are less worse than I first thought. It rests the duplicates found by g3dhack.
Title: Re: exporter/Blender 2.5/2.6 series
Post by: will on 8 December 2013, 13:52:53
Intriguing, and excellent test files.  I will poke around them on Monday.  I ought to be able to work out what is duplicated, at least.  The why may need learning the blender api to understand what meshes it gives us.

Its an annoying bug, and easy to become obsessed with solving, but its not a crash bug ;)
Title: Re: exporter/Blender 2.5/2.6 series
Post by: Yggdrasil on 8 December 2013, 19:25:07
The import of the animation was just a hack. The first thing which seemed to work.

There's code missing after the loop to handle the last shapekey in a special way. If extending the loop works too, then one can probably make the code even more simple.

I thought i fixed the problems with duplication but there's another bug. When a new vertex is created, it's not checked if it was created before. That's why you get unnecessary duplicates which are the exact same vertex-texcoord-pairs (g3dhack removes them). I'll try to fix it tomorrow or so.

The reason for duplication is simple a limitation in the g3d format (actually opengl likes it this way too): Every vertex can only have one texcoord. If there are more texcoords, you have to duplicate the vertex. Blender allows multiple attributes per vertex to make editing easier.
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 9 December 2013, 23:39:17
hi! About the importer I just want to mention that it works completly ok for atze with this little change I suggested!  He shrinked a whole techtree manually in blender and everything worked for him . Just import/shrink/export .
I am not sure I completely understand what you wrote, but we don't need the last shape key to be the first one. In the the rare cases we would need it we can set it manually.

Title: Re: exporter/Blender 2.5/2.6 series
Post by: Yggdrasil on 11 December 2013, 19:56:31
This should be fixed now. As always, testing is welcome as i don't have enough models nor blender knowledge to really test it.

Here the link again:
http://sourceforge.net/p/glestae/glestae/ci/master/tree/source/glexemel/g3d_support.py?format=raw
(Right-click 'Save As', name it g3d_support.py, in blender: File->User Preferences -> Addons -> Install Addon (bottom), pick the downloaded file, enable it)
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 12 December 2013, 00:42:40
This is a lot better  ;D ;D ;D . I need to test some more and atze should test import again, as he knows best whats going on there. Atzes english is not the best, can he write in german too ?

update:
Just to give you an idea: one of my current models has 941 vertices with old exporter and 845 vertices with new one !, this is very good news ( for bad gfx cards :D ).
Title: Re: exporter/Blender 2.5/2.6 series
Post by: Yggdrasil on 12 December 2013, 12:11:25
I have no problem with german. The importer is fixed like you did it. It seems to be the easiest way. Nothing else was changed in the importer. So if that worked for him before, he doesn't need to recheck everything.

It's even more important if you know that the vertex is duplicated with the corresponding normal and for every frame... For models with many frames this gets nasty.
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 12 December 2013, 23:53:45
Is it possible to remove the double vertices after you imported automatically ?

I had a quick look at some blender code and I think this does it if you do it for all imported objects:
Code: [Select]
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.remove_doubles()
bpy.ops.object.mode_set(mode='OBJECT')
Title: Re: exporter/Blender 2.5/2.6 series
Post by: Yggdrasil on 16 December 2013, 15:11:27
It's sadly not that simple. These operators only work in certain contexts which is not well documented. I can't use these operators inside an importer. I used a bmesh operator instead. You have to use at least Blender 2.65 from now on, better use the latest version.

Fun fact: Importing and then exporting an archmage model gives less vertices than the original. I'm not sure if the model was changed since vanilla glest. But maybe the old 3DS exporter produces unnecessary duplicates too. Or removing doubles in blender does more stuff than it should...
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 16 December 2013, 15:34:09
Its exactly like you say, the original 3ds exporter had trouble with unaccecary duplicating vertices. Thanks a lot for your help! 
( and btw these are the nice new monsters I exported with your exporter
(click to show/hide)
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 23 December 2013, 01:58:43
Trouble with the normals:

 :( bad news i have trouble with the current exporter. Somehow something must be wrong with the normals of the models, or its not wrong but incompatible with the current MegaGlest code. Problem is when you move a unit around the lighting is not calculated the right way. I have no clue what happens there.
Here is a G3d and its textures. It's showing a spider under a big web. http://titi.megaglest.org/g3dtest/spider  ( and it's blender file )
replace one units g3ds in MegaGlests original data or betterin a mod with this model and look at it in the game. When you start the game all is fine, but when you move the unit around, strange things happen with the lighting of the web. ( you can even try without net texture to see it more obvious ). If you turn the unit facing to the left, the lighted part is somehow nearly in the ground  on the opposite side.
And yes I double checked it, the normals of the models are ok!

Here are some screenshots showing the problem. If you look closely the spider shows the same problem ( its back is always lighted in strange ways )
(click to show/hide)
(click to show/hide)

Update:  More Infos about the normals:
This is what you get when you display the normals in G3DViewer:
 
(click to show/hide)

This is how they originallly looked like in blender ( ignore the texture )
 
(click to show/hide)
Title: Re: exporter/Blender 2.5/2.6 series
Post by: Yggdrasil on 23 December 2013, 12:51:07
A wild guess: Disable the rotation on export and do it manually. Maybe i forgot to rotate the normals. I have a look at the code this evening.
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 24 December 2013, 12:36:24
I don't really get what you mean with the rotation :-/. There is nothing rotated when exporting. I better wait until you have time to look at it. Then I will export all again.
Title: Re: exporter/Blender 2.5/2.6 series
Post by: Yggdrasil on 26 December 2013, 14:12:50
I meant the exporter option "rotate to glest orientation" which is checked by default.

The normals weren't rotated. I'm surprised nobody noticed it earlier. I hope it's fixed now.

Here the link again:
http://sourceforge.net/p/glestae/glestae/ci/master/tree/source/glexemel/g3d_support.py?format=raw
(Right-click 'Save As', name it g3d_support.py, in blender: File->User Preferences -> Addons -> Install Addon (bottom), pick the downloaded file, enable it)
Title: Re: exporter/Blender 2.5/2.6 series
Post by: Coldfusionstorm on 26 December 2013, 18:46:22
Just set blenders export option to start up with glest orientaion :P

I was not aware the script/addon had this feature.

Also Thanks a bunch Yggdrasil, This streamlines the process ALOT.
Title: Re: exporter/Blender 2.5/2.6 series
Post by: titi on 1 July 2014, 23:08:42
hm, Looks like I never really tested the last version and now I accidently overwrote my last version.

It looks like current version has a bug and does not export any normals! At least I cannot see any normals in the g3d-viewer and it looks wrong lighted  in the game. Yggdrasil can you help us ? ( just export an untextured quad and you will see what I mean ).



Update:
I found out more, it looks like only non animated models of one frame are exported this way. 2frames and more models are exported correct. Thats why i might have missed this bug yet. I check more, maybe its a bug in g3dviewer too.


Update:
This is a bug in the G3d-Viewer. It took me some time to find out and the special texture in my model made me think this is a bug in the exporter, but it looks like it is not! Sorry for this false alarm.