[lib] (wip) JSchMEe - Java MSH library

Started by RepComm, October 14, 2016, 10:19:12 AM

Previous topic - Next topic
October 14, 2016, 10:19:12 AM Last Edit: July 17, 2017, 11:16:31 AM by RepComm
JSchMEe - Java Library supporting *.MSH format
Based on study/code/documentation/tools by Tirpider

This project is open source, and is hosted on GitHub:
GitHub - JSchMEe

The Library is not a stand alone tool, but instead provides lots centralized functionality for modelling and file formats.

The library will support plugins, and LoaderPlugins, which will allow a person to write their own importer/exporter for a particular file format that isn't already supported, or provide functionality for manipulating a model itself.

[spoiler=Dev Log]
[7/16/17]
-WaveFrontLoader imports *.OBJ files (MTL soon finished)
-ZeroEngineLoader exports GEOM chunks in MSH format (current priority)
[7/17/17]
-Began plugin system for extending functionality
-Adding built in documentation to library
[/spoiler]

Code Example:

    //Create an OBJ loader
    WaveFrontLoader wavefront = new WaveFrontLoader();
   
    //Create an MSH loader
    ZeroEngineLoader zeroengine = new ZeroEngineLoader();

    //Tell loader to try reading cube.obj file
    GenericModel m = wavefront.parse("cube.obj");
   
    //Do stuff with the new model, in this case, try to export MSH of it
    if (!m.equals(GenericModel.EMPTY) { //Check for errors first
       
        zeroengine.export ("cube.msh", m); //Export the model as MSH
       
    }


This started out as a hacky script to try and dump some MSH file, but I've got a vision for it now.
There are obviously many more points to discuss, so if you have any questions: go for it.

Nice.  I hope you are doing well  :cheers:
Quote from: Abraham Lincoln. on November 04, 1971, 12:34:40 PM
Don't believe everything you read on the internet

July 16, 2017, 10:00:12 PM #2 Last Edit: July 17, 2017, 11:22:24 AM by RepComm
This is essentially a update 'bump'.

MSH exporter is taking shape, here's data I've converted from a blender cube (obj file):

[spoiler=Raw Data]
GEOM    BBOX                                                SEGMl   SHDW       MATI       POSLd      ÍÌŒ?  €¿  €¿  €?  €¿  €?  €¿  €¿  €?  €¿  €¿  €¿  €?  €?ïÿ¿ïÿ?  €? €?  €¿  €?  €?  €¿  €?  €¿WGHT        NRML        CLRLCLRBUV0LNDXLSTRP
[/spoiler]

FileUtils class has simple functions to read/write text/binary data with little code.

Crashing/Exceptions are a minimum, the code is very forgiving.

Documentation is being built into the library, so no extra JAR files to include.

Hey the github link is broken (not seeing the repository on your github page either) - did the project get scrapped or are you still working on it?

September 24, 2017, 02:01:31 PM #4 Last Edit: September 24, 2017, 02:04:41 PM by RepComm
Hello, yes I deleted the project completely because I needed to focus on some pressing matters. I had too much of a desire to work on it to stop. It was the only way I could stop myself :P
--
Okay so, if anyone has the built JAR or source of any commit, I am willing to rebuild everything and continue development ( it got pretty far ).

I do not have access to any of the original files ( I deleted mine, and the repository ).
I know I'm grabbing at straws here, but even if anyone has one of the JAR file builds, I can decompile and de-obfuscate it.

December 25, 2017, 09:58:37 PM #5 Last Edit: December 25, 2017, 10:39:10 PM by RepComm
So this is basically a revive of sorts, but with more serious implications.
Here is a standalone script (unfinished, I did all of this stuff today from scratch after finding my lost backup drive)
in node js.

It reads an msh file and loops through it all, and generates js object hierarchy (and thereby JSON format), outputs to terminal and saves the JSON in a file with the same name, but with the added .json extension.
It's obviously not done, but the rest is down hill (I'll prove it after Christmas, don't worry!)

If you have node already then you can just double click the .bat i made that will tell node to execute the js file.
The algorithm for looping through all of the msh file is there, now I'm just implementing the tags (easy!).

If you don't have node, you can take a look at the JSON file I've already generated with it.

I'm on my phone (no internet for my laptop :( ) so I can't post the JSON in the forum .. stupid tech.
Super exciting! We'll be at full functionality in weeks!

Edit- I figured out how to get off my phone:

{
    "type": "HEDR",
    "contentSize": 121036,
    "MSH2_0": {
        "type": "MSH2",
        "contentSize": 117984,
        "SINF": {
            "type": "SINF",
            "contentSize": 100,
            "NAME": "IMP_Scout_Skeleton\u0000\u0000",
            "FRAM": {
                "begin": 0,
                "end": 1,
                "fps": 29.970029830932617
            },
            "BBOX": {
                "rotation": {
                    "x": 0,
                    "y": 0,
                    "z": 0,
                    "w": 1
                },
                "center": {
                    "x": -0.0077544450759887695,
                    "y": 1.021206259727478,
                    "z": -0.04080498218536377
                },
                "dimension": {
                    "w": 0.9372228384017944,
                    "h": 1.0236891508102417,
                    "d": 0.24409937858581543
                },
                "boundingSphereRadius": 0
            },
            "CAMR": {
                "type": "CAMR",
                "contentSize": 64,
                "NAME": "Camera\u0000\u0000",
                "DATA_0": {
                    "type": "DATA",
                    "contentSize": 40,
                    "unhandled": true
                },
                "MATL_0": {
                    "type": "MATL",
                    "contentSize": 232,
                    "unhandled": true
                },
                "MODL_0": {
                    "type": "MODL",
                    "contentSize": 20208,
                    "unhandled": true
                },
                "SKL2_0": {
                    "type": "SKL2",
                    "contentSize": 504,
                    "unhandled": true
                },
                "BLN2_0": {
                    "type": "BLN2",
                    "contentSize": 204,
                    "unhandled": true
                },
                "ANM2_0": {
                    "type": "ANM2",
                    "contentSize": 2304,
                    "unhandled": true
                }
            }
        }
    }
}

May 02, 2018, 08:25:48 AM #6 Last Edit: September 30, 2018, 10:32:20 PM by RepComm
I've come a long way in my abilities, and I've refined the algorithm nearly perfectly.
It's pretty easy to add chunk types, here's a video of me adding transform chunks in just two minutes cold turkey: https://youtu.be/7xAJvnjedHc

The code has been organized into a separate repo so that it can be used as a dependency with node package manager using the git url.
At which point it's easy for me to add dependency to openbf project, which is coming along also.

I may end up doing this for the terrain parser also, I don't know.

edit- New links because projects are getting organized
Repository final url is http://github.com/RepComm/NodeMSH
https://github.com/node-openbf-project/node-openbf-io

And http://github.com/RepComm/openbf
https://github.com/node-openbf-project/node-openbf-client

September 24, 2018, 08:19:56 PM #7 Last Edit: September 25, 2018, 10:58:45 AM by RepComm
Not a bunch of work on the node module, decided to put it off until I get a blender exporter done.
Which segways into why I'm posting:

https://gist.github.com/RepComm/1df7c65ab5df58ff3c1c5d15fa05fbe9

Thats a gist of a work in progress python plugin for blender that exports
MSH files.
It isn't complete, I've been going at this thing for two days.
Currently I'm all the way to POSL (aka vertices of models),
which is pretty neat considering this is my first jab at python code.
I guess exporting is far easier than parsing.

455 lines of code strong, slightly un-optimised (consequence of not
knowing python combined with hating error messages for users).

Looking at Tirpider's documentation, this code is handling roughly 50% of the tags,
and I consider it a little more done than that since I won't be able to test cloth for
an indefinite amount of time.

edit- Added a demo of the current output from a hex editor view.

edit- I'm going to be having to get triangle strips out of blender models, and they are all stored separatedly.

I decided to post some links here that I found while looking for algorithms to stripify blender meshes:
https://github.com/HENDRIX-ZT2/jpog-blender/blob/master/utils/tristrip.py
Necessary code found in this folder:
https://github.com/HENDRIX-ZT2/jpog-blender/blob/master/utils

There is an nvidea cli solution, but I want to keep things in one code base.