Ahh yes. the lfsSMX_ things are
structs I defined based on the SMX.txt. They are:
struct lfsSMX_HEADER {
char LFSSMX[6];
unsigned char game_version, game_revision, SMX_version;
unsigned char dimensions, resolution, vertex_colours;
char spare1[4];
char track[32];
unsigned char ground_col[3];
char spare2[9];
int num_objects;
};
struct lfsSMX_OBJECT {
int X, Y, Z, radius;
int num_points, num_tris;
};
struct lfsSMX_POINT {
int X, Y, Z;
unsigned char colour[4];
};
struct lfsSMX_TRIANGLE {
unsigned short vertex_A, vertex_B, vertex_C, spare;
};
About the only thing they do is make reading the file easier. Instead of reading individual chars, ints, etc, it reads into those structs making it easier to manage imo.
For your code, I see you define some big (3000) integer arrays for your points that are not necessary. 3000 * 4 = 12000 bytes of memory a piece.. In a quick test on Blackwood, the max number of points any single object has is 660, so 3000 is a waste that may be slowing you down a bit. On the other hand, redefining the array for every object may slow you down too. Hmm, a quick test will help solve which is faster. It all depends..
Overall, our programs are very similar. I do see your program is technically 3D however. Perspective changes accordingly. You should use an orthographic view if you want a true 2D render. And yeah, your depth/z buffer is a little screwy. Mine is too I think but it gets better once zoomed in. Check out the oval building near the Blackwood pits for a good example.
Also for comparison, I attached what I have so far too. To use, create a folder named 'smx' or 'smxU' along side the .exe, move/copy the smx files inside those, then run it. If the smx are found, you will see a list of buttons on the right to open one. Use w, a, s, d respectively to move around, right mouse button to rotate, mousewheel to zoom, left and right to roll, up and down to adjust fov, space to toggle the overlay, o to toggle a world origin thing. The movement is all keyboard event based so its not smooth. I still need to implement some threaded animation code for that.
Have fun with it! I am
![](/static/smilies/nod.gif)