Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New polygon form found ! #23

Open
aybe opened this issue Nov 11, 2015 · 3 comments
Open

New polygon form found ! #23

aybe opened this issue Nov 11, 2015 · 3 comments

Comments

@aybe
Copy link

aybe commented Nov 11, 2015

I guess I've found something 💃

HEAD.PRM (Wipeout 1)

For those polygons:

        FlatTriangle = 0x05,
        FlatQuad = 0x07,

Basically the SubType in the polygon header is misleading, when there are more than 255 vertices, the SubType actually becomes an index as you can see below, and the length of polygons change:

2015-11-11 04_25_54-calculator
(SHLD is a small object with less than 0xFF vertices, HEAD exceeds 0xFF)

They are bigger than usual:

                case PrmPolygonType.FlatTriangle:
                    var flatTriangle = new FlatTriangle
                    {
                        Header = header,
                        Indices = reader.ReadUInt16BEs(3),
                        Unknown1 = reader.ReadUInt16BE(),
                        Colors = reader.ReadUInt32BEs(3)
                    };
                    if (prmObjectHeader.PolygonCount > 0xff)
                    {
                        reader.ReadBytes(52);
                    }
                case PrmPolygonType.FlatQuad:
                    var flatQuad = new FlatQuad
                    {
                        Header = header,
                        Indices = reader.ReadUInt16BEs(4),
                        Colors = reader.ReadUInt32BEs(4)
                    };
                    if (prmObjectHeader.PolygonCount > 0xff)
                    {
                        reader.ReadBytes(72);
                    }

The if are the code I've added to my working base and you can see the result below,

2015-11-11 04_20_07-unity personal 64bit - modelscene unity - wxx-rebirth - pc mac linux standa
2015-11-11 04_20_20-start
2015-11-11 04_20_38-cortana
2015-11-11 04_21_24-plotly
2015-11-11 04_21_39-start

It seems to be the trophy championship or something but I can't remember where it's in the game ...

By the way I did somehow try to understand the logic in IDA, there were nearly 20+ cases in switch blocks which makes me believe there are way more forms of polygons that one can think of ... but there must be some logic after all !

Any clue/hints are welcome !

Thanks :D

@aybe
Copy link
Author

aybe commented Nov 11, 2015

EDIT

Got it !!! 👯 👯 👯 👯 👯 👯 👯

2015-11-11 04_50_36-unity personal 64bit - modelscene unity - wxx-rebirth - pc mac linux standa

Here's the code used as I'm being in a rush:

       case PrmPolygonType.FlatQuad:
                    if (prmObjectHeader.PolygonCount > 0xff)
                    {
                        reader.Roll(2);
                        var indices = reader.ReadUInt16BEs(4);
                        reader.ReadBytes(6);
                        var c1 = reader.ReadUInt32BE();
                        reader.ReadUInt32BE();
                        var c2 = reader.ReadUInt32BE();
                        reader.ReadUInt32BE();
                        var c3 = reader.ReadUInt32BE();
                        reader.ReadUInt32BE();
                        var c4 = reader.ReadUInt32BE();
                        reader.ReadUInt32BE();

                        reader.ReadBytes(52);
                        var flatTriangleEx = new FlatQuadEx()
                        {
                            Header = header,
                            Indices = indices,
                            Colors = new[] { c1, c2, c3, c4 }
                        };
                        return flatTriangleEx;
                    }
                    else
                    {
                        var flatQuad = new FlatQuad
                        {
                            Header = header,
                            Indices = reader.ReadUInt16BEs(4),
                            Colors = reader.ReadUInt32BEs(4)
                        }; return flatQuad;
                    }

But it's pretty strange 2 be honest, there are 4 next colors, but there is an offset between previous ones:

2015-11-11 04_52_46-

We'll get to it 👍 👍 👍

Spent the damn whole night but at least it paid off 🎯

Cheers !

@aybe aybe changed the title New polygon form (mostly) found ! New polygon form found ! Nov 11, 2015
@MarcoEstevez
Copy link

Awesome!

@aybe
Copy link
Author

aybe commented Nov 11, 2015

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants