Important information: this site is currently scheduled to go offline indefinitely by December 1st 2023.
If you wish to donate to attempt the preservation of tools and software somewhere else before it goes down, check the GoFundMe

Settlers 7 Models help

Post questions about game models here, or help out others!
User avatar
TaylorMouse
ultra-veteran
ultra-veteran
Posts: 348
Joined: Mon Sep 26, 2011 12:51 pm
Has thanked: 11 times
Been thanked: 90 times

Re: Settlers 7 Models help

Post by TaylorMouse »

Sammie wrote:
TaylorMouse wrote:I have the settlers 7, so could you upload the s7bbaex extracter so i can do the extraction of the bba file myself. Thnx

T.
Download: s7bbaex.rar

Thnx
T.
Sammie
veteran
Posts: 106
Joined: Wed Apr 25, 2012 12:27 pm
Has thanked: 9 times
Been thanked: 34 times

Re: Settlers 7 Models help

Post by Sammie »

@finale00
Sounds complicated :eek: i wish i could understand this stuff :mrgreen:
so is it possible to build a s7m->obj converter?
User avatar
TaylorMouse
ultra-veteran
ultra-veteran
Posts: 348
Joined: Mon Sep 26, 2011 12:51 pm
Has thanked: 11 times
Been thanked: 90 times

Re: Settlers 7 Models help

Post by TaylorMouse »

what does the
read('4L') mean ?

T.
Sammie
veteran
Posts: 106
Joined: Wed Apr 25, 2012 12:27 pm
Has thanked: 9 times
Been thanked: 34 times

Re: Settlers 7 Models help

Post by Sammie »

TaylorMouse wrote:what does the
read('4L') mean ?

T.
4L= Unsigned Long Integer (Standardsize = 4)
2H = Unsigned Short Integer (Standardsize = 2)

Standardsize is the size of the packed value in bytes
User avatar
TaylorMouse
ultra-veteran
ultra-veteran
Posts: 348
Joined: Mon Sep 26, 2011 12:51 pm
Has thanked: 11 times
Been thanked: 90 times

Re: Settlers 7 Models help

Post by TaylorMouse »

Code: Select all

string file = @"C:\Temp\A_Sheep\A_Sheep_Shorn_01.s7m";

try
{
using(System.IO.BinaryReader r = new System.IO.BinaryReader(System.IO.File.Open(file, FileMode.Open, FileAccess.Read)))
{
	char[] chars = r.ReadChars(4);
	
	Debug.WriteLine(chars[0].ToString() + chars[1].ToString() + chars[2].ToString() + chars[3].ToString() );
		
	Debug.WriteLine(String.Format("Minor Version {0}", r.ReadUInt32()));
	Debug.WriteLine(String.Format("Major Version {0}", r.ReadUInt32()));
	int nVerts = (int)r.ReadUInt32();
	Debug.WriteLine(String.Format("Number Verts {0}",nVerts ));
	Debug.WriteLine(String.Format("Number Indexes {0}", r.ReadUInt32()));

 	for (int i = 0; i < 8; i++)
	{
		r.ReadUInt32();
	}
	
	int len = (int)r.ReadUInt32();
	len = len - (len%16) + 16; // 16 byte chunks
	Debug.WriteLine(String.Format("Texture Names Length {0}", len));
	
	r.ReadUInt32();
	r.ReadUInt32();
	
	char[] textures = r.ReadChars(len);
	
	string tmp = "";
	for	(int i = 0; i < len; i++)
	{ tmp += textures[i].ToString(); }
	
	string[] texNames = tmp.Split('\0');
	for(int i = 0; i < texNames.Length; i++)
	{
		if( texNames[i].Length > 0)
		Debug.WriteLine(texNames[i]);
	}
	
	int chunkType = (int) r.ReadUInt16();
	int chunkSize = (int)r.ReadUInt16();
	int structSize = (int)r.ReadUInt32();

	Debug.WriteLine(String.Format("Chunk Type {0}", chunkType ));
	Debug.WriteLine(String.Format("Chunk Size {0}", chunkSize  ));
	Debug.WriteLine(String.Format("Struct Size {0}", structSize ));	

	Debug.WriteLine(String.Format("This must be 24 => {0}", r.ReadUInt32() ));	
	
	char[] chunkName = r.ReadChars(4);
	
	Debug.WriteLine(chunkName[0].ToString() + chunkName[1].ToString() + chunkName[2].ToString() + chunkName[3].ToString() );

	for(int i = 0; i < nVerts; i++)
	{
		Debug.WriteLine(String.Format("[{0},{1},{2}] uv [{3},{4}]" ,  r.ReadSingle(),r.ReadSingle(),r.ReadSingle(),r.ReadSingle(),r.ReadSingle() ));
		 r.ReadSingle();
	}
	
	
	r.Close();

}
}
catch(Exception ex)
{
	Debug.WriteLine(ex);
}

Code: Select all

