OBJ support in GZDoom

Handy guides on how to do things, written by users for users.

Moderator: GZDoom Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.

OBJ support in GZDoom

Postby Talon1024 » Tue Sep 04, 2018 11:47 am

If you've seen the recent GZDoom changelog, you'll notice that I've added OBJ model support to GZDoom. However, due to the way GZDoom works, OBJ models for GZDoom are a little bit different than regular OBJ models.

First of all, GZDoom does not load the .mtl files that usually come with .obj models. Instead, GZDoom uses the materials that it has already loaded. So, if you have a material in your OBJ file called STARGR2, GZDoom will use the STARGR2 texture from the Doom/Doom 2 IWAD, instead of the STARGR2 material defined in the .mtl file.

Secondly, you can swap out materials on OBJ models using SurfaceSkin in the model definition file. Each "surface" on an OBJ model corresponds to a "usemtl" statement, so if you use "SurfaceSkin 0 0" in your model definition file, you'll change the texture on the faces below the first "usemtl" statement in the OBJ file, and if you use "SurfaceSkin 0 1" in your model definition file, you'll change the texture on the faces below the second "usemtl" statement. Because of an engine limit, however, you cannot replace any textures after the 32nd "usemtl" statement. If you really want, you can just open the OBJ file in a text editor and change the usemtl statements directly.

Third, some features supported by OBJ have been omitted because I thought they would be unimportant or too hard to add. Parametric surfaces, smooth groups for models without normals (although I am considering adding this feature), (Added as of this commit!) and faces with more than 4 sides fall under this category.

But, with this new feature, you can already load gigantic, highly detailed 3D models, such as levels exported from GZDoom Builder, or this model from Turbosquid (thanks, Rachael!). I've already stress-tested GZDoom's OBJ loader with a model of The Given RC2 MAP01 exported from GZDB, and several other maps from Ancient Aliens and Freedoom. Although OBJ rendering is supported in the software renderers, just bear in mind that the more highly-detailed models may crash the software renderers.
Last edited by Talon1024 on Thu Oct 18, 2018 4:10 am, edited 2 times in total.
Talon1024
 
 
 
Joined: 27 Jun 2016
Github ID: Talon1024
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
Graphics Processor: nVidia with Vulkan support

Re: OBJ support in GZDoom

Postby Reinchard2 » Tue Sep 04, 2018 11:52 am

Wow, that's really great news. Thanks for your work. I'm hope you can add support for smoothing groups some time, it's very important in some cases.
Reinchard2
 
Joined: 21 Sep 2007
Location: Poland - Bytom

Re: OBJ support in GZDoom

Postby Talon1024 » Tue Sep 04, 2018 11:58 am

Well, you can get smooth groups if you include the normals in the OBJ, since smooth groups are only a way to control calculation of vertex normals. However, I'm afraid that if I were to add code that searches for adjacent faces, I would end up increasing loading times too much.
Talon1024
 
 
 
Joined: 27 Jun 2016
Github ID: Talon1024
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
Graphics Processor: nVidia with Vulkan support

Re: OBJ support in GZDoom

Postby Reinchard2 » Tue Sep 04, 2018 1:39 pm

Oh, so smoothing groups works ok, I just don't understand you correctly in your previous post.
Reinchard2
 
Joined: 21 Sep 2007
Location: Poland - Bytom

Re: OBJ support in GZDoom

Postby HAL9000 » Tue Sep 04, 2018 3:30 pm

So, a quick question.... What are the benefits of using OBJ over MD3 file format in GZDoom?
(Except that I don't have to use extra steps to convert OBJ to MD3)

Don't get me wrong, I welcome this addition to the engine.
It's a nice thing that I can use OBJ straight away without converting it to other file formats
User avatar
HAL9000
I'm sorry Dave, I'm afraid I can't do that
 
Joined: 16 Mar 2018
Discord: HAL9000#9378

Re: OBJ support in GZDoom

Postby Talon1024 » Tue Sep 04, 2018 4:14 pm

  • Blender's MD3 export plugins are poorly documented and clunky to use IMO. OBJs are much more convenient, and much easier to change if necessary.
  • OBJs are not bound by the same limits as MD2, MD3, or UE1 models. For example, you can export a model of The Given MAP01 from GZDoom Builder and use it in GZDoom. With OBJ support, GZDoom has come full circle in that regard.
Talon1024
 
 
 
Joined: 27 Jun 2016
Github ID: Talon1024
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
Graphics Processor: nVidia with Vulkan support

Re: OBJ support in GZDoom

Postby Reinchard2 » Wed Sep 05, 2018 6:36 am

Is automatic polygonal collision detection possible in near future? Or is it still one of engine limitations?
Reinchard2
 
Joined: 21 Sep 2007
Location: Poland - Bytom

Re: OBJ support in GZDoom

Postby Nash » Wed Sep 05, 2018 6:44 am

How to embed texture paths into each mesh group? This is still unclear. MD3 let you use full texture path names ("models/my character/head 01.png") per object/mesh group/surface/whatever you call it.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: OBJ support in GZDoom

Postby Talon1024 » Wed Sep 05, 2018 7:10 am

Nash wrote:How to embed texture paths into each mesh group?

Code: Select allExpand view
usemtl "models/my character/head 01.png"

You won't need quotes if you remove the spaces or replace them with underscores, BTW.

Reinchard2 wrote:Is automatic polygonal collision detection possible in near future? Or is it still one of engine limitations?

ZZYZX did just that with ZScript.
Talon1024
 
 
 
Joined: 27 Jun 2016
Github ID: Talon1024
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
Graphics Processor: nVidia with Vulkan support

Re: OBJ support in GZDoom

Postby Trusty McLegit » Mon Oct 15, 2018 2:59 pm

Talon1024 wrote:
  • OBJs are not bound by the same limits as MD2, MD3, or UE1 models. For example, you can export a model of The Given MAP01 from GZDoom Builder and use it in GZDoom. With OBJ support, GZDoom has come full circle in that regard.

Wait, what??? You can export an .Obj of a map and use it AS a map? Or do you just mean you could use a 3d model of a doom map as a decoration or something? Because if you mean the first one, that would imply collision detection out of the box right? And if you meant the latter, than what would hold you back from exporting the map as an .obj, converting that to an md3, and using that as a decoration? Slightly confused as to what you meant here :P

Also, not very familiar with .obj in general. Can you still animate with OBJ models, or is it just for static models? Or would you need to have a separate obj for each frame?

Finally, hope I'm not asking too much, but could you provide a simple example wad so I can get a clearer understanding of how to use them? I didn't really follow what you wrote in the OP, and it would be easier to simply see it in action
User avatar
Trusty McLegit
 
Joined: 07 Feb 2016

Re: OBJ support in GZDoom

Postby Caligari87 » Mon Oct 15, 2018 5:25 pm

Trusty McLegit wrote:
Talon1024 wrote:
  • OBJs are not bound by the same limits as MD2, MD3, or UE1 models. For example, you can export a model of The Given MAP01 from GZDoom Builder and use it in GZDoom. With OBJ support, GZDoom has come full circle in that regard.

Wait, what??? You can export an .Obj of a map and use it AS a map? Or do you just mean you could use a 3d model of a doom map as a decoration or something? Because if you mean the first one, that would imply collision detection out of the box right? And if you meant the latter, than what would hold you back from exporting the map as an .obj, converting that to an md3, and using that as a decoration? Slightly confused as to what you meant here :P
You can use an OBJ as a "map" in GZDoom, but it will not have collision support. You'd still need to build a "skeleton" level for the player to walk and move in, but the visible geometry could be a single OBJ model with much more detail than can be achieved with linedefs/sectors.

Trusty McLegit wrote:Also, not very familiar with .obj in general. Can you still animate with OBJ models, or is it just for static models? Or would you need to have a separate obj for each frame?
OBJ does not support animations, to my knowledge, you're better off using MD3 for that. OBJ is better for static decorations.

8-)
User avatar
Caligari87
I'm just here for the community
User Accounts Assistant
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA
Discord: Caligari87#3089

Re: OBJ support in GZDoom

Postby Trusty McLegit » Mon Oct 15, 2018 6:58 pm

Ohhhhh okay, that makes sense. This is something you couldn't do with MD3?
User avatar
Trusty McLegit
 
Joined: 07 Feb 2016

Re: OBJ support in GZDoom

Postby Steve5563 » Thu Feb 28, 2019 7:29 pm

hi there, quick question. i am trying to export a very basic map as the .obj file and then import the same exact same file ( map ) back into gzdoom builder using the "wavefront obj as terrain" so i can open the level back up in gzdoom builder and then save the map as a .wad file. but its coming up with a error saying "only triangular faces are supported".
am i doing something wrong here as its my first time using this feature or doing anything with 3d model / files.
i am wanting to modify some textures in a 3d program with out altering the maps geometry in anyway. can this be fixed or a feature added to gzdoom builder, exporting the map as a .obj file and then importing the file back into gzdoom builder as a map and saving it as a .wad file? cheers
User avatar
Steve5563
 
Joined: 27 Jan 2019
Location: Australia

Re: OBJ support in GZDoom

Postby Kappes Buur » Sun Mar 03, 2019 3:43 pm

Request :D :

Could somebody make a step by step tutorial about using wavefront obj for GZDOOM.
How to export from GZDoom, manipulate with Blender and import back into GZDoom.
Something like OBJ for Dummies.

moved to viewtopic.php?f=39&t=63858
Last edited by Kappes Buur on Sun Mar 03, 2019 6:51 pm, edited 1 time in total.
User avatar
Kappes Buur
 
 
 
Joined: 17 Jul 2003
Location: British Columbia Canada

Re: OBJ support in GZDoom

Postby Arctangent » Sun Mar 03, 2019 3:47 pm

Trusty McLegit wrote:Ohhhhh okay, that makes sense. This is something you couldn't do with MD3?

I'm pretty sure you could make an MD3 of a map, but the MD3 format has hard limits on various aspects of the model and thus any map past a certain complexity would be a complete no-go.
User avatar
Arctangent
squawky
 
Joined: 06 Nov 2014
Discord: SquawkyAtan#2371


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests