Larian Studios
Posted By: eRe4s3r Editing GR2 meshes finally possible - 14/03/15 11:39 PM
Hi there, since I saw nobody yet post this I guess it's my duty to do so.

Norbyte (Who else?) created an absolutely fantastic utility

The Export Tool wink (It does in fact, convert GR2 to DAE and DAE to GR2.
This allows you to convert GR2 files.. to COLLADA DAE which you can load in Blender or 3DSMAX (both tested by Norbyte and me) and export from these apps back to DAE. Then you convert the modified DAE back to GR2, add it back in the game. And you have a modified GR2 mesh, complete with bones, skeleton, weighting and everything.

Download (This is Norbyte's Dropbox) File there is always up-to-date
https://dl.dropboxusercontent.com/u/32263228/dos/gr2/ExportTool.zip


For example, if you take a look at one of the body meshes in D:OS after unpacking the pak files. You can find for example here

Data\Public\Main\Assets\Characters\Players\PL_M_Body_A.GR2

Which is default male underwear mesh (as seen in 3dsmax 2013)
[Linked Image]

Turns out Roderick drank too much bear after winning....
[Linked Image]

A bit Export Tool vodoo, overwriting the relevant GR2 and...

Ingame magic
[Linked Image]

Since I am not a character modeler this is the extend of my abilities.. but someone who has the skills can with this likely edit the HAIR and BODY of ALL things in the game. You can also likely create new items and weapons, change existing ones. Or make better underwear... or naked meshes. Whatever. I am not judging you wink

The only thing I do not know is whether you can edit animations.

The bat files in the download allow you to quickly access all the tools functions. GR2 to DAE when you want to convert a D:OS mesh to DAE and load it in 3dsmax and Blender, and DAE to GR2 when you EXPORTED a DAE mesh from 3dsmax or Blender and want it in-game.

I don't need to tell you all what an incredible thing this is. Yes, you can now modify character meshes and mesh related things in the game world.

Caveats related to character mesh modifications. The skin texture is a greyscale (yes, really!) the skin color is applied by a shader. This means you are stuck in your colorization to what the skin shader in the game allows. It also means no "easy" conversion of Skyrim body meshes.... (Well.. which is not at all EASY since you have to rig the entire body again) this is something I honestly never want to do again...

So, cometh forth and mod this game. Now with 50% more modding possibilities. Thanks and I will repeat it, entirely to Norbyte. I tested, he made! Without him, we'd still be stuck at zero.

As bonus easter egg...

Rodericks body in Unity 5 riding one of my silly spaceship models rodeo
[Linked Image]

So things are possible now wink I hope someone else experiments with this further, as I am going to be very inactive very soon.
Posted By: Windemere Re: Editing GR2 meshes finally possible - 15/03/15 12:10 PM
Fantastic work, congrats!
Posted By: karlgoran Re: Editing GR2 meshes finally possible - 16/03/15 12:16 AM
boobs mods coming up. brave new world.
Posted By: eRe4s3r Re: Editing GR2 meshes finally possible - 16/03/15 01:51 AM
From a modders perspective that'd be harder than you would think.

Every armor piece would need to be adapted to your mesh modifications or you'd either not see any change, or you'd have clipping. Also armors seem to overwrite or layer textures over the body mesh, no idea how specifically that works, but it's another factor to consider. So skimpy armor becomes specifically hard to actually do ;p (but same applies for MORE fluffed up armor)

And any other (higher detail) mesh replacement would require you to rig the entire thing all over again. And you better take note how Larian did the weighting on their meshes, because one slight mismatch and animations look wonky.

This is particularly relevant if a modder wants to, say, convert a skyrim body mesh to D:OS.....

Anyway, I hope someone with the skills needed will be able to use this for something. For mods this allows for entirely new art assets for literally anything.
Posted By: Agamemnon1 Re: Editing GR2 meshes finally possible - 06/04/15 03:54 AM
Thanks for this!
I tried it with Blender 2.68. The convert to dae and import seem to work great, but when I try to convert collada-to-gr2 on the exported file I get an error. I have tried every combination of export options I can think of and all give the same error, or else produce a file which crashes Divinity OS. The error I get most of the time says:

"Conversion Failed!

System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at LSLib.Granny.Model.Root.ImportSkin(skin skin)
at LSLib.Granny.Model.Root.ImportFromCollada(String inputPath)
at TestApp.Program.Convert(String inPath, String outPath, Boolean inGR2, Boolean outGR2)
at TestApp.Program.ExportUI(Boolean inGR2, Boolean outGR2)"

It sound like you got it to work with Blender. What version and export options did you use?
Posted By: eRe4s3r Re: Editing GR2 meshes finally possible - 06/04/15 02:49 PM
Well.. I tested with 3dsmax, Norbyte with Blender wink

All I know is that you have disable Lights and Camera on export. Ie, they should not be part of the DAE. But aside and if disabling that doesn't fix the issue for you, only Norbyte can help you further.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 06/04/15 03:09 PM
Can you send me a sample .dae which fails to convert / crashes DOS?
Thanks!
Posted By: Agamemnon1 Re: Editing GR2 meshes finally possible - 07/04/15 04:37 AM
I'd be happy to do that, though I'm not sure how. It should be pretty simple to reproduce -- I simply tried exactly what eRe4s3r shows in the example above: PL_M_Body_A.GR2 and PL_F_Body_A.GR2.

I've been using Blender 2.68, but I tried the latest (2.74) just to see if it made any difference (it didn't seem to).

Basically, I used lstools to extract Main; then I put the GR2 file in the export tool folder; then I opened a command prompt and ran "TestApp GR2ToCollada" which seems to work fine; then I opened Blender and imported collada (there is only one option for import - I mostly left it blank, but I tried both ways - it seems to change the direction the model faces); everything looks good at that point - I make changes to the mesh or not to test it, but either way seems not to affect the outcome.

Then I exported back to collada, and here's where I tried every combo of option I could thing of (I mostly tried selection only with the model and/or the armature selected, and either include children or armature as appropriate). Then I tried most other options in various combinations.

When I run "TestApp ColladaToGR2" I mostly get that error, but in some cases where I only had the mesh or the armature, but not both I think, the conversion made the new GR2. Then loading that in DOS cause a crash to desktop.

I notice the new files are bigger, so maybe that's an indication of a problem.

I strongly suspect that, since it worked for you, it has something to do with what I am doing in Blender like my export settings, but I've run out of guesses...

If you could say what setting you are using that might do the trick.

Thanks for helping!
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 07/04/15 05:16 PM
Updated the exporter to fix a Blender skeleton import bug, should be working now.

Quote
I notice the new files are bigger, so maybe that's an indication of a problem.

That's because Blender doesn't deduplicate the UVs before exporting, so the same UV set appears multiple times with different indices and it increases the number of possible (Position, UV) combinations that should be exported to the GR2 file.
I'll add a separate position/UV filter step that should take care of this.

The higher vertex count may degrade performance somewhat but should not affect the mesh in any other way.

Quote
in some cases where I only had the mesh or the armature, but not both I think, the conversion made the new GR2. Then loading that in DOS cause a crash to desktop.

While a geometry without a skeleton, or a skeleton without a geometry is still valid GR2, it may not be valid for D:OS.
I've checked, and it seems that most D:OS meshes use a dummy skeleton with a single joint when no real skeleton is available.
Posted By: Agamemnon1 Re: Editing GR2 meshes finally possible - 08/04/15 03:15 AM
Thanks Norbyte, the updated version worked great!

For future reference by others, here's how it worked: in Blender 2.68, when I impoted COLLADA produced by your tool, I checked the "Import Units" option, and when I exported COLLADA, I checked the "Selection Only" option with the armature and mesh selected and left all other options with their default values. Then I ran your tool to export to GR2, which produced a few warnings, but worked anyway. Then I made the folder ..\Divinity - Original Sin\Data\Public\Main\Assets\Characters\Players and dropped the GR2 files in there, and now they appear in-game.

Thanks again!
Posted By: Agamemnon1 Re: Editing GR2 meshes finally possible - 10/04/15 12:25 AM
I've noticed one other thing: the skeletons -- Player_Male_Base and Player_Female_Base do not work in this process. They do not crash the converter or DOS, but when you get in the game, the character is very distorted with the head sideways and the legs off at funny angles.

Is there any chance of fixing that, or is it a settings issue of some sort?

Thanks!
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 12/04/15 07:49 AM
I'm back.
Did you modify the skeletons in any way, or just a straight reexport from Blender?
Posted By: Agamemnon1 Re: Editing GR2 meshes finally possible - 12/04/15 05:59 PM
I tried it both ways, same result.
Thanks for that great TOOL!

at first i want to give an huge applause to you and your fantastic guide for the material editor in the divinity engine.
After a while of testing, i wanted to modify an object and change some textures of it.
The export import of the MESH works correctly. Then I start to creat a new material with an new texture. I save the material as .lsmg (the only possibly file)

After that i start to import the new material, but i had to notice that the resource manager only let my import .lsb.

Have any one a idea, how i can get the .lsmg to an .lsb fiele? That i can import the material to the engine?

Greedings
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 27/04/15 10:51 PM
Here is the short version:

In the material editor window: File -> Regenerate Materials ...
[Linked Image]

Select Mods\%yourMod%\Assets\Materials
Click "Generate HLSL and GLSL"
[Linked Image]

After generation is complete, select Add Resource -> Material ... in the Resource Manager window.
Select the <materialName>.lsb file that was generated in the previous step, select a package from your mod. (You can leave the "Data mod" empty).
For some reason, the editor forgets the name of my material the first time I do this, so I end up with an unnamed material in the content browser. If you have the same issue, right click -> Rename/Move... and click OK. It'll fix the name issue.

If you have tex/scalar/etc parameters, you should also specify those in the next window.
Posted By: aqa Re: Editing GR2 meshes finally possible - 05/05/15 08:37 PM
So I wanted to try my hand at changing a few armors, since I am really not a fan of the huge shoulderpads. I am certainly not an expert on 3d editing, but I am mostly able to struggle my way through it. But for me things are not going so easy as described in the OP.

The first armor I wanted to change is PL_F_ARM_Starter_A_Torso_A.
So as a test I converted it to a .dae file and back to a gr2, so far so good, that loaded up perfectly in the game. But when I try to make any change things stop working.

In 3dmax I am getting a bunch of errors while loading the file, and when without any edit exporting back to a .dae and converting to gr2 the armor is invisible in game.

When trying the same with blender it seems the skeleton is completely messed up, the armor pieces drag on the floor behind my character when she's walking about, like some weird snake made of armor pieces.

Is there some tutorial for dummies I could follow?

The errors I'm seeing in 3dmax:
While reading or writing a file the following notifications have been raised.
-Warning: The transform of node "Bone_Dummy_Root" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001_Pelvis" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001_Spine" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001_Spine1" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001_Spine2" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001_Neck" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001_L_Clavicle" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001_L_UpperArm" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001_R_Clavicle" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001_L_Thigh" is not compatible with FBX, so it is baked into TRS.
-Warning: The transform of node "Bone_Bip001_R_Thigh" is not compatible with FBX, so it is baked into TRS.
Posted By: Agamemnon1 Re: Editing GR2 meshes finally possible - 05/05/15 09:20 PM
@aga: See my post above: when you import COLLADA to Blender, you must check the "Import Units" option or you will see the result you describe.

@Norbyte: Just curious, do you think you will be able to fix the skeleton (Player_..._Base) import-export? Or is that pretty unlikely? Thanks!
Posted By: aqa Re: Editing GR2 meshes finally possible - 05/05/15 10:30 PM
Originally Posted by Agamemnon1
See my post above: when you import COLLADA to Blender, you must check the "Import Units" option or you will see the result you describe.


Oops, I somehow completely missed your post.
It is not working for me unfortunately.

I am using these setting for importing:
[Linked Image]

And these for exporting:
[Linked Image]

Could you have a look and see if I'm missing anything?
Posted By: Agamemnon1 Re: Editing GR2 meshes finally possible - 05/05/15 11:30 PM
Mine (Blender 2.68) has a few less options, but the only thing that's different is I don't have "Include Armatures" checked. I selected both the armature parent object and the mesh object which is a child of that before exporting (and nothing else).
Posted By: aqa Re: Editing GR2 meshes finally possible - 06/05/15 12:06 AM
I tried your version of blender that did the trick, thank you so much. smile

It seems the newest version of blender imported it a little different, the model aligned to the Z axis blender 2.74, while in version 2.68 it is aligned to the y axis.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 06/05/15 06:42 PM
Originally Posted by Agamemnon1
@Norbyte: Just curious, do you think you will be able to fix the skeleton (Player_..._Base) import-export? Or is that pretty unlikely? Thanks!


It is technically feasible, I just haven't had time to work on it yet frown

UPDATE: I found the issue! Expect a fix tomorrow
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 07/05/15 10:58 PM
I've updated the exporter with the latest (WIP) version which should be able to convert stuff exported from Blender properly now.

Some notes:
  • Most of the options don't work yet, so don't check/uncheck stuff if you don't need to.
  • D:OS sometimes crashes when importing meshes that have no skeleton. The "Create dummy skeleton" is a workaround option for this, that generates a skeleton with a single dummy bone.
  • Some tools (eg. Blender) export Collada files with Z as the up vector. GR2 uses an Y-up system, so we need to convert between the two; this is what the "Apply basis transformation" option does. It is preferred that you export COLLADA in Y-up though if possible (eg. 3ds Max exporters support this).
  • Animation import/export is currently very rudimentary and experimental, so expect strange jittering there.


Lastly, animations may break when reimporting the mesh.
This is caused by art tools (eg. Blender, maybe others too) subtly changing the transformation matrices of the skeleton joints. Although the transformations they export is correct, the animations in the game expect the rotation/translation values of the binding pose to be exactly what they were when the original mesh was exported. If this is not the case, the animations will change these values in an incorrect way and this results in corrupted animations.

The "Conform to skeleton:" option copies the bind pose from the specified GR2 file. (You should select the *original* GR2 file that you exported from the game here)
This fixed animations in all tested cases so far.
Posted By: Agamemnon1 Re: Editing GR2 meshes finally possible - 09/05/15 02:00 PM
Thanks so much! I didn't get the skeleton working yet, but I see the rest works nicely!
Posted By: Evelilyt Re: Editing GR2 meshes finally possible - 11/07/15 01:29 PM
Hey guys, I'm trying to change models too but I'm facing some problems. My steps:
1. I use ExportTool to get *.dae file
2. I open them in Maya 2016. Here is what I see in viewport http://prntscr.com/7rfiyd
3. I export model to *.fbx format (Tried without any changes to be sure the problem was caused not by my modeling manipulations smile )
4. *.fbx file I converted using lstools (tools->export fbx to gr2)
5. And at last I put *.gr2 with appropriate name (PL_F_Head_A.GR2) to D:\Games\SteamLibrary\SteamApps\common\Divinity - Original Sin\Data\Public\Main\Assets\Characters\Players
And the face in game completely disappears smile http://prntscr.com/7rff92
My friend tried to convert model in 3dsMax for me, the result is almost the same no face and body now stands in T-pose smile
So somewhere between convertations I broke model(
Any ideas? Would be glad for help.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 12/07/15 07:18 PM
You should try exporting directly to .DAE from Maya and converting .DAE -> .GR2 directly.
If it doesn't work, please attach:
- The original .GR2 file
- The converted .DAE file
- The modified .DAE file that you exported from Maya
- The new .GR2 file

Thanks
Posted By: Evelilyt Re: Editing GR2 meshes finally possible - 25/07/15 11:39 AM
I'm sorry it seems that my browser didn't show me new replies cause I checked every day for new messages smile
I've tried convert directly to .dae but the problem is still there. Adding some screenshots and model files.
This is my convertor settings (all is default) http://prntscr.com/7wsge2
Imported file_name=PL_F_Head_A.GR2
File_name=PL_F_Head_A.dae is successfully exported
I'm getting those warnings in Maya BTW http://prntscr.com/7wshyo but I think they aren't critical (please correct me if I wrong).
Than I export all to .dae using maya's dae_fbx_export, all setting by default (maybe somewhere in default options my problem are hided) http://prntscr.com/7wsk8t
File_name=PL_F_Head_A_Exported.dae
And exported all to .fbx as did it before using maya's fbx_export
Here are all default settings:
http://prntscr.com/7wslqn
http://prntscr.com/7wslue
http://prntscr.com/7wsly4
File_name=PL_F_Head_A_Exported.fbx
I didn't make any changes in mesh, just export.
In lstools there are only 1 menu item for converting .fbx to .gr2 but it seems to work with .dae thought. http://prntscr.com/7wsmsj
Exported files:
From .dae = PL_F_Head_A_DAE.GR2
From .fbx = PL_F_Head_A_FBX.GR2
Then I just renamed one file to PL_F_Head_A.GR2, saw faceless women smile and than other. Every time I went back to main menu and started new single game with character creation for watching changes. After I put back original file face magically appears smile
All files are here https://www.dropbox.com/sh/vejkda3uryfhwvc/AAD7sENal38C1Bk9_wF_S5vma?dl=0
I hope you won't get any problems getting them, If you couldn't download files please contact me and tell where I can upload them for you.
I really hope we would find solution smile thanks for answering.

Posted By: Evelilyt Re: Editing GR2 meshes finally possible - 04/09/15 01:43 PM
horsey still didn't find a solution
Posted By: SniperHF Re: Editing GR2 meshes finally possible - 30/09/15 12:18 AM
Anyone around who knows how to make this part work?

I can't get the LSMG file to change to an LSB.

Originally Posted by Norbyte
Here is the short version:

In the material editor window: File -> Regenerate Materials ...
[Linked Image]

Select Mods\%yourMod%\Assets\Materials
Click "Generate HLSL and GLSL"
[Linked Image]

After generation is complete, select Add Resource -> Material ... in the Resource Manager window.
Select the <materialName>.lsb file that was generated in the previous step, select a package from your mod. (You can leave the "Data mod" empty).
For some reason, the editor forgets the name of my material the first time I do this, so I end up with an unnamed material in the content browser. If you have the same issue, right click -> Rename/Move... and click OK. It'll fix the name issue.

If you have tex/scalar/etc parameters, you should also specify those in the next window.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 05/10/15 04:45 PM
Originally Posted by Evelilyt
horsey still didn't find a solution


Hi,

I've completely forgotten about this thread, sorry frown
In case you're still interested:

1) You should use the new exporter for .DAE -> .GR2 conversion (the same one you used to convert from .GR2 to .DAE); the FBX one is quite old and since it uses a proprietary library, I can't really do much to fix issues with it. The new one is known to work with skeletons.

2) The scale in the exported FBX/DAE file is incorrect.
This is how it looks like after GR2 conversion and mesh composition:
https://dl.dropboxusercontent.com/u/32263228/dos/gr2/head_scale1.png
The small dot at the bottom is the rest of the body. I'd say the head is ~100x larger than it should be.

