www.tombraiderforums.com

www.tombraiderforums.com (https://www.tombraiderforums.com/index.php)
-   Software Development (https://www.tombraiderforums.com/forumdisplay.php?f=55)
-   -   New Blender addon to import wad objects and animation (https://www.tombraiderforums.com/showthread.php?t=225479)

Bergus 23-12-20 17:07

New Blender addon to import wad objects and animation
 
Hi guys,
this is a Blender addon that I'm using to export Lara animations in FBX format so that I can import them into Unity. It may be useful also for other stuff, so I'm sharing the code.

I didn't test it very well, so I need some feedback. Maybe I can implement more features if they do not require too much time. Here is the github link where you can download the addon:

https://github.com/veeti512/wadblender

and here is a small video to show how to display the animations if you are not used to Blender:

https://www.youtube.com/watch?v=b9EMGA7lkiI

PS: I tested it on Blender 2.9

VictorXD 23-12-20 21:28

This is amazing! thank you so much for this :jmp:

turneraider 23-12-20 21:35

I've been looking for something like this! Thank you so much!! :D

not again! 06-01-21 03:01

https://i.imgur.com/IYr2nDU.gif ... I don't know how I missed this thread but this is incredible news! I'm speechless. You just made all the fiddling with different versions of Blender for importing and the need for at least two different MQO plugins obsolete. Not even going to mention the problems of getting the original animations into Blender.
I need a few moments to process this. A million thanks, this is amazing! :hug: :D

not again! 07-01-21 19:09

Thank you again for this awesome addon, it works great!
There has been one small inconvenience that I have encountered so far that I wanted to ask about: the textures show up fine in Blender but when exporting as OBJ the texture.png does not get written into the .mtl file. I have to re-assign/reload the texture manually in Blender for it to get added to the mtl.

I realize the addon was optimized for fbx, it's just that for Tomb Editor the .obj file format works best when a model is supposed to have shininess.
Re-assigning the texture is a small extra step and nothing to complain about, just thought I mention in case it's something that can be fixed easily.

edit: after spending a bit more time importing and exporting things, I think having to reassign textures is perfectly fine. It's probably best to manually rename the automatically created texture.png and give it a custom name so the texture doesn't get accidentally overwritten when exporting several models into the same folder and then you have to reassign textures in any case, so it's all good the way it is. :)

Bergus 08-01-21 17:55

Thank you guys, I'm glad that the tool is useful!
I see the problem with exporting, sometimes it also happens that the uvmap completely disappear. This update should fix it by re-importing the uvmap image:

https://drive.google.com/file/d/15xd...ew?usp=sharing

If it works I'll update in github, maybe I can also change the texture.png filename with the name of the wad? This should avoid confusion.

By the way, speaking of shine, I was not able to render this effect on blender. I got the data from the wad but I don't know how to apply it to the model since it is applied to each face. Since obj files preserve this information, can you please send me a sample obj file with shine effect so I can see how is it applied?

Bergus 08-01-21 18:12

I was also trying to import mixamo animations to TRLE using tomb editor. The LARA.fbx file generated using the export FBX option seems to be correctly recognized by mixamo.com. I'm able to import the animations back to blender but not in tomb editor :confused: It says "wrong number of bones". Do you guys know any easy way to import them? otherwise I can spend some time and make a script.

not again! 08-01-21 18:58

Thank you once again very much, Bergus! :D
Quote:

Originally Posted by Bergus (Post 8267490)
Since obj files preserve this information, can you please send me a sample obj file with shine effect so I can see how is it applied?

I have uploaded the tr1 cat statue as .obj with shine; blender file is also included just in case. It's the Ns value in the .mtl file which determines the shine of models in game, if that info is of any help.

https://www.mediafire.com/file/afind...tatue.zip/file

Quote:

Originally Posted by Bergus (Post 8267497)
I was also trying to import mixamo animations to TRLE using tomb editor. The LARA.fbx file generated using the export FBX option seems to be correctly recognized by mixamo.com. I'm able to import the animations back to blender but not in tomb editor :confused: It says "wrong number of bones". Do you guys know any easy way to import them? otherwise I can spend some time and make a script.

The naming of the meshes and bones is important. I had not noticed yet, but just went to check and it's hopefully just the naming which causes the issue.
Lwmte explained it here (I bolded the important bit):

Quote:

Originally Posted by Lwmte (Post 8154833)
Thanks! I have checked your files, and there are problems with both of them.

Ones called "unmodified_ms3d_export" don't have meshes at all (or more specifically, there's one dummy mesh), i.e. only animations are exported, not actual model. WT requires exported animation to have exported model as well to reference meshes from bone animations.

Ones called "parts_separated_and_renamed" for some reason have different names for bones and meshes. Bones are called "bone_n" while meshes are called "mesh_n". How come that you have separate bones and meshes in your animation files? Those should be basically the same. If for some reason you have actual meshes and anim bones stored separately, you may try to rename bones "bone_n" to "mesh_n_anim". Generally, any bone which is storing anim information should have a part in its name which corresponds to target mesh name. Then animation will import correctly.

So basically the meshes should be numbered from mesh_00 to mesh mesh_14, and their corresponding bones need to have the same name but with _anim appended:

00 - pelvis
01 - left thigh
02 - left shin
03 - left foot
04 - right thigh
05 - right shin
06 - right foot
07 - torso
08 - right upper arm
09 - right lower arm
10 - right hand
11 - left upper arm
12 - left lower arm
13 - left hand
14 - head

edit: on further thought I probably should have linked the entire discussion for context and not just the quote by Lwmte; it's from the WadTool thread:
https://www.tombraiderforums.com/sho...=223525&page=5

edit 2: additional info (from the same discussion)

Quote:

Originally Posted by Lwmte (Post 8155048)
The problem is, since TR originally uses tree-based animation system with ugly push/pop operations, there's no way to clearly predict order of bones without referencing meshes. Usually it imports ok if you haven't messed with meshtree, but the chance to mess things up is still really big. So, as additional safety check, WT checks bone names against mesh names, and additionally checks if amount of bones is similar to amount of meshes. This way it can clearly predict if original TR animation integrity is broken or not.
[...]
as long as bone names are "synced" with mesh names (meaning - every bone name should contain full name of corresponding mesh name), you're good to go.


Richard_trle 08-01-21 23:58

I'm sorry, but if we export into fbx, can we import back using wadtool? or what? what am I missing?

not again! 09-01-21 08:02

^^ Yes, with this addon you can import objects and animations from a Wad into Blender, edit them and then re-import into your Wad using WadTool (importing animations into the Wad / WadTool is being worked on as mentioned above).

edit:

Quote:

Originally Posted by Bergus (Post 8267490)
This update should fix it by re-importing the uvmap image

Just got around to trying it and now it works like a charm! Thank you so much! :D

Quote:

Originally Posted by Bergus (Post 8267490)
maybe I can also change the texture.png filename with the name of the wad? This should avoid confusion.

This sounds like an ideal solution me.

Bergus 09-01-21 14:28

Thanks not Again!
It seems to me that the shine is stored using different materials. Since the same texture can be applied with multiple shine values to different faces of the same mesh, it is like having 32 different materials that differ only by some glossy parameter.

I'll see how to manage that. I think that applying different materials to different faces is quite painful to the object designer, I would rather have some friendly way to edit this property.

EDIT: I think it is the only way: when you open the wad, blender creates 32 materials with the the same uvs but different shine values. If some face needs shine, the proper material is applied.

Zebra 09-01-21 15:27

Quote:

Originally Posted by Bergus (Post 8267674)
Thanks not Again!
It seems to me that the shine is stored using different materials. Since the same texture can be applied with multiple shine values to different faces of the same mesh, it is like having 32 different materials that differ only by some glossy parameter.

I'll see how to manage that. I think that applying different materials to different faces is quite painful to the object designer, I would rather have some friendly way to edit this property.

EDIT: I think it is the only way: when you open the wad, blender creates 32 materials with the the same uvs but different shine values. If some face needs shine, the proper material is applied.

Could you maybe use something like weights, vertex groups or vertex colours to store shine value variations? That would make them easy to edit and I believe vertex colours should also straightforward to integrate into materials so you could preview it properly in Blender without needing a bunch of materials.

not again! 09-01-21 16:05

Ah, apologies, I think I worded my initial comment about OBJ being best for shininess confusingly. What I meant was that the Blender export script for OBJ is so far the only one that exports the new Principled BSDF shader in way that will give a model imported into WadTool glossiness.
Models exported as FBX or COLLADA appear matte in game no matter what shader settings are used. So basically if you want to have a model exported from Blender to have glossiness ingame you need to export as OBJ.
Personally I don't find it a problem if the shine attribute is not imported from the Wad, since it can be re-applied in Blender.

Bergus 09-01-21 18:24

Quote:

Originally Posted by Zebra (Post 8267685)
Could you maybe use something like weights, vertex groups or vertex colours to store shine value variations? That would make them easy to edit and I believe vertex colours should also straightforward to integrate into materials so you could preview it properly in Blender without needing a bunch of materials.

I used vertex color to define the light map of statics objects since it is based on vertices. However, movables shine is applied to each polygon, and if you set the shine as vertex weights, the face would take the average of the vertex weights around it.

I'm thinking of adding a simple entry in the panel that you get pressing N, where you can select the shine when faces are selected. In this way there's no need for the user to mess with materials.

Quote:

Originally Posted by not again! (Post 8267692)
Ah, apologies, I think I worded my initial comment about OBJ being best for shininess confusingly. What I meant was that the Blender export script for OBJ is so far the only one that exports the new Principled BSDF shader in way that will give a model imported into WadTool glossiness.
Models exported as FBX or COLLADA appear matte in game no matter what shader settings are used. So basically if you want to have a model exported from Blender to have glossiness ingame you need to export as OBJ.
Personally I don't find it a problem if the shine attribute is not imported from the Wad, since it can be re-applied in Blender.

Don't worry :) I just forgot about shine and wanted to figure out how to import it. Unfortunately TRLE is old, otherwise the correct way would be to make another image that maps the glossiness and assign it to the shader.

not again! 10-01-21 08:59

^^ Oh, good - I'm relieved to hear I did not accidentally waste your time.

Some more feedback and a potential bug report: the option to batch export models is truly a wild luxury after being used to the old time consuming workflows! :p
Batch exporting Statics seems buggy on my end though: a FBX file for each static object is created, but the files all have 4kb and are seemingly empty when trying to import them into Blender. Everything else (Lara and Moveables) exports fine, I tested with several of the original Core wads.

Bergus 10-01-21 17:53

Quote:

Originally Posted by not again! (Post 8267857)
^^ Oh, good - I'm relieved to hear I did not accidentally waste your time.

Some more feedback and a potential bug report: the option to batch export models is truly a wild luxury after being used to the old time consuming workflows! :p
Batch exporting Statics seems buggy on my end though: a FBX file for each static object is created, but the files all have 4kb and are seemingly empty when trying to import them into Blender. Everything else (Lara and Moveables) exports fine, I tested with several of the original Core wads.

Thanks, I'll look into it!
I almost finished with the shine. I wanted to ask, if you know, whether tomb editor is also able to import opacity/transparency. I think that the way to do in blender is to use the bsdf shader alpha parameter. For the shine I'm using the roughness (shine = 0 => roughness = max).

not again! 10-01-21 21:49

Yes, it's possible to import models into Tomb Editor / WadTool with transparency. Vertex colors also import fine into WadTool & Tomb Editor when the model is in either .fbx or .dae* file format.
Both transparency and shine work exactly as you described: by adjusting the Alpha and the Roughness slider of the BSDF shader.

Though as mentioned the Roughness value of the BSDF shader only carries over into the game as shininess when exporting as .obj
When exporting as .fbx (or .dae) the export scripts for those file formats apparently interpret the Roughness setting in a way that doesn't translate into in-game glossiness. None of the BSDF shader sliders that control specularity, sheen and reflectiveness have any effect in game when exporting as anything other than .obj
Transparency on the other hand does work with all three file formats.


* from the file formats that Blender can export without additional plugins OBJ, FBX and COLLADA are the three best supported for import into WadTool / Tomb Editor.

And thank you again for your amazing work! :)

Bergus 11-01-21 19:28

There is a new release (0.2) on Github :jmp:

You can now import shine and opacity information. To edit their values, you need to go into edit mode and it will appear a Wad Blender tab into the panel that you get by pressing N. By selecting a face of the active mesh, it will appear a form where you can edit shine (0-31) and opacity (ON OFF).

There is also the possibility to batch export in obj format plus probably many bugs. When I'm sure that everything works, I'll make some tutorials, maybe :D

not again! 12-01-21 05:26

This keeps getting better and better, and it was already amazing to begin with! :D
Export of statics works now perfectly on my end and I'm a big fan of the way applying shine and transparency has been integrated into the addon. Many thanks for adding the option to batch export to OBJ as well!
Having the option to adjust rotation on import is also greatly appreciated. One thing I noticed is that Moveables without rig (like inventory items and puzzle pieces) are not affected by the rotation-transform though when ticking "rotate objects upright".
Again, not really a problem since objects can easily be rotated manually - just mentioning in case that's the sort of thing you'd like people to report.
I think having the option "rotate upright" ticked by default is probably going to be more convenient - I suspect that it's going to be used way more often than it's not going to be used.
Thank you for this great update!

Bergus 12-01-21 08:04

Thanks for the feedback, please report everything! The code is fresh and I can correct it very easily. Later will be hard because coding for Blender is quite nasty :hea:

jhons0529 12-01-21 12:22

Nice work! :tmb:
This seems like a life saver in many ways!

Bergus 13-01-21 18:22

Coming soon a script to export blender animations as Wad Tool anim files. Here is a Adobe Mixamo animation:


piano_raider 13-01-21 19:29

Unbelievable! :cln:
Itīs time for me to learn animation :D

Ruu11 13-01-21 19:51

WAIT, so it could be possible to import animations from other games to TRLE?????? :eek:

not again! 13-01-21 20:59

This is such incredibly amazing news, I don't even know what to say! :D :jmp:

Craig Michaels 14-01-21 10:50

Quote:

Originally Posted by Bergus (Post 8269061)
Coming soon a script to export blender animations as Wad Tool anim files. Here is a Adobe Mixamo animation:

That is quite the stand idle animation there! I have never made a custom animation before, and I'm eager to learn how now!

Bergus 16-01-21 05:52

0.3b is out, please check the github page!
There are some problems with Lara feet animations. Probably it's because Lara has only one bone for each foot instead of two. However, they can be edited using blender's graph editor.

You can also combine multiple animations using the the blender nla editor. This may be useful to create cutscenes, see this video for an example: https://youtu.be/NIP8QibQ7XU
Wad blender will export the active action associated with the LARA_RIG. Note that the hips location and rotation datapath is "Location" and "Rotation Euler".

not again! 16-01-21 13:05

A million thanks for the update Bergus, I can't wait to try it out! :admles:

LeelooBastet 16-01-21 21:11

Sorry i didnt find the information
Is Wadblender a wad or a wad2 importer ?
Does the addon work with Blender 2.83 ?

Bergus 17-01-21 04:23

Quote:

Originally Posted by LeelooBastet (Post 8270025)
Sorry i didnt find the information
Is Wadblender a wad or a wad2 importer ?
Does the addon work with Blender 2.83 ?

It is an importer for the old wad format. At this moment I tested only on 2.9, it may misbehave on 2.8. Also be aware that it is still under development, now that I implemented all the features, I will take care of details.

not again! 17-01-21 13:45

Really fantastic work, Bergus. :tiphat: I'm having tons of fun going through animations on Mixamo, laughing at Lara clumsily dancing Rumba. Thank you again for this wonderful addon.



I also tried exporting both an original animation and a new animation I quickly made in Blender to .anim format, but both arrived as mangled mess when trying to import them into WadTool. I don't really know what I'm doing though (I'm just a beginner at making animations), and I was wondering if the export to .anim file format is for Mixamo animations only?

Bergus 17-01-21 14:44

Ops, sorry, I didn't specify it. I tested the anim export only with Mixamo animations! I think that TRLE animations get wrong because Mixamo rotations are imported as quaternions while TRLE animations are yaw pitch roll. I will add an option for that :hea:

Maybe if you start from the file you downloaded from Mixamo, delete the keyframes and then make your own from scratch it would work. Maybe... but better that I add the option, it should be few lines of code.


BTW Lara dancing is so funny, but a smile in her face would make it more believable :D

Edit: I was bored and coded a little, but didn't want to remake the tutorial, so at this moment I share here the update:

https://drive.google.com/file/d/15xd...ew?usp=sharing

I added a mixamo option, also now Lara should be facing correctly

not again! 17-01-21 16:35

Quote:

Originally Posted by Bergus (Post 8270197)
the update:

.. that was fast. Thank you once again so much! :D

I completely missed that there are tutorials. Thank you for those as well - I'll put the links in the first post of the Blender workflow thread.
I see you used the Thriller dance animation for the tutorial - truly the best choice.

not again! 18-01-21 12:58

Re-importing the original animations works splendidly now. :D
I have big hopes that this will make it possible to easily fix the old issue of Lara's joints collapsing during some of the original animations.

A question regarding making completely new animations, since you mentioned Mixamo animations use quaternion and classic TR use yaw pitch roll and you addon now lets us export animations with both types of rotation to the .anim file format: it is okay to use quaternions (which is superior to roll pitch yaw) when making new animations - do I have that correctly?
For exporting to .anim we can then use the Mixamo setting (since that is for animations using quaternion rotation)?

Bergus 18-01-21 17:23

I know that quaternions are better since they avoid gimbal lock problems while animating. However, I'm not sure whether the final conversion into Euler angles (yaw pitch roll) may cause problems. Probably not :confused:

I also need to investigate why the Mixamo pelvis bone is in Euler angles instead of quaternions :confused:

not again! 18-01-21 17:50

I did not mention that quaternion is better because I assumed you do not know that (that would be absurd given your knowledge about animations :p) - I was just trying to explain why I'm interested in whether we can use quaternion rotation when making new animations.

Bergus 18-01-21 18:35

In reality, I don't know anything about animations! I just wanted to say that I know just that gimbal problem, but I'm not sure whether you will run into it, even with quaternions. Sorry if I sounded nasty :( I just converted the angles so they can be imported/exported from Blender into the TRLE, but I don't know how to do an animation from scratch.

Anyway, the answer is yes, you can choose to create new animation from the RIG that you get from Mixamo and then export using the Mixamo checkbox. It makes sense, I don't know in practice if anything will change.

not again! 18-01-21 19:17

No worries, your comment sounded perfectly friendly and polite! :) I was just worried mine had sounded unintentionally patronizing and wanted to clear that up, sorry for the confusion. :p

Thank you, I'll use the Mixamo rig then.

Bergus 20-01-21 10:27

Probably I'll convert also TRLE animations to quaternions so that they can be mixed with Mixamo anims. I would like also to export non Lara animations if I'm able to discover in what order are the mesh rotation in tomb editor.

not again! 20-01-21 15:39

Quote:

Originally Posted by Bergus (Post 8270934)
Probably I'll convert also TRLE animations to quaternions so that they can be mixed with Mixamo anims.

That sounds amazing! :D
Would animations in FBX format from other sources (for instance ripped from other games) also work as long as they are similar to Mixamo's?

Quote:

Originally Posted by Bergus (Post 8270934)
I would like also to export non Lara animations if I'm able to discover in what order are the mesh rotation in tomb editor.

Lwmte would probably be the person to ask this. As far as I know he implemented the import of animations into WadTool.


I'm trying to modify one of the original animations using the NLA editor, and then baking everything into a new action, but have not managed to import that modified animation into WadTool successfully so far.
If I use the default export setting (for the original animations) then Lara will show up completely mangled and not move at all, but funnily enough if I use the Mixamo settings then she will show up less mangled and move, but with the wrong limbs (instead of the legs performing a running animation the arms will flail around wildly, etc)
But as mentioned, I don't really know what I'm doing here yet - I'm still at the stage of watching YouTube tutorials how to use Blenders various animation editing tools correctly :p


All times are GMT. The time now is 09:35.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.