Jump to content
The Dark Mod Forums

Exporting models from Blender into TDM


chedap
 Share

Recommended Posts

I've committed some initial changes to stop the script from crashing when vertex colour information is present in the mesh, however I have not yet tested that the exported vertex colours are correct. You're welcome to try the latest version and see if it does what you expect.

 

EDIT: The results look fairly reasonable I think; at least this more or less matches what I see in Blender.

 

post-254-0-81081400-1553115294_thumb.png

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

I know that this thread is mostly focused on getting LWO and ASE from Blender, but I don't want to make another thread for this one.

 

I downloaded this https://sourceforge.net/p/blenderbitsbobs/wiki/MD5%20exporter/ and tried to check whether it'd work with Blender 2.80.0 and it didn't. I checked the code block by block in Blender's console, most of which resulted in no errors whatsoever until the menu and registering parts, which throwed up a lot of errors:

 

def menu_func_import_mesh(self, context):
    self.layout.operator(
        ImportMD5Mesh.bl_idname, text="MD5 Mesh (.md5mesh)")
def menu_func_import_anim(self, context):
    self.layout.operator(
        MaybeImportMD5Anim.bl_idname, text="MD5 Animation (.md5anim)")

def menu_func_export_mesh(self, context):
    self.layout.operator(
        MaybeExportMD5Mesh.bl_idname, text="MD5 Mesh (.md5mesh)")
def menu_func_export_anim(self, context):
    self.layout.operator(
        MaybeExportMD5Anim.bl_idname, text="MD5 Animation (.md5anim)")
def menu_func_export_batch(self, context):
    self.layout.operator(
        MaybeExportMD5Batch.bl_idname, text="MD5 (batch export)")

def register():
    bpy.utils.register_module(__name__)
    bpy.types.INFO_MT_file_import.append(menu_func_import_mesh)
    bpy.types.INFO_MT_file_import.append(menu_func_import_anim)
    bpy.types.INFO_MT_file_export.append(menu_func_export_mesh)
    bpy.types.INFO_MT_file_export.append(menu_func_export_anim)
    bpy.types.INFO_MT_file_export.append(menu_func_export_batch)

def unregister():
    bpy.utils.unregister_module(__name__)
    bpy.types.INFO_MT_file_import.remove(menu_func_import_mesh)
    bpy.types.INFO_MT_file_import.remove(menu_func_import_anim)
    bpy.types.INFO_MT_file_export.remove(menu_func_export_mesh)
    bpy.types.INFO_MT_file_export.remove(menu_func_export_anim)
    bpy.types.INFO_MT_file_export.remove(menu_func_export_batch)

if __name__ == "__main__":
    register()

 

 

 

 

 

>>> def menu_func_import_mesh(self, context):
...     self.layout.operator(
...         ImportMD5Mesh.bl_idname, text="MD5 Mesh (.md5mesh)")
... def menu_func_import_anim(self, context):
  File "<blender_console>", line 4
    def menu_func_import_anim(self, context):
      ^
SyntaxError: invalid syntax

>>>     self.layout.operator(
  File "<blender_console>", line 1
    self.layout.operator(
    ^
IndentationError: unexpected indent

>>>         MaybeImportMD5Anim.bl_idname, text="MD5 Animation (.md5anim)")
  File "<blender_console>", line 1
    MaybeImportMD5Anim.bl_idname, text="MD5 Animation (.md5anim)")
    ^
IndentationError: unexpected indent

>>> 
>>> def menu_func_export_mesh(self, context):
...     self.layout.operator(
...         MaybeExportMD5Mesh.bl_idname, text="MD5 Mesh (.md5mesh)")
... def menu_func_export_anim(self, context):
  File "<blender_console>", line 4
    def menu_func_export_anim(self, context):
      ^
SyntaxError: invalid syntax

>>>     self.layout.operator(
  File "<blender_console>", line 1
    self.layout.operator(
    ^
IndentationError: unexpected indent

>>>         MaybeExportMD5Anim.bl_idname, text="MD5 Animation (.md5anim)")
  File "<blender_console>", line 1
    MaybeExportMD5Anim.bl_idname, text="MD5 Animation (.md5anim)")
    ^