... this is how it should look like with a correct scale:
https://dl.dropboxusercontent.com/u/32263228/dos/gr2/head_scale2.png

So to fix it, you should downscale the mesh in Max, and then export it to DAE.
Then export the DAE to GR2 like so:
https://dl.dropboxusercontent.com/u/32263228/dos/gr2/export_opts.png
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 05/10/15 05:10 PM
Originally Posted by SniperHF
Anyone around who knows how to make this part work?
I can't get the LSMG file to change to an LSB.


The .LSMG won't "change" to an .LSB, the editor will just generate multiple compiled materials (.SHD/.BSHD) and a "catalogue" (.LSB) for the source material (.LSMG).
The location of the generated .LSB-s is also a bit weird.
My .LSMG was in
Data\Editor\Mods\%MyMod%\Assets\Materials; the generated material was in
Data\Public\Mods\%MyMod%\Assets\Materials.

Also, make sure that you don't relocate the .LSB or .SHD files, as their paths are hardcoded in the .LSB:
[Linked Image]
Posted By: SniperHF Re: Editing GR2 meshes finally possible - 06/10/15 02:29 AM
Originally Posted by Norbyte

Also, make sure that you don't relocate the .LSB or .SHD files, as their paths are hardcoded in the .LSB:
[Linked Image]


