0

kk
that's still a little confusing :/

I'm trying to figure out the data of this object:

header:
00 00 04 C0 FF FE 67 A0 00 00 00 0F 00 00 54 00 
00 00 00 02 00 00 00 15 00 00 00 E0 00 00 00 80 
00 00 00 68 00 00 03 60 00 00 03 60 00 00 01 3C 
00 00 2E 00 00 00 00 00 00 01 0D F4 00 00 00 04 
00 00 00 C3 00 00 00 89 00 04 00 04 00 00 FF FF 
00 04 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
00 00 00 64 

weights:
            00 00 00 00 

shader instructions:
                        00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 08 50 00 00 54 00 
08 60 00 00 00 02 10 00 00 10 08 00 00 00 15 00 
08 70 41 37 70 09 08 80 C8 24 12 09 08 90 04 82 
41 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
I assume this is padding (between header and data offset)
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

polygons: (data offset + 36)
98 00 18 4B 22 00 4B 52 29 00 52 21 21 00 21 35 
25 00 35 34 34 00 34 2E 2E 00 2E 33 33 00 33 30 
30 00 30 41 3E 00 41 31 31 00 31 40 2E 00 40 32 
32 00 32 3F 3D 00 3F 3E 3C 00 3E 37 36 00 37 3D 
3B 00 3D 3C 3A 00 3C 24 24 00 24 25 25 00 25 0D 
0D 00 0D 16 16 00 16 0C 0C 00 0C 17 17 00 17 14 
14 00 14 98 00 12 4F 4B 00 4F 51 4D 00 51 2F 2F 
00 2F 12 12 00 12 11 11 00 11 10 10 00 10 19 19 
00 19 1A 1A 00 1A 18 18 00 18 05 05 00 05 06 06 
00 06 00 00 00 00 03 03 00 03 04 04 00 04 0C 0C 
00 0C 07 07 00 07 14 14 00 14 13 13 00 13 98 00 
10 4B 22 00 4B 21 21 00 21 23 23 00 23 20 20 00 
20 1F 1F 00 1F 1D 1D 00 1D 1C 1C 00 1C 1E 1E 00 
1E 2B 2B 00 2B 2C 2C 00 2C 2A 2A 00 2A 29 29 00 
29 1B 1B 00 1B 26 26 00 26 16 16 00 16 25 25 00 
25 98 00 0C 20 20 00 20 45 42 00 45 1D 1D 00 1D 
46 43 00 46 1E 1E 00 1E 39 1F 00 39 36 35 00 36 
37 36 00 37 38 37 00 38 3A 38 00 3A 26 26 00 26 
25 25 00 25 98 00 0A 05 05 00 05 01 01 00 01 00 
00 00 00 02 02 00 02 04 04 00 04 08 08 00 08 07 
07 00 07 09 09 00 09 13 13 00 13 15 15 00 15 98 
00 09 01 01 00 01 0E 0E 00 0E 02 02 00 02 0F 0F 
00 0F 08 08 00 08 48 45 00 48 0A 0A 00 0A 4D 49 
00 4D 4A 47 00 4A 98 00 08 30 30 00 30 11 11 00 
11 31 31 00 31 19 19 00 19 32 32 00 32 28 28 00 
28 3E 3C 00 3E 3D 3B 00 3D 98 00 08 39 1F 00 39 
46 43 00 46 37 36 00 37 45 42 00 45 44 41 00 44 
22 22 00 22 34 34 00 34 21 21 00 21 98 00 07 1E 
1E 00 1E 36 35 00 36 2C 2C 00 2C 38 37 00 38 2D 
2D 00 2D 26 26 00 26 29 29 00 29 98 00 06 19 19 
00 19 18 18 00 18 28 28 00 28 27 27 00 27 3D 3B 
00 3D 24 24 00 24 98 00 06 4A 47 00 4A 49 46 00 
49 0A 0A 00 0A 0B 0B 00 0B 09 09 00 09 15 15 00 
15 98 00 06 44 41 00 44 34 34 00 34 43 40 00 43 
42 3F 00 42 37 36 00 37 41 3E 00 41 98 00 05 35 
25 00 35 52 29 00 52 2E 2E 00 2E 50 4C 00 50 4E 
4A 00 4E 98 00 05 24 24 00 24 06 06 00 06 0D 0D 
00 0D 03 03 00 03 0C 0C 00 0C 98 00 05 3C 3A 00 
3C 25 25 00 25 3B 39 00 3B 3A 38 00 3A 37 36 00 
37 98 00 04 3F 3D 00 3F 37 36 00 37 40 2E 00 40 
41 3E 00 41 98 00 04 4F 4B 00 4F 2F 2F 00 2F 4E 
4A 00 4E 2E 2E 00 2E 98 00 04 2F 2F 00 2F 11 11 
00 11 2E 2E 00 2E 30 30 00 30 98 00 04 18 18 00 
18 06 06 00 06 27 27 00 27 24 24 00 24 98 00 04 
4D 49 00 4D 48 45 00 48 4C 48 00 4C 47 44 00 47 
98 00 04 48 45 00 48 0F 0F 00 0F 47 44 00 47 0E 
0E 00 0E 98 00 04 45 42 00 45 20 20 00 20 22 22 
00 22 21 21 00 21 98 00 04 41 3E 00 41 42 3F 00 
42 33 33 00 33 34 34 00 34 90 00 12 17 17 00 17 
1B 1B 00 1B 16 16 00 16 49 46 00 49 15 15 00 15 
0B 0B 00 0B 0A 0A 00 0A 09 09 00 09 08 08 00 08 
2D 2D 00 2D 29 29 00 29 2C 2C 00 2C 37 36 00 37 
44 41 00 44 43 40 00 43 37 36 00 37 3C 3A 00 3C 
3B 39 00 3B 00 00 00 00 00 00 00 00 00 00 00 00

