Showing posts with label Mirror's Edge. Show all posts
Showing posts with label Mirror's Edge. Show all posts

Sunday, February 15, 2009

Faith Model Continued

I spent several more hours examining the CH_Faith_Cinematic.upk posedAgain StaticMesh. First off, I discovered that my raw data exporter in UE3PackageViewer doesn't seem to work correctly (it cut off half of some of the data). Manually pulling out the data, I found several lists of structures:

struct UnknownStruct1 {
    struct Vertex1 {
        float x;
        float y;
        float z;
    };
    struct Vertex2 {
        float x;
        float y;
        float z;
    };
    int UnknownInt;  /* either 0 or 1 */
    union {
        struct { /* when UnknownInt == 0 */
            short int UnknownStruct1Index;
            short int UnknownStruct1IndexPlus1;
        };
        struct { /* when UnknownInt == 1 */
            short int Count;
            short int TriangleIndex;
        };
    };
};

struct Triangle {
    short int VertexIndexes[3];
    short int UnknownShort; /* material number? */
};

struct Vertex {
    float x;
    float y;
    float z;
};

struct UnknownStruct2 {
    char Unknown1[4];
    char Unknown2[4];
    int NegOne; /* always -1 */
    char Unknown3[4];
};

struct UnknownStruct3 {
    int UnknownInts[4];
};

There is also a large list of shorts and another of bools.

The list of Vertex and Triangle work out to the model in my last post. Of the rest, the list of UnknownStruct1 is the most interesting. Those verts aren't normals or texture coordinates (nearly all are > 1.0). When visualized in space, they hover all around the Faith model.

Additional searching about Unreal meshes led me back to the UnrealToX3D converter. The author wrote a nice white paper about converting the t3d format.

The real challenge was converting the texture coordinates. Unreal textures are described as tiling a plane in space coincident with the polygon on which they lie.

Each surface has a 3D vertex for U, another for V, and another for the texture normal (these are usually orthogonal). A pan value (in UV units) may also be supplied. This scheme allows for arbitrary scale, rotation, shear, and displacement of the texture without having to describe UV coordinates for each vertex on a polygon. To turn these various directionals into common UV coordinates, I find a transform that rotates the polygon from its arbitrary orientation onto the XY plane, and apply the same transform to the U and V texture components. I can now use the transformed U sand V component (which are now co-planar with the XY plane) to scale the texture. Using the pan components as offsets, I now use the polygon's coordinates (which are now all in the XY plane) to produce the UV coordinates.

Could those random points in space actually be 3D UV coordinates? I looked at the faces associated with the points, but the relation doesn't make any sense to me.

I wrote an exporter for this model and structures in Python if you want to look at the data yourself.

Other searching led me to comments in forums that say you can convert StaticMesh to brush in UnrealEd, and then export it as OBJ. I tried poking around but haven't quite found how.

Saturday, February 7, 2009

Unreal 3 Engine Model Extraction

While there is a lot of modding that may be possible with Mirror's Edge, my primary desire is to gain access to the various models of the game.

I have searched high and low, with at least 30 different queries thrown at Google, and several hours of scanning results, but nothing has turned up. No one seems to have a way to extract models from the Unreal 3 Engine. Which suggests that this is the first time anyone has.

Faith MeshIf someone has already found a way to extract models, then I'd be more than happy to be wrong. Thus far my mesh explorations have been hit and miss. This Faith StaticMesh resource (CH_Faith_Cinematic .posedAgain) has easily identifiable vertices and triangle indices, but I can't locate the texture coordinates. The resource right next to this mesh (posedAgain_Shaded) is even less clear. The data is tremendously random, with no obvious patterns. The S_M95 weapon StaticMesh appears to be the same.

After several hours of dead-ends I grew frustrated, so I played Unreal Tournament 3 for the rest of the day :) I'll give it another go eventually, but I don't have much hope in the results.

Update: Gildor's Unreal Mesh Viewer has now been updated to extract Mirror's Edge SekeletalMeshes. These are different from StaticMeshes (like the one above), and they include the bone structure of the model as well. The Faith SkeletalMesh (the one you actually see running around in the game) is in CH_TKY_Crim_Fixer.upk as SK_TKY_Crim_Fixer.

Wednesday, January 28, 2009

Dissecting Mirror's Edge

I'm brand new to the inner workings of the Unreal Engine, but this is what I've found works for Mirror's Edge.

Enabling the built-in Mirror's Edge editor!: Folks have gotten the real Unreal Editor mostly working for Mirror's Edge.

UE3PackageViewer: Hands down the nicest and completely open source package viewer found. I've already updated it to work with Mirror's Edge. It can preview DDS images (double-click the Texture2D in the detailed list), and even read compressed packages (.me1 files). I've also added Ogg extraction, and raw dump extraction for unknown data (somewhat broken). WARNING: the program is still full of bugs (and I don't have much motivation to update it any more that I have).

Upk Info: Not quite as extensive package viewer, and doesn't currently work with Mirror's Edge, but it's also open source.

Unreal Model Viewer: Soon to be open-sourced model viewer that works for many Unreal Engine games, including UT3 and Mirror's Edge (Gildor is the man).

Oggextract: Another open-source tool that scans and extracts Ogg files from the packages.

Another Ogg extractor: Closed source Ogg previewer and extractor.

NVidia's content creation tools: Includes DDS image viewers and converters.

Bink RAD tools: To watch and convert all the videos of the game.

3D Ripper DX: Can capture models being rendered by DirectX 9 on Windows XP.

Documentation

The Beyond Unreal Wiki: Documentation for practically every aspect of older (<= 2004) Unreal Engines.

Mod Authoring for Unreal Tournament 3: Serious documentation is serious.

Other points of interest

UShock: Open source UT2004 level viewer. Doesn't work with Mirror's Edge, but maybe it could be updated to do so.