I'll try running a search for those extensions by date modified and see if anything comes up. Thanks.
Posted By: fancyadul Re: Editing GR2 meshes finally possible - 11/12/15 07:23 AM
I know this thread is super old, but I'm trying to make some minor changes to a couple of meshes with Blender.

Everything is working and even appearing in game, just for some reason the backside of whatever I exported out of Blender glows and is bright while the front is dark. I'm just really confused haha
I've tried everything, but I don't know why it's doing that. Does anyone know what the problem could be?
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 12/12/15 08:20 AM
Sounds like the normal vectors are screwed, but I can't be sure until I take a closer look at it.
Can you attach one of the meshes and the steps you used for exporting from Blender?
Posted By: fancyadul Re: Editing GR2 meshes finally possible - 13/12/15 12:30 AM
When I export it I would just go file>export>collada to my desktop and then from there convert it back to a gr2 file with your tool.
I do delete the camera and lamp also.
All of the meshes are doing this after I export them, even if I don't do anything to what I import. I am using version 2.76 of Blender so I don't know if that has something to do with it since I saw that some people in this post are using older versions.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 13/12/15 10:37 AM
Works fine for me with 2.73, didn't try 2.76 yet.
Can you upload the .blend, .dae and .gr2 files somewhere?
Posted By: anonymous Re: Editing GR2 meshes finally possible - 04/01/16 06:19 PM
Hey!
I'm also experiencing the lighting issue described a few posts back. It looks like this: http://i.imgur.com/WIMZXN2.jpg

It looks like the rimlighting effect is being rendered on the front of the model instead of the back.

I have the EE version of the game. I'm exporting from 3ds Max 2012 using the latest FBX plugins. I import with default collada settings but with cameras and lights switched off, and export with scale conversion to decimeters and lights and cameras off. All other scale settings seem to blow up the model on export.
This issue doesn't occur when I import the default body into Max and export it straight back into the game without editing. Then the lighting shows up just as it should. When I export a custom mesh this happens. The only notable difference between the two, judging by cross referencing them in notepad++, is that Max exports materials with the custom mesh. I tried deleting material data from the DAE after export but it didn't make any difference.

It'd be awesome to get a solution for this - I'm a 3D artist and I'd love to make a nice female body replacer and maybe replace some armor with new designs smile
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 04/01/16 11:43 PM
It seems that 3ds Max exports the initial mesh rotation by multiplying it with the bind pose and saving it as the bind_shape_matrix instead of using a transform in the root scene node (as is usual), which confused the exporter a bit and caused vertex normals & tangents to point in the wrong direction.

