by Talon1024 » Tue Sep 04, 2018 10: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.
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 [url=https://zdoom.org/wiki/MODELDEF]model definition[/url] 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, [s]smooth groups for models without normals (although I am considering adding this feature),[/s] (Added as of [url=http://github.com/coelckers/gzdoom/commit/d4a64284ea3846330943c39434b171ecfd2b49bf]this commit[/url]!) 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 [url=https://www.turbosquid.com/FullPreview/Index.cfm/ID/1093267]this model[/url] 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.