.GHG files...how open it?

Post questions about game models here, or help out others!
Post Reply
Brickon
ultra-n00b
Posts: 5
Joined: Tue Jul 26, 2011 7:53 pm

.GHG files...how open it?

Post by Brickon » Tue Jul 26, 2011 8:38 pm

Hi, :)


I want to get the models from the game "Lego Star Wars 3".
I unpacked the .DAT files, and everything is fine with them.

I read in this ( viewtopic.php?f=10&t=4697&hilit=lego+star+wars&start=15 ) thread that the mesh data is stored in .hgp or .ghg files. i found .ghg and no .hgp files so I think the mesh data is stored in the .ghg files.


My question is:

How can I open/unpack/extract/convert a .ghg file?



I would be very thankful if I got an answer

-Brickon
:)


P.S:Sorry if my english is bad, I am not english. :)

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: 300 times

Re: .GHG files...how open it?

Post by finale00 » Tue Jul 26, 2011 9:13 pm

Post samples of your ghg files.

Brickon
ultra-n00b
Posts: 5
Joined: Tue Jul 26, 2011 7:53 pm

Re: .GHG files...how open it?

Post by Brickon » Wed Jul 27, 2011 10:46 am

The contents of this post was deleted because of possible forum rules violation.

RickyOs
n00b
Posts: 13
Joined: Mon Nov 29, 2010 5:54 pm
Been thanked: 5 times

Re: .GHG files...how open it?

Post by RickyOs » Wed Jul 27, 2011 5:24 pm

As far as I know the *nxg.ghg files are used in the pc-version of the games:

LEGO Harry Potter Years 1-4
LEGO Star Wars III
LEGO Pirates of the Caribbean

The files contain chunks in different versions. The data is stored in little
endian. The most interesting chunk is the MESH chunk. It contains the
vertices and indices next to some additional stuff.

MESH chunks in Version 0x04, 0x05, 0x2e and 0x2f crossed my way.

Maybe this helps (MESH in version 2e) (I have no Idea how to share!?!):

Code: Select all

struct MESH2E
{
    char              ChunkID[4];
    dword             dwVersion;
    dword             dwCntParts;
    dword             dwCntVertexLists;
    struct VertexList2E sVertexList[dwCntVertexLists];
    dword             dwUnknown;
    dword             dwUnknown;
    dword             dwUnknown;
    struct Indices    sIndices;
    struct Part2E     sPart[dwCntParts];
};

struct VertexList2E
{
    dword           dwUnknown;
    dword           dwUnknown;
    dword           dwCntVertices;
    dword           dwCntMeta;
    struct Meta     sMeta[dwCntMeta];
    struct Vertices sVertex[dwCntVertices];
    dword           dwUnknown;
};

struct Meta
{
    byte            bMajor;
    byte            bMinor;
    byte            bOffset;
};

struct Vertex
{
#if sMeta contains 0 3 0 // position
    float         x;
    float         y;
    float         z;
#elseif sMeta contains 0 6 0 // position
    half          x;
    half          y;
    half          z;
#endif
#if sMeta contains 1 8 n // normal at offset n
    byte          x; // 0 -> -1; 127 -> 0; 255 -> 1
    byte          y; // 0 -> -1; 127 -> 0; 255 -> 1
    byte          z; // 0 -> -1; 127 -> 0; 255 -> 1
    byte          ?;
#endif
#if sMeta contains 2 9 n // color at offset n
    byte          r; //signed
    byte          g; //signed 
    byte          b; //signed
    byte          a; //signed
#endif
#if sMeta contains 3 8 n // tangent at offset n
    byte          x; // 0 -> -1; 127 -> 0; 255 -> 1
    byte          y; // 0 -> -1; 127 -> 0; 255 -> 1
    byte          z; // 0 -> -1; 127 -> 0; 255 -> 1
    byte          ?;
#endif
#if sMeta contains 5 5 n // uvSet at offset n
    half          u;
    half          v;
#endif
#if sMeta contains 9 7 n // blendindices at offset n
    byte          bi1;
    byte          bi2;
    byte          bi3;
    byte          bi4;
#endif
#if sMeta contains 10 8 n // blendweights at offset n
    byte          bw1;
    byte          bw2;
    byte          bw3;
    byte          bw4;
#endif
}

struct Indices
{
    dword         dwIndices;
    dword         dwUnknown;
    word          wIndices[dwIndices];
};

struct Part2E
{
    ...
};
Sorry, time is up - I'll come back later...