IndentationError: unexpected indent

>>> def menu_func_export_batch(self, context):
...     self.layout.operator(
...         MaybeExportMD5Batch.bl_idname, text="MD5 (batch export)")
... 
>>> def register():
...     bpy.utils.register_module(__name__)
...     bpy.types.INFO_MT_file_import.append(menu_func_import_mesh)
...     bpy.types.INFO_MT_file_import.append(menu_func_import_anim)
...     bpy.types.INFO_MT_file_export.append(menu_func_export_mesh)
...     bpy.types.INFO_MT_file_export.append(menu_func_export_anim)
...     bpy.types.INFO_MT_file_export.append(menu_func_export_batch)
... 
>>> def unregister():
...     bpy.utils.unregister_module(__name__)
...     bpy.types.INFO_MT_file_import.remove(menu_func_import_mesh)
...     bpy.types.INFO_MT_file_import.remove(menu_func_import_anim)
...     bpy.types.INFO_MT_file_export.remove(menu_func_export_mesh)
...     bpy.types.INFO_MT_file_export.remove(menu_func_export_anim)
...     bpy.types.INFO_MT_file_export.remove(menu_func_export_batch)
... 
>>> if __name__ == "__main__":
...     register()
...     
Traceback (most recent call last):
  File "<blender_console>", line 2, in <module>
  File "<blender_console>", line 2, in register
AttributeError: module 'bpy.utils' has no attribute 'register_module' 

 

 

I'm not an expert of Blender API (in fact, I passionately hated earlier versions of the software), but I know that it was one of the major changes in 2.80.0 and I wanted to ask if the plugin may work correctly after updating this part.

Edited by Snehk

'What do I care for your suffering?'

Link to comment
Share on other sites

Its more complicated than that. The script will really only work up to version 2.72. If you use it on version 2.79, eveything looks great and the model and animations will go through, but they will actually be corrupted internally. I wasted countless hours trying to make it work before it finally crossed my mind to use an earlier version, because there were no visible errors pointing out the problem. So updating the scripts would probably take a bit more work.

  • Like 2
Link to comment
Share on other sites

  • 2 months later...

I'm happy to update the script for API changes and bring it into my repository along with the LWO and ASE exports, but I don't have any experience with the MD5 animation system so testing it would be somewhat challenging.

 

Probably the most reliable way to do it would be to get hold of an example BLEND file along with the correct exported result (from earlier Blender versions) and then treating this export as canonical test data which the updated script needs to produce. In fact I should do that with the ASE and LWO scripts too, to make it easier to check for future breakages without having to do a full export and manual inspection in game.

Link to comment
Share on other sites

  • 4 weeks later...

Hi OrbWeaver.

Each time I load Blender, for your ASE and LWO addons the console lists a load of warnings about properties that should be annotations. It doesn't say why, just that they should be.

Warning: class <class name> contains a property which should be an annotation!
...
    assign as a type annotation: EXPORT_OT_ase.filter_glob
    assign as a type annotation: EXPORT_OT_ase.filepath
...
    assign as a type annotation: EXPORT_OT_ase.option_scale

Fortunately all that's necessary is to change the = to a : and the console loses a lot of clutter.

  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
On 6/29/2019 at 11:18 PM, R Soul said:

Each time I load Blender, for your ASE and LWO addons the console lists a load of warnings about properties that should be annotations. It doesn't say why, just that they should be.

Thanks, fixed in Git.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...

As far as I remember, the engine drops smoothing information from LWO file and applies automatic determination of smooth groups depending on some hardcoded angle.
So I'm not sure these smoothing settings will help in TDM or Doom 3.

Link to comment
Share on other sites

5 hours ago, stgatilov said:

As far as I remember, the engine drops smoothing information from LWO file and applies automatic determination of smooth groups depending on some hardcoded angle.
So I'm not sure these smoothing settings will help in TDM or Doom 3.

Where can I get LWO exporter for Blender 3.4.x to give it a try ?

Link to comment
Share on other sites

