October 04, 2024, 22:40:12

Author Topic: [Tool] Model Converter  (Read 26498 times)

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
[Tool] Model Converter
« on: December 29, 2010, 02:10:51 »
Ok, this one is kind of a hackjob. This little converter converts Nexus .msh models to .obj files, which you should be able to import in most 3d content creation apps such as Lightwave, Blender, 3D Studio, etc.

Capabilities:
- command-line utility
- converts (most) .msh models to Wavefront's obj-format
- also generates a corresponding .mtl file with material and texture definitions
- can convert multiple models at once (just drag and drop multiple files or folders)

Requirements:
- .NET Framework 4 (Client Profile)

How to use:
- extract the MeshConv.exe somewhere and drag some files or folders onto it using Windows Explorer (or similar programs)
- the converter will create a subfolder "meshes" storing all converted model files
- it'll scan subfolders and preserve the folder structure
- you can also use it as a strict command line tool, just enter "MeshConv <path> [-o <outputFolder>]"

Limitations:
- doesn't convert textures, use my Texture Converter for that and place them in an "images"-subfolder next to your converted models
- only converts the highest detail level of the model and ignores less-detailed LOD phases
- doesn't convert animations, obj-files don't support animations
- might also generate some additional polygons, because obj-files don't support instancing
- doesn't convert weapon hardpoints, engine thrusters, position lights, etc - only the 3d model is converted

Nexus itself includes two models in a slightly different file format I didn't research yet, so these can't be converted. They are:
  • alien_locustfood (MESH1999E format)
  • earth_night (MESH1999H format)
All other models, including those generated by the mod tools, are in MESH1999J format and should be convertable, with a few exceptions:
  • raptor_wreck01
  • raptor_wreck02
  • raptor_wreck04
  • alien_w_kicsi_15
These generate an error during the conversion (will be skipped automatically). Also some models from the Stargate mod produced the same kind of error during tests. I'm not sure about the cause yet - likely something I don't yet fully understand about the file format, because Nexus handles these models just fine. Might fix this issue later, if I find a permanent fix.

The obj-format also doesn't support normal, specularity or luminosity maps, so you have to change that in your favourite 3d application and save it in a more advanced format, if you want these maps to be rendered. There's some quick info about how to extract these maps from the converted textures in the Texture Converter thread, so go there for more info.

Download Model Converter



« Last Edit: April 15, 2011, 01:05:53 by Arparso »

Offline DreamorCZ

  • Petty Officer
  • **
  • Posts: 110
  • Karma: 1
    • View Profile
    • Czech Gaming Nexus
Re: [Tool] Model Converter
« Reply #1 on: December 30, 2010, 19:18:47 »
I would say it's impressive but I don't think that could be sufficient. We will add Arparso's Engineer Medal to our mod's campaign.


Would it be possible for the program to divide model Layers as they should be divided? It could help with recreating of animations.
What Sg models were causing that error?
Editor in Chief at http://www.cgnexus.eu/

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
Re: [Tool] Model Converter
« Reply #2 on: December 30, 2010, 19:59:49 »
Would it be possible for the program to divide model Layers as they should be divided?
Yes, but it's not really implemented yet. The obj-format has limited support for combining polys into groups or layers, but still the obj-importer of the 3d tool you're using has to support that. Lightwave, for example, completely ignores any grouping whatsoever in obj files and throws everything into the same layer.

I might add support for more advanced file formats later on (like Collada or Lightwave's lwo/lws format). These are vastly more complex than obj, however, which is the reason why I avoided them for this initial version of the converter. Would also solve the lack of animations, because I could properly export them to these formats. ;)

That has to wait until I have enough time, though. :(

What Sg models were causing that error?
These models from beta 7 didn't work (I don't have the newest version of the mod installed right now :( ):
- AncientBS
- jpx_blue_x2
- grace
- roc

The problem lies within the converter, though - I didn't want to suggest, that these models are faulty in any imaginable way. The converter just encountered some unexpected error, most likely because of me not fully understanding the whole file format and thus interpreting the data in a wrong way.

Offline DreamorCZ

  • Petty Officer
  • **
  • Posts: 110
  • Karma: 1
    • View Profile
    • Czech Gaming Nexus
Re: [Tool] Model Converter
« Reply #3 on: December 30, 2010, 21:15:19 »
Quote
I might add support for more advanced file formats later on (like Collada or Lightwave's lwo/lws format).

I see, we will have to build a statue for you soon.  ;)

Quote
The problem lies within the converter, though - I didn't want to suggest, that these models are faulty in any imaginable way.

Well, I wanted to pinpoint an aspect that is making the error but since every of those models are completely different........ I can only say....... strange.
Editor in Chief at http://www.cgnexus.eu/

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
Re: [Tool] Model Converter
« Reply #4 on: December 30, 2010, 22:13:54 »
Is there any 2d or 1d geometry on these models? Like lines or single points that aren't part of any triangle and that don't serve any special purpose such as a "blink" or "boosters"?

To be overly technical: the error occurs when reading a number of vertices from an array. I extract the index (position in the array) of the first vertex from the file. I also extract the total number of geometric primitives I need to read from the array after that first vertex. Usually these primitives are triangles - so my converter tries to read three vertices for each primitive from the array:

(number of primitives) * (3 vertices per primitive) = (number of vertices to read from the array, beginning at first vertex's position)

In most cases this works fine... with these particular models, however, it fails, because the array isn't big enough to contain this calculated number of vertices. I'm guessing, that these vertices don't form triangles, but instead lines or even just points, because those would need less vertices for the same amount of primitives and might still fit into the array.

Problem is, the converter needs to recognize this before trying to read the vertices and I haven't yet found out how that kind of information is encoded in the msh file format.

I see, we will have to build a statue for you soon.  ;)
Nah, I accept cheques as well ;)
« Last Edit: December 30, 2010, 22:23:37 by Arparso »

Offline DreamorCZ

  • Petty Officer
  • **
  • Posts: 110
  • Karma: 1
    • View Profile
    • Czech Gaming Nexus
Re: [Tool] Model Converter
« Reply #5 on: December 31, 2010, 00:15:57 »
Grace (read: "freaky old horrible model") has alone vertices, one layer, no hardpoints and no textures; Roc has textures, one layer, alone vertices and #boosters#; AncientBS has alone vertices, one layer, hardpoints and no textures; jpx_blue_x2 has alone vertices, two layer, hardpoints and textures.

All of them except jpx_blue_x2 are created with polygons. AncientBS has more then one starting/ending verteces at same two coordinates. First/last vertex is always connected with another except on jpx_blue_x2.

AncientBS, Roc and Grace is created by me with Lghtwave 9.2. jpx_blue_x2 is created by former B5 team with older Lightwave.

As I said, completely different models with nothing in common.
« Last Edit: January 06, 2011, 10:35:32 by DreamorCZ »
Editor in Chief at http://www.cgnexus.eu/