Brickon
ultra-n00b
Posts: 5
Joined: Tue Jul 26, 2011 7:53 pm

Re: .GHG files...how open it?

Post by Brickon » Wed Jul 27, 2011 5:54 pm

:o That is more help than I expected, thank you! :keke:

But could you explain me how to use these informations (or is it a Script?),please? Sorry, I am a complete idiot at these things... :(


-Brickon

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: 300 times

Re: .GHG files...how open it?

Post by finale00 » Wed Jul 27, 2011 6:00 pm

It just describes the structure of each piece of data so you have some idea what's going on.
You typically use it as reference when going through the file cause there may be unknown information not captured explicitly.

In your case, it wouldn't apply directly as it is not the same version that is described, but it could be similar.

Immediately one notices that each chunk starts with some tag like "02UN", "OFNI", "HGXT", "SDNB", "HSEM", etc

Brickon
ultra-n00b
Posts: 5
Joined: Tue Jul 26, 2011 7:53 pm

Re: .GHG files...how open it?

Post by Brickon » Wed Jul 27, 2011 6:13 pm

And how can I use it to get the model? :)

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: 300 times

Re: .GHG files...how open it?

Post by finale00 » Wed Jul 27, 2011 7:16 pm

Write a script. A fully laid out format is a matter of translating into some language.

On the other hand, here you only have clues. I guess all you're interested in is a tool and not so much the process leading up to the tool? lol

Brickon
ultra-n00b
Posts: 5
Joined: Tue Jul 26, 2011 7:53 pm

Re: .GHG files...how open it?

Post by Brickon » Wed Jul 27, 2011 8:13 pm

Yes, I would prefer to use an already wrote script. I don't even know how to write a script... :D

RickyOs
n00b
Posts: 13
Joined: Mon Nov 29, 2010 5:54 pm
Been thanked: 5 times

Re: .GHG files...how open it?

Post by RickyOs » Thu Jul 28, 2011 11:30 am

I'm sorry, but I have no skills in python (blender) nor do I own max.

In whitch format do you need the meshes? What will you do with them?
There is much data in the files where I have no idea what it is used for.

This topic is really new to me. Maybe a more skilled or more experienced
person can write a script. I could provide an incomplete hsl-file for
HexWorkshop, but I found no way to handle the #if and #else segments (like I
have posted before) in a structure file.

If I find the time I'll try out blender...

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: 300 times

Re: .GHG files...how open it?

Post by finale00 » Thu Jul 28, 2011 2:50 pm

If I find the time I'll try out blender...
That may take some time just to figure out how to draw stuff in blender, in addition to python scripting.

You can try Sanae 3D, which exports in MQO format (open with metasequoia, free software). Also in python, but everything is set up for you so all you need to do is fill in the parser method. The tutorial I included in the first post should give you an idea how to get something working.

It's designed so that you can directly translate the specs almost line-by-line, where simple data types are read from the file and structs are defined by methods.

for example, taking one of the structs you wrote

Code: Select all

struct MESH2E
{
    char              ChunkID[4];
    dword             dwVersion;
    dword             dwCntParts;
    dword             dwCntVertexLists;
    struct VertexList2E sVertexList[dwCntVertexLists];
    dword             dwUnknown;
    dword             dwUnknown;
    dword             dwUnknown;
    struct Indices    sIndices;
    struct Part2E     sPart[dwCntParts];
};
would be translated as

Code: Select all

def part2E(self, dwCntParts):

	#definition of part2E struct
		
def vertexList2E(self, dwCntVertexLists):

  #definition of vertexList2E struct
		
def mesh2E(self):
	chunkID = self.inFile.read_char(4)				
	dwVersion = self.inFile.read_long()
	dwCntParts = self.inFile.read_long()
	dwCntVertexLists = self.inFile.read_long()
	self.vertexList2E(dwCntVertexLists)
	unk1 = self.inFile.read_long()
	unk2 = self.inFile.read_long()
	unk3 = self.inFile.read_long()
	self.indices()
	self.part2E(dwCntParts)

#main parser method
def parse_file(self):

	#stuff
	self.mesh2E() #parse mesh
	#more stuff
If I ever look at blender, I'll want to provide the same interface except add in some calls to blender's drawing methods so instead of exporting it would draw the model for you.

Eradicon
beginner
Posts: 27
Joined: Thu Feb 10, 2011 6:20 pm

Re: .GHG files...how open it?

Post by Eradicon » Tue May 27, 2014 3:09 pm

Will the script also work on .GHG files from Transformers The Game?

Post Reply