Sorry, I have been so busy that I haven't been on Daniweb in a week or two. Maybe when school settles down a little I'll look it this again.

oh... KK
crap... you were a very big help to me...
dang you school!!! XD

What you want Tcll, the conversion of the case?

How are you reading the values?

Cheers and Happy coding

I don't understand C++ <:/
like the only thing I can undersand in this is the vars...
and also the cases (barely), thanx to jcao

the function below is what seperates the differant data types for conversion...
(or so I believe)

but I'm still unsure about the expression '::'
I'm not sure how to use it in Py
(I did mention I wasn't the best python person) :P

ok...
I think it's been a while now...

BUUUUUMP!!!

This thread is very long, perhaps you should start a new one ?

This thread is very long, perhaps you should start a new one ?

I did...
but progress doesn't seem to kick-off in that one as much as this one...

if it were easy to move a group of people, then things would work out alot easier...

now, to make this post stick with the topic...

I'm trying to understand how to differentiate between the differant datatypes in the file...
I'm not talking about the 16bit to 32bit crap :P

I'm talking datatypes as in:
verts
normals
materials
colors
etc...

how do you find those (in the c++ code)

EDIT:
this should help me to actually get the start off on my full importer...

as far as I know, there are 4 steps to import the mdl0 file

1: Read the data
2: Seperate the data
3: Convert the data
4: send it to blender (the actual import process)

I currently have steps 1 and 3 almost completed...

the above info I'm asking for is for step 2...
and I have a thread over at blander forums to help me on step 4 :)

btw, thanx for the help all :)
you all were a very big help to me
(and am currently hoping for more help until I finish this)
thanx again
there alot of people that'll be happy when this is finished :D

Have you understood and converted this part yet?

for (int i = 0; i < 11; i++) {
		uint32_t ptr = BigUInt32(data, 16 + i * 4);

		if (ptr >= length)
			return false; // pointer is out of range

		if (ptr == 0)
			groupPtrs[i] = NULL;
		else
			groupPtrs[i] = data + ptr;
	}

	for (int i = 0; i < 11; i++) {
		if (groupPtrs[i] != NULL) {
			loadGroup(groupPtrs[i], i);
		}
	}

So groupPtrs is an array of 10 pointers to chars within the data.
After that it's just calling "loadGroup" for each pointer, and its index inside the array (1..10).

That index determines what data type it is.

You can see that in the loadGroup method.

honestly...
my cpu got taken away for a good month or so...

and honestly, right now, I'm not even supposed to be on it...
but I am *trollface*

anyways...
no...
I've looked over it so many times, it's not funny...
but I see it now, and thanx
I'll see what I can do on this :)

I think I see how this works...
but I'm not for certain... :/

I'm thinking if 'pointers = 9' then there are 9 groups;
and the index is the offset to the section in that group.

or basically saying:

group
    index

_
    _
    offset
    _

    _
    _

    _
    _
_
_
    _
    _

    _
    _
_

the procedure continued for the rest of the "9" groups

//data is an array of bytes, which contains the MDL0 files contents
//let's start loading the groups

for (int i = 0; i < 11; i++) {
		uint32_t ptr = BigUInt32(data, 16 + i * 4);
  //basically, reads the UINT value at data[16 + i*4], and assigns it to ptr.
  //ptr is a pointer to a group.

		if (ptr >= length)
			return false; // pointer is out of range
			/* you might want to raise an exception here.
			pointer out of range is bad.
			it means something went wrong.
   */
   
		if (ptr == 0) 
			groupPtrs[i] = NULL; //NULL = None
		else
			groupPtrs[i] = data + ptr;  //uh-oh, pointer arithmetic
			//but this is easier since we are only dealing with char/byte values
			
			//in C++, arrays identifiers are just pointers to the first element of the array
			//data is an array identifier
			
			//we know that ptr is the pointer to the group that you want to load
			//Meaning, if ptr = 4499, then that means the group that is to be loaded
			//is located at the 4499'th byte of data.
			//so then, (data + ptr) gives you the pointer to the location of the
			//4499'th byte of data!
	}

	for (int i = 0; i < 11; i++) {
		if (groupPtrs[i] != NULL) {
			loadGroup(groupPtrs[i], i);
		}
	}

Now, in Python, this can be loosely translated as:

groupPtrs = [None]*10
#assume data is the list where all the mdl0file is stored.
for i in range(11):
    ptr = BigUInt32(data, 16 + i * 4)  #I think we addressed BigUInt32 earlier.
	    
    if ptr >= len(data):
        return False
        #or raise IndexError("Index out of range.")
     
    if not ptr:
        groupPtrs[i] = None
    else:
        groupPtrs[i] = ptr  #there are no pointers in Python
        #so treat ptr just like a list index.
         
for i in range(11):
    if groupPtrs[i]:
        #loadGroup(groupPtrs[i], i)  This will *not* work.
        #I recommend rewriting loadGroup a little
        #so it takes these parameters:
        #(list data, index i)
        loadGroup(data, i)

Which can be further optimized as:

for i in range(11):
    group_i = BigUInt32(data, 16 + i * 4)
        
    if group_i >= len(data):
        raise IndexError("Index out of range.")
     
    if group_i:
        loadGroup(data, i)

If you need any help with the loadGroup method, I can help with it.

//data is an array of bytes, which contains the MDL0 files contents
//let's start loading the groups

for (int i = 0; i < 11; i++) {
		uint32_t ptr = BigUInt32(data, 16 + i * 4);
  //basically, reads the UINT value at data[16 + i*4], and assigns it to ptr.
  //ptr is a pointer to a group.

		if (ptr >= length)
			return false; // pointer is out of range
			/* you might want to raise an exception here.
			pointer out of range is bad.
			it means something went wrong.
   */
   
		if (ptr == 0) 
			groupPtrs[i] = NULL; //NULL = None
		else
			groupPtrs[i] = data + ptr;  //uh-oh, pointer arithmetic
			//but this is easier since we are only dealing with char/byte values
			
			//in C++, arrays identifiers are just pointers to the first element of the array
			//data is an array identifier
			
			//we know that ptr is the pointer to the group that you want to load
			//Meaning, if ptr = 4499, then that means the group that is to be loaded
			//is located at the 4499'th byte of data.
			//so then, (data + ptr) gives you the pointer to the location of the
			//4499'th byte of data!
	}

	for (int i = 0; i < 11; i++) {
		if (groupPtrs[i] != NULL) {
			loadGroup(groupPtrs[i], i);
		}
	}

Now, in Python, this can be loosely translated as:

groupPtrs = [None]*10
#assume data is the list where all the mdl0file is stored.
for i in range(11):
    ptr = BigUInt32(data, 16 + i * 4)  #I think we addressed BigUInt32 earlier.
	    
    if ptr >= len(data):
        return False
        #or raise IndexError("Index out of range.")
     
    if not ptr:
        groupPtrs[i] = None
    else:
        groupPtrs[i] = ptr  #there are no pointers in Python
        #so treat ptr just like a list index.
         
for i in range(11):
    if groupPtrs[i]:
        #loadGroup(groupPtrs[i], i)  This will *not* work.
        #I recommend rewriting loadGroup a little
        #so it takes these parameters:
        #(list data, index i)
        loadGroup(data, i)

Which can be further optimized as:

for i in range(11):
    group_i = BigUInt32(data, 16 + i * 4)
        
    if group_i >= len(data):
        raise IndexError("Index out of range.")
     
    if group_i:
        loadGroup(data, i)

If you need any help with the loadGroup method, I can help with it.

ok...
that really wasn't exactly my thoughs about it... :P
KK...

sure...
I guess I could use the help...

also...
what about that 2nd part of that function??

that just returns a number to that specific spot right??
or am I wrong there??

EDIT:
oh wait...
derp

I know what that does...
and you kinda explained it already...

ok...
that really wasn't exactly my thoughs about it... :P
KK...

sure...
I guess I could use the help...

also...
what about that 2nd part of that function??

that just returns a number to that specific spot right??
or am I wrong there??

EDIT:
oh wait...
derp

I know what that does...
and you kinda explained it already...

Any more parts that you need help on?

Any more parts that you need help on?

at this moment, no...
but keep in touch :)
there may be a string or something that I'll need...

or um...
do you have any knowledge of in-depth game dev??
eg: how materials compleatly work...

I'm into mdl0 materials right now and I don't understand why materials are split into 2 parts...