Should be working now in v1.4.3.
Posted By: anonymous Re: Editing GR2 meshes finally possible - 05/01/16 07:09 PM
Just tested it out and it works! Time to get cracking!

Thank you very much for your support and your instant response. I'll be sure to share my mod work when it's taken shape.

Edit: Well, I'm left dealing with this issue: http://i.imgur.com/KoydePI.jpg (nude barbie doll anatomy warning)

Even though I'm exporting a smooth clean unified mesh, it comes out split up at UV seams with messed up normals. I baked out super clean normal maps but it was no help. Possibly related to the normal vector issues from prior? I also saw this happening when the lighting issue was occurring.

I can send files over again if it's necessary, just let me know.

Edit: Nevermind! I flipped a normal map axis and the problem went poof smile
Posted By: Vector Re: Editing GR2 meshes finally possible - 20/01/16 03:06 PM
Hey Norbyte

Thank you so much for your time and developing your wonderful tool! I'm loving it! I have one question though. Normals import/export are not working yet right? Initially I thought it was the blender(s) plugins (I tested with 2.63, 2.72 and 2.74) but then I did a simple test, export the GR2 and import the DAE after without even going to blender, and the normals still get messed up. Not like those previous issues like others pointed out, I'm talking about the visible difference in lighting direction on UV island edges, which produce visible seams

In any case, thanks and kudos! =)

EDIT: I'm aware that flipping/inverting the green channel fixes the issue, but will need to replace a whole bunch of textures in the proccess, when it would be preferable to just fix the mesh instead
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 20/01/16 07:30 PM
Are you replacing textures as well, or just the mesh?
The normals are not recalculated and are always imported from the .GR2/.DAE file as recomputing them is a complicated process and the 3ds/Blender exporters would generate better normals anyway.
Posted By: Vector Re: Editing GR2 meshes finally possible - 21/01/16 02:35 PM
I'm mostly doing some minor mesh tweaks, but since when I re-import the mesh the normals are not being recalculated, it means I will have to edit the _NM.dds in order to fix the wrong directions. No biggie really, just thought it would be a nice feature to have, and I will have to edit some textures I wasnt planning on, but I can live with that =)

I would however suggest another feature that might be easy to implement, a batch convert for GR2/DAE just like you have done with the LSB/LSF/LSX tab. That would be truly awesome and save loads of time.

Anyway, thanks again for your fabulous tool!
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 21/01/16 06:17 PM
I checked the normals before and after exporting, and they seem to match.
I think I know what the issue is though; can you check if this version has the same issue?
https://dl.dropboxusercontent.com/u/32263228/dos/gr2/gr-test.zip
Posted By: Vector Re: Editing GR2 meshes finally possible - 21/01/16 08:47 PM
yes it has the same issue and I tested all possible combinations of changing the axis direction on all 3 channels (positive and negative) so I'm assuming that maybe that version swaps axis (which would mean that I would have to swap RGB channels?)

The current public version, still works better since I know exactly what channel to change direction (Green). With this one I always have normal issues no matter what. I would say that if you changed the way axis/directions are being used, you're in the right track though =)

Cheers!
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 21/01/16 09:40 PM
Hrm, that is unexpected.
Well the problem is, that the normals are just fine. The preview of the original and exported GR2 is a nearly 1:1 match:
https://dl.dropboxusercontent.com/u/32263228/dos/gr2/orig_export_comp.png
https://dl.dropboxusercontent.com/u/32263228/dos/gr2/orig_export_tangents.png

I suspect the screwups are because tangents are calculated differently (the only difference between the new version I sent you and the original is that I changed the direction of the binormal). These are not exported however, so they must be recalculated when converting to GR2.

Which model are you trying to modify btw?
Posted By: Vector Re: Editing GR2 meshes finally possible - 21/01/16 10:08 PM
Oh darn, it worked!! the results I was seeing was because of an option I had when exporting the Collada! When I continued working and saw I was having the same results, thats when I realized something else was wrong! You're a Genius! =D

Thank you so much! Will save me some time and I wont need to re-do all the normal maps!
Posted By: anonymous Re: Editing GR2 meshes finally possible - 24/01/16 01:07 PM
Which export option are you talking about? I also noticed I had to start flipping the green channel in my normal maps.

Edit: Started poking around and tried leaving 'Apply transformation basis to Y-up' unticked in the GR2 converter. That worked!
Posted By: Vector Re: Editing GR2 meshes finally possible - 29/01/16 08:59 PM
I'm almost sure I tried that with the previous app version and it didnt worked for me, in fact, that option seems to have no effect what so ever. The new version Norbyte uploaded though, did the trick.

Another option that doesnt seem to do anything (at least not when importing to GR2) is the mirror option. I've tried with that option both enabled and disabled and I still get the meshes in game mirrored on the X axis.

But... I'm having some real hard time when exporting/importing some armors:

1. Some armors, if I just export to DAE and immediatly to GR2 (not even editing/exporting in any 3D app) don't show up in the game. One example is PL_M_ARM_Leather_B_Torso_A.GR2

2. Some armors that have 2 parts/objects, if edited (for example, delete a vertex) when exported doesnt work either. PL_M_ARM_Leather_A_Torso_A.GR2 is an example for this.

Two things may happen:

A) Armor doesn't show up at all, character is naked.
B) As far as I can see, armors that have 2 parts, have a proper order, so the materials/uvs are assigned correctly. If I export with the wrong order, the armor shows up, but the materials swapped. If the order is the correct one, same thing happens as described in A).

Really puzzled... I've even tried to in some cases compare the DAEs text, to see what differences there were between the DAE produced by blender and the one by Norbyte's app, and edit the blender one so it "matches" the one exported by Norbyte's app.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 29/01/16 11:12 PM
Originally Posted by Vector
I'm almost sure I tried that with the previous app version and it didnt worked for me, in fact, that option seems to have no effect what so ever.

If your 3D editor already exports DAE files with an up vector of (0,1,0) then the Y-up conversion won't do anything.

Originally Posted by Vector
Another option that doesnt seem to do anything (at least not when importing to GR2) is the mirror option.

I'm not aware of any mirror option, at least not in the exporter :O


Originally Posted by Vector
1. Some armors, if I just export to DAE and immediatly to GR2 (not even editing/exporting in any 3D app) don't show up in the game. One example is PL_M_ARM_Leather_B_Torso_A.GR2

I'll look into it.

Originally Posted by Vector
2. Some armors that have 2 parts/objects, if edited (for example, delete a vertex) when exported doesnt work either. PL_M_ARM_Leather_A_Torso_A.GR2 is an example for this.

Can you attach a modified and an original DAE for this?
Posted By: Vector Re: Editing GR2 meshes finally possible - 30/01/16 01:36 AM
Originally Posted by Norbyte

If your 3D editor already exports DAE files with an up vector of (0,1,0) then the Y-up conversion won't do anything.


Nope its Blender, the exporter doesnt have that feature, however I've read that rotating the objects 90º on X is the same, and thats what I've been working with. FYI, I just tested exporting the same DAE to GR2 using the option "Apply Basis Transformation to Y-Up" both checked and unchecked, and I see no apparent difference between them, the meshes are properly placed (unless this option only affects normals???)

Originally Posted by Norbyte

I'm not aware of any mirror option, at least not in the exporter :O

Then I misinterpreted what "Recalculate inverse world transforms" do. Either way, again as the previous mentioned option, I see no difference from either using it or not. I assumed it had to do with some mirroring, because on Blender I have all meshes (and armature) mirrored on the X axis.

Originally Posted by Norbyte

I'll look into it.


Originally Posted by Norbyte

Can you attach a modified and an original DAE for this?


I tried to recreate the issue, now everything is working... *rolleyes*

