-
Notifications
You must be signed in to change notification settings - Fork 43
.WM File Format
The .WM files can be found in G03_GDATA\D07_GWORLD
It is safe to think of them as World Mesh files. They contain the walkable area in the form of triangles that are all joined up. It also contains a form of a QuadTree which seems to be split serialized into the file.
https://www.youtube.com/watch?v=FX1b2OpoCFE
Anywhere on a XZ coord that does not have a Y on a triangle under it is not walkable.
These files have quite a detailed structure. @LiamKarlMitchell or @Ane2 can write about it more later.
We load the mesh from these files for pathfinding. However we have exported it to an OBJ and optimized with a program called Atangeo Balancer
Please see our document here on polygon reduction. https://docs.google.com/document/d/1TLX8mAcPRLdz4WIq_lkbNQckFZxQG-KLsaIV8wr-CxU/edit?usp=sharing
Path Finding is another topic we can go into later when @Ane2 has coded it.
Look at: http://www.arongranberg.com/astar/docs/graph_types.php http://gamedev.stackexchange.com/questions/68302/how-does-the-simple-stupid-funnel-algorithm-work A* http://www.ai-blog.net/archives/000152.html
A WM file is made up of an array of vertexs 3 Vertexs make a triangle so it also has an array of triangles with each vertex referenced by an index. There is some extra data on the triangles to do with texture index to use, plane info (X Y Width Height) and sphere info (X Y Z Radius)
Presumably the texture indexes would be referencing the textures from the WG and the plane info would explain which part of texture to render. As for the sphere who knows.
If you look at the map birds eye down like the map, we have a X and a Z coord. Treet these as if they are XY on this view.
A X,Z 2D coord is used to lookup a triangle. If no triangle is found the area is not walkable. If found the triangle is looked at and a calculation is made to get the Y of the point on the face of that triangle. This would be the height of the ground.
So the file also stores a serialized quad tree of all the triangles. Who knows why its stored I guess old computers were too slow to calculate it on the fly?
Think of it as an array of boxes. They have vertexs for front top left and a back bottom right so the game knows the area they cover spatially.
They may have an array of triangle indexes they contain. And they may have 4 children (an index of another quad tree node)
In a quad tree each node could be split by factor of 2 to have 4 children. Example: top left, top right, bottom right, bottom left
struct QuadtreeNode {
float boxMin[3];
float boxMax[3];
unsigned int trisNumber;
byte useTris; // maybe this was unsigned int....
// some gaps
unsigned int * trisIndex; // 1 for each trisNumber if useTris is set to true
unsigned int childNodes[4]; // Only 4 children can be had for each node in quad tree they divide by factor of 2.
}
struct WMVertex {
float mV[3];
float mN[3];
float mT1[2];
float mT2[2];
};
struct WMTris {
int mTextureIndex;
WMVertex mVertex[3];
float mPlaneInfo[4];
float mSphereInfo[4];
}
unsigned int mWorldTrisNum;
WMTris mWorldTris[mWorldTrisNum];
unsigned int mTotalQuadtreeNodeNum;
unsigned int mMaxQuadtreeNodeLeafNum;
QuadtreeNode mQuadtree[mTotalQuadtreeNodeNum];