Recovered from microbel
This commit is contained in:
5
common/lib/geometry/Makefile.am
Normal file
5
common/lib/geometry/Makefile.am
Normal file
@@ -0,0 +1,5 @@
|
||||
INCLUDES = -I../../include
|
||||
|
||||
noinst_LIBRARIES = libgeometry.a
|
||||
|
||||
libgeometry_a_SOURCES = cache.C geometry.C int.C material.C readbog.C readmat.C vertex.C writebog.C
|
330
common/lib/geometry/Makefile.in
Normal file
330
common/lib/geometry/Makefile.in
Normal file
@@ -0,0 +1,330 @@
|
||||
# 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 = :
|
||||
CC = @CC@
|
||||
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../../include
|
||||
|
||||
noinst_LIBRARIES = libgeometry.a
|
||||
|
||||
libgeometry_a_SOURCES = cache.C geometry.C int.C material.C readbog.C readmat.C vertex.C writebog.C
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
|
||||
|
||||
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@
|
||||
libgeometry_a_LIBADD =
|
||||
libgeometry_a_OBJECTS = cache.o geometry.o int.o material.o readbog.o \
|
||||
readmat.o vertex.o writebog.o
|
||||
AR = ar
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_COMMON = Makefile.am Makefile.in TODO
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/cache.P .deps/geometry.P .deps/int.P .deps/material.P \
|
||||
.deps/readbog.P .deps/readmat.P .deps/vertex.P .deps/writebog.P
|
||||
SOURCES = $(libgeometry_a_SOURCES)
|
||||
OBJECTS = $(libgeometry_a_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .C .S .c .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --foreign common/lib/geometry/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-noinstLIBRARIES:
|
||||
|
||||
clean-noinstLIBRARIES:
|
||||
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
|
||||
|
||||
distclean-noinstLIBRARIES:
|
||||
|
||||
maintainer-clean-noinstLIBRARIES:
|
||||
|
||||
.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:
|
||||
|
||||
libgeometry.a: $(libgeometry_a_OBJECTS) $(libgeometry_a_DEPENDENCIES)
|
||||
-rm -f libgeometry.a
|
||||
$(AR) cru libgeometry.a $(libgeometry_a_OBJECTS) $(libgeometry_a_LIBADD)
|
||||
$(RANLIB) libgeometry.a
|
||||
.C.o:
|
||||
$(CXXCOMPILE) -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 = common/lib/geometry
|
||||
|
||||
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 common/lib/geometry/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
|
||||
|
||||
%.o: %.C
|
||||
@echo '$(CXXCOMPILE) -c $<'; \
|
||||
$(CXXCOMPILE) -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 '$(LTCXXCOMPILE) -c $<'; \
|
||||
$(LTCXXCOMPILE) -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-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: uninstall-am
|
||||
all-am: Makefile $(LIBRARIES)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
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:
|
||||
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-depend mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-depend \
|
||||
clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-noinstLIBRARIES distclean-compile \
|
||||
distclean-tags distclean-depend distclean-generic \
|
||||
clean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-noinstLIBRARIES \
|
||||
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-noinstLIBRARIES distclean-noinstLIBRARIES \
|
||||
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
|
||||
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
|
||||
|
||||
|
||||
# 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:
|
3
common/lib/geometry/TODO
Normal file
3
common/lib/geometry/TODO
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
CPolygon materialId int -> DWORD
|
||||
|
66
common/lib/geometry/cache.C
Normal file
66
common/lib/geometry/cache.C
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 "pvvmud.H"
|
||||
#include "cache.H"
|
||||
|
||||
CCache::CCache(){
|
||||
cache = new CObjectList();
|
||||
}
|
||||
|
||||
CObject * CCache::failFunc(int id){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CObject* CCache::add(int id, CObject * item){
|
||||
CObjectListItem * listItem = cache->getFirst();
|
||||
|
||||
while ( listItem != NULL ){
|
||||
CCacheItem * cacheItem = (CCacheItem*)listItem->getObject();
|
||||
if (cacheItem->getId() == id){
|
||||
return cacheItem->setItem(item);
|
||||
}
|
||||
listItem = listItem->getNext();
|
||||
}
|
||||
|
||||
CCacheItem * newItem = new CCacheItem(id,item);
|
||||
cache->addLast((CObject*)newItem);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
CObject * CCache::get(int id){
|
||||
CObjectListItem * item = cache->getFirst();
|
||||
|
||||
while ( item != NULL ){
|
||||
CCacheItem * cacheItem = (CCacheItem*)item->getObject();
|
||||
if (cacheItem->getId() == id) return cacheItem->getItem();
|
||||
item = item->getNext();
|
||||
}
|
||||
|
||||
// Failed to find object in cache calling failFunc
|
||||
CObject * newObject = failFunc(id);
|
||||
if (newObject != NULL) add(id,newObject);
|
||||
|
||||
return newObject;
|
||||
}
|
||||
|
||||
void CCache::clear(){
|
||||
cache->deleteAll();
|
||||
}
|
1107
common/lib/geometry/geometry.C
Normal file
1107
common/lib/geometry/geometry.C
Normal file
File diff suppressed because it is too large
Load Diff
37
common/lib/geometry/int.C
Normal file
37
common/lib/geometry/int.C
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 "pvvmud.H"
|
||||
#include "int.H"
|
||||
|
||||
CInt::CInt(int index){
|
||||
cInt = index;
|
||||
}
|
||||
|
||||
CInt::~CInt(){
|
||||
}
|
||||
|
||||
int CInt::getValue(){
|
||||
return cInt;
|
||||
}
|
||||
|
||||
int CInt::setValue(int value){
|
||||
cInt = value;
|
||||
return value;
|
||||
}
|
184
common/lib/geometry/material.C
Normal file
184
common/lib/geometry/material.C
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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 "pvvmud.H"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "material.H"
|
||||
|
||||
|
||||
CMaterial::CMaterial(){
|
||||
m_id = -1;
|
||||
m_textureId = MAT_NOTEXTURE;
|
||||
setAmbient(0.2,0.2,0.2,1.0);
|
||||
setDiffuse(0.8,0.8,0.8,1.0);
|
||||
setSpecular(0.0,0.0,0.0,1.0);
|
||||
setShininess(0.0F);
|
||||
setEmission(0.0,0.0,0.0,1.0);
|
||||
}
|
||||
|
||||
CMaterial::CMaterial(int materialId){
|
||||
m_id = materialId;
|
||||
m_textureId = MAT_NOTEXTURE;
|
||||
setAmbient(0.2,0.2,0.2,1.0);
|
||||
setDiffuse(0.8,0.8,0.8,1.0);
|
||||
setSpecular(0.0,0.0,0.0,1.0);
|
||||
setShininess(0.0F);
|
||||
setEmission(0.0,0.0,0.0,1.0);
|
||||
}
|
||||
|
||||
CMaterial::CMaterial(int materialId, char * name){
|
||||
m_id = materialId;
|
||||
CMaterial(m_id);
|
||||
load(name);
|
||||
}
|
||||
|
||||
void CMaterial::setId(int materialId){
|
||||
m_id = materialId;
|
||||
}
|
||||
|
||||
|
||||
void CMaterial::RGBA_SetColor(RGBA_t rgba,float red, float green, float blue, float alpha){
|
||||
rgba[0] = red;
|
||||
rgba[1] = green;
|
||||
rgba[2] = blue;
|
||||
rgba[3] = alpha;
|
||||
}
|
||||
|
||||
void CMaterial::RGBA_Print(RGBA_t rgba){
|
||||
printf("%f %f %f %fi\n",rgba[0],rgba[1],rgba[2],rgba[3]);
|
||||
}
|
||||
|
||||
void CMaterial::setTextureId(int textureId){
|
||||
m_textureId = textureId;
|
||||
}
|
||||
|
||||
int CMaterial::getTextureId() {
|
||||
return m_textureId;
|
||||
}
|
||||
|
||||
|
||||
void CMaterial::setAmbient(float red, float green, float blue, float alpha){
|
||||
RGBA_SetColor(m_ambient,red,green,blue,alpha);
|
||||
}
|
||||
|
||||
void CMaterial::setDiffuse(float red, float green, float blue, float alpha){
|
||||
RGBA_SetColor(m_diffuse,red,green,blue,alpha);
|
||||
}
|
||||
|
||||
void CMaterial::setSpecular(float red, float green, float blue, float alpha){
|
||||
RGBA_SetColor(m_specular,red,green,blue,alpha);
|
||||
}
|
||||
|
||||
void CMaterial::setShininess(float shininess){
|
||||
m_shininess[0] = shininess;
|
||||
}
|
||||
|
||||
void CMaterial::setEmission(float red, float green, float blue, float alpha){
|
||||
RGBA_SetColor(m_emission,red,green,blue,alpha);
|
||||
}
|
||||
|
||||
BYTE CMaterial::getAmbientByte(int num){
|
||||
return (BYTE)(m_ambient[num]*255.0F);
|
||||
}
|
||||
|
||||
BYTE CMaterial::getDiffuseByte(int num){
|
||||
return (BYTE)(m_diffuse[num]*255.0F);
|
||||
}
|
||||
|
||||
BYTE CMaterial::getSpecularByte(int num){
|
||||
return (BYTE)(m_specular[num]*255.0F);
|
||||
}
|
||||
|
||||
BYTE CMaterial::getEmissionByte(int num){
|
||||
return (BYTE)(m_emission[num]*255.0F);
|
||||
}
|
||||
|
||||
BYTE CMaterial::getShininessByte(){
|
||||
return (BYTE)(m_shininess[0]*255.0F);
|
||||
}
|
||||
|
||||
float CMaterial::getAmbientFloat(int num){
|
||||
return m_ambient[num];
|
||||
}
|
||||
|
||||
float CMaterial::getDiffuseFloat(int num){
|
||||
return m_diffuse[num];
|
||||
}
|
||||
|
||||
float CMaterial::getSpecularFloat(int num){
|
||||
return m_specular[num];
|
||||
}
|
||||
|
||||
float CMaterial::getEmissionFloat(int num){
|
||||
return m_emission[num];
|
||||
}
|
||||
|
||||
float CMaterial::getShininessFloat(){
|
||||
return m_shininess[0];
|
||||
}
|
||||
|
||||
void CMaterial::setAmbient(int num,BYTE value){
|
||||
m_ambient[num] = (float)(value) * (1.0F / 255.0F);
|
||||
}
|
||||
|
||||
void CMaterial::setDiffuse(int num,BYTE value){
|
||||
m_diffuse[num] = (float)(value) * (1.0F / 255.0F);
|
||||
}
|
||||
|
||||
void CMaterial::setSpecular(int num,BYTE value){
|
||||
m_specular[num] = (float)(value) * (1.0F / 255.0F);
|
||||
}
|
||||
|
||||
void CMaterial::setEmission(int num,BYTE value){
|
||||
m_emission[num] = (float)(value) * (1.0F / 255.0F);
|
||||
}
|
||||
|
||||
void CMaterial::setShininess(BYTE value){
|
||||
m_shininess[0] = (float)(value) * (1.0F / 255.0F);
|
||||
}
|
||||
|
||||
int CMaterial::exec(CTextureCache * texCache){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
*
|
||||
* Add material to MaterialCache
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
CMaterialCache::CMaterialCache():CCache(){
|
||||
}
|
||||
|
||||
CMaterial* CMaterialCache::add(CMaterial * mat) {
|
||||
return (CMaterial*)CCache::add(mat->getId(),mat);
|
||||
}
|
||||
|
||||
CMaterial * CMaterialCache::get(int id){
|
||||
return (CMaterial*)CCache::get(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
160
common/lib/geometry/readbog.C
Normal file
160
common/lib/geometry/readbog.C
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
/******************************************************************************
|
||||
*
|
||||
* Utilities for reading BOG file format
|
||||
*
|
||||
* Standard: Useing standard suggested in bogfileformat.html with
|
||||
* rcs version 1.2 from the pvvmud web pages
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "pvvmud.H"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <iostream.h>
|
||||
|
||||
#include "geometry.H"
|
||||
#include "bogfile.H"
|
||||
#include "exception.H"
|
||||
|
||||
//void CGeometry::load(int objId, char * name) {
|
||||
// setId(objId);
|
||||
// load(name);
|
||||
//}
|
||||
|
||||
void CGeometry::load(char * name) {
|
||||
FILE * bog;
|
||||
bog = fopen(name,"r");
|
||||
if (bog == NULL){
|
||||
cdebug << "Error: Failed to open BOG file " << name << "\n";
|
||||
throw new CException();
|
||||
}
|
||||
readBOG(bog);
|
||||
fclose(bog);
|
||||
}
|
||||
|
||||
|
||||
int CGeometry::readBOGCore(FILE * bog, int numV, int numN,
|
||||
int numTC, int numP){
|
||||
int ii,jj;
|
||||
int type,gltype,materialId,index;
|
||||
double d1,d2,d3;
|
||||
CPolygon * poly;
|
||||
|
||||
for (ii = 0; ii < numV; ii++){
|
||||
fscanf(bog,"%lf %lf %lf",&d1,&d2,&d3);
|
||||
addVertex(d1,d2,d3);
|
||||
}
|
||||
|
||||
for (ii = 0; ii < numN; ii++){
|
||||
fscanf(bog,"%lf %lf %lf",&d1,&d2,&d3);
|
||||
addNormal(d1,d2,d3);
|
||||
}
|
||||
|
||||
for (ii = 0; ii < numTC; ii++){
|
||||
fscanf(bog,"%lf %lf",&d1,&d2);
|
||||
addTexCoord(d1,d2);
|
||||
}
|
||||
|
||||
for (ii = 0; ii < numP; ii++){
|
||||
fscanf(bog,"%i %i %i %i %i",&type,&materialId,&numV,&numN,&numTC);
|
||||
|
||||
switch (type){
|
||||
case PT_Polygon: gltype = POLYGON_POLYGON; break;
|
||||
case PT_Triangles: gltype = POLYGON_TRIANGLES; break;
|
||||
case PT_Quads: gltype = POLYGON_QUADS; break;
|
||||
case PT_Quad_strip: gltype = POLYGON_QUAD_STRIP; break;
|
||||
case PT_Triangle_strip: gltype = POLYGON_TRIANGLE_STRIP; break;
|
||||
case PT_Triangle_fan: gltype = POLYGON_TRIANGLE_FAN; break;
|
||||
}
|
||||
|
||||
poly = new CPolygon(gltype,materialId,numV,numN,numTC);
|
||||
|
||||
for (jj = 0; jj < numV; jj++){
|
||||
fscanf(bog,"%i",&index);
|
||||
poly->addVertexIndex(index);
|
||||
}
|
||||
|
||||
for (jj = 0; jj < numN; jj++){
|
||||
fscanf(bog,"%i",&index);
|
||||
poly->addNormalIndex(index);
|
||||
}
|
||||
|
||||
for (jj = 0; jj < numTC; jj++){
|
||||
fscanf(bog,"%i",&index);
|
||||
poly->addTexCoordIndex(index);
|
||||
}
|
||||
|
||||
addPolygon(poly);
|
||||
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void CGeometry::readBOG(FILE * bog ){
|
||||
|
||||
CGeometry *geo=NULL,*lastgeo=NULL;
|
||||
int version,numSub,subid;
|
||||
int numV,numN,numTC,numP;
|
||||
int ii;
|
||||
char name[5];
|
||||
|
||||
// Read header : BOG <version> <numSubObjects>
|
||||
|
||||
fscanf(bog,"%s",name);
|
||||
|
||||
if (strcmp(name,"BOG") != 0){
|
||||
throw new CException();
|
||||
} else {
|
||||
fscanf(bog,"%i %i",&version,&numSub);
|
||||
if (version != 1) throw new CException();
|
||||
}
|
||||
|
||||
geo = this;
|
||||
|
||||
for (ii = 0; ii < numSub; ii++){
|
||||
|
||||
fscanf(bog,"%i",&subid);
|
||||
|
||||
fscanf(bog,"%i %i %i %i",&numV,&numN,&numTC,&numP);
|
||||
|
||||
if (ii != 0){
|
||||
geo = newGeometry(getId());
|
||||
}
|
||||
|
||||
geo->setSize(numV,numN,numTC,numP);
|
||||
|
||||
if (lastgeo != NULL){
|
||||
lastgeo->setNext(geo);
|
||||
}
|
||||
|
||||
geo->setSubId(subid);
|
||||
geo->readBOGCore(bog,numV,numN,numTC,numP);
|
||||
lastgeo = geo;
|
||||
}
|
||||
|
||||
}
|
||||
|
155
common/lib/geometry/readmat.C
Normal file
155
common/lib/geometry/readmat.C
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <iostream.h>
|
||||
|
||||
#include "pvvmud.H"
|
||||
#include "material.H"
|
||||
#include "matfile.H"
|
||||
|
||||
|
||||
int CMaterial::load(char * fileName) {
|
||||
char * sufix;
|
||||
|
||||
sufix = strrchr(fileName,'.');
|
||||
if (sufix == NULL) {
|
||||
cdebug << "Failed!\n";
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( (strcmp(sufix,".bmat")==0) || (strcmp(sufix,".BMAT")==0) ){
|
||||
loadBMAT(fileName);
|
||||
} else {
|
||||
cdebug << "Failed!\n";
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int CMaterial::loadBMAT(char * fileName) {
|
||||
FILE * matFile;
|
||||
|
||||
matFile = fopen(fileName,"r");
|
||||
if (matFile == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
float red,green,blue,alpha,shininess;
|
||||
int matfileid,id;
|
||||
|
||||
while (fscanf(matFile,"%i",&matfileid)==1){
|
||||
switch (matfileid){
|
||||
case MAT_TEXTURE:
|
||||
fscanf(matFile,"%i\n",&id);
|
||||
setTextureId(id);
|
||||
break;
|
||||
case MAT_AMBIENT:
|
||||
fscanf(matFile,"%f %f %f %f\n",&red,&green,&blue,&alpha);
|
||||
setAmbient(red,green,blue,alpha);
|
||||
break;
|
||||
case MAT_DIFFUSE:
|
||||
fscanf(matFile,"%f %f %f %f\n",&red,&green,&blue,&alpha);
|
||||
setDiffuse(red,green,blue,alpha);
|
||||
break;
|
||||
case MAT_SPECULAR:
|
||||
fscanf(matFile,"%f %f %f %f\n",&red,&green,&blue,&alpha);
|
||||
setSpecular(red,green,blue,alpha);
|
||||
break;
|
||||
case MAT_EMISSION:
|
||||
fscanf(matFile,"%f %f %f %f\n",&red,&green,&blue,&alpha);
|
||||
setEmission(red,green,blue,alpha);
|
||||
break;
|
||||
case MAT_SHININESS:
|
||||
fscanf(matFile,"%f",&shininess);
|
||||
setShininess(shininess);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(matFile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int CMaterial::save(char * name) {
|
||||
FILE * matFile;
|
||||
int ii;
|
||||
|
||||
matFile = fopen(name,"w");
|
||||
if (matFile == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (getTextureId() != MAT_NOTEXTURE)
|
||||
fprintf(matFile,"%i %i\n",MAT_TEXTURE,getTextureId());
|
||||
|
||||
// Ambient
|
||||
fprintf(matFile,"%i",MAT_AMBIENT);
|
||||
for (ii = 0; ii < 4; ii++)
|
||||
fprintf(matFile," %f",getAmbientFloat(ii));
|
||||
fprintf(matFile,"\n");
|
||||
|
||||
// Diffuse
|
||||
fprintf(matFile,"%i",MAT_DIFFUSE);
|
||||
for (ii = 0; ii < 4; ii++)
|
||||
fprintf(matFile," %f",getDiffuseFloat(ii));
|
||||
fprintf(matFile,"\n");
|
||||
|
||||
// Specular
|
||||
fprintf(matFile,"%i",MAT_SPECULAR);
|
||||
for (ii = 0; ii < 4; ii++)
|
||||
fprintf(matFile," %f",getSpecularFloat(ii));
|
||||
fprintf(matFile,"\n");
|
||||
|
||||
// Emission
|
||||
fprintf(matFile,"%i",MAT_EMISSION);
|
||||
for (ii = 0; ii < 4; ii++)
|
||||
fprintf(matFile," %f",getEmissionFloat(ii));
|
||||
fprintf(matFile,"\n");
|
||||
|
||||
// Shininess
|
||||
fprintf(matFile,"%i %f\n",MAT_SHININESS,getShininessFloat());
|
||||
|
||||
fclose(matFile);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
41
common/lib/geometry/vertex.C
Normal file
41
common/lib/geometry/vertex.C
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 "pvvmud.H"
|
||||
#include "vertex.H"
|
||||
|
||||
|
||||
double CVertex::getX() const {
|
||||
return m_coord[0];
|
||||
}
|
||||
|
||||
double CVertex::getY() const {
|
||||
return m_coord[1];
|
||||
}
|
||||
|
||||
double CVertex::getZ() const {
|
||||
return m_coord[2];
|
||||
}
|
||||
|
||||
CVector CVertex::operator-(const CVertex & vertex) const{
|
||||
return CVector(getX()-vertex.getX(),
|
||||
getY()-vertex.getY(),getZ()-vertex.getZ());
|
||||
}
|
||||
|
||||
|
122
common/lib/geometry/writebog.C
Normal file
122
common/lib/geometry/writebog.C
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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 "pvvmud.H"
|
||||
#include <stdio.h>
|
||||
#include "geometry.H"
|
||||
#include "bogfile.H"
|
||||
#include "exception.H"
|
||||
|
||||
int CGeometry::writeBOG( FILE * bog ){
|
||||
|
||||
CGeometry * geo;
|
||||
CPolygon * poly;
|
||||
int numVertices,numNormals,numTexCoords,numPolygons,ii,jj,nn;
|
||||
int type,materialId,index,subid,numSubobj;
|
||||
double x,y,z,u,v;
|
||||
|
||||
numSubobj = getNumSubobjects();
|
||||
|
||||
fprintf(bog,"BOG 1 %i\n",numSubobj);
|
||||
|
||||
// Requrcive algo. done iterative
|
||||
geo = this;
|
||||
for (nn = 0; nn < numSubobj; nn++){
|
||||
|
||||
subid = geo->getSubId();
|
||||
numVertices = geo->getNumVertices();
|
||||
numNormals = geo->getNumNormals();
|
||||
numTexCoords = geo->getNumTexCoords();
|
||||
numPolygons = geo->getNumPolygons();
|
||||
|
||||
fprintf(bog,"%i %i %i %i %i\n",subid,numVertices,numNormals,
|
||||
numTexCoords,numPolygons);
|
||||
|
||||
for (ii = 0; ii < numVertices; ii ++){
|
||||
geo->getVertex(ii,&x,&y,&z);
|
||||
fprintf(bog,"%f %f %f\n",x,y,z);
|
||||
}
|
||||
|
||||
for (ii = 0; ii < numNormals; ii ++){
|
||||
geo->getNormal(ii,&x,&y,&z);
|
||||
fprintf(bog,"%f %f %f\n",x,y,z);
|
||||
}
|
||||
|
||||
for (ii = 0; ii < numTexCoords; ii ++){
|
||||
geo->getTexCoord(ii,&u,&v);
|
||||
fprintf(bog,"%f %f\n",u,v);
|
||||
}
|
||||
|
||||
for (ii = 0; ii < numPolygons; ii ++){
|
||||
poly = geo->getPolygon(ii);
|
||||
poly->get(&type,&materialId,&numVertices,&numNormals,&numTexCoords);
|
||||
switch (type){
|
||||
case POLYGON_POLYGON: type = PT_Polygon; break;
|
||||
case POLYGON_TRIANGLES: type = PT_Triangles; break;
|
||||
case POLYGON_QUADS: type = PT_Quads; break;
|
||||
case POLYGON_QUAD_STRIP: type = PT_Quad_strip; break;
|
||||
case POLYGON_TRIANGLE_STRIP: type = PT_Triangle_strip; break;
|
||||
case POLYGON_TRIANGLE_FAN: type = PT_Triangle_fan; break;
|
||||
}
|
||||
|
||||
|
||||
fprintf(bog,"%i %i %i %i %i\n",
|
||||
type, materialId, numVertices, numNormals, numTexCoords );
|
||||
for (jj = 0; jj < numVertices; jj++){
|
||||
index = poly->getVertexIndex(jj);
|
||||
if (jj != (numVertices-1))
|
||||
fprintf(bog,"%i ",index);
|
||||
else
|
||||
fprintf(bog,"%i\n",index);
|
||||
}
|
||||
for (jj = 0; jj < numNormals; jj++){
|
||||
index = poly->getNormalIndex(jj);
|
||||
if (jj != (numNormals-1))
|
||||
fprintf(bog,"%i ",index);
|
||||
else
|
||||
fprintf(bog,"%i\n",index);
|
||||
}
|
||||
for (jj = 0; jj < numTexCoords; jj++){
|
||||
index = poly->getTexCoordIndex(jj);
|
||||
if (jj != (numTexCoords-1))
|
||||
fprintf(bog,"%i ",index);
|
||||
else
|
||||
fprintf(bog,"%i\n",index);
|
||||
}
|
||||
}
|
||||
geo = geo->getNext();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CGeometry::save(char * name){
|
||||
FILE * bog;
|
||||
int res;
|
||||
|
||||
bog = fopen(name,"w");
|
||||
if (bog == NULL){
|
||||
fprintf(stderr,"Error: Failed to open file %s\n",name);
|
||||
throw new CException();
|
||||
}
|
||||
writeBOG(bog);
|
||||
fclose(bog);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user