But I'm sure I didnt do anything wrong before because, I still happened to had the DAE open in the text editor, when I tried earlier and that same DAE didnt work. This DAE was causing the character to be naked (not even loading the body texture). I have tried this same DAE, and now its fine, so its not the DAE.

I know what I'm doing btw, its not the first game I ever modded or something lol, so the only possible explanation for these bizarre behaviours, is that I'm mostly running your app under Wine. Still find it bizarre though, that sometimes is able to work and sometimes not. However, I do know for example, that one day I was running it on Parallels, and was able to import a LSV, while trying it on Wine, I wasn't.

I also had to delete the CONFIG file you had in the zip, because it was preventing your app from recognizing the .NET installation, and was not able to run. As soon as I deleted, everything worked fine (or at least it seems lol)

If I get a GR2 that is getting me the same issue again, I'll make sure to post it here, maybe then you can shed some light about it.

Posted By: Norbyte Re: Editing GR2 meshes finally possible - 30/01/16 06:56 PM
Originally Posted by Vector
FYI, I just tested exporting the same DAE to GR2 using the option "Apply Basis Transformation to Y-Up" both checked and unchecked, and I see no apparent difference between them, the meshes are properly placed (unless this option only affects normals???)

More specifically, if the DAE you're importing has "<up_axis />" then it won't do anything.
If it has "<up_axis>Z_UP</up_axis>" or "<up_axis>X_UP</up_axis>", then it is converted to Y-up.
It is not specific to normals, it affects all properties of the model.

Originally Posted by Vector
Then I misinterpreted what "Recalculate inverse world transforms" do.

IWT recalc is usually not necessary as the converter uses the IWT that is baked into the DAE when exporting. Sometimes this information may not be correct, in which case a recalculation is needed. But it is more of a debug option than something you'd actually need to use.
Inverse world transform is also known as inverse bind shape matrix / bind pose.

Originally Posted by Vector
If I get a GR2 that is getting me the same issue again, I'll make sure to post it here, maybe then you can shed some light about it.

Please post the original DAE and corrupted GR2 file too, as apparently there is a specific configuration that causes this issue.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 30/01/16 09:16 PM
I've updated the dropbox version with the latest changes.
Changelog for v1.4.1 - v1.4.4:
- Fixed boolean parsing in LSX files
- Added pretty printing support for LSX files
- Fixed LSF/LSB resource handling confusion
- Add support for D:OS EE story files
- Add support for more (21) GR2 vertex formats
- Fix crash when the loaded GR2 file only contains a skeleton
- Fix occasionally incorrect transformation when loading skinned GR2 meshes
- Save GR2/DAE exporter info properly
- Fix tangent/binormal calculation
- Allow specifying a custom vertex format for GR2 meshes
- Allow manual rebuild of normals/tangents even if they were available in the source file
- Add normal/tangent/UV export selection
- Fix: Obey export options for Collada exports

Originally Posted by Vector
I'm mostly running your app under Wine.

AFAIK you can run it properly under Mono without the need for Wine.
Posted By: Aenra Re: Editing GR2 meshes finally possible - 30/01/16 10:27 PM
Thanks for keeping this up Norbyte smile
Posted By: Baardvark Re: Editing GR2 meshes finally possible - 30/01/16 11:06 PM
Add support for D:OS EE story files


Can we compile goals into the story now? Opened up the new version (though it seems like the dropbox version is only 1.4.3?) and tried the story tool. Nice to be able to extract the story.div.osi file into the individual goals, but we already have all the goals available. Is there a way to do the reverse? Also, don't quite understand the database editor. I load the story and there's this list of database entries, but doesn't seem to be any way to edit them or anything. Just these things like 0 (CHARACTER) 1 (INTEGER) when I select something, but not sure the purpose of that.

@Vector

What sort of models are you working on? Improving or changing existing gear or creating new models (is that possible?)
Posted By: Vector Re: Editing GR2 meshes finally possible - 31/01/16 12:08 PM
Mono doesnt work so good... crashes a lot (specially when copy/pasting the text, which I do a lot for import/export, I just change the extension from DAE to GR2)

and as expected, here you go:

PL_M_ARM_Cloth_A_Torso_B
https://www.dropbox.com/s/y3b9gkv019c53xb/PL_M_ARM_Cloth_A_Torso_B.zip?dl=0

I basically deleted everything on the mesh and left just the bag on the thigh. In game, character appears naked. I'm using the exact export settings I'm always using really baffles me why sometimes it works and sometimes it doesn't... I'm also gonna do 2-3 more exports next, and I'm sure I'll be able to at least do so for some bracers. Bracers/Boots so far havent given me any trouble.

I also suspect that the issue here might be that maybe the mesh is there, but somehow is not using the correct maps, so it fails to encounter a proper Alphas, so defaults to a full black alpha (which will ofc render it invisible). Although unsure if that would explain the nakedness, kinda hard to tell since the game engine uses tons of alphas to hide stuff/tint/whatever...

EDIT:
Just tested the new version, problem still occurs (although there was about a 1kb difference on the file size xD)

EDIT 2:
I was unaware that Mono was a standalone thing aswell, I was referring to Mono as the Mono for Wine, but I'm DLing Mono now and will give it a run, thanks for the tip! =)
Posted By: Vector Re: Editing GR2 meshes finally possible - 31/01/16 12:14 PM
Originally Posted by Baardvark

@Vector

What sort of models are you working on? Improving or changing existing gear or creating new models (is that possible?)


Its just minor edits and tweaks, no big deal, for my personal use, but anything is possible ofc... even if you want, you can import assets from other games, however that will potentially bring copyright issues.

Anything is possible really =)
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 31/01/16 02:20 PM
Originally Posted by Vector
I basically deleted everything on the mesh and left just the bag on the thigh. In game, character appears naked. I'm using the exact export settings I'm always using really baffles me why sometimes it works and sometimes it doesn't... I'm also gonna do 2-3 more exports next, and I'm sure I'll be able to at least do so for some bracers. Bracers/Boots so far havent given me any trouble.

I also suspect that the issue here might be that maybe the mesh is there, but somehow is not using the correct maps, so it fails to encounter a proper Alphas, so defaults to a full black alpha (which will ofc render it invisible). Although unsure if that would explain the nakedness, kinda hard to tell since the game engine uses tons of alphas to hide stuff/tint/whatever...


Well, there are two problems I could see:
1) The original GR2 file had two sub-meshes, PL_M_ARM_Cloth_A_Torso_B and PL_M_ARM_Cloth_A_Belt_B. In the export, the PL_M_ARM_Cloth_A_Torso_B mesh is not present at all, which may be an issue.
2) Lots of vertices were removed from PL_M_ARM_Cloth_A_Belt_B to the point where the mesh only has one influencing bone, with an uniform weight of 255. For some reason, Granny considers such meshes to be rigid, instead of skinned (probably an optimization), which again might cause the composition to fail. Adding a dummy weight of 0.0001 to one of the other bones can fix this one.

EDIT: There is a possible workaround for 2), available here:
https://dl.dropboxusercontent.com/u/32263228/dos/gr2/skin-test.zip
Posted By: Vector Re: Editing GR2 meshes finally possible - 31/01/16 03:03 PM
Actually I was starting to consider it was a weights issue, because I was just comparing vertex groups and noticed some of the meshes had the bone chain and some didnt. I did tried to add those "dummy" vertex groups, but didnt added any weights (the problem persisted anyway)

I'm aware of the missing object/mesh situation thing. but I've tried to add just a simple face to fake the missing object, and got the same problem. Ofc I also didnt add any weights to it, so I had the same problem.

I'll test the new version, and now that I understand that it might be indeed a lack of weights, I'll try to re-add the placeholder mesh to replace the belt, and see how it works.