the polygons are the trickiest part,
and I'm haing a heck of a time trying to read that confusing code I posted earlier

basically, the points of each polygon type are different sizes for each object
the size is specified in the header in some form that I am unsure of :/

that part of the code I posted is (I believe) what returns the correct data...

the polygon types are:

0x20 - Position matrix
0x28 - Normal matrix
0x30 - Texture matrix
0x38 - Light matrix
^(usually len(4))

0x80 - Quads
0x90 - Triangles
0x98 - Tristrip
0xA0 - Trian
0xA8 - Lines
0xB0 - Linestrip
0xB8 - Points

as specified in the first polygon:

98 00 18 #is a tristrip with a point list of 24
4B 22 00 4B 
52 29 00 52 
21 21 00 21 
35 25 00 35 
34 34 00 34 
2E 2E 00 2E 
33 33 00 33 
30 30 00 30 
41 3E 00 41 
31 31 00 31 
40 2E 00 40 
32 32 00 32 
3F 3D 00 3F 
3E 3C 00 3E 
37 36 00 37 
3D 3B 00 3D 
3C 3A 00 3C 
24 24 00 24 
25 25 00 25 
0D 0D 00 0D 
16 16 00 16 
0C 0C 00 0C 
17 17 00 17 
14 14 00 14

the points vary in length depending on the object being looked at
(all points for any polygon in the above object have a lengh of 4)

but what I need to know is how to find that length...
can you help??

yea...
the entire thing about this thread hes changed...
it's not really so much conversion anymore...
I need the stuff explained to me on how the code works :/

sry I failed to mention that earlier <:|

Edited by Tcll: n/a

0

and I'm haing a heck of a time trying to read that confusing code I posted earlier

It would be nice if you told us which parts of the code you don't understand. Reading the code is essential, in my opinion, to understanding how the data works.

the points vary in length depending on the object being looked at
(all points for any polygon in the above object have a lengh of 4)

From what I can see in the C++ code, it seems that length is always 4.

0

here's another polygon

98 00 08 
06 24 04 74 04 4B 00 00 C3 
06 24 04 75 04 4C 00 00 C2 
00 1E 04 73 04 4A 00 00 C1 
06 24 04 77 04 4E 00 00 C5 
03 21 04 78 04 4F 00 00 C6 
03 21 04 8E 04 62 00 00 DF 
0C 2A 04 F2 04 C3 00 01 44 
12 30 05 87 05 50 00 01 E3