I currently have to stay undercover...
(familiy's on the lookout for me being on the cpu)
>_> <_<

so yea :P

KK so I think I get how this works...
took me long enough to generate a visual (in my head)

but yea...
so it starts off in the header...

after the identifier and the file size, comes the num of groups...

then the nodes offset before finally hitting the group offsets...
(based on the number of groups)

these offsets link the to the specific offsets in the relocation table...
(offsets linking to offsets that link to the specific data parts)

the only problem with this is that there isn't a number for the index offsets in the particular groups...

say we have 9 groups...
then we have 9 indexes in the header...
linking these indexes to the relocation table to get a number is easy for groups 1-8...
just take the offset in the first group (i1) and the offset in the 2nd group (i2) and subtract i1 from i2, then divide by 4...

num = (i2 - i1) /4

that'll give you a number to go by...
once it reaches 0, repeat the process for groups 2 and 3

but now what about group 9??

I'm guessing just take the first index in group 1 minus the group 9 offset, and divide that by 4 :/

or is there a better way than this??

I'll give you some hints,
in the C++ version, the mdl0 file is loaded as (pointer to) a char array, and you know char is basically an unsigned byte.
So just open the file in python, and for each character in there, convert it to an integer using ord() so you have an array of integers.
Then manipulate the file.

I finally understand what you mean by this <:D

so this is, to say the least, the way to get the entire file stored in a single var...

you've just madee me re-think my entire concept on this...

but, even though I've re-thought, I still don't have a way of making it work properly...

with how basic this is,
could you possibly give me a program in python that can convert mdl0 into obj??

I can at least get all of what I need from that and won't have to keep hitting up this thread... :/

to tell the truth, I'm tired of this thread...
I wish I could just know it and get on with it...
I'm gonna go now before I say any more crap <:/

could you possibly give me a program in python that can convert mdl0 into obj??

What do you mean by "obj"?

What do you mean by "obj"?

O.o
I am honestly surprised to hear you say that... o_o

the obj file format...

v X Y Z #vert
vn X Y Z #normal
vt X Y Z #UV
o object0 #object
f pt1 pt2 pt3 pt4 #face

the easiest file format there is :/

I thought you'd know... -_-

O.o
I am honestly surprised to hear you say that... o_o

the obj file format...

v X Y Z #vert
vn X Y Z #normal
vt X Y Z #UV
o object0 #object
f pt1 pt2 pt3 pt4 #face

the easiest file format there is :/

I thought you'd know... -_-

Oh, I don't know about the obj file format (or the mdl0 format), so it'll be your job to convert it. You've already been working on it, so keep going. If you run into any problems, just ask here.

Oh, I don't know about the obj file format (or the mdl0 format), so it'll be your job to convert it. You've already been working on it, so keep going. If you run into any problems, just ask here.

I know...
but I'd be doing a better job if I actually got the info I needed :/

right now the program just converts mdl0 to collada...

the obj format's much easier to learn than the collada format...

v, vn, vt values are all floats
f values are all ints

just see if you can't use the mdl0 code from will's converter (3rd post) to write a program in py that converts mdl0 to obj...

I wouldn't have to ask you for anything dealing with this anymore :)

but I might come back with the code for AIS (Pharrox's program)
this does the same thing, but on a much higher level... (bones and such)

wills only converts verts, normals, faces, and UV's
(the same data an obj file can handle)

v, vn, and vt = float(X) float(Y) float(Z)

(v 0.000000 0.000000 0.000000) this is a vert

f = int(P1) int(P2) int(P3) or int(P4)

(f 0000 0000 0000 0000) this is a square face

can you please do that for me <:/

gawd... look at how pathetic I'm being >_>

geeze...

3 forums on this and still nothing D:

something's wrong here :/

kk
hey...
got some new code here...
this line stumped me:

public const uint Length = 72U;

what does that mean??
I know it's a read-by, or data length thing...
but I don't get the '72U'

It says unsigned integer doesn't it? Length must be positive.

It says unsigned integer doesn't it? Length must be positive.

I really have no idea what it says...

I know brawl data is 32 bit or [4]
unless...
72's a multiple of 4 right...
I think I've just found my answer.

that was the first line in a function that deciphered a file header...

I think it reads 72 bytes, then splits them up.

//data is an array of bytes, which contains the MDL0 files contents
//let's start loading the groups

for (int i = 0; i < 11; i++) {
		uint32_t ptr = BigUInt32(data, 16 + i * 4);
  //basically, reads the UINT value at data[16 + i*4], and assigns it to ptr.
  //ptr is a pointer to a group.

		if (ptr >= length)
			return false; // pointer is out of range
			/* you might want to raise an exception here.
			pointer out of range is bad.
			it means something went wrong.
   */
   
		if (ptr == 0) 
			groupPtrs[i] = NULL; //NULL = None
		else
			groupPtrs[i] = data + ptr;  //uh-oh, pointer arithmetic
			//but this is easier since we are only dealing with char/byte values
			
			//in C++, arrays identifiers are just pointers to the first element of the array
			//data is an array identifier
			
			//we know that ptr is the pointer to the group that you want to load
			//Meaning, if ptr = 4499, then that means the group that is to be loaded
			//is located at the 4499'th byte of data.
			//so then, (data + ptr) gives you the pointer to the location of the
			//4499'th byte of data!
	}

	for (int i = 0; i < 11; i++) {
		if (groupPtrs[i] != NULL) {
			loadGroup(groupPtrs[i], i);
		}
	}

Now, in Python, this can be loosely translated as:

groupPtrs = [None]*10
#assume data is the list where all the mdl0file is stored.
for i in range(11):
    ptr = BigUInt32(data, 16 + i * 4)  #I think we addressed BigUInt32 earlier.
	    
    if ptr >= len(data):
        return False
        #or raise IndexError("Index out of range.")
     
    if not ptr:
        groupPtrs[i] = None
    else:
        groupPtrs[i] = ptr  #there are no pointers in Python
        #so treat ptr just like a list index.
         
for i in range(11):
    if groupPtrs[i]:
        #loadGroup(groupPtrs[i], i)  This will *not* work.
        #I recommend rewriting loadGroup a little
        #so it takes these parameters:
        #(list data, index i)
        loadGroup(data, i)

Which can be further optimized as:

for i in range(11):
    group_i = BigUInt32(data, 16 + i * 4)
        
    if group_i >= len(data):
        raise IndexError("Index out of range.")
     
    if group_i:
        loadGroup(data, i)

If you need any help with the loadGroup method, I can help with it.

KK...
I need to know a little more of what the (data, 16 + i * 4) part does...

I've figured out that that's an offset data in the relocation table...

Relocation offsets are 16 bytes in length.

but now what I need to know is
how does one go about finding where the offsets lead to??

I can put that in simpler terms if you want ;)

KK

I need whatever info can be given from this code:

Vertex MDL0File::loadVertex(const char* data, int offset, std::vector<int> fmt,
		bool hasNormal, bool hasColor, int unknown, int uv, int& outLength) {
	uint16_t vert = 0;
	uint16_t norm = 0;
	uint16_t color = 0;
	uint16_t uvs[8];

	int length = 0;

	// assuming all unknowns are one byte long for now.
	length += unknown;

	if (fmt[0] == 1) {
		vert = (unsigned char) data[offset + length];
		length += 1;
	} else {
		vert = BigUInt16(data, offset + length);
		length += 2;
	}

	if (hasNormal) {
		if (fmt[1] == 1) {
			norm = (unsigned char) data[offset + length];
			length += 1;
		} else {
			norm = BigUInt16(data, offset + length);
			length += 2;
		}
	}

	if (hasColor) {
		if (fmt[1 + hasNormal] == 1) {
			color = (unsigned char) data[offset + length];
			length += 1;
		} else {
			color = BigUInt16(data, offset + length);
			length += 2;
		}
	}

	for (int i = 0; i < uv; i++) {
		if (fmt[1 + hasNormal + hasColor + i] == 1) {
			uvs[i] = (unsigned char) data[offset + length];
			length += 1;
		} else {
			uvs[i] = BigUInt16(data, offset + length);
			length += 2;
		}
	}

	Vertex outvert;
	outvert.Set(vert, norm, color, uvs, uv);

	outLength = length;

	return outvert;
}

it converts polygon data based on specific info given from this function:

bool MDL0File::loadPolyGroup(const char* data, PolyGroup* group) {
	uint16_t vertexid = BigUInt16(data, 72);
	uint16_t normalid = BigUInt16(data, 74);
	uint16_t colorid = BigUInt16(data, 76);
	uint16_t texcoordid[8];
	for (int i = 0; i < 8; i++)
		texcoordid[i] = BigUInt16(data, 80 + 2 * i);

	uint16_t unknowncount = BigUInt16(data, 102);

	// find the start of the array format
	int loc = 104 + unknowncount * 2;
	while (data[loc] == 0) {
		loc++;
	}

	// read array format
	std::vector<int> fmt;
	bool normalfmt = false;
	bool colorfmt = false;
	int unknownfmt = 0;
	int uvfmt = 0;
	int tempfmt = 0;

	if (data[loc] != 0x08 && data[loc + 1] != 0x50)
		return false;

	tempfmt = data[loc + 5] & 3;
	if (tempfmt) {
		unknownfmt = 1;
	}
	tempfmt = (data[loc + 5] & 12) >> 2;
	if (tempfmt) {
		unknownfmt++;
	}
	tempfmt = (data[loc + 5] & 48) >> 4;
	if (tempfmt) {
		unknownfmt++;
	}
	tempfmt = (data[loc + 5] & 192) >> 6;
	if (tempfmt) {
		unknownfmt++;
	}

	tempfmt = (data[loc + 4] & 6) >> 1;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 4] & 24) >> 3;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 4] & 96) >> 5;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);

	if (data[loc + 6] != 0x08 && data[loc + 7] != 0x60)
		return false;

	tempfmt = data[loc + 11] & 3;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 11] & 12) >> 2;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 11] & 48) >> 4;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 11] & 192) >> 6;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = data[loc + 10] & 3;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 10] & 12) >> 2;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 10] & 48) >> 4;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 10] & 192) >> 6;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);

	if (data[loc + 16] != 0x08 && data[loc + 17] != 0x00)
		return false;

	colorfmt = data[loc + 20] & 3;
	normalfmt = (data[loc + 20] & 12) >> 2;
	uvfmt = (data[loc + 20] & 240) >> 4;

	// find the start of the data
	loc += 40;
	while (data[loc] == 0) {
		loc++;
	}

	// read data
	bool reading = true;
	do {
		char type = data[loc];
		loc++;
		switch (type) {
		case 0x30:
			loc += 4;
			break;
		case 0x20:
			loc += 4;
			break;
		case 0x28:
			loc += 4;
			break;
		case 0x98: {
			uint16_t count = BigUInt16(data, loc);
			loc += 2;

			if (options & LO_CONV_TO_TRIS) {
				int length;
				for (int i = 0; i < count - 2; i++) {
					Vertex p1, p2, p3;
					if (i % 2) {
						p3 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
								unknownfmt, uvfmt, length);
						loc += length;
						p2 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
								unknownfmt, uvfmt, length);
						loc += length;
						p1 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
								unknownfmt, uvfmt, length);
						loc -= length;
					} else {
						p1 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
								unknownfmt, uvfmt, length);
						loc += length;
						p2 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
								unknownfmt, uvfmt, length);
						loc += length;
						p3 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
								unknownfmt, uvfmt, length);
						loc -= length;
					}
					Triangle tri(p1, p2, p3);
					group->AddTriangle(tri);
				}
				loc += length * 2;
			} else {
				TriangleStrip strip;
				for (int i = 0; i < count; i++) {
					int length;
					strip.Add(loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length));
					loc += length;
				}
				strip.Lock();
				group->AddTriangleStrip(strip);
			}
		}
			break;
		case 0x90: {
			uint16_t count = BigUInt16(data, loc);
			loc += 2;

			for (int i = 0; i < count; i += 3) {
				int length;
				Vertex p1 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
						unknownfmt, uvfmt, length);
				loc += length;
				Vertex p2 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
						unknownfmt, uvfmt, length);
				loc += length;
				Vertex p3 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
						unknownfmt, uvfmt, length);
				loc += length;
				Triangle tri(p1, p2, p3);
				group->AddTriangle(tri);
			}
		}
			break;
		case 0xA0: {
			uint16_t count = BigUInt16(data, loc);
			loc += 2;

			if (options & LO_CONV_TO_TRIS) {
				int length;
				Vertex origin = loadVertex(data, loc, fmt, normalfmt, colorfmt,
						unknownfmt, uvfmt, length);
				loc += length;

				for (int i = 1; i < count - 1; i++) {

					Vertex p1 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length);
					loc += length;
					Vertex p2 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length);
					Triangle tri(origin, p1, p2);
					group->AddTriangle(tri);
				}
				loc += length;
			} else {
				int length;
				Vertex origin = loadVertex(data, loc, fmt, normalfmt, colorfmt,
						unknownfmt, uvfmt, length);
				loc += length;
				TriangleFan fan(origin);
				for (int i = 1; i < count; i++) {

					fan.Add(loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length));
					loc += length;
				}
				fan.Lock();
				group->AddTriangleFan(fan);
			}
		}
			break;
		case 0x80: {
			uint16_t count = BigUInt16(data, loc);
			loc += 2;

			if (options & LO_CONV_TO_TRIS) {
				for (int i = 0; i < count; i += 4) {
					int length;
					Vertex p1 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length);
					loc += length;
					Vertex p2 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length);
					loc += length;
					Vertex p3 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length);
					loc += length;
					Vertex p4 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length);
					loc += length;
					Triangle tri1(p1, p2, p3);
					Triangle tri2(p1, p3, p4);
					group->AddTriangle(tri1);
					group->AddTriangle(tri2);
				}
			} else {
				for (int i = 0; i < count; i += 4) {
					int length;
					Vertex p1 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length);
					loc += length;
					Vertex p2 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length);
					loc += length;
					Vertex p3 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length);
					loc += length;
					Vertex p4 = loadVertex(data, loc, fmt, normalfmt, colorfmt,
							unknownfmt, uvfmt, length);
					loc += length;
					Quad quad(p1, p2, p3, p4);
					group->AddQuad(quad);
				}
			}
		}
			break;
		case 0x00:
			reading = false;
			break;
		default:
			return false;
		}
	} while (reading);

	group->SetVertex(vertexid, &vertexGroups[vertexid]);

	if (normalid != 0xFFFF)
		group->SetNormal(normalid, &normalGroups[normalid]);

	if (colorid != 0xFFFF)
		group->SetColor(colorid, &colorGroups[colorid]);

	for (int i = 0; i < 8; i++) {
		if (texcoordid[i] != 0xFFFF) {
			group->AddUV(texcoordid[i], &uvGroups[texcoordid[i]]);
		}
	}

	group->Lock();

	return true;
}

I need as much info as possible,
and maybe even a hex representation model...

eg:
00 00 4B 80 FF FF D5 40 FF FF FF FF 00 00 1E 05
00 00 00 03 00 00 00 14 00 00 00 E0 00 00 00 80
00 00 00 A8 00 00 49 E0 00 00 49 E0 00 00 01 7C
00 00 26 05 00 00 00 00 00 00 98 AC 00 00 00 00
00 00 08 72 00 00 05 EC 00 00 00 00 FF FF FF FF
00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF

info
info

thanx in return :)

MAy be converting the c++ script to python wont be that easy. I just tried and i think is insane idea. whops!

Look why not write a python script to implement the same functionalities. May be the interfaces of this C++ will not be the same but at least will produce the same results.
:)

MAy be converting the c++ script to python wont be that easy. I just tried and i think is insane idea. whops!

Look why not write a python script to implement the same functionalities. May be the interfaces of this C++ will not be the same but at least will produce the same results.
:)

I'd like to yes...

now wut does the code do is wut I'm askin :P

Here's an explanation of the first one:

Vertex MDL0File::loadVertex(const char* data, int offset, std::vector<int> fmt,
		bool hasNormal, bool hasColor, int unknown, int uv, int& outLength) {
        
    /*  data is an array of chars (bytes), fmt is like a python list of int values
        forget about outLength, Python should return it as part of a tuple
        I would make data look like this: ["\x00", "\x49", "\0x39"...
    */
	uint16_t vert = 0;    //convert these to python like this:  vert = 0
	uint16_t norm = 0;
	uint16_t color = 0;
	uint16_t uvs[8];   //uvs = [0]*8

	int length = 0;  //length = 0

	// assuming all unknowns are one byte long for now.
	length += unknown;

	if (fmt[0] == 1) {
		vert = (unsigned char) data[offset + length];  //Basically do this:
                                                       //vert = ord(data[offset + length])
		length += 1;
	} else {
		vert = BigUInt16(data, offset + length);    //You have this function written?
		length += 2;
	}

	if (hasNormal) {
		if (fmt[1] == 1) {
			norm = (unsigned char) data[offset + length];  //same as above
			length += 1;
		} else {
			norm = BigUInt16(data, offset + length);  //same as above
			length += 2;
		}
	}

	if (hasColor) {
		if (fmt[1 + hasNormal] == 1) {
			color = (unsigned char) data[offset + length];
			length += 1;
		} else {
			color = BigUInt16(data, offset + length);
			length += 2;
		}
	}

	for (int i = 0; i < uv; i++) {
		if (fmt[1 + hasNormal + hasColor + i] == 1) {
			uvs[i] = (unsigned char) data[offset + length];
			length += 1;
		} else {
			uvs[i] = BigUInt16(data, offset + length);
			length += 2;
		}
	}

	Vertex outvert;  //Do you have this class written?
	outvert.Set(vert, norm, color, uvs, uv);

	outLength = length;  //Forget about this

	return outvert;
    //do this:  return outvert, length
}

