Join also our Discord channel! Click here.

[Request]Hob game MDL converter

Post questions about game models here, or help out others!
User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Fri May 18, 2018 2:12 pm

akderebur wrote:They are not empty, so you might lose some data, but it is also possible that the data in those bytes are not necessary for ogre tools or torchlight. I can't say anything for sure since I don't know what those bytes represent.

Anyway here is the batrabbit model with 32 bytes blocks. You can give it a try at least.
Thanks akderebur. I tried this. The "Copy-Paste" metod does not work for this. It is sad.
You do not have the required permissions to view the files attached to this post.

User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Fri May 18, 2018 2:21 pm

Kva3imoda wrote:The "Copy-Paste" metod does not work for this.
It looks like I'm deleting/changing the information about buffer vertex size in this MDL type. Your model without changes does not give this error.

User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Fri May 18, 2018 2:45 pm

I think this is about such information:
<vertexbuffer positions="true" normals="true" texture_coord_dimensions_0="float2" texture_coords="1">
This can be found at the beginning of of any xml file.

User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 3135
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 833 times
Been thanked: 1674 times

Re: [Request]Hob game MDL converter

Post by shakotay2 » Fri May 18, 2018 3:57 pm

the uvs for C_Batrabbit.mdl are at FVF pos 52 (dec). The FVF size (=vertex declar.?) is at file offset 0x648: 58 00 (8 bytes before start of vertices).

It's claimed to be a skinned mesh so weights to be expected in the FVF block. But it looks like there's normals only (bi, or tangent, whatever) at offsets 12, 28 and 40 (dec).

When decreasing the FVF block you'll at least have to write a 0x20 to offset 0x648 and copy the uvs (8 bytes from pos 52-59 to pos 24-31).
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."

User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Fri May 18, 2018 9:20 pm

shakotay2 wrote: When decreasing the FVF block you'll at least have to write a 0x20 to offset 0x648 and copy the uvs (8 bytes from pos 52-59 to pos 24-31).
Yeah exactly. This is an excellent remark. I tried it, but failed.

It is a pity that among us there is no OGRE specialists. What if these 88 byte blocks are another OGRE standard? This means that we are on the wrong track. Now we just do not know why the the OGRE tools not understand these files.

User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Fri May 18, 2018 9:36 pm

In OGRE, the HardwareBuffer class represents a vertex buffer. The HardwareBufferManager singleton allows you to create new hardware buffers.

Creating a vertex buffer is quite simple, you call the createVertexBuffer method and tell it the following pieces of information:

How you plan to use the buffer
The number of bytes that represent each vertex
The number of vertices in the buffer
As I understand it, in Ogre we set/select the block size.

User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Fri May 18, 2018 9:50 pm

Ok, while we are struggling with this "88byte" files, can anyone create a utility for "nonconvertible_v1.9_o" files?

This is a fairly simple utility that should find a pattern - "vertex count", delete "the wrong header" and paste "the correct header".

akderebur
ultra-veteran
ultra-veteran
Posts: 503
Joined: Fri Jul 08, 2011 10:36 am
Has thanked: 63 times
Been thanked: 570 times

Re: [Request]Hob game MDL converter

Post by akderebur » Fri May 18, 2018 10:12 pm

Kva3imoda wrote: It is a pity that among us there is no OGRE specialists. What if these 88 byte blocks are another OGRE standard? This means that we are on the wrong track. Now we just do not know why the the OGRE tools not understand these files.
The problem is trying to get them to work with the existing tools really. The format is actually not complicated. It might even be easier to make a new tool that finds and loads the mesh/skeleton data, but since you need to import these stuff back, I guess you need the existing tools.

The problem is mostly data sizes/offsets imo. Like shakotay said 0x648 is where the block size is. Also 2 bytes later at 0x64C there is the offset to the next data, which is actually block size * vertex count + 6 = 88 * 1245 + 6 = 109566. There is also another offset like this before the indices, which will direct you to the skeleton data. So if you are trying 32 bytes blocks, you need to change these accordingly.

I tried the opposite of what you are doing, and copied the indices and vertices from the Batrabbit to the Fish. It came out like this.

Image

