Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Settlers 2: Rise of Cultures

Post questions about game models here, or help out others!
Post Reply
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Settlers 2: Rise of Cultures

Post by Rheini »

The predecessor of this game used Granny. But Granny Viewer isn't able to to open the files used by this one.
Seems like they use a proprietary format now.
I attached the donkey model files as an example.

EDIT: k, the strings are saved Pascal-style, preceded by their size (4 bytes).
Regarding LOD3...The second string is followed by an int denoting the number of dwords following it. Don't know what this is. Indices?
You do not have the required permissions to view the files attached to this post.
fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 94 times

Re: Settlers 2: Rise of Cultures

Post by fatduck »

Since I am good in 3D models data, so I help you out here!
Hope that people can help me in compression data!

Back to the topic, It seems all 3D data use the same extension *.KEX!
-donkey_mesh.KEX, donkey_mesh_LOD1.KEX, donkey_mesh_LOD2.KEX and donkey_mesh_LOD3.KEX are models
-donkey_model.KEX is skeleton file
-all others are animation files

Here is the Model format:

Code: Select all

Settler2 Mesh Format

dword         nLen
Char[nLen]    Filename
float_12      Matrix_3X4
float         ??
byte          numMesh

Struct Mesh {
  dword       nLen
  Char[nLen]  MeshName
  dword       nLen
  Char[nLen]  subMeshName
  dword       numFaceIndices
  dword       numVerts
  dword       numVertPoolData
  dword       numBones
  dword       numMaterial

  struct Face {
    dword_3   Index_123
  }

  Struct VertPool {
    byte      DataType
    dword     ofsDataSize
    //<PoolData>           //see below

    struct Vert {         //DataType = 0
      float_3 Pos_XYZ
    }
  
    struct Normal {       //DataType = 1
      float_3 Nomal_XYZ
    }  
  
    struct Unknown {      //DataType = 3; Maybe VertexColor
      byte_4  ??
    }  

    struct UV {           //DataType = 4
      float_2 Texture_UV
    }

    struct Unknon2D {     //DataType = 5 and 6
      float_2 Texture_UV
    }
    
    struct Weight {       //DataType = 12
      float_4 weight_1234
    }

    struct BoneID {       //DataType = 13
      byte_4  weight_1234
    }
    
  }

  struct BoneName {
    dword       nLen
    Char[nLen]  Bonename
  }

  struct Material {
    dword       nLen
    Char[nLen]  MaterialName
    dword       nLen
    Char[nLen]  SubMaterialName
    dword       ??
    dword       numMatFaces //for Multi-Material
    dword       numTexture
    struct Texture {
      dword       nLen
      Char[nLen]  SlotName
      dword       nLen
      Char[nLen]  TextureName
    }
  }  
    
}
You do not have the required permissions to view the files attached to this post.
Last edited by fatduck on Tue Sep 30, 2008 2:41 pm, edited 3 times in total.
No more Fatduck, no more FatImporter, Byebye everyone!
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: Settlers 2: Rise of Cultures

Post by Rheini »

fatduck wrote:Since I am good in 3D models data, so I help you out here!
Hope that people can help me in compression data!
I knew I can count on you :)
Back to the topic, It seems all 3D data use the same extension *.KEX!
-donkey_mesh.KEX, donkey_mesh_LOD1.KEX, donkey_mesh_LOD2.KEX and donkey_mesh_LOD3.KEX are models
-donkey_model.KEX is skeleton file
-all others are animation files
Already wondered what that _model.KEX is. Yeah all 3D files use *.KEX extension.

Code: Select all

//No sure about the follow, since only 1 Texture

dword       ??
dword       ??
dword       ??
dword       nLen
Char[nLen]  SlotName
dword       nLen
Char[nLen]  TextureName
Ok, I attached some more files.
Thanks for your help!


EDIT: But somehow I can't comprehend in which order those structs are saved in the file :(
You do not have the required permissions to view the files attached to this post.
fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 94 times

Re: Settlers 2: Rise of Cultures

Post by fatduck »

Job done! :keke:

A KEX can have more than 1 mesh.
And skeleton can be in the same KEX as well!

See the above updated format!
Rheini wrote: EDIT: But somehow I can't comprehend in which order those structs are saved in the file :(