Here's an explanation of the first one:

Vertex MDL0File::loadVertex(const char* data, int offset, std::vector<int> fmt,
		bool hasNormal, bool hasColor, int unknown, int uv, int& outLength) {
        
    /*  data is an array of chars (bytes), fmt is like a python list of int values
        forget about outLength, Python should return it as part of a tuple
        I would make data look like this: ["\x00", "\x49", "\0x39"...
    */
	uint16_t vert = 0;    //convert these to python like this:  vert = 0
	uint16_t norm = 0;
	uint16_t color = 0;
	uint16_t uvs[8];   //uvs = [0]*8

	int length = 0;  //length = 0

	// assuming all unknowns are one byte long for now.
	length += unknown;

	if (fmt[0] == 1) {
		vert = (unsigned char) data[offset + length];  //Basically do this:
                                                       //vert = ord(data[offset + length])
		length += 1;
	} else {
		vert = BigUInt16(data, offset + length);    //You have this function written?
		length += 2;
	}

	if (hasNormal) {
		if (fmt[1] == 1) {
			norm = (unsigned char) data[offset + length];  //same as above
			length += 1;
		} else {
			norm = BigUInt16(data, offset + length);  //same as above
			length += 2;
		}
	}

	if (hasColor) {
		if (fmt[1 + hasNormal] == 1) {
			color = (unsigned char) data[offset + length];
			length += 1;
		} else {
			color = BigUInt16(data, offset + length);
			length += 2;
		}
	}

	for (int i = 0; i < uv; i++) {
		if (fmt[1 + hasNormal + hasColor + i] == 1) {
			uvs[i] = (unsigned char) data[offset + length];
			length += 1;
		} else {
			uvs[i] = BigUInt16(data, offset + length);
			length += 2;
		}
	}

	Vertex outvert;  //Do you have this class written?
	outvert.Set(vert, norm, color, uvs, uv);

	outLength = length;  //Forget about this

	return outvert;
    //do this:  return outvert, length
}

