test.C 1.76 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dataBase.H"
#include "fileReader.H"
#include "fileWriter.H"

#define MULTIGEN	0
#define	LIGHTSCAPE	1
#define TEXTURE_SGI	2

#define TRANS_VERBOSE	0x0001

void main(int argc, char *argv[])
{
    DataBase *database;
    FileReader *reader;
    FileWriter *writer;
    char infile[32], outfile[32];
    int flag=0;
    int inType=1;
    int outType=0;

    if (argc > 30) printf("");
    char *dummy = *argv++;
    strcpy(infile, *argv);

    switch (inType)
    {
	case MULTIGEN:
	    reader = new FltReader();
	break;
	case LIGHTSCAPE:
	    int mindepth;
	    if (argc < 3)
		mindepth = 0;
	    else
		sscanf(argv[1], "%d", &mindepth);	
	    reader = new LsReader();
	    // causes it to write out a RAT .lsb file 
	    ((LsReader *)reader)->enableRadTexture();
	    printf("using minimum depth for rat texture of : %d\n", mindepth);
	    ((LsReader *)reader)->MinDepthForTexture(mindepth);
	    ((LsReader *)reader)->ColorDelta(5);
	    ((LsReader *)reader)->enableColorPerVertPoly();
	break;
	default:
	break;
    }

    fprintf(stderr, "Reading from input file: %s\n", infile);
    if ((database = reader->Read(infile)) == NULL)
    {
	fprintf(stderr, "ERROR: No database read from file: %s\n", infile);
	exit(1);
    }

    if (flag & TRANS_VERBOSE)
    	database->print();

    strcpy(outfile, infile);

    switch (outType)
    {
	case MULTIGEN:
	    writer = new FltWriter(database);
	    strcat(outfile, ".flt"); 
	break;
	case LIGHTSCAPE:
	    writer = new LsWriter(database);
	    strcat(outfile, ".lp");
	break;
	case TEXTURE_SGI:
	{
	    strcat(outfile, ".rgb");
	}
	break;
	default:
	break;
    }

    fprintf(stderr, "Writing to output file: %s\n", outfile);
    writer->Write(outfile);

    fprintf(stdout, "Done.\n");
}