PS-Tried Mono, crashes quite easily, and unfortunately I can't browse anything outside my home folder, so I'll keep using wine instead.

EDIT:
Just one reminder Norbyte, I had situations, just for the purpose of testing where I would import the GR2 directly from the original assets to DAE, and then procceed to import that same DAE back to GR2 and had the same issue, no armor, naked character. I can also say with 100% I tested that with an armor with two parts (the infamous belt part ofc). Like I said, I never had problems with bracers or boots. Its mainly armors that have 2 parts, and its not always because the mesh was deleted.

EDIT 2:
The 0.000001 fixed the issue, and I just did a plane with 4 vertex to act as placeholder for the belt scaled to 0.0 and also weighted it to the Pelvis bone.

And a suggestion if possible Nordbyte. Because you cant really set the export order for the objects (there is a Sort by Object name option but thats it), but as far as I can verify the order is relevant for keeping the correct textures applied, would it be possible to be able to change the order in the mesh list? That would be great, if not to complicated =)

Anyway, thank you again for your priceless help, you're awesome!
Posted By: Abraxas* Re: Editing GR2 meshes finally possible - 31/01/16 04:03 PM
@Vector: You seem to be quite experienced in modelling. I have started to explore how do create my own models and add them to the game via Resource Manager. Works fine so far! A further step would be adding animations. It should be possible, too, right? It would be great to have a Resource Manager Guide (models, animations, textures, effects etc.) and a Modelling/Animating Guide which contains information about what full functional character and armor/weapon assets consist of (e. g. how to make characters equip armor to the right parts of their body) and what to take care of during modelling and animating. Do you think you or someone else here on the forum could write a few Guides for all modders who aren't familiar with these things (like me)? I would really like to see new characters, weapons, armors, effects and more in the upcoming mods, after the Editor for EE is released!
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 31/01/16 09:55 PM
Originally Posted by Vector
Just one reminder Norbyte, I had situations, just for the purpose of testing where I would import the GR2 directly from the original assets to DAE, and then procceed to import that same DAE back to GR2 and had the same issue, no armor, naked character. I can also say with 100% I tested that with an armor with two parts (the infamous belt part ofc). Like I said, I never had problems with bracers or boots. Its mainly armors that have 2 parts, and its not always because the mesh was deleted.


Curious. Haven't encountered that problem yet

Originally Posted by Vector
The 0.000001 fixed the issue, and I just did a plane with 4 vertex to act as placeholder for the belt scaled to 0.0 and also weighted it to the Pelvis bone.

I've added a fix to auto-assign the same bones that were used in the original mesh if they aren't in the bone binding list if the "Conform to original GR2" option is checked.

Originally Posted by Vector
Because you cant really set the export order for the objects (there is a Sort by Object name option but thats it), but as far as I can verify the order is relevant for keeping the correct textures applied, would it be possible to be able to change the order in the mesh list? That would be great, if not to complicated =)

Models are now automatically sorted to use the same order as the original model uses if the "Conform to original GR2" option is checked.

Hopefully fixed but still beta version: https://dl.dropboxusercontent.com/u/32263228/dos/gr2/skin-test.zip
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 31/01/16 10:03 PM
Originally Posted by Baardvark
Can we compile goals into the story now? Opened up the new version (though it seems like the dropbox version is only 1.4.3?) and tried the story tool. Nice to be able to extract the story.div.osi file into the individual goals, but we already have all the goals available. Is there a way to do the reverse? Also, don't quite understand the database editor. I load the story and there's this list of database entries, but doesn't seem to be any way to edit them or anything. Just these things like 0 (CHARACTER) 1 (INTEGER) when I select something, but not sure the purpose of that.


About story stuff:
Since you'd need the EE editor to properly support EE anyway, I've decided not to reimplement the full story compiler stuff as it'd mostly be a waste of time, and very hard to do/test.
What you have now is the (WIP) ability to edit databases / story variables in existing files. This is mostly useful for simple stuff like the 4 players mod or editing the story DB-s of save game files (since it uses the same file format). It can be also useful for stuff like checking the contents of your databases while developing mods.

I was thinking about adding something on top of the original story language to make it worthwhile, like some simpler syntax to do "A and (B or C)", database name/signature typo detection (which can be mighty annoying to debug/detect otherwise) which currently requires duplicating all of the rules.
Its currently undecided as I'd need a lot of free time to do this, which I don't have atm.
Posted By: Baardvark Re: Editing GR2 meshes finally possible - 31/01/16 11:15 PM
Alright, makes sense. Definitely would be a pain to test story stuff without the editor (testing simple changes with Scales has been tedious but doable.)
Posted By: Vector Re: Editing GR2 meshes finally possible - 01/02/16 07:15 AM
@Abraxas

Oh I'm afraid I can't do that... I'm a retired modder and for reasons I care not to explain I'm setting myself away from being involved with anything.

And besides, my knowledge is only on 3D (and I don't think I'm even that good), I know almost nothing about modding D:OS specifically. I don't even know what the Resource Manager you speak of is. Is it the D:OS editor or a tool developed by the community?

But, if anyone has any particular 3D related question (be it directly about 3D and/or textures/maps) feel free to ask, and I'll gladly answer to the best of my ability.

And to shortly answer to the rest of your query:

About Animations:
Thanks to Norbyte's tool, you can import and export animations, so you can edit and/or replace them for sure. I only tested importing so far and it works.

I can't say if its possible to add new animations in a sense that those would have to be "hooked" to an action. So that would require for you to build those actions first. I've already stumbled upon the LSF that has the list of all animations and other assets used by any character, so I would believe that adding new actions/animations will most likely be possible.

Armors:
I'm sure its possible, but its pretty much like the animation assets, you have to first create the data to be usable in game, so it can call whatever asset you want. I can't really talk about adding new armors or how they relate to the "slots" concept. I don't really think there are slots (at least not as Skyrim has them), but I'm sure you can certainly influence meshes from being visible or not, because bracers for example, are hidden if you equip a Robe. I don't think this is hardcoded. So basically you would only have to create an item, assign a mesh to that item, that when equipped displays and/or hides on the character. D:OS makes extensive use of Alpha maps in order to normallly show/hide/tint the textures/meshes, so in my opinion hiding meshes are being controlled by alphas, rather than slots.