thanx

now I just need to know where it reads from in the 2nd one

thanx

now I just need to know where it reads from in the 2nd one

stupid time limit...
more like stupid admins for putting a limit on the editing D:<
I HATE TIME LIMITS!!!


KK...
seems I really need to know the 2nd one :/
the 1st one just reads the point data from a length
specified from the formats from the 2nd one...

I need to figure that out before looking at the first...

I already know how most of the data works,
but I don't know the important things...

hey...
this is basically what I need explained :/

uint16_t vertexid = BigUInt16(data, 72);
	uint16_t normalid = BigUInt16(data, 74);
	uint16_t colorid = BigUInt16(data, 76);
	uint16_t texcoordid[8];
	for (int i = 0; i < 8; i++)
		texcoordid[i] = BigUInt16(data, 80 + 2 * i);

	uint16_t unknowncount = BigUInt16(data, 102);

	// find the start of the array format
	int loc = 104 + unknowncount * 2;
	while (data[loc] == 0) {
		loc++;
	}

	// read array format
	std::vector<int> fmt;
	bool normalfmt = false;
	bool colorfmt = false;
	int unknownfmt = 0;
	int uvfmt = 0;
	int tempfmt = 0;

	if (data[loc] != 0x08 && data[loc + 1] != 0x50)
		return false;

	tempfmt = data[loc + 5] & 3;
	if (tempfmt) {
		unknownfmt = 1;
	}
	tempfmt = (data[loc + 5] & 12) >> 2;
	if (tempfmt) {
		unknownfmt++;
	}
	tempfmt = (data[loc + 5] & 48) >> 4;
	if (tempfmt) {
		unknownfmt++;
	}
	tempfmt = (data[loc + 5] & 192) >> 6;
	if (tempfmt) {
		unknownfmt++;
	}

	tempfmt = (data[loc + 4] & 6) >> 1;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 4] & 24) >> 3;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 4] & 96) >> 5;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);

	if (data[loc + 6] != 0x08 && data[loc + 7] != 0x60)
		return false;

	tempfmt = data[loc + 11] & 3;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 11] & 12) >> 2;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 11] & 48) >> 4;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 11] & 192) >> 6;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = data[loc + 10] & 3;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 10] & 12) >> 2;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 10] & 48) >> 4;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);
	tempfmt = (data[loc + 10] & 192) >> 6;
	if (tempfmt)
		fmt.push_back(tempfmt - 1);

	if (data[loc + 16] != 0x08 && data[loc + 17] != 0x00)
		return false;

	colorfmt = data[loc + 20] & 3;
	normalfmt = (data[loc + 20] & 12) >> 2;
	uvfmt = (data[loc + 20] & 240) >> 4;

	// find the start of the data
	loc += 40;
	while (data[loc] == 0) {
		loc++;
	}