see what I mean :/

it's only len(4) for 20, 28, 30, and 38
I think they may be offsets, but I'm not sure...
(not there yet)

and I posted the part of the function I didn't understand already... :/

0

and I posted the part of the function I didn't understand already... :/

I posted an explanation of that part (in the comments).
Are there any specific parts that you need clarification one on?
It's easier for me to explain the code, and from the
code you can probably figure out the data structure.

Also, can you attach an example data file?

Edited by jcao219: n/a

0

I posted an explanation of that part (in the comments).
Are there any specific parts that you need clarification one on?
It's easier for me to explain the code, and from the
code you can probably figure out the data structure.

you're talking about the entire code right??
look at the very first post of this thread for that...

EDIT:
or if you're talking about the "full code" as in the function...
it's the 2nd function in this post: http://www.daniweb.com/forums/post1425660.html#post1425660

Edited by Tcll: n/a

0

I'm talking about the code here http://www.daniweb.com/forums/post1426521.html#post1426521 (explained in the comments).

oh... ah... kk
yea... I was confused :P

I just need to know like...
like the steps it takes to convert the data...

like...
what does the code "do"

IDK how much furthur I can go with explaining what I need...
plus I'm on niquil right now DX

0

like...
what does the code "do"

To figure out what the code does, unfortunately, you have to read and study the code ;)

If you need trouble figuring out what specific parts of the code mean, I can help you with that.

0

To figure out what the code does, unfortunately, you have to read and study the code ;)

If you need trouble figuring out what specific parts of the code mean, I can help you with that.

I've been trying to...

it's that large block of if statments that keeps confusing me...

I have a different method on reading the file from this method...
since this one accesses the list of bytes at specific locations
mine just simply reads the bytes from the file

anyways...

it's the parts like '(data[loc + 5] & 12) >> 2;'
what offset is that??

or like how does that work to find the point length and contents??

and thanx for being here :)

Edited by Tcll: n/a

0


it's the parts like '(data[loc + 5] & 12) >> 2;'
what offset is that??

Well in the code you first see this:

uint16_t unknowncount = BigUInt16(data, 102);

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

So it reads a 2-byte integer value at offset 102, and then multiplies that value by 2, then adds 104, setting that to the variable "loc"

Then, loc is incremented until it becomes an offset to something that isn't 0x00 (again, read the code, it's hard to put it in sentences)

Now you can see what: tempfmt = (data[loc + 5] & 12) >> 2; means.

Apparently loc is the offset to the start of the "array format." I'm not sure what that means, but it seems to vary for each data file.

Edited by jcao219: n/a

0

KK...

so the start of the polygons == loc

what does the rest of that do exactly...
I don't think my math is correct :S

Edited by Tcll: n/a

0

KK...

so the start of the polygons == loc

what does the rest of that do exactly...
I don't think my math is correct :S

Well pretty much unknownfmt gets incremented each time tempfmt is true, then eventually tempfmt is put into a collection of integer.

