[Scummvm-cvs-logs] CVS: residual/tools set2fig.cc,NONE,1.1 .cvsignore,1.1,1.2 Makefile,1.3,1.4

Daniel Schepler dschepler at users.sourceforge.net
Thu Mar 25 05:03:19 CET 2004


Update of /cvsroot/scummvm/residual/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24615

Modified Files:
	.cvsignore Makefile 
Added Files:
	set2fig.cc 
Log Message:
Add set2fig debugging tool.


--- NEW FILE: set2fig.cc ---
// Utility to dump drawing of the sectors in a set file to an xfig file

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Usage: set2fig mo.set >mo.fig\n");
    exit(1);
  }
  printf("#FIG 3.2\n"
	 "Landscape\n"
	 "Center\n"
	 "Metric\n"
	 "A4\n"
	 "100.00\n"
	 "Single\n"
	 "-2\n"
	 "1200 2\n");

  FILE *in = fopen(argv[1], "r");
  if (in == NULL) {
    perror(argv[1]);
    exit(1);
  }

  char line[1024];
  do {
    fgets(line, 1024, in);
  } while (strcmp(line, "section: sectors\r\n") != 0);

  int numSectors = -1, numRead = 0;
  do {
    char sectorName[256];
    fscanf(in, " sector %256s", sectorName);

    int id;
    fscanf(in, " ID %d", &id);
    if (numSectors < 0)
      numSectors = id + 1;

    char buf[256];
    int color = 0;
    fscanf(in, " type %256s", buf);
    if (strcmp(buf, "walk") == 0)
      color = 0;
    else if (strcmp(buf, "funnel") == 0)
      color = 0;
    else if (strcmp(buf, "camera") == 0)
      color = 1;
    else if (strcmp(buf, "special") == 0)
      color = 5;
    else if (strcmp(buf, "chernobyl") == 0)
      color = 4;

    int linetype = 0;
    fscanf(in, " default visibility %256s", buf);
    if (strcmp(buf, "visible") == 0)
      linetype = 0;
    else if (strcmp(buf, "invisible") == 0)
      linetype = 1;

    float dummy;
    fscanf(in, " height %f", &dummy);

    int numVertices;
    fscanf(in, " numvertices %d", &numVertices);

    printf("# %s\n2 3 %d 1 %d 7 %d -1 -1 0.000 0 0 -1 0 0 %d\n\t",
	   sectorName, linetype, color, color * 10, numVertices + 1);

    float vertices[300];
    fscanf(in, " vertices:");
    for (int i = 0; i < numVertices; i++) {
      fscanf(in, " %f %f %f", vertices + 3*i, vertices + (3*i+1),
	     vertices + (3*i+2));
      printf(" %d %d", (int) round(vertices[3*i] * 1000),
	     -(int) round(vertices[3*i+1] * 1000));
    }
    printf(" %d %d\n", (int) round(vertices[0] * 1000),
	   -(int) round(vertices[1] * 1000));

    numRead++;
  } while (numRead < numSectors);
}

Index: .cvsignore
===================================================================
RCS file: /cvsroot/scummvm/residual/tools/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- .cvsignore	22 Aug 2003 11:07:19 -0000	1.1
+++ .cvsignore	25 Mar 2004 12:52:07 -0000	1.2
@@ -5,3 +5,4 @@
 mat2ppm
 unlab
 vima
+set2fig

Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/residual/tools/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile	22 Aug 2003 11:07:19 -0000	1.3
+++ Makefile	25 Mar 2004 12:52:07 -0000	1.4
@@ -4,7 +4,7 @@
 LDFLAGS = -g
 LIBS = -L../lua/lib -llua
 
-all: bmtoppm delua imc2wav int2flt mat2ppm unlab vima
+all: bmtoppm delua imc2wav int2flt mat2ppm set2fig unlab vima
 
 bmtoppm: bmtoppm.c
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ bmtoppm.c -lppm





More information about the Scummvm-git-logs mailing list