took me quite a while to find that btw :/

Here you go:

uint16_t vertexid = BigUInt16(data, 72);
uint16_t normalid = BigUInt16(data, 74);
uint16_t colorid = BigUInt16(data, 76);  //You have these functions, right?
//Basically takes the Unsigned Int16 values at locations of data+72, +74, etc
//(unsigned uint16 values are 2 bytes big)


uint16_t texcoordid[8];  //create an array of 8 Unsigned Int16 values (like an int list in Python)
for (int i = 0; i < 8; i++)  //for i in range(8):
	texcoordid[i] = BigUInt16(data, 80 + 2 * i);  //Same function

uint16_t unknowncount = BigUInt16(data, 102);  //Also the same function as above

// find the start of the array format
int loc = 104 + unknowncount * 2;  //Self explanatory
while (data[loc] == 0) {
	loc++;  //loc+= 1,    increases index loc until the byte at that index is not 0
	//Then loc will be the index of the start of the array
}

// read array format
std::vector<int> fmt;  //like an int list
bool normalfmt = false;
bool colorfmt = false;
int unknownfmt = 0;
int uvfmt = 0;
int tempfmt = 0;

if (data[loc] != 0x08 && data[loc + 1] != 0x50)  //if data[loc] != 0x08 and data[loc+1] != 0x50:
	return false;

