legomoe

LI2 Msh Tools v1.0

13 posts in this topic

In light of the recent discoveries on how to read LEGO Island 2's .msh model format, I thought that I would go ahead and update my old .msh to .obj converter tool.

I must admit, I got a little carried away. I completely rewrote the msh2obj tool, and I've written a brand new tool for converting .obj files back into .msh format.

To tools can't handle models that have animation data (SVWL and AVW2 sections), but I think they should be able to convert anything else.

I haven't had a chance to test anything beyond just moving vertices around, but feel free to experiment on your own and post what you find out in this topic.

Here's a link to both programs: http://www.mediafire..._Tools_v1.0.zip

NOTE: The .obj format can't handle the matrix transformation data in the .msh files for buildings with dynamic elements like doors that open, so the msh2obj tool will dump this data into a .matrix file with the same name as the .obj file when it does a conversion. Don't forget that the obj2msh tool will need that .matrix file passed in as a third parameter when you go to convert the .obj back to .msh format.

3 people like this

Share this post


Link to post
Share on other sites

Awesome. I'll certainly be doing some stuff with this. Thanks!

Share this post


Link to post
Share on other sites

one question: I extracted the BOD and BOB of the idjarandomcharactersIforgotLGI, all the models are there, though, where are the minifig Body and legs? I only find Minifig's hat, hands, head, and some weird shape that looks like a camera...

Share this post


Link to post
Share on other sites

one question: I extracted the BOD and BOB of the idjarandomcharactersIforgotLGI, all the models are there, though, where are the minifig Body and legs? I only find Minifig's hat, hands, head, and some weird shape that looks like a camera...

I'm not exactly sure. The model data for each minifigure should be in with all the other models, but I think their 3D data might be distorted, since they're supposed to be paired with animations. So they may not be recognizable, even if you find them.

Share this post


Link to post
Share on other sites

Is it possible to convert all MSH files to OBJ in one command, like V2 of your BODBOB tool? The2Banned2One's converter is built for the old converter...

Share this post


Link to post
Share on other sites

Is it possible to convert all MSH files to OBJ in one command, like V2 of your BODBOB tool? The2Banned2One's converter is built for the old converter...

No, but you can do it with a batch script.


@ECHO OFF

setlocal EnableDelayedExpansion

call :recurse

PAUSE

goto :eof

:recurse

SET mfile

FOR /f "usebackq delims=|" %%f IN (`dir /b "*.msh"`) DO (

    SET mfile=%%f

    ECHO Converting file %%f...

    msh2obj.exe %%f !mfile:.msh=.obj!

)

ECHO Finished


Here a link th the file as well: http://www.mediafire.com/file/v7ymf9mq9eup3nu/Msh2ObjAll.Bat

Just put this batch file, along with msh2obj.exe, in the same folder as all the .msh files you want to convert and double click the batch file.

Tell me if it gives you any problems!

3 people like this

Share this post


Link to post
Share on other sites

Hate to necro, but can someone tell me what to add to the batch script above to make the files convert into a folder name "converted" relative to where the .bat file was run?

I assume something on the "msh2obj.exe %%f !mfile:.msh=.obj!" part is what I need to change, but otherwise I don't know.

Share this post


Link to post
Share on other sites

I think it'll work if you change
 

msh2obj.exe %%f !mfile:.msh=.obj!

into

msh2obj.exe %%f Converted\!mfile:.msh=.obj!

Share this post


Link to post
Share on other sites

Ah nope.

"Cannot open X file "converted/model.obj for writing"

 

Creating the folder manually beforehand removed the error. This should be okay, but just in case, there isn't an easy way to make it so it creates the folder beforehand itself is there?

 

Something like this? (Not working)

mkdir %~dp0\Converted\

 

Share this post


Link to post
Share on other sites

Can't you work around it with saying

msh2obj.exe %%f !mfile:.msh=.obj!
mkdir _yourdir_
mv _location/file_ _yourdir_

so you just move it into the new folder after creation.

1 person likes this

Share this post


Link to post
Share on other sites

Oh, so that's how you do it. Putting just

 

mkdir Converted
on line two with nothing more or nothing less solved the problem. I think I was trying to over-complicate the folder creation process, also why is this line in a scroll bar now, ahhhhh. 

I suppose you COULD move it afterwards, but why not just do it on creation? It's one less step.

 


 

Here is my final product code with your guy's help.

I took the mkdir line to the next step and added something in so it won't say "this folder already exists!" if it does already.

@ECHO OFF
	if not exist Converted mkdir Converted
	setlocal EnableDelayedExpansion
	call :recurse
	PAUSE
	goto :eof
	:recurse
	SET mfile
	FOR /f "usebackq delims=|" %%f IN (`dir /b "*.msh"`) DO (
	    SET mfile=%%f
	    ECHO Converting file %%f...
	    msh2obj.exe %%f Converted\!mfile:.msh=.obj!
	)
	ECHO Finished
 

Also, I was noticing something, both in this and the original code legomoe posted. At the very start when you run the batch script it says "environment variable mfile not found".

Share this post


Link to post
Share on other sites
1 hour ago, Xiron said:

I suppose you COULD move it afterwards, but why not just do it on creation? It's one less step.

I thought with 'not working' you meant that it refused to place the file in any other directory on creation, hence I gave this workaround.

Share this post


Link to post
Share on other sites

Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah. It all makes sense now, thanks anyway!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now