(It's much easier to explain specific parts of the code)

EDIT:

I think that the loadVertex method determines the length, now that I look at it.

Edited by jcao219: n/a

0

Well pretty much unknownfmt gets incremented each time tempfmt is true, then eventually tempfmt is put into a collection of integer.

(It's much easier to explain specific parts of the code)

(offset & 12) >> 2;
^what does that mean??

offset and 12 is greater than 2??
I don't get it...

and unknownfmt is the weights btw :P
apperently William didn't know that...

0

">>" operator is the right shift bitwise operation.

It should be the same in C++/Python.

For more information: http://en.wikipedia.org/wiki/Arithmetic_shift

I think this is the most interesting part:

// 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);

Edited by jcao219: n/a

0

thanx...

that that part you posted is simple...
it just does a specific type or reading and then
sends certain variable data to the loadVertex() function

I've figured that out back when I was working on Melee's dat files...
images: http://picasaweb.google.com/tcll5850/Progress#

I'm trying to find out how to get that var data

so thanx again for the page :P
(I was lazy and didn't think of it... I know)
^then again, I'm talking on 5 threads at once here XD

that's how progress get's done though :D

Edited by Tcll: n/a

0

KK...

so I finally figured out a replacement method to understand the '>>'
(your notes didn't really help)

anyways...
'>>' == '/2**'
'<<' == '*2**'

but now I need to understand the '&'

'&' == ??

apparently I wasn't taught those back in skool >_>

Edited by Tcll: n/a

0

KK...

so I finally figured out a replacement method to understand the '>>'
(your notes didn't really help)

anyways...
'>>' == '/2**'
'<<' == '*2**'

but now I need to understand the '&'

'&' == ??

apparently I wasn't taught those back in skool >_>

that means AND
I've said this over and over,

3 >> 5 in C++ is the same as 3 >> 5 in Python.

64 & 39 in C++ is the exact same in Python.

You don't need to rewrite it as /2** or *2**, it only makes it slower.

Both Python and C++ were influenced by C, so their syntaxes don't change.
Write "&" and ">>" or "<<" in Python, it does the exact same thing as what it means in C++.

Besides,
'>>' == '/2**'
'<<' == '*2**' aren't always true.

-1 >> 1 = -1
-1 /2**1 = -0.5 (rounding to nearest whole number) = 0

Edited by jcao219: n/a

0

that means AND
I've said this over and over,

3 >> 5 in C++ is the same as 3 >> 5 in Python.

64 & 39 in C++ is the exact same in Python.

You don't need to rewrite it as /2** or *2**, it only makes it slower.

Both Python and C++ were influenced by C, so their syntaxes don't change.
Write "&" and ">>" or "<<" in Python, it does the exact same thing as what it means in C++.

no no no...
that's not what I ment at all

I know not to write *2** and such...
I didn't know what thos things did before...
that's all you had to tell me was /2** or *2**

IDK what & does and I'd like to know so
I know how the code works so I can re-write it...

will's code is way longer than it needs to be for one,
and I'm trying to write my own code that does
the same thing much more efficiently...

at least now I understand what >> does...
but now I need to understand what & does...

I know I can use it in Py as it is already...
there's just a few things IDK about coding yet...
(such as classes)
and I'm trying to figure them out :/

0

uugh...
I need a solution real fast :/
how could I convert this:

uint16_t uvs[8];

I've gotten it down to uvs[8],
but I don't think Py will define a var like that...
but then again, IDK...

there's another part too:

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;
		}
	}

I've gotten it down to:

for i in range(uv):
                            if fmt[3 + hasNormal + hasColor + i] == 1: uvs[i] = ui(fr.read(1)); length += 1
                            else: uvs[i] = ui(fr.read(2)); length += 2

but yea...
still a few parts that won't work :/

btw, you'll notice I've changed it to fmt[3 ...
the length of the fmt list is 3

I think he may have gotten a little lazy with the code...
which is prbly why it doesn't work for every model :/

anyways
just need help on that :P

0

also...
would there be an easier way to do this:

#temporary code:
                    fr.seek(objects_list+ui(offset[12:16])+attr_offset+2, 0)
                    data = []
                    while len(data) != 40: data.append(fr.read(1).encode('hex'))
                    
                    #Will's block (translated from C++ to Py)
                    fmt = []
                    normalfmt = 0
                    colorfmt = 0
                    unknownfmt = 0
                    uvfmt = 0
                    tempfmt = 0

                    if (data[0:1] == '0850'): #contents == vtx_des1
                        if (ui(data[5]) & 3) > 0: unknownfmt+=1
                        if ((ui(data[5]) & 12) >> 2) > 0: unknownfmt+=1
                        if ((ui(data[5]) & 48) >> 4) > 0: unknownfmt+=1
                        if ((ui(data[5]) & 192) >> 6) > 0: unknownfmt+=1
                        if ((ui(data[4]) & 6) >> 1) > 0: fmt.append(tempfmt - 1)
                        if ((ui(data[4]) & 24) >> 3) > 0: fmt.append(tempfmt - 1)
                        if ((ui(data[4]) & 96) >> 5) > 0: fmt.append(tempfmt - 1)

                    if (data[6:7] == '0860'): #contents == vtx_des2
                        if (ui(data[11]) & 3) > 0: fmt.append(tempfmt - 1)
                        if ((ui(data[11]) & 12) >> 2) > 0: fmt.append(tempfmt - 1)
                        if ((ui(data[11]) & 48) >> 4) > 0: fmt.append(tempfmt - 1)
                        if ((ui(data[11]) & 192) >> 6) > 0: fmt.append(tempfmt - 1)
                        if (ui(data[10]) & 3) > 0: fmt.append(tempfmt - 1)
                        if ((ui(data[10]) & 12) >> 2) > 0: fmt.append(tempfmt - 1)
                        if ((ui(data[10]) & 48) >> 4) > 0: fmt.append(tempfmt - 1)
                        if ((ui(data[10]) & 192) >> 6) > 0: fmt.append(tempfmt - 1)

                    if (data[16:17] == '0800'):
                        colorfmt = ui(data[20]) & 3
                        normalfmt = (ui(data[20]) & 12) >> 2
                        uvfmt = (ui(data[20]) & 240) >> 4
                        
                    #end Will's block

the code works perfectly btw ;)

0

uugh...
I need a solution real fast :/
how could I convert this:

uint16_t uvs[8];

Just do something like:

uvs = [None]*8

Also this part of your code: uvs[i] = ui(fr.read(1)) may not work.
The data is unsigned char, I don't think ui() is the one to use (which I guess stands for unsigned integer).
The uvs[i] = ui(fr.read(2)) also might not work, the data is a 16bit integer, but I'm not sure.

Can we see your ui function?

Edited by jcao219: n/a

0

Just do something like:

uvs = [None]*8

Also this part of your code: uvs[i] = ui(fr.read(1)) may not work.
The data is unsigned char, I don't think ui() is the one to use (which I guess stands for unsigned integer).
The uvs[i] = ui(fr.read(2)) also might not work, the data is a 16bit integer, but I'm not sure.

Can we see your ui function?

int(this.encode('hex'),16)

^that's all
I just made it simpler is all :P

but is that how you define a len(8) array??
I should've mention'd that in my last post >_>

uvs[8] is an array len(8)
^how can I do that in py...

sry bout re-stating that <:D

Edited by Tcll: n/a

0

int(this.encode('hex'),16)

^that's all
I just made it simpler is all :P

but is that how you define a len(8) array??
I should've mention'd that in my last post >_>

uvs[8] is an array len(8)
^how can I do that in py...

sry bout re-stating that <:D

uvs = [None]*8

Or something similar.

0
uvs = [None]*8

Or something similar.

KK thanx

and I thought that's what (unsigned char) did :/
(get an unsigned int and write it as a char)

IDK :P

here's my code before editing with the edits you've told me:

def facepoint(fmt,hasNormal,hasColor,unknown,uv,outLength):
                        vert = 0
                        norm = 0
                        color = 0
                        uvs[8]
                        length = unknown

                        if fmt[0] == 1: vert = ui(fr.read(1)); length += 1
                        else: vert = ui(fr.read(2)); length += 2
                        
                        if hasNormal:
                            if fmt[1] == 1: norm = ui(fr.read(1)); length += 1
                            else: norm = ui(fr.read(2)); length += 2
                                
                        if hasColor:
                            if fmt[1 + hasNormal] == 1: color = ui(fr.read(1)); length += 1
                            else: color = ui(fr.read(2)); length += 2
                            
                        for i in range(uv):
                            if fmt[1 + hasNormal + hasColor + i] == 1: uvs[i] = ui(fr.read(1)); length += 1
                            else: uvs[i] = ui(fr.read(2)); length += 2
                            
                        outvert = (vert, norm, color, uvs, uv)
                        outLength = length
                        return outvert

I already know there's quite alot that won't work...
I've tried a little research... but google was of no help there <_<
so now I'm coming here...

EDIT:
and yea...
I've switched the formats back to 1 now...
apperently I've fixed a few unknown broken parts in my other code and len(fmt) != 4 anymore

Edited by Tcll: n/a

0

hey...
is this right:

#Will's block (translated from C++ to Py)
                    fmt = []
                    unknownfmt = 0
                    
                    if (data[0]+data[1] == '0850'): #contents == vtx_des1
                        if ui(data[5]) & 3: unknownfmt+=1
                        if (ui(data[5]) & 12) >> 2: unknownfmt+=1
                        if (ui(data[5]) & 48) >> 4: unknownfmt+=1
                        if (ui(data[5]) & 192) >> 6: unknownfmt+=1
                        
                        tempfmt = (ui(data[4]) & 6) >> 1
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[4]) & 24) >> 3
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[4]) & 96) >> 5
                        if tempfmt: fmt.append(tempfmt - 1)
                        
                    if (data[6]+data[7] == '0860'): #contents == vtx_des2
                        tempfmt = ui(data[11]) & 3
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[11]) & 12) >> 2
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[11]) & 48) >> 4
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[11]) & 192) >> 6
                        if tempfmt: fmt.append(tempfmt - 1)
                        
                        tempfmt = ui(data[10]) & 3
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[10]) & 12) >> 2
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[10]) & 48) >> 4
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[10]) & 192) >> 6
                        if tempfmt: fmt.append(tempfmt - 1)
                        
                    if (data[16]+data[17] == '0800'):
                        colorfmt = ui(data[20]) & 3
                        normalfmt = (ui(data[20]) & 12) >> 2
                        uvfmt = (ui(data[20]) & 240) >> 4
                    #end Will's block