tempfmt = data[loc + 5] & 3;  //Same in Python
if (tempfmt) {
	unknownfmt = 1;
}
tempfmt = (data[loc + 5] & 12) >> 2;  //Also exactly the same in Python, don't change this
if (tempfmt) {
	unknownfmt++;  //unknownfmt += 1
}
tempfmt = (data[loc + 5] & 48) >> 4;
if (tempfmt) {
	unknownfmt++;
}
tempfmt = (data[loc + 5] & 192) >> 6;
if (tempfmt) {
	unknownfmt++;
}

tempfmt = (data[loc + 4] & 6) >> 1;
if (tempfmt)
	fmt.push_back(tempfmt - 1);
tempfmt = (data[loc + 4] & 24) >> 3;
if (tempfmt)
	fmt.push_back(tempfmt - 1);
tempfmt = (data[loc + 4] & 96) >> 5;
if (tempfmt)
	fmt.push_back(tempfmt - 1);

if (data[loc + 6] != 0x08 && data[loc + 7] != 0x60)  //fyi && means python's and
	return false;

tempfmt = data[loc + 11] & 3;  //don't change &, both Python and C++ have this operator
if (tempfmt)
	fmt.push_back(tempfmt - 1);
tempfmt = (data[loc + 11] & 12) >> 2; //don't change >> or << either
if (tempfmt)
	fmt.push_back(tempfmt - 1);  //push_back is exactly like Python's list.append, I think
tempfmt = (data[loc + 11] & 48) >> 4;
if (tempfmt)
	fmt.push_back(tempfmt - 1);
tempfmt = (data[loc + 11] & 192) >> 6;
if (tempfmt)
	fmt.push_back(tempfmt - 1);
tempfmt = data[loc + 10] & 3;
if (tempfmt)
	fmt.push_back(tempfmt - 1);
tempfmt = (data[loc + 10] & 12) >> 2;
if (tempfmt)
	fmt.push_back(tempfmt - 1);
tempfmt = (data[loc + 10] & 48) >> 4;
if (tempfmt)
	fmt.push_back(tempfmt - 1);
tempfmt = (data[loc + 10] & 192) >> 6;
if (tempfmt)
	fmt.push_back(tempfmt - 1);

if (data[loc + 16] != 0x08 && data[loc + 17] != 0x00)
	return false;

colorfmt = data[loc + 20] & 3;
normalfmt = (data[loc + 20] & 12) >> 2;
uvfmt = (data[loc + 20] & 240) >> 4;

// find the start of the data
loc += 40;
while (data[loc] == 0) {
	loc++;  //see above, does similar
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.