I copied the skeleton too, but the animation is messed up. I didn't expect it to work anyway :D I am not sure if 32 bytes is necessary though. It feels like the 88 bytes files can also work with proper header/offsets.

Anyway I will leave the file here, in case you are interested. I don't think I have much left to contribute. I suggest you to try to understand how the file is loaded. There might be some documentation on this format. It seems like "v1.9" files have some missing/extra info that prevents them from getting loaded by the standard tools. You can try finding that. Good luck figuring it out.
You do not have the required permissions to view the files attached to this post.

User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Fri May 18, 2018 10:39 pm

akderebur wrote: I tried the opposite of what you are doing, and copied the indices and vertices from the Batrabbit to the Fish.
akderebur wrote:Anyway I will leave the file here, in case you are interested.
Image
:lol:

Image
Last edited by Kva3imoda on Fri May 18, 2018 11:24 pm, edited 1 time in total.

User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Fri May 18, 2018 10:55 pm

akderebur wrote:I didn't expect it to work anyway :D
I did not expect that we will understand all this. And that someone will help me. :)
You guys rock! Today is my birthday and this is the best gift for me.

User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Sat May 19, 2018 5:13 am

akderebur сan you tell us in more detail how you converted 88 bytes blocks into 32 bytes? I tried to figure out what you deleted, and it looks like you used this scheme: 16 + 28 + 8 + 28 +8

Can you share the utility and the code that you used?

Also, can we create a fully automatic model converter? Can we find a pattern, recalculate the offset data and change the header?

akderebur
ultra-veteran
ultra-veteran
Posts: 503
Joined: Fri Jul 08, 2011 10:36 am
Has thanked: 63 times
Been thanked: 570 times

Re: [Request]Hob game MDL converter

Post by akderebur » Sat May 19, 2018 7:07 am

Kva3imoda wrote:akderebur сan you tell us in more detail how you converted 88 bytes blocks into 32 bytes?
I used : 24 + 28 + 8 + 28

I will be outside whole day and get back home late. I will post the code tomorrow.

User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Sat May 19, 2018 7:41 am

akderebur wrote:I will post the code tomorrow.
Ok, thanks.
I'll try to find a programmer in our community who will create tools for us.

Hob era has begun! :keke:

Image

User avatar
Kva3imoda
beginner
Posts: 32
Joined: Sun May 29, 2016 12:12 am
Location: Russia
Has thanked: 7 times
Been thanked: 6 times
Contact:

Re: [Request]Hob game MDL converter

Post by Kva3imoda » Thu May 24, 2018 7:35 pm

Well, all my familiar programmers are busy now. But we can always try to make scripts for a Hex editor.

akderebur I still need more details about your changes.

akderebur
ultra-veteran
ultra-veteran
Posts: 503
Joined: Fri Jul 08, 2011 10:36 am
Has thanked: 63 times
Been thanked: 570 times

Re: [Request]Hob game MDL converter

Post by akderebur » Fri May 25, 2018 8:52 am

Kva3imoda wrote: akderebur I still need more details about your changes.
You already have all the details actually :D Here is the code.

Code: Select all

private void Convert()
{
    int vertCount = 1245;

    FileStream newFs = new FileStream("conv_mesh.mesh", FileMode.Create);
    BinaryWriter writer = new BinaryWriter(newFs);

    FileStream fs = new FileStream("C_BATRABBIT.MDL", FileMode.Open);
    BinaryReader reader = new BinaryReader(fs);

    writer.Write(reader.ReadBytes(1608));
    writer.Write(new byte[] { 32, 0 });

    reader.ReadBytes(2);
    writer.Write(reader.ReadBytes(2));
    writer.Write(vertCount * 32 + 6);

    fs.Seek(1616, SeekOrigin.Begin);
    for (int i = 0; i < vertCount; i++)
    {
        writer.Write(reader.ReadBytes(24));
        fs.Seek(28, SeekOrigin.Current);
        writer.Write(reader.ReadBytes(8));
        fs.Seek(28, SeekOrigin.Current);
    }
}
This is just the code implementation of what we talked about above. Of course it will only work "BATRABBIT" as the offsets and counts are hard coded.

Post Reply