mdl2mesh - Neverwinter Nights model converter

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
Martoon
Greenskin
Posts: 118
Joined: Thu May 19, 2005 7:36 pm

Post by Martoon »

Marc wrote:
Martoon wrote:I've modified the script so the Ogre meshes it generates have the y-axis up (instead of z-up like NWN).
Is this configurable? I always prefer z-up ...
I guess I assumed people would be working with y-up in Ogre, since all of the Ogre Direction and LookAt functions assume y-up (and won't let you specify otherwise, as far as I can tell).

But I could throw another parameter in the script.
User avatar
Martoon
Greenskin
Posts: 118
Joined: Thu May 19, 2005 7:36 pm

Post by Martoon »

Okay, here it is (just for Marc :wink: ). The script now takes a "-zup" parameter. Without the "-zup" flag (by default), it converts everything to y up. With the "-zup" flag, it leaves it at the NWN orientation.

http://www.jcvr.org/rabens/mdl2mesh.lua
User avatar
Martoon
Greenskin
Posts: 118
Joined: Thu May 19, 2005 7:36 pm

Post by Martoon »

Having one small problem with massconvert and some of the content I'm converting. Ogre material names are case sensitive. Massconvert generates the universal material script from the filenames of the .tga files. However, some of my .mdl's refer to bitmaps with a different case than the name of the .tga file. For example, there's a "helopad.tga" file, but the .mdl has "bitmap HELOPAD". The Ogre mesh that's generated wants a material named "HELOPAD", but the material file has a material named "helopad", so when the mesh is loaded, it has no material.

I'm trying to figure out the best way to deal with this. Ideally, I think the material script should have material names with their case taken from the materials referenced in the models (instead of from the .tga filenames).

I'm thinking of modifying the massconvert program to do this, but it would alter the flow pretty significantly, since it would need to convert the models first (and glean the material names from each model), then generate the materials afterward.
User avatar
Pascal
Gnoblar
Posts: 4
Joined: Thu Apr 20, 2006 10:32 pm
Location: Poland, Chybie

Post by Pascal »

Is there any way to convert files like "c_yfem01.MDL" or "c_yshopkeep.MDL" (man or female models)? I get model with skeleton, but without any animations.

In .mdl files I see lines:
c_yfem01.MDL wrote:setsupermodel c_yFem01 a_fa
c_yshopkeep.MDL wrote:setsupermodel c_yShopkeep a_ba
It means that model needs another file ("a_fa.mdl" or "a_ba.dml") to work. Anyone know how to convert it? :)
User avatar
Borundin
Platinum Sponsor
Platinum Sponsor
Posts: 243
Joined: Fri Oct 03, 2003 5:57 am
Location: Sweden
x 2
Contact:

Post by Borundin »

What I did was to convert the a_ba.mdl file. Open the created XML file and then copy and paste the animation part into the XML file for the mesh I wanted to use it in (c_yfem01.MDL in your case). Then convert it ti the final mesh format.
Of course this will not be very efficient if you have several meshes that use the same animations. I think you can tell Ogre to use a skeleton from another mesh and then animate it as it had those animations from the beginning.
Image : Image
User avatar
Pascal
Gnoblar
Posts: 4
Joined: Thu Apr 20, 2006 10:32 pm
Location: Poland, Chybie

Post by Pascal »

I think that last version of script posted here has some bug.
This model comes with NWN Model Viewer 1.0 (Dire_Cat.mdl).

The first version, without animations working, but model looks fine:

Image

The last version posted here, animations are working, but some bones are translated or rotated incorrectly:

Image

I don't know much about LUA, so I tried to use .mesh file from the first converion and .skeleton from the second. The model looks fine (like 1st image), but animated model looks strange (like 2nd image)...

EDIT: Models like Deer.mdl or Boar.mdl also have this bug. I think that all animals with 4 (or more) legs have this problem ;) Sorry for my English, I am not a native English speaker ;)
User avatar
Borundin
Platinum Sponsor
Platinum Sponsor
Posts: 243
Joined: Fri Oct 03, 2003 5:57 am
Location: Sweden
x 2
Contact:

Post by Borundin »

I will look into this. Thanks for the feedback.
Image : Image
User avatar
Borundin
Platinum Sponsor
Platinum Sponsor
Posts: 243
Joined: Fri Oct 03, 2003 5:57 am
Location: Sweden
x 2
Contact:

Post by Borundin »