it's causing the facepoint function to read by 12 instead of 8... (for one mdl0)
which is really screwing it up :/

EDIT:
actually...
here's my full code for the objects:
http://www.pasteit4me.com/2238006

hopefully that'll help

Edited by Tcll: n/a

0

hey...
is this right:

#Will's block (translated from C++ to Py)
                    fmt = []
                    unknownfmt = 0
                    
                    if (data[0]+data[1] == '0850'): #contents == vtx_des1
                        if ui(data[5]) & 3: unknownfmt+=1
                        if (ui(data[5]) & 12) >> 2: unknownfmt+=1
                        if (ui(data[5]) & 48) >> 4: unknownfmt+=1
                        if (ui(data[5]) & 192) >> 6: unknownfmt+=1
                        
                        tempfmt = (ui(data[4]) & 6) >> 1
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[4]) & 24) >> 3
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[4]) & 96) >> 5
                        if tempfmt: fmt.append(tempfmt - 1)
                        
                    if (data[6]+data[7] == '0860'): #contents == vtx_des2
                        tempfmt = ui(data[11]) & 3
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[11]) & 12) >> 2
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[11]) & 48) >> 4
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[11]) & 192) >> 6
                        if tempfmt: fmt.append(tempfmt - 1)
                        
                        tempfmt = ui(data[10]) & 3
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[10]) & 12) >> 2
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[10]) & 48) >> 4
                        if tempfmt: fmt.append(tempfmt - 1)
                        tempfmt = (ui(data[10]) & 192) >> 6
                        if tempfmt: fmt.append(tempfmt - 1)
                        
                    if (data[16]+data[17] == '0800'):
                        colorfmt = ui(data[20]) & 3
                        normalfmt = (ui(data[20]) & 12) >> 2
                        uvfmt = (ui(data[20]) & 240) >> 4
                    #end Will's block