S7MF
Minor Version 1
Major Version 1
Number Verts 461
Number Indexes 1656
Texture Names Length 112
A_Sheep_A_Sheep_Shorn
Textures\Animals\A_Sheep_01_Shorn_D.dds
Models\Animals\A_Sheep\A_Sheep_Shorn_01.s7m
Chunk Type 1
Chunk Size 1383
Struct Size 11064
This must be 24 => 24
VST0
[5.652521E+08,2.943147E-41,0.0001288966] uv [1.642716E-38,-6.431651E+37]
[5.631549E+08,2.943147E-41,6.159579E-05] uv [1.642734E-38,-6.431651E+37]
[1.186988E+09,2.895503E-41,0.0001603965] uv [1.120339E-38,-6.431651E+37]
[2.074171E+09,2.928854E-41,0.0002157032] uv [1.198274E-38,NaN]

I think I'm on the right track, but then I run into a NaN... :/ any idea?

T.
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Settlers 7 Models help

Post by finale00 »

btw, it is

Code: Select all

int chunkType = (int) r.ReadUInt16();
int unk = r.ReadUInt16();
int chunkSize = (int)r.ReadUInt32();
int structSize = (int)r.ReadUInt32();
If you see e+41, you know there's something wrong lol
User avatar
TaylorMouse
ultra-veteran
ultra-veteran
Posts: 348
Joined: Mon Sep 26, 2011 12:51 pm
Has thanked: 11 times
Been thanked: 90 times

Re: Settlers 7 Models help

Post by TaylorMouse »

mmm.. ok :)

Code: Select all

                    int chunkType = (int)r.ReadUInt16();
                    int unk = (int)r.ReadUInt16();
                    int chunkSize = (int)r.ReadUInt32();
                    int structSize = (int)r.ReadUInt32();
                    char[] chunkName = r.ReadChars(4);
I already figured that out... thnx

Then I tried to read the chunk part ( at least I try to parse it)

but it has stuff like

Code: Select all

FF FF FF FF
and that, results in NaN :/

So if you have any idea...


T.
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Settlers 7 Models help

Post by finale00 »

It could just be an integer -1.
User avatar
TaylorMouse
ultra-veteran
ultra-veteran
Posts: 348
Joined: Mon Sep 26, 2011 12:51 pm
Has thanked: 11 times
Been thanked: 90 times

Re: Settlers 7 Models help

Post by TaylorMouse »

Sorry... what?

Code: Select all

FF FF FF FF
equals -1 as a signed Int or a signed Byte, but what do I do with it?

If I build it up like

v1,v2,v3,uv1,uv2

the uv2, mostly ends up in -1, but is that an ok uv value?

T.
Last edited by TaylorMouse on Mon Aug 13, 2012 9:47 pm, edited 1 time in total.
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Settlers 7 Models help

Post by finale00 »

Don't know, probably ignore it and look at the other values. I don't know what they're for. I don't really even have an idea how the VST chunks are supposed to look like. All we know is that they store vertex information, but why there is VST1 with 4-bytes per struct and VST2 with 8-bytes per struct is unknown.
User avatar
TaylorMouse
ultra-veteran
ultra-veteran
Posts: 348
Joined: Mon Sep 26, 2011 12:51 pm
Has thanked: 11 times
Been thanked: 90 times

Re: Settlers 7 Models help

Post by TaylorMouse »

Yeah, the numbers seem to add up, just not the chunks...

VST0 ->24 I assume 5 floats + 1 Signed Int ( could be if this is the w coordinate), being the xyz of the vertex, then the uvw of the vertex, but when I read them, they result in something weird like:


v[7.383575E-38,5.123147E-42,5.605194E-45] uvw[3.089743E-09,3935990,5]
v[971787.4,500305.2,342601.9] uvw[2980.65,9363.131,5]
v[0.01895693,0.01895693,0.05817918] uvw[9363.131,-5001.346,5]
v[-1.46332E+07,-1.46332E+07,-301668.3] uvw[-5001.346,0.01895693,5]
v[-301668.3,-301668.3,0.05817918] uvw[0.01895693,9363.131,5]
v[500305.2,500305.2,2980.65] uvw[9363.131,-24357.89,5]
v[-301610.5,189772.8,14740.71] uvw[8532.812,0.2564926,5]
v[212298.7,8564.812,14772.71] uvw[190284.8,207694.3,5]
v[185165.1,112550.2,14772.71] uvw[8564.812,277041.9,5]
v[1389705,1930855,139553.2] uvw[180506.2,492048.1,5]
v[811605.4,1389715,947213.9] uvw[828412.9,30628.46,5]
v[-0.4927383,1572864,5283178] uvw[3919609,2903857,5]
v[2660.574,17316.54,7077888] uvw[4365644,3247874,5]
v[1894346,255245.3,24868.12] uvw[5308416,3735552,5]
v[1041434,1010183,2056192] uvw[-16.53608,-180516.7,5]
v[-0.8916748,0.009964556,3.875] uvw[-55.07215,-453192.3,5]
v[-2593206,-202752,-41541.79] uvw[-52.56723,-6.31767E+07,5]
v[-1036288,-413696,0.001602173] uvw[2548.573,17316.54,5]
v[72337.03,-0.4927383,-180516.7] uvw[-55.07215,-453192.3,5]
v[-2593206,-6.31767E+07,161050.3] uvw[453136.2,0.009964556,5]
v[-9937.269,-202752,-1036288] uvw[-1.625293E+07,3.875,5]
v[-52.56723,-41541.79,-413696] uvw[811612,877591.9,5]
v[281137.9,161050.3,140577.2] uvw[1826816,1389705,5]

