Page 3 of 5

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 4:00 am
by finale00
The chunks are 16-byte aligned.
Just add

Code: Select all

(16 - (chunkSize % 16)) % 16
as the padding.

I'm not sure what the second short is in the chunk header really. You wrote data size, but sometimes it is drastically different from the chunk size.

Noesis plugin: https://www.dropbox.com/sh/7stlpd4qvkq3 ... rs7_s7m.py

I really have no clue what the rest of the data might be.
The VST1 chunk has half-floats greater than 1.0, so I assume those can't be UV's
VST2 chunk also has half-floats greater than 1.0.

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 9:55 am
by Sammie
finale00 wrote:The chunks are 16-byte aligned.
I'm not sure what the second short is in the chunk header really. You wrote data size, but sometimes it is drastically different from the chunk size.
Hm, I thought the dataSize multiplied by 8 is the relevant datalength for the chunk-block. If the result differ from the chunkSize I see only additional "0"-Bytes at the end, which I have to add to the regular 8 byte-padding until the next chunkblock. But okay, I don't really understand this stuff. ;)


thx for the plugin. Hm, the Noesis export model looks okay. but the UVs are definitively wrong (or not exported?). All UV-texture data is set to 0.0.

If you say "greater" - how much greater? If the value is a float beween -1 and +2 it could be normal. You can also store UV-data at 10000, but thats extremely unlikely.
Its common for 3d artists to store the UV-data around the default 0|1 Space +/-1. In some old settler games, the UVs were in 0|2 space. If the gameengine supports UV-repeating, it doesn't matter in what UV Space the UVs are.

Edit:
VST1 second and last value per chunk is a specific number (converted to decimal). Dont think that this are float-values.
130 58 89 51
61 59 64 51
58 59 218 50
58 59 218 50
130 58 89 51
156 58 44 52
232 59 91 54
230 59 174 53
210 59 191 53
137 59 244 58
184 59 96 59
184 59 96 59
137 59 244 58
137 59 244 58
239 59 57 59

VST2 seems to have only 2 Values per Vertex. Looks strange to me. Too many repeating values, definitely no UVs.
FF 00 00 00
0A 00 00 00
FF 00 00 00
0B 00 00 00
FF 00 00 00
0A 06 00 00
7F 7F 00 00
0A 08 00 00

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 1:02 pm
by TaylorMouse
I decided to give up to try it in c# and see what I can do with the .py scripts


What tool do you guys use to test/debug etc the .py script before you test it in Noesis?

T.

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 6:56 pm
by finale00
Wing IDE for python syntax errors

I use noesis' debug console for testing/debugging lol

You could always use C++ if you're into that. I couldn't go from C# to C++ though.

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 7:40 pm
by TaylorMouse
in VST0, the chunk is 24, and only 6 bytes are being used, in our code,

6 bytes being 3 * half floats ( 2 bytes per float )

what about the other 18 bytes?

they aren't vertex weights, cause there does not seem to be any reference to any bones here...

could it be normals ? also half floats
could it be uvw ? also half floats

Just thinking out load :)

btw : checking out Wing IDE 101 right now

T.

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 8:59 pm
by Sammie
TaylorMouse wrote:could it be normals ? also half floats
could it be uvw ? also half floats
Yes, for the UVs add to the Phyton-code:

Code: Select all

rapi.rpgBindUV1BufferOfs(mesh.vertBuff, noesis.RPGEODATA_HALFFLOAT, 24, 8)

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 9:03 pm
by finale00
Oh, so they're stored in VST0.
How does the resulting model look?

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 9:15 pm
by Sammie
Looks okay.. if I export the model as obj, and load it in Maya, I have to rotate the model -90° in X-axis and the UVs should be flipped vertically to match with the diffuse-textures.
Maybe you can add this in your plugin.

But its necessary to find out which textures are used. If the model use more than one texture (e.g the buildings), I dont know which polygon should have a specific texture. I think this data is stored in VST1.

Image

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 10:13 pm
by finale00
There is an xml file that defines material info. But the ones I have only seem to use one texture so I don't know how they deal with multiple materials.

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 10:32 pm
by Sammie
finale00 wrote:There is an xml file that defines material info. But the ones I have only seem to use one texture so I don't know how they deal with multiple materials.
Look at my post - there is an tavern-building in the downloadfile, with wall, windows and roof textures. The xml is just an info about light, shadow, ambient and displacementsettings for the gameengine, but the info which polygon uses a specific texture must be inside the .s7m-file. The texturenames are defined behind the verts and Idx-count. At Offset 00000038 is the length of the texture-string until the VST0-chunk starts.

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 10:36 pm
by TaylorMouse
I did the same, imported into Max, indeed the uv mappings need to be flipped horizontally, didn't need to rotate it since you can tell in the importer to do so

Smoothing groups suck :/

here is a little render on a Cavalier:

Image

iz nize no :D

Texture name can be found in the ChunkType = 6

it also contains the name of the material file , which ends with _mat and has the .xml extension
there it has this:

Code: Select all

  <Textures>
    <TextureEdge>
     <BlockVersion name="TextureEdge" version="1"/>
     <Usage>Diffuse</Usage>
     <Dimension>2D</Dimension>
     <TextureData>
      <BlockVersion name="TextureData" version="1"/>
      <Name>Textures\Units\M_MT_Cavalier_d.dds</Name>
     </TextureData>
    </TextureEdge>
   </Textures>
_d for diffuse but the mipmaps are split into 3 different levels

M_MT_Cavalier_d_l1.dds
M_MT_Cavalier_d_l2.dds
M_MT_Cavalier_d_l3.dds -> contains the highest mipmaps

I think this is done so that the loading of the textures is speed up in game

ps: sorry sammie didn't see your post, was busy making mine :)


T.

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 10:54 pm
by Sammie
TaylorMouse wrote:indeed the uv mappings need to be flipped horizontally
really horizontally in Max? I need to flip them vertically in Maya.

Re: Settlers 7 Models help

Posted: Tue Aug 14, 2012 11:13 pm
by TaylorMouse
Sammie wrote:
TaylorMouse wrote:indeed the uv mappings need to be flipped horizontally
really horizontally in Max? I need to flip them vertically in Maya.
My bad, my bad, it is of course VERTICALLY [roll]

T.

Re: Settlers 7 Models help

Posted: Wed Aug 15, 2012 2:37 am
by finale00
I don't see how you would separate the vertex buffer into the correct meshes..

Maybe they decided to store it as such

<mesh1> <mesh2> ... <mesh n>

But then it's not really obviously when one mesh ends and the next one begins.

Re: Settlers 7 Models help

Posted: Wed Aug 15, 2012 11:29 am
by Sammie
finale00 wrote:I don't see how you would separate the vertex buffer into the correct meshes..

Maybe they decided to store it as such

<mesh1> <mesh2> ... <mesh n>

But then it's not really obviously when one mesh ends and the next one begins.
I don't think there is more than one mesh-object per .s7m-file. All vertices & faces are combined together to one mesh for the gameengine. The whole thing has one pivot point.
Some buildings have additional s7m files for goods (crates, barrels..) around the building or other decals, but they are combined too.

So it should be possible to make a rotation around the x-axis with a transform-matrix and flip the UVs, too. If I flip the UVs via the option in Noesis they flipped to 0|-1 space, but that doesn't matter when importing it to Maya or Max. But would be better if the UVs stay within 0|1 space. Some buildings have UVs outside the 0|1 space like the bakery, they use UV-repeating.
Image