On 1/23/2023 at 7:53 PM, stgatilov said:

As far as I remember, the engine drops smoothing information from LWO file and applies automatic determination of smooth groups depending on some hardcoded angle.
So I'm not sure these smoothing settings will help in TDM or Doom 3.

What?! That is news to me, I use .lwo for all my static models and smoothing imports to idtech4 just fine!

Thou I most say, I don't use Blender for anything but MD5 models and still use old Modo 601, the same tool Seneca Menard a idSoftware artist uses, and also use his custom Modo plugging's, that he made public, exactly to streamline making static models for Doom 3 and Rage.

In modo you can set smoothing angle or edge smoothing (hard or soft edge) and it works in idTech 4, perhaps blender and other tools handle .lwo differently? After all modo was made by the same people that created lightwave 3D, so they literally created the .lwo file system.

 

modoex.gif

modoex2.gif

Link to comment
Share on other sites

On 1/23/2023 at 7:27 PM, motorsep said:

Is there an LWO exporter that works with Blender 3.4.1 ? 

As far as I know the most up-to-date one is the script I maintain (there is a single tdm_export script which supports both ASE and LWO export). However I haven't specifically tested with the latest Blender 3.4 series, so it's possible that it will need an update.

On 1/23/2023 at 7:53 PM, stgatilov said:

As far as I remember, the engine drops smoothing information from LWO file and applies automatic determination of smooth groups depending on some hardcoded angle.
So I'm not sure these smoothing settings will help in TDM or Doom 3.

I believe this information is out of date. The problem of LWO losing smoothing information was caused by the Blender exporter itself ignoring object-specific data and enforcing a hard-coded smoothing angle. This is now fixed in my latest version, although the old behaviour is selectable at the time of export if you don't want to deal with object smooth groups. As far as I can recall, when I was testing this, the smoothing options did take effect in the engine (although I couldn't say whether they were 100% mathematically correct).

  • Like 1
Link to comment
Share on other sites

On 1/26/2023 at 9:55 AM, OrbWeaver said:

I believe this information is out of date. The problem of LWO losing smoothing information was caused by the Blender exporter itself ignoring object-specific data and enforcing a hard-coded smoothing angle.

Well, if I look into the code at https://github.com/stgatilov/darkmod_src/blob/trunk/renderer/Model.cpp#L1101
I see that vertices which are almost equal by positions, texcoords and normals, are merged together.
And the constants which control that are r_slopVertex = 0.01, r_slopTexCoord = 0.001, r_slopNormal = 0.02.

On the other hand, it is probably OK.
It does not break convex or concave edges.
And only on mixed-convexity edges of edges with tangential points smoothing can be enforced near tangential points. But only in cases where it is almost zero anyway.

Link to comment
Share on other sites

Actually I might be confusing two different things.

What the latest LWO exporter fixes is the smoothing angle. Previously this was hard-coded at some weird value slightly less than 90°, but this can now be configured to smooth everything, smooth nothing, or use the Autosmooth Angle setting on the object.

I have no idea if explicit smooth groups are supported, or if this is even a thing in Blender.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share


  • Recent Status Updates

    • snatcher

      TDM Modpack v2.6 released!
      · 0 replies
    • peter_spy

      Perhaps an unpopular opinion: TDM team might benefit from someone with actual QA experience; someone with naturally and professionally developed curiosity, who is interested in how and why things work, how they break At least to me it's kind of mind-boggling how untested some rather important features are (first the absence alert feature for items, now the rope +body carry behavior).
      · 4 replies
    • nbohr1more

      The Dark Mod is hosting an Ask Me Anything thread on the PC Gaming reddit forum:  https://www.reddit.com/r/pcgaming/comments/10nfcwj/hello_we_are_the_international_development_team/
      Feel free to join the discussion there
      · 2 replies
    • stgatilov

      Bumped into an interesting piece of wisdom called Hyrum's Law:
      With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody.
      · 5 replies
    • The Black Arrow

      I love playing The Dark Mod when it's cold in my place. Bonus points when it's a bit (or even very) dark and it's raining, too.
      · 2 replies
×
×
  • Create New...