|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Archive::Tools Archive area for Tools's posts that were moved here after an inactivity period of 90 days. |
|
|
|
09-19-2004, 02:34 PM
|
Discordant
|
|
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
|
|
WLD->TER Converter v0.1
Just whipped this up in 15 minutes or so. It takes a zone s3d file and outputs a .TER for it
This requires the files s3d.c/.h, wld.c/.h, and ter.h from the OpenEQ source to build, which are available at http://home.archshadow.com/~daeken/openeq/.
Code:
#include <stdio.h>
#include "s3d.h"
#include "wld.h"
#include "ter.h"
int main(int argc, char **argv) {
wld_object wld;
ZoneMesh zm;
s3d_object s3d;
FILE *in, *out;
int i;
char tex_name[16];
char *s3d_name;
uchar *wld_buf;
ter_header thdr;
ter_vertex vert;
ter_triangle tri;
if(argc < 3) {
printf("Usage: ./%s [input.s3d] [output.ter]\n", argv[0]);
return;
}
s3d_name = (char *) malloc(strlen(argv[1]) + 5);
sprintf(s3d_name, "%s.s3d", argv[1]);
S3D_Init(&s3d, fopen(s3d_name, "r"));
sprintf(s3d_name, "%s.wld", argv[1]);
S3D_GetFile(&s3d, s3d_name, &wld_buf);
free(s3d_name);
out = fopen(argv[2], "w");
WLD_Init(&wld, wld_buf, &s3d, 0);
WLD_GetZoneMesh(&wld, &zm);
memcpy(thdr.magic, "EQGT", 4);
thdr.version = 2;
thdr.mat_count = zm.tex->count;
thdr.vert_count = zm.vertexCount;
thdr.tri_count = zm.polygonCount;
thdr.list_len = 0;
for(i = 0; i < thdr.mat_count; ++i) {
sprintf(tex_name, "tex_%i", i);
thdr.list_len += strlen(tex_name) + 1;
thdr.list_len += strlen(zm.tex->filenames[i]) + 1;
}
fwrite(&thdr, 1, sizeof(ter_header), out);
for(i = 0; i < thdr.mat_count; ++i) {
sprintf(tex_name, "tex_%i", i);
fwrite(tex_name, 1, strlen(tex_name) + 1, out);
fwrite(zm.tex->filenames[i], 1, strlen(zm.tex->filenames[i]) + 1, out);
}
for(i = 0; i < thdr.vert_count; ++i) {
vert.x = zm.verti[i]->x;
vert.y = zm.verti[i]->y;
vert.z = zm.verti[i]->z;
vert.u = zm.verti[i]->u;
vert.v = zm.verti[i]->v;
fwrite(&vert, 1, sizeof(ter_vertex), out);
}
for(i = 0; i < thdr.tri_count; ++i) {
tri.v1 = zm.poly[i]->v1;
tri.v2 = zm.poly[i]->v2;
tri.v3 = zm.poly[i]->v3;
tri.group = zm.poly[i]->tex;
tri.unk = 1;
fwrite(&tri, 1, sizeof(ter_triangle), out);
}
}
Happy Hacking,
Lord Daeken M. BlackBlade
(Cody Brocious)
|
|
|
|
09-19-2004, 07:01 PM
|
Hill Giant
|
|
Join Date: Mar 2003
Location: UK
Posts: 242
|
|
Umm very nice idea.
Will be nice to be able to render some zones which I already know what they are supposed to look like.
|
09-19-2004, 08:49 PM
|
|
Demi-God
|
|
Join Date: Aug 2003
Posts: 1,056
|
|
cool....
__________________
Quote:
Analysis paralysis will keep you from failing, but it will also keep you from succeeding.
|
|
09-19-2004, 10:43 PM
|
Discordant
|
|
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
|
|
The final release will probably be after school... gotta output a .ZON file, as well as package it up in a new EQG or in the old s3d.
|
09-19-2004, 11:02 PM
|
|
Dragon
|
|
Join Date: Mar 2004
Location: France, Bordeaux.
Posts: 677
|
|
Awesome Daeken, i cant wait to see final version, this way, i will be able to move all the zones i make for World of Alkora to EQG !
__________________
|
09-19-2004, 11:15 PM
|
Discordant
|
|
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
|
|
I can't wait to see someone use it hehe.
Btw... the final release isn't really the "final release" ... it's the final release of the first version... there will be an update as soon as possible to include the bsp/octree data that's before the vertices.. but this should work for OpenEQ and _possibly_ EQ as-is.
|
09-19-2004, 11:32 PM
|
Hill Giant
|
|
Join Date: Mar 2003
Location: UK
Posts: 242
|
|
Hmm I built it on windows (had to put in a fair number of changes) and tried to convert pknowledge.s3d and got out a .ter file but it seems to have major problems. My renderer program seems to be getting fairly random numbers and crashes when it tries to allocate memory for -200000 vertexes.
May be a problem with the conversion I had to do to make it run on windows. I'll have another look later when I'm home from work.
|
09-19-2004, 11:39 PM
|
Discordant
|
|
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
|
|
Yea... our WLD code doesn't run on Windows as far as I know.
|
09-19-2004, 11:42 PM
|
Hill Giant
|
|
Join Date: Mar 2003
Location: UK
Posts: 242
|
|
No reason why it shouldn't though... I'll look at why it doesn't work later on.
In fact I wonder if it might not be a good idea to make a "libeqff" as a standalong library for loading and extracting bits from s3d, ter and wld files, plus anything wanted in the future.
|
09-20-2004, 07:46 AM
|
Discordant
|
|
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
|
|
Hmm... may not be such a bad idea. The main issue is making it all standardized.
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 12:28 PM.
|
|
|
|
|
|
|
|
|
|
|
|
|