Recovered from microbel

This commit is contained in:
rot
2025-03-05 08:35:31 +01:00
committed by h7x4
commit 88b92402a8
601 changed files with 82177 additions and 0 deletions

1
util/geo2bog/.cvsignore Normal file
View File

@@ -0,0 +1 @@
geo2bog geo_parse.h geo_parse.c geo_scan.c

16
util/geo2bog/Makefile.am Normal file
View File

@@ -0,0 +1,16 @@
INCLUDES = -I../../common/include @TIFF_CFLAGS@
bin_PROGRAMS = geo2bog
geo2bog_SOURCES = geo2bog.c geo_parse.y geo_scan.l parse.c util.c writebog.c
geo2bog_LDADD = -L../../common/lib/geometry -lgeometry -L../../common/lib/texture -ltexture -L../../common/lib/utils -lpvvmudutils -L../../common/lib/srvcli -lsrvcli @TIFF_LIBS@ -ltiff -lm
BUILT_SOURCES = geo_parse.h geo_parse.c geo_scan.c
YFLAGS=-d
CC = $(CXX)
geo_parse.h: geo_parse.c
geo2bog.o: geo_parse.h

346
util/geo2bog/Makefile.in Normal file
View File

@@ -0,0 +1,346 @@
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
CXX = @CXX@
GL_CFLAGS = @GL_CFLAGS@
GL_LIBS = @GL_LIBS@
LEX = @LEX@
MAKEINFO = @MAKEINFO@
NETLIBS = @NETLIBS@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
TIFF_CFLAGS = @TIFF_CFLAGS@
TIFF_LIBS = @TIFF_LIBS@
VERSION = @VERSION@
YACC = @YACC@
INCLUDES = -I../../common/include @TIFF_CFLAGS@
bin_PROGRAMS = geo2bog
geo2bog_SOURCES = geo2bog.c geo_parse.y geo_scan.l parse.c util.c writebog.c
geo2bog_LDADD = -L../../common/lib/geometry -lgeometry -L../../common/lib/texture -ltexture -L../../common/lib/utils -lpvvmudutils -L../../common/lib/srvcli -lsrvcli @TIFF_LIBS@ -ltiff -lm
BUILT_SOURCES = geo_parse.h geo_parse.c geo_scan.c
YFLAGS = -d
CC = $(CXX)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
PROGRAMS = $(bin_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
geo2bog_OBJECTS = geo2bog.o geo_parse.o geo_scan.o parse.o util.o \
writebog.o
geo2bog_DEPENDENCIES =
geo2bog_LDFLAGS =
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LEXLIB = @LEXLIB@
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = Makefile.am Makefile.in geo_parse.c geo_scan.c
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
DEP_FILES = .deps/geo2bog.P .deps/geo_parse.P .deps/geo_scan.P \
.deps/parse.P .deps/util.P .deps/writebog.P
SOURCES = $(geo2bog_SOURCES)
OBJECTS = $(geo2bog_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .l .o .s .y
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --foreign util/geo2bog/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-binPROGRAMS:
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
distclean-binPROGRAMS:
maintainer-clean-binPROGRAMS:
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
list='$(bin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
done
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
geo2bog: $(geo2bog_OBJECTS) $(geo2bog_DEPENDENCIES)
@rm -f geo2bog
$(LINK) $(geo2bog_LDFLAGS) $(geo2bog_OBJECTS) $(geo2bog_LDADD) $(LIBS)
.l.c:
$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
.y.c:
$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
if test -f y.tab.h; then \
if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
else :; fi
geo_parse.h: geo_parse.c
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = util/geo2bog
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign util/geo2bog/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-include $(DEP_FILES)
mostlyclean-depend:
clean-depend:
distclean-depend:
-rm -rf .deps
maintainer-clean-depend:
%.o: %.c
@echo '$(COMPILE) -c $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-cp .deps/$(*F).pp .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
%.lo: %.c
@echo '$(LTCOMPILE) -c $<'; \
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-binPROGRAMS
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-binPROGRAMS
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(bindir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
-test -z "geo_scanlgeo_parsehgeo_parsec$(BUILT_SOURCES)" || rm -f geo_scanl geo_parseh geo_parsec $(BUILT_SOURCES)
mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
mostlyclean-tags mostlyclean-depend mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \
distclean-depend distclean-generic clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-binPROGRAMS \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-depend maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
clean-tags maintainer-clean-tags distdir mostlyclean-depend \
distclean-depend clean-depend maintainer-clean-depend info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
geo_parse.h: geo_parse.c
geo2bog.o: geo_parse.h
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

89
util/geo2bog/geo2bog.c Normal file
View File

@@ -0,0 +1,89 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "globals.h"
#include "parse.h"
FILE * source;
FILE * outfile;
FILE * ndbFile;
TreeNode_t * parseTree;
int main(int argc, char * argv[]){
char geofile[256];
char bogfile[256];
char ndbfile[256];
if (argc != 2) {
fprintf(stderr,"usage: %s <filename>\n",argv[0]);
exit(1);
}
strcpy(geofile,argv[1]);
if (strrchr (geofile, '/') != NULL){
if (strchr (strrchr(geofile,'/'), '.') == NULL)
strcat(geofile,".geo");
} else if (strchr (geofile, '.') == NULL)
strcat(geofile,".geo");
source = fopen(geofile,"r");
if (source == NULL){
fprintf(stderr,"File %s not found\n",geofile);
exit(1);
}
if (strrchr(geofile,'/') != NULL){
strcpy(bogfile,strrchr(geofile,'/')+1);
} else strcpy(bogfile,geofile);
strcpy(strchr(bogfile,'.'),".bog");
outfile = fopen(bogfile,"w");
if (outfile == NULL){
fprintf(stderr,"Error: Failed to open output file %s\n",bogfile);
exit(1);
}
strcpy(ndbfile,bogfile);
strcpy(strchr(ndbfile,'.'),".ndb");
parseTree = parse();
fclose(source);
ndbFile = fopen(ndbfile,"w");
if (ndbFile == NULL){
fprintf(stderr,"Error: Failed to open output file %s\n",ndbfile);
exit(1);
}
writebogfile(parseTree,outfile,ndbFile);
fclose(outfile);
fclose(ndbFile);
/* printTree(parseTree); */
return 0;
}

11
util/geo2bog/geo2bog.html Normal file
View File

@@ -0,0 +1,11 @@
<HTML>
<HEAD>
<TITLE>PVVMUD - geo2bog file converter</TITLE>
</HEAD>
<BODY>
<H1>geo2bog file converter</H1>
Se <A HREF="../../doc/geo2bog.html">doc/geo2bog.html</A> for current doc!
</BODY>
</HTML>

187
util/geo2bog/geo_parse.y Normal file
View File

@@ -0,0 +1,187 @@
/* The geo2bog Yacc/Bison spesification file */
%{
#define YYPARSER /* distinguishes yacc output from other code files */
#include "globals.h"
#include "parse.h"
#include "util.h"
#define YYSTYPE TreeNode_t *
static TreeNode_t * savedTree; /* Stores syntax tree for later return */
%}
%token GEO FILEVERSION GEOMETRY VERTEXLIST NORMALLIST TEXCOORDLIST POLYGON
%token TYPE MATERIAL VERTEX NORMAL TEXCOORD NAME
%token TRIANGLES QUADS QUAD_STRIP TRIANGLE_STRIP TRIANGLE_FAN
%token ASSIGN FLOAT NUM STRING
%token ERROR
%%
goeFile: geoHead geometry_seq
{ savedTree = newFile($1,$2); }
| geometry_seq
{ savedTree = newFile(NULL,$1); }
;
geoHead: GEO '(' FILEVERSION ASSIGN float_num ')'
{ $$ = newHead($5); }
;
geometry_seq: geometry_seq geometry
{ $$ = linkNode($1,$2); }
| geometry
{ $$ = $1; }
;
geometry: GEOMETRY '{' list_seq poly_seq '}'
{ $$ = newGeometry($3,$4); }
| GEOMETRY '(' NAME ASSIGN STRING ')' '{' list_seq poly_seq '}'
{ $$ = newGeometry($8,$9); }
;
list_seq: list_seq list
{ $$ = linkNode($1,$2); }
| list
{ $$ = $1; }
;
list: vertexlist ';'
{ $$ = $1; }
| normallist ';'
{ $$ = $1; }
| texcoordlist ';'
{ $$ = $1; }
;
vertexlist: VERTEXLIST ASSIGN '[' vertex_seq ']'
{ $$ = newVertexList($4); }
;
vertex_seq: vertex_seq ',' vertex
{ $$ = linkNode($1,$3); }
| vertex
{ $$ = $1; }
;
vertex: '(' float_num ',' float_num ',' float_num ')'
{ $$ = newVertex($2,$4,$6); }
;
float_num: FLOAT
{ $$ = newFloat((float)atof(tokenString)); }
| NUM
{ $$ = newFloat((float)atof(tokenString)); }
;
normallist: NORMALLIST ASSIGN '[' normal_seq ']'
{ $$ = newNormalList($4); }
;
normal_seq: normal_seq ',' normal
{ $$ = linkNode($1,$3); }
| normal
{ $$ = $1; }
;
normal: '(' float_num ',' float_num ',' float_num ')'
{ $$ = newNormal($2,$4,$6); }
;
texcoordlist: TEXCOORDLIST ASSIGN '[' texcoord_seq ']'
{ $$ = newTexCoordList($4); }
;
texcoord_seq: texcoord_seq ',' texcoord
{ $$ = linkNode($1,$3); }
| texcoord
{ $$ = $1; }
;
texcoord: '(' float_num ',' float_num ')'
{ $$ = newTexCoord($2,$4); }
;
poly_seq: poly_seq poly
{ $$ = linkNode($1,$2); }
| poly
{ $$ = $1; }
;
poly: POLYGON '{' polyattrib_seq '}'
{ $$ = newPoly($3); }
;
polyattrib_seq : polyattrib_seq polyattrib
{ $$ = linkNode($1,$2); }
| polyattrib
{ $$ = $1; }
;
polyattrib: type ';'
{ $$ = $1; }
| material ';'
{ $$ = $1; }
| vertexindexlst ';'
{ $$ = $1; }
| normalindexlst ';'
{ $$ = $1; }
| texindexlst ';'
{ $$ = $1; }
;
type: TYPE ASSIGN polytype
{ $$ = $3; }
;
polytype: POLYGON
{ $$ = newPolyType(PT_Polygon); }
| TRIANGLES
{ $$ = newPolyType(PT_Triangles); }
| QUADS
{ $$ = newPolyType(PT_Quads); }
| QUAD_STRIP
{ $$ = newPolyType(PT_Quad_strip); }
| TRIANGLE_STRIP
{ $$ = newPolyType(PT_Triangle_strip); }
| TRIANGLE_FAN
{ $$ = newPolyType(PT_Triangle_fan); }
;
material: MATERIAL ASSIGN STRING
{
tokenString[strlen(tokenString)-1] = '\0';
$$ = newMaterial(copyString(tokenString+1));
}
;
vertexindexlst: VERTEX ASSIGN '[' vertexindexseq ']'
{ $$ = newVertexIndexList($4); }
;
vertexindexseq: vertexindexseq ',' vertexindex
{ $$ = linkNode($1,$3); }
| vertexindex
{ $$ = $1; }
;
vertexindex: index
{ $$ = $1; }
;
normalindexlst: NORMAL ASSIGN '[' normalindexseq ']'
{ $$ = newNormalIndexList($4); }
;
normalindexseq: normalindexseq ',' normalindex
{ $$ = linkNode($1,$3); }
| normalindex
{ $$ = $1; }
;
normalindex: index
{ $$ = $1; }
;
texindexlst: TEXCOORD ASSIGN '[' texindexseq ']'
{ $$ = newTexCoordIndexList($4); }
;
texindexseq: texindexseq ',' texindex
{ $$ = linkNode($1,$3); }
| texindex
{ $$ = $1; }
;
texindex: index
{ $$ = $1; }
;
index: NUM
{ $$ = newIndex(atoi(tokenString)); }
;
%%
static TokenType yylex(){
return getToken();
}
int yyerror(char * message){
printf("Syntax error at line %d: %s\n",lineno,message);
return 0;
}
TreeNode_t * parse(){
yyparse();
return savedTree;
}

80
util/geo2bog/geo_scan.l Normal file
View File

@@ -0,0 +1,80 @@
/* Lex spesification for geo2bog */
%option noyywrap
%o 4000
%{
#define YYLEX
#include "globals.h"
int lineno;
char tokenString[MAXTOKENLEN+1];
%}
digit [0-9]
nat {digit}+
signedNat ("+"|"-")?{nat}
floating {signedNat}("."{nat})?(E{signedNat})?
string \"([^\"]|\\\")+\"
comment #[^\n]*
newline \n
whitespace [ \t\r]+
%%
"GEO" { return GEO; }
"Version" { return FILEVERSION; }
"Geometry" { return GEOMETRY ; }
"Name" { return NAME ; }
"VertexList" { return VERTEXLIST ; }
"NormalList" { return NORMALLIST ; }
"TexCoordList" { return TEXCOORDLIST ; }
"Vertex" { return VERTEX ; }
"Normal" { return NORMAL ; }
"TexCoord" { return TEXCOORD ; }
"Polygon" { return POLYGON ; }
"Type" { return TYPE ; }
"POLYGON" { return POLYGON ; }
"TRIANGLES" { return TRIANGLES ; }
"QUADS" { return QUADS ; }
"QUAD_STRIP" { return QUAD_STRIP ; }
"TRIANGLE_STRIP" { return TRIANGLE_STRIP ; }
"TRIANGLE_FAN" { return TRIANGLE_FAN ; }
"Material" { return MATERIAL ; }
"=" { return ASSIGN ; }
[;,()\[\]{}] { return yytext[0]; }
{nat} { return NUM; }
{floating} { return FLOAT; }
{string} { return STRING; }
{comment} { /* Skip */ }
{whitespace} { /* Skip */ }
{newline} { lineno++; }
. { return ERROR; }
%%
TokenType getToken(){
TokenType currentToken;
static int firstTime = TRUE;
if (firstTime){
firstTime = FALSE;
yyin = source;
lineno++;
}
currentToken = yylex();
strncpy(tokenString,yytext,MAXTOKENLEN);
return currentToken;
}
#if 0 /* ndef LINUX */
int yywrap(void){
return 1;
}
#endif

87
util/geo2bog/globals.h Normal file
View File

@@ -0,0 +1,87 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _GLOBALS_H
#define _GLOBALS_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "bogfile.H"
#ifndef YYPARSER
#include "geo_parse.h"
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define WORD unsigned short int
#define MAXTOKENLEN 64
#define MAXCHILDREN 3
typedef int TokenType;
extern int lineno;
extern char tokenString[MAXTOKENLEN+1];
extern FILE * source;
/******************************************************************************
*
* Syntax tree for parsing
*
*****************************************************************************/
typedef enum {FileK,HeadK,GeometryK,FloatK,IndexK,StringK,VertexK,VertexListK,NormalK,NormalListK,TexCoordK,TexCoordListK,PolyK,PolyTypeK,MaterialK,VertexIndexK,NormalIndexK,TexCoordIndexK,VertexIndexListK,NormalIndexListK,TexCoordIndexListK} NodeKind_t;
typedef struct treeNode {
NodeKind_t nodeKind;
struct treeNode * sibling;
struct treeNode * child[MAXCHILDREN];
union {
int index;
float value;
char * name;
PolyType_t polyType;
} attr;
} TreeNode_t;
/*
Declarations to prevent SYMBOL NOT FOUND in c++
*/
static TokenType yylex();
int yyerror(char *);
TreeNode_t *parse();
extern int getToken();
void writebogfile(TreeNode_t *, FILE *, FILE *);
#endif /* _GLOBALS_H */

308
util/geo2bog/parse.c Normal file
View File

@@ -0,0 +1,308 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "globals.h"
#include "parse.h"
TreeNode_t * linkNode(TreeNode_t * n1, TreeNode_t * n2){
TreeNode_t * t = n1;
if (t != NULL) {
while (t->sibling != NULL)
t = t->sibling;
t->sibling = n2;
return n1;
} else return n2;
}
TreeNode_t * newFile(TreeNode_t * head, TreeNode_t * geometry){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = FileK;
treeNode->child[0] = head;
treeNode->child[1] = geometry;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newHead(TreeNode_t * version){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = HeadK;
treeNode->child[0] = version;
treeNode->child[1] = NULL;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newGeometry(TreeNode_t * list, TreeNode_t * poly){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = GeometryK;
treeNode->child[0] = list;
treeNode->child[1] = poly;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newVertex(TreeNode_t * v1, TreeNode_t * v2, TreeNode_t * v3){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = VertexK;
treeNode->child[0] = v1;
treeNode->child[1] = v2;
treeNode->child[2] = v3;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newNormal(TreeNode_t * v1, TreeNode_t * v2, TreeNode_t * v3){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = NormalK;
treeNode->child[0] = v1;
treeNode->child[1] = v2;
treeNode->child[2] = v3;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newTexCoord(TreeNode_t * v1, TreeNode_t * v2){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = TexCoordK;
treeNode->child[0] = v1;
treeNode->child[1] = v2;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newVertexList(TreeNode_t * vertex){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = VertexListK;
treeNode->child[0] = vertex;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newNormalList(TreeNode_t * normal){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = NormalListK;
treeNode->child[0] = normal;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newTexCoordList(TreeNode_t * texCoord){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = TexCoordListK;
treeNode->child[0] = texCoord;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newFloat(float value){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = FloatK;
treeNode->attr.value = value;
return treeNode;
}
TreeNode_t * newIndex(int index){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = IndexK;
treeNode->attr.index = index;
return treeNode;
}
TreeNode_t * newPoly(TreeNode_t * polyattr){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = PolyK;
treeNode->child[0] = polyattr;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newPolyType(PolyType_t polyType){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = PolyTypeK;
treeNode->attr.polyType = polyType;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newMaterial(char * name){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = MaterialK;
treeNode->attr.name = name;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newVertexIndexList(TreeNode_t * indexList){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = VertexIndexListK;
treeNode->child[0] = indexList;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newNormalIndexList(TreeNode_t * indexList){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = NormalIndexListK;
treeNode->child[0] = indexList;
treeNode->sibling = NULL;
return treeNode;
}
TreeNode_t * newTexCoordIndexList(TreeNode_t * indexList){
TreeNode_t * treeNode = (TreeNode_t *)malloc( sizeof (TreeNode_t) );
treeNode->nodeKind = TexCoordIndexListK;
treeNode->child[0] = indexList;
treeNode->sibling = NULL;
return treeNode;
}
void printTree(TreeNode_t * node){
if (node == NULL) return;
switch (node->nodeKind){
case GeometryK:
printf("Geometry {\n");
printTree(node->child[0]);
printTree(node->child[1]);
printf("}\n");
break;
case VertexListK:
printf("\tVertexList = [\t");
printTree(node->child[0]);
printf(" ];\n");
printTree(node->sibling);
break;
case NormalListK:
printf("\tNormalList = [\t");
printTree(node->child[0]);
printf(" ];\n");
printTree(node->sibling);
break;
case TexCoordListK:
printf("\tTexCoordList = [ ");
printTree(node->child[0]);
printf(" ];\n");
printTree(node->sibling);
break;
case VertexK:
printf("( ");
printTree(node->child[0]);
printf(", ");
printTree(node->child[1]);
printf(", ");
printTree(node->child[2]);
printf(")");
if (node->sibling != NULL) {
printf(",\n\t\t\t");
printTree(node->sibling);
}
break;
case NormalK:
printf("( ");
printTree(node->child[0]);
printf(", ");
printTree(node->child[1]);
printf(", ");
printTree(node->child[2]);
printf(")");
if (node->sibling != NULL) {
printf(",\n\t\t\t");
printTree(node->sibling);
}
break;
case TexCoordK:
printf("( ");
printTree(node->child[0]);
printf(", ");
printTree(node->child[1]);
printf(")");
if (node->sibling != NULL) {
printf(",\n\t\t\t");
printTree(node->sibling);
}
break;
case PolyK:
printf("\tPolygon {\n");
printTree(node->child[0]);
printf("\t}\n");
printTree(node->sibling);
break;
case PolyTypeK:
printf("\t\tType = ");
switch(node->attr.polyType){
case PT_Polygon:
printf("POLYGON");
break;
case PT_Triangles:
printf("TRIANGLES");
break;
case PT_Quads:
printf("QUADS");
break;
case PT_Quad_strip:
printf("QUAD_STRIP");
break;
case PT_Triangle_strip:
printf("TRIANGLE_STRIP");
break;
case PT_Triangle_fan:
printf("TRIANGLE_FAN");
break;
}
printf("\n");
printTree(node->sibling);
break;
case MaterialK:
printf("\t\tMaterial = %s\n",node->attr.name);
printTree(node->sibling);
break;
case VertexIndexListK:
printf("\t\tVertex = [ ");
printTree(node->child[0]);
printf("];\n");
printTree(node->sibling);
break;
case NormalIndexListK:
printf("\t\tNormal = [ ");
printTree(node->child[0]);
printf("];\n");
printTree(node->sibling);
break;
case TexCoordIndexListK:
printf("\t\tTexCoord = [ ");
printTree(node->child[0]);
printf("];\n");
printTree(node->sibling);
break;
case IndexK:
printf("%i",node->attr.index);
if (node->sibling != NULL){
printf(", ");
printTree(node->sibling);
}
break;
case FloatK:
printf("%f",node->attr.value);
break;
}
}

50
util/geo2bog/parse.h Normal file
View File

@@ -0,0 +1,50 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _PARS_H
#define _PARS_H
TreeNode_t * parse(void);
TreeNode_t * linkNode(TreeNode_t * n1, TreeNode_t * n2 );
TreeNode_t * newFile(TreeNode_t * head, TreeNode_t * geometry);
TreeNode_t * newHead(TreeNode_t * version);
TreeNode_t * newGeometry(TreeNode_t * list, TreeNode_t * poly);
TreeNode_t * newVertex(TreeNode_t * v1, TreeNode_t * v2, TreeNode_t * v3);
TreeNode_t * newNormal(TreeNode_t * v1, TreeNode_t * v2, TreeNode_t * v3);
TreeNode_t * newTexCoord(TreeNode_t * v1, TreeNode_t * v2);
TreeNode_t * newVertexList(TreeNode_t * vertex);
TreeNode_t * newNormalList(TreeNode_t * normal);
TreeNode_t * newTexCoordList(TreeNode_t * texCoord);
TreeNode_t * newFloat(float value);
TreeNode_t * newIndex(int index);
TreeNode_t * newPoly(TreeNode_t * polyattr );
TreeNode_t * newPolyType(PolyType_t polyType );
TreeNode_t * newMaterial(char * name );
TreeNode_t * newVertexIndexList(TreeNode_t * indexList);
TreeNode_t * newNormalIndexList(TreeNode_t * indexList);
TreeNode_t * newTexCoordIndexList(TreeNode_t * indexList);
void printTree(TreeNode_t * node);
#endif /* _PARS_H */

35
util/geo2bog/util.c Normal file
View File

@@ -0,0 +1,35 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "globals.h"
#include "util.h"
char * copyString(char * s){
int n;
char * t;
if (s==NULL) return NULL;
n = strlen(s)+1;
t = (char *)malloc(n);
if (t==NULL)
printf("Error: Out of memory error at line %d\n",lineno);
else strcpy(t,s);
return t;
}

22
util/geo2bog/util.h Normal file
View File

@@ -0,0 +1,22 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
char * copyString(char * s);

310
util/geo2bog/writebog.c Normal file
View File

@@ -0,0 +1,310 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "globals.h"
#include "writebog.h"
#include "namedb.H"
CNameDB * nameDB;
void countElements(TreeNode_t * node, WORD * numV, WORD * numN,
WORD * numTC, WORD * numP){
if (node == NULL) return;
switch (node->nodeKind){
case FileK:
case GeometryK:
countElements(node->child[0],numV,numN,numTC,numP);
countElements(node->child[1],numV,numN,numTC,numP);
break;
case VertexListK:
case NormalListK:
case TexCoordListK:
countElements(node->child[0],numV,numN,numTC,numP);
countElements(node->sibling,numV,numN,numTC,numP);
break;
case VertexK:
(*numV)++;
countElements(node->sibling,numV,numN,numTC,numP);
break;
case NormalK:
(*numN)++;
countElements(node->sibling,numV,numN,numTC,numP);
break;
case TexCoordK:
(*numTC)++;
countElements(node->sibling,numV,numN,numTC,numP);
break;
case PolyK:
(*numP)++;
countElements(node->sibling,numV,numN,numTC,numP);
break;
}
}
void writeVertex(TreeNode_t * node, FILE * bogfile ){
if (node == NULL) return;
switch (node->nodeKind){
case GeometryK:
writeVertex(node->child[0],bogfile);
break;
case VertexListK:
writeVertex(node->child[0],bogfile);
writeVertex(node->sibling,bogfile);
break;
case NormalListK:
case TexCoordListK:
writeVertex(node->sibling,bogfile);
break;
case VertexK:
fprintf(bogfile,"%f %f %f\n", node->child[0]->attr.value,
node->child[1]->attr.value, node->child[2]->attr.value);
writeVertex(node->sibling,bogfile);
break;
}
}
void writeNormal(TreeNode_t * node, FILE * bogfile ){
if (node == NULL) return;
switch (node->nodeKind){
case GeometryK:
writeNormal(node->child[0],bogfile);
break;
case NormalListK:
writeNormal(node->child[0],bogfile);
writeNormal(node->sibling,bogfile);
break;
case VertexListK:
case TexCoordListK:
writeNormal(node->sibling,bogfile);
break;
case NormalK:
fprintf(bogfile,"%f %f %f\n", node->child[0]->attr.value,
node->child[1]->attr.value, node->child[2]->attr.value);
writeNormal(node->sibling,bogfile);
break;
}
}
void writeTexCoord(TreeNode_t * node, FILE * bogfile ){
if (node == NULL) return;
switch (node->nodeKind){
case GeometryK:
writeTexCoord(node->child[0],bogfile);
break;
case TexCoordListK:
writeTexCoord(node->child[0],bogfile);
writeTexCoord(node->sibling,bogfile);
break;
case VertexListK:
case NormalListK:
writeTexCoord(node->sibling,bogfile);
break;
case TexCoordK:
fprintf(bogfile,"%f %f\n", node->child[0]->attr.value,
node->child[1]->attr.value);
writeTexCoord(node->sibling,bogfile);
break;
}
}
void writePolygonType(TreeNode_t * node, FILE * bogfile ){
if (node == NULL) return;
if (node->nodeKind == PolyTypeK){
fprintf(bogfile,"%i ",node->attr.polyType);
} else writePolygonType(node->sibling,bogfile);
}
void writePolygonMaterial(TreeNode_t * node, FILE * bogfile ){
if (node == NULL) return;
if (node->nodeKind == MaterialK){
fprintf(bogfile,"%i ",nameDB->insert(node->attr.name));
} else writePolygonMaterial(node->sibling,bogfile);
}
void writePolygonVertices(TreeNode_t * node, FILE * bogfile ){
if (node == NULL) return;
switch (node->nodeKind){
case VertexIndexListK:
writePolygonVertices(node->child[0],bogfile);
break;
case IndexK:
fprintf(bogfile,"%i ",node->attr.index);
if (node->sibling == NULL) fprintf(bogfile,"\n");
break;
}
writePolygonVertices(node->sibling,bogfile);
}
void writePolygonNormals(TreeNode_t * node, FILE * bogfile ){
if (node == NULL) return;
switch (node->nodeKind){
case NormalIndexListK:
writePolygonNormals(node->child[0],bogfile);
break;
case IndexK:
fprintf(bogfile,"%i ",node->attr.index);
if (node->sibling == NULL) fprintf(bogfile,"\n");
break;
}
writePolygonNormals(node->sibling,bogfile);
}
void writePolygonTexCoords(TreeNode_t * node, FILE * bogfile ){
if (node == NULL) return;
switch (node->nodeKind){
case TexCoordIndexListK:
writePolygonTexCoords(node->child[0],bogfile);
break;
case IndexK:
fprintf(bogfile,"%i ",node->attr.index);
if (node->sibling == NULL) fprintf(bogfile,"\n");
break;
}
writePolygonTexCoords(node->sibling,bogfile);
}
void countIndex(TreeNode_t * node, WORD * numI){
if (node == NULL) return;
switch (node->nodeKind){
case IndexK:
(*numI)++;
break;
}
countIndex(node->sibling,numI);
}
void countPolygon(TreeNode_t * node, WORD * numV, WORD * numN,
WORD * numTC){
if (node == NULL) return;
switch (node->nodeKind){
case VertexIndexListK:
countIndex(node->child[0],numV);
break;
case NormalIndexListK:
countIndex(node->child[0],numN);
break;
case TexCoordIndexListK:
countIndex(node->child[0],numTC);
break;
}
countPolygon(node->sibling,numV,numN,numTC);
}
void writePolygon(TreeNode_t * node, FILE * bogfile ){
WORD numV,numN,numTC;
if (node == NULL) return;
switch (node->nodeKind){
case GeometryK:
writePolygon(node->child[1],bogfile);
break;
case PolyK:
writePolygonType(node->child[0],bogfile);
writePolygonMaterial(node->child[0],bogfile);
numV = numN = numTC = 0;
countPolygon(node->child[0],&numV,&numN,&numTC);
fprintf(bogfile,"%i %i %i\n",numV,numN,numTC);
writePolygonVertices(node->child[0],bogfile);
writePolygonNormals(node->child[0],bogfile);
writePolygonTexCoords(node->child[0],bogfile);
writePolygon(node->sibling,bogfile);
break;
}
}
void countObjects(TreeNode_t * node,WORD * numO){
if (node == NULL) return;
switch (node->nodeKind){
case FileK:
countObjects(node->child[1],numO);
break;
case GeometryK:
(*numO)++;
countObjects(node->sibling,numO);
break;
default:
printf("Error: countObjects not supposed to encounter this node!\n");
}
}
void writeObjects(TreeNode_t * node,FILE * bogfile, WORD objectId){
WORD numVertices,numNormals,numTexCoords,numPolygons;
if (node == NULL) return;
switch (node->nodeKind){
case FileK:
writeObjects(node->child[1],bogfile,objectId);
break;
case GeometryK:
numVertices = 0;
numNormals = 0;
numTexCoords = 0;
numPolygons = 0;
countElements(node,&numVertices,&numNormals,&numTexCoords,&numPolygons);
fprintf(bogfile,"%i %i %i %i %i\n",
objectId,numVertices,numNormals,numTexCoords,numPolygons);
writeVertex(node,bogfile);
writeNormal(node,bogfile);
writeTexCoord(node,bogfile);
writePolygon(node,bogfile);
writeObjects(node->sibling,bogfile,objectId+1);
break;
default:
printf("Error: writeObjects not supposed to encounter this node!\n");
}
}
void writebogfile(TreeNode_t * node, FILE * bogfile, FILE * ndbfile ){
WORD numObjects;
numObjects = 0;
nameDB = new CNameDB;
countObjects(node,&numObjects);
fprintf(bogfile,"BOG 1 %i\n",numObjects);
writeObjects(node,bogfile,0);
nameDB->writeNDB(ndbfile);
delete nameDB;
}

25
util/geo2bog/writebog.h Normal file
View File

@@ -0,0 +1,25 @@
/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _WRITEBOG_H
#define _WRITEBOG_H
void writebogfile(TreeNode_t * node, FILE * bogfile, FILE * ndbfile);
#endif /* _WRITEBOG_H */