Code: Select all

  Struct VertPool {
    byte      DataType     <- base on this flag
    dword     ofsDataSize
    //<PoolData>           //see below
For the whole file:

Code: Select all

Header
  Faces
  VertPool
    -Base on DataType
  Bones
  Materials

  Faces
  VertPool
    -Base on DataType
  Bones
  Materials

  ...

Skeleton
No more Fatduck, no more FatImporter, Byebye everyone!
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: Settlers 2: Rise of Cultures

Post by Rheini »

EDIT: Yeah, the meshes are followed by the skeleton.
I uploaded some more files containing no mesh.

EDIT: What could be contained in the skeleton?
You do not have the required permissions to view the files attached to this post.
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: Settlers 2: Rise of Cultures

Post by Rheini »

And the skeleton is followed by the animations.
But I can't even figure out the skeleton parts, since they have variable length.
fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 94 times

Re: Settlers 2: Rise of Cultures

Post by fatduck »

I can't believe you can not figure them out!

Code: Select all

Settler2 skeleton Format

struct Header {
  dword       nLen
  Char[nLen]  Filename
  float_12    Matrix_3X4
  float       ??
  byte        NumMesh
}
byte          SkeletonID        //01
dword         nLen
Char[nLen]    RootName  
dword         nLen
Char[nLen]    MeshName
dword         NumBones

struct Bone {
  dword       nLen
  Char[nLen]  BoneName
  dword       TransformType
  float_3     PosXYZ            //TransformType:1,3,5
  float_5     ??                //TransformType:5
  float_4     RotXYZW           //TransformType:2,3,5
  float_16    Matrix_4X4
  dword       ParentID
}
And AFAIK there is not skeleton in animation files, purely animation data!
No more Fatduck, no more FatImporter, Byebye everyone!
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: Settlers 2: Rise of Cultures

Post by Rheini »

I already had the skeleton header, but thought that your transformType is some kind of count variable.
Could it be that this variable is a flag byte (bitwise coding)?

Btw, what is your way of importing that stuff into a 3D-program?

EDIT:
fatduck wrote:And AFAIK there is not skeleton in animation files, purely animation data!
Yeah, but I found a file containing a mesh and animations, but no skeleton :?

This is getting bigger and bigger, my binary template is already 180 lines long :D

Code: Select all

typedef struct String {
	uint size;
	char data[size];
};

typedef struct Matrix3x4 {
	float elems[12];
};

String filename;
Matrix3x4 uk;
float uk;
byte numMeshes;

struct Mesh {

String meshName;
String subMeshName;
uint numFaceIndices;
uint numVerts;
uint numVertPoolData;
uint numBones;
uint numMaterials;

struct Face {
	uint index1;
	uint index2;
	uint index3;
};
Face faces[numFaceIndices/3];

struct Vert {         //DataType = 0
	float xpos;
	float ypos;
	float zpos;
};
//Vert verts[numVerts];

struct Normal {       //DataType = 1
	float xnorm;
	float ynorm;
	float znorm;
};

struct Type2 { // DataType = 2
	float x;
	float y;
	float z;
};

//maybe vertex color
struct Unknown {      //DataType = 3
	byte uk[4];
};

struct UV {           //DataType = 4
	float u;
	float v;
};

struct Unknown2D {	// DataType = 5 and 6
	float u;
	float v;
};

struct Weight {       //DataType = 12
	float w1;
	float w2;
	float w3;
	float w4;
};

struct BoneID {       //DataType = 13
	byte weight1;
	byte weight2;
	byte weight3;
	byte weight4;
};

struct VertPool {
	byte DataType;
	uint ofsDataSize;

	switch(DataType)
	{
		case 0:
			Vert verts[numVerts];
			break;
		case 1:
			Normal normals[numVerts];
			break;
		case 2:
			Type2 types2[numVerts];
			break;
		case 3:
			Unknown uks[numVerts];
			break;
		case 4:
			UV uvs[numVerts];
			break;
		case 5:
		case 6:
			Unknown2D uk2ds[numVerts];
			break;
		case 12:
			Weight weights[numVerts];
			break;
		case 13:
			BoneID boneIDs[numVerts];
			break;
		default :
			Warning("Unknown VertPoolData type: %i", DataType);
	}
};

VertPool vertPools[numVertPoolData]<optimize=false>;
String boneNames[numBones]<optimize=false>;

struct Texture
{
	String slotName;
	String textureNames;
};

struct Material
{
	String materialName;
	String subMaterialName;
	uint uk1;
	uint numMatFaces; //for Multi-Material
	uint numTextures;
	Texture textures[numTextures]<optimize=false>;
};
Material materials[numMaterials]<optimize=false>;

};
Mesh meshes[numMeshes]<optimize=false>;

byte numSkeletons;

struct Bone
{
	String boneName;
	uint transformType;
	if(transformType == 1 || transformType == 3 || transformType == 5)
		float posXYZ[3];
	if(transformType == 5)
		float uk[5];
	if(transformType == 2 || transformType == 3 || transformType == 5)
		float rotXYZW[4];
	float matrix[16];
	int parentID;
};

struct Skeleton
{
	String rootName;
	String meshName;
	uint numBones;
	Bone bones[numBones]<optimize=false>;

};
Skeleton skeletons[numSkeletons]<optimize=false>;

byte numAnimations;

struct Animation
{
	String rootName;
	String animName;
	float uk;
};

Animation anims[numAnimations]<optimize=false>;
You do not have the required permissions to view the files attached to this post.
fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 94 times

Re: Settlers 2: Rise of Cultures

Post by fatduck »

Rheini wrote:I already had the skeleton header, but thought that your transformType is some kind of count variable.
Could it be that this variable is a flag byte (bitwise coding)?
No, Because type 5 got all the data from type 1,2, and bitflag 5 = 00000101 which shouldn't have type 2!

Rheini wrote:Btw, what is your way of importing that stuff into a 3D-program?
I use maxscript(3dsmax), simply because it is a powerful 3D ready scripting language, easily edit and have the result instantly...

Rheini wrote:EDIT:
fatduck wrote:And AFAIK there is not skeleton in animation files, purely animation data!
Yeah, but I found a file containing a mesh and animations, but no skeleton :?
I am almost finish everything include animation and skeleton! Only have some problem in root bone animation! The animation data are based on parent coordinate so it is very unusual for a model without skeleton! Maybe the animation data there are all in world coordinate(which I am having problem with).

By the way the KEX format should be like this:

Code: Select all

struct Header {
dword         nLen
Char[nLen]    Filename
float_12      Matrix_3X4
float         ??KEXScale
}
byte          numMesh
<Mesh Data>
byte          numSkeleton
<SkeletonData>
byte          numAnimation
<AnimationData>
That why all model, skeleton and animation are in same extenstion .KEX!!!
No more Fatduck, no more FatImporter, Byebye everyone!
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: Settlers 2: Rise of Cultures

Post by Rheini »

fatduck wrote:I use maxscript(3dsmax), simply because it is a powerful 3D ready scripting language, easily edit and have the result instantly...
Ah ok. Gotta write something to import it.
I am almost finish everything include animation and skeleton! Only have some problem in root bone animation! The animation data are based on parent coordinate so it is very unusual for a model without skeleton! Maybe the animation data there are all in world coordinate(which I am having problem with).
Unfortunately I'm not familiar with this stuff.
By the way the KEX format should be like this:

Code: Select all

struct Header {
dword         nLen
Char[nLen]    Filename
float_12      Matrix_3X4
float         ??KEXScale
}
byte          numMesh
<Mesh Data>
byte          numSkeleton
<SkeletonData>
byte          numAnimation
<AnimationData>
That why all model, skeleton and animation are in same extenstion .KEX!!!
Yep, I know, it is already contained in my template :)
fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 94 times

Re: Settlers 2: Rise of Cultures

Post by fatduck »

OK! I sovled my problem and had a look in that boat file!
The animation is simply unused, so no needs to care about it!
No more Fatduck, no more FatImporter, Byebye everyone!
Rheini
Moderator
Posts: 652
Joined: Wed Oct 18, 2006 9:48 pm
Location: Germany
Has thanked: 19 times
Been thanked: 46 times
Contact:

Re: Settlers 2: Rise of Cultures

Post by Rheini »

Wow, will you release your import script (mabye at least partly)?
Post Reply