it's causing the facepoint function to read by 12 instead of 8... (for one mdl0)
which is really screwing it up :/

EDIT:
actually...
here's my full code for the objects:
http://www.pasteit4me.com/2238006

hopefully that'll help

^that has officially got to be the biggerst DERP I've ever done D:

the data var is already in hex
and I'm encoding hex in my ui function

hex.encode('hex')
srsly

deerrrrp
I'm such an idiot...

EDIT:
IT WORKS!!!
FINALLY

Edited by Tcll: n/a

0

hey...
I'm trying to figure this one out myself...
but the codes are in C#

I know you don't know anything about this program,
and the expert who made it is a selfish jerk who won't help me on what need's explaining >:/
(he ignores me and actually says "look at it yourself")

anyways...

here's what I'm stuck on:

//VTXSpecs
    //0000 0000 0000 0011   - Num colors
    //0000 0000 0000 1100   - Normal type (1 = normals, 2 = normals + binormals)
    //0000 0000 1111 0000   - Num textures
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct XFVertexSpecs
    {
        internal buint _data;

        public int ColorCount { 
        	get { return (int)(_data & 3); } 
        	set { _data = _data & 0xFFFFFFFC | ((uint)value & 3); } 
        }
        public int TextureCount { 
        	get { return (int)(_data >> 4 & 0xF); } 
        	set { _data = _data & 0xFFFFFF0F | (((uint)value & 0xF) << 4); }
        }
        public XFNormalFormat NormalFormat {
        	get { return (XFNormalFormat)(_data >> 2 & 3); }
        	set { _data = _data & 0xFFFFFFF3 | (((uint)value & 3) << 2); }
        }

        public XFVertexSpecs(uint raw) { _data = raw; }
        public XFVertexSpecs(int colors, int textures, XFNormalFormat normalFormat)
        { _data = (((uint)textures & 0xF) << 4) | (((uint)normalFormat & 3) << 2) | ((uint)colors & 3); }
    }