...
and so on,
but the red numbers, are so weird :/

T.
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Settlers 7 Models help

Post by finale00 »

Here I quickly printed out the VST chunk as half-floats and got this

Code: Select all

struct VST0 {
   Halffloat[3] vx, vy, vz
   byte[18] ?
}
Image

I'll look into VST1 and VST2 later. I don't think there are normals or UV's in VST0 though.
If anything I would think the other values to be related to bone indices and weights. I mean, there really isn't anywhere else you'd put them...
User avatar
TaylorMouse
ultra-veteran
ultra-veteran
Posts: 348
Joined: Mon Sep 26, 2011 12:51 pm
Has thanked: 11 times
Been thanked: 90 times

Re: Settlers 7 Models help

Post by TaylorMouse »

Damn, I was so close...

I don't seem to have a Half Precision Floating point in c#... :/


T.
finale00
M-M-M-Monster veteran
M-M-M-Monster veteran
Posts: 2382
Joined: Sat Apr 09, 2011 1:22 am
Has thanked: 170 times
Been thanked: 307 times

Re: Settlers 7 Models help

Post by finale00 »

lol I wish they had half-floats in 010 editor's inspector.

Not tested, but it was recommended on SO

http://sourceforge.net/projects/csharp-half/

I think you just need to pass in a short and it'll convert it to half-float.

You can roll your own binary reader so that you can say ReadHalfFloat or something, but
You might have your own binary reader already since BinaryReader doesn't support reading in big endian natively.
Sammie
veteran
Posts: 106
Joined: Wed Apr 25, 2012 12:27 pm
Has thanked: 9 times
Been thanked: 34 times

Re: Settlers 7 Models help

Post by Sammie »

TaylorMouse wrote:the uv2, mostly ends up in -1, but is that an ok uv value?

VST0 ->24 I assume 5 floats + 1 Signed Int ( could be if this is the w coordinate), being the xyz of the vertex, then the uvw of the vertex, but when I read them, they result in something weird like
Yes, UVs can have positve and negatives values.. The UV-Space has a default 0-1 range (the upper right), but if the gameengine supports UV-repeating or if the mesh have multiple UVs or the UVs are just bad, then they can have -1 or +2,3,4... - in X or Y. I saw it in old settler-games where many UVs are in 1|1 or -1|0 space. Its allowed. ;)

Image

The VST0-chunksize is 24. If you read 6 floatchunks á 4 bytes you get the XYZ + UV-XY Coordinates + 1 extra chunk. There is no "W" - UVs are flat 2D. 3D-Textures exists, but not in games like this. The 6th chunk is something else...

The VST-Blocks have a chunkType (UInt16), a dataSize (UInt16), a chunkSize(UInt32), a structSize(UInt32) and chunkName(Char4)
finale00 figured out the most things. The dataSize*8 is equal or lower than the chunkSize. If the dataSize is lower, you have to add the difference + 8 Bytes after the chunkSize until the next block.

Example @ M_MF_Musketeer_01.s7m:
chunkType: 1
dataSize: 3351 (26808)
chunkSize: 26808
structSize: 24
chunkName: VST0
# skip 8+0 bytes
#000069b0

chunkType: 2
dataSize: 558 (4464)
chunkSize: 4468
structSize: 4
chunkName: VST1
# skip 8+4 bytes
#00007b40

chunkType: 3
dataSize: 1117 (8936)
chunkSize: 8936
structSize: 8
chunkName: VST2
# skip 8+0 bytes
#00009e40

I think the stuff behind is not really relevant for us. Seems to be the faces/triangle-count in chunktype 4 and other bones and shader data behind.
finale00 wrote: I'll look into VST1 and VST2 later. I don't think there are normals or UV's in VST0 though.
If anything I would think the other values to be related to bone indices and weights. I mean, there really isn't anywhere else you'd put them...
Hmm, I think the normals und specular maps sharing the same UVs from VST0.
But the size in VST1 (1/6 from VST0) and VST2 (1/3 from VST0) is strange.
Too regular for bones. And buildings don't have any weights. I don't know if we need them.
Could you upload your converter?
Last edited by Sammie on Tue Aug 14, 2012 2:57 pm, edited 1 time in total.
Post Reply