In general, although sometimes its not so easy to find information about how to edit/add something specific, you can always just browse the LSF/LSB/LSXs to find out where certain things exist. Even the Classic D:OS game editor will be useful for you on this, because if you want to know how to do something in the EE LSFs, you can just do it on the editor, save your mod, and see what changes/LSBs exist. For example, I wanted to see if you could scale the characters, since I didnt knew how to do it, I did it on the editor (technically a friend did it for me, as I don't have it installed), looked up the LSBs it created, and then easily found out where to change that.
Posted By: Abraxas* Re: Editing GR2 meshes finally possible - 02/02/16 08:53 PM
Thanks for answering! Resource Manager is a tool included in the Editor which allows to add new models, textures, materials, sounds, effects, animations and (character and item) scripts. It looked as if you could assign animations to predefined actions (walking, attacking etc.) here, to make your model use its animations ingame (if I remember correctly). I was hoping to find some advice how to do that. As soon as I have some free time I'll look into that and, maybe, post what I found out. Thank you anyway!

Armors: Yeah, I imagined something like that. Should be possible for me to find out. If there are some 3D questions, I'll be glad to participate in your knowledge!

Posted By: NewEco Re: Editing GR2 meshes finally possible - 24/05/16 06:05 PM
any chance, Gr2Converter gets the capability of decoding compressed .gr2 files ?
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 24/05/16 09:43 PM
So far I've only seen one or two compressed meshes in DOS so it was not really worth the effort.
The compression used in GR2 is proprietary (Oodle0/Oodle1) and is quite hard to reverse engineer.
Is there a specific mesh you need this for?
Posted By: Ashryu Re: Editing GR2 meshes finally possible - 25/05/16 09:26 AM
Does anyone know why my meshes would appear sort of.....blocky in game? They look very polygon-ish, if that makes sense.

It looks like the problem is happening in blender, because I am able to convert to .dae and back to .gr2 using the tool and the effect doesn't happen. But if I import into blender, then export, THEN convert using the tool, I get the blocky effect.

Been banging my head against this for a while now, would really appreciate any insights that anyone might have.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 25/05/16 03:36 PM
Hi Ashryu,

Can you attach the original and modified .DAE files so I can examine them?
Posted By: Ashryu Re: Editing GR2 meshes finally possible - 25/05/16 10:04 PM
After messing around some more I got the process to work with freshly extracted .GR2 files. The reason this one in particular isn't working with blender has to have something to do with me getting it off of the Divinity Nexus. Thanks for the reply though.

Also, thank you very much for writing these tools!
Posted By: NewEco Re: Editing GR2 meshes finally possible - 02/06/16 05:40 PM
Actually I am not using it for DOS. I am playing around with the models of EVE Online. There is an .gr2 Exporter existing for this game (called Tri-Exporter). The issue is that it seems not being able to handle multiple UV maps in granny files it just exports data for just one, while there is no doubt there must be several within the file based on the texture maps that are used.

So I was sooooo happy when I saw that there is an exporter out there that seems to be more capable .... but unfortunately yours cant handle the compression. :-/
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 02/06/16 10:03 PM
Can you upload a few compressed samples somewhere and I'll see what I can do about the compression and UVs.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 25/06/16 06:57 PM
Updated the tool to v1.6.1!
Available here: https://s3.eu-central-1.amazonaws.com/nb-stor/dos/ExportTool-v1.7.2.zip

Changes:
- Add support for half-float UV formats
- Support multiple UV sets (currently up to 2)
- Add support for compressed GR2 files*

* you need to copy granny2.dll to the exporters' directory to do this, as redistributing that file violates the RAD game tools license
Posted By: volne Re: Editing GR2 meshes finally possible - 17/07/16 07:45 PM
Always getting same error trying to convert .dae-.gr2
"System.ArgumentException: Class doesn't have a vertex format descriptor"
...

tried exporting .dae from max, maya and blender always getting same result. any help?
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 18/07/16 05:27 AM
Oops, seems to be an oversight in the tangent computation code.
Should be fixed in v1.6.2:
https://s3.eu-central-1.amazonaws.com/nb-stor/dos/ExportTool-v1.7.2.zip
Posted By: volne Re: Editing GR2 meshes finally possible - 18/07/16 08:38 AM
nice, works fine. thanks!
Posted By: TheBigMan Re: Editing GR2 meshes finally possible - 12/09/16 11:00 PM
Trying to conform back into the gr2 and i get this message.

Export failed!

failed to conform skeleton:
No matching mesh found in source file for mesh 'CP_M_Body_AMesh'.
Check bone counts and ordering.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 14/09/16 04:40 PM
Hi,

Which GR2 did you export to DAE, and which did you select for the conform option? Is it CP_M_Body_AMesh for both?
In that case, make sure that your exporter tool exports the mesh using the same name as the original imported name; otherwise it may fail to find the correct mesh.
Posted By: TheBigMan Re: Editing GR2 meshes finally possible - 06/10/16 10:41 PM
Sorry I figured out what I was doing wrong. I dont know what conforming to the original mesh is for but it appears it is not neccessary. I do however not understand why some of the meshes refuse to be changeable. I do everything correctly without error and yet for some reason some meshes just dont seem to be loading the loose files so it is impossible to alter them. They just ignore the modified files and load the default ones. It is strange. I have noticed the orcs as well as the wooden shield and metal shield so far. Any idea about this?
Posted By: vometia Re: Editing GR2 meshes finally possible - 09/10/16 03:20 PM
I've been using this a bit to experiment with whatever's packaged in D:OS II and I'm really rather impressed with the scope of what it can do. So far I've extracted the PAKs, and even converted a mesh to get it into Blender and then back into the game.

It mostly works (er, by which I mean "I can mostly work it") but the one thing I can't get to work is UV maps: somewhere in between converting the mesh to Collada format and then slurping it into Blender (v2.75) the UV is going missing. I suspect it's something I'm doing wrong, especially as 2.75 is a bit of an unknown to me: as much as I hate 2.49's interface, I've resisted changing to something new until I've basically been forced to do so. biggrin Granny Viewer shows that the UV is there in the original GR2 so I figure I'm using the wrong options somewhere along the line.

For the record, Granny Viewer can't read the newly created GR2, though that's probably because I'm using a really ancient version that appears to be dated 2008.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 09/10/16 06:49 PM
Originally Posted by vometia
somewhere in between converting the mesh to Collada format and then slurping it into Blender (v2.75) the UV is going missing


The default Collada importer in v2.77 displays UVs just fine for me.

Originally Posted by vometia
Granny Viewer can't read the newly created GR2, though that's probably because I'm using a really ancient version that appears to be dated 2008


Not even the v2.8.49.0 (the version D:OS 2 uses) Granny Viewer can open them. It appears that the D:OS EE and D:OS 2 GR2 files use a different header signature that the Viewer doesn't recognize.
A workaround is to save them in the (old) D:OS format.
Posted By: vometia Re: Editing GR2 meshes finally possible - 09/10/16 07:53 PM
I'll give v2.77 a try, then! But I'll give it a try tomorrow when I'm slightly more awake: I feel like I should have my wits about me (such as they are) when I do anything with Blender. In the meantime, are there any tickboxes in the export pane I should tamper with, or are the default values reasonable enough to keep my meddling hands well away?

I should also maybe add that I'm not doing any serious remeshing or planning anything especially ambitious, I'm mostly just curious to see what's possible.
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 09/10/16 09:34 PM
No, the default options are OK for both import and export (at least in 2.77)
Posted By: vometia Re: Editing GR2 meshes finally possible - 10/10/16 09:59 AM
A bit of experimentation later (and a quick upgrade to 2.78... which promptly ate all my settings. Bah.) and the EE GR2 files' UVs are loading fine (although I had to invert the Y-axis of at least one of them), but the D:OS II ones seem to be missing them. I admit it may be just a little unreasonable of me to expect everything to just magically work at such an early stage so just put it down to my curiosity getting the better of me! smile
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 10/10/16 03:11 PM
Hrm, which D:OS 2 files are we talking about specifically? I checked a few character body parts and the UVs seemed fine.
Posted By: vometia Re: Editing GR2 meshes finally possible - 10/10/16 05:17 PM
One example is Humans_Female_Armor_Mage_B_Lowerbody_A.GR2, though none of those I've tried seem to have UVs. I think I'm currently using the latest version of the exporter, so that shouldn't be the problem, though I certainly won't rule out the possibility that I'm doing something wrong. That said, the D:OS EE GR2s I've imported do seem to have their UVs in place.

As I mentioned, at this point it's just a curiosity thing: ideally what I'd like to do is what Larian will do in due course which is to fill in the waist gap present in that mesh, but I have absolutely no idea at all how I'd go about adding weights to new vertices (okay, I know how to do weight-painting in Blender v2.49, but I'm very bad at it).
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 10/10/16 05:58 PM
Can you try this version?
https://s3.eu-central-1.amazonaws.com/nb-stor/dos/ExportTool/ExportTool-latest.zip
Posted By: vometia Re: Editing GR2 meshes finally possible - 10/10/16 06:48 PM
That works better, but in multipart meshes it's only importing some of the UV's, such as with Humans_Female_Armor_Mage_B_Lowerbody_A.GR2; same with a couple of others that I looked at. I'm not sure if it's failing to import the last mesh or if it's something to do with it being a skin texture. The UVs are also being inverted and slightly offset on the Y-axis too.

