Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Tools

Archive::Tools Archive area for Tools's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2004, 08:54 AM
daeken_bb
Discordant
 
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
Default WLD->TER Converter v0.1b

Just finished work on the latest version of the WLD convertor. I actually tested it this time

It gives you almost a godly feeling to be able to take poknowledge and make it into a .ter file

As before, you can get the neccesary files (wld.c, wld.h, s3d.c, s3d.h, and ter.h) from http://home.archshadow.com/~daeken/openeq/.

You can also download a package of OpenEQ with this included in it from http://home.archshadow.com/~daeken/openeq.tar.bz2

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);
  }

  fwrite("foo", 1, 3, out);
}
Happy Hacking,
Lord Daeken M. BlackBlade
(Cody Brocious)
__________________
Keep me unemployed and working on OpenEQ, PM me about donating

Check out my deviantART page at http://daeken.deviantart.com/
Reply With Quote
  #2  
Old 09-20-2004, 07:23 PM
jbb
Hill Giant
 
Join Date: Mar 2003
Location: UK
Posts: 242
Default

This works well at least when built on linux.
Great stuff

I guess it would be helpful to also take the textures from the original file and put them together with the .ter file into a new .eqg file so the same renderer code will work on new and old zones.

Also, you might want to make sure you open the files with "rb" and "wb" instead of "w" and "b" for portability. (Not that it works properly on windows at this time even with that changce for some reason)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 05:07 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3