vvv

[StructLayout(LayoutKind.Sequential)]
    public struct buint
    {
        public uint _data;
        public static implicit operator uint(buint val) { return val._data.Reverse(); }
        public static implicit operator buint(uint val) { return new buint { _data = val.Reverse() }; }
        public static explicit operator int(buint val) { return (int)val._data.Reverse(); }
        public static explicit operator buint(int val) { return new buint { _data = (uint)val.Reverse() }; }
    }

^^^ how does that even work btw??
does it return 4 values or something??

anyways...

public uint _data;

^what bit depth is that??
32bit??

and is there anything else I need to know??

Edited by Tcll: n/a

0

hey...
I'm trying to figure this one out myself...
but the codes are in C#

I know you don't know anything about this program,
and the expert who made it is a selfish jerk who won't help me on what need's explaining >:/
(he ignores me and actually says "look at it yourself")

anyways...

here's what I'm stuck on:

//VTXSpecs
    //0000 0000 0000 0011   - Num colors
    //0000 0000 0000 1100   - Normal type (1 = normals, 2 = normals + binormals)
    //0000 0000 1111 0000   - Num textures
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct XFVertexSpecs
    {
        internal buint _data;

        public int ColorCount { 
        	get { return (int)(_data & 3); } 
        	set { _data = _data & 0xFFFFFFFC | ((uint)value & 3); } 
        }
        public int TextureCount { 
        	get { return (int)(_data >> 4 & 0xF); } 
        	set { _data = _data & 0xFFFFFF0F | (((uint)value & 0xF) << 4); }
        }
        public XFNormalFormat NormalFormat {
        	get { return (XFNormalFormat)(_data >> 2 & 3); }
        	set { _data = _data & 0xFFFFFFF3 | (((uint)value & 3) << 2); }
        }

        public XFVertexSpecs(uint raw) { _data = raw; }
        public XFVertexSpecs(int colors, int textures, XFNormalFormat normalFormat)
        { _data = (((uint)textures & 0xF) << 4) | (((uint)normalFormat & 3) << 2) | ((uint)colors & 3); }
    }

vvv

[StructLayout(LayoutKind.Sequential)]
    public struct buint
    {
        public uint _data;
        public static implicit operator uint(buint val) { return val._data.Reverse(); }
        public static implicit operator buint(uint val) { return new buint { _data = val.Reverse() }; }
        public static explicit operator int(buint val) { return (int)val._data.Reverse(); }
        public static explicit operator buint(int val) { return new buint { _data = (uint)val.Reverse() }; }
    }

^^^ how does that even work btw??
does it return 4 values or something??

anyways...

public uint _data;

^what bit depth is that??
32bit??

and is there anything else I need to know??

EDIT:
it's 32bit
figured it out from looking at another function that reads a 32bit part... heh

I know you'd've help'd if you'd've been there, so thanx :)
(even though you didn't do anything)

Edited by Tcll: n/a

0

would this be right?? <:/

Python:

if (lo & 1) != 0: HasPosMatrix = (lo & 2) | 1
else: HasPosMatrix = (lo & 2) | 0

C#:

public bool HasPosMatrix { 
        get { return (_lo & 1) != 0; } 
        set { _lo = _lo & 2 | (uint)(value ? 1 : 0); } 
}

Edited by Reverend Jim: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.