It seems the last revision messed up a couple of things. I have removed the applyNodeOrientation code and updated mdl2mesh.lua in OgreAddons so that Dire_cat.mdl and others should work.

Remember for this model you need to set the parameter "-nobonerot" otherwise it will not work. This is the same as using 0 as value when asked "Apply bone rotation?"
Image : Image
cloud
Gremlin
Posts: 196
Joined: Tue Aug 08, 2006 6:45 pm
x 14

Post by cloud »

Hi, I had a troubles under the New Eihort XMLconverter (with OSX) I just downloaded the latest cvs version, the mesh xml file generated has this

Code: Select all

       <submesh material="c_werewolf
"
This \n after the material name din't used to be a problem for me XMLconverter, but it seems to be now

I added from a google search :wink:

Code: Select all

  
-- removes end-of-line characters in a string
  function Chomp(line)
    return string.gsub(line, "[\r\n]+$", "")
  end
and changed line 970

to io.write(" <submesh material=\"" .. Chomp(ktex) ..

and its working nicely again.

many thanks
User avatar
Borundin
Platinum Sponsor
Platinum Sponsor
Posts: 243
Joined: Fri Oct 03, 2003 5:57 am
Location: Sweden
x 2
Contact:

Post by Borundin »

cloud wrote:...and changed line 970

to io.write(" <submesh material="" .. Chomp(ktex) ..

and its working nicely again.
Thanks for your feedback!
I will add this to the mdl2mesh in Addons. Cant see anything that this would break... Programmers famous last words, I know :)
Image : Image
Lord LoriK
Goblin
Posts: 254
Joined: Tue Feb 13, 2007 5:33 am

Post by Lord LoriK »

Hi! I use this converter a lot and I found some models that give some wrong results, but not completely wrong. For instance, PLC_OAK207.mdl from the LUSH hakpack:

Image
Image

As you can see, only one of the thicker branches has the correct rotation. The same applies for the rest of the branches: one well positioned, the rest with wrong rotation.

Any ideas? I tested all the possible combinations of animation and bone rotation, and none fixed it.
User avatar
Borundin
Platinum Sponsor
Platinum Sponsor
Posts: 243
Joined: Fri Oct 03, 2003 5:57 am
Location: Sweden
x 2
Contact:

Post by Borundin »

Did you try the latest version of mdl2mesh.lua from AddOns?
I removed a couple of lines recently that caused a lot of models to be converted with strange artifacts like those you describe.
Image : Image
Lord LoriK
Goblin
Posts: 254
Joined: Tue Feb 13, 2007 5:33 am

Post by Lord LoriK »

I didn't remember if it was indeed the last version, so I downloaded it again, and ran every possible combination again. All give the same messed result.
User avatar
Borundin
Platinum Sponsor
Platinum Sponsor
Posts: 243
Joined: Fri Oct 03, 2003 5:57 am
Location: Sweden
x 2
Contact:

Post by Borundin »

Ok, I will download the PLC_OAK207.mdl model and see if I can solve this somehow.

Edit: Yes there is definately something wrong here. PLC_oak101.mdl seems OK but not this one. One thing that is different is that plc_oak207.mdl uses orientation but plc_oak101 does not. This might take some time to solve Im afraid...
Image : Image
Lord LoriK
Goblin
Posts: 254
Joined: Tue Feb 13, 2007 5:33 am

Post by Lord LoriK »

I'll be waiting, then. :) Hope you manage to fix it.
karnewarrior
Kobold
Posts: 32
Joined: Sun Apr 15, 2007 9:18 pm

Post by karnewarrior »

awsome :twisted:
nindim
Gnoblar
Posts: 17
Joined: Sun Mar 11, 2007 5:06 pm

Post by nindim »

I seem to be having the same problem that Spot was having way back when. Here's what he had to say at the time:
Hi,

I've used the script to convert the 400meg hakpak that someone put together and it seems to work fine. However, when I try to convert a model from the "base game" that I extracted with NWN Explorer it fails to do the conversion.

The material files are always blank.

Mesh file
<mesh>
<submeshes>
</submeshes>
<skeletonlink name="c_demon.mdl.skeleton" />
</mesh>

Skeleton file
<skeleton>
<bones>
</bones>
<bonehierarchy>
</bonehierarchy>
<animations>
</animations>
</skeleton>

Lua output
filename: c_demon.mdl
scale: 100
bonerot: 1
animpos: 1
creskel: 1
animation----->
{ }

tmp - { }

Scene hieracrchy:
{ }
Finished


Any ideas?
Unofrtunately he never posts what he was doing wrong. Ive tried NWN explorer to extract the model as well as bif unpacker as it lets you pick the key file for the bif, whereas nwnViewer doesnt... I dont have the game installed, I have a friends install direcotry copied onto a DVD which I placed in "C:\Neverwinter Nights\NWN". I dont seem to be able to use nwnmdlcomp as iyou have to have the game installed.

The tool works with users mods I have extracted from hak packs (well an older version of the script, the current version seems to screw things up a little, seems like when the rotation was added it went bad for me)

Any ideas on the base models?
nindim
Gnoblar
Posts: 17
Joined: Sun Mar 11, 2007 5:06 pm

Post by nindim »

Decompiling the models into ascii format did the trick. I had to use mdl2ascii.exe available in the ctools package. This doesnt require you to have NWN installed so all is good.
User avatar
Duncan Mac Leod
Halfling
Posts: 79
Joined: Fri Jun 23, 2006 12:27 am
Location: Germany
Contact:

Post by Duncan Mac Leod »

Martoon wrote:Okay, here it is (just for Marc :wink: ). The script now takes a "-zup" parameter. Without the "-zup" flag (by default), it converts everything to y up. With the "-zup" flag, it leaves it at the NWN orientation.

http://www.jcvr.org/rabens/mdl2mesh.lua
Is this version the latest??

Does it generate the new Mesh (1.4) format?
User avatar
SiENcE
Goblin
Posts: 231
Joined: Thu May 11, 2006 3:07 pm
Location: Berlin
Contact:

Post by SiENcE »

Its doesn't generate binary meshes. It only generates Ogre-Mesh.xml files which you can convert to Ogre.Mesh using the Ogre commandline tools.

http://downloads.sourceforge.net/ogre/O ... i?download
User avatar
Duncan Mac Leod
Halfling
Posts: 79
Joined: Fri Jun 23, 2006 12:27 am
Location: Germany
Contact:

Post by Duncan Mac Leod »

Hi!

Does anyone of you have BoundingBox Problems with the Animated (converted) Models ??

Use an animated model and place it on the 'ground', then start an animation (i.e. walking), the model 'jumps' in the air - the animated model is ABOVE the ground, so I put it 'down on the ground' again, BUT its BoundingBox is still at its original location, only the animation is played 'high in the air'...

Putting the animated model back on the ground is not the problem, BUT I want the Bounding Box around my Model, NOT outside...

Look at the screenshots - as you can see the BBox of the Model is lower than the played anim...

Image Image

On the first shot you can see how deep the BBox is under the Plane...

Do you know what's wrong? Please help! Thank you!

Duncan
pfepark
Gnoblar
Posts: 3
Joined: Fri Sep 14, 2007 12:11 pm

Problem : convert Iron_golem.mdl

Post by pfepark »

when I converted to Iron_golem.mdl(from official NWN1 homepage ) using mdl2mesh I saw This Error Message.

lua5.1: mdl2mesh.lua:171: attempt to index field '?' (a nil value)
stack traceback:
mdl2mesh.lua:171: in function 'CheckVert'
mdl2mesh.lua:954: in main chunk
[C]: ?


What problem is it now ... ? I dont know LUA.
User avatar
Borundin
Platinum Sponsor
Platinum Sponsor
Posts: 243
Joined: Fri Oct 03, 2003 5:57 am
Location: Sweden
x 2
Contact:

Re: Problem : convert Iron_golem.mdl

Post by Borundin »

pfepark wrote:when I converted to Iron_golem.mdl(from official NWN1 homepage ) using mdl2mesh I saw This Error Message.
There is a new converter that perhaps can solve your problem:
http://www.ogre3d.org/phpBB2/viewtopic. ... highlight=

Also remember that you need to have an ASCII model, not the binary ones the NWN engine uses for best performance.
Image : Image
Teirdalin
Gnoblar
Posts: 1
Joined: Mon Aug 31, 2020 5:40 am

Re: mdl2mesh - Neverwinter Nights model converter

Post by Teirdalin »

I know this is years old, but does anyone still have either MDL2Mesh or PyMDL2Mesh?
They seem to be down everywhere on the internet now, but the world really needs these tools for the betterment of humankind.
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 155

Re: mdl2mesh - Neverwinter Nights model converter

Post by sercero »

Hello,

You can find it here:
https://sourceforge.net/p/ogreaddons/co ... /mdl2mesh/

Be aware that this has not been updated since the year 2007.
Post Reply