I'm still not ruling out that it's something I'm doing. If there's a wrong way of doing it, I'll find it.
Posted By: vometia Re: Editing GR2 meshes finally possible - 10/10/16 09:48 PM
I think I've spotted the problem with the missing UVs: the one thing they seem to have in common is very, very long object names which Blender is truncating. I'm not sure if there's really much that can be done about that, unless the exporter can check for excessively long strings and rename them, though I guess that would probably be inviting other problems elsewhere...
Posted By: vometia Re: Editing GR2 meshes finally possible - 11/10/16 09:15 AM
Figured out a temporary work-around upon discovering that DAE files are plantext so "yay I can use vi to do my 3D modelling!" or rather I can edit it to temporarily rename the UV name to something shorter. So that now works. Also my complaining about the inverted UV map looks to be a bit of a red herring in practice as, although the image is upside-down in Blender, it effectively reinverts it on output so it looks fine in game. It just makes editing a bit fiddly.

One thing that continues to confound me is that the mesh is no longer coming out smooth once Blender's had its hands on it: it looks like I've done a "faces->set solid" and no amount of attempting to get smooth outlines (set smooth, auto smooth, convert to quads etc) will make any difference. A bit of Googling suggests this is likely a problem with Blender's export function so I'm not sure if there's anything the Exporter can do about it, but if there's any suggestions... Edit: actually, remove doubles fixed it. Probably obvious to everyone else, so everyone else is welcome to lol at the noob. biggrin
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 11/10/16 04:02 PM
Originally Posted by vometia
I think I've spotted the problem with the missing UVs: the one thing they seem to have in common is very, very long object names which Blender is truncating.


Blender has a name length limit of 63 chars (which is looow), so a rename is probably needed.
Some of them can be renamed, however the Model/Bone names cannot be changed as they must use exactly the same as the original file; otherwise D:OS won't load them.

Originally Posted by vometia
Also my complaining about the inverted UV map looks to be a bit of a red herring in practice as, although the image is upside-down in Blender, it effectively reinverts it on output so it looks fine in game. It just makes editing a bit fiddly.


Yeah, that seems to be a Blender-specific thing, as I'm exporting the UV values 1:1 as they are in the GR2 file.

Originally Posted by vometia
One thing that continues to confound me is that the mesh is no longer coming out smooth once Blender's had its hands on it: it looks like I've done a "faces->set solid" and no amount of attempting to get smooth outlines (set smooth, auto smooth, convert to quads etc) will make any difference. A bit of Googling suggests this is likely a problem with Blender's export function so I'm not sure if there's anything the Exporter can do about it, but if there's any suggestions... Edit: actually, remove doubles fixed it. Probably obvious to everyone else, so everyone else is welcome to lol at the noob. biggrin


GR2 doesn't support stuff like smoothing groups or co., so this only causes problems in practice if vertices are duplicated in the output file.
Posted By: vometia Re: Editing GR2 meshes finally possible - 11/10/16 05:20 PM
I know where I'm at now then: which is that the Exporter is doing exactly as intended and Blender has a couple of quirks to work around, which is as things always were! But it's definitely workable: inverting a temporary dds and putting it in a more convenient directory isn't a major chore and using a text editor to substitute to and from a temporary string isn't a deal-breaker.

So I find that at alpha stage, I can extract meshes, edit them, add and remove bits, re-weigh them, re-import them and have them appear correctly in game. I am seriously rather impressed and if I were currently wearing my hat I would take it off to you. But sadly, the cat has been sleeping on it. Consider me hatless anyway.
Posted By: Pesmontis Re: Editing GR2 meshes finally possible - 18/05/17 12:56 PM
Investigating gr2 files from Sacred 2 (v2.7.0.30) lead me to believe that I can't see all ExtendedData in GrannyViewer. Specifically user defined structures. I don't have the structure definition of that data, and I thought maybe you can help out a little. Thanks in advance :-)

(example gr2 sent by PM)
Posted By: vometia Re: Editing GR2 meshes finally possible - 18/05/17 03:56 PM
I could never get Sacred 2's GR2 files to do anything interesting: it seems they need a utility to convert them to and from an application like Blender or whatever. Though I admit I haven't actually attempted to use this particular approach on them, which may or may not bear some fruit: for example, I used Oblivion's usual modding tools to edit Ego Draconis' models and textures, though it did require quite a lot of additional faffing about to get them to work.
Posted By: Pesmontis Re: Editing GR2 meshes finally possible - 18/05/17 06:51 PM
grnreader98 v2.1 for Sacred 2 is here:
https://drive.google.com/file/d/0BwXXP3Exg5v4UDVVYnBicnNlYVk/view?usp=sharing
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 18/05/17 08:40 PM
(For the sake of completeness I've added a copy of my PM here as well.)
Hi,

I've implemented my own GR2 reader to make sure that the tool is as free of patents (and as legal) as possible. It currently only requires granny2.dll for Oodle0/Oodle1 (de)compression (which is only used by ~0.5% of Divinity 1/2 assets). It targets Granny version 2.8.49 though, and is not really meant to read customized formats of other games, so it fails to read the example file you provided. I'll check what can be done to make it work.

The code for reading GR2 files is available here:
https://github.com/Norbyte/lslib/tree/master/LSLib/Granny/GR2
Posted By: Pesmontis Re: Editing GR2 meshes finally possible - 19/05/17 10:26 AM
Wow, thanks a lot!
Posted By: Nazar Re: Editing GR2 meshes finally possible - 10/07/17 10:12 AM
If someone can help or know smt about textures & meshes in DOEE: http://larian.com/forums/ubbthreads.php?ubb=showflat&Number=606202#Post606202 please visit this theme
Posted By: eRe4s3r Re: Editing GR2 meshes finally possible - 24/09/17 11:57 AM
So I feel the need to post here the link to the current up-to-date link/topic by Norbyte for the unpacker, since I get asked this now a bit too much for my taste (once, that is ;p)

So you want the latest unpacker, you click on norbyte and find his latest posts (requires you to be logged in here), or you go here

http://larian.com/forums/ubbthreads.php?ubb=showflat&Number=619296
And find the latest link

I can not edit the first post in the topic so this is my fix for this wink When I wrote this I completely forgot that Larian uses the *worst* of the forum software packages available.... oh well wink

In fact, I would kindly request for this topic here to be closed, or even entirely deleted. As it is highly misleading nowadays ;P

Ps.: The reason I bring this up is that this topic comes up first in google. Since I got no clue who moderates here I hope a mod notices this ;P
Posted By: Norbyte Re: Editing GR2 meshes finally possible - 24/09/17 03:07 PM
Also, since old (and possibly broken) versions are being linked to all the time I've added a "latest" URL that links to the latest stable version:
https://s3.eu-central-1.amazonaws.com/nb-stor/dos/ExportTool/ExportTool-latest.zip

I've tried to update my posts to reflect this change, but only posts in the last ~1 year or so could be modified.
Posted By: vometia Re: Editing GR2 meshes finally possible - 29/09/17 08:39 PM
Originally Posted by eRe4s3r
In fact, I would kindly request for this topic here to be closed, or even entirely deleted. As it is highly misleading nowadays ;P

Ps.: The reason I bring this up is that this topic comes up first in google. Since I got no clue who moderates here I hope a mod notices this ;P

Argh, sorry it's taken me almost a week to notice! Locked as requested; PM me if you need anything else (er, I mean other than a forum upgrade, I can't quite manage that. biggrin )
© Larian Studios forums