Initial revision

brs2001 [2002-06-19 03:50:56]
Initial revision
Filename
client/client94/crystalspace/include/csdef.h
client/client94/crystalspace/include/csengine/arrays.h
client/client94/crystalspace/include/csengine/bezier.h
client/client94/crystalspace/include/csengine/bsp.h
client/client94/crystalspace/include/csengine/bsp2d.h
client/client94/crystalspace/include/csengine/bspbbox.h
client/client94/crystalspace/include/csengine/camera.h
client/client94/crystalspace/include/csengine/campos.h
client/client94/crystalspace/include/csengine/cbufcube.h
client/client94/crystalspace/include/csengine/cbuffer.h
client/client94/crystalspace/include/csengine/crysball.h
client/client94/crystalspace/include/csengine/cscoll.h
client/client94/crystalspace/include/csengine/curve.h
client/client94/crystalspace/include/csengine/engine.h
client/client94/crystalspace/include/csengine/halo.h
client/client94/crystalspace/include/csengine/lghtmap.h
client/client94/crystalspace/include/csengine/light.h
client/client94/crystalspace/include/csengine/lppool.h
client/client94/crystalspace/include/csengine/lview.h
client/client94/crystalspace/include/csengine/material.h
client/client94/crystalspace/include/csengine/meshobj.h
client/client94/crystalspace/include/csengine/movable.h
client/client94/crystalspace/include/csengine/octree.h
client/client94/crystalspace/include/csengine/pol2d.h
client/client94/crystalspace/include/csengine/poledges.h
client/client94/crystalspace/include/csengine/polygon.h
client/client94/crystalspace/include/csengine/polyint.h
client/client94/crystalspace/include/csengine/polyplan.h
client/client94/crystalspace/include/csengine/polytext.h
client/client94/crystalspace/include/csengine/polytmap.h
client/client94/crystalspace/include/csengine/polytree.h
client/client94/crystalspace/include/csengine/portal.h
client/client94/crystalspace/include/csengine/radiosty.h
client/client94/crystalspace/include/csengine/rdrprior.h
client/client94/crystalspace/include/csengine/region.h
client/client94/crystalspace/include/csengine/rview.h
client/client94/crystalspace/include/csengine/sector.h
client/client94/crystalspace/include/csengine/stats.h
client/client94/crystalspace/include/csengine/texture.h
client/client94/crystalspace/include/csengine/thing.h
client/client94/crystalspace/include/csengine/treeobj.h
client/client94/crystalspace/include/csengine/wirefrm.h
client/client94/crystalspace/include/csgeom/box.h
client/client94/crystalspace/include/csgeom/cspoint.h
client/client94/crystalspace/include/csgeom/csrect.h
client/client94/crystalspace/include/csgeom/csrectrg.h
client/client94/crystalspace/include/csgeom/fastsqrt.h
client/client94/crystalspace/include/csgeom/frustum.h
client/client94/crystalspace/include/csgeom/math2d.h
client/client94/crystalspace/include/csgeom/math3d.h
client/client94/crystalspace/include/csgeom/math3d_d.h
client/client94/crystalspace/include/csgeom/matrix2.h
client/client94/crystalspace/include/csgeom/matrix3.h
client/client94/crystalspace/include/csgeom/path.h
client/client94/crystalspace/include/csgeom/plane2.h
client/client94/crystalspace/include/csgeom/plane3.h
client/client94/crystalspace/include/csgeom/poly2d.h
client/client94/crystalspace/include/csgeom/poly3d.h
client/client94/crystalspace/include/csgeom/polyaa.h
client/client94/crystalspace/include/csgeom/polyclip.h
client/client94/crystalspace/include/csgeom/polyedge.h
client/client94/crystalspace/include/csgeom/polyidx.h
client/client94/crystalspace/include/csgeom/polypool.h
client/client94/crystalspace/include/csgeom/quaterni.h
client/client94/crystalspace/include/csgeom/segment.h
client/client94/crystalspace/include/csgeom/sphere.h
client/client94/crystalspace/include/csgeom/spline.h
client/client94/crystalspace/include/csgeom/subrec.h
client/client94/crystalspace/include/csgeom/tesselat.h
client/client94/crystalspace/include/csgeom/textrans.h
client/client94/crystalspace/include/csgeom/transfrm.h
client/client94/crystalspace/include/csgeom/vector2.h
client/client94/crystalspace/include/csgeom/vector3.h
client/client94/crystalspace/include/csgeom/vtpool.h
client/client94/crystalspace/include/csgfx/bumpmap.h
client/client94/crystalspace/include/csgfx/csimage.h
client/client94/crystalspace/include/csgfx/inv_cmap.h
client/client94/crystalspace/include/csgfx/memimage.h
client/client94/crystalspace/include/csgfx/quantize.h
client/client94/crystalspace/include/csgfx/rgbpixel.h
client/client94/crystalspace/include/csgfx/xorpat.h
client/client94/crystalspace/include/csphyzik/articula.h
client/client94/crystalspace/include/csphyzik/bodyforc.h
client/client94/crystalspace/include/csphyzik/contact.h
client/client94/crystalspace/include/csphyzik/ctcat.h
client/client94/crystalspace/include/csphyzik/ctcontct.h
client/client94/crystalspace/include/csphyzik/ctmatrix.h
client/client94/crystalspace/include/csphyzik/ctmspat.h
client/client94/crystalspace/include/csphyzik/ctquat.h
client/client94/crystalspace/include/csphyzik/ctvector.h
client/client94/crystalspace/include/csphyzik/ctvspat.h
client/client94/crystalspace/include/csphyzik/debug.h
client/client94/crystalspace/include/csphyzik/entity.h
client/client94/crystalspace/include/csphyzik/feathers.h
client/client94/crystalspace/include/csphyzik/force.h
client/client94/crystalspace/include/csphyzik/forces.h
client/client94/crystalspace/include/csphyzik/ik.h
client/client94/crystalspace/include/csphyzik/joint.h
client/client94/crystalspace/include/csphyzik/kinemat.h
client/client94/crystalspace/include/csphyzik/linklist.h
client/client94/crystalspace/include/csphyzik/math3d.h
client/client94/crystalspace/include/csphyzik/mathutil.h
client/client94/crystalspace/include/csphyzik/mc.h
client/client94/crystalspace/include/csphyzik/mtrxutil.h
client/client94/crystalspace/include/csphyzik/odesolve.h
client/client94/crystalspace/include/csphyzik/phyzent.h
client/client94/crystalspace/include/csphyzik/phyziks.h
client/client94/crystalspace/include/csphyzik/phyztype.h
client/client94/crystalspace/include/csphyzik/point.h
client/client94/crystalspace/include/csphyzik/ptforce.h
client/client94/crystalspace/include/csphyzik/ptmass.h
client/client94/crystalspace/include/csphyzik/qtrbconn.h
client/client94/crystalspace/include/csphyzik/qtrigid.h
client/client94/crystalspace/include/csphyzik/refframe.h
client/client94/crystalspace/include/csphyzik/rigidbod.h
client/client94/crystalspace/include/csphyzik/solver.h
client/client94/crystalspace/include/csphyzik/world.h
client/client94/crystalspace/include/css.h
client/client94/crystalspace/include/cssys/be/behelp.h
client/client94/crystalspace/include/cssys/be/csbe.h
client/client94/crystalspace/include/cssys/be/csosdefs.h
client/client94/crystalspace/include/cssys/csendian.h
client/client94/crystalspace/include/cssys/csosdefs.h
client/client94/crystalspace/include/cssys/csshlib.h
client/client94/crystalspace/include/cssys/djgpp/csosdefs.h
client/client94/crystalspace/include/cssys/djgpp/djgpp.h
client/client94/crystalspace/include/cssys/djgpp/doshelp.h
client/client94/crystalspace/include/cssys/getopt.h
client/client94/crystalspace/include/cssys/next/NeXTAssistant.h
client/client94/crystalspace/include/cssys/next/NeXTSystemDriver.h
client/client94/crystalspace/include/cssys/next/csosdefs.h
client/client94/crystalspace/include/cssys/os2/csos2.h
client/client94/crystalspace/include/cssys/os2/csosdefs.h
client/client94/crystalspace/include/cssys/os2/os2help.h
client/client94/crystalspace/include/cssys/sysdriv.h
client/client94/crystalspace/include/cssys/sysfunc.h
client/client94/crystalspace/include/cssys/system.h
client/client94/crystalspace/include/cssys/unix/csosdefs.h
client/client94/crystalspace/include/cssys/unix/mmiounix.h
client/client94/crystalspace/include/cssys/unix/unix.h
client/client94/crystalspace/include/cssys/win32/.cvsignore
client/client94/crystalspace/include/cssys/win32/csosdefs.h
client/client94/crystalspace/include/cssys/win32/cygosdef.h
client/client94/crystalspace/include/cssys/win32/volatile.h
client/client94/crystalspace/include/cssys/win32/win32.h
client/client94/crystalspace/include/cssysdef.h
client/client94/crystalspace/include/cstool/collider.h
client/client94/crystalspace/include/cstool/csanim2d.h
client/client94/crystalspace/include/cstool/csfxscr.h
client/client94/crystalspace/include/cstool/cspixmap.h
client/client94/crystalspace/include/cstool/csview.h
client/client94/crystalspace/include/cstool/gentrtex.h
client/client94/crystalspace/include/cstool/initapp.h
client/client94/crystalspace/include/cstool/keyval.h
client/client94/crystalspace/include/cstool/mapnode.h
client/client94/crystalspace/include/cstool/mdldata.h
client/client94/crystalspace/include/cstool/mdltool.h
client/client94/crystalspace/include/cstool/prdots.h
client/client94/crystalspace/include/cstool/prfire.h
client/client94/crystalspace/include/cstool/proctex.h
client/client94/crystalspace/include/cstool/prplasma.h
client/client94/crystalspace/include/cstool/prsky.h
client/client94/crystalspace/include/cstool/prwater.h
client/client94/crystalspace/include/cstool/sndwrap.h
client/client94/crystalspace/include/cstool/sprbuild.h
client/client94/crystalspace/include/cstool/vidprefs.h
client/client94/crystalspace/include/cstypes.h
client/client94/crystalspace/include/csutil/2bitary.h
client/client94/crystalspace/include/csutil/archive.h
client/client94/crystalspace/include/csutil/binder.h
client/client94/crystalspace/include/csutil/bitarray.h
client/client94/crystalspace/include/csutil/bitary2d.h
client/client94/crystalspace/include/csutil/bitset.h
client/client94/crystalspace/include/csutil/cfgacc.h
client/client94/crystalspace/include/csutil/cfgfile.h
client/client94/crystalspace/include/csutil/cfgmgr.h
client/client94/crystalspace/include/csutil/cmdhelp.h
client/client94/crystalspace/include/csutil/cmdline.h
client/client94/crystalspace/include/csutil/cscolor.h
client/client94/crystalspace/include/csutil/csctype.h
client/client94/crystalspace/include/csutil/csdllist.h
client/client94/crystalspace/include/csutil/csevcord.h
client/client94/crystalspace/include/csutil/csevent.h
client/client94/crystalspace/include/csutil/cseventq.h
client/client94/crystalspace/include/csutil/csinput.h
client/client94/crystalspace/include/csutil/csmd5.h
client/client94/crystalspace/include/csutil/csobject.h
client/client94/crystalspace/include/csutil/csobjvec.h
client/client94/crystalspace/include/csutil/cspmeter.h
client/client94/crystalspace/include/csutil/csppulse.h
client/client94/crystalspace/include/csutil/csqueue.h
client/client94/crystalspace/include/csutil/csrgbvct.h
client/client94/crystalspace/include/csutil/csstring.h
client/client94/crystalspace/include/csutil/csstrvec.h
client/client94/crystalspace/include/csutil/cstreend.h
client/client94/crystalspace/include/csutil/csvector.h
client/client94/crystalspace/include/csutil/databuf.h
client/client94/crystalspace/include/csutil/dataobj.h
client/client94/crystalspace/include/csutil/datastrm.h
client/client94/crystalspace/include/csutil/debug.h
client/client94/crystalspace/include/csutil/evoutlet.h
client/client94/crystalspace/include/csutil/flags.h
client/client94/crystalspace/include/csutil/garray.h
client/client94/crystalspace/include/csutil/halogen.h
client/client94/crystalspace/include/csutil/hashmap.h
client/client94/crystalspace/include/csutil/hashmapr.h
client/client94/crystalspace/include/csutil/inpnames.h
client/client94/crystalspace/include/csutil/intarray.h
client/client94/crystalspace/include/csutil/memfile.h
client/client94/crystalspace/include/csutil/mmapio.h
client/client94/crystalspace/include/csutil/nobjvec.h
client/client94/crystalspace/include/csutil/objiter.h
client/client94/crystalspace/include/csutil/objpool.h
client/client94/crystalspace/include/csutil/objreg.h
client/client94/crystalspace/include/csutil/parser.h
client/client94/crystalspace/include/csutil/plugldr.h
client/client94/crystalspace/include/csutil/plugmgr.h
client/client94/crystalspace/include/csutil/prfxcfg.h
client/client94/crystalspace/include/csutil/rng.h
client/client94/crystalspace/include/csutil/sarray.h
client/client94/crystalspace/include/csutil/scanstr.h
client/client94/crystalspace/include/csutil/scf.h
client/client94/crystalspace/include/csutil/scfstr.h
client/client94/crystalspace/include/csutil/scfstrv.h
client/client94/crystalspace/include/csutil/schedule.h
client/client94/crystalspace/include/csutil/snprintf.h
client/client94/crystalspace/include/csutil/sparse3d.h
client/client94/crystalspace/include/csutil/strset.h
client/client94/crystalspace/include/csutil/token.h
client/client94/crystalspace/include/csutil/typedvec.h
client/client94/crystalspace/include/csutil/util.h
client/client94/crystalspace/include/csutil/vfscache.h
client/client94/crystalspace/include/csutil/virtclk.h
client/client94/crystalspace/include/csutil/zip.h
client/client94/crystalspace/include/csver.h
client/client94/crystalspace/include/csws/csabslay.h
client/client94/crystalspace/include/csws/csapp.h
client/client94/crystalspace/include/csws/csbackgr.h
client/client94/crystalspace/include/csws/csbaglay.h
client/client94/crystalspace/include/csws/csbdrlay.h
client/client94/crystalspace/include/csws/csboxlay.h
client/client94/crystalspace/include/csws/csbutton.h
client/client94/crystalspace/include/csws/cschkbox.h
client/client94/crystalspace/include/csws/cscomp.h
client/client94/crystalspace/include/csws/cscwheel.h
client/client94/crystalspace/include/csws/csdialog.h
client/client94/crystalspace/include/csws/csflwlay.h
client/client94/crystalspace/include/csws/csgfxppl.h
client/client94/crystalspace/include/csws/csgrdlay.h
client/client94/crystalspace/include/csws/csgrid.h
client/client94/crystalspace/include/csws/cshints.h
client/client94/crystalspace/include/csws/csiline.h
client/client94/crystalspace/include/csws/cskeyacc.h
client/client94/crystalspace/include/csws/cslayout.h
client/client94/crystalspace/include/csws/cslistbx.h
client/client94/crystalspace/include/csws/csmenu.h
client/client94/crystalspace/include/csws/csmouse.h
client/client94/crystalspace/include/csws/csnotebk.h
client/client94/crystalspace/include/csws/csradbut.h
client/client94/crystalspace/include/csws/csscrbar.h
client/client94/crystalspace/include/csws/csskin.h
client/client94/crystalspace/include/csws/csspinbx.h
client/client94/crystalspace/include/csws/cssplit.h
client/client94/crystalspace/include/csws/csstatic.h
client/client94/crystalspace/include/csws/csstddlg.h
client/client94/crystalspace/include/csws/cstimer.h
client/client94/crystalspace/include/csws/cstree.h
client/client94/crystalspace/include/csws/csttlbar.h
client/client94/crystalspace/include/csws/cswindow.h
client/client94/crystalspace/include/csws/csws.h
client/client94/crystalspace/include/csws/cswsaux.h
client/client94/crystalspace/include/csws/cswspal.h
client/client94/crystalspace/include/csws/cswstex.h
client/client94/crystalspace/include/csws/cswsutil.h
client/client94/crystalspace/include/csws/sdefault.h
client/client94/crystalspace/include/iaws/aws.h
client/client94/crystalspace/include/iaws/awscnvs.h
client/client94/crystalspace/include/iaws/awsdefs.h
client/client94/crystalspace/include/iaws/awsecomp.h
client/client94/crystalspace/include/iaws/awsparm.h
client/client94/crystalspace/include/iengine/camera.h
client/client94/crystalspace/include/iengine/campos.h
client/client94/crystalspace/include/iengine/collectn.h
client/client94/crystalspace/include/iengine/dynlight.h
client/client94/crystalspace/include/iengine/engine.h
client/client94/crystalspace/include/iengine/fview.h
client/client94/crystalspace/include/iengine/halo.h
client/client94/crystalspace/include/iengine/light.h
client/client94/crystalspace/include/iengine/lod.h
client/client94/crystalspace/include/iengine/material.h
client/client94/crystalspace/include/iengine/mesh.h
client/client94/crystalspace/include/iengine/motion.h
client/client94/crystalspace/include/iengine/movable.h
client/client94/crystalspace/include/iengine/region.h
client/client94/crystalspace/include/iengine/rview.h
client/client94/crystalspace/include/iengine/sector.h
client/client94/crystalspace/include/iengine/shadcast.h
client/client94/crystalspace/include/iengine/shadows.h
client/client94/crystalspace/include/iengine/skelbone.h
client/client94/crystalspace/include/iengine/statlght.h
client/client94/crystalspace/include/iengine/texture.h
client/client94/crystalspace/include/iengine/viscull.h
client/client94/crystalspace/include/igeom/clip2d.h
client/client94/crystalspace/include/igraphic/image.h
client/client94/crystalspace/include/igraphic/imageio.h
client/client94/crystalspace/include/imap/ldrctxt.h
client/client94/crystalspace/include/imap/parser.h
client/client94/crystalspace/include/imap/reader.h
client/client94/crystalspace/include/imap/services.h
client/client94/crystalspace/include/imap/writer.h
client/client94/crystalspace/include/imesh/ball.h
client/client94/crystalspace/include/imesh/crossbld.h
client/client94/crystalspace/include/imesh/emit.h
client/client94/crystalspace/include/imesh/explode.h
client/client94/crystalspace/include/imesh/fire.h
client/client94/crystalspace/include/imesh/fountain.h
client/client94/crystalspace/include/imesh/genmesh.h
client/client94/crystalspace/include/imesh/haze.h
client/client94/crystalspace/include/imesh/lighting.h
client/client94/crystalspace/include/imesh/mdlconv.h
client/client94/crystalspace/include/imesh/mdldata.h
client/client94/crystalspace/include/imesh/metaball.h
client/client94/crystalspace/include/imesh/metagen.h
client/client94/crystalspace/include/imesh/object.h
client/client94/crystalspace/include/imesh/particle.h
client/client94/crystalspace/include/imesh/partsys.h
client/client94/crystalspace/include/imesh/rain.h
client/client94/crystalspace/include/imesh/skeleton.h
client/client94/crystalspace/include/imesh/snow.h
client/client94/crystalspace/include/imesh/spiral.h
client/client94/crystalspace/include/imesh/sprite2d.h
client/client94/crystalspace/include/imesh/sprite3d.h
client/client94/crystalspace/include/imesh/stars.h
client/client94/crystalspace/include/imesh/terrfunc.h
client/client94/crystalspace/include/imesh/thing/curve.h
client/client94/crystalspace/include/imesh/thing/lightmap.h
client/client94/crystalspace/include/imesh/thing/polygon.h
client/client94/crystalspace/include/imesh/thing/polytmap.h
client/client94/crystalspace/include/imesh/thing/portal.h
client/client94/crystalspace/include/imesh/thing/ptextype.h
client/client94/crystalspace/include/imesh/thing/thing.h
client/client94/crystalspace/include/inetwork/driver.h
client/client94/crystalspace/include/inetwork/socket.h
client/client94/crystalspace/include/isound/data.h
client/client94/crystalspace/include/isound/driver.h
client/client94/crystalspace/include/isound/handle.h
client/client94/crystalspace/include/isound/listener.h
client/client94/crystalspace/include/isound/loader.h
client/client94/crystalspace/include/isound/renderer.h
client/client94/crystalspace/include/isound/source.h
client/client94/crystalspace/include/isound/wrapper.h
client/client94/crystalspace/include/iutil/cache.h
client/client94/crystalspace/include/iutil/cfgfile.h
client/client94/crystalspace/include/iutil/cfgmgr.h
client/client94/crystalspace/include/iutil/cmdline.h
client/client94/crystalspace/include/iutil/comp.h
client/client94/crystalspace/include/iutil/config.h
client/client94/crystalspace/include/iutil/csinput.h
client/client94/crystalspace/include/iutil/databuff.h
client/client94/crystalspace/include/iutil/evdefs.h
client/client94/crystalspace/include/iutil/event.h
client/client94/crystalspace/include/iutil/eventh.h
client/client94/crystalspace/include/iutil/eventq.h
client/client94/crystalspace/include/iutil/object.h
client/client94/crystalspace/include/iutil/objref.h
client/client94/crystalspace/include/iutil/objreg.h
client/client94/crystalspace/include/iutil/plugin.h
client/client94/crystalspace/include/iutil/string.h
client/client94/crystalspace/include/iutil/strvec.h
client/client94/crystalspace/include/iutil/vfs.h
client/client94/crystalspace/include/iutil/virtclk.h
client/client94/crystalspace/include/ivaria/collider.h
client/client94/crystalspace/include/ivaria/conin.h
client/client94/crystalspace/include/ivaria/conout.h
client/client94/crystalspace/include/ivaria/cs.i
client/client94/crystalspace/include/ivaria/iso.h
client/client94/crystalspace/include/ivaria/isoldr.h
client/client94/crystalspace/include/ivaria/keyval.h
client/client94/crystalspace/include/ivaria/lexan.h
client/client94/crystalspace/include/ivaria/mapnode.h
client/client94/crystalspace/include/ivaria/perfstat.h
client/client94/crystalspace/include/ivaria/pmeter.h
client/client94/crystalspace/include/ivaria/polymesh.h
client/client94/crystalspace/include/ivaria/reporter.h
client/client94/crystalspace/include/ivaria/script.h
client/client94/crystalspace/include/ivaria/sequence.h
client/client94/crystalspace/include/ivaria/stdrep.h
client/client94/crystalspace/include/ivaria/view.h
client/client94/crystalspace/include/ivideo/codec.h
client/client94/crystalspace/include/ivideo/cursor.h
client/client94/crystalspace/include/ivideo/fontserv.h
client/client94/crystalspace/include/ivideo/graph2d.h
client/client94/crystalspace/include/ivideo/graph3d.h
client/client94/crystalspace/include/ivideo/halo.h
client/client94/crystalspace/include/ivideo/material.h
client/client94/crystalspace/include/ivideo/natwin.h
client/client94/crystalspace/include/ivideo/sproctxt.h
client/client94/crystalspace/include/ivideo/texture.h
client/client94/crystalspace/include/ivideo/txtmgr.h
client/client94/crystalspace/include/ivideo/vbufmgr.h
client/client94/crystalspace/include/ivideo/xextf86vm.h
client/client94/crystalspace/include/ivideo/xextshm.h
client/client94/crystalspace/include/ivideo/xwindow.h
client/client94/crystalspace/include/platform.h
client/client94/crystalspace/include/qint.h
client/client94/crystalspace/include/qsqrt.h
diff --git a/client/client94/crystalspace/include/csdef.h b/client/client94/crystalspace/include/csdef.h
new file mode 100644
index 0000000..fab5b72
--- /dev/null
+++ b/client/client94/crystalspace/include/csdef.h
@@ -0,0 +1,110 @@
+/*
+    Copyright (C) 1998-2000 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#if !defined(CSDEF_FRIEND)
+#error You are not allowed to include this file! Use cssysdef.h instead.
+#endif
+
+#ifndef __CS_CSDEF_H__
+#define __CS_CSDEF_H__
+
+#include "platform.h"
+#include "cstypes.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <time.h>
+#include <signal.h>
+#include <errno.h>
+#include <string.h>
+#include <assert.h>
+
+#ifndef TRUE
+  #define TRUE 1
+#endif
+
+#ifndef FALSE
+  #define FALSE 0
+#endif
+
+#ifndef MIN
+  #define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
+#ifndef MAX
+  #define MAX(a,b) ((a)>(b)?(a):(b))
+#endif
+
+#ifndef ABS
+ #define ABS(x) ((x)<0?-(x):(x))
+#endif
+
+#if !defined(SIGN)
+  #define SIGN(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
+#endif
+
+#ifndef PI
+ #define PI 3.1415926535897932385f
+#endif
+#ifndef HALF_PI
+  #define HALF_PI (PI / 2.0f)
+#endif
+#ifndef TWO_PI
+  #define TWO_PI (PI * 2.0f)
+#endif
+
+#undef EPSILON
+  #define EPSILON 0.001f			/* Small value */
+#undef SMALL_EPSILON
+  #define SMALL_EPSILON 0.000001f		/* Very small value */
+#undef SMALL_EPSILON_D
+  #define SMALL_EPSILON_D 0.000000000001f	/* Very, very small value */
+
+// A macro for defining a constant static table.  The default expansion is
+// merely `static const'.  Typical usage is `CS_STATIC_TABLE Foo[] = {...};',
+// which expands to `static const Foo[] = {...};'.  Some variants of GCC have
+// been known to throw an internal compiler error exception when confronted
+// with such an expression.  In this case, the platform-specific header file
+// may override the definition of CS_STATIC_TABLE with one which works around
+// the compiler bug.
+#define CS_STATIC_TABLE static const
+
+// Platforms with compilers which only understand old-style C++ casting syntax
+// should define CS_USE_OLD_STYLE_CASTS.
+#if defined(CS_USE_OLD_STYLE_CASTS)
+  #define CS_CAST(C,T,V) ((T)(V))
+#else
+  #define CS_CAST(C,T,V) (C<T>(V))
+#endif
+
+#define STATIC_CAST(T,V)      CS_CAST(static_cast,T,V)
+#define DYNAMIC_CAST(T,V)     CS_CAST(dynamic_cast,T,V)
+#define REINTERPRET_CAST(T,V) CS_CAST(reinterpret_cast,T,V)
+#define CONST_CAST(T,V)       CS_CAST(const_cast,T,V)
+
+// Platforms with compilers which do not understand the new C++ keyword
+// `explicit' should define CS_USE_FAKE_EXPLICIT_KEYWORD.
+#if defined(CS_USE_FAKE_EXPLICIT_KEYWORD)
+  #define explicit /* nothing */
+#endif
+
+// The smallest Z at which 3D clipping occurs
+#define SMALL_Z 0.01f
+
+#endif // __CS_CSDEF_H__
diff --git a/client/client94/crystalspace/include/csengine/arrays.h b/client/client94/crystalspace/include/csengine/arrays.h
new file mode 100644
index 0000000..e5e83ef
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/arrays.h
@@ -0,0 +1,79 @@
+/*
+    Dynamic arrays of engine objects
+    Copyright (C) 1999 by Andrew Zabolotny
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_ARRAYS_H__
+#define __CS_ARRAYS_H__
+
+#include "csutil/typedvec.h"
+
+class csCurve;
+class csLightHalo;
+class csPolygonInt;
+class csPolygon3D;
+
+/// A dynamic array of csCurve objects
+CS_DECLARE_TYPED_VECTOR_NODELETE (csCurvesArrayHelper, csCurve);
+
+class csCurvesArray : public csCurvesArrayHelper {
+public:
+  virtual bool FreeItem (csSome item);
+  virtual int CompareKey (csSome Item, csConstSome Key, int Mode) const;
+  csCurvesArray (int l=8, int t=8) : csCurvesArrayHelper (l, t) {}
+};
+
+/// A dynamic array of csLightHalo objects
+CS_DECLARE_TYPED_VECTOR_NODELETE (csHaloArrayHelper, csLightHalo);
+
+class csHaloArray : public csHaloArrayHelper {
+public:
+  virtual bool FreeItem (csSome item);
+  virtual int CompareKey (csSome Item, csConstSome Key, int Mode) const;
+  csHaloArray (int l=8, int t=8) : csHaloArrayHelper (l, t) {}
+};
+
+/**
+ * An dynamic array of csPolygon3D objects.
+ * This class is used in polygon set class and thing template class
+ * for storing the polygons that the model consists of.
+ */
+class csPolygonArray : public csVector
+{
+public:
+  /// Create the polygon array object
+  csPolygonArray (int iLimit, int iDelta) : csVector (iLimit, iDelta)
+  { }
+
+  /// Destroy the polygon array and all inserted polygons
+  virtual ~csPolygonArray ();
+
+  /// Delete a particular array element
+  virtual bool FreeItem (csSome Item);
+
+  /// Find a polygon by name
+  virtual int CompareKey (csSome Item, csConstSome Key, int Mode) const;
+
+  /// Get a polygon given its index in the array
+  csPolygon3D *Get (int iIndex) const;
+
+  /// Get the entire array of polygons as an array of pointers
+  csPolygonInt **GetArray ()
+  { return (csPolygonInt **)root; }
+};
+
+#endif // __CS_ARRAYS_H__
diff --git a/client/client94/crystalspace/include/csengine/bezier.h b/client/client94/crystalspace/include/csengine/bezier.h
new file mode 100644
index 0000000..145b20b
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/bezier.h
@@ -0,0 +1,138 @@
+/*
+    Copyright (C) 1998 by Ayal Zwi Pinkus
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_BEZIER_H__
+#define __CS_BEZIER_H__
+
+//////////////////////////////////////////////
+//////////////////////////////////////////////
+// Cache interface
+//////////////////////////////////////////////
+//////////////////////////////////////////////
+#define NR1 4
+#define NR2 9
+#define NR3 16
+#define NR4 25
+#define NR5 36
+#define NR6 49
+#define NR7 64
+#define NR8 81
+#define NR9 100
+
+#define IND1  0
+#define IND2  (IND1+NR1)
+#define IND3  (IND2+NR2)
+#define IND4  (IND3+NR3)
+#define IND5  (IND4+NR4)
+#define IND6  (IND5+NR5)
+#define IND7  (IND6+NR6)
+#define IND8  (IND7+NR7)
+#define IND9  (IND8+NR8)
+#define IND10 (IND9+NR9)
+
+#define OFFSET_1  (IND1  * 9)
+#define OFFSET_2  (IND2  * 9)
+#define OFFSET_3  (IND3  * 9)
+#define OFFSET_4  (IND4  * 9)
+#define OFFSET_5  (IND5  * 9)
+#define OFFSET_6  (IND6  * 9)
+#define OFFSET_7  (IND7  * 9)
+#define OFFSET_8  (IND8  * 9)
+#define OFFSET_9  (IND9  * 9)
+#define OFFSET_10 (IND10 * 9)
+
+#define LUT_SIZE  OFFSET_10 // Doubles
+
+class csVector3;
+class csVector2;
+
+class csBezier2
+{
+private:
+
+  // binary coefficients for a 2nd degree polynomial
+  static double bincoeff[3];
+
+  // This should be approx. less than 82K
+  static double bernsteinMap[LUT_SIZE];
+  static double bernsteinDuMap[LUT_SIZE];
+  static double bernsteinDvMap[LUT_SIZE];
+  static bool initialized;
+
+public:
+
+  /// Initialize.
+  static void Initialize ();
+
+  /// Evaulate the bernstien polynomial defined by the given j & k at u & v
+  static double BernsteinAt(double u, int j, double v, int k);
+
+  /**
+   * Evaluate the derivite of the Berstein polynomial defined by j & k with
+   * respect to u at coordinates u, v
+   */
+  static double BernsteinDuAt(double u, int j, double v, int k);
+
+  /**
+   * Evaluate the derivite of the Berstein polynomial defined by j & k with
+   * respect to v at coordinates u, v
+   */
+  static double BernsteinDvAt(double u, int j, double v, int k);
+
+  /**
+   * Find the normal at u, v where u, v are integers representing an index
+   * to a control point on the curve in the u and v directions respectively at
+   * the given resolution
+   *
+   * Formula:                      /2\/2\
+   * vtx = sum(j=0->2) sum(k=0->2) \j/\k/ u^j(1-u)^(2-j) v^k(1-v)^(2-k)*P_jk
+   */
+  static csVector3 GetNormal(double** aControls, int u,
+                             int v, int resolution);
+
+  /**
+   * Find the normal at u,v where u and v a the parametric coordinates on the
+   * curve
+   */
+  static csVector3 GetNormal(double** aControls, double u, double v);
+
+  /**
+   * Find the point at u, v where u, v are integers representing an index
+   * to a control point on the curve in the u and v directions respectively at
+   * the given resolution
+   */
+  static csVector3 GetPoint(double** aControls, int u, int v, int resolution,
+                            double *map = NULL);
+
+  /**
+   * Find the texture coordinates at u, v where u, v are integers
+   * representing an index to a control point on the curve in the u and v
+   * directions respectively at the given resolution
+   */
+  static csVector2 GetTextureCoord(double** aControls, int u, int v,
+                                   int resolution, double *map = NULL);
+
+                            /**
+   * Find the point at u,v where u and v a the parametric coordinates on the
+   * curve
+   */
+  static csVector3 GetPoint(double** aControls, double u, double v,
+                            double (*func)(double, int, double, int) = NULL );
+};
+
+#endif // __CS_BEZIER_H__
diff --git a/client/client94/crystalspace/include/csengine/bsp.h b/client/client94/crystalspace/include/csengine/bsp.h
new file mode 100644
index 0000000..5abd662
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/bsp.h
@@ -0,0 +1,241 @@
+/*
+    Copyright (C) 1998 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_BSP_H__
+#define __CS_BSP_H__
+
+#include "csgeom/math3d.h"
+#include "csengine/polytree.h"
+#include "csengine/polyint.h"
+#include "csengine/arrays.h"
+
+class csBspTree;
+class csPolygonArrayNoFree;
+struct iFile;
+
+// The BSP tree can be build using the following criteria:
+#define BSP_MINIMIZE_SPLITS 1		// Minimize the number of polygon splits
+#define BSP_MOST_ON_SPLITTER 2		// Splitter with most coplanar polygons
+#define BSP_RANDOM 3			// Choose a random splitter
+#define BSP_ALMOST_MINIMIZE_SPLITS 4	// Select a number of polygons and choose minimal split
+#define BSP_BALANCED 5			// Try to create a balanced tree
+#define BSP_ALMOST_BALANCED 6		// Try to create an approximation of a balanced tree
+#define BSP_BALANCE_AND_SPLITS 7	// Combine balanced tree and few splits.
+#define BSP_ALMOST_BALANCE_AND_SPLITS 8	// Combine balanced tree and few splits.
+
+/**
+ * A BSP node.
+ */
+class csBspNode : public csPolygonTreeNode
+{
+  friend class csBspTree;
+private:
+  /**
+   * All the polygons in this node.
+   * These polygons are all on the same plane.
+   * The 'front' and 'back' children in this node are seperated
+   * by that plane.
+   */
+  csPolygonIntArray polygons;
+
+  /**
+   * This flag is true if all polygons above are on the 'splitter' plane.
+   * In this case the BSP tree can backface cull them in one go.
+   */
+  bool polygons_on_splitter;
+
+  /// The splitter plane.
+  csPlane3 splitter;
+
+  /// The front node.
+  csBspNode* front;
+  /// The back node.
+  csBspNode* back;
+
+private:
+  /// Make an empty BSP node.
+  csBspNode ();
+
+  /**
+   * Destroy this BSP node. The list of polygons
+   * will be deleted but not the polygons themselves.
+   */
+  virtual ~csBspNode ();
+
+  /**
+   * Add a polygon to this BSP node.
+   */
+  void AddPolygon (csPolygonInt* poly);
+
+  /**
+   * Count all vertices used by polygons in this bsp node
+   * and children. Vertices used multiple times will be counted
+   * multiple times as well. So really it counts all the corners
+   * of all polygons used in the bsp node.
+   */
+  int CountVertices ();
+
+  /**
+   * Fetch all vertex indices used by polygons in this bsp node
+   * and children. The given array must be at least CountVertices()
+   * big.
+   */
+  void FetchVertices (int* array, int& cur_idx);
+
+public:
+  /// Return true if node is empty.
+  bool IsEmpty ()
+  {
+    return polygons.GetPolygonCount () == 0 &&
+    	(!front || front->IsEmpty ()) &&
+	(!back || back->IsEmpty ());
+  }
+
+  /// Return type (NODE_???).
+  int Type () { return NODE_BSPTREE; }
+
+  /**
+   * Count all the polygons in this node and children.
+   * This function only calls leaf polygons (i.e. polygons that will
+   * actually be returned by Front2Back/Back2Front).
+   */
+  int CountPolygons ();
+};
+
+/**
+ * The BSP tree.
+ */
+class csBspTree : public csPolygonTree
+{
+private:
+  /// The mode.
+  int mode;
+
+private:
+  /**
+   * Build the tree from the given node and number of polygons.
+   */
+  void Build (csBspNode* node, csPolygonInt** polygons, int num);
+
+  /**
+   * Select a splitter from a list of polygons and return the index.
+   */
+  int SelectSplitter (csPolygonInt** polygons, int num);
+
+  /// Traverse the tree from back to front starting at 'node' and 'pos'.
+  void* Back2Front (csBspNode* node, const csVector3& pos,
+  	csTreeVisitFunc* func, void* data, csTreeCullFunc* cullfunc,
+	void* culldata);
+  /// Traverse the tree from front to back starting at 'node' and 'pos'.
+  void* Front2Back (csBspNode* node, const csVector3& pos,
+  	csTreeVisitFunc* func, void* data, csTreeCullFunc* cullfunc,
+	void* culldata);
+
+  /// Return statistics about this bsp tree.
+  void Statistics (csBspNode* node, int depth, int* num_nodes,
+  	int* num_leaves, int* max_depth,
+  	int* tot_polygons, int* max_poly_in_node, int* min_poly_in_node);
+
+  /// Handle all dynamic objects in this tree.
+  void* HandleObjects (csBspNode* node, const csVector3& pos,
+  	csTreeVisitFunc* func, void* data);
+
+  /**
+   * Process all todo stubs in a node and add new
+   * todo stubs to the children of this node.
+   */
+  void ProcessTodo (csBspNode* node);
+
+  /// Cache this node and children.
+  void Cache (iFile* cf, csBspNode* node,
+  	csPolygonInt** polygons, int num);
+
+  /// Read this tree from cache.
+  bool ReadFromCache (iFile* cf, csBspNode* node,
+  	csPolygonInt** polygons, int num);
+
+public:
+  /**
+   * Create an empty tree for a parent container.
+   */
+  csBspTree (csThing* thing, int mode = BSP_MINIMIZE_SPLITS);
+
+  /**
+   * Destroy the whole BSP tree (but not the actual polygons and parent
+   * objects).
+   */
+  virtual ~csBspTree ();
+
+  /**
+   * Create the tree with a given set of polygons.
+   */
+  void Build (csPolygonInt** polygons, int num);
+
+  /**
+   * Create the tree with a given set of polygons.
+   */
+  void Build (csPolygonArray& polygons)
+  {
+    Build (polygons.GetArray (), polygons.Length ());
+  }
+
+  /// Traverse the tree from back to front starting at the root and 'pos'.
+  void* Back2Front (const csVector3& pos, csTreeVisitFunc* func, void* data,
+  	csTreeCullFunc* cullfunc = NULL, void* culldata = NULL);
+  /// Traverse the tree from front to back starting at the root and 'pos'.
+  void* Front2Back (const csVector3& pos, csTreeVisitFunc* func, void* data,
+  	csTreeCullFunc* cullfunc = NULL, void* culldata = NULL);
+
+  /// Print statistics about this bsp tree.
+  void Statistics ();
+
+  /// Return statistics about this particular tree.
+  void Statistics (int* num_nodes, int* num_leaves, int* max_depth,
+  	int* tot_polygons, int* max_poly_in_node, int* min_poly_in_node);
+
+  /**
+   * Get a list of all vertices used by all the polygons in this
+   * bsp tree. This list should be deleted with 'delete[]' after use.
+   * The vertices are returned as indices into the parent object (pset).
+   */
+  int* GetVertices (int& count);
+
+  /**
+   * Return true if bsp tree is empty.
+   */
+  bool IsEmpty () { return root ? root->IsEmpty () : false; }
+
+  /// Cache this tree.
+  void Cache (iFile* cf, csPolygonInt** polygons, int num);
+
+  /// Read this tree from cache.
+  bool ReadFromCache (iFile* cf, csPolygonInt** polygons, int num);
+
+  /**
+   * Count all the polygons in this tree.
+   * This function only calls leaf polygons (i.e. polygons that will
+   * actually be returned by Front2Back/Back2Front).
+   */
+  int CountPolygons ()
+  {
+    if (!root) return 0;
+    return ((csBspNode*)root)->CountPolygons ();
+  }
+};
+
+#endif // __CS_BSP_H__
diff --git a/client/client94/crystalspace/include/csengine/bsp2d.h b/client/client94/crystalspace/include/csengine/bsp2d.h
new file mode 100644
index 0000000..39f9bdf
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/bsp2d.h
@@ -0,0 +1,148 @@
+/*
+    Copyright (C) 2000 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_BSP2D_H__
+#define __CS_BSP2D_H__
+
+#include "csgeom/math2d.h"
+#include "csgeom/segment.h"
+#include "csengine/arrays.h"
+#include "csengine/bsp.h"
+#include "csutil/csvector.h"
+
+class csBspTree2D;
+
+/**
+ * An dynamic array of csSegment2 objects.
+ */
+class csSegmentArray : public csVector
+{
+public:
+  /// Create the segment array object
+  csSegmentArray (int iLimit, int iDelta) : csVector (iLimit, iDelta)
+  { }
+
+  /// Destroy the segment array and all inserted segments.
+  virtual ~csSegmentArray ();
+
+  /// Delete a particular array element.
+  virtual bool FreeItem (csSome Item)
+  {
+    delete (csSegment2*)Item;
+    return true;
+  }
+
+  /// Get a segment given its index in the array.
+  csSegment2* Get (int iIndex) const
+  {
+    return (csSegment2*)csVector::Get (iIndex);
+  }
+
+  /// Get the entire array of segments as an array of pointers.
+  csSegment2** GetArray () { return (csSegment2**)root; }
+};
+
+
+/**
+ * A 2D BSP node.
+ */
+class csBspNode2D
+{
+  friend class csBspTree2D;
+private:
+  /**
+   * All the lines in this node.
+   * These lines are all on the same line.
+   * The 'front' and 'back' children in this node are seperated
+   * by that line.
+   */
+  csSegmentArray segments;
+
+  /// The splitter plane.
+  csPlane2 splitter;
+
+  /// The front node.
+  csBspNode2D* front;
+  /// The back node.
+  csBspNode2D* back;
+
+private:
+  /// Make an empty BSP node.
+  csBspNode2D ();
+
+  /// Destroy this BSP node.
+  virtual ~csBspNode2D ();
+
+  /**
+   * Add a segment to this BSP node.
+   */
+  void AddSegment (csSegment2* seg);
+};
+
+typedef void* (csTree2DVisitFunc)(csSegment2**, int num, void*);
+
+/**
+ * The BSP tree.
+ * This bsp tree is ment mostly for adding segments dynamically.
+ * As such it does not provide a global build routine. That can
+ * of course easily be added if needed.
+ */
+class csBspTree2D
+{
+private:
+  /// The root.
+  csBspNode2D* root;
+
+  /**
+   * Add one segment to the tree.
+   */
+  void Add (csBspNode2D* node, csSegment2* segment);
+
+  /// Traverse the tree from back to front starting at 'node' and 'pos'.
+  void* Back2Front (csBspNode2D* node, const csVector2& pos,
+  	csTree2DVisitFunc* func, void* data);
+  /// Traverse the tree from front to back starting at 'node' and 'pos'.
+  void* Front2Back (csBspNode2D* node, const csVector2& pos,
+  	csTree2DVisitFunc* func, void* data);
+
+public:
+  /**
+   * Create an empty tree.
+   */
+  csBspTree2D ();
+
+  /**
+   * Destroy the whole BSP tree.
+   */
+  virtual ~csBspTree2D ();
+
+  /**
+   * Add one segment to the tree. The segment will be freed
+   * by this tree at some point. So don't depend on the given pointer
+   * anymore.
+   */
+  void Add (csSegment2* segment);
+
+  /// Traverse the tree from back to front starting at the root and 'pos'.
+  void* Back2Front (const csVector2& pos, csTree2DVisitFunc* func, void* data);
+  /// Traverse the tree from front to back starting at the root and 'pos'.
+  void* Front2Back (const csVector2& pos, csTree2DVisitFunc* func, void* data);
+};
+
+#endif // __CS_BSP2D_H__
+
diff --git a/client/client94/crystalspace/include/csengine/bspbbox.h b/client/client94/crystalspace/include/csengine/bspbbox.h
new file mode 100644
index 0000000..b75ed38
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/bspbbox.h
@@ -0,0 +1,367 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_BSPBBOX_H__
+#define __CS_BSPBBOX_H__
+
+#include "csgeom/math3d.h"
+#include "csgeom/polyidx.h"
+#include "csgeom/poly3d.h"
+#include "csgeom/transfrm.h"
+#include "csengine/polyint.h"
+#include "csengine/pol2d.h"
+#include "csengine/treeobj.h"
+#include "csutil/csobject.h"
+
+class csPolyTreeBBox;
+class csPolygonTree;
+class csTransform;
+class csBox3;
+struct iVisibilityObject;
+struct iShadowCaster;
+
+/**
+ * A factor for creating instances of csBspPolygon.
+ */
+class csBspPolygonFactory : public csPolygonIntFactory
+{
+  /// Create a csBspPolygon.
+  virtual csPolygonInt* Create ();
+  /// Initialize a csBspPolygon.
+  virtual void Init (csPolygonInt* pi);
+};
+
+/**
+ * Structure that is used by the visisibility
+ * culler to attach extra information to every bsp polygon.
+ */
+struct csVisObjInfo
+{
+  iVisibilityObject* visobj;
+  iShadowCaster* shadcast;
+  csPolyTreeBBox* bbox;
+  long last_movablenr;
+  long last_shapenr;
+};
+
+/**
+ * This class represents a polygon which can be inserted dynamically
+ * in a BSP tree. It is specifically designed to be able to add bounding
+ * boxes to sprites and dynamic things and then add those bounding boxes
+ * to the BSP tree.
+ */
+class csBspPolygon : public csPolygonInt
+{
+  friend class csBspPolygonFactory;
+
+private:
+  /// The 3D polygon.
+  csPolyIndexed polygon;
+  /// The plane.
+  csPlane3 plane;
+  /// The parent.
+  csPolyTreeBBox* parent;
+  /// Originator in the visibility culler.
+  csVisObjInfo* originator;
+
+public:
+  /// A pool of csBspPolygon.
+  CS_DECLARE_STATIC_CLASSVAR(poly_fact,GetPolygonFact,csBspPolygonFactory)
+  CS_DECLARE_STATIC_CLASSVAR_REF(poly_pool,GetPolygonPool,csPolygonIntPool)
+
+  /// Debug.
+  void Dump();
+
+private:
+  /// Constructor is private to prevent allocation by non-factory.
+  csBspPolygon () { }
+
+public:
+  /// Destructor.
+  virtual ~csBspPolygon () { }
+
+  /// Get the parent container.
+  csPolyTreeBBox* GetParent () { return parent; }
+
+  /// Set the parent container.
+  void SetParent (csPolyTreeBBox* par) { parent = par; }
+
+  /**
+   * Get originator.
+   */
+  csVisObjInfo* GetOriginator () { return originator; }
+
+  /// Set originator.
+  void SetOriginator (csVisObjInfo* org) { originator = org; }
+
+  /// Get the reference to the polygon.
+  csPolyIndexed& GetPolygon () { return polygon; }
+
+  /// Get number of vertices.
+  virtual int GetVertexCount () { return polygon.GetVertexCount (); }
+
+  /// Get vertex index table (required for csPolygonInt).
+  virtual int* GetVertexIndices () { return polygon.GetVertexIndices (); }
+
+  /// Get original polygon (not known for this polygon type).
+  virtual csPolygonInt* GetUnsplitPolygon () { return NULL; }
+
+  /// Set the plane for this polygon.
+  void SetPolyPlane (const csPlane3& pl) { plane = pl; }
+
+  /// Return the plane of this polygon.
+  csPlane3* GetPolyPlane () { return &plane; }
+
+  /// Classify a polygon with regards to this one.
+  int Classify (const csPlane3& pl);
+
+  /// Same as Classify() but for X plane only.
+  int ClassifyX (float x);
+
+  /// Same as Classify() but for Y plane only.
+  int ClassifyY (float y);
+
+  /// Same as Classify() but for Z plane only.
+  int ClassifyZ (float z);
+
+  /// Split this polygon with the given plane (A,B,C,D).
+  void SplitWithPlane (csPolygonInt** front, csPolygonInt** back,
+  	const csPlane3& split_plane);
+
+  /// Split this polygon to the x-plane.
+  void SplitWithPlaneX (csPolygonInt** front, csPolygonInt** back, float x);
+
+  /// Split this polygon to the y-plane.
+  void SplitWithPlaneY (csPolygonInt** front, csPolygonInt** back, float y);
+
+  /// Split this polygon to the z-plane.
+  void SplitWithPlaneZ (csPolygonInt** front, csPolygonInt** back, float z);
+
+  /// Return 3 to indicate it is a bsp polygon.
+  int GetType () { return 3; }
+
+  /// Transform the plane of this polygon.
+  void Transform (const csTransform& trans);
+
+  /**
+   * Clip this polygon to the Z plane and if portal_plane is given also
+   * clip the polygon to that plane.
+   * @@@ NOTE @@@ This function is almost identical to the one in
+   * csPolygon3D. It should be possible to reuse that code.
+   */
+  bool ClipToPlane (csPlane3* portal_plane, const csVector3& v_w2c,
+	csVector3*& pverts, int& num_verts, bool cw = true);
+
+  /**
+   * Perspective correct a polygon. Note that this function is nearly
+   * identical to a version in csPolygon3D. It should be possible to
+   * reuse that code.
+   */
+  bool DoPerspective (const csTransform& trans,
+	csVector3* source, int num_verts, csPolygon2D* dest, bool mirror);
+
+  /**
+   * Not implemented yet! @@@
+   */
+  bool Overlaps (csPolygonInt* /*overlapped*/) { return false; }
+
+  /**
+   * Intersect object-space segment with this polygon. Return
+   * true if it intersects and the intersection point in world coordinates.
+   */
+  bool IntersectSegment (const csVector3& start, const csVector3& end,
+                          csVector3& isect, float* pr = NULL);
+};
+
+/**
+ * This class represents a (dynamic) object that can be placed
+ * in a polygon tree (BSP, octree, ...). Every engine entity that
+ * is interested in adding itself to the tree will be represented
+ * by such an object.
+ */
+class csPolyTreeBBox
+{
+private:
+  /**
+   * A linked list for all object stubs that are added
+   * to the tree. These stubs represents parts of
+   * this object that belong to the tree. In case of csPolygonStub
+   * every stub will represent a list of polygons that are coplanar
+   * with the splitter plane at that node.
+   */
+  csPolygonStub* first_stub;
+
+  /// Array of vertices.
+  csVector3Array vertices;
+  /// Array of camera space vertices.
+  csVector3Array cam_vertices;
+
+  /// All polygons.
+  csPolygonStub* base_stub;
+
+  /**
+   * This number indicates the number of the camera we used to transform
+   * the camera vertices with. It is used to check if the current camera
+   * vertices are still valid.
+   */
+  int camera_nr;
+
+  /// Bounding box for this object.
+  csBox3 world_bbox;
+
+public:
+  /// Constructor.
+  csPolyTreeBBox ();
+  /// Destructor.
+  ~csPolyTreeBBox ();
+
+  CS_DECLARE_STATIC_CLASSVAR(stub_pool,GetPolyStubPool,csPolygonStubPool)
+  CS_DECLARE_STATIC_CLASSVAR(stub_fact,GetPolyStubFactory,csPolygonStubFactory)
+
+  /**
+   * Remove this object from its tree.
+   */
+  void RemoveFromTree ();
+
+  /**
+   * Unlink a stub from the stub list.
+   * Warning! This function does not test if the stub
+   * is really on the list!
+   */
+  void UnlinkStub (csPolygonStub* ps);
+
+  /**
+   * Link a stub to the stub list.
+   */
+  void LinkStub (csPolygonStub* ps);
+
+  /**
+   * Get the bounding box that represents this object.
+   * If the camera is inside this bbox then the object
+   * is certainly visible.
+   */
+  const csBox3& GetWorldBoundingBox ()
+  {
+    return world_bbox;
+  }
+
+  /**
+   * Get the base stub. In case of csPolygonStub this corresponds to the
+   * set of polygons that make up the desired object to be placed
+   * in the polygon tree. In most cases this will be a bounding
+   * box for the real object.
+   */
+  csPolygonStub* GetBaseStub () { return base_stub; }
+
+  /// Get vector array for this container.
+  csVector3Array& GetVertices () { return vertices; }
+
+  /// Get camera vector array for this container.
+  csVector3Array& GetCameraVertices () { return cam_vertices; }
+
+  /**
+   * Update this object using an object space bounding box
+   * and a transformation.
+   */
+  void Update (const csBox3& object_bbox, const csTransform& o2w,
+  	csVisObjInfo* vinf);
+
+  /**
+   * Update this object using a world space bounding box.
+   */
+  void Update (const csBox3& world_bbox,
+  	csVisObjInfo* vinf);
+
+  /// Add a polygon to this container.
+  void AddPolygon (csPolygonInt* poly)
+  {
+    base_stub->GetPolygonArray ().AddPolygon (poly);
+    ((csBspPolygon*)poly)->SetParent (this);
+  }
+
+  /// Get the number of polygons in this polygonset.
+  int GetPolygonCount () { return base_stub->GetPolygonCount (); }
+
+  /// Get the specified polygon from this set.
+  csPolygonInt* GetPolygon (int idx)
+  {
+    return base_stub->GetPolygonArray ().GetPolygon (idx);
+  }
+
+  /// Get the array of polygons.
+  csPolygonInt** GetPolygons () { return base_stub->GetPolygons (); }
+
+  /// Transform the vertices of this container from world to camera.
+  void World2Camera (const csTransform& trans, int cur_camera_nr);
+
+  /// Return true if this object is already transformed to camera space.
+  bool IsTransformed (int cur_camera_nr)
+  {
+    if (cur_camera_nr != camera_nr) return false;
+    return (cam_vertices.GetVertexCount () == vertices.GetVertexCount ());
+  }
+
+  /// Clear camera transformation.
+  void ClearTransform () { camera_nr = -1; }
+
+  /**
+   * Split the given stub with a plane and return
+   * three new stubs (all on the plane, in front, or
+   * back of the plane).<p>
+   *
+   * Note that this function is responsible for freeing 'stub' itself
+   * if needed. Also this function can return NULL for stub_on, stub_front,
+   * and stub_back in which case there simply is no stub for that
+   * particular case.<p>
+   *
+   * Other note. This function will also correctly account for
+   * the case where the given stub_on pointer is NULL. In that case
+   * the tree is not interested in the polygons on the plane and those
+   * polygons will be distributed to stub_front.
+   */
+  void SplitWithPlane (csPolygonStub* stub,
+  	csPolygonStub** stub_on, csPolygonStub** stub_front,
+	csPolygonStub** stub_back,
+	const csPlane3& plane);
+
+  /**
+   * Split the given stub with an X plane.
+   */
+  void SplitWithPlaneX (csPolygonStub* stub,
+  	csPolygonStub** stub_on, csPolygonStub** stub_front,
+	csPolygonStub** stub_back,
+	float x);
+
+  /**
+   * Split the given stub with an Y plane.
+   */
+  void SplitWithPlaneY (csPolygonStub* stub,
+  	csPolygonStub** stub_on, csPolygonStub** stub_front,
+	csPolygonStub** stub_back,
+	float y);
+
+  /**
+   * Split the given stub with an Z plane.
+   */
+  void SplitWithPlaneZ (csPolygonStub* stub,
+  	csPolygonStub** stub_on, csPolygonStub** stub_front,
+	csPolygonStub** stub_back,
+	float z);
+};
+
+#endif // __CS_BSPBBOX_H__
diff --git a/client/client94/crystalspace/include/csengine/camera.h b/client/client94/crystalspace/include/csengine/camera.h
new file mode 100644
index 0000000..134a29a
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/camera.h
@@ -0,0 +1,442 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_CAMERA_H__
+#define __CS_CAMERA_H__
+
+#include "csutil/scf.h"
+#include "csgeom/transfrm.h"
+#include "iengine/camera.h"
+#include "csengine/sector.h"
+#include "csengine/polygon.h"
+
+class csSector;
+class csPolygon3D;
+class Vertex;
+class csEngine;
+
+/**
+ * A camera positioned in the 3D world.
+ */
+class csCamera : public csOrthoTransform, public iBase
+{
+private:
+  /// The sector the camera is in.
+  csSector* sector;
+  /// If true we are in a mirrored world.
+  bool mirror;
+
+  /**
+   * If true then we only check collision with portals and not
+   * with other polygons.
+   */
+  bool only_portals;
+
+  /// a farplane to cut everything thats behind it
+  csPlane3 *fp;
+
+  ///
+  int aspect;
+  static int default_aspect;
+  ///
+  float inv_aspect;
+  static float default_inv_aspect;
+  ///
+  float shift_x;
+  float shift_y;
+
+  /// FOV in angles (degrees).
+  float fov_angle;
+  static float default_fov_angle;
+
+  /// Compute above angle.
+  void ComputeAngle (int width);
+  static void ComputeDefaultAngle (int width);
+
+  /**
+   * Camera number. This number is changed for every new camera
+   * instance and it is also updated whenever the camera transformation
+   * changes. This number can be used to cache camera vertex arrays, for
+   * example.
+   */
+  long cameranr;
+  /**
+   * The last used camera number.
+   */
+  static long cur_cameranr;
+
+public:
+  ///
+  csCamera ();
+  /// Copy constructor.
+  csCamera (csCamera* c);
+  /// Copy constructor.
+  csCamera (const csCamera& c);
+  ///
+  virtual ~csCamera ();
+
+  /**
+   * Get the camera number. This number is changed for every new camera
+   * instance and it is also updated whenever the camera transformation
+   * changes. This number can be used to cache camera vertex arrays, for
+   * example.
+   */
+  long GetCameraNumber () const
+  {
+    return cameranr;
+  }
+
+  /**
+   * Check if there is a polygon in front of us in the direction
+   * defined by 'v' (world space coordinates). Return the nearest polygon.
+   */
+  csPolygon3D* GetHit (csVector3& v);
+
+  /// Set the default FOV for new cameras.
+  static void SetDefaultFOV (int fov, int width)
+  {
+    default_aspect = fov;
+    default_inv_aspect = 1.0f / default_aspect;
+    ComputeDefaultAngle (width);
+  }
+
+  /// Get the default FOV for new cameras.
+  static int GetDefaultFOV () { return default_aspect; }
+  /// Get the default inverse FOV for new cameras.
+  static float GetDefaultInvFOV () { return default_inv_aspect; }
+  /// Get the default FOV in angles (degrees).
+  static float GetDefaultFOVAngle () { return default_fov_angle; }
+
+  /// Set the FOV for this camera.
+  void SetFOV (int a, int width)
+  {
+    aspect = a;
+    inv_aspect = 1.0f / a;
+    ComputeAngle (width);
+  }
+  /// Get the FOV for this camera
+  int GetFOV () const { return aspect; }
+  /// Get the inverse FOV for this camera.
+  float GetInvFOV () const { return inv_aspect; }
+
+  /// Set the FOV in angles (degrees).
+  void SetFOVAngle (float a, int width);
+  /// Get the FOV in angles (degrees).
+  float GetFOVAngle () const
+  {
+    return fov_angle;
+  }
+
+  /// Get the X shift value.
+  float GetShiftX () const { return shift_x; }
+  /// Get the Y shift value.
+  float GetShiftY () const { return shift_y; }
+
+  /// Set farplane, everything behind this will be cut
+  void SetFarPlane (const csPlane3* farplane);
+  /// Get the Farplane
+  csPlane3* GetFarPlane () const { return fp; }
+
+  /**
+   * Set the sector that the camera resides in.
+   * Note that this function does not check if the current
+   * camera location is really in that sector. In fact
+   * it is legal to have a camera which is viewing the
+   * current sector from outside.
+   */
+  void SetSector (csSector *s)
+  {
+    sector = s;
+    cameranr = cur_cameranr++;
+  }
+
+  /**
+   * Get the current sector of the camera.
+   */
+  csSector* GetSector () const { return sector; }
+
+  /**
+   * Returns true if we are in a mirrored world.
+   * Basicly this means that back-face culling will
+   * be reversed.
+   */
+  bool IsMirrored () const { return mirror; }
+
+  /**
+   * Set the mirrored state of this camera.
+   * The effect of this is mainly that back-face culling will
+   * be reversed. This is useful if you are stepping into a
+   * mirrored sector.
+   */
+  void SetMirrored (bool m)
+  {
+    if (mirror != m) cameranr = cur_cameranr++;
+    mirror = m;
+  }
+
+  /**
+   * Set 'other' to 'this' transformation matrix.
+   * csCamera overrides this in order to be able to update the
+   * camera number.
+   */
+  virtual void SetO2T (const csMatrix3& m)
+  {
+    csOrthoTransform::SetO2T (m);
+    cameranr = cur_cameranr++;
+  }
+
+  /**
+   * Set 'this' to 'other' transformation matrix.
+   * csCamera overrides this in order to be able to update the
+   * camera number.
+   */
+  virtual void SetT2O (const csMatrix3& m)
+  {
+    csOrthoTransform::SetT2O (m);
+    cameranr = cur_cameranr++;
+  }
+
+  /**
+   * Set 'world' to 'this' translation.
+   * csCamera overrides this in order to be able to update the
+   * camera number.
+   */
+  virtual void SetO2TTranslation (const csVector3& v)
+  {
+    csOrthoTransform::SetO2TTranslation (v);
+    cameranr = cur_cameranr++;
+  }
+
+  /**
+   * Sets the absolute position of the camera inside the sector.
+   * Vector 'v' is in world space coordinates. This function does
+   * not check if the vector is really in the current sector. In
+   * fact it is legal to set the position outside the sector
+   * boundaries.
+   */
+  virtual void SetPosition (const csVector3& v) { SetOrigin (v); }
+
+  /**
+   * Set the world to camera transformation matrix.
+   * This basicly defines the direction that the camera looks.
+   */
+  inline void SetW2C (const csMatrix3& m) { SetO2T (m); }
+
+  /**
+   * Set the camera to world transformation matrix.
+   * This basicly defines the direction that the camera looks.
+   */
+  inline void SetC2W (const csMatrix3& m) { SetT2O (m); }
+
+  /**
+   * Return the world to camera transformation matrix.
+   */
+  inline csMatrix3 GetW2C () const { return GetO2T (); }
+
+  /**
+   * Return the camera to world transformation matrix.
+   */
+  inline csMatrix3 GetC2W () const { return GetT2O (); }
+
+  /**
+   * Return the world to camera translation.
+   */
+  inline csVector3 GetW2CTranslation () const { return GetO2TTranslation (); }
+
+  /**
+   * Transform a worldspace point to camera space.
+   */
+  inline csVector3 World2Camera (const csVector3& v) const
+  { return Other2This (v); }
+
+  /**
+   * Transform a camera space point to world space.
+   */
+  inline csVector3 Camera2World (const csVector3& v) const
+  { return This2Other (v); }
+
+  /**
+   * Transform a camera space point to worldspace, relative to camera position.
+   */
+  inline csVector3 Camera2WorldRelative (const csVector3& v) const
+  { return This2OtherRelative (v); }
+
+  /**
+   * Moves the camera a relative amount in world coordinates.
+   * If 'cd' is true then collision detection with objects and things
+   * inside the sector is active. Otherwise you can walk through objects
+   * (but portals will still be correctly checked).
+   */
+  virtual void MoveWorld (const csVector3& v, bool cd = true);
+
+  /**
+   * Moves the camera a relative amount in camera coordinates.
+   */
+  virtual void Move (const csVector3& v, bool cd = true)
+  { MoveWorld (m_t2o * v, cd); }
+
+  /**
+   * Moves the camera a relative amount in world coordinates,
+   * ignoring portals and walls. This is used by the wireframe
+   * class. In general this is useful by any camera model that
+   * doesn't want to restrict its movement by portals and
+   * sector boundaries.
+   */
+  virtual void MoveWorldUnrestricted (const csVector3& v) { Translate (v); }
+
+  /**
+   * Moves the camera a relative amount in camera coordinates,
+   * ignoring portals and walls. This is used by the wireframe
+   * class. In general this is useful by any camera model that
+   * doesn't want to restrict its movement by portals and
+   * sector boundaries.
+   */
+  virtual void MoveUnrestricted (const csVector3& v) { Translate (m_t2o * v); }
+
+  /**
+   * Eliminate roundoff error by snapping the camera orientation to a
+   * grid of density n
+   */
+  void Correct (int n);
+
+  /// Change the shift for perspective correction.
+  void SetPerspectiveCenter (float x, float y) { shift_x = x; shift_y = y; }
+
+  /// Calculate perspective corrected point for this camera.
+  void Perspective (const csVector3& v, csVector2& p) const
+  {
+    float iz = aspect / v.z;
+    p.x = v.x * iz + shift_x;
+    p.y = v.y * iz + shift_y;
+  }
+
+  /// Calculate inverse perspective corrected point for this camera.
+  void InvPerspective (const csVector2& p, float z, csVector3& v) const
+  {
+    v.z = z;
+    v.x = (p.x - shift_x) * z * inv_aspect;
+    v.y = (p.y - shift_y) * z * inv_aspect;
+  }
+
+  SCF_DECLARE_IBASE;
+
+  //------------------------ iCamera implementation ------------------------
+  struct Camera : public iCamera
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csCamera);
+
+    virtual iCamera *Clone () const
+    { return &(new csCamera (*scfParent))->scfiCamera; }
+
+    virtual int GetFOV () const
+    { return scfParent->GetFOV (); }
+    virtual float GetInvFOV () const
+    { return scfParent->GetInvFOV (); }
+    virtual float GetFOVAngle () const
+    { return scfParent->GetFOVAngle (); }
+    virtual void SetFOV (int a, int width)
+    { scfParent->SetFOV (a, width); }
+    virtual void SetFOVAngle (float a, int width)
+    { scfParent->SetFOVAngle (a, width); }
+
+    virtual float GetShiftX () const
+    { return scfParent->GetShiftX (); }
+    virtual float GetShiftY () const
+    { return scfParent->GetShiftY (); }
+    virtual void SetPerspectiveCenter (float x, float y)
+    { scfParent->SetPerspectiveCenter (x, y); }
+
+    virtual csOrthoTransform& GetTransform ()
+    { return *(csOrthoTransform*)scfParent; }
+    virtual const csOrthoTransform& GetTransform () const
+    { return *(csOrthoTransform*)scfParent; }
+    virtual void SetTransform (const csOrthoTransform& tr)
+    {
+      *(csOrthoTransform*)scfParent = tr;
+      scfParent->cameranr = scfParent->cur_cameranr++;
+    }
+    virtual void MoveWorld (const csVector3& v, bool cd = true)
+    { scfParent->MoveWorld (v, cd); }
+    virtual void Move (const csVector3& v, bool cd = true)
+    { scfParent->Move (v, cd); }
+    virtual void MoveWorldUnrestricted (const csVector3& v)
+    { scfParent->MoveWorldUnrestricted (v); }
+    virtual void MoveUnrestricted (const csVector3& v)
+    { scfParent->MoveUnrestricted (v); }
+
+    virtual iSector* GetSector () const
+    { return scfParent->GetSector() ?
+      &scfParent->GetSector()->scfiSector : NULL; }
+    virtual void SetSector (iSector *s)
+    { scfParent->SetSector (s->GetPrivateObject ()); }
+
+    virtual iPolygon3D* GetHit (csVector3& v)
+    {
+      csPolygon3D* poly = scfParent->GetHit (v);
+      return poly ? &(poly->scfiPolygon3D) : NULL;
+    }
+    virtual void Correct (int n)
+    {
+      scfParent->Correct (n);
+    }
+    virtual bool IsMirrored () const
+    {
+      return scfParent->IsMirrored ();
+    }
+    virtual void SetMirrored (bool m)
+    {
+      scfParent->SetMirrored (m);
+    }
+    virtual csPlane3* GetFarPlane () const
+    {
+      return scfParent->GetFarPlane ();
+    }
+    virtual void SetFarPlane (csPlane3* fp)
+    {
+      scfParent->SetFarPlane (fp);
+    }
+    virtual long GetCameraNumber () const
+    {
+      return scfParent->GetCameraNumber ();
+    }
+    virtual void Perspective (const csVector3& v, csVector2& p) const
+    {
+      scfParent->Perspective (v, p);
+    }
+    virtual void InvPerspective (const csVector2& p, float z,
+    	csVector3& v) const
+    {
+      scfParent->InvPerspective (p, z, v);
+    }
+    virtual void OnlyPortals (bool hop)
+    {
+      scfParent->only_portals = hop;
+    }
+    virtual bool GetOnlyPortals ()
+    {
+      return scfParent->only_portals;
+    }
+  } scfiCamera;
+  friend struct Camera;
+
+private:
+  ///
+  void Correct (int n, float* vals[]);
+};
+
+#endif // __CS_CAMERA_H__
diff --git a/client/client94/crystalspace/include/csengine/campos.h b/client/client94/crystalspace/include/csengine/campos.h
new file mode 100644
index 0000000..d6cec66
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/campos.h
@@ -0,0 +1,110 @@
+/*
+    Copyright (C) 2000 by Andrew Zabolotny
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_CAMPOS_H__
+#define __CS_CAMPOS_H__
+
+#include "csutil/csobject.h"
+#include "csutil/nobjvec.h"
+#include "csgeom/vector3.h"
+#include "csengine/camera.h"
+#include "iengine/campos.h"
+
+struct iEngine;
+struct iCamera;
+class csPlane3;
+
+/**
+ * A camera position. This object can be used to initialize a camera object to
+ * a certain state.
+ */
+class csCameraPosition : public csObject
+{
+private:
+  /// Destroy this object and free all associated memory
+  virtual ~csCameraPosition ();
+
+private:
+  /// The sector this camera points to
+  char* sector;
+  /// The camera position
+  csVector3 position;
+  /// Camera orientation: forward vector
+  csVector3 forward;
+  /// Camera orientation: upward vector
+  csVector3 upward;
+  /**
+   * Far plane. Negative side of this plane (as seen with Classify() function)
+   * is invisible (which is different from how planes in CS usually
+   * act). If this is NULL there is no far plane.
+   */
+  csPlane3* far_plane;
+
+public:
+  /// Initialize the camera position object
+  csCameraPosition (const char *name, const char *sector,
+    const csVector3 &position,
+    const csVector3 &forward, const csVector3 &upward);
+
+  /// Change camera position object
+  void Set (const char *sector, const csVector3 &position,
+    const csVector3 &forward, const csVector3 &upward);
+
+  /// Load the camera position into a camera object
+  bool Load (iCamera*, iEngine*);
+
+  void SetFarPlane (csPlane3* pl);
+  void ClearFarPlane ();
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //--------------------- iCameraPosition implementation ----------------------
+  struct CameraPosition : public iCameraPosition
+  {
+    SCF_DECLARE_EMBEDDED_IBASE(csCameraPosition);
+
+    virtual iObject *QueryObject();
+    virtual iCameraPosition *Clone () const;
+    virtual const char *GetSector();
+    virtual void SetSector(const char *Name);
+    virtual const csVector3 &GetPosition();
+    virtual void SetPosition (const csVector3 &v);
+    virtual const csVector3 &GetUpwardVector();
+    virtual void SetUpwardVector (const csVector3 &v);
+    virtual const csVector3 &GetForwardVector();
+    virtual void SetForwardVector (const csVector3 &v);
+    virtual void Set (const char *sector, const csVector3 &pos,
+      const csVector3 &forward, const csVector3 &upward);
+    virtual bool Load (iCamera *c, iEngine *e);
+    virtual void SetFarPlane (csPlane3* pl)
+    {
+      scfParent->SetFarPlane (pl);
+    }
+    virtual void ClearFarPlane ()
+    {
+      scfParent->ClearFarPlane ();
+    }
+    virtual csPlane3* GetFarPlane () const
+    {
+      return scfParent->far_plane;
+    }
+  } scfiCameraPosition;
+  friend struct CameraPosition;
+};
+
+#endif // __CS_CAMPOS_H__
diff --git a/client/client94/crystalspace/include/csengine/cbufcube.h b/client/client94/crystalspace/include/csengine/cbufcube.h
new file mode 100644
index 0000000..726ce86
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/cbufcube.h
@@ -0,0 +1,107 @@
+/*
+    Copyright (C) 2000 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_CBUFCUBE_H__
+#define __CS_CBUFCUBE_H__
+
+class csClipper;
+
+#include "csengine/cbuffer.h"
+#include "csengine/pol2d.h"
+#include "csgeom/polyclip.h"
+
+/**
+ * Subclass of csCBuffer which adds perspective correction
+ * of 3d polygons.
+ */
+class csCBufferPersp : public csCBuffer
+{
+private:
+  /// Perspective project a polygon. Return true if visible.
+  bool DoPerspective (csVector3* verts, int num_verts,
+    csPolygon2D& persp);
+
+public:
+  /// Constructor.
+  csCBufferPersp (int sx, int sy, int nlines) : csCBuffer (sx, sy, nlines) { }
+
+  /**
+   * Insert a polygon/frustum into the cube.
+   * The optional 'clipper' will be used to clip the resulting polygon.
+   */
+  bool InsertPolygon (csVector3* verts, int num_verts, csClipper* clipper = NULL);
+
+  /**
+   * Test for polygon/frustum visibility with the cube.
+   * The optional 'clipper' will be used to clip the resulting polygon.
+   */
+  bool TestPolygon (csVector3* verts, int num_verts, csClipper* clipper = NULL);
+};
+
+/**
+ * A cbuffer cube is a set of six c-buffers arranged in a cube.
+ */
+class csCBufferCube
+{
+private:
+  /// The six c-buffers.
+  csCBufferPersp* trees[6];
+  /// A box clipper to clip all the 2D polygons with.
+  csBoxClipper* clipper;
+
+public:
+  /// Make the cube for the box.
+  csCBufferCube (int dim);
+
+  /**
+   * Destroy this cube.
+   */
+  ~csCBufferCube ();
+
+  /**
+   * Make cube empty.
+   */
+  void MakeEmpty ();
+
+  /**
+   * Is the cube full?
+   */
+  bool IsFull ();
+
+  /**
+   * Insert a polygon into the cube.
+   * Return true if the cube was modified (i.e. if parts of the
+   * polygon were visible.<p>
+   * The polygon does not actually need to be a polygon. It can
+   * be a general frustum. Note that the frustum is assumed
+   * to start at (0,0,0).
+   */
+  bool InsertPolygon (csVector3* verts, int num_verts);
+
+  /**
+   * Test for polygon visibility with the cube.
+   * Return true if polygon is visible.<p>
+   * The polygon does not actually need to be a polygon. It can
+   * be a general frustum. Note that the frustum is assumed
+   * to start at (0,0,0).
+   */
+  bool TestPolygon (csVector3* verts, int num_verts);
+};
+
+#endif // __CS_CBUFCUBE_H__
+
diff --git a/client/client94/crystalspace/include/csengine/cbuffer.h b/client/client94/crystalspace/include/csengine/cbuffer.h
new file mode 100644
index 0000000..f474bb5
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/cbuffer.h
@@ -0,0 +1,230 @@
+/*
+    Copyright (C) 1998 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_CBUFFER_H__
+#define __CS_CBUFFER_H__
+
+#include "csgeom/math2d.h"
+
+struct iGraphics2D;
+struct iGraphics3D;
+
+/*=================*
+ * Coverage Buffer *
+ *=================*/
+
+/**
+ * A simple span in a CBuffer line.
+ * Note that we work with a 'negative' c-buffer. This means
+ * that every span indicates an empty region on screen.
+ */
+struct csCBufferSpan
+{
+  /// Inclusive range of span.
+  int startx, endx;
+  /// Next span.
+  csCBufferSpan* next;
+};
+
+class csCBuffer;
+
+/**
+ * A line in the CBuffer.
+ * Spans are allocated on an as-needed base. But they are
+ * not freed. Instead, unused spans are put in the first_unused
+ * list (in csCBuffer). The size of this list will always be equal
+ * to the maximum number of spans once used on screen.
+ */
+class csCBufferLine
+{
+  friend class csCBuffer;
+
+private:
+  /// List of all empty spans on this line.
+  csCBufferSpan* first_span;
+  /// Pointer to last span in the list of empty spans.
+  csCBufferSpan* last_span;
+  /// Parent C-buffer.
+  csCBuffer* parent;
+
+private:
+  /// Initialize a c-buffer line.
+  csCBufferLine ();
+  /**
+   * Destruct a c-buffer line and free all used spans.
+   * Note: the spans are really freed and not put in the unused list.
+   */
+  ~csCBufferLine ();
+
+  /// Set parent.
+  void SetParent (csCBuffer* par) { parent = par; }
+
+  /**
+   * Initialize this line to the given empty span.
+   */
+  void Initialize (int startx, int endx);
+
+  /// Return true if this line if full (i.e. no empty spans left).
+  bool IsFull () { return first_span == NULL; }
+
+  /// Make this line full.
+  void MakeFull ();
+
+  /**
+   * Take a full span and test if it would have changed this c-buffer
+   * line on insertion. This means that the span is visible.
+   */
+  bool TestSpan (int startx, int endx);
+
+  /**
+   * Take a full span and insert it into the c-buffer line. Return
+   * true if the span line was modified (i.e. the span is visible).
+   */
+  bool InsertSpan (int startx, int endx);
+
+  /**
+   * Test if a given one-element-scan is full or empty (i.e. return
+   * true if visible).
+   */
+  bool TestSingle (int x) { return TestSpan (x, x); }
+
+  /// Dump information about this scanline.
+  void Dump ();
+};
+
+/**
+ * The CBuffer.
+ * Note that all ranges specified in this class are inclusive.
+ */
+class csCBuffer
+{
+  friend class csCBufferLine;
+
+private:
+  /// The lines of this c-buffer.
+  csCBufferLine* lines;
+  /// Number of vertical lines.
+  int num_lines;
+  /// Horizontal start and end (inclusive).
+  int startx, endx;
+  /// List of all unused spans on screen.
+  csCBufferSpan* first_unused;
+  /**
+   * A vertical c-buffer line which is used to indicate
+   * which horizontal lines of the c-buffer are full.
+   * Again spans indicate not-full regions.
+   */
+  csCBufferLine vert_line;
+
+  /// Allocate a span (possible from the unused list).
+  csCBufferSpan* AllocSpan ()
+  {
+    csCBufferSpan* s;
+    if (first_unused)
+    {
+      s = first_unused;
+      first_unused = first_unused->next;
+    }
+    else
+      s = new csCBufferSpan ();
+    return s;
+  }
+  /// Free a span (put in the unused list).
+  void FreeSpan (csCBufferSpan* span)
+  {
+    span->next = first_unused;
+    first_unused = span;
+  }
+
+  /**
+   * Take a full span and test if it would have changed the c-buffer
+   * line on insertion. This means that the span is visible.
+   */
+  bool TestSpan (int s_spanx, int e_spanx, int y)
+  {
+    if (y < 0 || y >= num_lines) return false;
+    return lines[y].TestSpan (s_spanx, e_spanx);
+  }
+
+  /**
+   * Take a full span and insert it into the c-buffer line. Return
+   * true if the span modified the buffer (i.e. span is visible).
+   */
+  bool InsertSpan (int s_spanx, int e_spanx, int y)
+  {
+    if (y < 0 || y >= num_lines) return false;
+    return lines[y].InsertSpan (s_spanx, e_spanx);
+  }
+
+  /// Test if a line is full.
+  bool IsFull (int y)
+  {
+    if (y < 0 || y >= num_lines) return false;
+    return lines[y].IsFull ();
+  }
+
+public:
+  /// Create a new c-buffer with the given dimensions.
+  csCBuffer (int sx, int ex, int n_lines);
+  /// Destroy the c-buffer.
+  ~csCBuffer ();
+
+  /// Initialize the c-buffer to empty.
+  void Initialize ();
+
+  /// Return true if the screen (c-buffer) is full.
+  bool IsFull () { return vert_line.IsFull (); }
+
+  /**
+   * Take a polygon and test if it would have changed the c-buffer.
+   * This means that the polygon is visible. Polygon vertices are
+   * converted to integer before comparing.
+   * Note that this function will work with both clockwise and anti-
+   * clockwise oriented polygons and will assume both orientations
+   * are visible. Backface culling needs to be done elsewhere.
+   */
+  bool TestPolygon (csVector2* verts, int num_verts);
+
+  /**
+   * Take a polygon and insert all spans in the c-buffer.
+   * Returns true if the polygon is visible.
+   * Note that this function will work with both clockwise and anti-
+   * clockwise oriented polygons and will assume both orientations
+   * are visible. Backface culling needs to be done elsewhere.
+   * If 'negative' is true the polygon is inserted inverted.
+   */
+  bool InsertPolygon (csVector2* verts, int num_verts, bool negative = false);
+
+  /**
+   * Test if a given point is visible in the c-buffer.
+   * Returns true if visible (i.e. c-buffer is empty at
+   * that point).
+   */
+  bool TestPoint (const csVector2& point);
+
+
+  /// Dump debug information for a scanline.
+  void DumpLine (int y) { lines[y].Dump (); }
+
+  /**
+   * Do a graphical dump of the c-buffer contents on screen.
+   */
+  void GfxDump (iGraphics2D* ig2d, iGraphics3D* ig3d);
+};
+
+#endif // __CS_CBUFFER_H__
diff --git a/client/client94/crystalspace/include/csengine/crysball.h b/client/client94/crystalspace/include/csengine/crysball.h
new file mode 100644
index 0000000..79d3879
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/crysball.h
@@ -0,0 +1,131 @@
+/*
+    Copyright (C) 2000 by Norman Krämer
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_CRYSBALL_H__
+#define __CS_CRYSBALL_H__
+
+/**
+ * This is an attempt to provide a  massdetection of backfaced polygons.
+ *
+ * Observation:
+ * Mark 3 distinct points on a sphere. Consider the spherical triangle they form . If all
+ * 3 points z-coordinates sign equal then all other points z-coordinate inside the
+ * triangle have the same sign.
+ *
+ * It works this way:
+ * Precompute the normals of a rigid set of polygons. These normals are unit size and
+ * therefor mark a point on the unit sphere. If one rotates the polygonset all points
+ * on the unit sphere are rotated by the same amount.
+ *
+ * To start off, subdivide the sphere into 8 spherical triangles. For every triangle make
+ * a list of  points (normals) in it. For every triangle then subdivide further into 3
+ * subtriangles and mark the points contained in it. Repeat this process until every
+ * triangle contains only one point (normal).
+ *
+ * Now to find the backfaced polygons rotate the triangle points on level 0.
+ * If a triangles points have all equally signed z-coordinates all polygons belonging
+ * to it are either all visible or invisible.
+ * If the signs differ then recursively test the subtriangles.
+ */
+
+#include "csutil/cstreend.h"
+#include "csgeom/vector3.h"
+#include "csgeom/math3d.h"
+#include "csgeom/transfrm.h"
+#include "ivaria/polymesh.h"
+
+class csCrystalBall
+{
+  class csCrystalBallVec : public csVector3
+  {
+  protected:
+    int idx; // holds the index of the polygon
+  public:
+    csCrystalBallVec (int polyidx) { idx = polyidx; }
+    inline int GetIndex () { return idx; }
+  };
+
+  class csTriNode : public csTreeNode
+  {
+  public:
+    enum
+    {
+      INSIDE = 0,
+      OUTSIDE = 1
+    };
+
+    int from, len; // contains <len> points in vPoints starting at <from>
+    int divider; // index to point that divides this triangle
+    csTriNode (csTriNode *theParent=NULL, int from=-1, int len=0) : csTreeNode (theParent)
+      {this->from = from; this->len = len;}
+
+    // find a triangle for <normal> and return the index where its been inserted into vP
+    int Add (const csCrystalBallVec *normal, int tri1, int tri2, int tri3,
+	      csVector *vP, csVector *vTP);
+
+    // adjust (from,len) pairs after a new point was inserted
+    void Adjust (int nPos);
+
+    // classify a point to lie inside or outside the spherical triangle
+    int Classify (const csVector3 &n, int i1, int i2, int i3,
+		  const csVector *vTP) const;
+
+    // are all 3 normals on the side <useSign>
+    // 0 ... yes
+    // 1 ... partly
+    // 2 ... all on other side
+    int SignMatches (const csVector3 *n1, const csVector3 *n2, const csVector3 *td,
+		     int useSign);
+
+    // is the normal tn on the <useSign> side ?
+    bool SignMatches (const csVector3 *tn, int useSign);
+
+    // rotate the unitsphere by matrix <m>. Add all polygon indices to <indexVector>
+    // which normlals point to the <useSign> side
+    void Transform (const csMatrix3 &m, csVector &indexVector,
+		    int useSign, long cookie,
+		    const csVector *vP, const csVector *vTP,
+		    const csVector3 &v1, const csVector3 &v2,
+		    const csVector3 &v3);
+  };
+
+ protected:
+  // here we store the normals (pointers to csCrystalBallVec)
+  csVector vPoints;
+  // we divide a triangle into 3 sub triangles by inserting a divider point.
+  // and <vTrianglePoints> is the place where we store those points (pointers to csVector3)
+  csVector vTrianglePoints;
+  // our crystal ball is initially made of 8 spherical triangles (in the octants of a 3d cartesian coo system)
+  csTriNode tri[8];
+
+ public:
+  csCrystalBall ();
+  ~csCrystalBall ();
+
+  // add all polygons in <polyset> to the crystal ball
+  void Build (iPolygonMesh *polyset);
+
+  // add a single polygon to the crystal ball
+  void InsertPolygon (iPolygonMesh *polyset, int idx);
+
+  // rotate the unitsphere by <t>. Add all polygon indices to <indexVector>
+  // which normlals point to the <useSign> side
+  void Transform (const csTransform &t, csVector &indexVector, int useSign, long cookie);
+};
+
+#endif // __CS_CRYSBALL_H__
diff --git a/client/client94/crystalspace/include/csengine/cscoll.h b/client/client94/crystalspace/include/csengine/cscoll.h
new file mode 100644
index 0000000..321cdd8
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/cscoll.h
@@ -0,0 +1,93 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_CSCOLL_H__
+#define __CS_CSCOLL_H__
+
+#include "csgeom/matrix3.h"
+#include "csutil/csobject.h"
+#include "csutil/csvector.h"
+#include "iengine/collectn.h"
+
+class csSector;
+class csEngine;
+
+SCF_VERSION (csCollection, 0, 0, 1);
+
+/**
+ * A collection object is for conveniance of the script language.
+ * It simply groups objects which are related in some way.
+ */
+class csCollection : public csObject
+{
+private:
+  /// The list of objects contained in this csCollection.
+  csVector objects;
+
+  /// Handle to the engine plug-in.
+  csEngine* engine;
+
+private:
+  ///
+  virtual ~csCollection ();
+
+public:
+  /**
+   * Create a new csCollection with the given name.
+   */
+  csCollection (csEngine* engine);
+
+  /**
+   * Find an object with the given name inside this collection.
+   */
+  iObject* FindObject (char* name);
+
+  /**
+   * Get the number of objects in this collection.
+   */
+  int GetObjectCount () const { return objects.Length(); }
+
+  /// Add an object to the collection.
+  void AddObject (iObject* obj) { objects.Push((csSome)obj); }
+
+  ///
+  iObject* operator[] (int i) { return (iObject*) (objects[i]); }
+
+  SCF_DECLARE_IBASE;
+
+  //------------------------- iCollection interface --------------------------
+  struct Collection : public iCollection
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csCollection);
+    virtual iObject *QueryObject()
+      { return scfParent; }
+    virtual iObject* FindObject (char* name) const
+      { return scfParent->FindObject(name); }
+    virtual int GetObjectCount () const
+      { return scfParent->GetObjectCount(); }
+    virtual void AddObject (iObject* obj)
+      { scfParent->AddObject(obj); }
+    virtual iObject* operator[] (int i) const
+      { return (*scfParent)[i]; }
+    virtual iObject* GetObject (int i) const
+      { return (*scfParent)[i]; }
+  } scfiCollection;
+  friend struct Collection;
+};
+
+#endif // __CS_CSCOLL_H__
diff --git a/client/client94/crystalspace/include/csengine/curve.h b/client/client94/crystalspace/include/csengine/curve.h
new file mode 100644
index 0000000..f8699e9
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/curve.h
@@ -0,0 +1,503 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_CURVE_H__
+#define __CS_CURVE_H__
+
+#include "csutil/scf.h"
+#include "csutil/csvector.h"
+#include "csgeom/math3d.h"
+#include "csgeom/math2d.h"
+#include "csgeom/box.h"
+#include "csengine/bezier.h"
+#include "csengine/texture.h"
+#include "csengine/material.h"
+#include "csengine/lghtmap.h"
+#include "csengine/rview.h"
+#include "csutil/csobject.h"
+#include "ivideo/graph3d.h"
+#include "ivideo/vbufmgr.h"
+#include "imesh/thing/curve.h"
+
+class csThing;
+class csCurveTemplate;
+class csLightPatch;
+class csSector;
+class csRadCurve;
+class csBspContainer;
+class csFrustumView;
+struct csCoverageMatrix;
+struct iMaterialHandle;
+struct iCacheManager;
+
+/**
+ * Tesselated curve. This is basicly a list of triangles.
+ */
+class csCurveTesselated
+{
+private:
+  // Object space coordinates.
+  csVector3* ObjectCoords;
+  // Texture coordinates.
+  csVector2* TextureCoords;
+  // Original control points.
+  csVector2* ControlPoints;
+  // Colors for the vertices.
+  csColor* Colors;
+  // Triangles.
+  csTriangle* Triangles;
+
+  // Number of vertices
+  int NumVertices;
+  // Number of triangles
+  int NumTriangles;
+  // A flag which indicates if the color table is filled in.
+  bool ColorsValid;
+
+public:
+  /**
+   * Allocate a new tesselated curve with the given
+   * number of vertices and triangles.
+   */
+  csCurveTesselated (int NumVertices, int NumTriangles);
+  /// destructor
+  ~csCurveTesselated ();
+
+  /// Return the number of vertices
+  inline int GetVertexCount () const;
+  /// Return the number of triangles
+  inline int GetTriangleCount () const;
+  /// Return the array of vertices
+  inline csVector3* GetVertices ();
+  /// Return the array of texture coordinates
+  inline csVector2* GetTxtCoords ();
+  /// Return the array of control points
+  inline csVector2* GetControlPoints ();
+  /// Return the array of vertex colors
+  inline csColor* GetColors ();
+  /// Return the array of triangles
+  inline csTriangle* GetTriangles ();
+  /// Return a single triangle @@@ why?
+  inline csTriangle& GetTriangle (int i);
+  /// Return true if the colors table is valid.
+  inline bool AreColorsValid () const;
+
+  /**
+   * Update the 'colors' array in this tesselation given
+   * a lightmap. This should be called whenever the lightmap
+   * changes and the curve needs to be rendered.
+   */
+  void UpdateColors (csLightMap* lightmap);
+};
+
+/**
+ * This is an abstract class for all curves in Crystal Space.
+ */
+class csCurve : public csObject
+{
+  /// allow csRadCurve to use our UV Buffers
+  friend class csRadCurve;
+
+private:
+  /// ID for this curve.
+  unsigned long CurveID;
+  /// Last used ID.
+  static unsigned long LastCurveID;
+
+  /// Material for this curve
+  iMaterialWrapper* Material;
+
+  /// Pointer to the template for this curve
+  csCurveTemplate* CurveTemplate;
+
+  /// list of light patches
+  csLightPatch* LightPatches;
+
+  /**
+   * Object to world transformation (Needed by CalculateLighting &
+   * ShineDynLight).
+   */
+  csReversibleTransform* O2W;
+
+  /*
+   * Position Buffer: this is an array which coordinates u,v lightmap
+   * pixel coordinates to the position on the curve in world space
+   * coordinates.
+   * i.e. in a 10x10 lightmap uv2World[5][5] is the world space coordinate
+   *   of the lightmap texel 5,5 on the lightmap
+   */
+  csVector3* uv2World;
+
+  /*
+   * Normal Buffer: this is an array which coordinates u,v lightmap
+   * pixel coordinates to the normal of the curve
+   * i.e. in a 10x10 lightmap uv2Normal[5][5] is the normal vector which
+   * corresponds to the lightmap texel 5,5 on the lightmap
+   */
+  csVector3* uv2Normal;
+
+  /// Vertex buffer.
+  iVertexBuffer* vbuf;
+  iVertexBufferManager* vbufmgr;
+
+  /// retrieve a vertexbuffer from the manager if not done already
+  void SetupVertexBuffer ();
+
+  /// interface to receive state of vertexbuffermanager
+  struct eiVertexBufferManagerClient : public iVertexBufferManagerClient
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csCurve);
+    virtual void ManagerClosing ();
+  }scfiVertexBufferManagerClient;
+  friend struct eiVertexBufferManagerClient;
+
+
+public:
+  /// The polygon set parent.
+  csThing* ParentThing;
+
+  /// This is the lightmap to be placed on the curve.
+  csLightMap* LightMap;
+
+  /// This flag indicates whether the lightmap is up-to-date
+  bool LightmapUpToDate;
+
+public:
+
+  /// Constructor
+  csCurve (csCurveTemplate* parent_tmpl);
+  /// Destructor
+  virtual ~csCurve ();
+
+  /// Get the ID of this curve.
+  inline unsigned long GetCurveID () const;
+
+  /// Get the vertex buffer for this curve.
+  iVertexBuffer* GetVertexBuffer () const { return vbuf; }
+
+  /// Return the material handle for this curve
+  inline iMaterialHandle* GetMaterialHandle () const;
+  /// Return the material wrapper for this curve
+  inline iMaterialWrapper* GetMaterial () const;
+  /// Set the material wrapper for this curve
+  void SetMaterial (iMaterialWrapper* h);
+
+  /// Get the parent template used for this curve.
+  inline csCurveTemplate* GetParentTemplate () const;
+
+  /// @@@
+  void MakeDirtyDynamicLights ();
+  /// Add a lightpatch to this curves list of light patches
+  void AddLightPatch (csLightPatch* lp);
+  /// Remove a lightpatch from this curves list
+  void UnlinkLightPatch (csLightPatch* lp);
+  /// update the real lightmap with all light info
+  bool RecalculateDynamicLights ();
+  /// update the real lightmap with info from the lightpatch
+  void ShineDynLight (csLightPatch* lp);
+
+  /// Set the current object to world space transformation.
+  void SetObject2World (const csReversibleTransform *o2w);
+  /// Return the current object to world space transformation
+  inline const csReversibleTransform *GetObject2World () const;
+
+  /// Set the parent thing for this curve
+  inline void SetParentThing (csThing* p);
+  /// Return the parent thing for this curve
+  inline csThing* GetParentThing () const;
+
+  /// Get the lightmap.
+  inline csLightMap* GetLightMap () const;
+  /// Calculate the lighting for this curve (static).
+  void CalculateLightingStatic (csFrustumView* lview, bool vis);
+  /// Calculate the lighting for this curve (dynamic).
+  void CalculateLightingDynamic (csFrustumView* lview);
+  /// Initialize default lighting.
+  void InitializeDefaultLighting ();
+  /// Read lighting from cache.
+  bool ReadFromCache (iCacheManager* cache_mgr, int id);
+  /// Cache the curve lightmaps.
+  bool WriteToCache (iCacheManager* cache_mgr, int id);
+  /// Prepare lighting.
+  void PrepareLighting ();
+
+  /**
+   * Populate a coverage matrix which relates shadow information for this
+   * curve's lightmap
+   */
+  void GetCoverageMatrix (csFrustumView& lview, csCoverageMatrix &cm) const;
+
+  /// return an approximation of the area of this curve
+  float GetArea();
+
+  /// @@@
+  void CalcUVBuffers();
+
+  /**
+   * Tesselate this curve with the given resolution.
+   * This function will allocated and return a csCurveTesselated object.
+   * the curve is responsible for clamping res to allowed values itself.
+  */
+  virtual csCurveTesselated* Tesselate (int res) = 0;
+
+  /**
+   * set control index for a control point (referring to the controls
+   * in the parent csThing)
+   */
+  virtual void SetControlPoint (int index, int control_id) = 0;
+
+  /// Return a bounding box in object space for this curve.
+  virtual void GetObjectBoundingBox (csBox3& bbox) = 0;
+
+  /**
+   * Get a bounding box in camera space. This function
+   * uses the object bounding box so it will exagerate the real
+   * bounding box a little.
+   */
+  void GetCameraBoundingBox (const csTransform& obj2cam, csBox3& cbox);
+
+  /**
+   * Get a bounding box in screen space and camera space.
+   * This function will use GetCameraBoundingBox().
+   * It will fill in the boundingBox with the X and Y locations
+   * of the curve.  Returns the max Z location of the curve,
+   * or -1 if the curve is not on-screen.
+   * If the curve is not on-screen, the X and Y values are
+   * not valid.
+   */
+  float GetScreenBoundingBox (const csTransform& obj2cam,
+  	iCamera* camera, csBox3& cameraBox, csBox2& boundingBox);
+
+  /**
+   * Lighting support. If IsLightable returns true, PosInSpace and Normal should
+   * calculate accurate positions and normals for the beziers, regardless of the
+   * approximating tesselation method. These are used for lighting.
+   * Default behaviour is to allow for unlighted curves. Derive these if you do
+   * want them lighted.
+   */
+  virtual bool IsLightable ();
+  /// Helper function for lighting. Override for different types of curves.
+  virtual void PosInSpace (csVector3& vec, double u, double v);
+  /// Helper function for lighting. Override for different types of curves.
+  virtual void Normal (csVector3& vec, double u, double v);
+
+  /// Do a hard transform on this curve.
+  virtual void HardTransform (const csReversibleTransform& trans);
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //----------------------- iCurve interface implementation -----------------
+  struct Curve : public iCurve
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csCurve);
+
+    virtual csCurve* GetOriginalObject ()
+    { return scfParent; }
+    virtual iObject *QueryObject()
+    { return scfParent; }
+    virtual iCurveTemplate* GetParentTemplate ();
+    virtual void SetMaterial (iMaterialWrapper* mat)
+    { scfParent->SetMaterial (mat); }
+    virtual iMaterialWrapper* GetMaterial ()
+    { return scfParent->GetMaterial (); }
+    virtual void SetName (const char* name)
+    { scfParent->SetName (name); }
+    virtual const char* GetName () const
+    { return scfParent->GetName (); }
+    virtual void SetControlPoint (int idx, int control_id)
+    { scfParent->SetControlPoint (idx, control_id); }
+  } scfiCurve;
+  friend struct Curve;
+};
+
+
+SCF_VERSION (csCurveTemplate, 0, 0, 1);
+
+/**
+ * A curve template.
+ */
+class csCurveTemplate : public csObject
+{
+protected:
+  iMaterialWrapper* Material;
+
+protected:
+  ///
+  virtual ~csCurveTemplate ();
+
+public:
+  ///
+  csCurveTemplate();
+
+  /// Create an instance of this template.
+  virtual csCurve* MakeCurve () = 0;
+
+  /// Set a vertex of the template
+  virtual void SetVertex (int index, int ver_ind) = 0;
+  /// Return a vertex of the template
+  virtual int GetVertex (int index)  = 0;
+  /// Return the number of vertices in the template
+  virtual int GetVertexCount () = 0;
+
+  /// Return the current material.
+  iMaterialWrapper* GetMaterial () { return Material; }
+  /// Set the current material.
+  void SetMaterial (iMaterialWrapper* h);
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //------------------ iCurveTemplate interface implementation --------------
+  struct CurveTemplate : public iCurveTemplate
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csCurveTemplate);
+    virtual iObject *QueryObject()
+    { return scfParent; }
+    virtual void SetMaterial (iMaterialWrapper* mat)
+    { scfParent->SetMaterial (mat); }
+    virtual iMaterialWrapper* GetMaterial ()
+    { return scfParent->GetMaterial (); }
+    virtual iCurve* MakeCurve ()
+    { return &(scfParent->MakeCurve ()->scfiCurve); }
+    virtual int GetVertexCount () const
+    { return scfParent->GetVertexCount (); }
+    virtual int GetVertex (int idx) const
+    { return scfParent->GetVertex (idx); }
+    virtual void SetVertex (int idx, int vt)
+    { scfParent->SetVertex (idx, vt); }
+  } scfiCurveTemplate;
+  friend struct CurveTemplate;
+};
+
+/**
+ * A specific curve implementation for Bezier curve template.
+ */
+class csBezierTemplate : public csCurveTemplate
+{
+private:
+  int ver_id[9];
+
+public:
+  csBezierTemplate();
+
+  virtual csCurve* MakeCurve();
+
+  /// Tesselate this curve.
+  virtual void SetVertex (int index, int ver_ind);
+  ///
+  virtual int GetVertex (int index);
+  virtual int GetVertexCount ();
+
+  // Should not be necessary, but without this buggy NextStep compiler
+  // incorrectly calls csObject::QueryInterface() rather than correctly
+  // calling csCurveTemplate::QueryInterface().
+  SCF_DECLARE_IBASE_EXT(csCurveTemplate);
+};
+
+/**
+ * A specific curve implementation for Bezier curves.
+ */
+class csBezierCurve : public csCurve
+{
+private:
+  /// The control points of this curve.
+  csVector3 points[3][3];
+  /// The texture coordinates of every control point.
+  csVector2 texture_coords[3][3];
+
+  double cpt[9][5];
+
+  csCurveTesselated* previous_tesselation;
+  int previous_resolution;
+
+  /// Object space bounding box.
+  csBox3 object_bbox;
+  /// If true then the object bbox is valid.
+  bool valid_bbox;
+
+public:
+  ///
+  csBezierCurve (csBezierTemplate* parent_tmpl);
+  ///
+  ~csBezierCurve ();
+
+  /// Tesselate this curve.
+  virtual csCurveTesselated* Tesselate (int res);
+
+  /// Return a bounding box in object space for this curve.
+  virtual void GetObjectBoundingBox (csBox3& bbox);
+
+  /// Load a curve from disk.
+  void Load (char* buf);
+
+  virtual void SetControlPoint (int index, int control_id);
+
+  /// Get a curve point.
+  inline csVector3& GetControlPoint (int i) { return points[i/3][i-(i/3)*3]; }
+
+  /// Get the texture coordinate of a curve point.
+  inline csVector2& GetTextureCoord (int i) { return texture_coords[i/3][i-(i/3)*3]; }
+
+  virtual bool IsLightable ();
+  virtual void PosInSpace (csVector3& vec, double u, double v);
+  virtual void Normal (csVector3& vec, double u, double v);
+
+  /// Do a hard transform on this curve.
+  virtual void HardTransform (const csReversibleTransform& trans);
+};
+
+/*
+ * Implementation of inline functions
+ */
+
+inline int csCurveTesselated::GetVertexCount () const
+{ return NumVertices; }
+inline int csCurveTesselated::GetTriangleCount () const
+{ return NumTriangles; }
+inline csVector3* csCurveTesselated::GetVertices ()
+{ return ObjectCoords; }
+inline csVector2* csCurveTesselated::GetTxtCoords ()
+{ return TextureCoords; }
+inline csVector2* csCurveTesselated::GetControlPoints ()
+{ return ControlPoints; }
+inline csColor* csCurveTesselated::GetColors ()
+{ return Colors; }
+inline csTriangle* csCurveTesselated::GetTriangles ()
+{ return Triangles; }
+inline csTriangle& csCurveTesselated::GetTriangle (int i)
+{ return Triangles[i]; }
+inline bool csCurveTesselated::AreColorsValid () const
+{ return ColorsValid; }
+
+inline unsigned long csCurve::GetCurveID () const
+{ return CurveID; }
+inline iMaterialHandle* csCurve::GetMaterialHandle () const
+{ return Material ? Material->GetMaterialHandle() : NULL; }
+inline iMaterialWrapper* csCurve::GetMaterial () const
+{ return Material; }
+inline csCurveTemplate* csCurve::GetParentTemplate () const
+{ return CurveTemplate; }
+inline csLightMap* csCurve::GetLightMap () const
+{ return LightMap; }
+inline void csCurve::SetParentThing (csThing* p)
+{ ParentThing = p; }
+inline csThing* csCurve::GetParentThing () const
+{ return ParentThing; }
+inline const csReversibleTransform *csCurve::GetObject2World () const
+{ return O2W; }
+
+#endif // __CS_CURVE_H__
diff --git a/client/client94/crystalspace/include/csengine/engine.h b/client/client94/crystalspace/include/csengine/engine.h
new file mode 100644
index 0000000..5e5e4b0
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/engine.h
@@ -0,0 +1,1130 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_ENGINE_H__
+#define __CS_ENGINE_H__
+
+#include "csutil/scf.h"
+#include "csutil/nobjvec.h"
+#include "csutil/csobject.h"
+#include "csutil/garray.h"
+#include "iutil/eventh.h"
+#include "iutil/comp.h"
+#include "iutil/config.h"
+#include "csgeom/math3d.h"
+#include "csengine/arrays.h"
+#include "csengine/rview.h"
+#include "csengine/thing.h"
+#include "csengine/meshobj.h"
+#include "csengine/region.h"
+#include "iengine/engine.h"
+#include "iengine/collectn.h"
+#include "iengine/campos.h"
+#include "ivideo/graph3d.h"
+
+class csRegion;
+class csRadiosity;
+class csSector;
+class csMeshWrapper;
+class csTextureList;
+class csMaterialList;
+class csPolygon3D;
+class csCamera;
+class csStatLight;
+class csDynLight;
+class csCBufferCube;
+class csEngine;
+class csLight;
+class csCBuffer;
+class csPoly2DPool;
+class csLightPatchPool;
+class csLightHalo;
+class csRenderView;
+struct iVFS;
+struct iMaterialWrapper;
+struct iRegion;
+struct iLight;
+struct iImageIO;
+struct iClipper2D;
+struct iReporter;
+struct iProgressMeter;
+struct iObjectRegistry;
+struct iVirtualClock;
+struct iCacheManager;
+
+SCF_DECLARE_FAST_INTERFACE (iEngine)
+SCF_DECLARE_FAST_INTERFACE (iSector)
+SCF_DECLARE_FAST_INTERFACE (iMeshWrapper)
+SCF_DECLARE_FAST_INTERFACE (iCollection)
+SCF_DECLARE_FAST_INTERFACE (iMeshFactoryWrapper)
+SCF_DECLARE_FAST_INTERFACE (iCurveTemplate)
+SCF_DECLARE_FAST_INTERFACE (iMaterialWrapper)
+SCF_DECLARE_FAST_INTERFACE (iTextureWrapper)
+SCF_DECLARE_FAST_INTERFACE (iCameraPosition)
+SCF_DECLARE_FAST_INTERFACE (iPolyTxtPlane)
+SCF_DECLARE_FAST_INTERFACE (iStatLight)
+SCF_DECLARE_FAST_INTERFACE (iDynLight)
+SCF_DECLARE_FAST_INTERFACE (iLightingInfo)
+SCF_DECLARE_FAST_INTERFACE (iLight)
+SCF_DECLARE_FAST_INTERFACE (iMeshObject)
+SCF_DECLARE_FAST_INTERFACE (iMaterial)
+SCF_DECLARE_FAST_INTERFACE (iCrossHalo)
+SCF_DECLARE_FAST_INTERFACE (iNovaHalo)
+SCF_DECLARE_FAST_INTERFACE (iFlareHalo)
+SCF_DECLARE_FAST_INTERFACE (iThingState)
+SCF_DECLARE_FAST_INTERFACE (iShadowCaster)
+SCF_DECLARE_FAST_INTERFACE (iPolygon3D)
+SCF_DECLARE_FAST_INTERFACE (iMeshObjectFactory)
+SCF_DECLARE_FAST_INTERFACE (iReferencedObject)
+SCF_DECLARE_FAST_INTERFACE (iFile)
+SCF_DECLARE_FAST_INTERFACE (iVisibilityObject)
+SCF_DECLARE_FAST_INTERFACE (iVisibilityCuller)
+
+SCF_DECLARE_FAST_INTERFACE (csRadPoly)
+SCF_DECLARE_FAST_INTERFACE (csRadCurve)
+
+/**
+ * Iterator to iterate over all static lights in the engine.
+ * This iterator assumes there are no fundamental changes
+ * in the engine while it is being used.
+ * If changes to the engine happen the results are unpredictable.
+ */
+class csLightIt
+{
+private:
+  // The engine for this iterator.
+  csEngine* engine;
+  // The region we are iterating in (optional).
+  iRegion* region;
+  // Current sector index.
+  int sector_idx;
+  // Current light index.
+  int light_idx;
+
+  // Go to next sector. Return false if finished.
+  bool NextSector ();
+
+public:
+  /// Construct an iterator and initialize to start.
+  csLightIt (csEngine*, iRegion* region = NULL);
+
+  /// Restart iterator.
+  void Restart ();
+
+  /// Get light from iterator. Return NULL at end.
+  csLight* Fetch ();
+
+  /// Get the sector for the last fetched light.
+  csSector* GetLastSector ();
+};
+
+CS_DECLARE_OBJECT_VECTOR (csCollectionListHelper, iCollection);
+
+/**
+ * List of collections for the engine. This class implements iCollectionList.
+ */
+class csCollectionList : public csCollectionListHelper
+{
+public:
+  SCF_DECLARE_IBASE;
+
+  /// constructor
+  csCollectionList ();
+  /// Create a new collection.
+  virtual iCollection* NewCollection (const char* name);
+
+  class CollectionList : public iCollectionList
+  {
+  public:
+    SCF_DECLARE_EMBEDDED_IBASE (csCollectionList);
+    virtual iCollection* NewCollection (const char* name);
+    virtual int GetCount () const;
+    virtual iCollection *Get (int n) const;
+    virtual int Add (iCollection *obj);
+    virtual bool Remove (iCollection *obj);
+    virtual bool Remove (int n);
+    virtual void RemoveAll ();
+    virtual int Find (iCollection *obj) const;
+    virtual iCollection *FindByName (const char *Name) const;
+  } scfiCollectionList;
+};
+
+CS_DECLARE_OBJECT_VECTOR (csCameraPositionListHelper, iCameraPosition);
+
+/**
+ * List of camera positions for the engine. This class implements
+ * iCameraPositionList.
+ */
+class csCameraPositionList : public csCameraPositionListHelper
+{
+public:
+  SCF_DECLARE_IBASE;
+
+  /// constructor
+  csCameraPositionList ();
+  /// New camera position.
+  virtual iCameraPosition* NewCameraPosition (const char* name);
+
+  class CameraPositionList : public iCameraPositionList
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csCameraPositionList);
+    virtual iCameraPosition* NewCameraPosition (const char* name);
+    virtual int GetCount () const;
+    virtual iCameraPosition *Get (int n) const;
+    virtual int Add (iCameraPosition *obj);
+    virtual bool Remove (iCameraPosition *obj);
+    virtual bool Remove (int n);
+    virtual void RemoveAll ();
+    virtual int Find (iCameraPosition *obj) const;
+    virtual iCameraPosition *FindByName (const char *Name) const;
+  } scfiCameraPositionList;
+};
+
+/**
+ * A list of meshes for the engine.
+ */
+class csEngineMeshList : public csMeshList
+{
+public:
+  virtual ~csEngineMeshList ();
+  virtual bool FreeItem (csSome Item);
+};
+
+/**
+ * Object which implements iConfig interface on behalf of csEngine.
+ * This class is used as an embedded SCF object within csEngine.  Typically,
+ * this class would be declared as an inner class of csEngine, but the NextStep
+ * compiler was unable to grok that usage after csObject (from which csEngine
+ * inherits) was changed so that it inherits from iObject.  Somehow, the
+ * compiler was getting confused by the QueryInterface(), IncRef(), and
+ * DecRef() methods declared here as well as in iEngine and csObject (both of
+ * which csEngine inherits from).  Making csEngineConfig stand-alone works
+ * around the problem.
+ */
+struct csEngineConfig : public iConfig
+{
+  SCF_DECLARE_EMBEDDED_IBASE (csEngine);
+  virtual bool GetOptionDescription (int idx, csOptionDescription *option);
+  virtual bool SetOption (int id, csVariant* value);
+  virtual bool GetOption (int id, csVariant* value);
+};
+
+/**
+ * The 3D engine.
+ * This class manages all components which comprise a 3D world including
+ * sectors, polygons, curves, mesh objects, etc.
+ */
+class csEngine : public iEngine
+{
+public:
+  /**
+   * This is the Virtual File System object where all the files
+   * used by the engine live. Textures, models, data, everything -
+   * reside on this virtual disk volume. You should avoid using
+   * the standard file functions (such as fopen(), fread() and so on)
+   * since they are highly system-dependent (for example, DOS uses
+   * '\' as path separator, Mac uses ':' and Unix uses '/').
+   */
+  iVFS *VFS;
+
+  /**
+   * Pointer to an optional reporter that will be used for notification
+   * and warning messages.
+   */
+  iReporter* Reporter;
+
+  /**
+   * This is a vector which holds objects of type 'csCleanable'.
+   * They will be destroyed when the engine is destroyed. That's
+   * the only special thing. This is useful for holding memory
+   * which you allocate locally in a function but you want
+   * to reuse accross function invocations. There is no general
+   * way to make sure that the memory will be freed it only exists
+   * as a static pointer in your function code. Adding a class
+   * encapsulating that memory to this array will ensure that the
+   * memory is removed once the engine is destroyed.
+   */
+  csObjVector cleanup;
+
+  /**
+   * List of sectors in the engine. This vector contains
+   * objects of type iSector*. Use CreateSector()
+   * to add sectors to the engine.
+   */
+  csSectorList sectors;
+
+  /**
+   * List of all collections in the engine. This vector contains objects
+   * of type iCollection*.
+   */
+  csCollectionList collections;
+
+  /**
+   * List of mesh object factories. This vector contains objects of
+   * type csMeshFactoryWrapper*.
+   */
+  csMeshFactoryList mesh_factories;
+
+  /**
+   * List of all meshes in the engine. This vector contains objects
+   * of type csMeshWrapper*. Use RemoveMesh() to remove meshes from this
+   * list. This function will take care of correctly removing the meshes
+   * from all sectors as well. Note that after you add a mesh to the list
+   * you still need to add it to all sectors that you want it to be visible in.
+   */
+  csEngineMeshList meshes;
+
+  /**
+   * The list of all camera position objects.
+   */
+  csCameraPositionList camera_positions;
+
+  /// Remember dimensions of display.
+  static int frame_width, frame_height;
+  /// Remember iObjectRegistry.
+  static iObjectRegistry* object_reg;
+  /// The shared engine instance.
+  static csEngine* current_engine;
+  /// The shared engine instance.
+  static iEngine* current_iengine;
+  /// Need to render using newradiosity?
+  static bool use_new_radiosity;
+  /// An object pool for 2D polygons used by the rendering process.
+  csPoly2DPool* render_pol2d_pool;
+  /// An object pool for lightpatches.
+  csLightPatchPool* lightpatch_pool;
+  /// The 3D driver
+  iGraphics3D* G3D;
+  /// The 2D driver
+  iGraphics2D* G2D;
+  /// The graphics loader
+  iImageIO* ImageLoader;
+  /// The fog mode this G3D implements
+  G3D_FOGMETHOD fogmethod;
+  /// Does the 3D driver require power-of-two lightmaps?
+  bool NeedPO2Maps;
+  /// Maximum texture aspect ratio
+  int MaxAspectRatio;
+  /// A pointer to the current region.
+  iRegion* region;
+  /// The list of all regions currently loaded.
+  csRegionList regions;
+
+  /// The list of all named render priorities.
+  csVector render_priorities;
+  /// Sorting flags for the render priorities.
+  CS_DECLARE_GROWING_ARRAY (render_priority_sortflags, int);
+  /**
+   * The engine knows about the following render priorities and keeps
+   * them here:
+   * <ul>
+   * <li>"sky": usually rendered using ZFILL or ZNONE
+   * <li>"wall": usually rendered using ZFILL
+   * <li>"object": usually rendered using ZUSE
+   * <li>"alpha": usually rendered using ZTEST
+   * </ul>
+   */
+  long render_priority_sky;
+  long render_priority_wall;
+  long render_priority_object;
+  long render_priority_alpha;
+
+  /// Option variable: force lightmap recalculation?
+  static int lightcache_mode;
+  /// Option variable: quality for lightmap calculation.
+  static int lightmap_quality;
+  /// Option variable: force visibility recalculation?
+  static bool do_force_revis;
+  /// Option variable: radiosity debugging (step by step)?
+  static bool do_rad_debug;
+
+private:
+  /// Texture and color information objects.
+  csTextureList* textures;
+  /// Material objects.
+  csMaterialList* materials;
+  /// Linked list of dynamic lights.
+  csDynLight* first_dyn_lights;
+  /// List of halos (csHaloInformation).
+  csHaloArray halos;
+  /// Debugging: maximum number of polygons to process in one frame.
+  static int max_process_polygons;
+  /// Current number of processed polygons.
+  static int cur_process_polygons;
+
+  /// Current engine mode (one of CS_ENGINE_... flags).
+  int engine_mode;
+
+  /// Pointer to radiosity system if we are in step-by-step radiosity mode.
+  csRadiosity* rad_debug;
+
+  /// Optional c-buffer used for rendering.
+  csCBuffer* c_buffer;
+
+  /// C-buffer cube used for lighting.
+  csCBufferCube* cbufcube;
+
+  /// Use PVS.
+  bool use_pvs;
+
+  /**
+   * Use PVS only. If this flag is true (and use_pvs == true)
+   * then no other culling mechanisms will be used.
+   */
+  bool use_pvs_only;
+
+  /**
+   * Freeze the PVS.
+   * If this flag is true then the PVS will be 'frozen'.
+   * The freeze_pvs_pos will be used as the fixed position
+   * to calculate the PVS from.
+   */
+  bool freeze_pvs;
+  /// Frozen PVS position.
+  csVector3 freeze_pvs_pos;
+
+  /// Clear the Z-buffer every frame.
+  bool clear_zbuf;
+
+  /**
+   * If this nextframe_pending is not 0 then a call of NextFrame
+   * has happened. As soon as some object is visible (DrawTest() returns
+   * true) we will really call NextFrame() if its locally remembered
+   * last-anim value is different from this one. This should improve
+   * global speed of the engine as this means that invisible particle
+   * systems will now not be updated anymore until they are really visible.
+   */
+  csTicks nextframe_pending;
+
+  /// Store virtual clock to speed up time queries.
+  iVirtualClock* virtual_clock;
+
+private:
+  /**
+   * Resolve the engine mode if it is CS_ENGINE_AUTODETECT.
+   */
+  void ResolveEngineMode ();
+
+  /**
+   * Setup for starting a Draw or DrawFunc.
+   */
+  void StartDraw (iCamera* c, iClipper2D* view, csRenderView& rview);
+
+  /**
+   * Controll animation and delete meshes that want to die.
+   */
+  void ControlMeshes ();
+
+  /**
+   * Split a name into optional 'region/name' format.
+   * This function returns the pointer to the real name of the object.
+   * The 'region' variable will contain the region is one is given.
+   * If a region was given but none could be found this function returns
+   * NULL (this is an error).<br>
+   * If '*' was given as a region name then all regions are searched EVEN if
+   * the the FindXxx() routine is called for a specific region only. i.e.
+   * this forces the search to be global. In this case 'global' will be set
+   * to true.
+   */
+  char* SplitRegionName (const char* name, iRegion*& region, bool& global);
+
+  /**
+   * The following variable is only set if the engine had to create its
+   * own cache manager. In that case the engine is also responsible
+   * for cleaning this up.
+   */
+  iCacheManager* cache_mgr;
+
+public:
+  /**
+   * The current camera for drawing the world.
+   */
+  iCamera* current_camera;
+
+  /**
+   * The top-level clipper we are currently using for drawing.
+   */
+  iClipper2D* top_clipper;
+
+public:
+  /**
+   * Initialize an empty engine.  The only thing that is valid just after
+   * creating the engine is the configurator object which you can use to
+   * configure the engine before continuing (see GetEngineConfig()).
+   */
+  csEngine (iBase *iParent);
+
+  /**
+   * Delete the engine and all entities it contains.  All objects added to this
+   * engine by the user (like Things, Sectors, ...) will be deleted as well.
+   * If you don't want this then you should unlink them manually before
+   * destroying the engine.
+   */
+  virtual ~csEngine ();
+
+  /**
+   * Report a notification message.
+   */
+  void Report (const char* description, ...) CS_GNUC_PRINTF (2, 3);
+
+  /**
+   * Report a warning.
+   */
+  void Warn (const char* description, ...) CS_GNUC_PRINTF (2, 3);
+
+  /**
+   * Report a bug.
+   */
+  void ReportBug (const char* description, ...) CS_GNUC_PRINTF (2, 3);
+
+  /**
+   * Check consistency of the loaded elements which comprise the world.
+   * Currently this function only checks if polygons have three or more
+   * vertices and if the vertices are coplanar (if more than three).  This
+   * function prints out warnings for all found errors.  Returns true if
+   * everything is in order.
+   */
+  bool CheckConsistency ();
+
+  /**
+   * Prepare the textures. It will initialise all loaded textures
+   * for the texture manager. (Normally you shouldn't call this function
+   * directly, because it will be called by Prepare() for you.
+   * This function will also prepare all loaded materials after preparing
+   * the textures.
+   */
+  virtual void PrepareTextures ();
+
+  /**
+   * Calls UpdateMove for all meshes to initialise bsp bounding boxes.
+   * Call this after creating a BSP tree. csEngine::Prepare() will call
+   * this function automatically so you normally don't have to call it.
+   */
+  virtual void PrepareMeshes ();
+
+  /**
+   * Calculate all lighting information. Normally you shouldn't call
+   * this function directly, because it will be called by Prepare().
+   * If the optional 'region' parameter is given then only lights will
+   * be recalculated for the given region.
+   */
+  virtual void ShineLights (iRegion* region = NULL,
+  	iProgressMeter* meter = NULL);
+
+  /// Query the iObject for the engine.
+  virtual iObject *QueryObject();
+  /// Query the csObject for the engine.
+  inline csObject *QueryCsObject () { return &scfiObject; }
+
+  /**
+   * Prepare the engine. This function must be called after
+   * you loaded/created the world. It will prepare all lightmaps
+   * for use and also free all images that were loaded for
+   * the texture manager (the texture manager should have them
+   * locally now). The optional progress meter will be used to
+   * report progress.
+   */
+  virtual bool Prepare (iProgressMeter* meter = NULL);
+
+  /**
+   * Set the maximum number of polygons to process in
+   * one frame. This is mainly useful for debugging.
+   */
+  static void SetMaxProcessPolygons (int m) { max_process_polygons = m; }
+
+  /**
+   * Get the maximum number of polygons to process in one frame.
+   */
+  static int GetMaxProcessPolygons () { return max_process_polygons; }
+
+  /**
+   * Indicate that we will process another polygon. Returns false
+   * if we need to stop.
+   */
+  static bool ProcessPolygon ()
+  {
+    if (cur_process_polygons > max_process_polygons) return false;
+    cur_process_polygons++;
+    return true;
+  }
+
+  /**
+   * Return true if we are processing the last polygon.
+   */
+  static bool ProcessLastPolygon ()
+  {
+    return cur_process_polygons >= max_process_polygons;
+  }
+
+  /**
+   * Get the pointer to the radiosity object (used with step-by-step
+   * debugging).
+   */
+  csRadiosity* GetRadiosity () const { return rad_debug; }
+
+  /**
+   * Invalidate all lightmaps. This can be called after doing
+   * a significant change on the static lightmaps (i.e. after doing
+   * a radiosity debug function).
+   */
+  void InvalidateLightmaps ();
+
+  /**
+   * Set the desired engine mode.
+   * One of the CS_ENGINE_... flags. Default is CS_ENGINE_AUTODETECT.
+   * If you select CS_ENGINE_AUTODETECT then the mode will be
+   * auto-detected (depending on level and/or hardware capabilities)
+   * the first time csEngine::Draw() is called.
+   */
+  virtual void SetEngineMode (int mode)
+  {
+    engine_mode = mode;
+  }
+
+  /**
+   * Get the current engine mode.
+   * If called between SetEngineMode() and the first Draw() it is
+   * possible that this mode will still be CS_ENGINE_AUTODETECT.
+   */
+  virtual int GetEngineMode () const { return engine_mode; }
+
+  virtual void SetClearZBuf (bool yesno)
+  {
+    clear_zbuf = yesno;
+  }
+
+  virtual bool GetClearZBuf () const { return clear_zbuf; }
+
+  /**
+   * Get the required flags for 3D->BeginDraw() which should be called
+   * from the application. These flags must be or-ed with optional other
+   * flags that the application might be interested in.
+   */
+  virtual int GetBeginDrawFlags () const
+  {
+    if (clear_zbuf || engine_mode == CS_ENGINE_ZBUFFER)
+      return CSDRAW_CLEARZBUFFER;
+    else
+      return 0;
+  }
+
+  /**
+   * Get the last animation time.
+   */
+  csTicks GetLastAnimationTime () const { return nextframe_pending; }
+
+  /**
+   * Initialize the culler.
+   */
+  void InitCuller ();
+
+  /**
+   * Return c-buffer (or NULL if not used).
+   */
+  csCBuffer* GetCBuffer () const { return c_buffer; }
+
+  /**
+   * Return cbuffer cube.
+   */
+  csCBufferCube* GetCBufCube () const { return cbufcube; }
+
+  /**
+   * Enable PVS.
+   */
+  void EnablePVS () { use_pvs = true; use_pvs_only = false; }
+
+  /**
+   * Disable PVS.
+   */
+  void DisablePVS () { use_pvs = false; }
+
+  /**
+   * Is PVS enabled?
+   */
+  virtual bool IsPVS () const { return use_pvs; }
+
+  /**
+   * Use only PVS for culling. This flag only makes sense when
+   * PVS is enabled.
+   */
+  void EnablePVSOnly () { use_pvs_only = true; }
+
+  /**
+   * Don't use only PVS for culling.
+   */
+  void DisablePVSOnly () { use_pvs_only = false; }
+
+  /**
+   * Is PVS only enabled?
+   */
+  bool IsPVSOnly () { return use_pvs_only; }
+
+  /**
+   * Freeze the PVS for some position.
+   */
+  void FreezePVS (const csVector3& pos) { freeze_pvs = true; freeze_pvs_pos = pos; }
+
+  /**
+   * Unfreeze the PVS.
+   */
+  void UnfreezePVS () { freeze_pvs = false; }
+
+  /**
+   * Is the PVS frozen?
+   */
+  bool IsPVSFrozen () { return freeze_pvs; }
+
+  /**
+   * Return the frozen position for the PVS.
+   */
+  const csVector3& GetFrozenPosition () const { return freeze_pvs_pos; }
+
+  /**
+   * Set the mode for the lighting cache (combination of CS_ENGINE_CACHE_???).
+   * Default is CS_ENGINE_CACHE_READ.
+   */
+  virtual void SetLightingCacheMode (int mode) { lightcache_mode = mode; }
+  /// Get the mode for the lighting cache.
+  virtual int GetLightingCacheMode () { return lightcache_mode; }
+
+  /// Return current lightmap cell size
+  virtual int GetLightmapCellSize () const;
+  /// Set lightmap cell size
+  virtual void SetLightmapCellSize (int Size);
+
+  /**
+   * Read configuration file (using the system driver) for all engine
+   * specific values. This function is called by Initialize() so you
+   * normally do not need to call it yourselves.
+   */
+  void ReadConfig (iConfigFile*);
+
+  /**
+   * Prepare for creation of a world. This function is called
+   * by Initialize() so you normally do not need to call it
+   * yourselves.
+   */
+  void StartEngine ();
+
+  /**
+   * Return the object managing all loaded textures.
+   */
+  csTextureList* GetTextures () const { return textures; }
+
+  /**
+   * Return the object managing all loaded materials.
+   */
+  csMaterialList* GetMaterials () const { return materials; }
+
+  /**
+   * Create a base material.
+   */
+  virtual iMaterial* CreateBaseMaterial (iTextureWrapper* txt);
+  virtual iMaterial* CreateBaseMaterial (iTextureWrapper* txt,
+  	int num_layers, iTextureWrapper** wrappers, csTextureLayer* layers);
+
+  virtual iMaterialList* GetMaterialList () const;
+  virtual iTextureList* GetTextureList () const;
+  virtual iRegionList* GetRegions ();
+
+  /**
+   * Conveniance function to create the thing containing the
+   * convex outline of a sector. The thing will be empty but
+   * it will have CS_ZBUF_FILL set. This version creates a mesh wrapper.
+   */
+  iMeshWrapper* CreateSectorWallsMesh (csSector* sector, const char* name);
+
+  /**
+   * Conveniance function to create the thing containing the
+   * convex outline of a sector. The thing will be empty but
+   * it will have CS_ZBUF_FILL set. This version creates a mesh wrapper.
+   */
+  virtual iMeshWrapper* CreateSectorWallsMesh (iSector* sector,
+      const char* name);
+
+  /**
+   * Add a dynamic light to the engine.
+   */
+  void AddDynLight (csDynLight* dyn);
+
+  /**
+   * Remove a dynamic light from the engine.
+   */
+  void RemoveDynLight (csDynLight* dyn);
+
+  /**
+   * Return the first dynamic light in this engine.
+   */
+  csDynLight* GetFirstDynLight () const { return first_dyn_lights; }
+
+  /**
+   * This routine returns all lights which might affect an object
+   * at some position according to the following flags:<br>
+   * <ul>
+   * <li>CS_NLIGHT_SHADOWS: detect shadows and don't return lights for
+   *     which the object is shadowed (not implemented yet).
+   * <li>CS_NLIGHT_STATIC: return static lights.
+   * <li>CS_NLIGHT_DYNAMIC: return dynamic lights.
+   * <li>CS_NLIGHT_NEARBYSECTORS: Also check lights in nearby sectors
+   *     (not implemented yet).
+   * </ul><br>
+   * It will only return as many lights as the size that you specified
+   * for the light array. The returned lights are not guaranteed to be sorted
+   * but they are guaranteed to be the specified number of lights closest to
+   * the given position.<br>
+   * This function returns the actual number of lights added to the 'lights'
+   * array.
+   */
+  virtual int GetNearbyLights (iSector* sector, const csVector3& pos,
+  	uint32 flags, iLight** lights, int max_num_lights);
+
+  /**
+   * This routine returns an iterator to iterate over
+   * all nearby sectors.
+   * Delete the iterator with 'DecRef()' when ready.
+   */
+  virtual iSectorIterator* GetNearbySectors (iSector* sector,
+  	const csVector3& pos, float radius);
+
+  /**
+   * This routine returns an iterator to iterate over
+   * all objects of a given type that are within a radius
+   * of a given position. You can use SCF_QUERY_INTERFACE to get
+   * any interface from the returned objects. <p>
+   * Delete the iterator with 'DecRef()' when ready.
+   */
+  virtual iObjectIterator* GetNearbyObjects (iSector* sector,
+    const csVector3& pos, float radius);
+
+  virtual bool RemoveObject (iBase* object);
+
+  /**
+   * Add a halo attached to given light to the engine.
+   */
+  void AddHalo (csLight* Light);
+
+  /**
+   * Remove halo attached to given light from the engine.
+   */
+  void RemoveHalo (csLight* Light);
+
+  /**
+   * Draw the 3D world given a camera and a clipper. Note that
+   * in order to be able to draw using the given 3D driver
+   * all textures must have been registered to that driver (using
+   * Prepare()). Note that you need to call Prepare() again if
+   * you switch to another 3D driver.
+   */
+  virtual void Draw (iCamera* c, iClipper2D* clipper);
+
+  /**
+   * This function is similar to Draw. It will do all the stuff
+   * that Draw would do except for one important thing: it will
+   * not draw anything. Instead it will call a callback function for
+   * every entity that it was planning to draw. This allows you to show
+   * or draw debugging information (2D egdes for example).
+   */
+  virtual void DrawFunc (iCamera* c, iClipper2D* clipper,
+    iDrawFuncCallback* callback);
+
+  /**
+   * Create an iterator to iterate over all static lights of the engine.
+   */
+  csLightIt* NewLightIterator (iRegion* region = NULL)
+  {
+    csLightIt* it;
+    it = new csLightIt (this, region);
+    return it;
+  }
+
+  /**
+   * Add an object to the current region.
+   */
+  void AddToCurrentRegion (csObject* obj);
+
+  /// Register a new render priority.
+  virtual void RegisterRenderPriority (const char* name, long priority,
+  	int rendsort = CS_RENDPRI_NONE);
+  /// Get a render priority by name.
+  virtual long GetRenderPriority (const char* name) const;
+  /// Get the render priority sorting flag.
+  virtual int GetRenderPrioritySorting (const char* name) const;
+  /// Get the render priority sorting flag.
+  virtual int GetRenderPrioritySorting (long priority) const;
+  /// Get the render priority for sky objects (attached to 'sky' name).
+  virtual long GetSkyRenderPriority () const { return render_priority_sky; }
+  /// Get the render priority for wall objects (attached to 'wall' name).
+  virtual long GetWallRenderPriority () const { return render_priority_wall; }
+  /// Get the render priority for general objects (attached to 'object' name).
+  virtual long GetObjectRenderPriority () const { return render_priority_object; }
+  /// Get the render priority for alpha objects (attached to 'alpha' name).
+  virtual long GetAlphaRenderPriority () const { return render_priority_alpha; }
+  /// Clear all render priorities.
+  virtual void ClearRenderPriorities ();
+
+  /// @@@ Temporary until things move to their own mesh plugin system.
+  csThingObjectType* thing_type;
+  virtual iMeshObjectType* GetThingType () const
+  {
+    return (iMeshObjectType*)thing_type;
+  }
+
+  SCF_DECLARE_IBASE;
+
+  //------------------ iComponent interface implementation --------------------
+
+  /**
+   * Initialize the engine. This is automatically called by system driver
+   * at startup so that plugin can do basic initialization stuff, register
+   * with the system driver and so on.
+   */
+  virtual bool Initialize (iObjectRegistry* object_reg);
+
+  /// We need to handle some events
+  virtual bool HandleEvent (iEvent &Event);
+
+  struct eiComponent : public iComponent
+  {
+    SCF_DECLARE_EMBEDDED_IBASE(csEngine);
+    virtual bool Initialize (iObjectRegistry* p)
+    { return scfParent->Initialize(p); }
+  } scfiComponent;
+  struct EventHandler : public iEventHandler
+  {
+  private:
+    csEngine* parent;
+  public:
+    SCF_DECLARE_IBASE;
+    EventHandler (csEngine* parent)
+    {
+      SCF_CONSTRUCT_IBASE (NULL);
+      EventHandler::parent = parent;
+    }
+    virtual bool HandleEvent (iEvent& e) { return parent->HandleEvent(e); }
+  } * scfiEventHandler;
+
+  //--------------------- iEngine interface implementation --------------------
+
+  virtual csEngine *GetCsEngine () { return this; };
+
+  /**
+   * Query the format to load textures
+   * (usually this depends on texture manager).
+   */
+  virtual int GetTextureFormat () const;
+
+  /**
+   * Create or select a new region (name can be NULL for the default main
+   * region). All new objects will be marked as belonging to this region.
+   */
+  virtual void SelectRegion (const char* iName);
+
+  /**
+   * Create or select a new region (region can be NULL for the default main
+   * region). All new objects will be marked as belonging to this region.
+   */
+  virtual void SelectRegion (iRegion* region);
+
+  /**
+   * Get a reference to the current region (or NULL if the default main
+   * region is selected).
+   */
+  virtual iRegion* GetCurrentRegion () const;
+
+  /// Clear the entire engine.
+  virtual void DeleteAll ();
+
+  /// Register a texture to be loaded during Prepare()
+  virtual iTextureWrapper* CreateTexture (const char *iName, const char *iFileName,
+    csColor *iTransp, int iFlags);
+  /// Register a material to be loaded during Prepare()
+  virtual iMaterialWrapper* CreateMaterial (const char *iName, iTextureWrapper* texture);
+
+  /// Create a empty sector with given name.
+  virtual iSector *CreateSector (const char *iName);
+
+  /// Return the list of sectors
+  virtual iSectorList *GetSectors ()
+    { return &sectors.scfiSectorList; }
+  /// Return the list of mesh factories
+  virtual iMeshFactoryList *GetMeshFactories ()
+    { return &mesh_factories.scfiMeshFactoryList; }
+  /// Return the list of meshes
+  virtual iMeshList *GetMeshes ()
+    { return &meshes.scfiMeshList; }
+  /// Return the list of collections
+  virtual iCollectionList *GetCollections ()
+    { return &collections.scfiCollectionList; }
+  /// Return the list of camera positions.
+  virtual iCameraPositionList *GetCameraPositions ()
+    { return &camera_positions.scfiCameraPositionList; }
+
+  /// Create a new camera.
+  virtual iCamera* CreateCamera ();
+
+  /// Create a static/pseudo-dynamic light.
+  virtual iStatLight* CreateLight (const char* name,
+  	const csVector3& pos, float radius,
+  	const csColor& color, bool pseudoDyn);
+  /// Find a static/pseudo-dynamic light by ID.
+  virtual iStatLight* FindLight (unsigned long light_id) const;
+  /// Find a static/pseudo-dynamic light by name.
+  virtual iStatLight* FindLight (const char *Name, bool RegionOnly = false)
+    const;
+  /// Create a dynamic light.
+  virtual iDynLight* CreateDynLight (const csVector3& pos, float radius,
+  	const csColor& color);
+  /// Remove a dynamic light.
+  virtual void RemoveDynLight (iDynLight*);
+
+  /// Create a mesh factory wrapper from a mesh plugin
+  virtual iMeshFactoryWrapper* CreateMeshFactory (const char* classId,
+  	const char* name);
+  /// Create a mesh factory wrapper for an existing mesh factory
+  virtual iMeshFactoryWrapper* CreateMeshFactory (iMeshObjectFactory *,
+  	const char* name);
+  /// Create an uninitialized mesh factory wrapper
+  virtual iMeshFactoryWrapper* CreateMeshFactory (const char* name);
+  virtual iLoaderContext* CreateLoaderContext (iRegion* region = NULL);
+  /// Load mesh factory.
+  virtual iMeshFactoryWrapper* LoadMeshFactory (
+  	const char* name, const char* loaderClassId,
+	iDataBuffer* input);
+
+  /// Create a mesh wrapper from a mesh factory wrapper
+  virtual iMeshWrapper* CreateMeshWrapper (iMeshFactoryWrapper* factory,
+  	const char* name, iSector* sector = NULL,
+	const csVector3& pos = csVector3(0, 0, 0));
+  /// Create a mesh wrapper for an existing mesh object
+  virtual iMeshWrapper* CreateMeshWrapper (iMeshObject*,
+  	const char* name, iSector* sector = NULL,
+	const csVector3& pos = csVector3(0, 0, 0));
+  /// Create an uninitialized mesh wrapper
+  virtual iMeshWrapper* CreateMeshWrapper (const char* name);
+  /// Load mesh object.
+  virtual iMeshWrapper* LoadMeshWrapper (
+  	const char* name, const char* loaderClassId,
+	iDataBuffer* input, iSector* sector, const csVector3& pos);
+
+  virtual iClipper2D* GetTopLevelClipper () const;
+
+  /// Set the amount of ambient light
+  virtual void SetAmbientLight (const csColor &c);
+  /// Return the amount of ambient light
+  virtual void GetAmbientLight (csColor &c) const;
+
+  virtual iMaterialWrapper* FindMaterial (const char* name,
+  	iRegion* region = NULL);
+  virtual iTextureWrapper* FindTexture (const char* name,
+  	iRegion* region = NULL);
+  virtual iSector* FindSector (const char* name,
+  	iRegion* region = NULL);
+  virtual iMeshWrapper* FindMeshObject (const char* name,
+  	iRegion* region = NULL);
+  virtual iMeshFactoryWrapper* FindMeshFactory (const char* name,
+  	iRegion* region = NULL);
+  virtual iCameraPosition* FindCameraPosition (const char* name,
+  	iRegion* region = NULL);
+  virtual iCollection* FindCollection (const char* name,
+  	iRegion* region = NULL);
+
+  //----------------------- iCacheManager implementation ---------------------
+
+  virtual void SetCacheManager (iCacheManager* cache_mgr);
+  virtual iCacheManager* GetCacheManager ();
+
+  //--------------------- iConfig interface implementation -------------------
+
+  csEngineConfig scfiConfig;
+
+  //----------------Begin-Multi-Context-Support-------------------------------
+
+  /// Point engine to rendering context
+  virtual void SetContext (iGraphics3D* g3d);
+  /// Return the current drawing context
+  virtual iGraphics3D *GetContext () const;
+
+private:
+  /// Resizes frame width and height dependent data members
+  void Resize ();
+  /// Flag set when window requires resizing.
+  bool resize;
+  /**
+   * Private class which keeps state information about the engine specific to
+   * each context.
+   */
+
+  class csEngineState
+  {
+  public:
+    csEngine *engine;
+    bool resize;
+    iGraphics2D *G2D;
+    iGraphics3D *G3D;
+    csCBuffer* c_buffer;
+    csCBufferCube* cbufcube;
+    /// Creates an engine state by copying the relevant data members
+    csEngineState (csEngine *this_engine);
+
+    /// Destroys buffers and trees
+    virtual ~csEngineState ();
+
+    /// Swaps state into engine and deals with resizing issues.
+    void Activate ();
+  };
+
+  friend class csEngineState;
+
+  class csEngineStateVector : public csVector
+  {
+  public:
+     // Constructor
+    csEngineStateVector () : csVector (8, 8) {}
+    // Destructor
+    virtual ~csEngineStateVector () { DeleteAll (); }
+    // Free an item from array
+    virtual bool FreeItem (csSome Item)
+    { delete (csEngineState *)Item; return true; }
+    // Find a state by referenced g2d
+    virtual int CompareKey (csSome Item, csConstSome Key, int /*Mode*/) const
+    { return ((csEngineState *)Item)->G3D == (iGraphics3D *)Key ? 0 : -1; }
+    // Get engine state according to index
+    inline csEngineState *Get (int n) const
+    { return (csEngineState *)csVector::Get (n); }
+
+    // Mark engine state to be resized
+    void Resize (iGraphics2D *g2d);
+
+    // Dispose of engine state dependent on g2d
+    void Close (iGraphics2D *g2d);
+  };
+
+  csEngineStateVector *engine_states;
+
+  //------------End-Multi-Context-Support-------------------------------------
+
+  /**
+   * This object is used in the engine as an embedded iObject interface.
+   */
+  class iObjectInterface : public csObject
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csEngine);
+  } scfiObject;
+};
+
+#endif // __CS_ENGINE_H__
diff --git a/client/client94/crystalspace/include/csengine/halo.h b/client/client94/crystalspace/include/csengine/halo.h
new file mode 100644
index 0000000..8b79800
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/halo.h
@@ -0,0 +1,271 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+    Copyright (C) 2001 by W.C.A. Wijngaards
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_HALO_H__
+#define __CS_HALO_H__
+
+#include "csgeom/math3d.h"
+#include "csengine/light.h"
+#include "ivideo/halo.h"
+#include "iengine/halo.h"
+
+class csEngine;
+struct iMaterialWrapper;
+
+/**
+ * This is the basic class for all types of halos.
+ * The csLight class contains a pointer to a object derived from this class.
+ */
+class csHalo : public iBaseHalo
+{
+  /// the current intensity of the attached halo; if >0 halo is in halo queue.
+  float Intensity;
+
+public:
+  /// The type of halo
+  csHaloType Type;
+
+  /// Constructor
+  csHalo (csHaloType iType);
+  /// Destructor
+  virtual ~csHalo ();
+
+  /// Generate the alphamap for this halo of size Size x Size
+  virtual unsigned char *Generate (int Size) = 0;
+
+  /// Get halo intensity
+  virtual float GetIntensity () { return Intensity; }
+  /// Set halo intensity
+  virtual void SetIntensity (float iInt) { Intensity = iInt; }
+
+  SCF_DECLARE_IBASE;
+};
+
+/**
+ * This is a halo which resembles a cross.
+ */
+class csCrossHalo : public csHalo
+{
+public:
+  /// Halo intensity factor
+  float IntensityFactor;
+  /// Halo cross-ressemblance factor
+  float CrossFactor;
+
+  /// Create a halo object
+  csCrossHalo (float intensity_factor, float cross_factor);
+
+  /// Generate the alphamap for this halo of size Size x Size
+  virtual unsigned char *Generate (int Size);
+
+  //------------------------ iCrossHalo ------------------------------------
+  SCF_DECLARE_IBASE_EXT (csHalo);
+  struct CrossHalo : public iCrossHalo
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csCrossHalo);
+    virtual void SetIntensityFactor (float i)
+    { scfParent->IntensityFactor = i; }
+    virtual float GetIntensityFactor ()
+    { return scfParent->IntensityFactor; }
+    virtual void SetCrossFactor (float i)
+    { scfParent->CrossFactor = i; }
+    virtual float GetCrossFactor ()
+    { return scfParent->CrossFactor; }
+  } scfiCrossHalo;
+  friend struct CrossHalo;
+};
+
+/** This halo has a center with a number of spokes */
+class csNovaHalo : public csHalo
+{
+public:
+  /// Random seed for generating halo
+  int Seed;
+  /// Number of halo spokes
+  int NumSpokes;
+  /// The "roundness" factor
+  float Roundness;
+
+  /// Create a halo object
+  csNovaHalo (int seed, int num_spokes, float roundness);
+
+  /// Generate the alphamap for this halo of size Size x Size
+  virtual unsigned char *Generate (int Size);
+
+  //------------------------ iNovaHalo ------------------------------------
+  SCF_DECLARE_IBASE_EXT (csHalo);
+  struct NovaHalo : public iNovaHalo
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csNovaHalo);
+    virtual void SetRandomSeed (int s)
+    { scfParent->Seed = s; }
+    virtual int GetRandomSeed ()
+    { return scfParent->Seed; }
+    virtual void SetSpokeCount (int s)
+    { scfParent->NumSpokes = s; }
+    virtual int GetSpokeCount ()
+    { return scfParent->NumSpokes; }
+    virtual void SetRoundnessFactor (float r)
+    { scfParent->Roundness = r; }
+    virtual float GetRoundnessFactor ()
+    { return scfParent->Roundness; }
+  } scfiNovaHalo;
+  friend struct NovaHalo;
+};
+
+
+/** structure used to keep flare component information */
+struct csFlareComponent {
+  /// position, (0.= at light, 1.=center)
+  float position;
+  /// width and height (1.0 gives size of a normal halo)
+  float width, height;
+  /// visual image of component
+  iMaterialWrapper *image;
+  /// mixmode for drawing
+  uint mixmode;
+  /// next component to draw
+  csFlareComponent *next;
+};
+
+/**
+ * This halo is used for (solar)flares
+ */
+class csFlareHalo : public csHalo
+{
+private:
+  /// list of the flare components. in drawing order
+  csFlareComponent *components;
+  /// last flare component to make adding efficient
+  csFlareComponent *last;
+public:
+  /// create an (empty) flare
+  csFlareHalo();
+  ///
+  ~csFlareHalo();
+  /**
+   * Add a visual component to the flare.
+   * give position, size, image and mixmode.
+   * The component is added at the end of the list - to be displayed last.
+   */
+  void AddComponent(float pos, float w, float h, uint mode,
+    iMaterialWrapper *image);
+  /// Get the list of component
+  csFlareComponent *GetComponents() const {return components;}
+  /**
+   * Generate this halo's alpha map.
+   * Not used for this halo (returns NULL) since the halo consists of
+   * multiple images.
+   */
+  virtual unsigned char *Generate (int Size);
+
+  //------------------------ iFlareHalo ------------------------------------
+  SCF_DECLARE_IBASE_EXT (csHalo);
+  struct FlareHalo : public iFlareHalo
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csFlareHalo);
+    virtual void AddComponent (float pos, float w, float h, uint mode,
+      iMaterialWrapper *image)
+    {
+      scfParent->AddComponent (pos, w, h, mode, image);
+    }
+  } scfiFlareHalo;
+  friend struct FlareHalo;
+};
+
+/**
+ * This is used to keep track of halos.<p>
+ * When the engine detects that a light that is marked to have an halo
+ * is directly visible, an object of this type is created and put into
+ * a global queue maintained within the engine object. The light starts
+ * to brighten until it reaches maximal intensity; when the halo becomes
+ * obscured by something or goes out of view the intensity starts to
+ * decrease until it reaches zero; upon this event the halo object is
+ * destroyed and removed from halo queue.
+ */
+class csLightHalo
+{
+public:
+  /// The light this halo is attached to
+  csLight *Light;
+
+  /// Halo handle as returned by 3D rasterizer
+  iHalo *Handle;
+
+  /// Last time we were updated
+  csTicks LastTime;
+
+  /// Create an light halo object
+  csLightHalo (csLight *iLight, iHalo *iHandle);
+
+  /// Destroy the light halo object
+  virtual ~csLightHalo ();
+
+  /**
+   * Process a light halo. The function changes halo brightness depending
+   * whenever the halo is obscured or not and returns "false" if halo has
+   * reached zero intensity and should be removed from halo queue.
+   * The function also actually projects, clips and draws the halo.
+   */
+  virtual bool Process (csTicks ElapsedTime, csEngine const&);
+
+  /**
+   * see if camera position is visible, returns it projected onto screen.
+   * Called by Process.
+   */
+  bool IsVisible(csEngine const& engine, csVector3& v);
+
+  /**
+   * add up elapsed time, and returns new intensity, given the current
+   * halo intensity. Give whether halo is currently visible for fading in
+   * and out. returns true if intensity >0, returns false if intensity <= 0,
+   * when the halo is completely faded out.
+   * Called by Process.
+   */
+  bool ComputeNewIntensity(csTicks ElapsedTime, float& hintensity,
+    bool halo_vis);
+};
+
+/**
+ * This class is used to keep track of visible Flares.
+ * It is a subclass of csLightHalo, and - to the engine - behaves the same.
+ */
+class csLightFlareHalo : public csLightHalo
+{
+  /// size of halos on the screen
+  int halosize;
+  /// the flare description
+  csFlareHalo *flare;
+public:
+  /**
+   * create. pass light, and flareHalo, the halosize is the size that
+   * halos have on the screen - it is used to scale the flare.
+   */
+  csLightFlareHalo(csLight *light, csFlareHalo *halo, int iHaloSize);
+  /// remove
+  virtual ~csLightFlareHalo();
+
+  /// process the halo.
+  virtual bool Process (csTicks elapsed_time, csEngine const& engine);
+  /// process a flare component (clip and draw it).
+  void ProcessFlareComponent(csEngine const& engine, csFlareComponent *comp,
+    csVector2 const& start, csVector2 const& deltapos);
+};
+
+#endif // __CS_HALO_H__
diff --git a/client/client94/crystalspace/include/csengine/lghtmap.h b/client/client94/crystalspace/include/csengine/lghtmap.h
new file mode 100644
index 0000000..f23a99b
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/lghtmap.h
@@ -0,0 +1,259 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_LIGHTMAP_H__
+#define __CS_LIGHTMAP_H__
+
+#include "csutil/scf.h"
+#include "csutil/sarray.h"
+#include "csgfx/rgbpixel.h"
+#include "imesh/thing/lightmap.h"
+
+class csPolyTexture;
+class csThing;
+class csPolygon3D;
+class csCurve;
+class csLight;
+class csEngine;
+class csDelayedLightingInfo;
+class csObject;
+struct iLight;
+struct iCacheManager;
+
+CS_DECLARE_STATIC_ARRAY (csRGBMap, csRGBpixel);
+CS_DECLARE_STATIC_ARRAY (csShadowMapHelper, unsigned char);
+
+class csShadowMap : public csShadowMapHelper
+{
+public:
+  iLight *Light;
+  csShadowMap *next;
+
+  csShadowMap ();
+  virtual ~csShadowMap ();
+  void Alloc (iLight *l, int w, int h);
+  void Copy (const csShadowMap *other);
+};
+
+/**
+ * The static and all dynamic lightmaps for one polygon.
+ */
+class csLightMap : public iLightMap
+{
+  ///
+  friend class csPolyTexture;
+
+private:
+  /**
+   * A color lightmap containing all static lighting information
+   * for the static lights (no pseudo-dynamic lights are here).
+   */
+  csRGBMap static_lm;
+
+  /**
+   * The final lightmap that is going to be used for rendering.
+   * In many cases this is just a copy of static_lm. But it may
+   * contain extra lighting information obtained from all the
+   * pseudo-dynamic shadowmaps and also the true dynamic lights.
+   */
+  csRGBMap real_lm;
+
+  /**
+   * A flag indicating whether the lightmaps needs recalculating
+   * for dynamic lights
+   */
+  bool dyn_dirty;
+
+  /**
+   * Linked list of shadow-maps (for the pseudo-dynamic lights).
+   * These shadowmaps are applied to static_lm to get real_lm.
+   */
+  csShadowMap* first_smap;
+
+  /// Size of the lightmap.
+  long lm_size;
+
+  /// LightMap dims (possibly po2 depending on used 3D driver).
+  int lwidth, lheight;
+  /// Original lightmap dims (non-po2 possibly).
+  int rwidth, rheight;
+
+  /**
+   * Mean lighting value of this lightmap.
+   * (only for static lighting currently).
+   */
+  csRGBpixel mean_color;
+
+  /// The hicolor cache ptr.
+  void *cachedata;
+
+  /// Used when computing lightmaps shared by several polygons
+  csDelayedLightingInfo *delayed_light_info;
+
+#if 0
+  /**
+   * Convert three lightmap tables to the right mixing mode.
+   * This function assumes that mixing mode is one of FAST_Wxx
+   * and will not function correctly if called with NOCOLOR, TRUE_RGB
+   * or FAST_RGB.<br>
+   * This function correctly recognizes a dynamic lightmap which only
+   * contains shadow information and does not do the conversion in that
+   * case.
+   */
+  void ConvertToMixingMode (unsigned char* mr, unsigned char* mg,
+			    unsigned char* mb, int sz);
+#endif
+
+  /**
+   * Calculate the sizes of this lightmap.
+   */
+  void SetSize (int w, int h);
+
+public:
+  /// Option variable: shadow cell size
+  static int lightcell_size;
+  /// Log base 2 of lightcell_size
+  static int lightcell_shift;
+
+  /// Return the width of a lightmap given a texture size.
+  static int CalcLightMapWidth (int w)
+  {
+    return 1 + ((w + lightcell_size - 1) >> lightcell_shift);
+    //return 1 + ((w + lightcell_size) >> lightcell_shift); //@@@ EXP
+  }
+  /// Return the height of a lightmap given a texture size.
+  static int CalcLightMapHeight (int h)
+  {
+    return 1 + ((h + lightcell_size - 1) >> lightcell_shift);
+    //return 1 + ((h + lightcell_size) >> lightcell_shift); //@@@ EXP
+  }
+
+  ///
+  csLightMap ();
+  ///
+  virtual ~csLightMap ();
+
+  /// set the dirty flag for this lightmap
+  void MakeDirtyDynamicLights () { dyn_dirty = true; }
+
+  bool UpdateRealLightMap ();
+
+  ///
+  csRGBMap& GetStaticMap () { return static_lm; }
+  ///
+  csRGBMap& GetRealMap () { return real_lm; }
+
+  /**
+   * Allocate the lightmap. 'w' and 'h' are the size of the
+   * bounding box in lightmap space.
+   * r,g,b is the ambient light color used to initialize the lightmap.
+   */
+  void Alloc (int w, int h, int r, int g, int b);
+
+  /// Copy a lightmap.
+  void CopyLightMap (csLightMap* source);
+
+  /**
+   * Create a ShadowMap for this LightMap.
+   */
+  csShadowMap* NewShadowMap (csLight* light, int w, int h);
+
+  /**
+   * Allocate the static csRGBMap.
+   */
+  void AllocStaticLM (int w, int h);
+
+  /**
+   * Find a ShadowMap for a specific pseudo-dynamic light.
+   */
+  csShadowMap* FindShadowMap (csLight* light);
+
+  /**
+   * Delete a ShadowMap. NOTE!!! This function only works
+   * if the ShadowMap was the LAST CREATED for this LightMap!!!
+   * It is ment for dynamic lights that do not reach the polygon
+   * but this can only be seen after trying.
+   */
+  void DelShadowMap (csShadowMap* plm);
+
+  /**
+   * Read from the cache. Return true if succesful.
+   * 'id' is a global id that is used to identify objects.
+   */
+  bool ReadFromCache (iCacheManager* cache_mgr, int id, int w, int h,
+    csObject* obj, bool isPolygon, csEngine*);
+
+  /**
+   * Cache the lightmaps in the precalculation area.
+   * 'id' is a global id that is used to identify objects.
+   */
+  void Cache (iCacheManager* cache_mgr, int id, csPolygon3D* poly,
+  	csCurve* curve, csEngine*);
+
+  /**
+   * Convert the lightmaps to the correct mixing mode.
+   * This function does nothing unless the mixing mode is
+   * nocolor.<p>
+   *
+   * This function also calculates the mean color of the lightmap.
+   */
+  void ConvertToMixingMode ();
+
+  /**
+   * Convert the lightmaps to a 3D driver dependent size.
+   */
+  void ConvertFor3dDriver (bool requirePO2, int maxAspect = 32767);
+
+  /**
+   * Set the size of one lightmap cell (default = 16).
+   * Do not directly assign to the lightcell_size variable, as
+   * lightmap_shift also has to be updated.
+   */
+  static void SetLightCellSize (int size);
+
+  //------------------------ iLightMap implementation ------------------------
+  SCF_DECLARE_IBASE;
+  ///
+  virtual csRGBpixel *GetMapData ();
+  ///
+  virtual int GetWidth ()
+  { return lwidth; }
+  ///
+  virtual int GetHeight ()
+  { return lheight; }
+  ///
+  virtual int GetRealWidth ()
+  { return rwidth; }
+  ///
+  virtual int GetRealHeight ()
+  { return rheight; }
+  ///
+  virtual void *GetCacheData ()
+  { return cachedata; }
+  ///
+  virtual void SetCacheData (void *d)
+  { cachedata = d; }
+  ///
+  virtual void GetMeanLighting (int &r, int &g, int &b)
+  { r = mean_color.red; g = mean_color.green; b = mean_color.blue; }
+  /// Get size of one lightmap
+  virtual long GetSize ()
+  { return lm_size; }
+};
+
+#endif // __CS_LIGHTMAP_H__
diff --git a/client/client94/crystalspace/include/csengine/light.h b/client/client94/crystalspace/include/csengine/light.h
new file mode 100644
index 0000000..2ea46ca
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/light.h
@@ -0,0 +1,624 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_LIGHT_H__
+#define __CS_LIGHT_H__
+
+#include "csgeom/transfrm.h"
+#include "csutil/csobject.h"
+#include "csutil/cscolor.h"
+#include "csutil/flags.h"
+#include "csutil/csvector.h"
+#include "csutil/nobjvec.h"
+#include "csengine/lview.h"
+#include "iengine/light.h"
+#include "iengine/statlght.h"
+#include "iengine/dynlight.h"
+
+class csLightMap;
+class csDynLight;
+class csLightPatchPool;
+class csHalo;
+class csPolygon3D;
+class csCurve;
+class csSector;
+struct iMeshWrapper;
+
+/**
+ * If CS_LIGHT_THINGSHADOWS is set for a light then things will also
+ * cast shadows. This flag is set by default for static lights and unset
+ * for dynamic lights.
+ */
+#define CS_LIGHT_THINGSHADOWS	0x00000001
+
+/**
+ * If this flag is set, the halo for this light is active and is in the
+ * engine's queue of active halos. When halo become inactive, this flag
+ * is reset.
+ */
+#define CS_LIGHT_ACTIVEHALO	0x80000000
+
+/**
+ * Superclass of all positional lights.
+ * A light subclassing from this has a color, a position
+ * and a radius.<P>
+ *
+ * First some terminology about all the several types of lights
+ * that Crystal Space supports:
+ * <ul>
+ * <li>Static light. This is a normal static light that cannot move
+ *     and cannot change intensity/color. All lighting information from
+ *     all static lights is collected in one static lightmap.
+ * <li>Pseudo-dynamic light. This is a static light that still cannot
+ *     move but the intensity/color can change. The shadow information
+ *     from every pseudo-dynamic light is kept in a seperate shadow-map.
+ *     Shadowing is very accurate with pseudo-dynamic lights since they
+ *     use the same algorithm as static lights.
+ * <li>Dynamic light. This is a light that can move and change
+ *     intensity/color. These lights are the most flexible. All lighting
+ *     information from all dynamic lights is collected in one dynamic
+ *     lightmap (seperate from the pseudo-dynamic shadow-maps).
+ *     Shadows for dynamic lights will be less accurate because things
+ *     will not cast accurate shadows (due to computation speed limitations).
+ * </ul>
+ * Note that static and pseudo-dynamic lights are represented by the
+ * same csStatLight class.
+ */
+class csLight : public csObject
+{
+private:
+  /// ID for this light.
+  unsigned long light_id;
+  /// Last used ID.
+  static unsigned long last_light_id;
+
+protected:
+  /// Home sector of the light.
+  csSector* sector;
+  /// Position of the light.
+  csVector3 center;
+  /// Radius of light.
+  float dist;
+  /// Squared radius of light.
+  float sqdist;
+  /// Inverse radius of light.
+  float inv_dist;
+  /// Color.
+  csColor color;
+  /// The associated halo (if not NULL)
+  csHalo *halo;
+
+  /// Attenuation type
+  int attenuation;
+
+public:
+  /// Set of flags
+  csFlags flags;
+
+public:
+  /// Config value: ambient red value.
+  static int ambient_red;
+  /// Config value: ambient green value.
+  static int ambient_green;
+  /// Config value: ambient blue value.
+  static int ambient_blue;
+
+public:
+  /**
+   * Construct a light at a given position. With
+   * a given radius, a given color, a given name and
+   * type. The light will not have a halo by default.
+   */
+  csLight (float x, float y, float z, float dist,
+  	 float red, float green, float blue);
+
+  /**
+   * Destroy the light. Note that destroying a light
+   * may not have the expected effect. Static lights result
+   * in changes in the lightmaps. Removing them will not automatically
+   * update those lightmaps as that is a time-consuming process.
+   */
+  virtual ~csLight ();
+
+  /// Get the ID of this light.
+  unsigned long GetLightID () { return light_id; }
+
+  /**
+   * Set the current sector for this light.
+   */
+  virtual void SetSector (csSector* sector) { csLight::sector = sector; }
+
+  /**
+   * Get the current sector for this light.
+   */
+  csSector* GetSector () const { return sector; }
+
+  /**
+   * Set the center position.
+   */
+  void SetCenter (const csVector3& v) { center = v; }
+
+  /**
+   * Get the center position.
+   */
+  const csVector3& GetCenter () { return center; }
+
+  /**
+   * Get the radius.
+   */
+  float GetRadius () const { return dist; }
+
+  /**
+   * Get the squared radius.
+   */
+  float GetSquaredRadius () const { return sqdist; }
+
+  /**
+   * Get the inverse radius.
+   */
+  float GetInverseRadius () const { return inv_dist; }
+
+  /**
+   * Set the radius.
+   */
+  void SetRadius (float radius)
+    { dist = radius; sqdist = dist*dist; inv_dist = 1 / dist; }
+
+  /**
+   * Get the light color.
+   */
+  csColor& GetColor () { return color; }
+
+  /**
+   * Set the light color. Note that setting the color
+   * of a light may not always have an immediate visible effect.
+   * Static lights are precalculated into the lightmaps and those
+   * lightmaps are not automatically updated when calling this function
+   * as that is a time consuming process.
+   */
+  virtual void SetColor (const csColor& col) { color = col; }
+
+  /**
+   * Return the associated halo
+   */
+  csHalo *GetHalo () { return halo; }
+
+  /**
+   * Set the halo associated with this light.
+   */
+  void SetHalo (csHalo *Halo);
+
+  /**
+   * Get the light's attenuation type
+   */
+  int GetAttenuation () {return attenuation;}
+
+  /**
+   * Change the light's attenuation type
+   */
+  void SetAttenuation (int a) {attenuation = a;}
+
+  /**
+   * Get the brightness of a light at a given distance.
+   */
+  float GetBrightnessAtDistance (float d);
+
+  //------------------------ iLight interface -----------------------------
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  struct Light : public iLight
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csLight);
+    virtual csLight* GetPrivateObject ();
+    virtual unsigned long GetLightID ();
+    virtual iObject *QueryObject();
+    virtual const csVector3& GetCenter ();
+    virtual void SetCenter (const csVector3& pos);
+    virtual iSector *GetSector ();
+    virtual void SetSector (iSector* sector);
+    virtual float GetRadius ();
+    virtual float GetSquaredRadius ();
+    virtual float GetInverseRadius ();
+    virtual void SetRadius (float r);
+    virtual const csColor& GetColor ();
+    virtual void SetColor (const csColor& col);
+    virtual int GetAttenuation ();
+    virtual void SetAttenuation (int a);
+    virtual float GetBrightnessAtDistance (float d);
+    virtual iCrossHalo* CreateCrossHalo (float intensity, float cross);
+    virtual iNovaHalo* CreateNovaHalo (int seed, int num_spokes,
+  	float roundness);
+    virtual iFlareHalo* CreateFlareHalo ();
+  } scfiLight;
+};
+
+/**
+ * Class for a static light. These lights cast shadows (against
+ * sector boundaries and with things), they support three different
+ * colors (R,G,B). They cannot move and they can only vary in
+ * intensity with some memory trade-offs (in which case we call
+ * it a pseudo-dynamic light).
+ */
+class csStatLight : public csLight
+{
+private:
+  /**
+   * The following three variables are used if the light intensity
+   * can vary. 'dynamic' is set to true in that case.
+   * The 'lightmaps' vector indicates all lightmaps that are
+   * possibly lit by this light.
+   */
+  bool dynamic;
+
+  /// Vector of lightmaps that are affected by this dynamic light.
+  csVector lightmaps;
+
+public:
+  /**
+   * Construct a static light at a given position. With
+   * a given radius and a given color. If 'dynamic' is
+   * true we have a pseudo-dynamic light which can change
+   * intensity and color (but not move).
+   * The light will not have a halo by default.
+   */
+  csStatLight (float x, float y, float z, float dist,
+  	 float red, float green, float blue,
+	 bool dynamic);
+  /**
+   * Destroy the light. Note that destroying a light
+   * may not have the expected effect. Static lights result
+   * in changes in the lightmaps. Removing them will not automatically
+   * update those lightmaps as that is a time-consuming process.
+   */
+  virtual ~csStatLight ();
+
+  /**
+   * Return true if this light is pseudo-dynamic.
+   */
+  bool IsDynamic () { return dynamic; }
+
+  /**
+   * Set the light color. Note that setting the color
+   * of a light may not always have an immediate visible effect.
+   * Static lights are precalculated into the lightmaps and those
+   * lightmaps are not automatically updated when calling this function
+   * as that is a time consuming process.
+   * However, this function works as expected for pseudo-dynamic
+   * lights. In this case the lightmaps will be correctly updated
+   * the next time they become visible.
+   */
+  virtual void SetColor (const csColor& col);
+
+  /**
+   * Register a lightmap for a pseudo-dynamic light.
+   * Every lightmap which is interested in updating itself
+   * as this light changes should register itself to the light.
+   */
+  void RegisterLightMap (csLightMap* lmap);
+
+  /**
+   * Shine this light on all polygons visible from the light.
+   * This routine will update the lightmaps of all polygons or
+   * update the vertex colors if gouraud shading is used.
+   * It correctly takes pseudo-dynamic lights into account and will then
+   * update the corresponding shadow map.
+   */
+  void CalculateLighting ();
+
+  /**
+   * Shine this light on all polygons of the mesh.
+   * Only backface culling is used. The light is assumed
+   * to be in the same sector as the mesh.
+   * Currently only works on thing meshes.
+   */
+  void CalculateLighting (iMeshWrapper* mesh);
+
+  //------------------------ iStatLight interface -----------------------------
+  SCF_DECLARE_IBASE_EXT (csLight);
+
+  struct eiStaticLight : public iStatLight
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csStatLight);
+
+    /// Used by the engine to retrieve internal static light object (ugly)
+    virtual csStatLight *GetPrivateObject ()
+    { return scfParent; }
+    virtual iObject *QueryObject ()
+    { return scfParent; }
+    virtual iLight *QueryLight ()
+    { return &scfParent->scfiLight; }
+  } scfiStatLight;
+  friend struct eiStaticLight;
+};
+
+/**
+ * A light patch. This is a 3D polygon which fits on a world level 3D
+ * polygon and defines where the light hits the polygon.
+ * There is a list of light patches in every polygon (all dynamic lights
+ * hitting a polygon will give rise to a seperate light patch) and there
+ * is a list of light patches in every dynamic light (representing all
+ * polygons that are hit by that particular light).
+ */
+class csLightPatch
+{
+  friend class csLightPatchPool;
+
+private:
+  csLightPatch* next_poly;
+  csLightPatch* prev_poly;
+  csLightPatch* next_light;
+  csLightPatch* prev_light;
+
+  /// Vertices.
+  csVector3* vertices;
+  /// Current number of vertices.
+  int num_vertices;
+  /// Maximum number of vertices.
+  int max_vertices;
+
+  /// Polygon that this light patch is for.
+  csPolygon3D* polygon;
+  /// Curve that this light patch is for
+  csCurve* curve;
+
+  /// Light that this light patch originates from.
+  csDynLight* light;
+
+  /// List of shadow frustums.
+  csShadowBlock shadows;
+
+  /// frustum of where the visible light hits (for use with curves)
+  csFrustum *light_frustum;
+
+public:
+  /**
+   * Create an empty light patch (infinite frustum).
+   */
+  csLightPatch ();
+
+  /**
+   * Unlink this light patch from the polygon and the light
+   * and then destroy.
+   */
+  ~csLightPatch ();
+
+  /**
+   * Make room for the specified number of vertices and
+   * initialize to start a new light patch.
+   */
+  void Initialize (int n);
+
+  /**
+   * Remove this light patch (unlink from all lists).
+   */
+  void RemovePatch ();
+
+  /**
+   * Get the polygon that this light patch belongs too.
+   */
+  csPolygon3D* GetPolygon () { return polygon; }
+
+  /**
+   * Get the curve that this light patch belongs too.
+   */
+  csCurve* GetCurve () { return curve; }
+
+  /**
+   * Get the light that this light patch belongs too.
+   */
+  csDynLight* GetLight () { return light; }
+
+  /// Get a reference to the shadow list.
+  csShadowBlock& GetShadowBlock () { return shadows; }
+
+  /// Get the number of vertices in this light patch.
+  int GetVertexCount () { return num_vertices; }
+  /// Get all the vertices.
+  csVector3* GetVertices () { return vertices; }
+
+  /// Get a vertex.
+  csVector3& GetVertex (int i)
+  {
+    CS_ASSERT (vertices != NULL);
+    CS_ASSERT (i >= 0 && i < num_vertices);
+    return vertices[i];
+  }
+
+  /**
+   * Get next light patch as seen from the standpoint
+   * of the polygon.
+   */
+  csLightPatch* GetNextPoly () { return next_poly; }
+
+  /**
+   * Get the next light patch as seen from the standpoint
+   * of the light.
+   */
+  csLightPatch* GetNextLight () { return next_light; }
+
+  /// Set polygon.
+  void SetPolyCurve (csPolygon3D* pol) { polygon = pol; curve = NULL; }
+  /// Set curve.
+  void SetPolyCurve (csCurve* c) { curve = c; polygon = NULL; }
+  /// Set light.
+  void SetLight (csDynLight* l) { light = l; }
+  /// Add to poly list.
+  void AddPolyList (csLightPatch*& first)
+  {
+    next_poly = first;
+    prev_poly = NULL;
+    if (first)
+      first->prev_poly = this;
+    first = this;
+  }
+  /// Remove from poly list.
+  void RemovePolyList (csLightPatch*& first)
+  {
+    if (next_poly) next_poly->prev_poly = prev_poly;
+    if (prev_poly) prev_poly->next_poly = next_poly;
+    else first = next_poly;
+    prev_poly = next_poly = NULL;
+    polygon = NULL;
+    curve = NULL;
+  }
+  /// Add to light list.
+  void AddLightList (csLightPatch*& first)
+  {
+    next_light = first;
+    prev_light = NULL;
+    if (first)
+      first->prev_light = this;
+    first = this;
+  }
+  /// Remove from light list.
+  void RemoveLightList (csLightPatch*& first)
+  {
+    if (next_light) next_light->prev_light = prev_light;
+    if (prev_light) prev_light->next_light = next_light;
+    else first = next_light;
+    prev_light = next_light = NULL;
+    light = NULL;
+  }
+
+  /// Set the light frustum.
+  void SetLightFrustum (csFrustum* lf) { light_frustum = lf; }
+  /// Get the light frustum.
+  csFrustum* GetLightFrustum () { return light_frustum; }
+};
+
+/**
+ * Class for a dynamic light. These lights only cast shadows
+ * for sectors/portals and not for things. However, they can
+ * freely move and change color intensity.
+ */
+class csDynLight : public csLight
+{
+private:
+  csDynLight* next;
+  csDynLight* prev;
+
+  /// List of light patches for this dynamic light.
+  csLightPatch* lightpatches;
+
+public:
+  /**
+   * Create a new dynamic light at the given position and with the
+   * given radius and color. Initially the light will
+   * not be visible. You need to set the current
+   * sector and call 'Setup()' first.
+   */
+  csDynLight (float x, float y, float z, float dist,
+  	 float red, float green, float blue);
+
+  /**
+   * Remove the dynamic light from all polygons (i.e.
+   * remove all light patches) and then destroy the light itself.
+   */
+  virtual ~csDynLight ();
+
+  /**
+   * Initial placement of the light. This routine generates a view
+   * frustum as seen from the light. The clipped polygons that
+   * result from this are light patches and are put in the
+   * lightpatches list. This routine needs to be called whenever
+   * the light moves.
+   */
+  void Setup ();
+
+  /**
+   * Call this when the color of the light changes. This is more
+   * efficient than calling Setup().
+   */
+  virtual void SetColor (const csColor& col);
+
+  /**
+   * Unlink a light patch from the light patch list.
+   * Warning! This function does not test if the light patch
+   * is really on the list!
+   */
+  void UnlinkLightpatch (csLightPatch* lp);
+
+  /**
+   * Add a light patch to the light patch list.
+   */
+  void AddLightpatch (csLightPatch* lp);
+
+  ///
+  void SetNext (csDynLight* n) { next = n; }
+  ///
+  void SetPrev (csDynLight* p) { prev = p; }
+  ///
+  csDynLight* GetNext () { return next; }
+  ///
+  csDynLight* GetPrev () { return prev; }
+
+  //------------------------ iDynLight interface -----------------------------
+  SCF_DECLARE_IBASE_EXT (csLight);
+
+  struct eiDynLight : public iDynLight
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csDynLight);
+
+    /// Used by the engine to retrieve internal dyn light object (ugly)
+    virtual csDynLight* GetPrivateObject ()
+    { return scfParent; }
+    virtual void Setup ()
+    { scfParent->Setup (); }
+    virtual iObject *QueryObject ()
+    { return scfParent; }
+    virtual iLight *QueryLight ()
+    { return &(scfParent->scfiLight); }
+    virtual iDynLight* GetNext ()
+    { return &(scfParent->GetNext())->scfiDynLight; }
+  } scfiDynLight;
+  friend struct eiDynLight;
+};
+
+
+CS_DECLARE_OBJECT_VECTOR (csLightListHelper, iLight);
+
+/**
+ * List of lights for a sector. This class implements iLightList.
+ */
+class csLightList : public csLightListHelper
+{
+public:
+  SCF_DECLARE_IBASE;
+
+  /// constructor
+  csLightList ();
+
+  /// Find a light by ID
+  iLight *FindByID (unsigned long id) const;
+
+  class LightList : public iLightList
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csLightList);
+    virtual int GetCount () const;
+    virtual iLight *Get (int n) const;
+    virtual int Add (iLight *obj);
+    virtual bool Remove (iLight *obj);
+    virtual bool Remove (int n);
+    virtual void RemoveAll ();
+    virtual int Find (iLight *obj) const;
+    virtual iLight *FindByName (const char *Name) const;
+    virtual iLight *FindByID (unsigned long id) const;
+  } scfiLightList;
+};
+
+#endif // __CS_LIGHT_H__
diff --git a/client/client94/crystalspace/include/csengine/lppool.h b/client/client94/crystalspace/include/csengine/lppool.h
new file mode 100644
index 0000000..ad8e50e
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/lppool.h
@@ -0,0 +1,44 @@
+/*
+    Copyright (C) 1998 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_LPPOOL_H__
+#define __CS_LPPOOL_H__
+
+#include "csutil/objpool.h"
+#include "csengine/light.h"
+
+
+CS_DECLARE_OBJECT_POOL (csLightPatchPoolHelper, csLightPatch);
+
+/**
+ * This is an object pool which holds objects of type
+ * csLightPatch. You can ask new instances from this pool.
+ * If needed it will allocate one for you but ideally it can
+ * give you one which was allocated earlier.
+ */
+class csLightPatchPool : public csLightPatchPoolHelper {
+public:
+  void Free (void* o)
+  {
+    csLightPatch* p = (csLightPatch*)o;
+    p->RemovePatch ();
+    csLightPatchPoolHelper::Free (p);
+  }
+};
+
+#endif // __CS_LPPOOL_H__
diff --git a/client/client94/crystalspace/include/csengine/lview.h b/client/client94/crystalspace/include/csengine/lview.h
new file mode 100644
index 0000000..75fb8bb
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/lview.h
@@ -0,0 +1,545 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_LVIEW_H__
+#define __CS_LVIEW_H__
+
+#include "csgeom/math3d.h"
+#include "csgeom/frustum.h"
+#include "csutil/csvector.h"
+#include "iengine/shadows.h"
+#include "iengine/fview.h"
+
+class csMatrix3;
+class csVector3;
+class csLight;
+class csFrustumView;
+struct csFog;
+struct iGraphics3D;
+struct iGraphics2D;
+struct iPolygon3D;
+struct iSector;
+struct iClipper2D;
+
+/**
+ * This class is a csFrustum especially used for the lighting calculations.
+ * It represents a shadow. It extends csFrustum by adding the notion of
+ * a 'shadow' originator.
+ */
+class csShadowFrustum: public csFrustum
+{
+private:
+  void* userData;
+  bool relevant;
+public:
+  /// Create empty frustum.
+  csShadowFrustum () :
+    csFrustum (csVector3 (0), &csPooledVertexArrayPool::GetDefaultPool()),
+    userData (NULL), relevant (false) { }
+  /// Create empty frustum.
+  csShadowFrustum (const csVector3& origin) :
+    csFrustum (origin, &csPooledVertexArrayPool::GetDefaultPool()),
+    userData (NULL), relevant (false) { }
+  /// Create empty frustum.
+  csShadowFrustum (const csVector3& origin, int num_verts) :
+    csFrustum (origin, num_verts, &csPooledVertexArrayPool::GetDefaultPool()),
+    userData (NULL), relevant (false) { }
+  /// Copy constructor.
+  csShadowFrustum (const csShadowFrustum& orig);
+  /// Set user data.
+  void SetUserData (void* ud) { userData = ud; }
+  /// Get user data.
+  void* GetUserData () { return userData; }
+  /// Mark shadow as relevant or not.
+  void MarkRelevant (bool rel = true) { relevant = rel; }
+  /// Is shadow relevant?
+  bool IsRelevant () { return relevant; }
+};
+
+class csShadowBlockList;
+class csShadowBlock;
+
+/**
+ * An iterator to iterate over a list of shadows.
+ * This iterator can work in two directions and also supports
+ * deleting the current element in the iterator.
+ */
+class csShadowIterator : public iShadowIterator
+{
+  friend class csShadowBlockList;
+  friend class csShadowBlock;
+
+private:
+  csShadowBlock* first_cur;
+  csShadowBlock* cur;
+  int i, cur_num;
+  bool onlycur;
+  int dir;	// 1 or -1 for direction.
+  csShadowIterator (csShadowBlock* cur, bool onlycur, int dir);
+  csShadowFrustum* cur_shad;
+
+public:
+  /// Return true if there are further elements to process.
+  virtual bool HasNext ()
+  {
+    return cur != NULL && i < cur_num && i >= 0;
+  }
+  /// Return the next element.
+  virtual csFrustum* Next ();
+  /// Get the user data for the last shadow.
+  virtual void* GetUserData () { return cur_shad->GetUserData (); }
+  /// Return if the last shadow is relevant or not.
+  virtual bool IsRelevant () { return cur_shad->IsRelevant (); }
+  /// Mark the last shadow as relevant.
+  virtual void MarkRelevant (bool rel) { cur_shad->MarkRelevant (rel); }
+  /// Reset the iterator to start again from initial setup.
+  virtual void Reset ();
+  /// Delete the last element returned.
+  virtual void DeleteCurrent ();
+  /// Return the shadow list for the 'current' element.
+  virtual iShadowBlock* GetCurrentShadowBlock ();
+  /// Return the shadow list for the 'next' element.
+  virtual iShadowBlock* GetNextShadowBlock ();
+  /// Return the shadow list for the 'current' element.
+  csShadowBlock* GetCsCurrentShadowBlock ();
+  /// Return the shadow list for the 'next' element.
+  csShadowBlock* GetCsNextShadowBlock () { return cur; }
+
+  SCF_DECLARE_IBASE;
+};
+
+/**
+ * A single block of shadows. This block will use IncRef()/DecRef()
+ * on the shadow frustums so that it is possible and legal to put a single
+ * shadow in several blocks.
+ */
+class csShadowBlock : public iShadowBlock
+{
+  friend class csShadowBlockList;
+  friend class csShadowIterator;
+
+private:
+  csShadowBlock* next, * prev;
+  csVector shadows;
+  iSector* sector;
+  int draw_busy;
+
+public:
+  /// Create a new empty list for a sector.
+  csShadowBlock (iSector* sector, int draw_busy, int max_shadows = 30,
+  	int delta = 30);
+  /// Create a new empty list.
+  csShadowBlock (int max_shadows = 30, int delta = 30);
+
+  /// Destroy the list and release all shadow references.
+  virtual ~csShadowBlock ();
+
+  /// Dereference all shadows in the list.
+  virtual void DeleteShadows ()
+  {
+    int i;
+    for (i = 0 ; i < shadows.Length () ; i++)
+    {
+      csShadowFrustum* sf = (csShadowFrustum*)shadows[i];
+      CS_ASSERT (sf != NULL);
+      sf->DecRef ();
+    }
+    shadows.DeleteAll ();
+  }
+
+  /**
+   * Copy all relevant shadow frustums from another shadow block
+   * into this block. The frustums are not really copied but a new
+   * reference is kept. However, if a transformation is given then
+   * a copy is made and the shadows are transformed.
+   */
+  void AddRelevantShadows (csShadowBlock* source, csTransform* trans = NULL);
+
+  /**
+   * Copy all relevant shadow frustums from another shadow block
+   * into this block. The frustums are not really copied but a new
+   * reference is kept. However, if a transformation is given then
+   * a copy is made and the shadows are transformed.
+   */
+  virtual void AddRelevantShadows (iShadowBlock* source,
+  	csTransform* trans = NULL);
+
+  /**
+   * Copy all relevant shadow frustums from another shadow block list
+   * into this block. The frustums are not really copied but a new
+   * reference is kept.
+   */
+  void AddRelevantShadows (csShadowBlockList* source);
+
+  /**
+   * Copy all relevant shadow frustums from another shadow block list
+   * into this block. The frustums are not really copied but a new
+   * reference is kept.
+   */
+  virtual void AddRelevantShadows (iShadowBlockList* source);
+
+  /**
+   * Copy all shadow frustums from another shadow block list
+   * into this block. The frustums are not really copied but a new
+   * reference is kept.
+   */
+  void AddAllShadows (csShadowBlockList* source);
+
+  /**
+   * Copy all shadow frustums from another shadow block list
+   * into this block. The frustums are not really copied but a new
+   * reference is kept.
+   */
+  virtual void AddAllShadows (iShadowBlockList* source);
+
+  /**
+   * Add unique shadows. Only add relevant shadow frustums that are not
+   * already in the current list. The frustums are not really copied
+   * but a new reference is kept.
+   */
+  void AddUniqueRelevantShadows (csShadowBlockList* source);
+
+  /**
+   * Add unique shadows. Only add relevant shadow frustums that are not
+   * already in the current list. The frustums are not really copied
+   * but a new reference is kept.
+   */
+  virtual void AddUniqueRelevantShadows (iShadowBlockList* source);
+
+  /**
+   * Add a new frustum and return a reference.
+   * The frustum will have the specified number of vertices but the
+   * vertices still need to be initialized.
+   */
+  virtual csFrustum* AddShadow (const csVector3& origin, void* userData,
+  	int num_verts, csPlane3& backplane);
+
+  /// Unlink a shadow frustum from the list and dereference it.
+  virtual void UnlinkShadow (int idx);
+
+  /// Get the number of shadows in this list.
+  virtual int GetShadowCount ()
+  {
+    return shadows.Length ();
+  }
+
+  /// Get the specified shadow.
+  csFrustum* GetShadow (int idx)
+  {
+    return (csFrustum*)(
+	(csShadowFrustum*)(idx < shadows.Length () ? shadows[idx] : NULL));
+  }
+
+  /**
+   * Apply a transformation to all frustums in this list.
+   */
+  void Transform (csTransform* trans)
+  {
+    int i;
+    for (i = 0 ; i < shadows.Length () ; i++)
+    {
+      csShadowFrustum* sf = (csShadowFrustum*)shadows[i];
+      CS_ASSERT (sf != NULL);
+      sf->Transform (trans);
+    }
+  }
+
+  /// Get iterator to iterate over all shadows in this block.
+  csShadowIterator* GetCsShadowIterator (bool reverse = false)
+  {
+    return new csShadowIterator (this, true, reverse ? -1 : 1);
+  }
+
+  /// Get iterator to iterate over all shadows in this block.
+  iShadowIterator* GetShadowIterator (bool reverse = false)
+  {
+    return (iShadowIterator*)(new csShadowIterator (this, true,
+    	reverse ? -1 : 1));
+  }
+
+  /// Get Sector.
+  virtual iSector* GetSector () { return sector; }
+  /// Get draw_busy for sector.
+  virtual int GetRecLevel () { return draw_busy; }
+
+  SCF_DECLARE_IBASE;
+};
+
+/**
+ * A list of shadow blocks.
+ */
+class csShadowBlockList : public iShadowBlockList
+{
+private:
+  csShadowBlock* first;
+  csShadowBlock* last;
+
+public:
+  /// Create a new empty list.
+  csShadowBlockList ();
+  /// Destroy the list and all shadow blocks in it.
+  virtual ~csShadowBlockList ()
+  {
+    DeleteAllShadows ();
+  }
+
+  /// Create a new shadow block and append to the list.
+  virtual iShadowBlock* NewShadowBlock (iSector* sector,
+  	int draw_busy, int num_shadows = 30);
+  /// Create a new shadow block and append to the list.
+  virtual iShadowBlock* NewShadowBlock ();
+
+  /// Append a shadow block to this list.
+  void AppendShadowBlock (csShadowBlock* slist)
+  {
+    CS_ASSERT (slist->prev == NULL && slist->next == NULL);
+    CS_ASSERT ((!!first) == (!!last));
+    slist->next = NULL;
+    if (!last)
+    {
+      first = last = slist;
+      slist->prev = NULL;
+    }
+    else
+    {
+      slist->prev = last;
+      last->next = slist;
+      last = slist;
+    }
+  }
+
+  /// Remove the last shadow block from this list.
+  virtual void RemoveLastShadowBlock ()
+  {
+    CS_ASSERT ((!!first) == (!!last));
+    if (last)
+    {
+      CS_ASSERT (last->next == NULL);
+      CS_ASSERT (first->prev == NULL);
+      csShadowBlock* old = last;
+      last = old->prev;
+      if (last) last->next = NULL;
+      else first = NULL;
+      old->prev = old->next = NULL;
+    }
+  }
+
+  /// Clear first and last pointers without deleting anything!
+  void Clear ()
+  {
+    CS_ASSERT ((!!first) == (!!last));
+#   ifdef CS_DEBUG
+    // If we are in debug mode then we additionally set all next/prev
+    // fields in the list to NULL so that our assert's above will work.
+    while (first)
+    {
+      csShadowBlock* old = first;
+      first = old->next;
+      old->prev = old->next = NULL;
+    }
+#   endif
+    last = NULL;
+  }
+
+  /// Destroy all shadow lists and shadows in the list.
+  virtual void DeleteAllShadows ()
+  {
+    CS_ASSERT ((!!first) == (!!last));
+    while (first)
+    {
+      first->DeleteShadows ();
+      csShadowBlock* todel = first;
+      first = first->next;
+      delete todel;
+    }
+    last = NULL;
+  }
+
+  virtual iShadowBlock* GetFirstShadowBlock () { return (iShadowBlock*)first; }
+  virtual iShadowBlock* GetLastShadowBlock () { return (iShadowBlock*)last; }
+  virtual iShadowBlock* GetNextShadowBlock (iShadowBlock* s)
+  {
+    return (iShadowBlock*)(((csShadowBlock*)s)->next);
+  }
+  virtual iShadowBlock* GetPreviousShadowBlock (iShadowBlock* s)
+  {
+    return (iShadowBlock*)(((csShadowBlock*)s)->prev);
+  }
+
+  /**
+   * Return an iterator to iterate over all shadows in this list.
+   */
+  csShadowIterator* GetCsShadowIterator (bool reverse = false)
+  {
+    return new csShadowIterator (first, false, reverse ? -1 : 1);
+  }
+
+  /**
+   * Return an iterator to iterate over all shadows in this list.
+   */
+  virtual iShadowIterator* GetShadowIterator (bool reverse = false)
+  {
+    return (iShadowIterator*)(new csShadowIterator (first, false,
+    	reverse ? -1 : 1));
+  }
+
+  SCF_DECLARE_IBASE;
+};
+
+class csFrustumView;
+class csObject;
+class csOctreeNode;
+typedef void (csFrustumViewFunc)(csObject* obj, csFrustumView* lview, bool vis);
+typedef void (csFrustumViewNodeFunc)(csOctreeNode* node, csFrustumView* lview,
+	bool vis);
+
+/**
+ * This structure represents all information needed for the frustum
+ * visibility calculator.
+ */
+class csFrustumView : public iFrustumView
+{
+private:
+  /// A function that is called for every node that is visited.
+  csFrustumViewNodeFunc* node_func;
+  /// A function that is called for every polygon that is hit.
+  csFrustumViewFunc* poly_func;
+  /// A function that is called for every curve that is hit.
+  csFrustumViewFunc* curve_func;
+  /// User data for the entire process.
+  iFrustumViewUserdata* userdata;
+
+  /// Radius we want to check.
+  float radius;
+
+  /// Squared radius.
+  float sq_radius;
+
+  /// If true the we process shadows for things.
+  bool things_shadow;
+
+  /**
+   * Mask and value which will be checked against the flags of every
+   * encountered thing to see if it will be included in the shadow
+   * processing.
+   */
+  unsigned int shadow_thing_mask, shadow_thing_value;
+  /**
+   * Mask and value which will be checked against the flags of every
+   * encountered thing to see if CheckFrustum must recursively call
+   * itself for this thing.
+   */
+  unsigned int process_thing_mask, process_thing_value;
+
+  /// Current frustum context.
+  csFrustumContext* ctxt;
+
+public:
+  /// Constructor.
+  csFrustumView ();
+
+  /// Destroy the object
+  virtual ~csFrustumView ();
+
+  /// Get the current frustum context.
+  virtual csFrustumContext* GetFrustumContext () const { return ctxt; }
+  /// Create a new frustum context.
+  virtual void CreateFrustumContext ();
+  /// Create a copy.
+  virtual csFrustumContext* CopyFrustumContext ();
+  /// Set the frustum context.
+  virtual void SetFrustumContext (csFrustumContext* ctxt);
+  /// Restore a frustum context.
+  virtual void RestoreFrustumContext (csFrustumContext* original);
+
+  /// Start new shadow list for this frustum.
+  virtual void StartNewShadowBlock ();
+
+  /// Set the function that is called for every node.
+  void SetNodeFunction (csFrustumViewNodeFunc* func) { node_func = func; }
+  /// Set the function that is called for every polygon to visit.
+  void SetPolygonFunction (csFrustumViewFunc* func) { poly_func = func; }
+  /// Set the function that is called for every curve to visit.
+  void SetCurveFunction (csFrustumViewFunc* func) { curve_func = func; }
+  /// Call the node function.
+  virtual void CallNodeFunction (csOctreeNode* onode, bool vis)
+  {
+    if (node_func) node_func (onode, this, vis);
+  }
+  /// Call the polygon function.
+  virtual void CallPolygonFunction (csObject* poly, bool vis)
+  {
+    poly_func (poly, this, vis);
+  }
+  /// Call the curve function.
+  virtual void CallCurveFunction (csObject* curve, bool vis)
+  {
+    curve_func (curve, this, vis);
+  }
+  /// Set the maximum radius to use for visiting objects.
+  void SetRadius (float rad)
+  {
+    radius = rad;
+    sq_radius = rad*rad;
+  }
+  /// Get the radius.
+  virtual float GetRadius () { return radius; }
+  /// Get the squared radius.
+  float GetSquaredRadius () { return sq_radius; }
+  /// Enable shadowing for things (off by default). @@@SUSPECT!!!
+  void EnableThingShadows (bool e) { things_shadow = e; }
+  /// Return true if shadowing for things is enabled.
+  virtual bool ThingShadowsEnabled () { return things_shadow; }
+  /// Set shadow mask.
+  void SetShadowMask (unsigned int mask, unsigned int value)
+  {
+    shadow_thing_mask = mask;
+    shadow_thing_value = value;
+  }
+  /// Set process mask.
+  void SetProcessMask (unsigned int mask, unsigned int value)
+  {
+    process_thing_mask = mask;
+    process_thing_value = value;
+  }
+  /// Check if a mask corresponds with the shadow mask.
+  virtual bool CheckShadowMask (unsigned int mask)
+  {
+    return ((mask & shadow_thing_mask) == shadow_thing_value);
+  }
+  /// Check if a mask corresponds with the process mask.
+  virtual bool CheckProcessMask (unsigned int mask)
+  {
+    return ((mask & process_thing_mask) == process_thing_value);
+  }
+
+  /// Set or clear userdata.
+  virtual void SetUserdata (iFrustumViewUserdata* data)
+  {
+    SCF_SET_REF (userdata, data);
+  }
+  /// Get userdata.
+  virtual iFrustumViewUserdata* GetUserdata ()
+  {
+    return userdata;
+  }
+  SCF_DECLARE_IBASE;
+};
+
+#endif // __CS_LVIEW_H__
+
diff --git a/client/client94/crystalspace/include/csengine/material.h b/client/client94/crystalspace/include/csengine/material.h
new file mode 100644
index 0000000..88dc9cd
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/material.h
@@ -0,0 +1,247 @@
+/*
+    Copyright (C) 2001 by Jorrit Tyberghein
+    Copyright (C) 2000 by W.C.A. Wijngaards
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_MATERIAL_H__
+#define __CS_MATERIAL_H__
+
+#include "csgfx/rgbpixel.h"
+#include "csutil/csobject.h"
+#include "csutil/nobjvec.h"
+#include "ivideo/material.h"
+#include "iengine/material.h"
+
+struct iTextureWrapper;
+struct iTextureManager;
+
+
+SCF_VERSION (csMaterialWrapper, 0, 0, 1);
+
+/**
+ * A material class.
+ */
+class csMaterial : public iMaterial
+{
+private:
+  /// flat shading color
+  csRGBcolor flat_color;
+  /// the texture of the material (can be NULL)
+  iTextureWrapper *texture;
+  /// Number of texture layers (currently maximum 4).
+  int num_texture_layers;
+  /// Optional texture layer.
+  csTextureLayer texture_layers[4];
+  /// Texture wrappers for texture layers.
+  iTextureWrapper* texture_layer_wrappers[4];
+
+  /// The diffuse reflection value of the material
+  float diffuse;
+  /// The ambient lighting of the material
+  float ambient;
+  /// The reflectiveness of the material
+  float reflection;
+
+public:
+  /**
+   * create an empty material
+   */
+  csMaterial ();
+  /**
+   * create a material with only the texture given.
+   */
+  csMaterial (iTextureWrapper *txt);
+
+  /**
+   * destroy material
+   */
+  virtual ~csMaterial ();
+
+  /// Get the flat shading color
+  csRGBcolor& GetFlatColor () { return flat_color; }
+
+  /// Get diffuse reflection constant for the material
+  float GetDiffuse () const { return diffuse; }
+  /// Set diffuse reflection constant for the material
+  void SetDiffuse (float val) { diffuse = val; }
+
+  /// Get ambient lighting for the material
+  float GetAmbient () const { return ambient; }
+  /// Set ambient lighting for the material
+  void SetAmbient (float val) { ambient = val; }
+
+  /// Get reflection of the material
+  float GetReflection () const { return reflection; }
+  /// Set reflection of the material
+  void SetReflection (float val) { reflection = val; }
+
+  /// Get the texture (if none NULL is returned)
+  iTextureWrapper *GetTextureWrapper () const { return texture; }
+  /// Set the texture (pass NULL to set no texture)
+  void SetTextureWrapper (iTextureWrapper *tex);
+
+  /// Add a texture layer (currently only one supported).
+  void AddTextureLayer (iTextureWrapper* txtwrap, uint mode,
+      	float uscale, float vscale, float ushift, float vshift);
+
+  //--------------------- iMaterial implementation ---------------------
+
+  /// Get texture.
+  virtual iTextureHandle* GetTexture ();
+  /// Get num texture layers.
+  virtual int GetTextureLayerCount ();
+  /// Get a texture layer.
+  virtual csTextureLayer* GetTextureLayer (int idx);
+  /// Get flat color.
+  virtual void GetFlatColor (csRGBpixel &oColor);
+  /// Set the flat shading color
+  virtual void SetFlatColor (const csRGBcolor& col) { flat_color = col; }
+  /// Get reflection values (diffuse, ambient, reflection).
+  virtual void GetReflection (float &oDiffuse, float &oAmbient,
+    float &oReflection);
+  /// Set reflection values (diffuse, ambient, reflection).
+  virtual void SetReflection (float oDiffuse, float oAmbient,
+    float oReflection)
+  {
+    diffuse = oDiffuse;
+    ambient = oAmbient;
+    reflection = oReflection;
+  }
+
+  SCF_DECLARE_IBASE;
+};
+
+/**
+ * csMaterialWrapper represents a texture and its link
+ * to the iMaterialHandle as returned by iTextureManager.
+ */
+class csMaterialWrapper : public csObject
+{
+private:
+  /// The corresponding iMaterial.
+  iMaterial* material;
+  /// The handle as returned by iTextureManager.
+  iMaterialHandle* handle;
+
+private:
+  /// Release material handle
+  virtual ~csMaterialWrapper ();
+
+public:
+  /// Construct a material handle given a material.
+  csMaterialWrapper (iMaterial* Image);
+  /// Construct a csMaterialWrapper from a pre-registered material handle.
+  csMaterialWrapper (iMaterialHandle *ith);
+  /// Copy constructor
+  csMaterialWrapper (csMaterialWrapper &);
+
+  /**
+   * Change the material handle. Note: This will also change the base
+   * material to NULL.
+   */
+  void SetMaterialHandle (iMaterialHandle *mat);
+  /// Get the material handle.
+  iMaterialHandle* GetMaterialHandle () { return handle; }
+
+  /**
+   * Change the base material. Note: The changes will not be visible until
+   * you re-register the material.
+   */
+  void SetMaterial (iMaterial* material);
+  /// Get the original material.
+  iMaterial* GetMaterial () { return material; }
+
+  /// Register the material with the texture manager
+  void Register (iTextureManager *txtmng);
+
+  /**
+   * Visit this material. This should be called by the engine right
+   * before using the material. It will call Visit() on all textures
+   * that are used.
+   */
+  void Visit ();
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //------------------- iMaterialWrapper implementation -----------------------
+  struct MaterialWrapper : public iMaterialWrapper
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csMaterialWrapper);
+    virtual csMaterialWrapper* GetPrivateObject ()
+    { return (csMaterialWrapper*)scfParent; }
+    virtual iObject *QueryObject()
+    { return scfParent; }
+    virtual iMaterialWrapper *Clone () const
+    { return &(new csMaterialWrapper (*scfParent))->scfiMaterialWrapper; }
+    virtual void SetMaterialHandle (iMaterialHandle *mat)
+    { scfParent->SetMaterialHandle (mat); }
+    virtual iMaterialHandle* GetMaterialHandle ()
+    { return scfParent->GetMaterialHandle (); }
+    virtual void SetMaterial (iMaterial* material)
+    { scfParent->SetMaterial (material); }
+    virtual iMaterial* GetMaterial ()
+    { return scfParent->GetMaterial (); }
+    virtual void Register (iTextureManager *txtmng)
+    { scfParent->Register (txtmng); }
+    virtual void Visit ()
+    { scfParent->Visit (); }
+  } scfiMaterialWrapper;
+  friend struct MaterialWrapper;
+};
+
+CS_DECLARE_OBJECT_VECTOR (csMaterialListHelper, iMaterialWrapper);
+
+/**
+ * This class is used to hold a list of materials.
+ */
+class csMaterialList : public csMaterialListHelper
+{
+public:
+  /// Initialize the array
+  csMaterialList ();
+
+  /// Create a new material.
+  iMaterialWrapper* NewMaterial (iMaterial* material);
+
+  /**
+   * Create a engine wrapper for a pre-prepared iTextureHandle
+   * The handle will be IncRefed.
+   */
+  iMaterialWrapper* NewMaterial (iMaterialHandle *ith);
+
+  SCF_DECLARE_IBASE;
+
+  //------------------- iMaterialList implementation -----------------------
+  class MaterialList : public iMaterialList
+  {
+  public:
+    SCF_DECLARE_EMBEDDED_IBASE (csMaterialList);
+
+    virtual iMaterialWrapper* NewMaterial (iMaterial* material);
+    virtual iMaterialWrapper* NewMaterial (iMaterialHandle *ith);
+    virtual int GetCount () const;
+    virtual iMaterialWrapper *Get (int n) const;
+    virtual int Add (iMaterialWrapper *obj);
+    virtual bool Remove (iMaterialWrapper *obj);
+    virtual bool Remove (int n);
+    virtual void RemoveAll ();
+    virtual int Find (iMaterialWrapper *obj) const;
+    virtual iMaterialWrapper *FindByName (const char *Name) const;
+  } scfiMaterialList;
+};
+
+#endif // __CS_MATERIAL_H__
diff --git a/client/client94/crystalspace/include/csengine/meshobj.h b/client/client94/crystalspace/include/csengine/meshobj.h
new file mode 100644
index 0000000..0e47b60
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/meshobj.h
@@ -0,0 +1,679 @@
+/*
+    Copyright (C) 2000-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_MESHOBJ_H__
+#define __CS_MESHOBJ_H__
+
+#include "csgeom/transfrm.h"
+#include "csutil/csobject.h"
+#include "csutil/nobjvec.h"
+#include "csutil/flags.h"
+#include "csutil/garray.h"
+#include "csengine/movable.h"
+#include "imesh/object.h"
+#include "iengine/mesh.h"
+#include "iengine/viscull.h"
+#include "ivideo/graph3d.h"
+
+struct iMeshWrapper;
+struct iRenderView;
+struct iMovable;
+class csMeshWrapper;
+class csMeshFactoryWrapper;
+class csLight;
+
+CS_DECLARE_OBJECT_VECTOR (csMeshListHelper, iMeshWrapper);
+
+/**
+ * General list of meshes. This class implements iMeshList.
+ * Subclasses of this class can override FreeItem(), AddMesh(),
+ * and RemoveMesh() for more specific functionality.
+ */
+class csMeshList : public csMeshListHelper
+{
+public:
+  SCF_DECLARE_IBASE;
+
+  /// constructor
+  csMeshList ();
+
+  class MeshList : public iMeshList
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csMeshList);
+    virtual int GetCount () const;
+    virtual iMeshWrapper *Get (int n) const;
+    virtual int Add (iMeshWrapper *obj);
+    virtual bool Remove (iMeshWrapper *obj);
+    virtual bool Remove (int n);
+    virtual void RemoveAll ();
+    virtual int Find (iMeshWrapper *obj) const;
+    virtual iMeshWrapper *FindByName (const char *Name) const;
+  } scfiMeshList;
+};
+
+/**
+ * Subclass of csMeshList to hold the children of another mesh object.
+ */
+class csMeshMeshList : public csMeshList
+{
+private:
+  csMeshWrapper* mesh;
+
+public:
+  csMeshMeshList () : mesh (NULL) { }
+  ~csMeshMeshList () { DeleteAll (); }
+  void SetMesh (csMeshWrapper* m) { mesh = m; }
+  virtual bool PrepareItem (csSome Item);
+  virtual bool FreeItem (csSome Item);
+};
+
+CS_DECLARE_OBJECT_VECTOR (csMeshFactoryListHelper, iMeshFactoryWrapper);
+
+/**
+ * A list of mesh factories.
+ */
+class csMeshFactoryList : public csMeshFactoryListHelper
+{
+public:
+  SCF_DECLARE_IBASE;
+
+  /// constructor
+  csMeshFactoryList ();
+
+  class MeshFactoryList : public iMeshFactoryList
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csMeshFactoryList);
+    virtual int GetCount () const;
+    virtual iMeshFactoryWrapper *Get (int n) const;
+    virtual int Add (iMeshFactoryWrapper *obj);
+    virtual bool Remove (iMeshFactoryWrapper *obj);
+    virtual bool Remove (int n);
+    virtual void RemoveAll ();
+    virtual int Find (iMeshFactoryWrapper *obj) const;
+    virtual iMeshFactoryWrapper *FindByName (const char *Name) const;
+  } scfiMeshFactoryList;
+};
+
+/**
+ * Subclass of csMeshFactoryList to hold the children of another mesh factory.
+ */
+class csMeshFactoryFactoryList : public csMeshFactoryList
+{
+private:
+  csMeshFactoryWrapper* meshfact;
+
+public:
+  csMeshFactoryFactoryList () : meshfact (NULL) {}
+  ~csMeshFactoryFactoryList () { DeleteAll (); }
+  void SetMeshFactory (csMeshFactoryWrapper* m) { meshfact = m; }
+  virtual bool PrepareItem (csSome Item);
+  virtual bool FreeItem (csSome Item);
+};
+
+SCF_VERSION (csMeshWrapper, 0, 0, 1);
+
+/**
+ * The holder class for all implementations of iMeshObject.
+ */
+class csMeshWrapper : public csObject
+{
+  friend class csMovable;
+  friend class csMovableSectorList;
+
+protected:
+
+  /// The parent mesh object, or NULL
+  iMeshWrapper *Parent;
+
+  /**
+   * Bounding box in world space.
+   * This is a cache for GetWorldBoundingBox() which will recalculate this
+   * if the movable changes (by using movablenr).
+   */
+  csBox3 wor_bbox;
+  /// Last used movable number for wor_bbox.
+  long wor_bbox_movablenr;
+
+  /// Defered lighting. If > 0 then we have defered lighting.
+  int defered_num_lights;
+
+  /// Flags to use for defered lighting.
+  int defered_lighting_flags;
+
+  /**
+   * This value indicates the last time that was used to do animation.
+   * If 0 then we haven't done animation yet. We compare this value
+   * with the value returned by engine->GetLastAnimationTime() to see
+   * if we need to call meshobj->NextFrame() again.
+  */
+  csTicks last_anim_time;
+
+  /**
+   * Flag which is set to true when the object is visible.
+   * This is used by the c-buffer/bsp routines. The object itself
+   * will not use this flag in any way at all. It is simply intended
+   * for external visibility culling routines.
+   */
+  bool is_visible;
+
+  /**
+   * Position in the world.
+   */
+  csMovable movable;
+
+  /**
+   * The renderer will render all objects in a sector based on this
+   * number. Low numbers get rendered first. High numbers get rendered
+   * later. There are a few predefined slots which the application is
+   * free to use or not.
+   */
+  long render_priority;
+
+  /// Update defered lighting.
+  void UpdateDeferedLighting (const csVector3& pos);
+
+private:
+  /// Mesh object corresponding with this csMeshWrapper.
+  iMeshObject* mesh;
+
+  /// Children of this object (other instances of iMeshWrapper).
+  csMeshMeshList children;
+
+  /// The callback which is called just before drawing.
+  iMeshDrawCallback* draw_cb;
+
+  /// Optional reference to the parent csMeshFactoryWrapper.
+  iMeshFactoryWrapper* factory;
+
+  /// Z-buf mode to use for drawing this object.
+  csZBufMode zbufMode;
+
+public:
+  /// Set of flags
+  csFlags flags;
+
+protected:
+  /// Move this object to the specified sector. Can be called multiple times.
+  void MoveToSector (csSector* s);
+
+  /// Remove this object from all sectors it is in (but not from the engine).
+  void RemoveFromSectors ();
+
+  /**
+   * Update transformations after the object has moved
+   * (through updating the movable instance).
+   * This MUST be done after you change the movable otherwise
+   * some of the internal data structures will not be updated
+   * correctly. This function is called by movable.UpdateMove();
+   */
+  void UpdateMove ();
+
+  /**
+   * Draw this mesh object given a camera transformation.
+   * If needed the skeleton state will first be updated.
+   * Optionally update lighting if needed (DeferUpdateLighting()).
+   */
+  void DrawInt (iRenderView* rview);
+
+  /**
+   * Destructor.  This is private in order to force clients to use DecRef()
+   * for object destruction.
+   */
+  virtual ~csMeshWrapper ();
+
+public:
+  /// Constructor.
+  csMeshWrapper (iMeshWrapper* theParent, iMeshObject* mesh);
+  /// Constructor.
+  csMeshWrapper (iMeshWrapper* theParent);
+
+  /// Set parent container for this object.
+  void SetParentContainer (iMeshWrapper* newParent) { Parent = newParent; }
+  /// Get parent container for this object.
+  iMeshWrapper* GetParentContainer () const { return Parent; }
+
+  /// Set the mesh factory.
+  void SetFactory (iMeshFactoryWrapper* factory)
+  {
+    csMeshWrapper::factory = factory;
+  }
+  /// Get the mesh factory.
+  iMeshFactoryWrapper* GetFactory () const
+  {
+    return factory;
+  }
+
+  /// Set the mesh object.
+  void SetMeshObject (iMeshObject* mesh);
+  /// Get the mesh object.
+  iMeshObject* GetMeshObject () const {return mesh;}
+
+  /// Set the Z-buf drawing mode to use for this object.
+  void SetZBufMode (csZBufMode mode) { zbufMode = mode; }
+  /// Get the Z-buf drawing mode.
+  csZBufMode GetZBufMode () const { return zbufMode; }
+
+  /**
+   * Set a callback which is called just before the object is drawn.
+   * This is useful to do some expensive computations which only need
+   * to be done on a visible object. Note that this function will be
+   * called even if the object is not visible. In general it is called
+   * if there is a likely probability that the object is visible (i.e.
+   * it is in the same sector as the camera for example).
+   */
+  void SetDrawCallback (iMeshDrawCallback* cb)
+  {
+    if (cb) cb->IncRef ();
+    if (draw_cb) draw_cb->DecRef ();
+    draw_cb = cb;
+  }
+
+  /// Get the draw callback.
+  iMeshDrawCallback* GetDrawCallback () const
+  {
+    return draw_cb;
+  }
+
+  /// Mark this object as visible.
+  void MarkVisible () { is_visible = true; }
+
+  /// Mark this object as invisible.
+  void MarkInvisible () { is_visible = false; }
+
+  /// Return if this object is visible.
+  bool IsVisible () const { return is_visible; }
+
+  /**
+   * Light object according to the given array of lights (i.e.
+   * fill the vertex color array).
+   */
+  void UpdateLighting (iLight** lights, int num_lights);
+
+  /**
+   * Update lighting as soon as the object becomes visible.
+   * This will call engine->GetNearestLights with the supplied
+   * parameters.
+   */
+  void DeferUpdateLighting (int flags, int num_lights);
+
+  /**
+   * Draw this mesh object given a camera transformation.
+   * If needed the skeleton state will first be updated.
+   * Optionally update lighting if needed (DeferUpdateLighting()).
+   */
+  void Draw (iRenderView* rview);
+
+  /// Returns true if this object wants to die.
+  bool WantToDie () { return mesh->WantToDie (); }
+
+  /**
+   * Get the movable instance for this object.
+   * It is very important to call GetMovable().UpdateMove()
+   * after doing any kind of modification to this movable
+   * to make sure that internal data structures are
+   * correctly updated.
+   */
+  csMovable& GetMovable () { return movable; }
+
+  /**
+   * This routine will find out in which sectors a mesh object
+   * is positioned. To use it the mesh has to be placed in one starting
+   * sector. This routine will then start from that sector, find all
+   * portals that touch the sprite and add all additional sectors from
+   * those portals. Note that this routine using a bounding sphere for
+   * this test so it is possible that the mesh will be added to sectors
+   * where it really isn't located (but the sphere is).
+   * <p>
+   * If the mesh is already in several sectors those additional sectors
+   * will be ignored and only the first one will be used for this routine.
+   */
+  void PlaceMesh ();
+
+  /**
+   * Check if this object is hit by this object space vector.
+   * BBox version.
+   */
+  int HitBeamBBox (const csVector3& start, const csVector3& end,
+         csVector3& isect, float* pr);
+  /**
+   * Check if this object is hit by this object space vector.
+   * Outline version.
+   */
+  bool HitBeamOutline (const csVector3& start, const csVector3& end,
+         csVector3& isect, float* pr);
+  /**
+   * Check if this object is hit by this object space vector.
+   * Return the collision point in object space coordinates.
+   */
+  bool HitBeamObject (const csVector3& start, const csVector3& end,
+  	csVector3& isect, float* pr);
+  /**
+   * Check if this object is hit by this world space vector.
+   * Return the collision point in world space coordinates.
+   */
+  bool HitBeam (const csVector3& start, const csVector3& end,
+  	csVector3& isect, float* pr);
+
+  /// Get the children of this mesh object.
+  const csMeshMeshList& GetChildren () const { return children; }
+
+  /// Get the radius of this mesh and all its children.
+  void GetRadius (csVector3& rad, csVector3& cent) const;
+
+  /**
+   * Do a hard transform of this object.
+   * This transformation and the original coordinates are not
+   * remembered but the object space coordinates are directly
+   * computed (world space coordinates are set to the object space
+   * coordinates by this routine). Note that some implementations
+   * of mesh objects will not change the orientation of the object but
+   * only the position.
+   */
+  void HardTransform (const csReversibleTransform& t);
+
+  /**
+   * Get the bounding box of this object in world space.
+   * This routine will cache the bounding box and only recalculate it
+   * if the movable changes.
+   */
+  void GetWorldBoundingBox (csBox3& cbox);
+
+  /**
+   * Get the bounding box of this object after applying a transformation to it.
+   * This is really a very inaccurate function as it will take the bounding
+   * box of the object in object space and then transform this bounding box.
+   */
+  void GetTransformedBoundingBox (const csReversibleTransform& trans,
+  	csBox3& cbox);
+
+  /**
+   * Get a very inaccurate bounding box of the object in screen space.
+   * Returns -1 if object behind the camera or else the distance between
+   * the camera and the furthest point of the 3D box.
+   */
+  float GetScreenBoundingBox (const iCamera *camera, csBox2& sbox,
+  	csBox3& cbox);
+
+  /// Set the render priority for this object.
+  void SetRenderPriority (long rp);
+  /// Get the render priority for this object.
+  long GetRenderPriority () const
+  {
+    return render_priority;
+  }
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //--------------------- iMeshWrapper implementation --------------------//
+  struct MeshWrapper : public iMeshWrapper
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csMeshWrapper);
+    virtual csMeshWrapper* GetPrivateObject ()
+    {
+      return (csMeshWrapper*)scfParent;
+    }
+    virtual iObject *QueryObject ()
+    {
+      return scfParent;
+    }
+    virtual iMeshObject* GetMeshObject () const
+    {
+      return scfParent->GetMeshObject ();
+    }
+    virtual void SetMeshObject (iMeshObject* m)
+    {
+      scfParent->SetMeshObject (m);
+    }
+    virtual iMeshFactoryWrapper* GetFactory () const
+    {
+      return scfParent->GetFactory ();
+    }
+    virtual void SetFactory (iMeshFactoryWrapper* m)
+    {
+      scfParent->SetFactory (m);
+    }
+    virtual void DeferUpdateLighting (int flags, int num_lights)
+    {
+      scfParent->DeferUpdateLighting (flags, num_lights);
+    }
+    virtual void UpdateLighting (iLight** lights, int num_lights)
+    {
+      scfParent->UpdateLighting (lights, num_lights);
+    }
+    virtual iMovable* GetMovable () const
+    {
+      return &(scfParent->movable.scfiMovable);
+    }
+    virtual void PlaceMesh ()
+    {
+      scfParent->PlaceMesh ();
+    }
+    virtual int HitBeamBBox (const csVector3& start, const csVector3& end,
+          csVector3& isect, float* pr)
+    {
+      return scfParent->HitBeamBBox (start, end, isect, pr);
+    }
+    virtual bool HitBeamOutline (const csVector3& start, const csVector3& end,
+          csVector3& isect, float* pr)
+    {
+      return scfParent->HitBeamOutline (start, end, isect, pr);
+    }
+    virtual bool HitBeamObject (const csVector3& start, const csVector3& end,
+  	csVector3& isect, float* pr)
+    {
+      return scfParent->HitBeamObject (start, end, isect, pr);
+    }
+    virtual bool HitBeam (const csVector3& start, const csVector3& end,
+  	csVector3& isect, float* pr)
+    {
+      return scfParent->HitBeam (start, end, isect, pr);
+    }
+    virtual void SetDrawCallback (iMeshDrawCallback* cb)
+    {
+      scfParent->SetDrawCallback (cb);
+    }
+    virtual iMeshDrawCallback* GetDrawCallback () const
+    {
+      return scfParent->GetDrawCallback ();
+    }
+    virtual void SetRenderPriority (long rp)
+    {
+      scfParent->SetRenderPriority (rp);
+    }
+    virtual long GetRenderPriority () const
+    {
+      return scfParent->GetRenderPriority ();
+    }
+    virtual csFlags& GetFlags ()
+    {
+      return scfParent->flags;
+    }
+    virtual void SetZBufMode (csZBufMode mode)
+    {
+      scfParent->SetZBufMode (mode);
+    }
+    virtual csZBufMode GetZBufMode () const
+    {
+      return scfParent->GetZBufMode ();
+    }
+    virtual void HardTransform (const csReversibleTransform& t)
+    {
+      scfParent->HardTransform (t);
+    }
+    virtual void GetWorldBoundingBox (csBox3& cbox)
+    {
+      scfParent->GetWorldBoundingBox (cbox);
+    }
+    virtual void GetTransformedBoundingBox (const csReversibleTransform& trans,
+  	csBox3& cbox)
+    {
+      scfParent->GetTransformedBoundingBox (trans, cbox);
+    }
+    virtual float GetScreenBoundingBox (iCamera* camera, csBox2& sbox,
+  	csBox3& cbox);
+    virtual iMeshList* GetChildren ()
+    {
+      return &(scfParent->children.scfiMeshList);
+    }
+    virtual iMeshWrapper* GetParentContainer ()
+    {
+      return scfParent->GetParentContainer ();
+    }
+    virtual void SetParentContainer (iMeshWrapper* p)
+    {
+      scfParent->SetParentContainer (p);
+    }
+    virtual void GetRadius (csVector3& rad, csVector3 &cent) const
+    {
+      scfParent->GetRadius (rad,cent);
+    }
+    virtual void Draw (iRenderView* rview)
+    {
+      scfParent->Draw (rview);
+    }
+    virtual bool WantToDie ()
+    {
+      return scfParent->WantToDie ();
+    }
+  } scfiMeshWrapper;
+  friend struct MeshWrapper;
+
+  //-------------------- iVisibilityObject interface implementation ----------
+  struct VisObject : public iVisibilityObject
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csMeshWrapper);
+    virtual iMovable* GetMovable () const
+    {
+      return &(scfParent->movable.scfiMovable);
+    }
+    virtual long GetShapeNumber () const
+    {
+      return scfParent->mesh->GetShapeNumber ();
+    }
+    virtual void GetBoundingBox (csBox3& bbox)
+    {
+      scfParent->mesh->GetObjectBoundingBox (bbox, CS_BBOX_MAX);
+    }
+    virtual void MarkVisible () { scfParent->MarkVisible (); }
+    virtual void MarkInvisible () { scfParent->MarkInvisible (); }
+    virtual bool IsVisible () const { return scfParent->IsVisible (); }
+  } scfiVisibilityObject;
+  friend struct VisObject;
+};
+
+SCF_VERSION (csMeshFactoryWrapper, 0, 0, 3);
+
+/**
+ * The holder class for all implementations of iMeshObjectFactory.
+ */
+class csMeshFactoryWrapper : public csObject
+{
+private:
+  /// Mesh object factory corresponding with this csMeshFactoryWrapper.
+  iMeshObjectFactory* meshFact;
+
+  /// Optional parent of this object (can be NULL).
+  iMeshFactoryWrapper* parent;
+
+  /// Optional relative transform to parent.
+  csReversibleTransform transform;
+
+  /// Children of this object (other instances of iMeshFactoryWrapper).
+  csMeshFactoryFactoryList children;
+
+private:
+  /// Destructor.
+  virtual ~csMeshFactoryWrapper ();
+
+public:
+  /// Constructor.
+  csMeshFactoryWrapper (iMeshObjectFactory* meshFact);
+  /// Constructor.
+  csMeshFactoryWrapper ();
+
+  /// Set the mesh object factory.
+  void SetMeshObjectFactory (iMeshObjectFactory* meshFact);
+
+  /// Get the mesh object factory.
+  iMeshObjectFactory* GetMeshObjectFactory () const
+  {
+    return meshFact;
+  }
+
+  /**
+   * Create a new mesh object for this template.
+   */
+  iMeshWrapper* NewMeshObject ();
+
+  /**
+   * Do a hard transform of this factory.
+   * This transformation and the original coordinates are not
+   * remembered but the object space coordinates are directly
+   * computed (world space coordinates are set to the object space
+   * coordinates by this routine). Note that some implementations
+   * of mesh objects will not change the orientation of the object but
+   * only the position.
+   */
+  void HardTransform (const csReversibleTransform& t);
+
+  /// This function is called for every child that is added
+  void PrepareChild (iMeshFactoryWrapper* child);
+  /// This function is called for every child that is removed
+  void UnprepareChild (iMeshFactoryWrapper* child);
+
+  /**
+   * Get optional relative transform (relative to parent).
+   */
+  csReversibleTransform& GetTransform () { return transform; }
+
+  /**
+   * Set optional relative transform (relative to parent).
+   */
+  void SetTransform (const csReversibleTransform& tr) { transform = tr; }
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //----------------- iMeshFactoryWrapper implementation --------------------//
+  struct MeshFactoryWrapper : public iMeshFactoryWrapper
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csMeshFactoryWrapper);
+    virtual iMeshObjectFactory* GetMeshObjectFactory () const
+      { return scfParent->GetMeshObjectFactory (); }
+    virtual void SetMeshObjectFactory (iMeshObjectFactory* fact)
+      { scfParent->SetMeshObjectFactory (fact); }
+    virtual iObject *QueryObject ()
+      { return scfParent; }
+    virtual void HardTransform (const csReversibleTransform& t)
+      { scfParent->HardTransform (t); }
+    virtual iMeshWrapper* CreateMeshWrapper ()
+      { return scfParent->NewMeshObject (); }
+    virtual iMeshFactoryWrapper* GetParentContainer () const
+      { return scfParent->parent; }
+    virtual void SetParentContainer (iMeshFactoryWrapper *p)
+      { scfParent->parent = p; }
+    virtual iMeshFactoryList* GetChildren ()
+      { return &(scfParent->children.scfiMeshFactoryList); }
+    virtual csReversibleTransform& GetTransform ()
+      { return scfParent->GetTransform (); }
+    virtual void SetTransform (const csReversibleTransform& tr)
+      { scfParent->SetTransform (tr); }
+  } scfiMeshFactoryWrapper;
+  friend struct MeshFactoryWrapper;
+};
+
+#endif // __CS_MESHOBJ_H__
diff --git a/client/client94/crystalspace/include/csengine/movable.h b/client/client94/crystalspace/include/csengine/movable.h
new file mode 100644
index 0000000..a6c0b6c
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/movable.h
@@ -0,0 +1,284 @@
+/*
+    Copyright (C) 2000 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_MOVABLE_H__
+#define __CS_MOVABLE_H__
+
+#include "csutil/typedvec.h"
+#include "csutil/nobjvec.h"
+#include "iengine/movable.h"
+#include "iengine/sector.h"
+
+class csVector3;
+class csMatrix3;
+class csMovable;
+class csMeshWrapper;
+
+CS_DECLARE_TYPED_VECTOR_NODELETE (csMovableListenerVector, iMovableListener);
+CS_DECLARE_RESTRICTED_ACCESS_OBJECT_VECTOR (csSectorVector, iSector);
+
+/// A list of sectors as the movable uses it
+class csMovableSectorList : public csSectorVector
+{
+private:
+  csMovable* movable;
+
+public:
+  SCF_DECLARE_IBASE;
+
+  csMovableSectorList ();
+  ~csMovableSectorList ();
+  void SetMovable (csMovable* mov) { movable = mov; }
+
+  virtual bool PrepareItem (csSome item);
+  virtual bool FreeItem (csSome item);
+
+  class SectorList : public iSectorList
+  {
+  public:
+    SCF_DECLARE_EMBEDDED_IBASE (csMovableSectorList);
+
+    virtual int GetCount () const;
+    virtual iSector *Get (int n) const;
+    virtual int Add (iSector *obj);
+    virtual bool Remove (iSector *obj);
+    virtual bool Remove (int n);
+    virtual void RemoveAll ();
+    virtual int Find (iSector *obj) const;
+    virtual iSector *FindByName (const char *Name) const;
+  } scfiSectorList;
+};
+
+/**
+ * This class represents an entity that can move in the engine.
+ * It has a list of sectors and a position (a list of sectors
+ * because an entity can overlap several sectors at the same time
+ * through portals). This class itself does not have geometry.
+ * It is only responsible for managing movement.
+ */
+class csMovable : public iBase
+{
+private:
+  /// World to object transformation.
+  csReversibleTransform obj;
+  /// List of sectors.
+  csMovableSectorList sectors;
+  /// List of listeners to this movable.
+  csMovableListenerVector listeners;
+  /// List of user-data for the listeners.
+  csVector listener_userdata;
+
+  /**
+   * Parent (for hierachical transformations).
+   * Note that if the parent is not NULL then the list of
+   * sectors is ignored for this movable (the parent list is
+   * returned) and the 'obj' transformation is relative to
+   * the parent one. The pointer is not reference-counted.
+   */
+  iMovable* parent;
+
+  /**
+   * Mesh on which this movable operates.
+   */
+  csMeshWrapper* object;
+
+  /// Update number.
+  long updatenr;
+
+public:
+  /**
+   * Create a default movable.
+   */
+  csMovable ();
+
+  /// Destructor.
+  virtual ~csMovable ();
+
+  /// Set mesh on which this movable operates.
+  void SetMeshWrapper (csMeshWrapper* obj)
+  { object = obj; }
+
+  /// Get the mesh wrapper on which we operate.
+  csMeshWrapper* GetMeshWrapper ()
+  { return object; }
+
+  /// Set the parent movable.
+  void SetParent (iMovable* par)
+  { parent = par; }
+
+  /// Get the parent movable.
+  iMovable* GetParent () const
+  { return parent; }
+
+  /**
+   * Initialize the list of sectors to one sector where
+   * this thing is. This is a conveniance funcion.
+   * This function does not do anything if the parent is not NULL.
+   */
+  void SetSector (iSector* sector);
+
+  /**
+   * Clear the list of sectors.
+   * This function does not do anything if the parent is not NULL.
+   */
+  void ClearSectors ();
+
+  /**
+   * Get list of sectors for this entity.
+   * This will return the sectors of the parent if there
+   * is a parent.
+   */
+  iSectorList *GetSectors ()
+  {
+    if (parent) return parent->GetSectors ();
+    else return &sectors.scfiSectorList;
+  }
+
+  /**
+   * Return true if we are placed in a sector.
+   */
+  bool InSector () const
+  {
+    return sectors.Length () > 0;
+  }
+
+  /**
+   * Set the transformation vector and sector to move to
+   * some position.
+   */
+  void SetPosition (iSector* home, const csVector3& v);
+
+  /**
+   * Set the transformation vector for this object. Note
+   * that the sectors are unchanged.
+   */
+  void SetPosition (const csVector3& v)
+  {
+    obj.SetOrigin (v);
+  }
+
+  /**
+   * Get the current local position.
+   */
+  const csVector3& GetPosition () const { return obj.GetOrigin (); }
+
+  /**
+   * Get the current position using the full transformation (using
+   * possible parent transformations).
+   * @@@ Currently not very efficient!
+   */
+  const csVector3 GetFullPosition () const
+  {
+    return GetFullTransform ().GetOrigin ();
+  }
+
+  /**
+   * Set the transformation matrix for this entity.
+   */
+  void SetTransform (const csMatrix3& matrix);
+
+  /**
+   * Set the local world to object tranformation.
+   */
+  void SetTransform (const csReversibleTransform& t) { obj = t; }
+
+  /**
+   * Get the local world to object tranformation.
+   */
+  csReversibleTransform& GetTransform () { return obj; }
+
+  /**
+   * Get the local world to object tranformation.
+   */
+  const csReversibleTransform& GetTransform () const { return obj; }
+
+  /**
+   * Construct the full world to object transformation given
+   * this transformation and possible parents transformations.
+   */
+  csReversibleTransform GetFullTransform () const;
+
+  /**
+   * Relative move.
+   */
+  void MovePosition (const csVector3& v);
+
+  /**
+   * Relative transform.
+   */
+  void Transform (const csMatrix3& matrix);
+
+  /**
+   * After all movement has been done you need to
+   * call UpdateMove() to make the final changes to the entity
+   * that is controlled by this movable. This is very important!
+   */
+  void UpdateMove ();
+
+  /**
+   * Add a listener to this movable. This listener will be called whenever
+   * the movable changes or right before the movable is destroyed.
+   */
+  void AddListener (iMovableListener* listener, void* userdata);
+
+  /**
+   * Remove a listener from this movable.
+   */
+  void RemoveListener (iMovableListener* listener);
+
+  /**
+   * A number which indicates if the movable has been updated.
+   * One can use this number to see if the position of the object
+   * has changed since the last time it was checked.
+   */
+  long GetUpdateNumber () const { return updatenr; }
+
+  SCF_DECLARE_IBASE;
+
+  //------------------------- iMovable interface -------------------------------
+  struct eiMovable : public iMovable
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csMovable);
+    virtual iMovable* GetParent () const;
+    virtual void SetParent (iMovable* parent)
+    {
+      scfParent->SetParent (parent);
+    }
+    virtual void SetSector (iSector* sector);
+    virtual void ClearSectors ();
+    virtual iSectorList *GetSectors ();
+    virtual bool InSector () const;
+    virtual void SetPosition (iSector* home, const csVector3& v);
+    virtual void SetPosition (const csVector3& v);
+    virtual const csVector3& GetPosition () const;
+    virtual const csVector3 GetFullPosition () const;
+    virtual void SetTransform (const csMatrix3& matrix);
+    virtual void SetTransform (const csReversibleTransform& t);
+    virtual csReversibleTransform& GetTransform ();
+    virtual csReversibleTransform GetFullTransform () const;
+    virtual void MovePosition (const csVector3& v);
+    virtual void Transform (const csMatrix3& matrix);
+    virtual void AddListener (iMovableListener* listener, void* userdata);
+    virtual void RemoveListener (iMovableListener* listener);
+    virtual void UpdateMove ();
+    virtual long GetUpdateNumber () const;
+  } scfiMovable;
+  friend struct eiMovable;
+};
+
+#endif // __CS_MOVABLE_H__
diff --git a/client/client94/crystalspace/include/csengine/octree.h b/client/client94/crystalspace/include/csengine/octree.h
new file mode 100644
index 0000000..cf590d0
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/octree.h
@@ -0,0 +1,355 @@
+/*
+    Copyright (C) 1998,2000 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_OCTREE_H__
+#define __CS_OCTREE_H__
+
+#include "csgeom/math3d.h"
+#include "csgeom/box.h"
+#include "csengine/polytree.h"
+#include "csengine/bsp.h"
+
+class csPolygonInt;
+class csOctree;
+class csOctreeNode;
+class csBspTree;
+class csThing;
+struct iCacheManager;
+struct iFile;
+
+#define OCTREE_FFF 0
+#define OCTREE_FFB 1
+#define OCTREE_FBF 2
+#define OCTREE_FBB 3
+#define OCTREE_BFF 4
+#define OCTREE_BFB 5
+#define OCTREE_BBF 6
+#define OCTREE_BBB 7
+
+/**
+ * An octree node.
+ * @@@ We should have seperate leaf/non-leaf structures as they
+ * are considerably different.
+ */
+class csOctreeNode : public csPolygonTreeNode
+{
+  friend class csOctree;
+
+private:
+  /// Children.
+  csPolygonTreeNode* children[8];
+  /// Bounding box;
+  csBox3 bbox;
+  /// Center point for this node.
+  csVector3 center;
+
+  /**
+   * Six masks representing solid space on the boundaries
+   * of this node. Use the CS_BOX_SIDE_xxx flags to fetch them.
+   */
+  uint16 solid_masks[6];
+
+  /**
+   * If true then this is a leaf.
+   * If a node has no polygons then it will also be a leaf
+   * but there will be no mini-bsp.
+   */
+  bool leaf;
+
+  /**
+   * A list of all polygons in this node. These are the original
+   * unsplit polygons. Further subdivision of this node will
+   * cause these polygons to be split into the children but
+   * the list here reflects the unsplit polygons.
+   */
+  csPolygonIntArray unsplit_polygons;
+
+  /// Mini-bsp tree (in this case there are no children).
+  csBspTree* minibsp;
+
+  /**
+   * If there is a mini-bsp tree this array contains the indices
+   * of all vertices that are used by the polygons in the tree.
+   * This can be used to optimize the world->camera transformation
+   * process because only the minibsp nodes that are really used
+   * need to be traversed.
+   */
+  int* minibsp_verts;
+
+  /// Number of vertices in minibsp_verts.
+  int minibsp_numverts;
+
+private:
+  /// Make an empty octree node.
+  csOctreeNode ();
+
+  /**
+   * Destroy this octree node.
+   */
+  virtual ~csOctreeNode ();
+
+  /// Set box.
+  void SetBox (const csVector3& bmin, const csVector3& bmax)
+  {
+    bbox.Set (bmin, bmax);
+    center = (bmin + bmax) / 2;
+  }
+
+  /// Set mini-bsp tree.
+  void SetMiniBsp (csBspTree* mbsp);
+
+  /// Build vertex tables.
+  void BuildVertexTables ();
+
+public:
+  /// Return true if node is empty.
+  bool IsEmpty ();
+
+  /// Return true if node is leaf.
+  bool IsLeaf () { return leaf; }
+
+  /// Get center.
+  const csVector3& GetCenter () const { return center; }
+
+  /// Get minimum coordinate of box.
+  const csVector3& GetMinCorner () const { return bbox.Min (); }
+
+  /// Get maximum coordinate of box.
+  const csVector3& GetMaxCorner () const { return bbox.Max (); }
+
+  /// Get box.
+  const csBox3& GetBox () { return bbox; }
+
+  /// Get a child.
+  csOctreeNode* GetChild (int i) { return (csOctreeNode*)children[i]; }
+
+  /**
+   * Get one of the masks representing solid space on the boundaries
+   * of this node. Use the CS_BOX_SIDE_xxx flags to fetch them.
+   */
+  uint16 GetSolidMask (int idx) { return solid_masks[idx]; }
+
+  /**
+   * Get the list of all unsplit polygons in this node.
+   * These are the original unsplit polygons. Further
+   * subdivision of this node will have caused these polygons to
+   * be split into the children but the list here reflects
+   * the unsplit polygons.
+   */
+  csPolygonIntArray& GetUnsplitPolygons () { return unsplit_polygons; }
+
+  /// Get mini-bsp tree.
+  csBspTree* GetMiniBsp () const { return minibsp; }
+
+  /// Get indices of vertices used in the mini-bsp of this leaf.
+  int* GetMiniBspVerts () const { return minibsp_verts; }
+
+  /// Get number of vertices.
+  int GetMiniBspVertexCount () const { return minibsp_numverts; }
+
+  /// Return type (NODE_???).
+  int Type () { return NODE_OCTREE; }
+
+  /// Count the number of children (octree nodes) for this node.
+  int CountChildren ();
+
+  /**
+   * Count all the polygons in this node and children.
+   * This function only calls leaf polygons (i.e. polygons that will
+   * actually be returned by Front2Back/Back2Front).
+   */
+  int CountPolygons ();
+
+  /**
+   * Create an iterator to iterate over all solid polygons that
+   * are on the specified side of this octree node ('side' is one
+   * of CS_BOX_SIDE_xxx flags).
+   */
+  void* InitSolidPolygonIterator (int side);
+
+  /**
+   * Get the next solid polygon from the iterator. Returns false
+   * if there are no more polygons.
+   */
+  bool NextSolidPolygon (void* vspit, csPoly3D& poly);
+
+  /**
+   * If done with the iterator clean it up.
+   */
+  void CleanupSolidPolygonIterator (void* vspit);
+};
+
+/**
+ * The octree.
+ */
+class csOctree : public csPolygonTree
+{
+private:
+  /// The main bounding box for the octree.
+  csBox3 bbox;
+  /// The number of polygons at which we revert to a bsp tree.
+  int bsp_num;
+  /// The mode for the mini-bsp trees.
+  int mode;
+
+private:
+  /// Build the tree from the given node and number of polygons.
+  void Build (csOctreeNode* node, const csVector3& bmin, const csVector3& bmax,
+  	csPolygonInt** polygons, int num);
+
+  /// Traverse the tree from back to front starting at 'node' and 'pos'.
+  void* Back2Front (csOctreeNode* node, const csVector3& pos,
+  	csTreeVisitFunc* func, void* data, csTreeCullFunc* cullfunc,
+	void* culldata);
+  /// Traverse the tree from front to back starting at 'node' and 'pos'.
+  void* Front2Back (csOctreeNode* node, const csVector3& pos,
+  	csTreeVisitFunc* func, void* data, csTreeCullFunc* cullfunc,
+	void* culldata);
+
+  /**
+   * Process all todo stubs in a node and add new
+   * todo stubs to the children of this node.
+   */
+  void ProcessTodo (csOctreeNode* node);
+
+  /**
+   * Try to find the best center possible and update the node.
+   */
+  void ChooseBestCenter (csOctreeNode* node, csPolygonInt** polygons, int num);
+
+  /**
+   * Gather statistics info about this tree.
+   */
+  void Statistics (csOctreeNode* node, int depth,
+  	int* num_oct_nodes, int* max_oct_depth, int* num_bsp_trees,
+  	int* tot_bsp_nodes, int* min_bsp_nodes, int* max_bsp_nodes,
+	int* tot_bsp_leaves, int* min_bsp_leaves, int* max_bsp_leaves,
+	int* tot_max_depth, int* min_max_depth, int* max_max_depth,
+	int* tot_tot_poly, int* min_tot_poly, int* max_tot_poly,
+	int* num_pvs_leaves,
+	int* tot_pvs_vis_nodes, int* min_pvs_vis_nodes, int* max_pvs_vis_nodes,
+	int* tot_pvs_vis_poly, int* min_pvs_vis_poly, int* max_pvs_vis_poly);
+
+  /**
+   * Calculate masks for the sides of all nodes.
+   */
+  void CalculateSolidMasks (csOctreeNode* node);
+
+  /// Cache this node and children.
+  void Cache (csOctreeNode* node, iFile* cf);
+
+  /// Read this node from cache and also children.
+  bool ReadFromCache (iFile* cf, csOctreeNode* node,
+  	const csVector3& bmin, const csVector3& bmax,
+  	csPolygonInt** polygons, int num);
+
+  /**
+   * Get the node for this path.
+   */
+  csOctreeNode* GetNodeFromPath (csOctreeNode* node,
+	unsigned char* path, int path_len);
+
+  /**
+   * Get the path to a node in the tree.
+   * The length should be set to 0 before calling this function.
+   * The returned length will be the length of the path in 'path'.
+   */
+  void GetNodePath (csOctreeNode* node, csOctreeNode* child,
+	unsigned char* path, int& path_len);
+
+public:
+  /**
+   * Create an empty tree for the given parent, a bounding box defining the
+   * outer limits of the octree, and the number of polygons at which we
+   * revert to a BSP tree.
+   */
+  csOctree (csThing* thing, const csVector3& min_bbox,
+  	const csVector3& max_bbox, int bsp_num, int mode = BSP_MINIMIZE_SPLITS);
+
+  /**
+   * Destroy the whole octree (but not the actual polygons and parent
+   * objects).
+   */
+  virtual ~csOctree ();
+
+  /**
+   * Get the root.
+   */
+  csOctreeNode* GetRoot () { return (csOctreeNode*)root; }
+
+  /**
+   * Create the tree with a given set of polygons.
+   */
+  void Build (csPolygonInt** polygons, int num);
+
+  /**
+   * Create the tree with a given set of polygons.
+   */
+  void Build (const csPolygonArray& polygons);
+
+  /// Traverse the tree from back to front starting at the root and 'pos'.
+  void* Back2Front (const csVector3& pos, csTreeVisitFunc* func, void* data,
+  	csTreeCullFunc* cullfunc = NULL, void* culldata = NULL);
+  /// Traverse the tree from front to back starting at the root and 'pos'.
+  void* Front2Back (const csVector3& pos, csTreeVisitFunc* func, void* data,
+  	csTreeCullFunc* cullfunc = NULL, void* culldata = NULL);
+
+  /**
+   * Get a convex outline (not a polygon unless projected to 2D)
+   * for for this octree node as seen from the given position.
+   * The coordinates returned are world space coordinates.
+   * Note that you need place for at least six vectors in the array.
+   * If bVisible is set true, the method returns all visible corners.
+   * This could be up to 7 vertices.
+   */
+  void GetConvexOutline (csOctreeNode* node, const csVector3& pos,
+  	csVector3* array, int& num_array, bool bVisible = false)
+  {
+    node->bbox.GetConvexOutline (pos, array, num_array, bVisible);
+  }
+
+  /**
+   * Given a position return the leaf that this position is in.
+   */
+  csOctreeNode* GetLeaf (const csVector3& pos);
+
+  /**
+   * Build vertex tables for minibsp leaves. These tables are
+   * used to optimize the world to camera transformation so that only
+   * the needed vertices are transformed.
+   */
+  void BuildVertexTables () { if (root) ((csOctreeNode*)root)->BuildVertexTables (); }
+
+  /// Print statistics about this octree.
+  void Statistics ();
+
+  /**
+   * Cache this entire octree to the cache manager.
+   */
+  void Cache (iCacheManager* cache_mgr);
+
+  /**
+   * Read this entire octree from cache manager.
+   * Returns false if not cached, or cache not valid.
+   */
+  bool ReadFromCache (iCacheManager* cache_mgr,
+  	csPolygonInt** polygons, int num);
+};
+
+#endif // __CS_OCTREE_H__
+
diff --git a/client/client94/crystalspace/include/csengine/pol2d.h b/client/client94/crystalspace/include/csengine/pol2d.h
new file mode 100644
index 0000000..8c0d436
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/pol2d.h
@@ -0,0 +1,167 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_POL2D_H__
+#define __CS_POL2D_H__
+
+#include "csutil/scf.h"
+#include "csgeom/math2d.h"
+#include "csgeom/math3d.h"
+#include "csgeom/poly2d.h"
+#include "ivideo/graph3d.h"
+
+class csPolygon3D;
+class csPolyPlane;
+struct iRenderView;
+struct iGraphics2D;
+struct iGraphics3D;
+
+/**
+ * The following class represents a 2D polygon (the 2D coordinates are
+ * perspective corrected coordinates).<p>
+ *
+ * This class is used as the main driver for the engine pipeline.
+ * The source Polygon is first converted to 2D using csPolygon3D::DoPerspective.
+ */
+class csPolygon2D : public csPoly2D
+{
+public:
+  /**
+   * Compute the perspective transformation of a 3D vertex and add it to the polygon.
+   */
+  void AddPerspective (const csVector3& v);
+
+  /**
+   * Compute the perspective transformation of a 3D vertex and add it to the polygon.
+   * This version computes unit perspective correction for which aspect ratio
+   * is one and shift_x and shift_y are zero.
+   */
+  void AddPerspectiveUnit (const csVector3& v);
+
+  /**
+   * Compute the perspective transformation of a 3D vertex and add it to the polygon.
+   * This version computes perspective correction for a given aspect
+   * ratio and given shift value.
+   */
+  void AddPerspectiveAspect (const csVector3& v, float ratio, float shift);
+
+  /**
+   * Draw the polygon (wireframe version).
+   */
+  void Draw (iGraphics2D* g2d, int col);
+
+  /**
+   * Draw a texture mapped polygon.
+   * 'plane' should be a correctly transformed plane (transformed to camera
+   * space).
+   * 'poly' is only used for debugging. The plane and vertices are not used.
+   */
+  void DrawFilled (iRenderView* rview, csPolygon3D* poly, csPolyPlane* plane,
+	csZBufMode zbufMode = CS_ZBUF_FILL);
+
+  /**
+   * Z fill the Z buffer for this polygon.
+   * Nothing else is rendered.
+   */
+  void FillZBuf (iRenderView* rview, csPolygon3D* poly, csPolyPlane* plane);
+
+  /**
+   * Add this polygon as a back or front polygon of a fog object.
+   * NOTE! Don't forget to open the fog object first with g3d->OpenFogObject ();
+   */
+  void AddFogPolygon (iGraphics3D* g3d, csPolygon3D* poly, csPolyPlane* plane,
+  	bool mirror, CS_ID id, int fog_type);
+};
+
+/**
+ * Factory to create csPolygon2D objects.
+ */
+class csPolygon2DFactory : public csPoly2DFactory
+{
+public:
+  /// A shared factory that you can use.
+  CS_DECLARE_STATIC_CLASSVAR(sharedFactory,SharedFactory,csPolygon2DFactory)
+
+  /// Create a poly2d.
+  virtual csPoly2D* Create () { csPolygon2D* p = new csPolygon2D (); return (csPoly2D*)p; }
+};
+
+
+struct G3DPolygonDPFX;
+struct csVertexStatus;
+
+/**
+ * Prepare a filled in G3DPolygonDPFX structure for drawing via
+ * g3d->DrawPolygonFX
+ */
+extern void PreparePolygonFX (G3DPolygonDPFX* g3dpoly, csVector2* clipped_poly,
+  int num_vertices, csVector2 *orig_triangle, bool gouraud);
+extern void PreparePolygonFX2 (G3DPolygonDPFX* g3dpoly, csVector2* clipped_poly,
+  int num_vertices, csVertexStatus* clipped_vtstats,
+  int orig_num_vertices, bool gouraud);
+
+/*
+ * An element for the queue.
+ */
+struct csQueueElement
+{
+  csPolygon3D* poly3d;
+  csPolygon2D* poly2d;
+};
+
+/**
+ * A queue for polygon 2D objects to render at a later time.
+ * This queue is useful to remember a set of 2D polygons efficiently
+ * and play them back in front to back or back to front.
+ * A queue is always allocated for a given maximum size. This size
+ * is known in advance because we know for which polygons the queue
+ * is going to be used.<br>
+ * Note! The queue will never delete polygons from memory. You are
+ * responsible for cleaning up the queue first.
+ */
+class csPolygon2DQueue
+{
+private:
+  // The queue.
+  csQueueElement* queue;
+
+  // Maximum number of elements in the queue.
+  int max_queue;
+
+  // Current number of elements in the queue.
+  int num_queue;
+
+public:
+  /// Construct a queue for a given maximum size.
+  csPolygon2DQueue (int max_size);
+
+  /// Destruct queue.
+  ~csPolygon2DQueue ();
+
+  /// Push a 2D polygon to the queue.
+  void Push (csPolygon3D* poly3d, csPolygon2D* poly2d);
+
+  /**
+   * Pop last added 2D polygon from the queue.
+   * Return false if there are no more 2D polygons.
+   */
+  bool Pop (csPolygon3D** poly3d, csPolygon2D** poly2d);
+};
+
+
+#endif // __CS_POL2D_H__
diff --git a/client/client94/crystalspace/include/csengine/poledges.h b/client/client94/crystalspace/include/csengine/poledges.h
new file mode 100644
index 0000000..987d2d6
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/poledges.h
@@ -0,0 +1,157 @@
+/*
+    Copyright (C) 2000 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _CS_POLEDGES_H
+#define _CS_POLEDGES_H
+
+#include "csutil/hashmap.h"
+
+class csPolygonInt;
+class csPolygon3D;
+class csPolygonEdges;
+
+/**
+ * A private structure inside the hashmap.
+ */
+struct csPolEdge
+{
+  csPolygon3D* p;
+  int i1, i2;	// Edge; i1 < i2
+};
+
+/**
+ * An iterator to iterate over all polygons sharing some
+ * edge.
+ */
+class csPolEdgeIterator
+{
+  friend class csPolygonEdges;
+
+private:
+  /// Hash iterator to iterate over the key.
+  csHashIterator* iterator;
+  /// Indices of two vertices making the edge.
+  int i1, i2;
+  /// Current poledge structure.
+  csPolEdge* current;
+
+private:
+  /**
+   * Constructor is private. This object is only made
+   * by the friend csPolygonEdges.
+   */
+  csPolEdgeIterator (csHashMap& edges, int i1, int i2);
+
+public:
+  /// Destructor.
+  virtual ~csPolEdgeIterator ();
+
+  /// Is there a next polygon in this iterator?
+  bool HasNext ()
+  {
+    return current != NULL;
+  }
+
+  /// Get the next polygon.
+  csPolygon3D* Next ();
+};
+
+/**
+ * An iterator to iterate over all edges.
+ */
+class csEdgeIterator
+{
+  friend class csPolygonEdges;
+
+private:
+  /// Hash iterator.
+  csHashIterator* iterator;
+  /// Current poledge structure.
+  csPolEdge* current;
+
+private:
+  /**
+   * Constructor is private. This object is only made
+   * by the friend csPolygonEdges.
+   */
+  csEdgeIterator (csHashMap& edges);
+
+public:
+  /// Destructor.
+  virtual ~csEdgeIterator ();
+
+  /// Is there a next edge in this iterator?
+  bool HasNext ()
+  {
+    return current != NULL;
+  }
+
+  /// Get the next polygon/edge.
+  csPolygon3D* Next (int& e1, int& e2);
+};
+
+/**
+ * A class representing all edges in a set of polygons.
+ */
+class csPolygonEdges
+{
+private:
+  /**
+   * This hashmap contains entries for all edges (and
+   * attached polygon). An edge is defined by the two
+   * vertex indices increased with one and then multiplied
+   * (i.e. (i1+1) * (i2+1)).
+   */
+  csHashMap edges;
+
+public:
+  /**
+   * Construct this structure based on the given array
+   * of csPolygonInt*. The csPolygonInt* are assumed to
+   * be of type csPolygon3D.
+   */
+  csPolygonEdges (csPolygonInt** polygons, int num_polygons);
+
+  /**
+   * Destroy this set of edges
+   */
+  virtual ~csPolygonEdges ();
+
+  /**
+   * Return an iterator to iterate over all polygons sharing
+   * some edge. 'delete' this iterator when ready.
+   * i1 and i2 are the indices of the vertices making up the edge.
+   * The order of i1 and i2 is irrelevant.
+   */
+  csPolEdgeIterator* GetPolygons (int i1, int i2)
+  {
+    return new csPolEdgeIterator (edges, i1, i2);
+  }
+
+  /**
+   * Get an iterator to iterate over all edges and polygons
+   * in this structure. 'delete' this iterator when ready.
+   */
+  csEdgeIterator* GetEdges ()
+  {
+    return new csEdgeIterator (edges);
+  }
+};
+
+#endif // __CS_POLEDGES_H__
+
diff --git a/client/client94/crystalspace/include/csengine/polygon.h b/client/client94/crystalspace/include/csengine/polygon.h
new file mode 100644
index 0000000..96761a6
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/polygon.h
@@ -0,0 +1,1468 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_POLYGON_H__
+#define __CS_POLYGON_H__
+
+#include "csutil/scf.h"
+#include "csutil/cscolor.h"
+#include "csutil/flags.h"
+#include "csgeom/transfrm.h"
+#include "csgeom/polyclip.h"
+#include "csgeom/polyidx.h"
+#include "csengine/polyint.h"
+#include "csengine/polyplan.h"
+#include "csengine/thing.h"
+#include "csengine/portal.h"
+#include "csengine/polytext.h"
+#include "csengine/octree.h"
+#include "csengine/material.h"
+#include "iengine/sector.h"
+#include "imesh/thing/polygon.h"
+#include "imesh/thing/ptextype.h"
+
+class csSector;
+class csFrustumView;
+class csFrustumContext;
+class csMaterialWrapper;
+class csPolyPlane;
+class csPolyTxtPlane;
+class csPolygon2D;
+class csPolygon3D;
+class csLightMap;
+class csLightPatch;
+class csPolyTexture;
+class csThing;
+struct iLight;
+struct iGraphics2D;
+struct iGraphics3D;
+struct iCacheManager;
+
+/**
+ * Structure containing lighting information valid
+ * for all types of polygons.
+ */
+struct csPolygonLightInfo
+{
+  /**
+   * This field describes how the light hitting this polygon is affected
+   * by the angle by which the beam hits the polygon. If this value is
+   * equal to -1 (default) then the global csPolyTexture::cfg_cosinus_factor
+   * will be used.
+   */
+  float cosinus_factor;
+
+  /**
+   * List of light patches for this polygon.
+   */
+  csLightPatch *lightpatches;
+
+  /**
+   * True if we have a dirty polygon due to dynamic lighting.
+   */
+  bool dyn_dirty;
+};
+
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Kind of texturing that is used for a 3D polygon.
+ * This is the base class with subclasses depending on the kind
+ * of texturing that is used for a polygon. Also this class contains
+ * all the information required for POLYTXT_NONE texture type.
+ */
+class csPolyTexType : public iPolyTexType
+{
+  friend class csPolygon3D;
+
+protected:
+  /**
+   * 0 is no alpha, 25 is 25% see through and 75% texture and so on.
+   * Valid values are from 0 to 100; some renderers in some modes will
+   * approximate it (and some values like 25/50/75 are optimized for speed).
+   * Note that alpha is in range 0..255, 0 for 0% and 255 for 100%.
+   */
+  uint16 Alpha;
+
+  /**
+   * MixMode to use for drawing this polygon (plus alpha value
+   * which is stored separately). The GetMixMode() function will
+   * overlap both variables to get one compound value.
+   */
+  uint MixMode;
+
+  /// Common constructor for derived classes
+  csPolyTexType ();
+  /// Destructor is virtual to be able to delete derived objects
+  virtual ~csPolyTexType ();
+
+public:
+  /// Return a type for the kind of texturing used.
+  virtual int GetTextureType () { return POLYTXT_NONE; }
+
+  /// Get the alpha value for this polygon
+  int GetAlpha () { return Alpha; }
+  /// Set the alpha value for this polygon
+  void SetAlpha (int a) { Alpha = a; }
+
+  /// Sets the mode that is used for DrawPolygonFX.
+  virtual void SetMixMode (uint m) { MixMode = m & ~CS_FX_MASK_ALPHA; }
+
+  /// Gets the mode that is used for DrawPolygonFX.
+  virtual uint GetMixMode () { return (MixMode | Alpha); }
+
+  SCF_DECLARE_IBASE;
+};
+
+/**
+ * This structure contains all required information for
+ * flat-shaded (do not mix with flat-colored!) texture mapped
+ * (or flat-shaded) polygons.
+ */
+class csPolyTexFlat : public csPolyTexType
+{
+  friend class csPolygon3D;
+
+private:
+  /**
+   * The following array specifies the u,v coordinates for every vertex
+   * of the polygon.
+   */
+  csVector2* uv_coords;
+
+protected:
+  /// Constructor.
+  csPolyTexFlat () : csPolyTexType ()
+  { SCF_CONSTRUCT_EMBEDDED_IBASE(scfiPolyTexFlat); uv_coords = NULL; }
+
+  /// Destructor.
+  virtual ~csPolyTexFlat ();
+
+public:
+  /// Return a type for the kind of texturing used.
+  virtual int GetTextureType () { return POLYTXT_FLAT; }
+
+  /**
+   * Setup this lighting structure with the right number of vertices,
+   * taken from parent object. The contents of U/V array are not destroyed,
+   * if it was previously allocated.
+   */
+  void Setup (csPolygon3D *iParent);
+
+  /**
+   * Setup this lighting structure with the right number of vertices,
+   * taken from parent object. The contents of U/V array are not destroyed,
+   * if it was previously allocated.
+   */
+  virtual void Setup (iPolygon3D *iParent);
+
+  /**
+   * Set an (u,v) texture coordinate for the specified vertex
+   * of this polygon. This function may only be called after all
+   * vertices have been added. As soon as this function is used
+   * this polygon will be rendered using a different technique
+   * (perspective incorrect texture mapping and Gouroud shading).
+   * This is useful for triangulated objects for which the triangles
+   * are very small and also for drawing very far away polygons
+   * for which perspective correctness is not needed (sky polygons for
+   * example).
+   */
+  virtual void SetUV (int i, float u, float v);
+
+  /**
+   * Clear all (u,v) coordinates.
+   */
+  virtual void ClearUV ();
+
+  /// Get the pointer to the vertex uv coordinates.
+  virtual csVector2 *GetUVCoords () { return uv_coords; }
+
+  SCF_DECLARE_IBASE_EXT (csPolyTexType);
+
+  struct eiPolyTexFlat : public iPolyTexFlat
+  {
+    SCF_DECLARE_EMBEDDED_IBASE(csPolyTexFlat);
+    virtual void Setup (iPolygon3D *p) { scfParent->Setup(p); }
+    virtual void SetUV (int i, float u, float v) { scfParent->SetUV(i,u,v); }
+    virtual void ClearUV () { scfParent->ClearUV(); }
+    virtual csVector2 *GetUVCoords () { return scfParent->GetUVCoords(); }
+  } scfiPolyTexFlat;
+};
+
+/**
+ * Structure containing information about texture mapping
+ * and vertex colors for Gouraud-shaded polygons.
+ */
+class csPolyTexGouraud : public csPolyTexFlat
+{
+  friend class csPolygon3D;
+
+private:
+  /**
+   * If uv_coords is given then this can be an optional array of vertex
+   * colors. If this array is given then gouraud shading is used. Otherwise
+   * flatshading.
+   */
+  csColor *colors;
+
+  /**
+   * This array contains the static colors. It is used in combination with
+   * 'colors'.  'colors=static_colors+dynamic_lights'.
+   */
+  csColor *static_colors;
+
+  /**
+   * This bool indicates if the gouraud shading (static colors)
+   * is up-to-date (read from the cache). If set to false the polygon
+   * still needs to be lit.
+   */
+  bool gouraud_up_to_date;
+
+protected:
+  /// Constructor.
+  csPolyTexGouraud () : csPolyTexFlat ()
+  {
+    SCF_CONSTRUCT_EMBEDDED_IBASE(scfiPolyTexGouraud);
+    colors = static_colors = 0;
+    gouraud_up_to_date = false;
+  }
+
+  /// Destructor.
+  virtual ~csPolyTexGouraud ();
+
+public:
+  /// Return a type for the kind of texturing used.
+  virtual int GetTextureType () { return POLYTXT_GOURAUD; }
+
+  /**
+   * Setup this lighting structure with the rignt number of vertices,
+   * taken from parent object. The contents of U/V array are not destroyed,
+   * if it was previously allocated.
+   */
+  void Setup (csPolygon3D *iParent);
+
+  /**
+   * Setup this lighting structure with the rignt number of vertices,
+   * taken from parent object. The contents of U/V array are not destroyed,
+   * if it was previously allocated.
+   */
+  virtual void Setup (iPolygon3D *iParent);
+
+  /**
+   * Clear all color information.
+   */
+  virtual void ClearColors ();
+
+  /// Get the pointer to the vertex color table.
+  virtual csColor *GetColors () { return colors; }
+
+  /// Get the pointer to the static vertex color table.
+  virtual csColor *GetStaticColors () { return static_colors; }
+
+  /**
+   * Add a color to the static color array.
+   */
+  void AddColor (int i, float r, float g, float b);
+
+  /**
+   * Add a color to the dynamic color array.
+   */
+  void AddDynamicColor (int i, float r, float g, float b);
+
+  /**
+   * Set a color in the dynamic array.
+   */
+  void SetDynamicColor (int i, float r, float g, float b);
+
+  /**
+   * Reset a dynamic color to the static values.
+   */
+  virtual void ResetDynamicColor (int i);
+
+  /**
+   * Set a color in the dynamic array.
+   */
+  virtual void SetDynamicColor (int i, const csColor& c)
+  { SetDynamicColor (i, c.red, c.green, c.blue); }
+
+  /**
+   * Set a color in the static array.
+   */
+  void SetColor (int i, float r, float g, float b);
+
+  /**
+   * Set a color in the static array.
+   */
+  virtual void SetColor (int i, const csColor& c)
+  { SetColor (i, c.red, c.green, c.blue); }
+
+  SCF_DECLARE_IBASE_EXT (csPolyTexFlat);
+
+  struct eiPolyTexGouraud : public iPolyTexGouraud
+  {
+    SCF_DECLARE_EMBEDDED_IBASE(csPolyTexGouraud);
+    virtual void Setup (iPolygon3D *p) { scfParent->Setup(p); }
+    virtual void ClearColors () { scfParent->ClearColors(); }
+    virtual csColor *GetColors () { return scfParent->GetColors(); }
+    virtual csColor *GetStaticColors() { return scfParent->GetStaticColors(); }
+    virtual void ResetDynamicColor (int i) { scfParent->ResetDynamicColor(i); }
+    virtual void SetDynamicColor (int i, const csColor& c)
+    { scfParent->SetDynamicColor(i,c); }
+    virtual void SetColor(int i,const csColor& c) { scfParent->SetColor(i,c); }
+  } scfiPolyTexGouraud;
+};
+
+/**
+ * Structure containing all required information
+ * for lightmapped polygons.
+ */
+class csPolyTexLightMap : public csPolyTexType
+{
+  friend class csPolygon3D;
+
+private:
+  /// The transformed texture for this polygon.
+  csPolyTexture *tex;
+
+  /**
+   * The csPolyTxtPlane for this polygon.
+   */
+  csPolyTxtPlane *txt_plane;
+
+  /**
+   * This bool indicates if the lightmap is up-to-date (read from the
+   * cache). If set to false the polygon still needs to be lit.
+   */
+  bool lightmap_up_to_date;
+
+private:
+  /// Constructor.
+  csPolyTexLightMap ();
+
+  /// Destructor.
+  virtual ~csPolyTexLightMap ();
+
+public:
+  /// Setup for the given polygon and material.
+  void Setup (csPolygon3D* poly3d, csMaterialWrapper* math);
+
+  /// Return a type for the kind of texturing used.
+  virtual int GetTextureType () { return POLYTXT_LIGHTMAP; }
+
+  /// Get the polytexture (lighted texture)
+  csPolyTexture* GetPolyTex ();
+
+  /**
+   * Return the texture plane of this polygon.
+   */
+  csPolyTxtPlane* GetTxtPlane () const { return txt_plane; }
+  /**
+   * Return the texture plane of this polygon.
+   */
+  virtual iPolyTxtPlane* GetPolyTxtPlane () const;
+
+  /**
+   * Set the texture plane.
+   */
+  void SetTxtPlane (csPolyTxtPlane* txt_pl);
+
+  /**
+   * Create a new texture plane.
+   */
+  void NewTxtPlane ();
+
+  /**
+   * Get the lightmap belonging with this polygon.
+   */
+  iLightMap* GetLightMap () { return tex->GetLightMap (); }
+
+  SCF_DECLARE_IBASE_EXT (csPolyTexType);
+
+  struct eiPolyTexLightMap : public iPolyTexLightMap
+  {
+    SCF_DECLARE_EMBEDDED_IBASE(csPolyTexLightMap);
+    virtual iPolyTxtPlane* GetPolyTxtPlane () const
+    { return scfParent->GetPolyTxtPlane(); }
+  } scfiPolyTexLightMap;
+};
+
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Additional polygon flags. These flags are private,
+ * unlike those defined in ipolygon.h
+ */
+
+/**
+ * If this flag is set this portal was allocated by this polygon
+ * and it should also be deleted by it.
+ */
+#define CS_POLY_DELETE_PORTAL	0x80000000
+
+/**
+ * If this flag is true then this polygon will never be drawn.
+ * This is useful for polygons which have been split. The original
+ * unsplit polygon is still kept because it holds the shared
+ * information about the lighted texture and lightmaps (all split
+ * children refer to the original polygon for that).
+ */
+#define CS_POLY_NO_DRAW		0x40000000
+
+/**
+ * If this flag is set then this polygon has been split (BSP tree
+ * or other reason). Depending on the engine mode this polygon will
+ * not be used anymore for rendering.
+ */
+#define CS_POLY_SPLIT		0x20000000
+
+/**
+ * This flag is set if the renderer can't handle the lightmap.
+ * Lighting is still calculated, but the lightmap isn't passed to the
+ * renderer.
+ */
+#define CS_POLY_LM_REFUSED	0x10000000
+
+/**
+ * This is our main 3D polygon class. Polygons are used to construct the
+ * outer hull of sectors and the faces of 3D things.
+ * Polygons can be transformed in 3D (usually they are transformed so
+ * that the camera position is at (0,0,0) and the Z-axis is forward).
+ * Polygons cannot be transformed in 2D. That's what csPolygon2D is for.
+ * It is possible to convert a csPolygon3D to a csPolygon2D though, at
+ * which point processing continues with the csPolygon2D object.
+ *<p>
+ * Polygons have a texture and lie on a plane. The plane does not
+ * define the orientation of the polygon but is derived from it. The plane
+ * does define how the texture is scaled and translated accross the surface
+ * of the polygon (in case we are talking about lightmapped polygons, gouraud
+ * shaded polygons have u,v coordinates at every vertex).
+ * Several planes can be shared for different polygons. As a result of this
+ * their textures will be correctly aligned.
+ *<p>
+ * If a polygon is part of a sector it can be a portal to another sector.
+ * A portal-polygon is a see-through polygon that defines a view to another
+ * sector. Normally the texture for a portal-polygon is not drawn unless
+ * the texture is filtered in which case it is drawn on top of the other
+ * sector.
+ */
+class csPolygon3D : public csPolygonInt, public csObject
+// NOTE: DO NOT MOVE csPolygonInt FROM FIRST PLACE! THERE ARE LOTS OF PLACES
+// WHERE CODE BLATANTLY SWITCHES BETWEEN csPolygon3D AND csPolygonInt TYPES
+// WITHOUT GIVING TO THE C++ COMPILER EVEN A CHANCE TO ADJUST THE POINTER!!!
+{
+  friend class csPolyTexture;
+
+private:
+  /// ID for this polygon relative to the parent (will be >0).
+  unsigned long polygon_id;
+
+  /*
+   * A table of indices into the vertices of the parent csThing
+   * (container).
+   */
+  csPolyIndexed vertices;
+
+  /**
+   * The physical parent of this polygon.
+   * Important note for CS developers. If the parent of a polygon
+   * is changed in any way and this polygon has a portal then the
+   * portal needs to be removed from the old thing and added to the
+   * new thing (things keep a list of all polygons having a portal
+   * on them).
+   */
+  csThing* thing;
+
+  /**
+   * If not-null, this polygon is a portal.
+   * Important note for CS developers. If the portal is changed
+   * in any way (deleted or set) then the parent thing has to
+   * be notified (csThing::AddPortalPolygon() and
+   * csThing::RemovePortalPolygon()) so that it can update its list
+   * of portal polygons.
+   */
+  csPortal* portal;
+
+  /**
+   * The PolygonPlane for this polygon.
+   */
+  csPolyPlane* plane;
+
+  /**
+   * The material, this contains the texture handle,
+   * the flat color (if no texture) and other parameters.
+   */
+  csMaterialWrapper* material;
+
+  /**
+   * General lighting information for this polygon.
+   */
+  csPolygonLightInfo light_info;
+
+  /**
+   * Texture type specific information for this polygon. Can be either
+   * csPolyTexLightMap or csPolyTexGouraud.
+   */
+  csPolyTexType *txt_info;
+
+  /**
+   * The original polygon. This is useful when a BSP tree
+   * has split a polygon. In that case, orig_poly will indicate the
+   * original polygon that this polygon was split from.
+   * If not split then this will be NULL.
+   */
+  csPolygon3D *orig_poly;
+
+  /**
+   * The texture share list. All polygons that share a single texture
+   * are linked using this field. For example, if some polygon was split
+   * multiple times by the BSP algorithm, all polygons that results
+   * from that split are linked through this field. The start of list is
+   * in "orig_poly" polygon.
+   */
+  csPolygon3D *txt_share_list;
+
+  /**
+   * Visibility number. If equal to csOctreeNode::pvs_cur_vis_nr then
+   * this object is visible.
+   */
+  uint32 pvs_vis_nr;
+
+  /**
+   * Return twice the signed area of the polygon in world space coordinates
+   * using the yz, zx, and xy components.  In effect this calculates the
+   * (P,Q,R) or the plane normal of the polygon.
+   */
+  void PlaneNormal (float* yz, float* zx, float* xy);
+
+#ifdef DO_HW_UVZ
+  /// Precompute the (u,v) values for all vertices of the polygon
+  void SetupHWUV();
+#endif
+
+  /**
+   * Same as CalculateLighting but called before light view destruction
+   * through callbacks and csPolyTexture::ProcessDelayedLightmaps ().
+   * Called only for lightmapped polygons with shared lightmap.
+   */
+  void CalculateDelayedLighting (csFrustumView *lview, csFrustumContext* ctxt);
+
+public:
+  /// Set of flags
+  csFlags flags;
+
+public:
+#ifdef DO_HW_UVZ
+  csVector3 *uvz;
+  bool isClipped;
+#endif
+
+  /**
+   * Construct a new polygon with the given material.
+   */
+  csPolygon3D (csMaterialWrapper *mat);
+
+  /**
+   * Construct a new polygon and copy from the given polygon.
+   * Note! Several fields will reflect that a copy was made!
+   * New polytextures will be allocated. This is mainly used when
+   * a BSP tree splits a polygon.
+   */
+  csPolygon3D (csPolygon3D& poly);
+
+  /**
+   * Delete everything related to this polygon. Less is
+   * deleted if this polygon is a copy of another one (because
+   * some stuff is shared).
+   */
+  virtual ~csPolygon3D ();
+
+  /// Get the ID of this polygon relative to the parent (will be >0).
+  unsigned long GetPolygonID ()
+  {
+    CS_ASSERT (polygon_id != 0);
+    return polygon_id;
+  }
+
+  /**
+   * Set type of texturing to use for this polygon (one of
+   * the POLYTXT_??? flags). POLYTXT_LIGHTMAP is default.
+   * This function is guaranteed not to do anything if the type is
+   * already correct.
+   */
+  void SetTextureType (int type);
+
+  /**
+   * Get the polygon texture type (one of POLYTXT_XXX values).
+   */
+  int GetTextureType ()
+  { return txt_info->GetTextureType (); }
+
+  /**
+   * Copy texture type settings from another polygon.
+   * (this will not copy the actual material that is used, just the
+   * information on how to apply that material to the polygon).
+   */
+  void CopyTextureType (iPolygon3D* other_polygon);
+
+  /**
+   * Get the general texture type information structure.
+   */
+  csPolyTexType *GetTextureTypeInfo () { return txt_info; }
+
+  /**
+   * This is a conveniance function to get the lightmap information
+   * structure. If this polygon is not POLYTXT_LIGHTMAP it will return NULL.
+   */
+  csPolyTexLightMap *GetLightMapInfo ()
+  {
+    if (txt_info && txt_info->GetTextureType () == POLYTXT_LIGHTMAP)
+      return (csPolyTexLightMap *)txt_info;
+    else
+      return NULL;
+  }
+
+  /**
+   * This is a conveniance function to get the gouraud information
+   * structure. If this polygon is not POLYTXT_GOURAUD it will return NULL.
+   */
+  csPolyTexGouraud *GetGouraudInfo ()
+  {
+    if (txt_info && txt_info->GetTextureType () == POLYTXT_GOURAUD)
+      return (csPolyTexGouraud*)txt_info;
+    else
+      return NULL;
+  }
+
+  /**
+   * This is a conveniance function to get the flat shaded information
+   * structure. If this polygon is not POLYTXT_FLAT or POLYTXT_GOURAUD
+   * it will return NULL, GOURAUD is derived from the FLAT structure.
+   */
+  csPolyTexFlat *GetFlatInfo ()
+  {
+    if (txt_info
+     && (txt_info->GetTextureType () == POLYTXT_FLAT
+      || txt_info->GetTextureType () == POLYTXT_GOURAUD))
+      return (csPolyTexFlat*)txt_info;
+    else
+      return NULL;
+  }
+
+  /**
+   * This is a conveniance function to get the "type" texturing type
+   * information structure. It returns NULL only if the polygon texture
+   * type is lightmapped, because all other texturing types are subclassed
+   * from NONE.
+   */
+  csPolyTexType *GetNoTexInfo ()
+  {
+    if (txt_info && txt_info->GetTextureType () != POLYTXT_LIGHTMAP)
+      return (csPolyTexType *)txt_info;
+    else
+      return NULL;
+  }
+
+  /**
+   * Clear the polygon (remove all vertices).
+   */
+  void Reset ();
+
+  /**
+   * Add a vertex from the container (polygonset) to the polygon.
+   */
+  int AddVertex (int v);
+
+  /**
+   * Add a vertex to the polygon (and containing thing).
+   * Note that it will not check if the vertex is already there.
+   * After adding all vertices/polygons you should call
+   * CompressVertices() to safe space and gain
+   * efficiency.
+   */
+  int AddVertex (const csVector3& v);
+
+  /**
+   * Add a vertex to the polygon (and containing thing).
+   * Note that it will not check if the vertex is already there.
+   * After adding all vertices/polygons you should call
+   * CompressVertices() to safe space and gain
+   * efficiency.
+   */
+  int AddVertex (float x, float y, float z);
+
+  /**
+   * Precompute the plane normal. Normally this is done automatically by
+   * set_texture_space but if needed you can call this function again when
+   * something has changed.
+   */
+  void ComputeNormal ();
+
+  /**
+   * After the plane normal and the texture matrices have been set
+   * up this routine makes some needed pre-calculations for this polygon.
+   * It will create a texture space bounding box that
+   * is going to be used for lighting and the texture cache.
+   * Then it will allocate the light map tables for this polygons.
+   * You also need to call this function if you make a copy of a
+   * polygon (using the copy constructor) or if you change the vertices
+   * in a polygon.
+   */
+  void Finish ();
+
+  /**
+   * If the polygon is a portal this will set the sector
+   * that this portal points to. If this polygon has no portal
+   * one will be created.
+   * If 'null' is true and sector == 'NULL' then a NULL portal
+   * is created.
+   */
+  void SetCSPortal (csSector* sector, bool null = false);
+
+  /**
+   * Set a pre-created portal on this polygon.
+   */
+  void SetPortal (csPortal* prt);
+
+  /**
+   * Get the portal structure (if there is one).
+   */
+  csPortal* GetPortal () { return portal; }
+
+  /**
+   * Set the thing that this polygon belongs to.
+   */
+  void SetParent (csThing* thing);
+
+  /**
+   * Get the polygonset (container) that this polygons belongs to.
+   */
+  csThing* GetParent () { return thing; }
+
+  /**
+   * Return the plane of this polygon.  This function returns a 3D engine type
+   * csPolyPlane which encapsulates object, world, and camera space planes as
+   * well as the texture transformation.
+   */
+  csPolyPlane* GetPlane () { return plane; }
+
+  /**
+   * Return the world-space plane of this polygon.
+   */
+  csPlane3* GetPolyPlane () { return &plane->GetWorldPlane (); }
+
+  /**
+   * Get the vertices.
+   */
+  csPolyIndexed& GetVertices () { return vertices; }
+
+  /**
+   * Get number of vertices (required for csPolygonInt).
+   */
+  virtual int GetVertexCount () { return vertices.GetVertexCount (); }
+
+  /**
+   * Get vertex index table (required for csPolygonInt).
+   */
+  virtual int* GetVertexIndices () { return vertices.GetVertexIndices (); }
+
+  /**
+   * Set the warping transformation for the portal.
+   * If there is no portal this function does nothing.
+   */
+  void SetWarp (const csTransform& t) { if (portal) portal->SetWarp (t); }
+
+  /**
+   * Set the warping transformation for the portal.
+   * If there is no portal this function does nothing.
+   */
+  void SetWarp (const csMatrix3& m_w, const csVector3& v_w_before,
+  	const csVector3& v_w_after)
+  {
+    if (portal) portal->SetWarp (m_w, v_w_before, v_w_after);
+  }
+
+  /**
+   * 'idx' is a local index into the vertices table of the polygon.
+   * This index is translated to the index in the parent container and
+   * a reference to the vertex in world-space is returned.
+   */
+  const csVector3& Vwor (int idx) const
+  { return thing->Vwor (vertices.GetVertexIndices ()[idx]); }
+
+  /**
+   * 'idx' is a local index into the vertices table of the polygon.
+   * This index is translated to the index in the parent container and
+   * a reference to the vertex in object-space is returned.
+   */
+  const csVector3& Vobj (int idx) const
+  { return thing->Vobj (vertices.GetVertexIndices ()[idx]); }
+
+  /**
+   * 'idx' is a local index into the vertices table of the polygon.
+   * This index is translated to the index in the parent container and
+   * a reference to the vertex in camera-space is returned.
+   */
+  const csVector3& Vcam (int idx) const
+  { return thing->Vcam (vertices.GetVertexIndices ()[idx]); }
+
+  /**
+   * Before calling a series of Vcam() you should call
+   * UpdateTransformation() first to make sure that the camera vertex set
+   * is up-to-date.
+   */
+  void UpdateTransformation (const csTransform& c, long cam_cameranr)
+  {
+    thing->UpdateTransformation (c, cam_cameranr);
+  }
+
+  /**
+   * Before calling a series of Vwor() you should call
+   * WorUpdate() first to make sure that the world vertex set
+   * is up-to-date.
+   */
+  void WorUpdate () { thing->WorUpdate (); }
+
+  /**
+   * Set the material for this polygon.
+   * This material handle will only be used as soon as 'Finish()'
+   * is called. So you can safely wait preparing the materials
+   * until finally csEngine::Prepare() is called (which in the end
+   * calls Finish() for every polygon).
+   */
+  void SetMaterial (csMaterialWrapper* material);
+
+  /**
+   * Get the material.
+   */
+  csMaterialWrapper* GetMaterialWrapper () { return material; }
+
+  /**
+   * Return true if this polygon or the texture it uses is transparent.
+   */
+  bool IsTransparent ();
+
+  /// Calculates the area of the polygon in object space.
+  float GetArea ();
+
+  /**
+   * Get the cosinus factor. This factor is used
+   * for lighting.
+   */
+  float GetCosinusFactor () { return light_info.cosinus_factor; }
+
+  /**
+   * Set the cosinus factor. This factor is used
+   * for lighting.
+   */
+  void SetCosinusFactor (float f) { light_info.cosinus_factor = f; }
+
+  /**
+   * One of the SetTextureSpace functions should be called after
+   * adding all vertices to the polygon (not before) and before
+   * doing any processing on the polygon (not after)!
+   * It makes sure that the plane normal is correctly computed and
+   * the texture and plane are correctly initialized.
+   *<p>
+   * Internally the transformation from 3D to texture space is
+   * represented by a matrix and a vector. You can supply this
+   * matrix directly or let it be calculated from other parameters.
+   * If you supply another Polygon or a csPolyPlane to this function
+   * it will automatically share the plane.
+   *<p>
+   * This version copies the plane from the other polygon. The plane
+   * is shared with that other plane and this allows the engine to
+   * do some optimizations. This polygon is not responsible for
+   * cleaning this plane.
+   */
+  void SetTextureSpace (csPolygon3D* copy_from);
+
+  /**
+   * This version takes the given plane. Using this function you
+   * can use the same plane for several polygons. This polygon
+   * is not responsible for cleaning this plane.
+   */
+  void SetTextureSpace (csPolyTxtPlane* txt_pl);
+
+  /**
+   * Set the texture space transformation given three vertices and
+   * their uv coordinates.
+   */
+  void SetTextureSpace (
+  	const csVector3& p1, const csVector2& uv1,
+  	const csVector3& p2, const csVector2& uv2,
+  	const csVector3& p3, const csVector2& uv3);
+
+  /**
+   * Calculate the matrix using two vertices (which are preferably on the
+   * plane of the polygon and are possibly (but not necessarily) two vertices
+   * of the polygon). The first vertex is seen as the origin and the second
+   * as the u-axis of the texture space coordinate system. The v-axis is
+   * calculated on the plane of the polygon and orthogonal to the given
+   * u-axis. The length of the u-axis and the v-axis is given as the 'len1'
+   * parameter.
+   *<p>
+   * For example, if 'len1' is equal to 2 this means that texture will be
+   * tiled exactly two times between vertex 'v_orig' and 'v1'.
+   *<p>
+   * I hope this explanation is clear since I can't seem to make it
+   * any clearer :-)
+   */
+  void SetTextureSpace (const csVector3& v_orig,
+    const csVector3& v1, float len1);
+
+  /**
+   * Calculate the matrix using two vertices (which are preferably on the
+   * plane of the polygon and are possibly (but not necessarily) two vertices
+   * of the polygon). The first vertex is seen as the origin and the second
+   * as the u-axis of the texture space coordinate system. The v-axis is
+   * calculated on the plane of the polygon and orthogonal to the given
+   * u-axis. The length of the u-axis and the v-axis is given as the 'len1'
+   * parameter.
+   */
+  void SetTextureSpace (
+    float xo, float yo, float zo,
+    float x1, float y1, float z1, float len1);
+
+  /**
+   * Calculate the matrix using 'v1' and 'len1' for the u-axis and
+   * 'v2' and 'len2' for the v-axis.
+   */
+  void SetTextureSpace (
+    const csVector3& v_orig,
+    const csVector3& v1, float len1,
+    const csVector3& v2, float len2);
+
+  /**
+   * The same but all in floats.
+   */
+  void SetTextureSpace (
+    float xo, float yo, float zo,
+    float x1, float y1, float z1, float len1,
+    float x2, float y2, float z2, float len2);
+
+  /**
+   * The most general function. With these you provide the matrix
+   * directly.
+   */
+  void SetTextureSpace (csMatrix3 const&, csVector3 const&);
+
+  /// Return the pointer to the original polygon (before any BSP splits).
+  csPolygonInt* GetUnsplitPolygon () { return orig_poly; }
+
+  /**
+   * Return the pointer to the original polygon (before any BSP splits).
+   * If polygon was not split this will return current poly.
+   */
+  csPolygon3D* GetBasePolygon ()
+  { return orig_poly ? (csPolygon3D*)orig_poly : this; }
+
+  /**
+   * A dynamic light has changed (this can be either an
+   * intensity/color change of a pseudo-dynamic light or else
+   * a real dynamic light change).
+   */
+  void MakeDirtyDynamicLights ();
+
+  /// Return true if polygon is dirty for dynamic lights.
+  bool IsDirty () { return light_info.dyn_dirty; }
+
+  /// Make clean again.
+  void MakeCleanDynamicLights () { light_info.dyn_dirty = false; }
+
+  /**
+   * Unlink a light patch from the light patch list.
+   * Warning! This function does not test if the light patch
+   * is really on the list!
+   */
+  void UnlinkLightpatch (csLightPatch* lp);
+
+  /**
+   * Add a light patch to the light patch list.
+   */
+  void AddLightpatch (csLightPatch *lp);
+
+  /**
+   * Get the list of light patches for this polygon.
+   */
+  csLightPatch* GetLightpatches () { return light_info.lightpatches; }
+
+  /**
+   * Clip a polygon against a plane (in camera space).
+   * The plane is defined as going through v1, v2, and (0,0,0).
+   * The 'verts' array is modified and 'num' is also modified if needed.
+   */
+  void ClipPolyPlane (csVector3* verts, int* num, bool mirror,
+  	csVector3& v1, csVector3& v2);
+
+  /**
+   * Initialize the lightmaps for this polygon.
+   * Should be called before calling CalculateLighting() and before
+   * calling WriteToCache().
+   */
+  void InitializeDefault ();
+
+  /**
+   * This function will try to read the lightmap from the
+   * cache in the level archive.
+   * If do_cache == false this function will not try to read the lightmap
+   * from the cache.
+   */
+  bool ReadFromCache (iCacheManager* cache_mgr, int id);
+
+  /**
+   * Call after calling InitializeDefault() and CalculateLighting to cache
+   * the calculated lightmap to the level archive. This function does
+   * nothing if the cached lightmap was already up-to-date.
+   */
+  bool WriteToCache (iCacheManager* cache_mgr, int id);
+
+  /**
+   * Prepare the lightmaps for use.
+   * This function also converts the lightmaps to the correct
+   * format required by the 3D driver. This function does NOT
+   * create the first lightmap. This is done by the precalculated
+   * lighting process (using CalculateLighting()).
+   */
+  void PrepareLighting ();
+
+  /**
+   * Fill the lightmap of this polygon according to the given light and
+   * the frustum. The light is given in world space coordinates. The
+   * view frustum is given in camera space (with (0,0,0) the origin
+   * of the frustum). The camera space used is just world space translated
+   * so that the center of the light is at (0,0,0).
+   * If the lightmaps were cached in the level archive this function will
+   * do nothing.
+   * The "frustum" parameter defines the original light frustum (not the
+   * one bounded by this polygon as given by "lview").
+   */
+  void FillLightMapDynamic (csFrustumView& lview);
+
+  /**
+   * Fill the lightmap of this polygon according to the given light and
+   * the frustum. The light is given in world space coordinates. The
+   * view frustum is given in camera space (with (0,0,0) the origin
+   * of the frustum). The camera space used is just world space translated
+   * so that the center of the light is at (0,0,0).
+   * If the lightmaps were cached in the level archive this function will
+   * do nothing.<p>
+   *
+   * The "frustum" parameter defines the original light frustum (not the
+   * one bounded by this polygon as given by "lview").<p>
+   *
+   * If 'vis' == false this means that the lighting system already discovered
+   * that the polygon is totally shadowed.
+   */
+  void FillLightMapStatic (csFrustumView* lview, bool vis);
+
+  /**
+   * Update vertex lighting for this polygon. Only works if the
+   * polygon uses gouraud shading or is flat-shaded.
+   * 'dynamic' is true for a dynamic light.
+   * 'reset' is true if the light values need to be reset to 0.
+   * 'lcol' is the color of the light. It is given seperately
+   * because the color of the light may be modified by portals and
+   * other effects.<br>
+   * 'light' can be NULL in which case this function is useful
+   * for resetting dynamic light values to the static lights ('reset'
+   * must be equal to true then).
+   */
+  void UpdateVertexLighting (iLight* light, const csColor& lcol,
+  	bool dynamic, bool reset);
+
+  /**
+   * Check all shadow frustums and mark all relevant ones. A shadow
+   * frustum is relevant if it is (partially) inside the light frustum
+   * and if it is not obscured by other shadow frustums.
+   * In addition to the checking above this routine will return false
+   * if it can find a shadow frustum which totally obscures the light
+   * frustum. In this case it makes no sense to continue lighting the
+   * polygon.<br>
+   * This function will also discard all shadow frustums which start at
+   * the same plane as the given plane.
+   */
+  bool MarkRelevantShadowFrustums (csFrustumView& lview, csPlane3& plane);
+
+  /**
+   * Same as above but takes polygon plane as 'plane' argument.
+   */
+  bool MarkRelevantShadowFrustums (csFrustumView& lview);
+
+  /**
+   * Check visibility of this polygon with the given csFrustumView
+   * and update the light patches if needed.
+   * This function will also traverse through a portal if so needed.
+   * This version is for dynamic lighting.
+   */
+  void CalculateLightingDynamic (csFrustumView* lview);
+
+  /**
+   * Check visibility of this polygon with the given csFrustumView
+   * and fill the lightmap if needed (this function calls FillLightMap ()).
+   * This function will also traverse through a portal if so needed.
+   * If 'vis' == false this means that the lighting system already discovered
+   * that the polygon is totally shadowed.
+   * This version is for static lighting.
+   */
+  void CalculateLightingStatic (csFrustumView* lview, bool vis);
+
+  /**
+   * Transform the plane of this polygon from object space to world space.
+   * 'vt' is a vertex of this polygon in world space.
+   */
+  void ObjectToWorld (const csReversibleTransform& t, const csVector3& vwor);
+
+  /**
+   * Hard transform the plane of this polygon and also the
+   * portal and lightmap info. This is similar to ObjectToWorld
+   * but it does a hard transform of the object space planes
+   * instead of keeping a transformation.
+   */
+  void HardTransform (const csReversibleTransform& t);
+
+  /**
+   * Clip this camera space polygon to the given plane. 'plane' can be NULL
+   * in which case no clipping happens.<p>
+   *
+   * If this function returns false then the polygon is not visible (backface
+   * culling, no visible vertices, ...) and 'verts' will be NULL. Otherwise
+   * this function will return true and 'verts' will point to the new
+   * clipped polygon (this is a pointer to a static table of vertices.
+   * WARNING! Because of this you cannot do new ClipToPlane calls until
+   * you have processed the 'verts' array!).<p>
+   *
+   * If 'cw' is true the polygon has to be oriented clockwise in order to be
+   * visible. Otherwise it is the other way around.
+   */
+  bool ClipToPlane (csPlane3* portal_plane, const csVector3& v_w2c,
+  	csVector3*& pverts, int& num_verts, bool cw = true);
+
+  /**
+   * This is the link between csPolygon3D and csPolygon2D (see below for
+   * more info about csPolygon2D). It should be used after the parent
+   * container has been transformed from world to camera space.
+   * It will fill the given csPolygon2D with a perspective corrected
+   * polygon that is also clipped to the view plane (Z=SMALL_Z).
+   * If all vertices are behind the view plane the polygon will not
+   * be visible and it will return false.
+   * 'do_perspective' will also do back-face culling and returns false
+   * if the polygon is not visible because of this.
+   * If the polygon is deemed to be visible it will return true.
+   */
+  bool DoPerspective (const csTransform& trans, csVector3* source,
+  	int num_verts, csPolygon2D* dest, csVector2* orig_triangle,
+	bool mirror);
+
+  /**
+   * Classify this polygon with regards to a plane (in object space).  If this
+   * poly is on same plane it returns CS_POL_SAME_PLANE.  If this poly is
+   * completely in front of the given plane it returnes CS_POL_FRONT.  If this
+   * poly is completely back of the given plane it returnes CS_POL_BACK.
+   * Otherwise it returns CS_POL_SPLIT_NEEDED.
+   */
+  virtual int Classify (const csPlane3& pl);
+
+  /// Same as Classify() but for X plane only.
+  virtual int ClassifyX (float x);
+
+  /// Same as Classify() but for Y plane only.
+  virtual int ClassifyY (float y);
+
+  /// Same as Classify() but for Z plane only.
+  virtual int ClassifyZ (float z);
+
+  /**
+   * Split this polygon with the given plane (A,B,C,D) and return the
+   * two resulting new polygons in 'front' and 'back'. The new polygons will
+   * mimic the behaviour of the parent polygon as good as possible.
+   * This function is mainly used by the BSP splitter. Note that splitting
+   * happens in object space.
+   */
+  virtual void SplitWithPlane (csPolygonInt** front, csPolygonInt** back,
+  	const csPlane3& plane);
+
+  /**
+   * Check if this polygon (partially) overlaps the other polygon
+   * from some viewpoint in space. This function works in object space.
+   */
+  virtual bool Overlaps (csPolygonInt* overlapped);
+
+  /**
+   * Return 1 to indicate to the BSP tree routines that
+   * this is a csPolygon3D.
+   */
+  virtual int GetType () { return 1; }
+
+  /**
+   * Intersect object-space segment with this polygon. Return
+   * true if it intersects and the intersection point in world coordinates.
+   */
+  bool IntersectSegment (const csVector3& start, const csVector3& end,
+                          csVector3& isect, float* pr = NULL);
+
+  /**
+   * Intersect object-space ray with this polygon. This function
+   * is similar to IntersectSegment except that it doesn't keep the lenght
+   * of the ray in account. It just tests if the ray intersects with the
+   * interior of the polygon. Note that this function also does back-face
+   * culling.
+   */
+  bool IntersectRay (const csVector3& start, const csVector3& end);
+
+  /**
+   * Intersect object-space ray with this polygon. This function
+   * is similar to IntersectSegment except that it doesn't keep the lenght
+   * of the ray in account. It just tests if the ray intersects with the
+   * interior of the polygon. Note that this function doesn't do
+   * back-face culling.
+   */
+  bool IntersectRayNoBackFace (const csVector3& start, const csVector3& end);
+
+  /**
+   * Intersect object space ray with the plane of this polygon and
+   * returns the intersection point. This function does not test if the
+   * intersection is inside the polygon. It just returns the intersection
+   * with the plane (in or out). This function returns false if the ray
+   * is parallel with the plane (i.e. there is no intersection).
+   */
+  bool IntersectRayPlane (const csVector3& start, const csVector3& end,
+  	csVector3& isect);
+
+  /**
+   * This is a given point is on (or very nearly on) this polygon.
+   * Test happens in object space.
+   */
+  bool PointOnPolygon (const csVector3& v);
+
+  /// Get the alpha transparency value for this polygon.
+  virtual int GetAlpha ()
+  { return txt_info->GetAlpha (); }
+
+  /**
+   * Set the alpha transparency value for this polygon (only if
+   * it is a portal).
+   * Not all renderers support all possible values. 0, 25, 50,
+   * 75, and 100 will always work but other values may give
+   * only the closest possible to one of the above.
+   */
+  virtual void SetAlpha (int iAlpha)
+  { txt_info->SetAlpha (iAlpha); }
+
+  /// Get the material handle for the texture manager.
+  virtual iMaterialHandle *GetMaterialHandle ();
+  /// Get the handle to the polygon texture object
+  virtual iPolygonTexture *GetTexture ()
+  {
+    csPolyTexLightMap *lm = GetLightMapInfo ();
+    return lm ? lm->GetPolyTex () : (iPolygonTexture*)NULL;
+  }
+
+  /// Get next polygon in texture share list
+  csPolygon3D *GetNextShare ()
+  { return txt_share_list; }
+  /// Set next polygon in texture share list
+  void SetNextShare (csPolygon3D *next)
+  { txt_share_list = next; }
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //------------------- iPolygon3D interface implementation -------------------
+
+  struct eiPolygon3D : public iPolygon3D
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csPolygon3D);
+
+    virtual csPolygon3D *GetPrivateObject () { return scfParent; }
+    virtual iObject *QueryObject() {return scfParent;}
+    virtual iThingState *GetParent ();
+    virtual iLightMap *GetLightMap ()
+    {
+      csPolyTexLightMap *lm = scfParent->GetLightMapInfo ();
+      return lm ? lm->GetLightMap () : (iLightMap*)NULL;
+    }
+    virtual iPolygonTexture *GetTexture () { return scfParent->GetTexture(); }
+    virtual iMaterialHandle *GetMaterialHandle ()
+    { return scfParent->GetMaterialHandle (); }
+    virtual void SetMaterial (iMaterialWrapper* mat)
+    {
+      scfParent->SetMaterial (
+        ((csMaterialWrapper::MaterialWrapper*)(mat))->scfParent);
+    }
+    virtual iMaterialWrapper* GetMaterial ()
+    {
+      // @@@ Not efficient. In future we need to store iMaterialWrapper
+      // directly.
+      if (!scfParent->GetMaterialWrapper ()) return NULL;
+      else
+      {
+        iMaterialWrapper* wrap = SCF_QUERY_INTERFACE (
+	  scfParent->GetMaterialWrapper (), iMaterialWrapper);
+        wrap->DecRef ();
+	return wrap;
+      }
+    }
+
+    virtual int GetVertexCount ()
+    { return scfParent->vertices.GetVertexCount (); }
+    virtual int* GetVertexIndices ()
+    { return scfParent->vertices.GetVertexIndices (); }
+    virtual const csVector3 &GetVertex (int idx) const
+    { return scfParent->Vobj (idx); }
+    virtual const csVector3 &GetVertexW (int idx) const
+    { return scfParent->Vwor (idx); }
+    virtual const csVector3 &GetVertexC (int idx) const
+    { return scfParent->Vcam (idx); }
+    virtual int CreateVertex (int idx)
+    { return scfParent->AddVertex (idx); }
+    virtual int CreateVertex (const csVector3 &iVertex)
+    { return scfParent->AddVertex (iVertex); }
+
+    virtual int GetAlpha ()
+    { return scfParent->GetAlpha (); }
+    virtual void SetAlpha (int iAlpha)
+    { scfParent->SetAlpha (iAlpha); }
+
+    virtual void CreatePlane (const csVector3 &iOrigin,
+      const csMatrix3 &iMatrix);
+    virtual bool SetPlane (const char *iName);
+
+    virtual csFlags& GetFlags ()
+    { return scfParent->flags; }
+
+    virtual void SetLightingMode (bool iGouraud)
+    { scfParent->SetTextureType(iGouraud ? POLYTXT_GOURAUD:POLYTXT_LIGHTMAP); }
+
+    virtual iPortal* CreateNullPortal ()
+    {
+      scfParent->SetCSPortal (NULL, true);
+      return &(scfParent->GetPortal ()->scfiPortal);
+    }
+    virtual iPortal* CreatePortal (iSector *iTarget)
+    {
+      scfParent->SetCSPortal (iTarget->GetPrivateObject ());
+      return &(scfParent->GetPortal ()->scfiPortal);
+    }
+    virtual iPortal* GetPortal ()
+    {
+      csPortal* prt = scfParent->GetPortal ();
+      if (prt)
+        return &(prt->scfiPortal);
+      else
+        return NULL;
+    }
+
+    virtual void SetTextureSpace (
+  	const csVector3& p1, const csVector2& uv1,
+  	const csVector3& p2, const csVector2& uv2,
+  	const csVector3& p3, const csVector2& uv3)
+    {
+      scfParent->SetTextureSpace (p1, uv1, p2, uv2, p3, uv3);
+    }
+    virtual void SetTextureSpace (const csVector3& v_orig,
+      const csVector3& v1, float l1)
+    {
+      scfParent->SetTextureSpace (v_orig, v1, l1);
+    }
+    virtual void SetTextureSpace (
+        const csVector3& v_orig,
+        const csVector3& v1, float len1,
+        const csVector3& v2, float len2)
+    {
+      scfParent->SetTextureSpace (v_orig, v1, len1, v2, len2);
+    }
+    virtual void SetTextureSpace (csMatrix3 const& m, csVector3 const& v)
+    {
+      scfParent->SetTextureSpace (m, v);
+    }
+    virtual void SetTextureSpace (iPolyTxtPlane* plane);
+
+    virtual void SetTextureType (int type)
+    {
+      scfParent->SetTextureType (type);
+    }
+    virtual int GetTextureType ()
+    {
+      return scfParent->GetTextureType ();
+    }
+    virtual void CopyTextureType (iPolygon3D* other_polygon)
+    {
+      scfParent->CopyTextureType (other_polygon);
+    }
+
+    virtual const csPlane3& GetWorldPlane ()
+    {
+      return scfParent->plane->GetWorldPlane ();
+    }
+    virtual const csPlane3& GetObjectPlane ()
+    {
+      return scfParent->plane->GetObjectPlane ();
+    }
+    virtual const csPlane3& GetCameraPlane ()
+    {
+      return scfParent->plane->GetCameraPlane ();
+    }
+    virtual bool IsTransparent ()
+    {
+      return scfParent->IsTransparent ();
+    }
+    virtual float GetCosinusFactor ()
+    {
+      return scfParent->GetCosinusFactor ();
+    }
+    virtual void SetCosinusFactor (float cosfact)
+    {
+      scfParent->SetCosinusFactor (cosfact);
+    }
+    virtual iPolyTexType* GetPolyTexType ();
+    virtual void UpdateVertexLighting (iLight* light, const csColor& lcol,
+  	bool dynamic, bool reset)
+    {
+      scfParent->UpdateVertexLighting (light, lcol, dynamic, reset);
+    }
+    virtual unsigned long GetPolygonID ()
+    {
+      return scfParent->GetPolygonID ();
+    }
+    virtual bool IntersectSegment (const csVector3& start, const csVector3& end,
+                          csVector3& isect, float* pr = NULL)
+    {
+      return scfParent->IntersectSegment (start, end, isect, pr);
+    }
+    virtual bool IntersectRay (const csVector3& start, const csVector3& end)
+    {
+      return scfParent->IntersectRay (start, end);
+    }
+    virtual bool IntersectRayNoBackFace (const csVector3& start,
+      const csVector3& end)
+    {
+      return scfParent->IntersectRayNoBackFace (start, end);
+    }
+    virtual bool IntersectRayPlane (const csVector3& start,
+      const csVector3& end, csVector3& isect)
+    {
+      return scfParent->IntersectRayPlane (start, end, isect);
+    }
+    virtual bool PointOnPolygon (const csVector3& v)
+    {
+      return scfParent->PointOnPolygon (v);
+    }
+  } scfiPolygon3D;
+  friend struct eiPolygon3D;
+};
+
+#endif // __CS_POLYGON_H__
diff --git a/client/client94/crystalspace/include/csengine/polyint.h b/client/client94/crystalspace/include/csengine/polyint.h
new file mode 100644
index 0000000..9ca47f8
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/polyint.h
@@ -0,0 +1,349 @@
+/*
+    Copyright (C) 1998-2000 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_POLYINT_H__
+#define __CS_POLYINT_H__
+
+#include "csgeom/math3d.h"
+#include "csgeom/poly3d.h"
+
+class csPolygonIntPool;
+
+/**
+ * This class indicates what methods a class should use in order
+ * to be a 'polygon'. It acts as an 'interface' in JAVA terminology.
+ * There is no data in this class and no method implementations.<p>
+ *
+ * The BSP tree implementation is an example of a class that
+ * uses this csPolygonInt interface. The consequence of this is that
+ * the BSP tree can be used for several sorts of polygons (even
+ * 3D or 2D ones). The csOctree class also uses csPolygonInt.
+ */
+class csPolygonInt
+{
+  friend class csPolygonIntPool;
+
+private:
+  // Reference counter.
+  int ref_count;
+
+public:
+  /// Constructor. Init ref counter to 1.
+  csPolygonInt () { ref_count = 1; }
+
+  /**
+   * Increase the reference counter in this csPolygonInt.
+   */
+  void IncRefCount () { ref_count++; }
+
+  /**
+   * Decrease the reference counter. This function returns
+   * false as soon as the reference counter reaches zero.
+   * The object is NOT deleted automatically in that case.
+   */
+  bool DecRefCount () { ref_count--; return ref_count > 0; }
+
+  /**
+   * Return false if object is not referenced.
+   */
+  bool IsReferenced () { return ref_count > 0; }
+
+  /**
+   * Return the plane of this polygon.
+   */
+  virtual csPlane3* GetPolyPlane () = 0;
+
+  /**
+   * Classify this polygon with regards to a plane (in world space).  If this
+   * poly is on same plane it returns CS_POL_SAME_PLANE.  If this poly is
+   * completely in front of the given plane it returnes CS_POL_FRONT.  If this
+   * poly is completely back of the given plane it returnes CS_POL_BACK.
+   * Otherwise it returns CS_POL_SPLIT_NEEDED.
+   */
+  virtual int Classify (const csPlane3& pl) = 0;
+
+  /**
+   * Classify to X plane. The default implementation just calls Classify()
+   * above with a constructed plane but this function can be overridden
+   * for more efficiency.
+   */
+  virtual int ClassifyX (float x) { return Classify (csPlane3 (1, 0, 0, -x)); }
+
+  /**
+   * Classify to Y plane. The default implementation just calls Classify()
+   * above with a constructed plane but this function can be overridden
+   * for more efficiency.
+   */
+  virtual int ClassifyY (float y) { return Classify (csPlane3 (0, 1, 0, -y)); }
+
+  /**
+   * Classify to Z plane. The default implementation just calls Classify()
+   * above with a constructed plane but this function can be overridden
+   * for more efficiency.
+   */
+  virtual int ClassifyZ (float z) { return Classify (csPlane3 (0, 0, 1, -z)); }
+
+  /**
+   * Split this polygon with the given plane (A,B,C,D) and return the
+   * two resulting new polygons in 'front' and 'back'. The new polygons will
+   * mimic the behaviour of the parent polygon as good as possible.
+   * Note that the 'front' should be the negative side of the plane
+   * and 'back' the positive side.
+   */
+  virtual void SplitWithPlane (csPolygonInt** front, csPolygonInt** back,
+  	const csPlane3& plane) = 0;
+
+  /**
+   * Split this polygon with the X plane. Default implementation just
+   * calls SplitWithPlane() with a constructed plane but this function
+   * can be overridden for more efficiency.
+   */
+  virtual void SplitWithPlaneX (csPolygonInt** front, csPolygonInt** back,
+  	float x)
+  {
+    SplitWithPlane (front, back, csPlane3 (1, 0, 0, -x));
+  }
+
+  /**
+   * Split this polygon with the Y plane. Default implementation just
+   * calls SplitWithPlane() with a constructed plane but this function
+   * can be overridden for more efficiency.
+   */
+  virtual void SplitWithPlaneY (csPolygonInt** front, csPolygonInt** back,
+  	float y)
+  {
+    SplitWithPlane (front, back, csPlane3 (0, 1, 0, -y));
+  }
+
+  /**
+   * Split this polygon with the Z plane. Default implementation just
+   * calls SplitWithPlane() with a constructed plane but this function
+   * can be overridden for more efficiency.
+   */
+  virtual void SplitWithPlaneZ (csPolygonInt** front, csPolygonInt** back,
+  	float z)
+  {
+    SplitWithPlane (front, back, csPlane3 (0, 0, 1, -z));
+  }
+
+  /**
+   * Return some type-id which BSP visitors can use for their
+   * own purpose. The purpose of this is to allow several different
+   * types of polygons to be added to the same tree. With this number
+   * you can recognize them.
+   */
+  virtual int GetType () = 0;
+
+  /**
+   * Get number of vertices for this polygon.
+   */
+  virtual int GetVertexCount () = 0;
+
+  /**
+   * Get pointer to array of vertex indices.
+   */
+  virtual int* GetVertexIndices () = 0;
+
+  /**
+   * If known and if there is any, return the pointer to
+   * the original unsplit polygon.
+   */
+  virtual csPolygonInt* GetUnsplitPolygon () = 0;
+
+  /**
+   * Compare this polygon to the other one. If there exists
+   * a position in space where this polygon would overlap the other
+   * then return true. The other polygon is not guaranteed to
+   * have the same type but it is guaranteed to be part of the
+   * same set of added polygon then this one. So the type should
+   * always be known.
+   */
+  virtual bool Overlaps (csPolygonInt* overlapped) = 0;
+};
+
+/**
+ * An array of csPolygonInt pointers.
+ */
+class csPolygonIntArray
+{
+private:
+  /// Array.
+  csPolygonInt** polygons;
+  ///
+  int num;
+  ///
+  int max;
+
+public:
+  /// Constructor. Initialize empty array.
+  csPolygonIntArray ();
+
+  /**
+   * Destructor. The list of polygons is removed
+   * but NOT the polygons themselves.
+   */
+  ~csPolygonIntArray ();
+
+  /// Reset the array to empty.
+  void Reset () { num = 0; }
+
+  /// Add a polygon.
+  void AddPolygon (csPolygonInt* polygon);
+
+  /// Get polygon.
+  csPolygonInt* GetPolygon (int idx) { return polygons[idx]; }
+
+  /// Get polygons.
+  csPolygonInt** GetPolygons () { return polygons; }
+
+  /// Get number of polygons.
+  int GetPolygonCount () { return num; }
+
+  /**
+   * Set number of polygons (i.e. truncate list).
+   * The new number of polygons cannot be greater than the
+   * current number of polygons.
+   */
+  void SetPolygonCount (int n) { num = n; }
+};
+
+/**
+ * An abstract factory class to create specific instances of csPolygonInt.
+ * To create a real factory you need to subclass this factory.
+ * In addition to creation this factory also manages the reference
+ * counter and a function to initialize a given polygon as managed
+ * by this factory.
+ */
+class csPolygonIntFactory
+{
+public:
+  /// Create a csPolygonInt.
+  virtual csPolygonInt* Create () = 0;
+  /// Initialize a csPolygonInt known to this factory.
+  virtual void Init (csPolygonInt* p) = 0;
+};
+
+/**
+ * This is an object pool which holds objects of type
+ * csPolygonInt. You can ask new instances from this pool.
+ * If needed it will allocate one for you but ideally it can
+ * give you one which was allocated earlier.
+ */
+class csPolygonIntPool
+{
+private:
+  struct PoolObj
+  {
+    PoolObj* next;
+    csPolygonInt* pi;
+  };
+  /// List of allocated polygons.
+  PoolObj* alloced;
+  /// List of previously allocated, but now unused polygons.
+  PoolObj* freed;
+  /// Factory to create new polygons.
+  csPolygonIntFactory* poly_fact;
+
+public:
+  /// Create an empty pool.
+  csPolygonIntPool (csPolygonIntFactory* fact) : alloced (NULL),
+  	freed (NULL), poly_fact (fact) { }
+
+  /// Destroy pool and all objects in the pool.
+  ~csPolygonIntPool ()
+  {
+    while (alloced)
+    {
+      PoolObj* n = alloced->next;
+      //delete alloced->pi; @@@ This free is not valid!
+      // We should use a ref count on the pool itself so that we
+      // now when all objects in the pool are freed and the
+      // 'alloced' list will be empty.
+      delete alloced;
+      alloced = n;
+    }
+    while (freed)
+    {
+      PoolObj* n = freed->next;
+      if (!freed->pi->DecRefCount ()) delete freed->pi;
+      delete freed;
+      freed = n;
+    }
+  }
+
+  /**
+   * Allocate a new object in the pool.
+   */
+  csPolygonInt* Alloc ()
+  {
+    PoolObj* pnew;
+    if (freed)
+    {
+      pnew = freed;
+      freed = freed->next;
+    }
+    else
+    {
+      pnew = new PoolObj ();
+      pnew->pi = poly_fact->Create ();
+    }
+    poly_fact->Init (pnew->pi);
+    pnew->next = alloced;
+    alloced = pnew;
+    pnew->pi->ref_count = 1;
+    return pnew->pi;
+  }
+
+  /**
+   * Free an object and put it back in the pool.
+   * Note that it is only legal to free objects which were allocated
+   * from the pool.
+   */
+  void Free (csPolygonInt* pi)
+  {
+    if (pi->DecRefCount ()) return;
+    if (alloced)
+    {
+      PoolObj* po = alloced;
+      alloced = alloced->next;
+      po->pi = pi;
+      po->next = freed;
+      freed = po;
+    }
+    else
+    {
+      // Cannot happen!
+    }
+  }
+
+  /// Dump some information about this pool.
+  void Dump ()
+  {
+    int cnt;
+    cnt = 0;
+    PoolObj* po = alloced;
+    while (po) { cnt++; po = po->next; }
+    printf ("PolyInt pool: %d allocated, ", cnt);
+    cnt = 0;
+    po = freed;
+    while (po) { cnt++; po = po->next; }
+    printf ("%d freed.\n", cnt);
+  }
+};
+
+#endif // __CS_POLYINT_H__
diff --git a/client/client94/crystalspace/include/csengine/polyplan.h b/client/client94/crystalspace/include/csengine/polyplan.h
new file mode 100644
index 0000000..a04fa2d
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/polyplan.h
@@ -0,0 +1,161 @@
+/*
+    Copyright (C) 1998 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_POLYPLANE_H__
+#define __CS_POLYPLANE_H__
+
+#include "csgeom/math3d.h"
+#include "csgeom/transfrm.h"
+
+/**
+ * This class represents a polygon plane.
+ * Never 'delete' an instance of this class directly
+ * but instead call 'DecRef()'.
+ */
+class csPolyPlane
+{
+  ///
+  friend class csPolygon2D;
+  ///
+  friend class csPolyTexture;
+
+private:
+  /// The object space plane equation (this is fixed).
+  csPlane3 plane_obj;
+  /// The world space plane equation.
+  csPlane3 plane_wor;
+  /// The camera space plane equation.
+  csPlane3 plane_cam;
+  /// Reference count.
+  int ref_count;
+
+  /// Destructor is private.
+  virtual ~csPolyPlane ();
+
+public:
+  /// Constructor. Reference count is initialized to 1.
+  csPolyPlane ();
+
+  /// Maintain a reference counter for texture type objects
+  void IncRef () { ref_count++; }
+  /// Decrement usage counter
+  void DecRef () { if (!--ref_count) delete this; }
+
+  /**
+   * Transform this plane from object space to world space using
+   * the given matrices. One vertex on the plane is also given so
+   * that we can more easily recompute the 'D' component of the plane.
+   * The given vertex should be in world space.
+   */
+  void ObjectToWorld (
+  	const csReversibleTransform& obj,
+  	const csVector3& vertex1);
+
+  /**
+   * Transform this plane from world space to camera space using
+   * the given matrices. One vertex on the plane is also given so
+   * that we can more easily recompute the 'D' component of the plane.
+   * The given vertex should be in camera space.
+   */
+  void WorldToCamera (
+  	const csReversibleTransform& t,
+	const csVector3& vertex1);
+
+  /**
+   * Return the minimum squared distance from the plane to
+   * a point in 3D space (using world coordinates).
+   */
+  float SquaredDistance (csVector3& v) const
+  {
+    float d = plane_wor.Distance (v);
+    return d*d;
+  }
+
+  /**
+   * Check if this plane is nearly equal to another one in
+   * world space coordinates (it only checks on the component
+   * values. The planes are not normalized).
+   */
+  bool NearlyEqual (csPolyPlane* plane) const
+  {
+    return csMath3::PlanesEqual (plane_wor, plane->plane_wor);
+  }
+
+  /**
+   * Return the closest point on the plane to a point
+   * in 3D space (using world coordinates).
+   */
+  void ClosestPoint (csVector3& v, csVector3& isect) const;
+
+  /**
+   * Run a segment through this plane (in object space) and
+   * see where it intersects. Put value in 'pr' between 0 and 1 for
+   * position on segment (0 is at start, 1 is at end) and also
+   * put intersection point in 'isect'. Return false if there is
+   * no intersection.
+   */
+  bool IntersectSegment (const csVector3& start, const csVector3& end,
+                          csVector3& isect, float* pr) const;
+
+  /**
+   * Get the object version of the plane.
+   */
+  csPlane3& GetObjectPlane () { return plane_obj; }
+
+  /**
+   * Get the object version of the plane.
+   */
+  const csPlane3& GetObjectPlane () const { return plane_obj; }
+
+  /**
+   * Get the world version of the plane.
+   */
+  csPlane3& GetWorldPlane () { return plane_wor; }
+
+  /**
+   * Get the world version of the plane.
+   */
+  const csPlane3& GetWorldPlane () const { return plane_wor; }
+
+  /**
+   * Get the camera version of the plane.
+   */
+  csPlane3& GetCameraPlane () { return plane_cam; }
+
+  /**
+   * Get the camera version of the plane.
+   */
+  const csPlane3& GetCameraPlane () const { return plane_cam; }
+
+  /**
+   * Get the normal in object space.
+   */
+  void GetObjectNormal (float* p_A, float* p_B, float* p_C, float* p_D) const;
+
+  /**
+   * Get the normal in world space.
+   */
+  void GetWorldNormal (float* p_A, float* p_B, float* p_C, float* p_D) const;
+
+  /**
+   * Get the normal in camera space.
+   */
+  void GetCameraNormal (float* p_A, float* p_B, float* p_C, float* p_D) const;
+};
+
+#endif // __CS_POLYPLANE_H__
diff --git a/client/client94/crystalspace/include/csengine/polytext.h b/client/client94/crystalspace/include/csengine/polytext.h
new file mode 100644
index 0000000..1f60903
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/polytext.h
@@ -0,0 +1,449 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_POLYTEXT_H__
+#define __CS_POLYTEXT_H__
+
+#include "csgeom/math3d.h"
+#include "csutil/csvector.h"
+#include "csutil/cscolor.h"
+#include "imesh/thing/polygon.h"
+#include "iengine/light.h"
+
+struct iFrustumView;
+struct iMaterialHandle;
+struct iPolygon3D;
+struct iLight;
+struct csRGBpixel;
+class csPolygon3D;
+class csPolyTexture;
+class csLightMap;
+class csLightPatch;
+class csFrustumContext;
+class csFrustumView;
+class csLight;
+class csMatrix3;
+class csVector3;
+class csVector2;
+class csColor;
+
+SCF_VERSION (csLightingPolyTexQueue, 0, 0, 1);
+
+/**
+ * This is user-data for iFrustumView for the lighting process.
+ * It represents a queue holding references to csPolyTexture
+ * for all polygons that were hit by a light during the lighting
+ * process.
+ */
+struct csLightingPolyTexQueue : public iLightingProcessInfo
+{
+private:
+  // Vector containing csPolygonTexture pointers.
+  csVector polytxts;
+  // Light.
+  csLight* light;
+  // Gouraud shading alone.
+  bool gouraud_only;
+  // For dynamic lighting.
+  bool dynamic;
+  // Current lighting color.
+  csColor color;
+
+public:
+  csLightingPolyTexQueue (csLight* light, bool dynamic, bool gouraud_only);
+  virtual ~csLightingPolyTexQueue ();
+
+  /**
+   * Get the light.
+   */
+  csLight* GetCsLight () const { return light; }
+  virtual iLight* GetLight () const;
+
+  /**
+   * Get gouraud only state.
+   */
+  virtual bool GetGouraudOnly () const { return gouraud_only; }
+
+  /**
+   * Return true if dynamic.
+   */
+  virtual bool IsDynamic () const { return dynamic; }
+
+  /**
+   * Set the current color.
+   */
+  virtual void SetColor (const csColor& col) { color = col; }
+
+  /**
+   * Get the current color.
+   */
+  virtual const csColor& GetColor () const { return color; }
+
+  /**
+   * Add a csPolyTexture to the queue. Only call this when the
+   * polytexture is not already there! A csPolyTexture should be
+   * added to the queue when it gets a shadow_bitmap.
+   */
+  void AddPolyTexture (csPolyTexture* pt);
+
+  /**
+   * Update all lightmaps or shadowmaps mentioned in the queue.
+   */
+  void UpdateMaps (csLight* light, const csVector3& lightpos,
+  	const csColor& lightcolor);
+
+  SCF_DECLARE_IBASE;
+};
+
+/**
+ * This class represents a shadow-bitmap. It is used while calculating
+ * lighting for one light on a polygon. First shadows are collected on
+ * this bitmap. Later the bitmap will be used to update the lightmap.
+ */
+class csShadowBitmap
+{
+private:
+  char* light;		// Light bitmap.
+  char* shadow;		// Shadow bitmap.
+  int lm_w, lm_h;	// Original lightmap size.
+  int sb_w, sb_h;	// Shadow bitmap size.
+  int quality;		// Quality factor.
+  int cnt_unshadowed;	// Number of bits still unshadowed in 'shadow' array.
+  int cnt_unlit;	// Number of bits still unlit in 'light' array.
+  int default_light;	// Default value to use initially for light map.
+
+private:
+  /**
+   * Get the lighting level of a point in the lightmap (using lightmap
+   * coordinates). This will be a number between 1 and 0 with 1 meaning
+   * fully lit and 0 meaning fully shadowed.
+   */
+  float GetLighting (int lm_u, int lm_v);
+
+  /*
+   * For csAntialiasedPolyFill().
+   */
+  static void LightPutPixel (int x, int y, float area, void *arg);
+  static void LightDrawBox (int x, int y, int w, int h, void *arg);
+  static void ShadowPutPixel (int x, int y, float area, void *arg);
+  static void ShadowDrawBox (int x, int y, int w, int h, void *arg);
+  void _LightPutPixel (int x, int y, float area);
+  void _LightDrawBox (int x, int y, int w, int h);
+  void _ShadowPutPixel (int x, int y, float area);
+  void _ShadowDrawBox (int x, int y, int w, int h);
+
+public:
+  /**
+   * Make a new shadow bitmap of the given lightmap size and quality.
+   * Quality will be a number indicating how much we want to enhance
+   * or reduce size of this bitmap compared to the lightmap size.
+   * A quality of 0 means no change (i.e. the bitmap will hold as many
+   * shadow-points as lumels). A quality of -1 means that for every 2x2
+   * lumels there will be one shadow-point. A quality of 1 means that
+   * one lumel corresponds with 2x2 shadow-points.
+   */
+  csShadowBitmap (int lm_w, int lm_h, int quality, int default_light);
+
+  /**
+   * Destroy the shadow bitmap.
+   */
+  ~csShadowBitmap () { delete[] shadow; delete[] light; }
+
+  /**
+   * Render a polygon on this bitmap. The coordinates of this
+   * polygon are given in lightmap coordinates. WARNING the given polygon
+   * will be modified by this function!
+   * 'val' can be 0 or 1 and will be used to fill the polygon. To render
+   * a shadow you would use 1 and for light you would use 0.
+   */
+  void RenderPolygon (csVector2* poly, int num_vertices, int val);
+
+  /**
+   * Set the entire area of this bitmap to either completely shadowed
+   * (val==1) or fully lit (val==0).
+   */
+  void RenderTotal (int val);
+
+  /**
+   * Take a light and update the lightmap using the information in
+   * this shadow-bitmap.
+   * <ul>
+   * <li>lightcell_shift is the shift to scale lightmap space to
+   *     texture space (with texture space meaning 0 to real texture size).
+   * <li>The shf_u, shf_v, mul_u, and mul_v fields define how to translate
+   *     the previous texture space to uv space (where uv goes between
+   *     0 and 1 for a single texture).
+   * <li>m_t2w and v_t2w transform uv space to world space coordinates.
+   * <li>light is the light and lightpos is the position of that light (which
+   *     can be different from the position of the light given by 'light'
+   *     itself because we can have space warping).
+   * <li>lightcolor can also be different from the color of the light because
+   *     it could in principle be modified by portals.
+   * </ul>
+   */
+  void UpdateLightMap (csRGBpixel* lightmap,
+	int lightcell_shift,
+	float shf_u, float shf_v,
+	float mul_u, float mul_v,
+	const csMatrix3& m_t2w, const csVector3& v_t2w,
+	csLight* light, const csVector3& lightpos,
+	const csColor& lightcolor,
+	const csVector3& poly_normal,
+	float cosfact);
+
+  /**
+   * Take a light and update the shadowmap using the information in
+   * this shadow-bitmap.
+   * <ul>
+   * <li>lightcell_shift is the shift to scale lightmap space to
+   *     texture space (with texture space meaning 0 to real texture size).
+   * <li>The shf_u, shf_v, mul_u, and mul_v fields define how to translate
+   *     the previous texture space to uv space (where uv goes between
+   *     0 and 1 for a single texture).
+   * <li>m_t2w and v_t2w transform uv space to world space coordinates.
+   * <li>light is the light and lightpos is the position of that light (which
+   *     can be different from the position of the light given by 'light'
+   *     itself because we can have space warping).
+   * </ul>
+   */
+  void UpdateShadowMap (unsigned char* shadowmap,
+	int lightcell_shift,
+	float shf_u, float shf_v,
+	float mul_u, float mul_v,
+	const csMatrix3& m_t2w, const csVector3& v_t2w,
+	csLight* light, const csVector3& lightpos,
+	const csVector3& poly_normal,
+	float cosfact);
+
+  /**
+   * Return true if this bitmap is fully shadowed.
+   */
+  bool IsFullyShadowed () const
+  {
+    return cnt_unshadowed == 0;
+  }
+
+  /**
+   * Return true if this bitmap is fully unlit.
+   */
+  bool IsFullyUnlit () const
+  {
+    return cnt_unlit == sb_w * sb_h;
+  }
+
+  /**
+   * Return true if this bitmap is fully lit.
+   */
+  bool IsFullyLit () const
+  {
+    return cnt_unlit == 0 && (cnt_unshadowed == sb_w * sb_h);
+  }
+};
+
+
+/**
+ * This class represents a lighted texture for a polygon.
+ */
+class csPolyTexture : public iPolygonTexture
+{
+  friend class csPolygon3D;
+  friend class csPolygon2D;
+
+private:
+  /// The corresponding polygon.
+  csPolygon3D* polygon;
+  /// SCF pointer.
+  iPolygon3D* ipolygon;
+
+  /// The corresponding unlighted material.
+  iMaterialHandle* mat_handle;
+
+  /**
+   * Bounding box of corresponding polygon in 2D texture space.
+   * Note that the u-axis of this bounding box is made a power of 2 for
+   * efficiency reasons.
+   */
+  int Imin_u, Imin_v, Imax_u, Imax_v;
+
+  //@@@Fmin... Fmax... is the same for all four csPolyTexture.
+  //SHARE!
+  /// fp bounding box (0..1 texture space)
+  float Fmin_u, Fmin_v, Fmax_u, Fmax_v;
+
+  ///
+  uint16 shf_u;
+  ///
+  uint16 and_u;
+
+  /*
+   * New texture data with lighting added. This is an untiled texture
+   * so it is more efficient to draw. This texture data is allocated
+   * and maintained by the texture cache. If a PolyTexture is in the
+   * cache it will be allocated, otherwise it won't.
+   */
+
+  /// Width of lighted texture ('w' is a power of 2).
+  int w;
+
+  /// Height of lighted texture.
+  int h;
+
+  /// Original width (not a power of 2) (w_orig <= w).
+  int w_orig;
+
+  ///
+  float fdu;
+  ///
+  float fdv;
+
+  /// LightMap.
+  csLightMap* lm;
+  /**
+   * Shadow-bitmap used while doing lighting.
+   */
+  csShadowBitmap* shadow_bitmap;
+
+  /// Internally used by (software) texture cache
+  void *cache_data [4];
+
+public:
+  /**
+   * Option variable: control how much the angle of the light with the polygon
+   * it hits affects the final light value. Values ranges from -1 to 1.
+   * With -1 the polygons will get no light at all. With 0 it will be perfect
+   * cosine rule. With 1 the cosine is ignored and it will be like Crystal Space
+   * was in the past. Note that changing this value at runtime only has an
+   * effect on dynamic lights.
+   */
+  static float cfg_cosinus_factor;
+
+  ///
+  csPolyTexture ();
+  ///
+  virtual ~csPolyTexture ();
+
+  /**
+   * Set the corresponding polygon for this polytexture.
+   */
+  void SetPolygon (csPolygon3D* p);
+
+  /**
+   * Return the polygon corresponding to this texture
+   */
+  csPolygon3D *GetCSPolygon () { return polygon; }
+
+  /**
+   * Set the lightmap for this polytexture (and call IncRef()
+   * on the lightmap). Can also be used to clear the reference
+   * to the lightmap if 'lightmap' is NULL.
+   */
+  void SetLightMap (csLightMap* lightmap);
+
+  /// Get the cslightmap, for engine internal use (users see GetLightMap below)
+  csLightMap *GetCSLightMap() { return lm; }
+
+  /// Set the material to be used for this polytexture.
+  void SetMaterialHandle (iMaterialHandle* th) { mat_handle = th; }
+
+  /**
+   * Calculate the bounding box in (u,v) space for the lighted texture.
+   */
+  void CreateBoundingTextureBox ();
+
+  /**
+   * Initialize the lightmaps.
+   */
+  void InitLightMaps ();
+
+  /**
+   * Update the lightmap for the given light.
+   * 'vis' will be false if the polygon is totally shadowed. In this
+   * case we should use 'subpoly' to see where the shadow must go and
+   * not the base polygon which this csPolyTexture points too.
+   */
+  void FillLightMap (csFrustumView* lview, bool vis, csPolygon3D* subpoly);
+
+  /**
+   * Update the lightmap of this polygon using the current shadow-bitmap
+   * and the light information below.
+   */
+  void UpdateFromShadowBitmap (csLight* light, const csVector3& lightpos,
+  	const csColor& lightcolor);
+
+  /// set the dirty flag for our lightmap
+  void MakeDirtyDynamicLights ();
+
+  /**
+   * Update the real lightmap for a given csLightPatch
+   * (used for a dynamic light).
+   */
+  void ShineDynLightMap (csLightPatch* lp);
+
+  //--------------------- iPolygonTexture implementation ---------------------
+  SCF_DECLARE_IBASE;
+  ///
+  virtual iMaterialHandle *GetMaterialHandle () { return mat_handle; }
+  ///
+  virtual float GetFDU () { return fdu; }
+  ///
+  virtual float GetFDV () { return fdv; }
+  /// Get width of lighted texture (power of 2)
+  virtual int GetWidth () { return w; }
+  /// Get height of lighted texture.
+  virtual int GetHeight () { return h; }
+  ///
+  virtual int GetShiftU () { return shf_u; }
+  ///
+  virtual int GetIMinU () { return Imin_u; }
+  ///
+  virtual int GetIMinV () { return Imin_v; }
+  ///
+  virtual void GetTextureBox (float& fMinU, float& fMinV,
+  	float& fMaxU, float& fMaxV);
+  ///
+  virtual int GetOriginalWidth () { return w_orig; }
+
+  ///
+  virtual iPolygon3D *GetPolygon ()
+  {
+    return ipolygon;
+  }
+  /// Check if dynamic lighting information should be recalculated
+  virtual bool DynamicLightsDirty ();
+  /**
+   * Recalculate all pseudo and real dynamic lights if the
+   * texture is dirty. The function returns true if there
+   * was a recalculation (then the texture needs to be removed
+   * from the texture cache).
+   */
+  virtual bool RecalculateDynamicLights ();
+
+  ///
+  virtual iLightMap *GetLightMap ();
+  /// Query the size of one light cell
+  virtual int GetLightCellSize ();
+  /// Query log2 (cell size)
+  virtual int GetLightCellShift ();
+
+  /// Get data used internally by texture cache
+  virtual void *GetCacheData (int idx) { return cache_data[idx]; }
+  /// Set data used internally by texture cache
+  virtual void SetCacheData (int idx, void *d) { cache_data[idx] = d; }
+};
+
+#endif // __CS_POLYTEXT_H__
diff --git a/client/client94/crystalspace/include/csengine/polytmap.h b/client/client94/crystalspace/include/csengine/polytmap.h
new file mode 100644
index 0000000..aaaf6a5
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/polytmap.h
@@ -0,0 +1,163 @@
+/*
+    Copyright (C) 1999-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_POLYTMAP_H__
+#define __CS_POLYTMAP_H__
+
+#include "csgeom/transfrm.h"
+#include "csutil/csobject.h"
+#include "imesh/thing/polytmap.h"
+
+
+SCF_VERSION (csPolyTxtPlane, 0, 0, 1);
+
+/**
+ * This class represents a texture plane. This is a plane
+ * that defines the orientation and offset of a texture. It can
+ * be used by several polygons to let the textures fit perfectly.
+ */
+class csPolyTxtPlane : public csObject
+{
+  ///
+  friend class csPolygon2D;
+  ///
+  friend class csPolyTexture;
+
+private:
+  /// Transformation from object to texture space.
+  csMatrix3 m_obj2tex;
+  /// Translation from object to texture space.
+  csVector3 v_obj2tex;
+
+  /// Transformation from world to texture space.
+  csMatrix3 m_world2tex;
+  /// Translation from world to texture space.
+  csVector3 v_world2tex;
+
+  /// Destructor is private.
+  virtual ~csPolyTxtPlane ();
+
+public:
+  /// Constructor. Reference count is initialized to 1.
+  csPolyTxtPlane ();
+
+  /**
+   * Transform this plane from object space to world space using
+   * the given transform.
+   */
+  void ObjectToWorld (const csReversibleTransform& obj);
+
+  /**
+   * Hard transform of this plane.
+   */
+  void HardTransform (const csReversibleTransform& obj);
+
+  /**
+   * Transform this plane from world space to camera space using
+   * the given transform. The resulting transform is put in m_cam2tex
+   * and v_cam2tex.
+   */
+  void WorldToCamera (const csReversibleTransform& t,
+  	csMatrix3& m_cam2tex, csVector3& v_cam2tex);
+
+  /**
+   * Get object to texture transformation.
+   */
+  void GetObjectToTexture (csMatrix3*& m_obj2tex, csVector3*& v_obj2tex)
+  {
+    m_obj2tex = &this->m_obj2tex;
+    v_obj2tex = &this->v_obj2tex;
+  }
+
+  /**
+   * Get world to texture transformation.
+   */
+  void GetWorldToTexture (csMatrix3*& m_wor2tex, csVector3*& v_wor2tex)
+  {
+    m_wor2tex = &this->m_world2tex;
+    v_wor2tex = &this->v_world2tex;
+  }
+
+  ///
+  void SetTextureSpace (const csVector3& v_orig,
+			const csVector3& v1, float len1,
+			const csVector3& v2, float len2);
+  ///
+  void SetTextureSpace (const csPlane3& plane_wor,
+  			float xo, float yo, float zo,
+			float x1, float y1, float z1,
+			float len);
+  ///
+  void SetTextureSpace (const csPlane3& plane_wor,
+  			const csVector3& v_orig,
+  			const csVector3& v1, float len);
+  ///
+  void SetTextureSpace (const csVector3& v_orig,
+  			const csVector3& v_u,
+			const csVector3& v_v);
+  ///
+  void SetTextureSpace (float xo, float yo, float zo,
+			float xu, float yu, float zu,
+			float xv, float yv, float zv);
+  ///
+  void SetTextureSpace (float xo, float yo, float zo,
+			float xu, float yu, float zu,
+			float xv, float yv, float zv,
+			float xw, float yw, float zw);
+  ///
+  void SetTextureSpace (const csMatrix3& tx_matrix,
+  			const csVector3& tx_vector);
+
+  /// Get the transformation from object to texture space.
+  void GetTextureSpace (csMatrix3& tx_matrix, csVector3& tx_vector);
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //----------------- iPolyTxtPlane interface implementation -----------------
+  struct PolyTxtPlane : public iPolyTxtPlane
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csPolyTxtPlane);
+
+    virtual iObject *QueryObject()
+    {
+      return scfParent;
+    }
+    virtual csPolyTxtPlane* GetPrivateObject ()
+    {
+      return (csPolyTxtPlane*)scfParent;
+    }
+    virtual void SetTextureSpace (const csVector3& v_orig,
+			const csVector3& v1, float len1,
+			const csVector3& v2, float len2)
+    {
+      scfParent->SetTextureSpace (v_orig, v1, len1, v2, len2);
+    }
+    virtual void SetTextureSpace (const csMatrix3& tx_matrix,
+  			const csVector3& tx_vector)
+    {
+      scfParent->SetTextureSpace (tx_matrix, tx_vector);
+    }
+    virtual void GetTextureSpace (csMatrix3& tx_matrix, csVector3& tx_vector)
+    {
+      scfParent->GetTextureSpace (tx_matrix, tx_vector);
+    }
+  } scfiPolyTxtPlane;
+  friend struct PolyTxtPlane;
+};
+
+#endif // __CS_POLYTMAP_H__
diff --git a/client/client94/crystalspace/include/csengine/polytree.h b/client/client94/crystalspace/include/csengine/polytree.h
new file mode 100644
index 0000000..049cf67
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/polytree.h
@@ -0,0 +1,212 @@
+/*
+    Copyright (C) 2000 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_POLYTREE_H__
+#define __CS_POLYTREE_H__
+
+#include "csgeom/math3d.h"
+#include "csgeom/plane3.h"
+#include "csgeom/vector3.h"
+#include "csgeom/box.h"
+#include "csengine/arrays.h"
+
+class csThing;
+class csPolygonInt;
+class csPolygonTree;
+class csPolygonTreeNode;
+class csPolygonStub;
+class csPolyTreeBBox;
+struct iFile;
+
+
+#define NODE_OCTREE 1
+#define NODE_BSPTREE 2
+
+/**
+ * Visit a node in a polygon tree. If this function returns non-NULL
+ * the scanning will stop and the pointer will be returned.
+ * The 'same_plane' bool will be true if all polygons are on the same
+ * plane.
+ */
+typedef void* (csTreeVisitFunc)(csThing*, csPolygonInt**,
+	int num, bool same_plane, void*);
+
+/**
+ * Potentially cull a node from the tree just before it would otherwise
+ * have been traversed in Back2Front() or Front2Back().
+ * If this function returns true then the node is potentially visible.
+ */
+typedef bool (csTreeCullFunc)(csPolygonTree* tree, csPolygonTreeNode* node,
+	const csVector3& pos, void* data);
+
+/**
+ * A general node in a polygon tree.
+ */
+class csPolygonTreeNode
+{
+protected:
+  /**
+   * A linked list for all stubs that are added
+   * to this node. These stubs represents parts of an object
+   * that is located inside this node.
+   */
+  csPolygonStub* first_stub;
+
+  /**
+   * A linked list of all polygons stubs that still need to
+   * be processed whenever this node becomse visible.
+   */
+  csPolygonStub* todo_stubs;
+
+public:
+  /**
+   * Constructor.
+   */
+  csPolygonTreeNode () : first_stub (NULL), todo_stubs (NULL) { }
+
+  /**
+   * Destructor.
+   */
+  virtual ~csPolygonTreeNode ();
+
+  /// Return true if node is empty.
+  virtual bool IsEmpty () = 0;
+
+  /// Return type (NODE_???).
+  virtual int Type () = 0;
+
+  /**
+   * Unlink a stub from the stub list.
+   * Warning! This function does not test if the stub
+   * is really on the list!
+   */
+  void UnlinkStub (csPolygonStub* ps);
+
+  /**
+   * Link a stub to the todo list.
+   */
+  void LinkStubTodo (csPolygonStub* ps);
+
+  /**
+   * Link a stub to the stub list.
+   */
+  void LinkStub (csPolygonStub* ps);
+
+  /**
+   * Traverse all the polygons in the dynamic objects
+   * added to this node.
+   */
+  void* TraverseObjects (csThing* thing, const csVector3& pos,
+  	csTreeVisitFunc* func, void* data);
+};
+
+/**
+ * A general polygon tree. This is an abstract data type.
+ * Concrete implementations like csBspTree or csOctree inherit
+ * from this class.
+ */
+class csPolygonTree
+{
+protected:
+  /// The root of the tree.
+  csPolygonTreeNode* root;
+
+  /// The parent thing that this tree is made for.
+  csThing* thing;
+
+  /// Clear the nodes.
+  void Clear () { delete root; }
+
+  // Various routines to write to an iFile. Used by 'Cache'.
+  void WriteString (iFile* cf, char* str, int len);
+  void WriteBox3 (iFile* cf, const csBox3& box);
+  void WriteVector3 (iFile* cf, const csVector3& v);
+  void WritePlane3 (iFile* cf, const csPlane3& v);
+  void WriteLong (iFile* cf, long l);
+  void WriteUShort (iFile* cf, uint16 l);
+  void WriteByte (iFile* cf, unsigned char b);
+  void WriteBool (iFile* cf, bool b);
+
+  // Various routines to write from an iFile. Used by 'ReadFromCache'.
+  void ReadString (iFile* cf, char* str, int len);
+  void ReadBox3 (iFile* cf, csBox3& box);
+  void ReadVector3 (iFile* cf, csVector3& v);
+  void ReadPlane3 (iFile* cf, csPlane3& v);
+  long ReadLong (iFile* cf);
+  uint16 ReadUShort (iFile* cf);
+  unsigned char ReadByte (iFile* cf);
+  bool ReadBool (iFile* cf);
+
+public:
+  /**
+   * Constructor.
+   */
+  csPolygonTree (csThing* th) : root (NULL), thing (th) { }
+
+  /**
+   * Destructor.
+   */
+  virtual ~csPolygonTree () { }
+
+  /// Get the thing for this tree.
+  csThing* GetThing () { return thing; }
+
+  /**
+   * Create the tree with a given set of polygons.
+   */
+  virtual void Build (csPolygonInt** polygons, int num) = 0;
+
+  /**
+   * Create the tree with a given set of polygons.
+   */
+  void Build (csPolygonArray& polygons)
+  {
+    Build (polygons.GetArray (), polygons.Length ());
+  }
+
+  /**
+   * Add a dynamic object to the tree.
+   */
+  void AddObject (csPolyTreeBBox* obj);
+
+  /**
+   * Add a stub to the todo list of the tree.
+   */
+  void AddStubTodo (csPolygonStub* stub)
+  {
+    root->LinkStubTodo (stub);
+  }
+
+  /**
+   * Test if any polygon in the list overlaps any other polygon.
+   * If this function returns false we have convexity.
+   */
+  bool Overlaps (csPolygonInt** polygons, int num);
+
+  /// Traverse the tree from back to front starting at the root and 'pos'.
+  virtual void* Back2Front (const csVector3& pos, csTreeVisitFunc* func,
+  	void* data, csTreeCullFunc* cullfunc = NULL, void* culldata = NULL) = 0;
+  /// Traverse the tree from front to back starting at the root and 'pos'.
+  virtual void* Front2Back (const csVector3& pos, csTreeVisitFunc* func,
+  	void* data, csTreeCullFunc* cullfunc = NULL, void* culldata = NULL) = 0;
+
+  /// Print statistics about this tree.
+  virtual void Statistics () = 0;
+};
+
+#endif // __CS_POLYTREE_H__
diff --git a/client/client94/crystalspace/include/csengine/portal.h b/client/client94/crystalspace/include/csengine/portal.h
new file mode 100644
index 0000000..5f9dbfc
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/portal.h
@@ -0,0 +1,330 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_PORTAL_H__
+#define __CS_PORTAL_H__
+
+#include "csgeom/transfrm.h"
+#include "csutil/flags.h"
+#include "csutil/csobject.h"
+#include "imesh/thing/portal.h"
+
+class csPolygon2D;
+class csPolygon3D;
+class csStatLight;
+class csObject;
+class csMeshWrapper;
+struct iRenderView;
+struct iFrustumView;
+
+/**
+ * This class represents a portal. It belongs to some polygon
+ * which is then considered a portal to another sector.
+ */
+class csPortal : public csObject
+{
+private:
+  /// The sector that this portal points to.
+  iSector* sector;
+
+public:
+  /// Set of flags
+  csFlags flags;
+
+protected:
+  /// Warp transform in object space.
+  csReversibleTransform warp_obj;
+  /// Warp transform in world space.
+  csReversibleTransform warp_wor;
+  /// Callback when a sector is missing.
+  iPortalCallback* sector_cb;
+  /// Callback for traversing to a portal.
+  iPortalCallback* portal_cb;
+  /// Maximum number of time a single sector will be visited by this portal.
+  int max_sector_visit;
+
+  /**
+   * A portal will change the intensity/color of the light that passes
+   * through it depending on the texture.
+   */
+  iTextureHandle* filter_texture;
+
+  /**
+   * If filter_texture is NULL then this filter is used instead.
+   */
+  float filter_r, filter_g, filter_b;
+
+public:
+  /// Create a portal.
+  csPortal ();
+
+  /// Destructor.
+  virtual ~csPortal ();
+
+  //---- misc. manipulation functions ---------------------------------------
+
+  /// For iReference.
+  iReferencedObject* GetReferencedObject () const;
+
+  /// For iReference.
+  void SetReferencedObject (iReferencedObject* b);
+
+  /// Return the sector that this portal points too.
+  iSector* GetSector () const;
+
+  /**
+   * Set the sector that this portal points too. To avoid circular
+   * references, the sector is not IncRef'ed!
+   */
+  void SetSector (iSector* s);
+
+  /// Set portal flags (see CS_PORTAL_XXX values)
+  csFlags& GetFlags ();
+
+  /// Set the maximum sector visit.
+  void SetMaximumSectorVisit (int msv)
+  {
+    max_sector_visit = msv;
+  }
+
+  /// Get the maximum sector visit.
+  int GetMaximumSectorVisit () const
+  {
+    return max_sector_visit;
+  }
+
+  /// Set the portal callback.
+  void SetPortalCallback (iPortalCallback* cb);
+
+  /// Get the portal callback.
+  iPortalCallback* GetPortalCallback () const;
+
+  /// Set the missing sector callback.
+  void SetMissingSectorCallback (iPortalCallback* cb);
+
+  /// Get the missing sector callback.
+  iPortalCallback* GetMissingSectorCallback () const;
+
+  /// Set the filter texture
+  void SetFilter (iTextureHandle* ft);
+  /// Get the filter texture
+  iTextureHandle* GetTextureFilter () const;
+
+  /// Set a color filter (instead of the texture).
+  void SetFilter (float r, float g, float b);
+  /// Get the current color filter
+  void GetColorFilter (float &r, float &g, float &b) const;
+
+  //---- space warping ------------------------------------------------------
+
+  /// Get the warping transformation in object space.
+  const csReversibleTransform& GetWarp () const;
+
+  /**
+   * Set the warping transformation for this portal in object space and world
+   * space.
+   */
+  void SetWarp (const csTransform& t);
+
+  /*
+   * Set the warping transformation for this portal in object space and world
+   * space.
+   */
+  void SetWarp (const csMatrix3 &m_w, const csVector3 &v_w_before,
+    const csVector3 &v_w_after);
+
+  /// Set warping transformation to mirror
+  void SetMirror (iPolygon3D *iPoly);
+
+  /// Transform the warp matrix from object space to world space.
+  void ObjectToWorld (const csReversibleTransform& t);
+
+  /// Hard transform the warp matrix.
+  void HardTransform (const csReversibleTransform& t);
+
+  /// Warp a position in world space.
+  csVector3 Warp (const csVector3& pos) const;
+
+  /**
+   * Warp space using the given world->camera transformation.
+   * This function modifies the given camera transformation to reflect
+   * the warping change.<p>
+   *
+   * 't' is the transformation from world to camera space.<br>
+   * 'mirror' is true if the camera transformation transforms all polygons so
+   * that the vertices are ordered anti-clockwise.  'mirror' will be modified
+   * by warp_space if needed.
+   */
+  void WarpSpace (csReversibleTransform& t, bool& mirror) const;
+
+  //-------------------------------------------------------------------------
+
+  /**
+   * Draw the sector that is visible through this portal.
+   * This function can be overriden by a subclass of Portal
+   * to support portals to other types of engines.
+   * This function also takes care of space warping.<p>
+   *
+   * 'new_clipper' is the new 2D polygon to which all things drawn
+   * should be clipped.<br>
+   * 'portal_polygon' is the polygon containing this portal. This routine
+   * will use the camera space plane of the portal polygon.<br>
+   * 'rview' is the current iRenderView.<p>
+   *
+   * Return true if succesful, false otherwise.
+   * Failure to draw through a portal does not need to
+   * be harmful. It can just mean that some maximum number is
+   * reached (like the maximum number of times a certain sector
+   * can be drawn through a mirror).
+   */
+  bool Draw (csPolygon2D* new_clipper, csPolygon3D* portal_polygon,
+  	iRenderView* rview);
+
+  /**
+   * Follow a beam through this portal and return the polygon
+   * that it hits with. This function properly acounts for space
+   * warping portals and also checks for infinite recursion (does
+   * not allow traversing the same sector more than five times).
+   * Returns the intersection point with the polygon in 'isect'.
+   */
+  csPolygon3D* HitBeam (const csVector3& start, const csVector3& end,
+  	csVector3& isect);
+
+  /**
+   * Follow a beam through this portal and return the object
+   * that it hits with. This function properly acounts for space
+   * warping portals and also checks for infinite recursion (does
+   * not allow traversing the same sector more than five times).
+   * Optionally returns the polygon in 'polygonPtr'.
+   */
+  csMeshWrapper* HitBeam (const csVector3& start, const csVector3& end,
+  	csVector3& isect, csPolygon3D** polygonPtr);
+
+  /**
+   * Check if the destination sector is NULL and if so call
+   * the callback. This function returns false if the portal should
+   * not be traversed.
+   */
+  bool CompleteSector (iBase* context);
+
+  /**
+   * Check frustum visibility of all polygons reachable through this portal.
+   * Alpha is the alpha value you'd like to use to pass through this
+   * portal (0 is no completely transparent, 100 is complete opaque).
+   */
+  void CheckFrustum (iFrustumView* lview, int alpha);
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //------------------- iPortal implementation -----------------------
+  struct Portal : public iPortal
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csPortal);
+    virtual iReferencedObject* GetReferencedObject () const
+    { return scfParent->GetReferencedObject (); }
+    virtual void SetReferencedObject (iReferencedObject* b)
+    { scfParent->SetReferencedObject (b); }
+    virtual iObject *QueryObject () { return scfParent; }
+    virtual iSector* GetSector () const { return scfParent->GetSector (); }
+    virtual void SetSector (iSector* s) { scfParent->SetSector (s); }
+    virtual csFlags& GetFlags () { return scfParent->GetFlags (); }
+    virtual void SetMaximumSectorVisit (int msv)
+    {
+      scfParent->SetMaximumSectorVisit (msv);
+    }
+    virtual int GetMaximumSectorVisit () const
+    {
+      return scfParent->GetMaximumSectorVisit ();
+    }
+    virtual void SetPortalCallback (iPortalCallback* cb)
+    {
+      scfParent->SetPortalCallback (cb);
+    }
+    virtual iPortalCallback* GetPortalCallback () const
+    {
+      return scfParent->GetPortalCallback ();
+    }
+    virtual void SetMissingSectorCallback (iPortalCallback* cb)
+    {
+      scfParent->SetMissingSectorCallback (cb);
+    }
+    virtual iPortalCallback* GetMissingSectorCallback () const
+    {
+      return scfParent->GetMissingSectorCallback ();
+    }
+    virtual void SetFilter (iTextureHandle* ft)
+    {
+      scfParent->SetFilter (ft);
+    }
+    virtual iTextureHandle* GetTextureFilter () const
+    {
+      return scfParent->GetTextureFilter ();
+    }
+    virtual void SetFilter (float r, float g, float b)
+    {
+      scfParent->SetFilter (r, g, b);
+    }
+    virtual void GetColorFilter (float &r, float &g, float &b) const
+    {
+      scfParent->GetColorFilter (r, g, b);
+    }
+    virtual void SetWarp (const csMatrix3 &m_w, const csVector3 &v_w_before,
+      const csVector3 &v_w_after)
+    {
+      scfParent->SetWarp (m_w, v_w_before, v_w_after);
+    }
+    virtual void SetWarp (const csTransform& t)
+    {
+      scfParent->SetWarp (t);
+    }
+    virtual void SetMirror (iPolygon3D *iPoly)
+    {
+      scfParent->SetMirror (iPoly);
+    }
+    virtual const csReversibleTransform &GetWarp () const
+    {
+      return scfParent->GetWarp ();
+    }
+    virtual void ObjectToWorld (const csReversibleTransform& t)
+    {
+      scfParent->ObjectToWorld (t);
+    }
+    virtual void HardTransform (const csReversibleTransform& t)
+    {
+      scfParent->HardTransform (t);
+    }
+    virtual csVector3 Warp (const csVector3& pos) const
+    {
+      return scfParent->Warp (pos);
+    }
+    virtual void WarpSpace (csReversibleTransform& t, bool& mirror) const
+    {
+      scfParent->WarpSpace (t, mirror);
+    }
+    virtual bool CompleteSector (iBase* context)
+    {
+      return scfParent->CompleteSector (context);
+    }
+    virtual void CheckFrustum (iFrustumView* lview, int alpha)
+    {
+      scfParent->CheckFrustum (lview, alpha);
+    }
+  } scfiPortal;
+};
+
+#endif // __CS_PORTAL_H__
diff --git a/client/client94/crystalspace/include/csengine/radiosty.h b/client/client94/crystalspace/include/csengine/radiosty.h
new file mode 100644
index 0000000..8f6adad
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/radiosty.h
@@ -0,0 +1,656 @@
+/*
+    Copyright (C) 2000 by W.C.A. Wijngaards
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_RADIOSTY_H__
+#define __CS_RADIOSTY_H__
+
+#include "csutil/csobject.h"
+#include "csgeom/vector3.h"
+#include "csutil/cscolor.h"
+#include "csengine/polygon.h"
+#include "csengine/curve.h"
+#include "csengine/polytext.h"
+#include "csengine/lghtmap.h"
+#include "csengine/lview.h"
+
+class csEngine;
+class csPolygon3D;
+class csLightMap;
+class csRGBMap;
+class csProgressPulse;
+class csShadowFrustum;
+struct iProgressMeter;
+
+/// computes x ** (2 ** y), using only y multiplies.
+float FastPow2(float x, const int y);
+
+/**
+ * A small class encapsulating an RGB lightmap.
+ * The float version of csRGBMap
+ * Helps radiosity.
+ */
+class csRGBFloatLightMap
+{
+private:
+  int max_sizeRGB;      // Max size for every map.
+  float* map;
+
+public:
+  ///
+  void Clear ()
+  {
+    delete [] map; map = NULL;
+    max_sizeRGB = 0;
+  }
+
+  ///
+  csRGBFloatLightMap () : max_sizeRGB (0), map (NULL) { }
+  ///
+  ~csRGBFloatLightMap () { Clear (); }
+
+  ///
+  int GetMaxSize () { return max_sizeRGB; }
+  ///
+  void SetMaxSize (int s) { max_sizeRGB = s; }
+
+  /// Get data.
+  float* GetMap () const { return map; }
+  /// Get red map.
+  float* GetRed () const { return map; }
+  /// Get green map.
+  float* GetGreen () const { return map+max_sizeRGB; }
+  /// Get blue map.
+  float* GetBlue () const { return map+(max_sizeRGB<<1); }
+
+  /// Set color maps.
+  void SetMap (float* m) { map = m; }
+
+  ///
+  void Alloc (int size)
+  {
+    max_sizeRGB = size;
+    delete [] map;
+    map = new float [size*3];
+  }
+
+  /// copy from floatmap
+  void Copy (csRGBFloatLightMap& other, int size)
+  {
+    Clear ();
+    if (other.map) { Alloc (size); memcpy (map, other.map,
+      size * 3 * sizeof(float)); }
+  }
+
+  /// copy from bytemap
+  void Copy (csRGBMap& other, int size)
+  {
+    Clear ();
+    if (other.GetArray()) {
+      Alloc (size);
+      csRGBpixel* m = other.GetArray ();
+	  int i;
+      for(i=0; i<size; i++)
+      {
+        GetRed()[i] = m[i].red;
+        GetGreen()[i] = m[i].green;
+        GetBlue()[i] = m[i].blue;
+      }
+    }
+  }
+
+  /// copy to bytemap
+  void CopyTo (csRGBMap& other, int size)
+  {
+    other.Clear ();
+    if (GetMap()) {
+      other.Alloc (size);
+      csRGBpixel* m = other.GetArray ();
+	  int i;
+      for(i=0; i<size; i++)
+      {
+        m[i].red = (unsigned char)GetRed()[i];
+        m[i].green = (unsigned char)GetGreen()[i];
+        m[i].blue = (unsigned char)GetBlue()[i];
+      }
+    }
+  }
+};
+
+/**
+ *  A radiosity Element, containing lightmap patches, the lumels.
+ *  Radiosity rendering specific info is kept here.
+ */
+class csRadElement : public csObject {
+protected:
+  float area;
+
+  float total_unshot_light; // diffuse * area * avg_delta_level
+
+public://@@@
+  csLightMap *csmap;
+
+protected:
+  int width, height, size;
+
+  /// ptr to static lightmap of polygon
+  csRGBMap *lightmap;
+
+  /// the change to this lightmap, unshot light.
+  csRGBFloatLightMap *deltamap;
+
+  /**
+   * if we are debugging radiosity then this is a copy of the
+   * lightmap that we store in order to restore the static lightmap
+   * values later.
+   */
+  csRGBMap* copy_lightmap;
+
+  /// the area of one lumel of the polygon
+  float one_lumel_area;
+
+  /// values for loop detection, last shooting priority and repeats
+  float last_shoot_priority;
+  int num_repeats;
+
+protected:
+
+  /// return the material handle
+  virtual iMaterialWrapper* GetMaterialWrapper () = 0;
+
+  /// return the flat color value
+  virtual csColor GetFlatColor() const = 0;
+
+  // setup some necessary values
+  virtual void Setup() {};
+
+
+
+public:
+  csRadElement();
+  ~csRadElement();
+
+  /// for queueing of elements to shoot their light
+  inline float GetPriority() { return total_unshot_light; }
+
+  /// get area size of element, precomputed
+  inline float GetArea() const { return area; }
+
+  /// Get diffuse reflection value for element. 0.55-0.75 is nice.
+  inline float GetDiffuse() const { return 0.7f; }
+
+  /// get width of lightmap and deltamap
+  inline int GetWidth() const{ return width; }
+
+  /// get height of lightmap and deltamap
+  inline int GetHeight() const { return height; }
+
+  /// get size of lightmap and deltamap
+  inline int GetSize() const { return size; }
+
+  /// check if a delta lumel is zero
+  inline bool DeltaIsZero(int suv)
+  { return !(deltamap->GetRed()[suv] || deltamap->GetGreen()[suv] ||
+      deltamap->GetBlue()[suv] ); }
+
+  /// return the sector of this element
+  virtual csSector* GetSector () const = 0;
+
+  /// return the normal at the point x, y
+  virtual const csVector3& GetNormal(int x, int y) const = 0;
+
+  /// return the average normal for this element
+  csVector3 GetAvgNormal() const;
+
+  /// check if a patch has zero delta
+  bool DeltaIsZero(int suv, int w, int h);
+
+  /// Get avg texture colour for a patch.
+  void GetTextureColour(int suv, int w, int h, csColor &avg,
+    csRGBMap *texturemap);
+
+  /// Cap every delta in patch to value.
+  void CapDelta(int suv, int w, int h, float max);
+
+  /// Get the summed delta of a patch
+  void GetSummedDelta(int suv, int w, int h, csColor& sum);
+
+  /// get the delta map
+  inline csRGBFloatLightMap* GetDeltaMap() { return deltamap; }
+
+  /**
+   * For debugging: keep a pointer of the static lightmap
+   * and temporarily copy the deltamap to the static lightmap again.
+   */
+  void ShowDeltaMap ();
+
+  /**
+   * For debugging: restore the state of the static lightmaps
+   * and free the copy of the static lightmap.
+   */
+  void RestoreStaticMap ();
+
+  /// Get last shooting priority of this radpoly
+  inline float GetLastShootingPriority() { return last_shoot_priority;}
+
+  /// Set last shooting priority
+  inline void SetLastShootingPriority(float val) {last_shoot_priority=val;}
+
+  /// Get number of repeats shooting at the same priority for this poly.
+  inline int GetRepeatCount() { return num_repeats; }
+
+  /// Increment the number of repeats of shooting at same priority by one.
+  inline void IncNumRepeats() {num_repeats++;}
+
+  /// Get world coordinates for a lumel
+  virtual void Lumel2World(csVector3& res, int x, int y) = 0;
+
+  /// get area of one lumel in world space
+  inline float GetOneLumelArea() const { return one_lumel_area; }
+
+
+  /// Populates the shadow coverage Matrix for this element
+  virtual void GetCoverageMatrix(csFrustumView* lview,
+                                 csCoverageMatrix* shadow_matrix) = 0;
+
+  /**
+   * computes new priority value, summing the light unshot.
+   * Note: Do no touch the variable total_unshot_light without
+   * doing a list->Delete(this), beforehand.
+   */
+  void ComputePriority();
+
+  /**
+   * Add a fraction to delta map of lumel from given source RadPoly.
+   * suv is index in src, ruv is index in maps of this poly.
+   */
+  void AddDelta(csRadElement *src, int suv, int ruv, float fraction,
+    const csColor& filtercolor);
+
+  /**
+   * Add a value *to* the deltamap.
+   */
+  inline void AddToDelta(int ruv, const csColor& value)
+  { deltamap->GetRed()[ruv] += value.red;
+    deltamap->GetGreen()[ruv] += value.green;
+    deltamap->GetBlue()[ruv] += value.blue;
+  }
+
+  /**
+   * light has been shot, copy delta to lightmap, clear delta,
+   * recompute priority. (this radpoly may not be in list as
+   * the total_unshot_light value changes).
+   */
+  void CopyAndClearDelta();
+
+  /**
+   * Get the sums of red.green.blue in the delta map.
+   */
+  void GetDeltaSums(float &red, float &green, float &blue);
+
+  /**
+   *  Add ambient value to deltamap
+   */
+  void ApplyAmbient(int red, int green, int blue);
+
+  /**
+   *  Compute the texture map at the size of the lumel map.
+   *  Gets the texture, and scales down. You must delete the map.
+   */
+  csRGBMap *ComputeTextureLumelSized();
+
+  /// Get a RadElement when you have a csPolygon3D or a csCurve
+  static csRadElement* GetRadElement(csPolygon3D &object);
+
+  /// Get a RadElement
+  static csRadElement* GetRadElement(csCurve &object);
+};
+
+
+SCF_VERSION (csRadPoly, 0, 0, 1);
+
+/**
+ *  A radiosity polygon, containing lightmap patches, the lumels.
+ *  Radiosity rendering specific info is kept here.
+ */
+class csRadPoly : public csRadElement
+{
+private:
+  csPolygon3D* polygon;
+  csSector* sector;
+  csVector3 lumel_origin, lumel_x_axis, lumel_y_axis;
+
+protected:
+  /// return the material handle for this polygon
+  virtual iMaterialWrapper * GetMaterialWrapper ()
+  { return &(polygon->GetMaterialWrapper ())->scfiMaterialWrapper; }
+
+  /// return the flat color for the polygons texture
+  virtual csColor GetFlatColor() const;
+
+  // setup some necessary values
+  virtual void Setup();
+
+public:
+  csRadPoly(csPolygon3D *original, csSector* sector);
+  ~csRadPoly();
+
+  /// get normal vector for polygon
+  const csVector3& GetNormal(int x, int y) const
+  { (void)x; (void)y; return polygon->GetPolyPlane()->Normal();}
+
+  /// get original csPolgyon3D for this radpoly
+  inline csPolygon3D *GetPolygon3D() const { return polygon; }
+
+  /// Get world coordinates for a lumel -- slow method
+  void CalcLumel2World(csVector3& res, int x, int y);
+
+  /// Get world coordinates for a lumel
+  virtual void Lumel2World(csVector3& res, int x, int y);
+
+  csSector* GetSector () const { return sector; }
+
+  /// Populates the shadow coverage Matrix for this element
+  virtual void GetCoverageMatrix(csFrustumView* lview,
+                                 csCoverageMatrix* shadow_matrix)
+  {
+      (void)lview;
+      (void)shadow_matrix;
+#if 0
+// @@@@@@@@@@@ REWRITE
+    GetPolygon3D()->GetLightMapInfo()->GetPolyTex()->
+                    GetCoverageMatrix(*lview, *shadow_matrix);
+#endif
+  }
+  SCF_DECLARE_IBASE_EXT (csRadElement);
+};
+
+
+SCF_VERSION (csRadCurve, 0, 0, 1);
+
+/**
+ *  A radiosity curve, containing lightmap patches, the lumels.
+ *  Radiosity rendering specific info is kept here.
+ */
+class csRadCurve : public csRadElement {
+private:
+  csCurve* curve;
+  csSector* sector;
+
+protected:
+  /// return the texture handle for this curve
+  virtual iMaterialWrapper * GetMaterialWrapper ()
+  { return curve->Material; }
+
+  /// return the flat color for the polygons texture
+  virtual csColor GetFlatColor() const
+  {
+    /// @@@ I'm not sure why curves don't have a flat color, so for now
+    /// @@@ just return a default color of mid-gray
+    return csColor(0.5, 0.5, 0.5);
+  }
+
+  virtual void Setup();
+
+public:
+  csRadCurve (csCurve* curve, csSector* sector);
+  ~csRadCurve();
+
+  /// get normal vector for the Curve
+  virtual const csVector3& GetNormal(int x, int y) const;
+
+  /// Get world coordinates for a lumel
+  virtual void Lumel2World(csVector3& res, int x, int y);
+
+  csSector* GetSector () const { return sector; }
+
+  /// Populates the shadow coverage Matrix for this element
+  virtual void GetCoverageMatrix(csFrustumView* /*(lview*/,
+                                 csCoverageMatrix* /*shadow_matrix*/)
+  { /* @@@ curve->GetCoverageMatrix(*lview, *shadow_matrix); */ }
+
+  SCF_DECLARE_IBASE_EXT (csRadElement);
+};
+
+
+/**
+ *  csRadTree is a binary tree, used to store RadPolys by csRadList
+ */
+class csRadTree{
+private:
+  csRadElement *element;
+
+  csRadTree *left, *right;
+
+  /// deletes this node which must have non-null left and right subtrees.
+  void DelNode();
+
+  /// Returns Leftmost node in this tree, parent is also stored or NULL
+  csRadTree* FindLeftMost(csRadTree*& parent);
+
+  /// Returns rightost node in this tree, parent is also stored or NULL
+  csRadTree* FindRightMost(csRadTree*& parent);
+
+public:
+  /// create a new node, with values
+  inline csRadTree(csRadElement *n, csRadTree *l, csRadTree *r)
+  {element = n; left=l; right=r;}
+
+  /// delete the tree, does not delete the elements.
+  inline ~csRadTree() {if (left) delete left; if (right) delete right;}
+
+  /// Insert RadElement into tree;
+  void Insert(csRadElement *e);
+
+  /// Delete RadElement from tree; returns new tree. does not delete element.
+  csRadTree* Delete(csRadElement *e);
+
+  /// get element with highest priority. It is deleted, returns new tree.
+  csRadTree* PopHighest(csRadElement*& e);
+
+  /// get node priority
+  inline float GetPriority() { return element->GetPriority(); }
+
+  /// traverse tree in in-order (from low to high), calling func(element).
+  void TraverseInOrder( void (*func)( csRadElement * ) );
+};
+
+
+/**
+ *  All csRadPolys, keeps them sorted on priority.
+ */
+class csRadList {
+private:
+  /// does the actual work
+  csRadTree *tree;
+  /// number of elements
+  int num;
+
+public:
+  /// create
+  csRadList();
+
+  /// delete, also deletes all elements!
+  ~csRadList();
+
+  /// Insert an element
+  void InsertElement(csRadElement *e);
+
+  /// Delete an element
+  void DeleteElement(csRadElement *e);
+
+  /// get element with highest priority. It is also deleted.
+  csRadElement *PopHighest();
+
+  /// print list on output
+  void Print();
+
+  /// traverse in some order.
+  void Traverse( void (*func)( csRadElement * ) )
+  { if(tree) tree->TraverseInOrder(func); }
+
+  /// get the number of elements in the list
+  inline int GetElementCount() { return num; }
+};
+
+/**
+ *  calculates radiosity
+ */
+class csRadiosity {
+public:
+  /**
+   * Configuration information
+   *
+   * when true static specular gloss is applied, giving extra light.
+   */
+  static bool do_static_specular;
+  /// amount of specular to add 0..1 is a sane setting.
+  static float static_specular_amount;
+  /**
+   *  Bigger value gives smaller highlight. Try between 0..10.
+   *  The value is the 2log(n), where n is the usual highlightsize used
+   *  with specular highlighting in other programs.
+   */
+  static int static_specular_tightness;
+
+  /** Multiplier for amount of texture colour used.
+   *  regular value is 1.0, smaller will be darker, larger will make
+   *  surroundings blend eachothers colours more.
+   *  0.0 means not to use texture colouring.
+   */
+  static float colour_bleed;
+
+  /** when priority gets below this value calculation will stop.
+   *  > 0.0. Set higher for shorter calculation time, and less quality.
+   */
+  static float stop_priority;
+  /** The improvement factor in priority when calculation can stop.
+   *  Must be > 0. Try 1000. Larger values, better quality, more time needed.
+   */
+  static float stop_improvement;
+  /// max number of iterations, after that amount of polygons processed stop.
+  static int stop_iterations;
+
+  /**
+   * light will be shot from n by n lumels.
+   */
+  static int source_patch_size;
+
+private:
+  /// world being radiosity rendered
+  csEngine *engine;
+  /// list of all radiosity polygon info
+  csRadList *list;
+
+  /**
+   * For debugging: if true we are showing the delta maps in the
+   * static map.
+   */
+  bool showing_deltamaps;
+
+  /// progress meter of the work
+  iProgressMeter *meter;
+  /// pulse to see polygon shootings
+  csProgressPulse *pulse;
+  /// the probably highest priority, starting priority.
+  float start_priority;
+  /// the number of iterations done.
+  int iterations;
+
+  /// Shooting info
+  /// lightness factor, built up to form_factor * diffuse * area.
+  float factor;
+  /// polys that are shooting / shot at.
+  csRadElement *shoot_src, *shoot_dest;
+  /// lumels in worlds coords
+  csVector3 src_lumel, dest_lumel;
+  /// normals pointing towards shooting.
+  csVector3 src_normal, dest_normal;
+  /// size of source patches in source polygon, i.e. the size of the lumels
+  float source_poly_patch_area;
+  /// size of the source patch, width, height
+  int srcp_width, srcp_height;
+  /// area of source patch visible for lighting
+  float source_patch_area;
+  /// index into source maps
+  int src_uv;
+  /// x, y of source lumel
+  int src_x, src_y;
+  /// texture map of source polygon - reasonably quick to compute, saves
+  /// a lot of space.
+  csRGBMap *texturemap;
+  /// the shadows lying on the dest polygon, 1=full visible, 0=all shadow
+  csCoverageMatrix *shadow_matrix;
+  /// color from passing portals between source and dest polygon.
+  csColor trajectory_color;
+  /// color of source lumel for multiplying delta's with.
+  csColor src_lumel_color;
+  /// delta to add to destination, the summed delta  * src_lumel_colour
+  csColor delta_color;
+
+public:
+  /// create all radiosity data.
+  csRadiosity(csEngine *current_engine, iProgressMeter* meter);
+  /// get rid of radiosity data.
+  ~csRadiosity();
+  /// Does the whole radiosity thing. This is the one to call.
+  void DoRadiosity();
+
+  /**
+   * Do the radiosity a few steps at a time. This is useful for debugging.
+   * Returns false on stop criterium.
+   */
+  bool DoRadiosityStep (int steps);
+  /// For step-by-step radiosity: return next polygon to process.
+  csPolygon3D* GetNextPolygon ();
+  /**
+   * For debugging: temporarily show all delta maps.
+   * Calling this again will restore the situation.
+   */
+  void ToggleShowDeltaMaps ();
+  /**
+   * Restore the static maps after doing ToggleShowDeltaMaps().
+   * Calling DoRadiosityStep() will also do this.
+   */
+  void RestoreStaticMaps ();
+
+  /// get next best poly to shoot, or NULL if we should stop.
+  csRadElement* FetchNext();
+  /// Start a sector frustum to shoot from the source. callback is used.
+  void StartFrustum();
+  /// found a destination polygon, test and process it
+  void ProcessDest(csRadElement *dest, csFrustumView *lview);
+  /// Shoot light from one polygon to another
+  void ShootRadiosityToElement(csRadElement* dest);
+  /// Prepare to shoot from source poly
+  void PrepareShootSource(csRadElement* src);
+  /// Prepare to shoot from source to dest, if false skip dest.
+  bool PrepareShootDest(csRadElement* dest, csFrustumView *lview);
+  /// Prepare to shoot from a lumel
+  void PrepareShootSourceLumel(int sx, int sy, int suv);
+  /// Shoot it, dest lumel given.
+  void ShootPatch(int rx, int ry, int ruv);
+
+
+  /// Apply all deltamaps if stopped early, and add ambient light
+  void ApplyDeltaAndAmbient();
+  /// Remove old ambient, for now.
+  void RemoveAmbient();
+
+};
+
+#endif // __CS_RADIOSTY_H__
diff --git a/client/client94/crystalspace/include/csengine/rdrprior.h b/client/client94/crystalspace/include/csengine/rdrprior.h
new file mode 100644
index 0000000..5379a7d
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/rdrprior.h
@@ -0,0 +1,69 @@
+/*
+    Copyright (C) 2001 by Martin Geisse <mgeisse@gmx.net>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CSENGINE_RDRPRIOR_H__
+#define __CSENGINE_RDRPRIOR_H__
+
+struct iMeshWrapper;
+struct iRenderView;
+
+CS_DECLARE_TYPED_VECTOR_NODELETE (csMeshVectorNodelete, iMeshWrapper);
+CS_DECLARE_TYPED_VECTOR (csMeshVectorNodeleteVector, csMeshVectorNodelete);
+
+/**
+ * This class contains a list of rendering queues, each of which is a list
+ * of mesh wrappers. The rendering queues are sorted by rendering priority.
+ * Note that the mesh objects are not reference-counted!
+ */
+class csRenderQueueSet
+{
+private:
+  // the list of queues
+  csMeshVectorNodeleteVector Queues;
+
+public:
+
+  /// Constructor.
+  csRenderQueueSet ();
+  /// Destructor.
+  ~csRenderQueueSet ();
+
+  /// Add a mesh object.
+  void Add (iMeshWrapper *mesh);
+
+  /// Remove a mesh object.
+  void Remove (iMeshWrapper *mesh);
+
+  /// Remove a mesh object which is potentially in the wrong queue.
+  void RemoveUnknownPriority (iMeshWrapper *mesh);
+
+  /// Return the number of rendering queues (the maximum priority value).
+  int GetQueueCount () { return Queues.Length (); }
+
+  /// Return a single queue, or NULL if no queue exists for the given priority.
+  csMeshVectorNodelete *GetQueue (int priority)
+  {
+    return Queues[priority];
+  }
+
+  /// Sort this queue based on the flags for that queue.
+  void Sort (iRenderView* rview, int priority);
+};
+
+#endif // __CSENGINE_RDRPRIOR_H__
+
diff --git a/client/client94/crystalspace/include/csengine/region.h b/client/client94/crystalspace/include/csengine/region.h
new file mode 100644
index 0000000..7f39e44
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/region.h
@@ -0,0 +1,170 @@
+/*
+    Copyright (C) 2000 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_REGION_H__
+#define __CS_REGION_H__
+
+#include "csutil/csobject.h"
+#include "csutil/nobjvec.h"
+#include "iengine/region.h"
+
+struct iEngine;
+
+/**
+ * A region. A region is basically a collection of objects in the
+ * 3D engine that can be treated as a unit.
+ */
+class csRegion : public csObject
+{
+private:
+  iEngine* engine;
+
+public:
+  /**
+   * Initialize an empty region.
+   */
+  csRegion (iEngine*);
+
+  /**
+   * Delete the region without deleting the entities in it. The entities
+   * in this region will simply get unconnected.
+   */
+  virtual ~csRegion ();
+
+  /**
+   * Check if some object is in this region.
+   * The speed of this function is independent of the number of
+   * objects in this region (i.e. very fast).
+   */
+  virtual bool IsInRegion (iObject* obj);
+
+  /**
+   * Delete all entities in this region.
+   */
+  virtual void DeleteAll ();
+
+  /**
+   * Prepare all textures and materials in this region.
+   */
+  virtual bool PrepareTextures ();
+
+  /**
+   * Do lighting calculations (or read from cache).
+   */
+  virtual bool ShineLights ();
+
+  /**
+   * Prepare all objects in this region. This has to be called
+   * directly after loading new objects.
+   * This function is equivalent to calling PrepareTextures(),
+   * followed by ShineLights().
+   */
+  virtual bool Prepare ();
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //--------------------- iRegion implementation ---------------------
+  struct Region : public iRegion
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csRegion);
+
+    /// Query the iObject.
+    virtual iObject *QueryObject();
+
+    /**
+     * Clear this region without removing the entities in it. The entities
+     * will simply get unconnected from this region.
+     */
+    virtual void Clear ();
+
+    /**
+     * Delete all entities in this region.
+     */
+    virtual void DeleteAll ();
+
+    /**
+     * Prepare all textures and materials in this region.
+     */
+    virtual bool PrepareTextures ();
+
+    /**
+     * Do lighting calculations (or read from cache).
+     */
+    virtual bool ShineLights ();
+
+    /**
+     * Prepare all objects in this region. This has to be called
+     * directly after loading new objects.
+     * This function is equivalent to calling PrepareTextures(),
+     * followed by ShineLights().
+     */
+    virtual bool Prepare ();
+
+    /// Find a sector in this region by name.
+    virtual iSector *FindSector (const char *iName);
+    /// Find a mesh in this region by name
+    virtual iMeshWrapper *FindMeshObject (const char *iName);
+    /// Find a mesh factory in this region by name
+    virtual iMeshFactoryWrapper *FindMeshFactory (const char *iName);
+    /// Find a texture in this region by name
+    virtual iTextureWrapper *FindTexture (const char *iName);
+    /// Find a material in this region by name
+    virtual iMaterialWrapper *FindMaterial (const char *iName);
+    /// Find a camera position in this region by name
+    virtual iCameraPosition *FindCameraPosition (const char *iName);
+    /// Find a collection in this region by name
+    virtual iCollection *FindCollection (const char *iName);
+
+    /**
+     * Check if some object is in this region.
+     * The speed of this function is independent of the number of
+     * objects in this region (i.e. very fast).
+     */
+    virtual bool IsInRegion (iObject* obj);
+  } scfiRegion;
+  friend struct Region;
+};
+
+
+CS_DECLARE_OBJECT_VECTOR (csRegionListHelper, iRegion);
+
+class csRegionList : public csRegionListHelper
+{
+public:
+  SCF_DECLARE_IBASE;
+
+  /// constructor
+  csRegionList ();
+
+  class RegionList : public iRegionList
+  {
+  public:
+    SCF_DECLARE_EMBEDDED_IBASE (csRegionList);
+
+    virtual int GetCount () const;
+    virtual iRegion *Get (int n) const;
+    virtual int Add (iRegion *obj);
+    virtual bool Remove (iRegion *obj);
+    virtual bool Remove (int n);
+    virtual void RemoveAll ();
+    virtual int Find (iRegion *obj) const;
+    virtual iRegion *FindByName (const char *Name) const;
+  } scfiRegionList;
+};
+
+#endif // __CS_REGION_H__
diff --git a/client/client94/crystalspace/include/csengine/rview.h b/client/client94/crystalspace/include/csengine/rview.h
new file mode 100644
index 0000000..a7ca5f0
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/rview.h
@@ -0,0 +1,376 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_RVIEW_H__
+#define __CS_RVIEW_H__
+
+#include "csgeom/math3d.h"
+#include "csgeom/frustum.h"
+#include "csengine/camera.h"
+#include "csutil/csvector.h"
+#include "iengine/rview.h"
+#include "iengine/engine.h"
+
+class csMatrix3;
+class csVector3;
+class csRenderView;
+struct csFog;
+struct iGraphics3D;
+struct iGraphics2D;
+struct iPolygon3D;
+struct iSector;
+struct iClipper2D;
+
+/**
+ * This structure represents all information needed for drawing
+ * a scene. It is modified while rendering according to
+ * portals/warping portals and such.
+ */
+class csRenderView : public iRenderView
+{
+private:
+  /**
+   * A structure to keep data with the render context. All data
+   * that is attached to a render context will be automatically cleaned
+   * up when the render context is deleted (i.e. when a recursion level
+   * is closed).
+   */
+  struct csRenderContextData
+  {
+    /// Next data.
+    csRenderContextData* next;
+
+    /// The key is some value on which we want to retreive the data.
+    void* key;
+    /**
+     * This is the data. When the render context is deleted it will DecRef()
+     * this.
+     */
+    iBase* data;
+  };
+
+  /// The current render context.
+  csRenderContext* ctxt;
+
+  /// Engine handle.
+  iEngine* iengine;
+  /// The 3D graphics subsystem used for drawing.
+  iGraphics3D* g3d;
+  /// The 2D graphics subsystem used for drawing.
+  iGraphics2D* g2d;
+  /**
+   * A copy to the original base camera before space warping.
+   */
+  iCamera* original_camera;
+
+  /// The view frustum as defined at z=1.
+  float leftx, rightx, topy, boty;
+  /// The frustum corresponding with this.
+  csRenderContextFrustum* top_frustum;
+
+  /**
+   * A callback function. If this is set then no drawing is done.
+   * Instead the callback function is called.
+   */
+  iDrawFuncCallback* callback;
+
+  /**
+   * Delete all data on the given render context.
+   */
+  void DeleteRenderContextData (csRenderContext* rc);
+
+  /**
+   * Update the csRenderContextFrustum to the given clipper.
+   */
+  void UpdateFrustum (iClipper2D* clip, csRenderContextFrustum*
+  	frust);
+
+  /**
+   * Given a csRenderContextFrustum and a bounding sphere calculate if
+   * the sphere is fully inside and fully outside that frustum.
+   */
+  static void TestSphereFrustum (csRenderContextFrustum* frust,
+  	const csVector3& center, float radius, bool& inside, bool& outside);
+
+public:
+  ///
+  csRenderView ();
+  ///
+  csRenderView (iCamera* c);
+  ///
+  csRenderView (iCamera* c, iClipper2D* v, iGraphics3D* ig3d,
+    iGraphics2D* ig2d);
+
+  virtual ~csRenderView ();
+
+  /// Set the engine.
+  void SetEngine (iEngine* engine);
+  /// Set the camera.
+  void SetCamera (iCamera* camera);
+  /// Set the original camera.
+  void SetOriginalCamera (iCamera* camera);
+  /// Get the original camera.
+  virtual iCamera* GetOriginalCamera () const { return original_camera; }
+
+  ///
+  virtual void SetCallback (iDrawFuncCallback* cb)
+  {
+    if (cb) cb->IncRef ();
+    if (callback) callback->DecRef ();
+    callback = cb;
+  }
+  ///
+  virtual iDrawFuncCallback* GetCallback ()
+  {
+    return callback;
+  }
+
+  /// Call callback.
+  virtual void CallCallback (int type, void* data)
+  {
+    callback->DrawFunc (this, type, data);
+  }
+
+  SCF_DECLARE_IBASE;
+
+  /// Get the current render context.
+  virtual csRenderContext* GetRenderContext () { return ctxt; }
+
+  /**
+   * Create a new render context. This is typically used
+   * when going through a portal. Note that you should remember
+   * the old render context if you want to restore it later.
+   * The render context will get all the values from the current context
+   * (with SCF references properly incremented).
+   */
+  virtual void CreateRenderContext ();
+
+  /**
+   * Restore a render context. Use this to restore a previously overwritten
+   * render context. This function will take care of properly cleaning
+   * up the current render context.
+   */
+  virtual void RestoreRenderContext (csRenderContext* original);
+
+  /**
+   * Create a new camera in the current render context. This function
+   * will create a new camera based on the current one. The new camera
+   * reference is returned.
+   */
+  virtual iCamera* CreateNewCamera ();
+
+  /// Get the engine.
+  virtual iEngine* GetEngine () { return iengine; }
+  /// Get the 2D graphics subsystem.
+  virtual iGraphics2D* GetGraphics2D () { return g2d; }
+  /// Get the 3D graphics subsystem.
+  virtual iGraphics3D* GetGraphics3D () { return g3d; }
+  /// Set the view frustum at z=1.
+  virtual void SetFrustum (float lx, float rx, float ty, float by);
+  /// Get the frustum.
+  virtual void GetFrustum (float& lx, float& rx, float& ty, float& by)
+  {
+    lx = leftx;
+    rx = rightx;
+    ty = topy;
+    by = boty;
+  }
+  /// Get the top level frustum (corresponding with SetFrustum()).
+  virtual csRenderContextFrustum* GetTopFrustum ()
+  {
+    return top_frustum;
+  }
+
+  //-----------------------------------------------------------------
+  // The following functions operate on the current render context.
+  //-----------------------------------------------------------------
+
+  /// Get the 2D clipper for this view.
+  virtual iClipper2D* GetClipper () { return ctxt->iview; }
+  /// Set the 2D clipper for this view.
+  virtual void SetClipper (iClipper2D* clip);
+
+  /**
+   * If true then we have to clip all objects to the portal frustum
+   * (returned with GetClipper()). Normally this is not needed but
+   * some portals require this. If GetClipPlane() returns true then the
+   * value of this function is also implied to be true.
+   */
+  virtual bool IsClipperRequired () { return ctxt->do_clip_frustum; }
+  /**
+   * Get the 3D clip plane that should be used to clip all geometry.
+   * If this function returns false then this plane is invalid and should
+   * not be used. Otherwise it must be used to clip the object before
+   * drawing.
+   */
+  virtual bool GetClipPlane (csPlane3& pl)
+  {
+    pl = ctxt->clip_plane;
+    return ctxt->do_clip_plane;
+  }
+  /// Get the clip plane.
+  virtual csPlane3& GetClipPlane ()
+  {
+    return ctxt->clip_plane;
+  }
+  ///
+  virtual void SetClipPlane (const csPlane3& p) { ctxt->clip_plane = p; }
+  ///
+  virtual void UseClipPlane (bool u) { ctxt->do_clip_plane = u; }
+  ///
+  virtual void UseClipFrustum (bool u) { ctxt->do_clip_frustum = u; }
+
+
+  /**
+   * Every fogged sector we encountered results in an extra structure in the
+   * following list. This is only used if we are doing vertex based fog.
+   * This function will return the first csFogInfo instance.
+   */
+  virtual csFogInfo* GetFirstFogInfo () { return ctxt->fog_info; }
+  /**
+   * Set the first fog info.
+   */
+  virtual void SetFirstFogInfo (csFogInfo* fi)
+  {
+    ctxt->fog_info = fi;
+    ctxt->added_fog_info = true;
+  }
+  /**
+   * Return true if fog info has been added.
+   */
+  virtual bool AddedFogInfo () { return ctxt->added_fog_info; }
+  /**
+   * Reset fog info.
+   */
+  virtual void ResetFogInfo () { ctxt->added_fog_info = false; }
+
+  /**
+   * Get the current camera.
+   */
+  virtual iCamera* GetCamera () { return ctxt->icamera; }
+  /**
+   * Calculate the fog information in the given G3DPolygonDP structure.
+   */
+  virtual void CalculateFogPolygon (G3DPolygonDP& poly);
+  /**
+   * Calculate the fog information in the given G3DPolygonDPFX structure.
+   */
+  virtual void CalculateFogPolygon (G3DPolygonDPFX& poly);
+  /**
+   * Calculate the fog information in the given G3DTriangleMesh
+   * structure. This function assumes the fog array is already preallocated
+   * and the rest of the structure should be filled in.
+   * This function will take care of correctly enabling/disabling fog.
+   */
+  virtual void CalculateFogMesh (const csTransform& tr_o2c,
+  	G3DTriangleMesh& mesh);
+
+  /**
+   * Calculate the fog information in the given G3DPolygonMesh
+   * structure. This function assumes the fog array is already preallocated
+   * and the rest of the structure should be filled in.
+   * This function will take care of correctly enabling/disabling fog.
+   */
+
+  virtual void CalculateFogMesh (const csTransform &tr_o2c,
+    G3DPolygonMesh &mesh);
+
+
+
+  /**
+   * Test if the given bounding sphere (in object space coordinates)
+   * is visibile in this render view. The transformation will
+   * transform object to camera space.
+   */
+  virtual bool TestBSphere (const csReversibleTransform& o2c,
+  	const csSphere& sphere);
+  /**
+   * Check if the given bounding sphere (in object space coordinates)
+   * is visibile in this render view. The given transformation should
+   * transform object to camera space. If the sphere is visible this
+   * function will also initialize the clip_plane, clip_z_plane, and
+   * clip_portal fields which can be used for DrawTriangleMesh or
+   * DrawPolygonMesh.
+   */
+  virtual bool ClipBSphere (const csReversibleTransform& o2c,
+  	const csSphere& sphere,
+	int& clip_portal, int& clip_plane, int& clip_z_plane);
+  /**
+   * Check if the screen bounding box of an object is visible in
+   * this render view. If true is returned (visible) then clip_plane,
+   * clip_z_plane, and clip_portal will be set to the right value depending
+   * on wether or not clipping is wanted. This function also does far
+   * plane clipping.
+   */
+  virtual bool ClipBBox (const csBox2& sbox, const csBox3& cbox,
+      	int& clip_portal, int& clip_plane, int& clip_z_plane);
+
+  /**
+   * Get current sector.
+   */
+  virtual iSector* GetThisSector () { return ctxt->this_sector; }
+
+  /**
+   * Set the current sector.
+   */
+  virtual void SetThisSector (iSector* s) { ctxt->this_sector = s; }
+
+  /**
+   * Get previous sector.
+   */
+  virtual iSector* GetPreviousSector () { return ctxt->previous_sector; }
+
+  /**
+   * Set the previous sector.
+   */
+  virtual void SetPreviousSector (iSector* s) { ctxt->previous_sector = s; }
+
+  /// Get the portal polygon.
+  virtual iPolygon3D* GetPortalPolygon () { return ctxt->portal_polygon; }
+  /// Set the portal polygon.
+  virtual void SetPortalPolygon (iPolygon3D* por)
+  { ctxt->portal_polygon = por; }
+
+  /**
+   * Get render recursion level.
+   */
+  virtual int GetRenderRecursionLevel () { return ctxt->draw_rec_level; }
+  /**
+   * Set render recursion level.
+   */
+  virtual void SetRenderRecursionLevel (int rec)
+  {
+    ctxt->draw_rec_level = rec;
+  }
+
+  /**
+   * Attach data to the current render context.
+   */
+  virtual void AttachRenderContextData (void* key, iBase* data);
+  /**
+   * Look for data on the current render context.
+   */
+  virtual iBase* FindRenderContextData (void* key);
+  /**
+   * Delete all data with the given key on the current render
+   * context.
+   */
+  virtual void DeleteRenderContextData (void* key);
+};
+
+#endif // __CS_RVIEW_H__
diff --git a/client/client94/crystalspace/include/csengine/sector.h b/client/client94/crystalspace/include/csengine/sector.h
new file mode 100644
index 0000000..f8a03d7
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/sector.h
@@ -0,0 +1,494 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_SECTOR_H__
+#define __CS_SECTOR_H__
+
+#include "csgeom/math3d.h"
+#include "csutil/csobject.h"
+#include "csutil/nobjvec.h"
+#include "csutil/cscolor.h"
+#include "iutil/objref.h"
+#include "ivideo/graph3d.h"
+#include "csengine/light.h"
+#include "csengine/meshobj.h"
+#include "csengine/rdrprior.h"
+#include "iengine/sector.h"
+
+class csEngine;
+class csProgressPulse;
+class csSector;
+class csStatLight;
+class csMeshWrapper;
+class csPolygon3D;
+struct iStatLight;
+struct iVisibilityCuller;
+struct iRenderView;
+struct iMeshWrapper;
+struct iFrustumView;
+
+/// A list of lights for a sector.
+class csSectorLightList : public csLightList
+{
+private:
+  csSector* sector;
+
+public:
+  /// constructor
+  csSectorLightList ();
+  /// destructor
+  ~csSectorLightList ();
+  /// Set the sector.
+  void SetSector (csSector* s) { sector = s; }
+
+  /// Override PrepareItem
+  virtual bool PrepareItem (csSome Item);
+  /// Override FreeItem
+  virtual bool FreeItem (csSome Item);
+};
+
+/// A list of meshes for a sector.
+class csSectorMeshList : public csMeshList
+{
+private:
+  csSector* sector;
+
+public:
+  /// constructor
+  csSectorMeshList ();
+  /// destructor
+  ~csSectorMeshList ();
+  /// Set the sector.
+  void SetSector (csSector* sec) { sector = sec; }
+
+  /// Override PrepareItem
+  virtual bool PrepareItem (csSome item);
+  /// Override FreeItem
+  virtual bool FreeItem (csSome item);
+};
+
+
+SCF_VERSION (csSector, 0, 0, 2);
+
+/**
+ * A sector is a container for objects. It is one of
+ * the base classes for the portal engine.
+ */
+class csSector : public csObject
+{
+private:
+  /**
+   * List of meshes in this sector. Note that meshes also
+   * need to be in the engine list. This vector contains objects
+   * of type iMeshWrapper*.
+   */
+  csSectorMeshList meshes;
+
+  /**
+   * The same meshes above but each mesh in their own render priority
+   * queue. This is a vector of vectors.
+   */
+  csRenderQueueSet RenderQueues;
+
+  /**
+   * List of references (portals?) to this sector.
+   */
+  csVector references;
+
+  /**
+   * All static and pseudo-dynamic lights in this sector.
+   * This vector contains objects of type iLight*.
+   */
+  csSectorLightList lights;
+
+  /// Engine handle.
+  csEngine* engine;
+
+  /// Fog information.
+  csFog fog;
+
+  /**
+   * This is a pointer to the csMeshWrapper which implements the visibility
+   * culler.
+   */
+  iMeshWrapper* culler_mesh;
+
+  /**
+   * The visibility culler for this sector or NULL if none.
+   * In future we should support more than one visibility culler probably.
+   */
+  iVisibilityCuller* culler;
+
+private:
+  /**
+   * Destroy this sector. All things in this sector are also destroyed.
+   * Meshes are unlinked from the sector but not removed because they
+   * could be in other sectors.
+   */
+  virtual ~csSector ();
+
+public:
+  /**
+   * Option variable: render portals?
+   * If this variable is false portals are rendered as a solid polygon.
+   */
+  static bool do_portals;
+
+  /**
+   * Configuration variable: number of allowed reflections for static lighting.
+   * This option controls how many time a given sector may be visited by the
+   * same beam of light. When this value is 1 it means that light is not
+   * reflected.
+   */
+  static int cfg_reflections;
+
+  /**
+   * Option variable: do pseudo-radiosity?
+   * When pseudo-radiosity is enabled every polygon behaves as if
+   * it is a mirroring portal when lighting calculations are concerned.
+   * This simulates radiosity because light reflects from every surface.
+   * The number of reflections allowed is controlled by cfg_reflections.
+   */
+  static bool do_radiosity;
+
+  /**
+   * How many times are we busy drawing this sector (recursive).
+   * This is an important variable as it indicates to
+   * 'new_transformation' which set of camera vertices it should
+   * use.
+   */
+  int draw_busy;
+
+public:
+  /**
+   * Construct a sector. This sector will be completely empty.
+   */
+  csSector (csEngine*);
+
+  /**
+   * This function MUST be called before the sector is deleted in order
+   * to make sure that all references to the sector are cleaned up.
+   */
+  void CleanupReferences ();
+
+  //----------------------------------------------------------------------
+  // Mesh manipulation functions
+  //----------------------------------------------------------------------
+
+  iMeshList* GetMeshes ()
+    { return &(meshes.scfiMeshList); }
+
+  /**
+   * Prepare a mesh for rendering. This function is called for all meshes that
+   * are added to the sector.
+   */
+  void PrepareMesh (iMeshWrapper* mesh);
+
+  /**
+   * Unprepare a mesh. This function is called for all meshes that
+   * are removed from the sector.
+   */
+  void UnprepareMesh (iMeshWrapper* mesh);
+
+  /**
+   * Relink a mesh from this sector. This is mainly useful if
+   * characterics of the mesh changed (like render priority) so
+   * that the sector needs to know this.
+   */
+  void RelinkMesh (iMeshWrapper* mesh);
+
+  //----------------------------------------------------------------------
+  // Light manipulation functions
+  //----------------------------------------------------------------------
+
+  /**
+   * Get the list of lights in this sector.
+   */
+  iLightList* GetLights ()
+    { return &lights.scfiLightList; }
+
+  //----------------------------------------------------------------------
+  // Visibility Stuff
+  //----------------------------------------------------------------------
+
+  /**
+   * Get the mesh which implements the visibility culler.
+   */
+  iMeshWrapper* GetCullerMesh () const { return culler_mesh; }
+
+  /**
+   * Look for the mesh object and see if it implements iVisibilityCuller.
+   * If so then use it for visibility culling in this sector.
+   */
+  void UseCuller (const char* meshname);
+
+  /**
+   * Get the visibility culler that is used for this sector.
+   * NULL if none.
+   */
+  iVisibilityCuller* GetVisibilityCuller () const { return culler; }
+
+  //----------------------------------------------------------------------
+  // Drawing
+  //----------------------------------------------------------------------
+
+  /**
+   * Draw the sector in the given view and with the given transformation.
+   */
+  void Draw (iRenderView* rview);
+
+  //----------------------------------------------------------------------
+  // Utility Functions
+  //----------------------------------------------------------------------
+
+  /**
+   * Follow a beam from start to end and return the first polygon that
+   * is hit. This function correctly traverse portals and space warping
+   * portals. Normally the sector you call this on should be the sector
+   * containing the 'start' point. 'isect' will be the intersection point
+   * if a polygon is returned.
+   */
+  csPolygon3D* HitBeam (const csVector3& start, const csVector3& end,
+  	csVector3& isect);
+
+  /**
+   * Follow a beam from start to end and return the first object
+   * that is hit. In case it is a thing the csPolygon3D field will be
+   * filled with the polygon that was hit.
+   * If polygonPtr is null then the polygon will not be filled in.
+   */
+  csMeshWrapper* HitBeam (const csVector3& start, const csVector3& end,
+  	csVector3& intersect, csPolygon3D** polygonPtr);
+
+  /**
+   * Check visibility in a frustum way for all things and polygons in
+   * this sector and possibly traverse through portals to other sectors.
+   * This version doesn't init the 2D culler cube so it can be used
+   * for recursing.
+   */
+  void RealCheckFrustum (iFrustumView* lview);
+
+  /**
+   * Check visibility in a frustum way for all things and polygons in
+   * this sector and possibly traverse through portals to other sectors.
+   */
+  void CheckFrustum (iFrustumView* lview);
+
+  /**
+   * Get a list of all objects which are visible in the given frustum.
+   * Return an array to pointers to visible objects.
+   * You must delete this array after you are ready using it.
+   * @@@ When csThing becomes a mesh object then change rc to csMeshWrapper**
+   */
+  csObject** GetVisibleObjects (iFrustumView* lview, int& num_objects);
+
+  /**
+   * Intersects world-space sphere with polygons of this set. Return
+   * polygon it hits with (or NULL) and the intersection point
+   * in world coordinates. It will also return the polygon with the
+   * closest hit (the most nearby polygon).
+   * If 'pr' != NULL it will also return the distance where the
+   * intersection happened.
+   * Note. This function correctly accounts for portal polygons
+   * and could thus return a polygon not belonging to this sector.
+   */
+  csPolygon3D* IntersectSphere (csVector3& center, float radius,
+                               float* pr = NULL);
+
+  /**
+   * Follow a segment starting at this sector. If the segment intersects
+   * with a polygon it will stop there unless the polygon is a portal in which
+   * case it will recursively go to that sector (possibly applying warping
+   * transformations) and continue there.<p>
+   *
+   * This routine will modify all the given parameters to reflect space warping.
+   * These should be used as the new camera transformation when you decide to
+   * really go to the new position.<p>
+   *
+   * This function returns the resulting sector and new_position will be set
+   * to the last position that you can go to before hitting a wall.<p>
+   *
+   * If only_portals is true then only portals will be checked. This
+   * means that intersection with normal polygons is not checked. This
+   * is a lot faster but it does mean that you need to use another
+   * collision detection system to test with walls.
+   */
+  csSector* FollowSegment (csReversibleTransform& t, csVector3& new_position,
+                          bool& mirror, bool only_portals = false);
+
+  /**
+   * Intersect world-space segment with polygons of this sector. Return
+   * polygon it intersects with (or NULL) and the intersection point
+   * in world coordinates.<p>
+   *
+   * If 'pr' != NULL it will also return a value between 0 and 1
+   * indicating where on the 'start'-'end' vector the intersection
+   * happened.<p>
+   *
+   * This function is an extension of csPolygonSet::intersect_segment in
+   * that it will also test for hits against things.<p>
+   *
+   * If 'only_portals' == true only portals are checked.<p>
+   *
+   * If 'mesh' != NULL the mesh will be filled in.
+   */
+  csPolygon3D* IntersectSegment (const csVector3& start,
+	const csVector3& end, csVector3& isect,
+	float* pr = NULL, bool only_portals = false,
+	csMeshWrapper** p_mesh = NULL);
+
+  /**
+   * Calculate the bounding box of all objects in this sector.
+   * This function is not very efficient as it will traverse all objects
+   * in the sector one by one and compute a bounding box from that.
+   */
+  void CalculateSectorBBox (csBox3& bbox, bool do_meshes) const;
+
+  //------------------------------------------------
+  // Everything for setting up the lighting system.
+  //------------------------------------------------
+
+  /**
+   * The whole setup starts with csEngine::shine_lights calling
+   * csSector::shine_lights for every sector in the engine.
+   * This function will call csStatLight::shine_lightmaps for every
+   * light in the sector.
+   * csStatLight::shine_light will generate a view frustum from the
+   * center of the light and use that to light all polygons that
+   * are hit by the frustum.
+   */
+  void ShineLights (csProgressPulse* = 0);
+
+  /// Version of shine_lights() which only affects one mesh object.
+  void ShineLights (iMeshWrapper*, csProgressPulse* = 0);
+
+  //----------------------------------------------------------------------
+  // Various
+  //----------------------------------------------------------------------
+
+  /// Get the engine for this sector.
+  csEngine* GetEngine () const { return engine; }
+
+  /// Return true if this has fog.
+  bool HasFog () const { return fog.enabled; }
+
+  /// Return fog structure.
+  csFog& GetFog () { return fog; }
+
+  /// Conveniance function to set fog to some setting.
+  void SetFog (float density, const csColor& color)
+  {
+    fog.enabled = true;
+    fog.density = density;
+    fog.red = color.red;
+    fog.green = color.green;
+    fog.blue = color.blue;
+  }
+
+  /// Disable fog.
+  void DisableFog () { fog.enabled = false; }
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //-------------------- iReferencedObject interface --------------------------
+  struct ReferencedObject : public iReferencedObject
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csSector);
+    virtual void AddReference (iReference* ref);
+    virtual void RemoveReference (iReference* ref);
+  } scfiReferencedObject;
+  friend struct ReferencedObject;
+
+  //------------------------- iSector interface -------------------------------
+  struct eiSector : public iSector
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csSector);
+
+    virtual csSector *GetPrivateObject ()
+      { return (csSector*)scfParent; }
+    virtual iObject *QueryObject()
+      { return scfParent; }
+    virtual int GetRecLevel () const
+      { return scfParent->draw_busy; }
+    virtual void SetVisibilityCuller (const char *Name)
+      { scfParent->UseCuller (Name); }
+    virtual iVisibilityCuller* GetVisibilityCuller () const
+      { return scfParent->GetVisibilityCuller (); }
+    virtual iMeshList* GetMeshes ()
+      { return scfParent->GetMeshes (); }
+    virtual iLightList* GetLights ()
+      { return scfParent->GetLights (); }
+    virtual void ShineLights ()
+      { scfParent->ShineLights (); }
+    virtual void ShineLights (iMeshWrapper* mesh)
+      { scfParent->ShineLights (mesh); }
+    virtual void CalculateSectorBBox (csBox3& bbox, bool do_meshes) const
+      { scfParent->CalculateSectorBBox (bbox, do_meshes); }
+    virtual bool HasFog () const
+      { return scfParent->HasFog (); }
+    virtual csFog *GetFog () const
+      { return &scfParent->fog; }
+    virtual void SetFog (float density, const csColor& color)
+      { scfParent->SetFog (density, color); }
+    virtual void DisableFog ()
+      { scfParent->DisableFog (); }
+    virtual iPolygon3D* HitBeam (const csVector3& start, const csVector3& end,
+  	csVector3& isect);
+    virtual iMeshWrapper* HitBeam (const csVector3& start, const csVector3& end,
+  	csVector3& intersect, iPolygon3D** polygonPtr);
+    virtual iSector* FollowSegment (csReversibleTransform& t,
+  	csVector3& new_position, bool& mirror, bool only_portals = false);
+    virtual void Draw (iRenderView* rview)
+      { scfParent->Draw (rview); }
+  } scfiSector;
+  friend struct eiSector;
+};
+
+CS_DECLARE_OBJECT_VECTOR (csSectorListHelper, iSector);
+
+class csSectorList : public csSectorListHelper
+{
+public:
+  SCF_DECLARE_IBASE;
+  bool CleanupReferences;
+
+  /// constructor
+  csSectorList (bool CleanupReferences);
+  /// destructor
+  ~csSectorList ();
+
+  /// override FreeItem
+  virtual bool FreeItem (csSome Item);
+
+  class SectorList : public iSectorList
+  {
+  public:
+    SCF_DECLARE_EMBEDDED_IBASE (csSectorList);
+
+    virtual int GetCount () const;
+    virtual iSector *Get (int n) const;
+    virtual int Add (iSector *obj);
+    virtual bool Remove (iSector *obj);
+    virtual bool Remove (int n);
+    virtual void RemoveAll ();
+    virtual int Find (iSector *obj) const;
+    virtual iSector *FindByName (const char *Name) const;
+  } scfiSectorList;
+};
+
+#endif // __CS_SECTOR_H__
diff --git a/client/client94/crystalspace/include/csengine/stats.h b/client/client94/crystalspace/include/csengine/stats.h
new file mode 100644
index 0000000..033de07
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/stats.h
@@ -0,0 +1,42 @@
+/*
+    Statistics collection variables
+    Copyright (C) 1998 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_STATS_H__
+#define __CS_STATS_H__
+
+/**
+ * Class containing statistics information for
+ * the renderer.
+ */
+class Stats
+{
+public:
+  ///
+  static int polygons_considered;
+  ///
+  static int polygons_rejected;
+  ///
+  static int polygons_accepted;
+  ///
+  static int polygons_drawn;
+  ///
+  static int portals_drawn;
+};
+
+#endif // __CS_STATS_H__
diff --git a/client/client94/crystalspace/include/csengine/texture.h b/client/client94/crystalspace/include/csengine/texture.h
new file mode 100644
index 0000000..07e2d8d
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/texture.h
@@ -0,0 +1,224 @@
+/*
+    Copyright (C) 1998 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_TEXTURE_H__
+#define __CS_TEXTURE_H__
+
+#include "cstypes.h"
+#include "csutil/csobject.h"
+#include "csutil/nobjvec.h"
+#include "ivideo/graph2d.h"
+#include "ivideo/texture.h"
+#include "iengine/texture.h"
+#include "igraphic/image.h"
+
+class csTextureWrapper;
+struct iTextureManager;
+struct iTextureHandle;
+struct iImage;
+
+
+SCF_VERSION (csTextureWrapper, 0, 0, 1);
+
+/**
+ * csTextureWrapper represents a texture and its link
+ * to the iTextureHandle as returned by iTextureManager.
+ */
+class csTextureWrapper : public csObject
+{
+private:
+  /// The corresponding iImage.
+  iImage* image;
+  /// The handle as returned by iTextureManager.
+  iTextureHandle* handle;
+  // key color
+  int key_col_r, key_col_g, key_col_b;
+  /// Texture registration flags
+  int flags;
+
+  // The callback which is called just before texture is used.
+  iTextureCallback* use_callback;
+
+  // update our key color with that from the handle
+  void UpdateKeyColorFromHandle ()
+  {
+    if (handle && handle->GetKeyColor ())
+    {
+      uint8 r, g, b;
+      handle->GetKeyColor (r, g, b);
+      SetKeyColor ((int)r, (int)g, (int)b);
+    }
+    else
+      key_col_r = -1;
+  }
+
+  // update our key color with that from the image
+  void UpdateKeyColorFromImage ()
+  {
+    if(image->HasKeycolor ())
+      image->GetKeycolor( key_col_r, key_col_g, key_col_b );
+    else
+      key_col_r = -1;
+  }
+
+private:
+  /// Release texture handle
+  virtual ~csTextureWrapper ();
+
+public:
+
+  /// Construct a texture handle given a image file
+  csTextureWrapper (iImage* Image);
+  /// Construct a csTextureWrapper from a pre-registered texture
+  csTextureWrapper (iTextureHandle *ith);
+  /// Copy constructor
+  csTextureWrapper (csTextureWrapper &);
+
+  /**
+   * Change the base iImage. The changes will not be visible until the
+   * texture is registered again.
+   */
+  void SetImageFile (iImage *Image);
+  /// Get the iImage.
+  iImage* GetImageFile () { return image; }
+
+  /**
+   * Change the texture handle. The changes will immediatly be visible. This
+   * will also change the key color and registration flags to those of
+   * the new texture and the iImage to NULL.
+   */
+  void SetTextureHandle (iTextureHandle *tex);
+  /// Get the texture handle.
+  iTextureHandle* GetTextureHandle () { return handle; }
+
+  /// Set the transparent color.
+  void SetKeyColor (int red, int green, int blue);
+  /// Query the transparent color.
+  void GetKeyColor (int &red, int &green, int &blue)
+  { red = key_col_r; green = key_col_g; blue = key_col_b; }
+
+  /// Set the flags which are used to register the texture
+  void SetFlags (int flags) { csTextureWrapper::flags = flags; }
+  /// Return the flags which are used to register the texture
+  int GetFlags () { return flags; }
+
+  /// Register the texture with the texture manager
+  void Register (iTextureManager *txtmng);
+
+  /**
+   * Set a callback which is called just before the texture is used.
+   * This is mainly useful for procedural textures which can then
+   * choose to update their image.
+   */
+  void SetUseCallback (iTextureCallback* callback)
+  {
+    SCF_SET_REF (use_callback, callback);
+  }
+
+  /**
+   * Get the use callback. If there are multiple use callbacks you can
+   * use this function to chain.
+   */
+  iTextureCallback* GetUseCallback ()
+  {
+    return use_callback;
+  }
+
+  /**
+   * Visit this texture. This should be called by the engine right
+   * before using the texture. It is responsible for calling the use
+   * callback if there is one.
+   */
+  void Visit ()
+  {
+    if (use_callback)
+      use_callback->UseTexture (&scfiTextureWrapper);
+  }
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //-------------------- iTextureWrapper implementation -----------------------
+  struct TextureWrapper : public iTextureWrapper
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csTextureWrapper);
+
+    virtual csTextureWrapper *GetPrivateObject()
+    {return scfParent;}
+
+    virtual iObject *QueryObject();
+    virtual iTextureWrapper *Clone () const
+    { return &(new csTextureWrapper (*scfParent))->scfiTextureWrapper; }
+    virtual void SetImageFile (iImage *Image);
+    virtual iImage* GetImageFile ();
+    virtual void SetTextureHandle (iTextureHandle *tex);
+    virtual iTextureHandle* GetTextureHandle ();
+    virtual void SetKeyColor (int red, int green, int blue);
+    virtual void GetKeyColor (int &red, int &green, int &blue);
+    virtual void SetFlags (int flags);
+    virtual int GetFlags ();
+    virtual void Register (iTextureManager *txtmng);
+    virtual void SetUseCallback (iTextureCallback* callback);
+    virtual iTextureCallback* GetUseCallback ();
+    virtual void Visit ();
+  } scfiTextureWrapper;
+  friend struct TextureWrapper;
+};
+
+// helper for the texture list
+CS_DECLARE_OBJECT_VECTOR (csTextureListHelper, iTextureWrapper);
+
+/**
+ * This class is used to hold a list of textures.
+ */
+class csTextureList : public csTextureListHelper
+{
+public:
+  /// Initialize the array
+  csTextureList ();
+
+  /// Create a new texture.
+  iTextureWrapper *NewTexture (iImage *image);
+
+  /**
+   * Create a engine wrapper for a pre-prepared iTextureHandle
+   * The handle will be IncRefed
+   */
+  iTextureWrapper *NewTexture (iTextureHandle *ith);
+
+  SCF_DECLARE_IBASE;
+
+  //-------------------- iTextureList implementation -------------------------
+  class TextureList : public iTextureList
+  {
+  public:
+    SCF_DECLARE_EMBEDDED_IBASE (csTextureList);
+
+    virtual iTextureWrapper *NewTexture (iImage *image);
+    virtual iTextureWrapper *NewTexture (iTextureHandle *ith);
+    virtual int GetCount () const;
+    virtual iTextureWrapper *Get (int n) const;
+    virtual int Add (iTextureWrapper *obj);
+    virtual bool Remove (iTextureWrapper *obj);
+    virtual bool Remove (int n);
+    virtual void RemoveAll ();
+    virtual int Find (iTextureWrapper *obj) const;
+    virtual iTextureWrapper *FindByName (const char *Name) const;
+  } scfiTextureList;
+};
+
+#endif // __CS_TEXTURE_H__
diff --git a/client/client94/crystalspace/include/csengine/thing.h b/client/client94/crystalspace/include/csengine/thing.h
new file mode 100644
index 0000000..00a7199
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/thing.h
@@ -0,0 +1,1324 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_THING_H__
+#define __CS_THING_H__
+
+#include "csgeom/transfrm.h"
+#include "csutil/csobject.h"
+#include "csutil/nobjvec.h"
+#include "csengine/bsp.h"
+#include "csutil/util.h"
+#include "csutil/flags.h"
+#include "csutil/cscolor.h"
+#include "csutil/csvector.h"
+#include "csutil/garray.h"
+#include "ivaria/polymesh.h"
+#include "iengine/viscull.h"
+#include "iengine/mesh.h"
+#include "iengine/rview.h"
+#include "imesh/thing/thing.h"
+#include "imesh/object.h"
+#include "imesh/lighting.h"
+#include "iutil/eventh.h"
+#include "iutil/comp.h"
+
+class csSector;
+class csEngine;
+class csStatLight;
+class csMaterialWrapper;
+class csMaterialList;
+class csThing;
+class csPolygon3D;
+class csPolygonInt;
+class csPolygonTree;
+class csPolygon2D;
+class csPolygon2DQueue;
+class csFrustumList;
+struct iShadowBlockList;
+struct csVisObjInfo;
+struct iGraphics3D;
+struct iRenderView;
+struct iMovable;
+struct iFrustumView;
+struct iMaterialWrapper;
+struct iPolygonBuffer;
+
+/**
+ * This structure keeps the indices of the vertices which
+ * define the bounding box of a csThing. It is calculated
+ * by CreateBoundingBox() and stored with the csThing.<p>
+ *
+ * The following are six polygons which describe the faces
+ * of the bounding box (clock-wise vertex order):<br>
+ * <ul>
+ *   <li>i2,i1,i3,i4
+ *   <li>i6,i2,i4,i8
+ *   <li>i5,i6,i8,i7
+ *   <li>i1,i5,i7,i3
+ *   <li>i1,i2,i6,i5
+ *   <li>i7,i8,i4,i3
+ * </ul>
+ */
+struct csThingBBox
+{
+  int i1, i2, i3, i4, i5, i6, i7, i8;
+};
+
+/**
+ * This struct represents a line along which polygons are attached.
+ * These polygons don't have to be adjacent but they usually are.
+ * A thing has a list of these edges.
+ */
+struct csThingEdge
+{
+  int num_polygons;
+  int* polygon_indices;
+};
+
+/**
+ * A Thing is a set of polygons. A thing can be used for the
+ * outside of a sector or else to augment the sector with
+ * features that are difficult to describe with convex sectors alone.<p>
+ *
+ * Every polygon in the set has a visible and an invisible face;
+ * if the vertices of the polygon are ordered clockwise then the
+ * polygon is visible. Using this feature it is possible to define
+ * two kinds of things: in one kind the polygons are oriented
+ * such that they are visible from within the hull. In other words,
+ * the polygons form a sort of container or room where the camera
+ * can be located. This kind of thing can be used for the outside
+ * walls of a sector. In another kind the polygons are
+ * oriented such that they are visible from the outside.<p>
+ *
+ * Things can also be used for volumetric fog. In that case
+ * the Thing must be convex.<p>
+ *
+ * If you add a static tree (octree/BSP trees) to a thing it can
+ * be used as a visibility culler (i.e. it implements iVisibilityCuller).
+ */
+class csThing : public csObject
+{
+private:
+  /// ID for this thing (will be >0).
+  unsigned int thing_id;
+  /// Last used ID.
+  static int last_thing_id;
+  /// Last used polygon ID.
+  unsigned long last_polygon_id;
+  /// Name of the cache to use for lightmapping.
+  char* cachename;
+
+  /// Number of vertices
+  int num_vertices;
+  /// Maximal number of vertices
+  int max_vertices;
+
+  /// Vertices in object space.
+  csVector3* obj_verts;
+  /**
+   * Vertices in world space.
+   * It is possible that this array is equal to obj_verts. In that
+   * case this is a thing that never moves.
+   */
+  csVector3* wor_verts;
+  /// Vertices in camera space.
+  csVector3* cam_verts;
+  /// Number of vertices for cam_verts.
+  int num_cam_verts;
+  /// Camera number for which the above camera vertices are valid.
+  long cameranr;
+
+  /**
+   * This number indicates the last value of the movable number.
+   * This thing can use this to check if the world space coordinates
+   * need to be updated.
+   */
+  long movablenr;
+  /**
+   * The last movable used to move this object.
+   */
+  iMovable* cached_movable;
+  /**
+   * How is moving of this thing controlled? This is one of the
+   * CS_THING_MOVE_... flags above.
+   */
+  int cfg_moving;
+
+  /// The array of polygons forming the outside of the set
+  csPolygonArray polygons;
+  /**
+   * A vector with polygons that contain portals (optimization).
+   * csPolygon3D will make sure to call AddPortalPolygon() and
+   * RemovePortalPolygon() when appropriate.
+   */
+  csVector portal_polygons;
+
+  /**
+   * If we are a detail object then this will contain a reference to a
+   * polygon buffer for the 3D renderer. This can be used by DrawPolygonMesh.
+   */
+  iPolygonBuffer* polybuf;
+  /**
+   * An array of materials that are used with the polygon buffer.
+   */
+  iMaterialWrapper** polybuf_materials;
+  int polybuf_material_count;
+
+  /// A vector with all edges in this thing.
+  CS_DECLARE_GROWING_ARRAY (thing_edges, csThingEdge);
+  /// If false then thing_edges is not valid and needs to be recalculated.
+  bool thing_edges_valid;
+
+  /// The array of curves forming the outside of the set
+  csCurvesArray curves;
+  /**
+   * If true the transforms of the curves are set up (in case
+   * CS_THING_MOVE_NEVER is used).
+   */
+  bool curves_transf_ok;
+
+  /// Optional oriented bounding box.
+  csThingBBox* bbox;
+
+  /// Bounding box in object space.
+  csBox3 obj_bbox;
+  /**
+   * Bounding box in world space.
+   * This is a cache for GetBoundingBox(iMovable,csBox3) which
+   * will recalculate this if the movable changes (by using movablenr).
+   */
+  csBox3 wor_bbox;
+  /// Last movable number that was used for the bounding box in world space.
+  long wor_bbox_movablenr;
+
+  /// If true then the bounding box in object space is valid.
+  bool obj_bbox_valid;
+
+  /// Radius of object in object space.
+  csVector3 obj_radius;
+  /// Full radius of object in object space.
+  float max_obj_radius;
+
+  /**
+   * Light frame number. Using this number one can see if gouraud shaded
+   * vertices have been initialized already.
+   */
+  long light_frame_number;
+
+  /// Fog information.
+  csFog fog;
+
+  /**
+   * Vector with visibility objects. Only useful if this thing has a
+   * static tree and thus can do visibility testing.
+   */
+  csVector visobjects;
+
+  /**
+   * If this variable is not NULL then it is a BSP or octree for this
+   * thing.
+   */
+  csPolygonTree* static_tree;
+
+  /// If convex, this holds the index to the center vertex.
+  int center_idx;
+
+  /// Pointer to the Thing Template which it derived from.
+  csThing* ParentTemplate;
+  /// Pointer to logical parent.
+  iBase* logparent;
+
+  /// If true then this thing has been prepared (Prepare() function).
+  bool prepared;
+
+  /**
+   * Tesselation parameter:
+   * Center of thing to determine distance from
+   */
+  csVector3 curves_center;
+  /**
+   * Scale param (the larger this param it, the more the curves are
+   * tesselated).
+   */
+  float curves_scale;
+
+  /// Curve vertices.
+  csVector3* curve_vertices;
+  /// Texture coords of curve vertices
+  csVector2* curve_texels;
+
+  /// Number of vertices.
+  int num_curve_vertices;
+  /// Maximum number of vertices.
+  int max_curve_vertices;
+
+  float current_lod;
+  uint32 current_features;
+
+public:
+  /// Set of flags
+  csFlags flags;
+
+  /**
+   * Current light frame number. This is used for seeing
+   * if gouraud shading should be recalculated for this thing.
+   * If there is a mismatch between the frame number of this set
+   * and the global number then the gouraud shading is not up-to-date.
+   */
+  static long current_light_frame_number;
+
+  /**
+   * How many times are we busy drawing this thing (recursive).
+   * This is an important variable as it indicates to
+   * 'new_transformation' which set of camera vertices it should
+   * use.
+   */
+  int draw_busy;
+
+private:
+  /**
+   * Prepare the polygon buffer for use by DrawPolygonMesh.
+   * If the polygon buffer is already made then this function will do
+   * nothing.
+   */
+  void PreparePolygonBuffer ();
+
+  /**
+   * Invalidate a thing. This has to be called when new polygons are
+   * added or removed.
+   */
+  void InvalidateThing ();
+
+  /**
+   * Draw the given array of polygons in the current thing.
+   * This version uses iGraphics3D->DrawPolygonMesh()
+   * for more efficient rendering. WARNING! This version only works for
+   * lightmapped polygons right now and is far from complete.
+   */
+  void DrawPolygonArrayDPM (csPolygonInt** polygon, int num,
+	iRenderView* rview, iMovable* movable, csZBufMode zMode);
+
+  /**
+   * Draw the given array of polygons in the current csPolygonSet.
+   */
+  static void DrawPolygonArray (csPolygonInt** polygon, int num,
+	iRenderView* rview, csZBufMode zMode);
+
+  /**
+   * Test a number of polygons against the c-buffer and insert them to the
+   * c-buffer if visible and also add them to a queue.
+   * If 'pvs' is true then the PVS is used (polygon->IsVisible()).
+   */
+  static void* TestQueuePolygonArray (csPolygonInt** polygon, int num,
+	iRenderView* d, csPolygon2DQueue* poly_queue, bool pvs);
+
+  /**
+   * Draw one 3D/2D polygon combination. The 2D polygon is the transformed
+   * and clipped version of the 3D polygon.
+   */
+  static void DrawOnePolygon (csPolygon3D* p, csPolygon2D* poly,
+	iRenderView* d, csZBufMode zMode);
+
+  /**
+   * This function is called by the BSP tree traversal routine
+   * to test polygons against the C buffer and add them to a queue if needed.
+   */
+  static void* TestQueuePolygons (csThing*, csPolygonInt** polygon,
+  	int num, bool same_plane, void* data);
+
+  /**
+   * Draw a number of polygons from a queue (used with C buffer processing).
+   * Polygons are drawn using ZFILL mode.
+   */
+  void DrawPolygonsFromQueue (csPolygon2DQueue* queue, iRenderView* rview);
+
+  /**
+   * This function is called by the BSP tree traversal routine
+   * to draw a number of polygons.
+   */
+  static void* DrawPolygons (csThing*, csPolygonInt** polygon,
+  	int num, bool same_plane, void* data);
+
+  /**
+   * Check if some object needs updating in the visibility information
+   * (static tree) and do the update in that case.
+   */
+  void CheckVisUpdate (csVisObjInfo* vinf);
+
+  /**
+   * Utility function to be called whenever movable changes so the
+   * object to world transforms in all the curves have to be updated.
+   */
+  void UpdateCurveTransform (const csReversibleTransform& movtrans);
+
+  /**
+   * Utility function to call when the thing never moves but the
+   * curve transform has to be updated. The identity transformation
+   * is used.
+   */
+  void UpdateCurveTransform ();
+
+  /// Cleanup the thing edge table.
+  void CleanupThingEdgeTable ();
+
+  /// Compute table of thing edges if needed.
+  void ComputeThingEdgeTable ();
+
+  /// Generate a cachename based on geometry.
+  void GenerateCacheName ();
+
+public:
+  /**
+   * Create an empty thing.
+   */
+  csThing (iBase* parent);
+
+  /// Destructor.
+  virtual ~csThing ();
+
+  //----------------------------------------------------------------------
+  // Vertex handling functions
+  //----------------------------------------------------------------------
+
+  /// Just add a new vertex to the thing.
+  int AddVertex (const csVector3& v) { return AddVertex (v.x, v.y, v.z); }
+
+  /// Just add a new vertex to the thing.
+  int AddVertex (float x, float y, float z);
+
+  /**
+   * Add a vertex but first check if there is already
+   * a vertex close to the wanted position. In that case
+   * don't add a new vertex but return the index of the old one.
+   * Note that this function is not very efficient. If you plan
+   * to add a lot of vertices you should just use AddVertex()
+   * and call CompressVertices() later.
+   */
+  int AddVertexSmart (const csVector3& v)
+  {
+    return AddVertexSmart (v.x, v.y, v.z);
+  }
+
+  /**
+   * Add a vertex but first check if there is already
+   * a vertex close to the wanted position. In that case
+   * don't add a new vertex but return the index of the old one.
+   * Note that this function is not very efficient. If you plan
+   * to add a lot of vertices you should just use AddVertex()
+   * and call CompressVertices() later.
+   */
+  int AddVertexSmart (float x, float y, float z);
+
+  /**
+   * Compress the vertex table so that all nearly identical vertices
+   * are compressed. The polygons in the set are automatically adapted.
+   * This function can be called at any time in the creation of the object
+   * and it can be called multiple time but it normally only makes sense
+   * to call this function after you have finished adding all polygons
+   * and all vertices.<p>
+   * Note that calling this function will make the camera vertex array
+   * invalid.
+   */
+  void CompressVertices ();
+
+  /**
+   * Optimize the vertex table so that all unused vertices are deleted.
+   * Note that calling this function will make the camera vertex array
+   * invalid.
+   */
+  void RemoveUnusedVertices ();
+
+  /// Return the object space vector for the vertex.
+  const csVector3& Vobj (int idx) const { return obj_verts[idx]; }
+
+  /**
+   * Return the world space vector for the vertex.
+   * Make sure you recently called WorUpdate(). Otherwise it is
+   * possible that this coordinate will not be valid.
+   */
+  const csVector3& Vwor (int idx) const { return wor_verts[idx]; }
+
+  /**
+   * Return the camera space vector for the vertex.
+   * Make sure you recently called UpdateTransformation(). Otherwise it is
+   * possible that this coordinate will not be valid.
+   */
+  const csVector3& Vcam (int idx) const { return cam_verts[idx]; }
+
+  /// Return the number of vertices.
+  int GetVertexCount () const { return num_vertices; }
+
+  /// Change a vertex.
+  void SetVertex (int idx, const csVector3& vt);
+
+  /// Delete a vertex.
+  void DeleteVertex (int idx);
+
+  /// Delete a range of vertices.
+  void DeleteVertices (int from, int to);
+
+  //----------------------------------------------------------------------
+  // Polygon handling functions
+  //----------------------------------------------------------------------
+
+  /// Add a polygon to this thing.
+  void AddPolygon (csPolygonInt* spoly);
+
+  /// Create a new polygon in this thing and add it.
+  csPolygon3D* NewPolygon (csMaterialWrapper* material);
+
+  /// Get the number of polygons in this thing.
+  int GetPolygonCount ()
+  { return polygons.Length (); }
+
+  /// Get a csPolygonInt with the index.
+  csPolygonInt* GetPolygonInt (int idx);
+
+  /// Get the specified polygon from this set.
+  csPolygon3D *GetPolygon3D (int idx)
+  { return polygons.Get (idx); }
+
+  /// Get the named polygon from this set.
+  csPolygon3D *GetPolygon3D (const char* name);
+
+  /// Get the entire array of polygons.
+  csPolygonArray& GetPolygonArray () { return polygons; }
+
+  /**
+   * Get a new polygon ID. This is used by the polygon constructor.
+   */
+  unsigned long GetNewPolygonID ()
+  {
+    last_polygon_id++;
+    return last_polygon_id;
+  }
+
+  /// Find a polygon index.
+  int FindPolygonIndex (iPolygon3D* polygon) const;
+
+  /// Remove a single polygon.
+  void RemovePolygon (int idx);
+
+  /// Remove all polygons.
+  void RemovePolygons ();
+
+  //----------------------------------------------------------------------
+  // Curve handling functions
+  //----------------------------------------------------------------------
+
+  /// Add a curve to this thing.
+  void AddCurve (csCurve* curve);
+
+  /// Get the number of curves in this thing.
+  int GetCurveCount () const
+  { return curves.Length (); }
+
+  /// Get the specified curve from this set.
+  csCurve* GetCurve (int idx) const
+  { return curves.Get (idx); }
+
+  /// Create a curve from a template.
+  iCurve* CreateCurve (iCurveTemplate* tmpl);
+
+  /// Find a curve index.
+  int FindCurveIndex (iCurve* curve) const;
+
+  /// Delete a curve given an index.
+  void RemoveCurve (int idx);
+
+  /// Delete all curves.
+  void RemoveCurves ();
+
+  /// Get the named curve from this set.
+  csCurve* GetCurve (char* name) const;
+
+  /// Get the number of curve vertices.
+  int GetCurveVertexCount () const { return num_curve_vertices; }
+
+  /// Get the specified curve vertex.
+  csVector3& GetCurveVertex (int i) const { return curve_vertices[i]; }
+
+  /// Get the curve vertices.
+  csVector3* GetCurveVertices () const { return curve_vertices; }
+
+  /// Get the specified curve texture coordinate (texel).
+  csVector2& GetCurveTexel (int i) const { return curve_texels[i]; }
+
+  /// Get the specified curve coordinate.
+  void SetCurveVertex (int idx, const csVector3& vt);
+
+  /// Set the specified curve texture coordinate (texel).
+  void SetCurveTexel (int idx, const csVector2& vt);
+
+  /// Clear the curve vertices.
+  void ClearCurveVertices ();
+
+  /// Add a curve vertex and return the index of the vertex.
+  int AddCurveVertex (const csVector3& v, const csVector2& t);
+
+  /// Get the curve scale.
+  float GetCurvesScale () const { return curves_scale; }
+
+  /// Set the curve scale.
+  void SetCurvesScale (float f) { curves_scale = f; }
+
+  /// Get the curves center.
+  const csVector3& GetCurvesCenter () const { return curves_center; }
+
+  /// Set the curves center.
+  void SetCurvesCenter (csVector3& v) { curves_center = v; }
+
+  //----------------------------------------------------------------------
+  // Setup
+  //----------------------------------------------------------------------
+
+  /**
+   * Prepare all polygons for use. This function MUST be called
+   * AFTER the texture manager has been prepared. This function
+   * is normally called by csEngine::Prepare() so you only need
+   * to worry about this function when you add sectors or things
+   * later.
+   */
+  void Prepare ();
+
+  /**
+   * Merge the given Thing into this one. The other polygons and
+   * curves are removed from the other thing so that it is ready to
+   * be removed. Warning! All Things are merged in world space
+   * coordinates and not in object space as one could expect!
+   */
+  void Merge (csThing* other);
+
+  /**
+   * Add polygons and vertices from the specified thing (seen as template).
+   */
+  void MergeTemplate (iThingState* tpl,
+  	iMaterialWrapper* default_material = NULL,
+	csVector3* shift = NULL, csMatrix3* transform = NULL);
+
+  /**
+   * Replace the materials in this thing with new materials that are
+   * prefixed by some name. For example, if a polygon in this thing uses
+   * a material 'blabla' and the prefix is 'pref' then the new material
+   * that will be used is called 'pref_blabla'. If that material cannot
+   * be found then the original material will be used.
+   */
+  void ReplaceMaterials (iMaterialList* matList, const char* prefix);
+
+  /// Set parent template.
+  void SetTemplate (csThing *t)
+  { ParentTemplate = t; }
+
+  /// Query parent template.
+  csThing *GetTemplate () const
+  { return ParentTemplate; }
+
+  //----------------------------------------------------------------------
+  // Bounding information
+  //----------------------------------------------------------------------
+
+  /**
+   * Create an oriented bounding box (currently not oriented yet@@@)
+   * for this polygon set. This function will add the vertices for the
+   * bounding box to the set itself so that they will get translated
+   * together with the other vertices. The indices of the vertices
+   * are added to the csThingBBox structure which is returned here.
+   * Note that this creation is done in object space. The newly added
+   * vertices will not have been translated to world/camera space yet.<p>
+   */
+  void CreateBoundingBox ();
+
+  /// Get the oriented bounding box created by CreateBoundingBox().
+  csThingBBox* GetBoundingBox ()
+  {
+    if (!bbox) CreateBoundingBox ();
+    return bbox;
+  }
+
+  /**
+   * Get bounding box given some transformation.
+   */
+  void GetTransformedBoundingBox (
+	const csReversibleTransform& trans, csBox3& cbox);
+
+  /**
+   * Get bounding box in screen space.
+   */
+  float GetScreenBoundingBox (
+	float fov, float sx, float sy,
+	const csReversibleTransform& trans, csBox2& sbox, csBox3& cbox);
+
+  /**
+   * Get the bounding box in object space for this polygon set.
+   * This is calculated based on the oriented bounding box.
+   */
+  void GetBoundingBox (csBox3& box);
+
+  /**
+   * Get the bounding box for this object given some transformation (movable).
+   */
+  void GetBoundingBox (iMovable* movable, csBox3& box);
+
+  /**
+   * Get the radius in object space for this polygon set.
+   */
+  void GetRadius (csVector3& rad, csVector3& cent);
+
+  /**
+   * Add a polygon to the list of polygons having a portal.
+   * This function is called by a csPolygon3D in this thing
+   * whenever it gets a portal.
+   */
+  void AddPortalPolygon (csPolygon3D* poly);
+
+  /**
+   * Remove a polygon from the list of polygons having a portal.
+   */
+  void RemovePortalPolygon (csPolygon3D* poly);
+
+  //----------------------------------------------------------------------
+  // Visibility culler
+  //----------------------------------------------------------------------
+
+  /**
+   * Get the static polygon tree.
+   */
+  csPolygonTree* GetStaticTree () { return static_tree; }
+
+  /**
+   * Call this function to generate a polygon tree for this csThing.
+   * This might make drawing more efficient because
+   * this thing can then be drawn using Z-fill instead of Z-buffer.
+   * Also the c-buffer requires a tree of this kind.
+   */
+  void BuildStaticTree (const char* name, int mode = BSP_MINIMIZE_SPLITS);
+
+  /// Register a visibility object with this culler.
+  void RegisterVisObject (iVisibilityObject* visobj);
+  /// Unregister a visibility object with this culler.
+  void UnregisterVisObject (iVisibilityObject* visobj);
+
+  /**
+   * Do the visibility test from a given viewpoint. This will first
+   * clear the visible flag on all registered objects and then it will
+   * mark all visible objects.
+   */
+  bool VisTest (iRenderView* irview);
+
+  //----------------------------------------------------------------------
+  // Shadow System
+  //----------------------------------------------------------------------
+
+  /// Register a shadow receiver.
+  void RegisterShadowReceiver (iShadowReceiver* receiver);
+  /// Unregister a shadow receiver.
+  void UnregisterShadowReceiver (iShadowReceiver* receiver);
+
+  /**
+   * Start casting shadows from a given point in space.
+   */
+  void CastShadows (iFrustumView* fview);
+
+  //----------------------------------------------------------------------
+  // Drawing
+  //----------------------------------------------------------------------
+
+  /**
+   * Test if this thing is visible or not.
+   */
+  bool DrawTest (iRenderView* rview, iMovable* movable);
+
+  /**
+   * Draw this thing given a view and transformation.
+   */
+  bool Draw (iRenderView* rview, iMovable* movable, csZBufMode zMode);
+
+  /**
+   * Draw all curves in this thing given a view and transformation.
+   */
+  bool DrawCurves (iRenderView* rview, iMovable* movable, csZBufMode zMode);
+
+  /**
+   * Draw this thing as a fog volume (only when fog is enabled for
+   * this thing).
+   */
+  bool DrawFoggy (iRenderView* rview, iMovable* movable);
+
+  //----------------------------------------------------------------------
+  // Lighting
+  //----------------------------------------------------------------------
+
+  /**
+   * Init the lightmaps for all polygons in this thing.
+   */
+  void InitializeDefault ();
+
+  /**
+   * Read the lightmaps from the cache.
+   */
+  bool ReadFromCache (iCacheManager* cache_mgr, int id);
+
+  /**
+   * Cache the lightmaps for all polygons in this thing.
+   */
+  bool WriteToCache (iCacheManager* cache_mgr, int id);
+
+  /**
+   * Prepare the lightmaps for all polys so that they are suitable
+   * for the 3D rasterizer.
+   */
+  void PrepareLighting ();
+
+  /// Set the cache name for this thing.
+  void SetCacheName (const char* n)
+  {
+    delete[] cachename;
+    cachename = n ? csStrNew (n) : 0;
+  }
+  /// Get the cache name.
+  const char* GetCacheName ();
+
+  //----------------------------------------------------------------------
+  // Utility functions
+  //----------------------------------------------------------------------
+
+  /**
+   * Intersects object-space sphere with polygons of this set. Return
+   * polygon it hits with (or NULL) and the intersection point
+   * in object coordinates. It will also return the polygon with the
+   * closest hit (the most nearby polygon).
+   * If 'pr' != NULL it will also return the distance where the
+   * intersection happened.
+   */
+  csPolygon3D* IntersectSphere (csVector3& center, float radius,
+  	float* pr = NULL);
+
+  /**
+   * Intersect object-space segment with polygons of this set. Return
+   * polygon it intersects with (or NULL) and the intersection point
+   * in object coordinates.<p>
+   *
+   * If 'pr' != NULL it will also return a value between 0 and 1
+   * indicating where on the 'start'-'end' vector the intersection
+   * happened.<p>
+   *
+   * If only_portals == true then only portals are checked.
+   */
+  csPolygon3D* IntersectSegment (const csVector3& start,
+	const csVector3& end, csVector3& isect,
+	float* pr = NULL, bool only_portals = false);
+
+  /**
+   * Intersect object-space segment with polygons of this set. Return
+   * polygon it intersects with (or NULL) and the intersection point
+   * in object coordinates.<p>
+   *
+   * If 'pr' != NULL it will also return a value between 0 and 1
+   * indicating where on the 'start'-'end' vector the intersection
+   * happened.<p>
+   *
+   * This version is similar to IntersectSegment() but it will also test
+   * polygons of all objects which are registered to the visibility culler
+   * of this thing (if there is any). It also returns the mesh wrapper
+   * that was hit. If this is NULL then this mesh was hit.
+   */
+  csPolygon3D* IntersectSegmentFull (const csVector3& start,
+	const csVector3& end, csVector3& isect,
+	float* pr = NULL, csMeshWrapper** p_mesh = NULL);
+
+  /**
+   * Check frustum visibility on this thing.
+   */
+  void RealCheckFrustum (iFrustumView* lview, iMovable* movable);
+
+  /**
+   * Check frustum visibility on this thing.
+   * First initialize the 2D culler cube.
+   */
+  void CheckFrustum (iFrustumView* lview, iMovable* movable);
+
+  /**
+   * Return a list of shadow frustums which extend from
+   * this thing. The origin is the position of the light.
+   * Note that this function uses camera space coordinates and
+   * thus assumes that this thing is transformed to the
+   * origin of the light.
+   */
+  void AppendShadows (iMovable* movable, iShadowBlockList* shadows,
+  	csVector3& origin);
+
+  //----------------------------------------------------------------------
+  // Transformation
+  //----------------------------------------------------------------------
+
+  /**
+   * Transform to the given camera if needed. This function will use
+   * the camera number to avoid unneeded transformation.
+   */
+  void UpdateTransformation (const csTransform& c, long cam_cameranr);
+
+  /// Make sure the world vertices are up-to-date.
+  void WorUpdate ();
+
+  /**
+   * Do a hard transform of the object vertices.
+   * This transformation and the original coordinates are not
+   * remembered but the object space coordinates are directly
+   * computed (world space coordinates are set to the object space
+   * coordinates by this routine).
+   */
+  void HardTransform (const csReversibleTransform& t);
+
+  /// Get the array of camera vertices.
+  csVector3* GetCameraVertices (const csTransform& c, long cam_cameranr)
+  {
+    UpdateTransformation (c, cam_cameranr);
+    return cam_verts;
+  }
+
+  //----------------------------------------------------------------------
+  // Various
+  //----------------------------------------------------------------------
+
+  /**
+   * Control how this thing will be moved.
+   */
+  void SetMovingOption (int opt);
+
+  /**
+   * Get the moving option.
+   */
+  int GetMovingOption () const { return cfg_moving; }
+
+  /**
+   * Set convexity flag of this thing. You should call this instead
+   * of SetFlags (CS_ENTITY_CONVEX, CS_ENTITY_CONVEX) because this function
+   * does some extra calculations.
+   */
+  void SetConvex (bool c);
+
+  /**
+   * If this thing is convex you can use getCenter to get the index
+   * of the vertex holding the center of this thing. This center is
+   * calculated by 'setConvex(true)'.
+   */
+  int GetCenter () { return center_idx; }
+
+  /// Return true if this has fog.
+  bool HasFog () { return fog.enabled; }
+
+  /// Return fog structure.
+  csFog& GetFog () { return fog; }
+
+  /// Conveniance function to set fog to some setting.
+  void SetFog (float density, const csColor& color)
+  {
+    fog.enabled = true;
+    fog.density = density;
+    fog.red = color.red;
+    fog.green = color.green;
+    fog.blue = color.blue;
+  }
+
+  /// Disable fog.
+  void DisableFog () { fog.enabled = false; }
+
+  SCF_DECLARE_IBASE_EXT (csObject);
+
+  //------------------------- iThingState interface -------------------------
+  struct ThingState : public iThingState
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csThing);
+    virtual void* GetPrivateObject () { return (void*)scfParent; }
+    virtual iObject* QueryObject () { return scfParent; }
+    virtual void CompressVertices () { scfParent->CompressVertices(); }
+
+    virtual int GetPolygonCount () { return scfParent->polygons.Length (); }
+    virtual iPolygon3D *GetPolygon (int idx);
+    virtual iPolygon3D *GetPolygon (const char* name);
+    virtual iPolygon3D *CreatePolygon (const char *iName);
+    virtual int FindPolygonIndex (iPolygon3D* polygon) const
+    { return scfParent->FindPolygonIndex (polygon); }
+    virtual void RemovePolygon (int idx)
+    { scfParent->RemovePolygon (idx); }
+    virtual void RemovePolygons ()
+    { scfParent->RemovePolygons (); }
+
+    virtual int GetPortalCount () const;
+    virtual iPortal* GetPortal (int idx) const;
+    virtual iPolygon3D* GetPortalPolygon (int idx) const;
+
+    virtual int GetVertexCount () const { return scfParent->num_vertices; }
+    virtual const csVector3 &GetVertex (int i) const
+    { return scfParent->obj_verts[i]; }
+    virtual const csVector3* GetVertices () const
+    { return scfParent->obj_verts; }
+    virtual const csVector3 &GetVertexW (int i) const
+    { return scfParent->wor_verts[i]; }
+    virtual const csVector3* GetVerticesW () const
+    { return scfParent->wor_verts; }
+    virtual const csVector3 &GetVertexC (int i) const
+    { return scfParent->cam_verts[i]; }
+    virtual const csVector3* GetVerticesC () const
+    { return scfParent->cam_verts; }
+    virtual int CreateVertex (const csVector3 &iVertex)
+    { return scfParent->AddVertex (iVertex.x, iVertex.y, iVertex.z); }
+    virtual void SetVertex (int idx, const csVector3& vt)
+    { scfParent->SetVertex (idx, vt); }
+    virtual void DeleteVertex (int idx)
+    { scfParent->DeleteVertex (idx); }
+    virtual void DeleteVertices (int from, int to)
+    { scfParent->DeleteVertices (from, to); }
+
+    virtual void CheckFrustum (iFrustumView* fview, iMovable* movable)
+    { scfParent->CheckFrustum (fview, movable); }
+    virtual csFlags& GetFlags () { return scfParent->flags; }
+    virtual int GetMovingOption () const
+    { return scfParent->GetMovingOption (); }
+    virtual void SetMovingOption (int opt)
+    { scfParent->SetMovingOption (opt); }
+
+    virtual const csVector3& GetCurvesCenter () const
+    { return scfParent->curves_center; }
+    virtual void SetCurvesCenter (const csVector3& cen)
+    { scfParent->curves_center = cen; }
+    virtual float GetCurvesScale () const
+    { return scfParent->curves_scale; }
+    virtual void SetCurvesScale (float scale)
+    { scfParent->curves_scale = scale; }
+    virtual int GetCurveCount () const
+    { return scfParent->GetCurveCount (); }
+    virtual int GetCurveVertexCount () const
+    { return scfParent->GetCurveVertexCount (); }
+    virtual csVector3& GetCurveVertex (int i) const
+    { return scfParent->GetCurveVertex (i); }
+    virtual csVector3* GetCurveVertices () const
+    { return scfParent->GetCurveVertices (); }
+    virtual csVector2& GetCurveTexel (int i) const
+    { return scfParent->GetCurveTexel (i); }
+    virtual void SetCurveVertex (int idx, const csVector3& vt)
+    { scfParent->SetCurveVertex (idx, vt); }
+    virtual void SetCurveTexel (int idx, const csVector2& vt)
+    { scfParent->SetCurveTexel (idx, vt); }
+    virtual void ClearCurveVertices ()
+    { scfParent->ClearCurveVertices (); }
+    virtual iCurve* GetCurve (int idx) const;
+    virtual iCurve* CreateCurve (iCurveTemplate* tmpl)
+    { return scfParent->CreateCurve (tmpl); }
+    virtual int FindCurveIndex (iCurve* curve) const
+    { return scfParent->FindCurveIndex (curve); }
+    virtual void RemoveCurve (int idx)
+    { scfParent->RemoveCurve (idx); }
+    virtual void RemoveCurves ()
+    { scfParent->RemoveCurves (); }
+
+    virtual void MergeTemplate (iThingState* tpl,
+  	iMaterialWrapper* default_material = NULL,
+	csVector3* shift = NULL, csMatrix3* transform = NULL)
+    {
+      scfParent->MergeTemplate (tpl, default_material, shift, transform);
+    }
+    virtual void ReplaceMaterials (iMaterialList* materials,
+    	const char* prefix)
+    {
+      scfParent->ReplaceMaterials (materials, prefix);
+    }
+    virtual void AddCurveVertex (const csVector3& v, const csVector2& uv)
+    {
+      scfParent->AddCurveVertex (v, uv);
+    }
+    virtual bool HasFog () const
+    { return scfParent->HasFog (); }
+    virtual csFog *GetFog () const
+    { return &scfParent->GetFog (); }
+  } scfiThingState;
+  friend struct ThingState;
+
+  //------------------------- iLightingInfo interface -------------------------
+  struct LightingInfo : public iLightingInfo
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csThing);
+    virtual void InitializeDefault ()
+    {
+      scfParent->InitializeDefault ();
+    }
+    virtual bool ReadFromCache (iCacheManager* cache_mgr, int id)
+    {
+      return scfParent->ReadFromCache (cache_mgr, id);
+    }
+    virtual bool WriteToCache (iCacheManager* cache_mgr, int id)
+    {
+      return scfParent->WriteToCache (cache_mgr, id);
+    }
+    virtual void PrepareLighting ()
+    {
+      scfParent->PrepareLighting ();
+    }
+    virtual void SetCacheName (const char* cachename)
+    {
+      scfParent->SetCacheName (cachename);
+    }
+    virtual const char* GetCacheName () const
+    {
+      return scfParent->GetCacheName ();
+    }
+  } scfiLightingInfo;
+  friend struct LightingInfo;
+
+  //-------------------- iPolygonMesh interface implementation ---------------
+  struct PolyMesh : public iPolygonMesh
+  {
+    PolyMesh () : polygons (NULL), vertices (NULL), alloc_vertices (NULL) { }
+    virtual ~PolyMesh () { Cleanup (); }
+    void Setup ();
+
+    SCF_DECLARE_EMBEDDED_IBASE (csThing);
+
+    virtual int GetVertexCount ()
+    {
+      Setup ();
+      return num_verts;
+    }
+    virtual csVector3* GetVertices ()
+    {
+      Setup ();
+      return vertices;
+    }
+    virtual int GetPolygonCount ()
+    {
+      Setup ();
+      return num_poly;
+    }
+    virtual csMeshedPolygon* GetPolygons ()
+    {
+      Setup ();
+      return polygons;
+    }
+    virtual void Cleanup ();
+
+    csMeshedPolygon* polygons;	// Array of polygons.
+    csVector3* vertices;	// Array of vertices (points to alloc_vertices
+    				// or else obj_verts of scfParent).
+    csVector3* alloc_vertices;	// Optional copy of vertices from parent.
+    				// This copy is used if there are curve
+				// vertices.
+    int num_poly;		// Total number of polygons.
+    int curve_poly_start;	// Index of first polygon from curves.
+    				// Polygons after this index need to be
+				// deleted individually.
+    int num_verts;		// Total number of vertices.
+  } scfiPolygonMesh;
+  friend struct PolyMesh;
+
+  //-------------------- iVisibilityCuller interface implementation ----------
+  struct VisCull : public iVisibilityCuller
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csThing);
+    virtual void Setup (const char* name)
+    {
+      scfParent->BuildStaticTree (name, BSP_MINIMIZE_SPLITS);
+    }
+    virtual void RegisterVisObject (iVisibilityObject* visobj)
+    {
+      scfParent->RegisterVisObject (visobj);
+    }
+    virtual void UnregisterVisObject (iVisibilityObject* visobj)
+    {
+      scfParent->UnregisterVisObject (visobj);
+    }
+    virtual bool VisTest (iRenderView* irview)
+    {
+      return scfParent->VisTest (irview);
+    }
+    virtual iPolygon3D* IntersectSegment (const csVector3& start,
+      const csVector3& end, csVector3& isect, float* pr = NULL,
+      iMeshWrapper** p_mesh = NULL);
+    virtual bool SupportsShadowCasting ()
+    {
+      return true;
+    }
+    virtual void RegisterShadowReceiver (iShadowReceiver* receiver)
+    {
+      scfParent->RegisterShadowReceiver (receiver);
+    }
+    virtual void UnregisterShadowReceiver (iShadowReceiver* receiver)
+    {
+      scfParent->UnregisterShadowReceiver (receiver);
+    }
+    virtual void CastShadows (iFrustumView* fview)
+    {
+      scfParent->CastShadows (fview);
+    }
+  } scfiVisibilityCuller;
+  friend struct VisCull;
+
+  //-------------------- iMeshObject interface implementation ----------
+  struct MeshObject : public iMeshObject
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csThing);
+    virtual iMeshObjectFactory* GetFactory () const;
+    virtual bool DrawTest (iRenderView* rview, iMovable* movable)
+    {
+      return scfParent->DrawTest (rview, movable);
+    }
+    virtual void UpdateLighting (iLight** /*lights*/, int /*num_lights*/,
+      	iMovable* /*movable*/) { }
+    virtual bool Draw (iRenderView* rview, iMovable* movable,
+    	csZBufMode zMode)
+    {
+      return scfParent->Draw (rview, movable, zMode);
+    }
+    virtual void SetVisibleCallback (iMeshObjectDrawCallback* /*cb*/) { }
+    virtual iMeshObjectDrawCallback* GetVisibleCallback () const
+    { return NULL; }
+    virtual void GetObjectBoundingBox (csBox3& bbox,
+    	int /*type = CS_BBOX_NORMAL*/)
+    {
+      scfParent->GetBoundingBox (bbox);
+    }
+    virtual void GetRadius ( csVector3& rad, csVector3& cent)
+	  { scfParent->GetRadius (rad,cent); }
+    virtual void NextFrame (csTicks /*current_time*/) { }
+    virtual bool WantToDie () const { return false; }
+    virtual void HardTransform (const csReversibleTransform& t)
+    {
+      scfParent->HardTransform (t);
+    }
+    virtual bool SupportsHardTransform () const { return true; }
+    virtual bool HitBeamOutline (const csVector3&, const csVector3&,
+      csVector3&, float*)
+    { return false; }
+    virtual bool HitBeamObject (const csVector3& /*start*/,
+    	const csVector3& /*end*/,
+  	csVector3& /*isect*/, float* /*pr*/) { return false; }
+    virtual long GetShapeNumber () const { return 0; /*@@@*/ }
+    virtual void SetLogicalParent (iBase* lp) { scfParent->logparent = lp; }
+    virtual iBase* GetLogicalParent () const { return scfParent->logparent; }
+  } scfiMeshObject;
+  friend struct MeshObject;
+
+  //-------------------- iMeshObjectFactory interface implementation ---------
+  struct MeshObjectFactory : public iMeshObjectFactory
+  {
+    SCF_DECLARE_EMBEDDED_IBASE (csThing);
+    virtual iMeshObject* NewInstance ();
+    virtual void HardTransform (const csReversibleTransform& t)
+    {
+      scfParent->HardTransform (t);
+    }
+    virtual bool SupportsHardTransform () const { return true; }
+    virtual void SetLogicalParent (iBase* lp) { scfParent->logparent = lp; }
+    virtual iBase* GetLogicalParent () const { return scfParent->logparent; }
+  } scfiMeshObjectFactory;
+  friend struct MeshObjectFactory;
+};
+
+/**
+ * Thing type. This is the plugin you have to use to create instances
+ * of csThing.
+ */
+class csThingObjectType : public iMeshObjectType
+{
+private:
+  iObjectRegistry* object_reg;
+
+  /**
+   * List of planes. This vector contains objects of type
+   * csPolyTxtPlane*. Note that this vector only contains named
+   * planes. Default planes which are created for polygons
+   * are not in this list.
+   */
+  csNamedObjVector planes;
+
+  /**
+   * List of curve templates (bezier templates). This vector contains objects of
+   * type csCurveTemplate*.
+   */
+  csNamedObjVector curve_templates;
+
+public:
+  SCF_DECLARE_IBASE;
+
+  /// Constructor.
+  csThingObjectType (iBase*);
+
+  /// Destructor.
+  virtual ~csThingObjectType ();
+
+  /// Register plugin with the system driver
+  virtual bool Initialize (iObjectRegistry *object_reg);
+
+  /// New Factory.
+  virtual iMeshObjectFactory* NewFactory ();
+
+  iPolyTxtPlane* CreatePolyTxtPlane (const char* name = NULL);
+  iPolyTxtPlane* FindPolyTxtPlane (const char* name);
+  iCurveTemplate* CreateBezierTemplate (const char* name = NULL);
+  iCurveTemplate* FindCurveTemplate (const char *iName);
+  void RemovePolyTxtPlane (iPolyTxtPlane* pl);
+  void RemoveCurveTemplate (iCurveTemplate* ct);
+  void ClearPolyTxtPlanes ();
+  void ClearCurveTemplates ();
+
+  struct eiThingEnvironment : public iThingEnvironment
+  {
+    SCF_DECLARE_EMBEDDED_IBASE(csThingObjectType);
+    virtual iPolyTxtPlane* CreatePolyTxtPlane (const char* name = NULL)
+    {
+      return scfParent->CreatePolyTxtPlane (name);
+    }
+    virtual iPolyTxtPlane* FindPolyTxtPlane (const char* name)
+    {
+      return scfParent->FindPolyTxtPlane (name);
+    }
+    virtual iCurveTemplate* CreateBezierTemplate (const char* name = NULL)
+    {
+      return scfParent->CreateBezierTemplate (name);
+    }
+    virtual iCurveTemplate* FindCurveTemplate (const char* name)
+    {
+      return scfParent->FindCurveTemplate (name);
+    }
+    virtual void RemovePolyTxtPlane (iPolyTxtPlane* pl)
+    {
+      scfParent->RemovePolyTxtPlane (pl);
+    }
+    virtual void RemoveCurveTemplate (iCurveTemplate* ct)
+    {
+      scfParent->RemoveCurveTemplate (ct);
+    }
+    virtual void ClearPolyTxtPlanes ()
+    {
+      scfParent->ClearPolyTxtPlanes ();
+    }
+    virtual void ClearCurveTemplates ()
+    {
+      scfParent->ClearCurveTemplates ();
+    }
+  } scfiThingEnvironment;
+
+  struct eiComponent : public iComponent
+  {
+    SCF_DECLARE_EMBEDDED_IBASE(csThingObjectType);
+    virtual bool Initialize (iObjectRegistry* p)
+    { return scfParent->Initialize(p); }
+  } scfiComponent;
+};
+
+#endif // __CS_THING_H__
diff --git a/client/client94/crystalspace/include/csengine/treeobj.h b/client/client94/crystalspace/include/csengine/treeobj.h
new file mode 100644
index 0000000..6d2d2d7
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/treeobj.h
@@ -0,0 +1,180 @@
+/*
+    Copyright (C) 2000 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_TREEOBJ_H__
+#define __CS_TREEOBJ_H__
+
+#include "csutil/csvector.h"
+#include "csgeom/math3d.h"
+#include "csgeom/box.h"
+#include "csengine/polyint.h"
+#include "csengine/polytree.h"
+
+class csObject;
+class csPolygonStubPool;
+class csPolygonInt;
+class csPolygonIntPool;
+class csPolygonTreeNode;
+class csPolyTreeBBox;
+class csThing;
+
+/**
+ * An object stub. For a given tree object there can be
+ * many object stubs. Every stub represents some object (or
+ * part of that object) that belongs to some node.
+ */
+class csPolygonStub
+{
+  friend class csPolyTreeBBox;
+  friend class csPolygonTreeNode;
+  friend class csPolygonStubPool;
+
+private:
+  // Linked list in every tree node.
+  csPolygonStub* next_tree, * prev_tree;
+  // Linked list in every csPolyTreeBBox.
+  csPolygonStub* next_obj, * prev_obj;
+  // Object where this stub lives.
+  csPolyTreeBBox* object;
+  // Tree node where this stub lives.
+  csPolygonTreeNode* node;
+  // Reference counter. This ref counter is managed by the
+  // csPolygonStubPool.
+  int ref_count;
+
+  // List of polygons.
+  csPolygonIntArray polygons;
+  // The pool that is used to create polygons.
+  csPolygonIntPool* poly_pool;
+
+public:
+  /// Initialize this stub with a polygon pool.
+  csPolygonStub (csPolygonIntPool* pool) : next_tree (NULL),
+  	prev_tree (NULL), next_obj (NULL), prev_obj (NULL),
+	object (NULL), node (NULL), ref_count (1), poly_pool (pool) { }
+  ~csPolygonStub ()
+  {
+    RemoveStub ();
+  }
+
+  // Increment the ref counter.
+  void IncRef () { ref_count++; }
+  // Decrement the ref counter.
+  void DecRef () { if (ref_count <= 0) DEBUG_BREAK; ref_count--; }
+
+  /// Unlink this stub from all lists.
+  void RemoveStub ();
+
+  /// Get parent object for this stub.
+  csPolyTreeBBox* GetObject () { return object; }
+
+  /// Get access to the list of polygons in this stub.
+  csPolygonIntArray& GetPolygonArray () { return polygons; }
+  /// Get list of polygons.
+  csPolygonInt** GetPolygons () { return polygons.GetPolygons (); }
+  /// Get number of polygons.
+  int GetPolygonCount () { return polygons.GetPolygonCount (); }
+
+  /// Visit this stub while traversing the tree (octree or BSP tree).
+  void* Visit (csThing* thing, csTreeVisitFunc* func, void* data)
+  {
+    return func (thing, polygons.GetPolygons (), polygons.GetPolygonCount (),
+    	false, data);
+  }
+
+  /// Initialize this stub.
+  void Initialize ()
+  {
+    polygons.Reset ();
+  }
+
+  /**
+   * Clean up data from this stub.
+   */
+  void RemoveData ();
+};
+
+/**
+ * A csPolygonStub factory. This factory will create objects
+ * of type csPolygonStub.
+ */
+class csPolygonStubFactory
+{
+private:
+  // The pool that is used to create polygons.
+  csPolygonIntPool* poly_pool;
+
+public:
+  /// Initialize this stub factory with a polygon pool.
+  csPolygonStubFactory (csPolygonIntPool* pool) : poly_pool (pool) { }
+
+  /// Create a new stub.
+  csPolygonStub* Create ()
+  {
+    return new csPolygonStub (poly_pool);
+  }
+};
+
+/**
+ * This is an object pool which holds objects of type
+ * csPolygonStub. You control which type of csPolygonStub you need
+ * by the factory that you give with Alloc().
+ * You can ask new instances from this pool.
+ * If needed it will allocate one for you but ideally it can
+ * give you one which was allocated earlier.
+ */
+class csPolygonStubPool
+{
+private:
+  struct PoolObj
+  {
+    PoolObj* next;
+    csPolygonStub* ps;
+  };
+  /// List of allocated polygon stubs.
+  PoolObj* alloced;
+  /// List of previously allocated, but now unused stubs.
+  PoolObj* freed;
+
+public:
+  /// Create an empty pool.
+  csPolygonStubPool () : alloced (NULL), freed (NULL) { }
+
+  /// Destroy pool and all objects in the pool.
+  ~csPolygonStubPool ();
+
+  /**
+   * Allocate a new object in the pool.
+   * The object is initialized to empty.
+   */
+  csPolygonStub* Alloc (csPolygonStubFactory* factory);
+
+  /**
+   * Free an object and put it back in the pool. This function will
+   * call DecRef on the stub and only free it for real if the ref
+   * counter reaches zero.
+   * Note that it is only legal to free objects which were allocated
+   * from the pool.
+   */
+  void Free (csPolygonStub* ps);
+
+  /// Dump some information about this pool.
+  void Dump ();
+};
+
+#endif // __CS_TREEOBJ_H__
diff --git a/client/client94/crystalspace/include/csengine/wirefrm.h b/client/client94/crystalspace/include/csengine/wirefrm.h
new file mode 100644
index 0000000..4c7074b
--- /dev/null
+++ b/client/client94/crystalspace/include/csengine/wirefrm.h
@@ -0,0 +1,289 @@
+/*
+    Copyright (C) 1998 by Jorrit Tyberghein
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_WIREFRM_H__
+#define __CS_WIREFRM_H__
+
+#include "csutil/scf.h"
+#include "csgeom/math3d.h"
+#include "csgeom/math2d.h"
+
+struct iGraphics3D;
+struct iTextureManager;
+class csCamera;
+
+#define PLANE_VERTEX_RADIUS 0.1f
+
+#define WF_ORTHO_PERSP -1
+#define WF_ORTHO_X 0
+#define WF_ORTHO_Y 1
+#define WF_ORTHO_Z 2
+
+/**
+ * A color for an object in a WireFrame.
+ * This color object is special in that it provides support
+ * for depth based dimming.
+ */
+class csWfColor
+{
+public:
+  csWfColor* next;	// Next color.
+  int r, g, b;		// Base color.
+  int col_idx[16];	// 16-levels based on distance.
+
+public:
+  ///
+  csWfColor (iTextureManager* txtmgr, int r, int g, int b);
+  /// Get a color based on depth.
+  int GetColor (float z);
+};
+
+/**
+ * Object in a WireFrame.
+ */
+class csWfObject
+{
+private:
+  csWfObject* next, * prev;
+
+protected:
+  csWfColor* color;
+
+public:
+  ///
+  csWfObject ();
+  ///
+  virtual ~csWfObject ();
+
+  /// Set the prefered color.
+  void SetColor (csWfColor* col) { color = col; }
+  ///
+  csWfColor* GetColor () { return color; }
+
+  ///
+  csWfObject* GetNext () { return next; }
+  ///
+  csWfObject* GetPrev () { return prev; }
+  ///
+  void SetNext (csWfObject* ob) { next = ob; }
+  ///
+  void SetPrev (csWfObject* ob) { prev = ob; }
+
+  /// Draw this object given a camera.
+  virtual void Draw (iGraphics3D* g, csCamera* c, int ortho = WF_ORTHO_PERSP) = 0;
+
+  /// Do the perspective transform.
+  bool Perspective (csCamera* c, csVector3& v, csVector2& persp, float radius, float& pradius);
+  //
+  /// Do an orthographic transform.
+  bool Orthographic (csCamera* c, int ortho, csVector3& v, csVector2& persp);
+};
+
+/**
+ * Vertex in a WireFrame.
+ */
+class csWfVertex : public csWfObject
+{
+private:
+  csVector3 loc;
+
+public:
+  ///
+  csVector3& GetLocation () { return loc; }
+
+  ///
+  void SetLocation (const csVector3& v) { loc = v; }
+  ///
+  void SetLocation (float x, float y, float z) { loc.x = x; loc.y = y; loc.z = z; }
+
+  ///
+  virtual void Draw (iGraphics3D* g, csCamera* c, int ortho = WF_ORTHO_PERSP);
+};
+
+/**
+ * Line in a WireFrame.
+ */
+class csWfLine : public csWfObject
+{
+private:
+  csVector3 v1, v2;
+
+public:
+  ///
+  csVector3& GetVertex1 () { return v1; }
+  ///
+  csVector3& GetVertex2 () { return v2; }
+  ///
+  void SetLine (csVector3& vv1, csVector3& vv2) { v1 = vv1; v2 = vv2; }
+
+  ///
+  virtual void Draw (iGraphics3D* g, csCamera* c, int ortho = WF_ORTHO_PERSP);
+};
+
+/**
+ * A polygon in a WireFrame.
+ */
+class csWfPolygon : public csWfObject
+{
+private:
+  int num_vertices;
+  csVector3* vertices;
+  csVector3 center;		// Calculated center of polygon.
+  float A, B, C, D;		// Plane equation of polygon.
+  csWfColor* vcolor;		// Visibility color.
+
+public:
+  ///
+  csWfPolygon ();
+  ///
+  virtual ~csWfPolygon ();
+
+  ///
+  void SetVertexCount (int n);
+  ///
+  int GetVertexCount () { return num_vertices; }
+  ///
+  void SetVertex (int i, csVector3& v);
+
+  /// Set the prefered color for the visibility lines.
+  void SetVisColor (csWfColor* vcol) { vcolor = vcol; }
+
+  /// This function should be called after all vertices have been set.
+  void Prepare ();
+
+  /// Return true if object is visible from a given camera.
+  bool IsVisible (csCamera* camera);
+
+  ///
+  virtual void Draw (iGraphics3D* g, csCamera* c, int ortho = WF_ORTHO_PERSP);
+};
+
+/**
+ * A WireFrame is a set of lines, vertices and polygons in 3D.
+ * You can draw it given a camera.
+ */
+class csWireFrame
+{
+private:
+  csWfObject* objects;
+  iTextureManager* txtmgr;
+  csWfColor* colors;
+  csWfColor* white;
+  csWfColor* red;
+  csWfColor* green;
+  csWfColor* blue;
+  csWfColor* yellow;
+
+  size_t numObjects;
+
+public:
+  ///
+  csWireFrame (iTextureManager* txtmgr);
+  ///
+  virtual ~csWireFrame ();
+
+  ///
+  void Clear ();
+
+  ///
+  size_t Entries () { return numObjects; }
+
+  /// Get the default white color.
+  csWfColor* GetWhite () { return white; }
+
+  /// Get the default red color.
+  csWfColor* GetRed () { return red; }
+
+  /// Get the default blue color.
+  csWfColor* GetBlue () { return blue; }
+
+  /// Get the default green color.
+  csWfColor* GetGreen () { return green; }
+
+  /// Get the default yellow color.
+  csWfColor* GetYellow () { return yellow; }
+
+  /**
+   * Find a registered color.
+   */
+  csWfColor* FindColor (int r, int g, int b);
+
+  /**
+   * Register a color so that it can be used by objects in
+   * the wireframe. This is needed because colors are
+   * represented by an array (darker colors for objects in the
+   * distance).<p>
+   * The returned value is the one that should be given to the
+   * csWfObject::SetColor function.
+   */
+  csWfColor* RegisterColor (int r, int g, int b);
+
+  ///
+  csWfVertex* AddVertex (const csVector3& v);
+  ///
+  csWfLine* AddLine (csVector3& v1, csVector3& v2);
+  ///
+  csWfPolygon* AddPolygon ();
+
+  ///
+  void Draw (iGraphics3D* g, csCamera* c, int ortho = WF_ORTHO_PERSP);
+
+  /// Apply a function to all objects contained in the WireFrame
+  void Apply (void (*func)( csWfObject*, void*), void*);
+};
+
+/**
+ * A WireFrame associated with a camera.
+ */
+class csWireFrameCam
+{
+private:
+  csWireFrame* wf;
+  csCamera* c;
+
+public:
+  ///
+  csWireFrameCam (iTextureManager* txtmgr);
+  ///
+  virtual ~csWireFrameCam ();
+
+  ///
+  csWireFrame* GetWireframe () { return wf; }
+  ///
+  csCamera* GetCamera () { return c; }
+
+  ///
+  void KeyUp (float speed, bool slow, bool fast);
+  ///
+  void KeyDown (float speed, bool slow, bool fast);
+  ///
+  void KeyLeft (float speed, bool slow, bool fast);
+  ///
+  void KeyRight (float speed, bool slow, bool fast);
+  ///
+  void KeyLeftStrafe (float speed, bool slow, bool fast);
+  ///
+  void KeyRightStrafe (float speed, bool slow, bool fast);
+  ///
+  void KeyPgDn (float speed, bool slow, bool fast);
+  ///
+  void KeyPgUp (float speed, bool slow, bool fast);
+};
+
+#endif // __CS_WIREFRM_H__
+
diff --git a/client/client94/crystalspace/include/csgeom/box.h b/client/client94/crystalspace/include/csgeom/box.h
new file mode 100644
index 0000000..4dc52c2
--- /dev/null
+++ b/client/client94/crystalspace/include/csgeom/box.h
@@ -0,0 +1,781 @@
+/*
+    Copyright (C) 1998,1999,2000 by Jorrit Tyberghein
+    Largely rewritten by Ivan Avramovic <ivan@avramovic.com>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_BOX_H__
+#define __CS_BOX_H__
+
+#include "cstypes.h"	// for bool
+#include "vector2.h"
+#include "vector3.h"
+#include "segment.h"
+
+class csPlane3;
+
+/**
+ * The maximum value that a coordinate in the bounding box can use.
+ * This is considered the 'infinity' value used for empty bounding boxes.
+ */
+#define CS_BOUNDINGBOX_MAXVALUE 1000000000.
+
+/// For csBox2::GetCorner().
+#define CS_BOX_CORNER_xy 0
+#define CS_BOX_CORNER_xY 1
+#define CS_BOX_CORNER_Xy 2
+#define CS_BOX_CORNER_XY 3
+
+/**
+ * Indices of edges for cxBox2.
+ * Index e+1 is opposite edge of e (with e even).
+ */
+#define CS_BOX_EDGE_xy_Xy 0
+#define CS_BOX_EDGE_Xy_xy 1
+#define CS_BOX_EDGE_Xy_XY 2
+#define CS_BOX_EDGE_XY_Xy 3
+#define CS_BOX_EDGE_XY_xY 4
+#define CS_BOX_EDGE_xY_XY 5
+#define CS_BOX_EDGE_xY_xy 6
+#define CS_BOX_EDGE_xy_xY 7
+
+/**
+ * A bounding box in 2D space.
+ * In order to operate correctly, this bounding box assumes that all values
+ * entered or compared against lie within the range
+ * (-CS_BOUNDINGBOX_MAXVALUE, CS_BOUNDINGBOX_MAXVALUE).  It is not
+ * recommended to use points outside of this range.
+ */
+class csBox2
+{
+private:
+  struct bEdge
+  {
+    uint8 v1, v2;	// Indices of vertex in bounding box (CS_BOX_CORNER_...)
+  };
+  // Index by edge number. Edge e and e+1 with e even are opposite edges.
+  // (CS_BOX_EDGE_...)
+  static bEdge edges[8];
+
+protected:
+  /// The top-left coordinate of the bounding box.
+  csVector2 minbox;
+  /// The bottom-right coordinate of the bounding box.
+  csVector2 maxbox;
+
+public:
+  /// Get the minimum X value of the box
+  float MinX () const { return minbox.x; }
+  /// Get the minimum Y value of the box
+  float MinY () const { return minbox.y; }
+  /// Get the maximum X value of the box
+  float MaxX () const { return maxbox.x; }
+  /// Get the maximum Y value of the box
+  float MaxY () const { return maxbox.y; }
+  /// Get Min component for 0 (x) or 1 (y).
+  float Min (int idx) const { return idx ? minbox.y : minbox.x; }
+  /// Get Max component for 0 (x) or 1 (y).
+  float Max (int idx) const { return idx ? maxbox.y : maxbox.x; }
+  /// Get the 2d vector of minimum (x, y) values
+  const csVector2& Min () const { return minbox; }
+  /// Get the 2d vector of maximum (x, y) values
+  const csVector2& Max () const { return maxbox; }
+
+  /**
+   * Return every corner of this bounding box from 0
+   * to 3. This contrasts with Min() and Max() because
+   * those are only the min and max corners.
+   * Corner 0 = xy, 1 = xY, 2 = Xy, 3 = XY.
+   * Use CS_BOX_CORNER_??? defines.
+   */
+  csVector2 GetCorner (int corner) const;
+
+  /**
+   * Get the center of this box.
+   */
+  csVector2 GetCenter () const { return (minbox+maxbox)/2; }
+
+  /**
+   * Set the center of this box. This will not change the size
+   * of the box but just relocate the center.
+   */
+  void SetCenter (const csVector2& c);
+
+  /**
+   * Set the size of the box but keep the center intact.
+   */
+  void SetSize (const csVector2& s);
+
+  /**
+   * Given an edge index (CS_BOX_EDGE_???) return the two vertices
+   * (index CS_BOX_CORNER_???).
+   */
+  void GetEdgeInfo (int edge, int& v1, int& v2) const
+  {
+    v1 = edges[edge].v1;
+    v2 = edges[edge].v2;
+  }
+
+  /**
+   * Return every edge (segment) of this bounding box
+   * from 0 to 7 (CS_BOX_EDGE_???).
+   */
+  csSegment2 GetEdge (int edge) const
+  {
+    return csSegment2 (GetCorner (edges[edge].v1), GetCorner (edges[edge].v2));
+  }
+
+  /**
+   * Return every edge (segment) of this bounding box
+   * from 0 to 7 (CS_BOX_EDGE_???).
+   */
+  void GetEdge (int edge, csSegment2& e) const
+  {
+    e.SetStart (GetCorner (edges[edge].v1));
+    e.SetEnd (GetCorner (edges[edge].v2));
+  }
+
+  /**
+   * Test if a polygon if visible in the box. This
+   * function does not test the case where the box is
+   * fully contained in the polygon. But all other
+   * cases are tested.
+   */
+  static bool Intersect (float minx, float miny, float maxx, float maxy,
+    csVector2* poly, int num_poly);
+
+  /**
+   * Test if a polygon if visible in the box. This
+   * function does not test the case where the box is
+   * fully contained in the polygon. But all other
+   * cases are tested.
+   */
+  static bool Intersect (const csVector2& minbox, const csVector2& maxbox,
+    csVector2* poly, int num_poly)
+  {
+    return Intersect (minbox.x, minbox.y, maxbox.x, maxbox.y, poly, num_poly);
+  }
+
+  /**
+   * Test if a polygon if visible in the box. This
+   * function does not test the case where the box is
+   * fully contained in the polygon. But all other
+   * cases are tested.
+   */
+  bool Intersect (csVector2* poly, int num_poly) const
+  {
+    return Intersect (minbox, maxbox, poly, num_poly);
+  }
+
+  /// Test if the given coordinate is in this box.
+  bool In (float x, float y) const
+  {
+    if (x < minbox.x || x > maxbox.x) return false;
+    if (y < minbox.y || y > maxbox.y) return false;
+    return true;
+  }
+
+  /// Test if the given coordinate is in this box.
+  bool In (const csVector2& v) const
+  {
+    return In (v.x, v.y);
+  }
+
+  /// Test if this box overlaps with the given box.
+  bool Overlap (const csBox2& box) const
+  {
+    if (maxbox.x < box.minbox.x || minbox.x > box.maxbox.x) return false;
+    if (maxbox.y < box.minbox.y || minbox.y > box.maxbox.y) return false;
+    return true;
+  }
+
+  /// Test if this box contains the other box.
+  bool Contains (const csBox2& box) const
+  {
+    return (box.minbox.x >= minbox.x && box.maxbox.x <= maxbox.x) &&
+           (box.minbox.y >= minbox.y && box.maxbox.y <= maxbox.y);
+  }
+
+  /// Test if this box is empty.
+  bool Empty () const
+  {
+    if (minbox.x > maxbox.x) return true;
+    if (minbox.y > maxbox.y) return true;
+    return false;
+  }
+
+  /**
+   * Calculate the squared distance between (0,0) and the box
+   * This routine is extremely efficient.
+   */
+  float SquaredOriginDist () const;
+
+  /**
+   * Calculate the squared distance between (0,0) and the point
+   * on the box which is furthest away from (0,0).
+   * This routine is extremely efficient.
+   */
+  float SquaredOriginMaxDist () const;
+
+  /// Initialize this box to empty.
+  void StartBoundingBox ()
+  {
+    minbox.x =  CS_BOUNDINGBOX_MAXVALUE;  minbox.y =  CS_BOUNDINGBOX_MAXVALUE;
+    maxbox.x = -CS_BOUNDINGBOX_MAXVALUE;  maxbox.y = -CS_BOUNDINGBOX_MAXVALUE;
+  }
+
+  /// Initialize this box to one vertex.
+  void StartBoundingBox (const csVector2& v)
+  {
+    minbox = v;
+    maxbox = v;
+  }
+
+  /// Same but given some coordinates.
+  void StartBoundingBox (float x, float y)
+  {
+    minbox.x = maxbox.x = x;
+    minbox.y = maxbox.y = y;
+  }
+
+  /// Add a new vertex and recalculate the bounding box.
+  void AddBoundingVertex (float x, float y)
+  {
+    if (x < minbox.x) minbox.x = x;  if (x > maxbox.x) maxbox.x = x;
+    if (y < minbox.y) minbox.y = y;  if (y > maxbox.y) maxbox.y = y;
+  }
+
+  /// Add a new vertex and recalculate the bounding box.
+  void AddBoundingVertex (const csVector2& v)
+  {
+    AddBoundingVertex (v.x, v.y);
+  }
+
+  /**
+   * Add a new vertex and recalculate the bounding box.
+   * This version is a little more optimal. It assumes however
+   * that at least one point has been added to the bounding box.
+   */
+  void AddBoundingVertexSmart (float x, float y)
+  {
+    if (x < minbox.x) minbox.x = x; else if (x > maxbox.x) maxbox.x = x;
+    if (y < minbox.y) minbox.y = y; else if (y > maxbox.y) maxbox.y = y;
+  }
+
+  /**
+   * Add a new vertex and recalculate the bounding box.
+   * This version is a little more optimal. It assumes however
+   * that at least one point has been added to the bounding box.
+   */
+  void AddBoundingVertexSmart (const csVector2& v)
+  {
+    AddBoundingVertexSmart (v.x, v.y);
+  }
+
+  //-----
+  // Maintenance Note: The csBox2 constructors and Set() appear at this point
+  // in the file, rather than earlier, in order to appease the OpenStep 4.2
+  // compiler.  Specifically, the problem is that the compiler botches code
+  // generation if an unseen method (which is later declared inline) is
+  // called from within another inline method.  For instance, if the
+  // constructors were listed at the top of the file, rather than here, the
+  // compiler would see calls to Empty() and StartBoundingBox() before seeing
+  // declarations for them.  In such a situation, the buggy compiler
+  // generates a broken object file.  The simple work-around of textually
+  // reorganizing the file ensures that the declarations for Empty() and
+  // StartBoundingBox() are seen before they are called.
+  //-----
+
+  /// Initialize this box to empty.
+  csBox2 () : minbox (CS_BOUNDINGBOX_MAXVALUE, CS_BOUNDINGBOX_MAXVALUE),
+	     maxbox (-CS_BOUNDINGBOX_MAXVALUE, -CS_BOUNDINGBOX_MAXVALUE) {}
+
+  /// Initialize this box with one point.
+  csBox2 (const csVector2& v) : minbox (v.x, v.y), maxbox (v.x, v.y) {}
+
+  /// Initialize this box with the given values.
+  csBox2 (float x1, float y1, float x2, float y2) :
+    minbox (x1, y1), maxbox (x2, y2)
+  { if (Empty ()) StartBoundingBox (); }
+
+  /// Sets the bounds of the box with the given values.
+  void Set (const csVector2& bmin, const csVector2& bmax)
+  {
+    minbox = bmin;
+    maxbox = bmax;
+  }
+
+  /// Sets the bounds of the box with the given values.
+  void Set (float x1, float y1, float x2, float y2)
+  {
+    if (x1>x2 || y1>y2) StartBoundingBox();
+    else { minbox.x = x1;  minbox.y = y1;  maxbox.x = x2;  maxbox.y = y2; }
+  }
+
+  /// Compute the union of two bounding boxes.
+  csBox2& operator+= (const csBox2& box);
+  /// Compute the union of a point with this bounding box.
+  csBox2& operator+= (const csVector2& point);
+  /// Compute the intersection of two bounding boxes.
+  csBox2& operator*= (const csBox2& box);
+
+  /// Compute the union of two bounding boxes.
+  friend csBox2 operator+ (const csBox2& box1, const csBox2& box2);
+  /// Compute the union of a bounding box and a point.
+  friend csBox2 operator+ (const csBox2& box, const csVector2& point);
+  /// Compute the intersection of two bounding boxes.
+  friend csBox2 operator* (const csBox2& box1, const csBox2& box2);
+
+  /// Tests if two bounding boxes are equal.
+  friend bool operator== (const csBox2& box1, const csBox2& box2);
+  /// Tests if two bounding boxes are unequal.
+  friend bool operator!= (const csBox2& box1, const csBox2& box2);
+  /// Tests if box1 is a subset of box2.
+  friend bool operator< (const csBox2& box1, const csBox2& box2);
+  /// Tests if box1 is a superset of box2.
+  friend bool operator> (const csBox2& box1, const csBox2& box2);
+  /// Tests if a point is contained in a box.
+  friend bool operator< (const csVector2& point, const csBox2& box);
+};
+
+/**
+ * Indices of corner vertices for csBox3.
+ * Used by csBox3::GetCorner().
+ */
+#define CS_BOX_CORNER_xyz 0
+#define CS_BOX_CORNER_xyZ 1
+#define CS_BOX_CORNER_xYz 2
+#define CS_BOX_CORNER_xYZ 3
+#define CS_BOX_CORNER_Xyz 4
+#define CS_BOX_CORNER_XyZ 5
+#define CS_BOX_CORNER_XYz 6
+#define CS_BOX_CORNER_XYZ 7
+
+/**
+ * Indices of faces for csBox3.
+ * Used by csBox3::GetSide().
+ */
+#define CS_BOX_SIDE_x 0
+#define CS_BOX_SIDE_X 1
+#define CS_BOX_SIDE_y 2
+#define CS_BOX_SIDE_Y 3
+#define CS_BOX_SIDE_z 4
+#define CS_BOX_SIDE_Z 5
+#define CS_BOX_INSIDE 6
+
+/**
+ * Indices of edges for cxBox3.
+ * Index e+1 is opposite edge of e (with e even).
+ */
+#define CS_BOX_EDGE_Xyz_xyz 0
+#define CS_BOX_EDGE_xyz_Xyz 1
+#define CS_BOX_EDGE_xyz_xYz 2
+#define CS_BOX_EDGE_xYz_xyz 3
+#define CS_BOX_EDGE_xYz_XYz 4
+#define CS_BOX_EDGE_XYz_xYz 5
+#define CS_BOX_EDGE_XYz_Xyz 6
+#define CS_BOX_EDGE_Xyz_XYz 7
+#define CS_BOX_EDGE_Xyz_XyZ 8
+#define CS_BOX_EDGE_XyZ_Xyz 9
+#define CS_BOX_EDGE_XyZ_XYZ 10
+#define CS_BOX_EDGE_XYZ_XyZ 11
+#define CS_BOX_EDGE_XYZ_XYz 12
+#define CS_BOX_EDGE_XYz_XYZ 13
+#define CS_BOX_EDGE_XYZ_xYZ 14
+#define CS_BOX_EDGE_xYZ_XYZ 15
+#define CS_BOX_EDGE_xYZ_xYz 16
+#define CS_BOX_EDGE_xYz_xYZ 17
+#define CS_BOX_EDGE_xYZ_xyZ 18
+#define CS_BOX_EDGE_xyZ_xYZ 19
+#define CS_BOX_EDGE_xyZ_xyz 20
+#define CS_BOX_EDGE_xyz_xyZ 21
+#define CS_BOX_EDGE_xyZ_XyZ 22
+#define CS_BOX_EDGE_XyZ_xyZ 23
+
+/**
+ * A bounding box in 3D space.
+ * In order to operate correctly, this bounding box assumes that all values
+ * entered or compared against lie within the range
+ * (-CS_BOUNDINGBOX_MAXVALUE, CS_BOUNDINGBOX_MAXVALUE).  It is not
+ * recommended to use points outside of this range.
+ */
+class csBox3
+{
+protected:
+  /// The top-left of this bounding box.
+  csVector3 minbox;
+  /// The bottom-right.
+  csVector3 maxbox;
+
+  struct bEdge
+  {
+    uint8 v1, v2; // Indices of vertex in bounding box (CS_BOX_CORNER_...)
+    uint8 fl, fr; // Indices of left/right faces sharing edge (CS_BOX_SIDE_...)
+  };
+  typedef uint8 bFace[4];	// Indices of four clock-wise edges (0..23)
+  // Index by edge number. Edge e and e+1 with e even are opposite edges.
+  // (CS_BOX_EDGE_...)
+  static bEdge edges[24];
+  // Index by CS_BOX_SIDE_? number.
+  static bFace faces[6];
+public:
+  /// Get the minimum X value of the box
+  float MinX () const { return minbox.x; }
+  /// Get the minimum Y value of the box
+  float MinY () const { return minbox.y; }
+  /// Get the minimum Z value of the box
+  float MinZ () const { return minbox.z; }
+  /// Get the maximum X value of the box
+  float MaxX () const { return maxbox.x; }
+  /// Get the maximum Y value of the box
+  float MaxY () const { return maxbox.y; }
+  /// Get the maximum Z value of the box
+  float MaxZ () const { return maxbox.z; }
+  /// Get Min component for 0 (x), 1 (y), or 2 (z).
+  float Min (int idx) const
+  { return idx == 1 ? minbox.y : idx == 0 ? minbox.x : minbox.z; }
+  /// Get Max component for 0 (x), 1 (y), or 2 (z).
+  float Max (int idx) const
+  { return idx == 1 ? maxbox.y : idx == 0 ? maxbox.x : maxbox.z; }
+  /// Get the 3d vector of minimum (x, y, z) values
+  const csVector3& Min () const { return minbox; }
+  /// Get the 3d vector of maximum (x, y, z) values
+  const csVector3& Max () const { return maxbox; }
+
+  /**
+   * Return every corner of this bounding box from 0
+   * to 7. This contrasts with Min() and Max() because
+   * those are only the min and max corners.
+   * Corner 0 = xyz, 1 = xyZ, 2 = xYz, 3 = xYZ,
+   *        4 = Xyz, 5 = XyZ, 6 = XYz, 7 = XYZ.
+   * Use CS_BOX_CORNER_??? defines.
+   */
+  csVector3 GetCorner (int corner) const;
+
+  /**
+   * Given an edge index (CS_BOX_EDGE_???) return the two vertices
+   * (index CS_BOX_CORNER_???) and left/right faces (CS_BOX_SIDE_???).
+   */
+  void GetEdgeInfo (int edge, int& v1, int& v2, int& fleft, int& fright) const
+  {
+    v1 = edges[edge].v1;
+    v2 = edges[edge].v2;
+    fleft = edges[edge].fl;
+    fright = edges[edge].fr;
+  }
+
+  /**
+   * Given a face index (CS_BOX_SIDE_???) return the four edges oriented
+   * clockwise around this face (CS_BOX_EDGE_???).
+   */
+  uint8* GetFaceEdges (int face) const
+  {
+    return faces[face];
+  }
+
+  /**
+   * Get the center of this box.
+   */
+  csVector3 GetCenter () const { return (minbox+maxbox)/2; }
+
+  /**
+   * Set the center of this box. This will not change the size
+   * of the box but just relocate the center.
+   */
+  void SetCenter (const csVector3& c);
+
+  /**
+   * Set the size of the box but keep the center intact.
+   */
+  void SetSize (const csVector3& s);
+
+  /**
+   * Get a side of this box as a 2D box.
+   * Use CS_BOX_SIDE_??? defines.
+   */
+  csBox2 GetSide (int side) const;
+
+  /**
+   * Fill the array (which should be three long at least)
+   * with all visible sides (CS_BOX_SIDE_??? defines) as seen
+   * from the given point.
+   * Returns the number of visible sides.
+   */
+  int GetVisibleSides (const csVector3& pos, int* visible_sides) const;
+
+  /**
+   * Static function to get the 'other' side (i.e. CS_BOX_SIDE_X
+   * to CS_BOX_SIDE_x, ...).
+   */
+  static int OtherSide (int side)
+  {
+    return side ^ 1;
+  }
+
+  /**
+   * Return every edge (segment) of this bounding box
+   * from 0 to 23 (use one of the CS_BOX_EDGE_??? indices).
+   * The returned edge is undefined for any other index.
+   */
+  csSegment3 GetEdge (int edge) const
+  {
+    return csSegment3 (GetCorner (edges[edge].v1), GetCorner (edges[edge].v2));
+  }
+
+  /**
+   * Return every edge (segment) of this bounding box
+   * from 0 to 23 (use one of the CS_BOX_EDGE_??? indices).
+   * The returned edge is undefined for any other index.
+   */
+  void GetEdge (int edge, csSegment3& e) const
+  {
+    e.SetStart (GetCorner (edges[edge].v1));
+    e.SetEnd (GetCorner (edges[edge].v2));
+  }
+
+  /// Test if the given coordinate is in this box.
+  bool In (float x, float y, float z) const
+  {
+    if (x < minbox.x || x > maxbox.x) return false;
+    if (y < minbox.y || y > maxbox.y) return false;
+    if (z < minbox.z || z > maxbox.z) return false;
+    return true;
+  }
+
+  /// Test if the given coordinate is in this box.
+  bool In (const csVector3& v) const
+  {
+    return In (v.x, v.y, v.z);
+  }
+
+  /// Test if this box overlaps with the given box.
+  bool Overlap (const csBox3& box) const
+  {
+    if (maxbox.x < box.minbox.x || minbox.x > box.maxbox.x) return false;
+    if (maxbox.y < box.minbox.y || minbox.y > box.maxbox.y) return false;
+    if (maxbox.z < box.minbox.z || minbox.z > box.maxbox.z) return false;
+    return true;
+  }
+
+  /// Test if this box contains the other box.
+  bool Contains (const csBox3& box) const
+  {
+    return (box.minbox.x >= minbox.x && box.maxbox.x <= maxbox.x) &&
+           (box.minbox.y >= minbox.y && box.maxbox.y <= maxbox.y) &&
+           (box.minbox.z >= minbox.z && box.maxbox.z <= maxbox.z);
+  }
+
+  /// Test if this box is empty.
+  bool Empty () const
+  {
+    if (minbox.x > maxbox.x) return true;
+    if (minbox.y > maxbox.y) return true;
+    if (minbox.z > maxbox.z) return true;
+    return false;
+  }
+
+  /// Initialize this box to empty.
+  void StartBoundingBox ()
+  {
+    minbox.x =  CS_BOUNDINGBOX_MAXVALUE;
+    minbox.y =  CS_BOUNDINGBOX_MAXVALUE;
+    minbox.z =  CS_BOUNDINGBOX_MAXVALUE;
+    maxbox.x = -CS_BOUNDINGBOX_MAXVALUE;
+    maxbox.y = -CS_BOUNDINGBOX_MAXVALUE;
+    maxbox.z = -CS_BOUNDINGBOX_MAXVALUE;
+  }
+
+  /// Initialize this box to one vertex.
+  void StartBoundingBox (const csVector3& v)
+  {
+    minbox = v; maxbox = v;
+  }
+
+  /// Add a new vertex and recalculate the bounding box.
+  void AddBoundingVertex (float x, float y, float z)
+  {
+    if (x < minbox.x) minbox.x = x; if (x > maxbox.x) maxbox.x = x;
+    if (y < minbox.y) minbox.y = y; if (y > maxbox.y) maxbox.y = y;
+    if (z < minbox.z) minbox.z = z; if (z > maxbox.z) maxbox.z = z;
+  }
+
+  /// Add a new vertex and recalculate the bounding box.
+  void AddBoundingVertex (const csVector3& v)
+  {
+    AddBoundingVertex (v.x, v.y, v.z);
+  }
+
+  /**
+   * Add a new vertex and recalculate the bounding box.
+   * This version is a little more optimal. It assumes however
+   * that at least one point has been added to the bounding box.
+   */
+  void AddBoundingVertexSmart (float x, float y, float z)
+  {
+    if (x < minbox.x) minbox.x = x; else if (x > maxbox.x) maxbox.x = x;
+    if (y < minbox.y) minbox.y = y; else if (y > maxbox.y) maxbox.y = y;
+    if (z < minbox.z) minbox.z = z; else if (z > maxbox.z) maxbox.z = z;
+  }
+
+  /**
+   * Add a new vertex and recalculate the bounding box.
+   * This version is a little more optimal. It assumes however
+   * that at least one point has been added to the bounding box.
+   */
+  void AddBoundingVertexSmart (const csVector3& v)
+  {
+    AddBoundingVertexSmart (v.x, v.y, v.z);
+  }
+
+  //-----
+  // Maintenance Note: The csBox3 constructors and Set() appear at this point
+  // in the file, rather than earlier, in order to appease the OpenStep 4.2
+  // compiler.  Specifically, the problem is that the compiler botches code
+  // generation if an unseen method (which is later declared inline) is
+  // called from within another inline method.  For instance, if the
+  // constructors were listed at the top of the file, rather than here, the
+  // compiler would see calls to Empty() and StartBoundingBox() before seeing
+  // declarations for them.  In such a situation, the buggy compiler
+  // generated a broken object file.  The simple work-around of textually
+  // reorganizing the file ensures that the declarations for Empty() and
+  // StartBoundingBox() are seen before they are called.
+  //-----
+
+  /// Initialize this box to empty.
+  csBox3 () :
+    minbox ( CS_BOUNDINGBOX_MAXVALUE,
+             CS_BOUNDINGBOX_MAXVALUE,
+	     CS_BOUNDINGBOX_MAXVALUE),
+    maxbox (-CS_BOUNDINGBOX_MAXVALUE,
+            -CS_BOUNDINGBOX_MAXVALUE,
+	    -CS_BOUNDINGBOX_MAXVALUE) {}
+
+  /// Initialize this box with one point.
+  csBox3 (const csVector3& v) : minbox (v), maxbox (v) { }
+
+  /// Initialize this box with two points.
+  csBox3 (const csVector3& v1, const csVector3& v2) :
+  	minbox (v1), maxbox (v2)
+  { if (Empty ()) StartBoundingBox (); }
+
+  /// Initialize this box with the given values.
+  csBox3 (float x1, float y1, float z1, float x2, float y2, float z2) :
+    minbox (x1, y1, z1), maxbox (x2, y2, z2)
+  { if (Empty ()) StartBoundingBox (); }
+
+  /// Sets the bounds of the box with the given values.
+  void Set (const csVector3& bmin, const csVector3& bmax)
+  {
+    minbox = bmin;
+    maxbox = bmax;
+  }
+
+  /// Sets the bounds of the box with the given values.
+  void Set (float x1, float y1, float z1, float x2, float y2, float z2)
+  {
+    if (x1>x2 || y1>y2 || z1>z2) StartBoundingBox();
+    else
+    {
+      minbox.x = x1; minbox.y = y1; minbox.z = z1;
+      maxbox.x = x2; maxbox.y = y2; maxbox.z = z2;
+    }
+  }
+
+  /**
+   * Test if this box is adjacent to the other on the X side.
+   */
+  bool AdjacentX (const csBox3& other) const;
+
+  /**
+   * Test if this box is adjacent to the other on the Y side.
+   */
+  bool AdjacentY (const csBox3& other) const;
+
+  /**
+   * Test if this box is adjacent to the other on the Z side.
+   */
+  bool AdjacentZ (const csBox3& other) const;
+
+  /**
+   * Test if this box is adjacent to the other one.
+   * Return -1 if not adjacent or else any of the CS_BOX_SIDE_???
+   * flags to indicate the side of this box that the other
+   * box is adjacent with.
+   */
+  int Adjacent (const csBox3& other) const;
+
+  /**
+   * Get a convex outline (not a polygon unless projected to 2D)
+   * for for this box as seen from the given position.
+   * The coordinates returned are world space coordinates.
+   * Note that you need place for at least six vectors in the array.
+   * If you set bVisible true, you will get all visible corners - this
+   * could be up to 7.
+   */
+  void GetConvexOutline (const csVector3& pos,
+  	csVector3* array, int& num_array, bool bVisible=false) const;
+
+  /**
+   * Test if this box is between two others.
+   */
+  bool Between (const csBox3& box1, const csBox3& box2) const;
+
+  /**
+   * Calculate the minimum manhattan distance between this box
+   * and another one.
+   */
+  void ManhattanDistance (const csBox3& other, csVector3& dist) const;
+
+  /**
+   * Calculate the squared distance between (0,0,0) and the box
+   * This routine is extremely efficient.
+   */
+  float SquaredOriginDist () const;
+
+  /**
+   * Calculate the squared distance between (0,0,0) and the point
+   * on the box which is furthest away from (0,0,0).
+   * This routine is extremely efficient.
+   */
+  float SquaredOriginMaxDist () const;
+
+  /// Compute the union of two bounding boxes.
+  csBox3& operator+= (const csBox3& box);
+  /// Compute the union of a point with this bounding box.
+  csBox3& operator+= (const csVector3& point);
+  /// Compute the intersection of two bounding boxes.
+  csBox3& operator*= (const csBox3& box);
+
+  /// Compute the union of two bounding boxes.
+  friend csBox3 operator+ (const csBox3& box1, const csBox3& box2);
+  /// Compute the union of a bounding box and a point.
+  friend csBox3 operator+ (const csBox3& box, const csVector3& point);
+  /// Compute the intersection of two bounding boxes.
+  friend csBox3 operator* (const csBox3& box1, const csBox3& box2);
+
+  /// Tests if two bounding boxes are equal.
+  friend bool operator== (const csBox3& box1, const csBox3& box2);
+  /// Tests if two bounding boxes are unequal.
+  friend bool operator!= (const csBox3& box1, const csBox3& box2);
+  /// Tests if box1 is a subset of box2.
+  friend bool operator< (const csBox3& box1, const csBox3& box2);
+  /// Tests if box1 is a superset of box2.
+  friend bool operator> (const csBox3& box1, const csBox3& box2);
+  /// Tests if a point is contained in a box.
+  friend bool operator< (const csVector3& point, const csBox3& box);
+};
+
+#endif // __CS_BOX_H__
diff --git a/client/client94/crystalspace/include/csgeom/cspoint.h b/client/client94/crystalspace/include/csgeom/cspoint.h
new file mode 100644
index 0000000..a928604
--- /dev/null
+++ b/client/client94/crystalspace/include/csgeom/cspoint.h
@@ -0,0 +1,48 @@
+/*
+    Copyright (C) Aleksandras Gluchovas
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CSPOINT_H__
+#define __CSPOINT_H__
+
+/**
+ * A 2D point object
+ */
+struct csPoint
+{
+  /// The coordinates of the point
+  int x, y;
+
+  /// Constructor: initialize the object with zeros
+  csPoint ():x(0), y(0)
+  { }
+  /// Constructor: initialize the object with given values
+  csPoint (int iX, int iY):x(iX), y(iY)
+  { }
+  /// Constructor: initialize the object by copying
+  csPoint (const csPoint &v):x(v.x), y(v.y)
+  { }
+  /// Set the coordinates of this point
+  void Set (int iX, int iY)
+  { x = iX; y = iY; }
+  /// Set the coordinates of this point from another point
+  void Set (csPoint &v)
+  { x = v.x; y = v.y; }
+};
+
+#endif
+
diff --git a/client/client94/crystalspace/include/csgeom/csrect.h b/client/client94/crystalspace/include/csgeom/csrect.h
new file mode 100644
index 0000000..46caf4b
--- /dev/null
+++ b/client/client94/crystalspace/include/csgeom/csrect.h
@@ -0,0 +1,201 @@
+/*
+    Crystal Space Engine: rectangle class interface
+    Copyright (C) 2001 by Jorrit Tyberghein
+    Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_RECT_H__
+#define __CS_RECT_H__
+
+/**
+ * Rectangle class: simple class for manipulating 2D rectangles.
+ * This class is somewhat similar to Box, but uses integer coordinates.<p>
+ * Example of a rectangle (xmin = 0, ymin = 0, xmax = 3, ymax = 2):
+ * <pre>
+ *     0  1  2  3  4 ...
+ *     |  |  |  |  |  |
+ * 0 --@@@@@@@@@@--+--+--
+ *     @//|//|//@  |  |
+ * 1 --@--+--+--@--+--+--
+ *     @//|//|//@  |  |
+ * 2 --@@@@@@@@@@--+--+--
+ *     |  |  |  |  |  |
+ * 3 --+--+--+--+--+--+--
+ *     |  |  |  |  |  |
+ *...--+--+--+--+--+--+--
+ * </pre>
+ * Vertical line 'X=3' and horizontal line 'Y=2' does NOT belong to
+ * the rectangle.
+ */
+class csRect
+{
+public:
+  /// Rectangle bounds.
+  int xmin, ymin, xmax, ymax;
+
+  /// Create a empty rectangle.
+  csRect ();
+
+  /// Create a new rectangle.
+  csRect (int ixmin, int iymin, int ixmax, int iymax);
+
+  /// Copy constructor.
+  csRect (const csRect &copy);
+
+  /// Destructor.
+  virtual ~csRect ();
+
+  /// Intersect with another rectangle.
+  void Intersect (int ixmin, int iymin, int ixmax, int iymax);
+
+  /// Intersect with another rectangle.
+  inline void Intersect (const csRect &other)
+  { Intersect (other.xmin, other.ymin, other.xmax, other.ymax); }
+
+  /// Return true if rectangle intersects with target.
+  bool Intersects (const csRect &target) const;
+
+  /**
+   * Add a rectangle: find minimal rectangle
+   * that embeds both given rectangles.
+   */
+  void Union (int ixmin, int iymin, int ixmax, int iymax);
+
+  /**
+   * Add a rectangle: find minimal rectangle
+   * that embeds both given rectangles.
+   */
+  inline void Union (const csRect &other)
+  { Union (other.xmin, other.ymin, other.xmax, other.ymax); }
+
+  /**
+   * Subtract rectangle: find the minimal rectangle which embeds all
+   * parts of this rectangle which are not covered by given rectangle.
+   * If rectangle is fully covered by argument, it becomes empty.
+   */
+  void Exclude (int ixmin, int iymin, int ixmax, int iymax);
+
+  /// Same but works on a csRect argument
+  inline void Exclude (const csRect &other)
+  { Exclude (other.xmin, other.ymin, other.xmax, other.ymax); }
+
+  /**
+   * Alternative subtraction: find maximal area of this rectangle that
+   * is not covered by argument.
+   */
+  void Subtract (const csRect &rect);
+
+  /// Return true if rectangle is empty.
+  inline bool IsEmpty () const
+  { return (xmin >= xmax) || (ymin >= ymax); }
+
+  /// Make rectangle empty.
+  inline void MakeEmpty ()
+  { xmin = xmax = 0; }
+
+  /// Set rectangle to given ixmin,iymin,ixmax,iymax position.
+  inline void Set (int ixmin, int iymin, int ixmax, int iymax)
+  {
+    xmin = ixmin; xmax = ixmax;
+    ymin = iymin; ymax = iymax;
+  }
+
+  /// Copy rectangle.
+  inline void Set (const csRect &target)
+  {
+    xmin = target.xmin; xmax = target.xmax;
+    ymin = target.ymin; ymax = target.ymax;
+  }
+
+  /// Set rectangle xmin,ymin position.
+  inline void SetPos (int x, int y)
+  { xmin = x; ymin = y; }
+
+  /// Set rectangle size.
+  inline void SetSize (int w, int h)
+  { xmax = xmin + w; ymax = ymin + h; }
+
+  /// Move rectangle by deltaX, deltaY.
+  inline void Move (int dX, int dY)
+  { xmin += dX; xmax += dX; ymin += dY; ymax += dY; }
+
+  /// Return the width of rectangle.
+  inline int Width () const { return xmax - xmin; }
+
+  /// Return the height of rectangle.
+  inline int Height () const { return ymax - ymin; }
+
+  /// Return true if a point lies within rectangle bounds.
+  inline bool Contains (int x, int y) const
+  { return (x >= xmin) && (x < xmax) && (y >= ymin) && (y < ymax); }
+
+  /// Return true if a relative point lies within rectangle bounds.
+  inline bool ContainsRel (int x, int y) const
+  { return (x >= 0) && (x < Width ()) && (y >= 0) && (y < Height ()); }
+
+  /// Return true if rectangle is the same.
+  inline bool Equal (int ixmin, int iymin, int ixmax, int iymax) const
+  { return (xmin == ixmin) && (ymin == iymin) &&
+           (xmax == ixmax) && (ymax == iymax); }
+  /// Same but compare with another csRect
+  inline bool Equal (csRect &other) const
+  { return Equal (other.xmin, other.ymin, other.xmax, other.ymax); }
+
+  /// Normalize a rectangle such that xmin <= xmax and ymin <= ymax.
+  inline void Normalize ()
+  {
+    if (xmin > xmax) { int tmp = xmin; xmin = xmax; xmax = tmp; }
+    if (ymin > ymax) { int tmp = ymin; ymin = ymax; ymax = tmp; }
+  }
+
+  /// Return area of this rectangle.
+  inline int Area () const
+  {
+    if (IsEmpty ())
+      return 0;
+    else
+      return Width () * Height ();
+  }
+
+  /// Add an adjanced rectangle if resulting rectangle will have larger area.
+  void AddAdjanced (const csRect &rect);
+
+  /// Test inequality of two rectangles.
+  inline bool operator != (const csRect &rect) const
+  {
+    return (xmin != rect.xmin) || (ymin != rect.ymin)
+        || (xmax != rect.xmax) || (ymax != rect.ymax);
+  }
+
+  /// Extend rectangle so that it will include given point
+  inline void Extend (int x, int y)
+  {
+    if (xmin > x) xmin = x; if (xmax < x) xmax = x;
+    if (ymin > y) ymin = y; if (ymax < y) ymax = y;
+  }
+
+  /// Joins two rects by their minimum and maximum bounds
+  void Join (const csRect &rect);
+
+  /// Expands the whole rect by n units
+  void Outset(int n);
+
+  /// Contracts the whole rect by n units
+  void Inset(int n);
+};
+
+#endif // __CS_RECT_H__
diff --git a/client/client94/crystalspace/include/csgeom/csrectrg.h b/client/client94/crystalspace/include/csgeom/csrectrg.h
new file mode 100644
index 0000000..46ad5bf
--- /dev/null
+++ b/client/client94/crystalspace/include/csgeom/csrectrg.h
@@ -0,0 +1,89 @@
+/*
+    Copyright (C) 2001 by Christopher Nelson
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_CSRECTREGION_H__
+#define __CS_CSRECTREGION_H__
+
+#include "csgeom/csrect.h"
+
+const int FRAGMENT_BUFFER_SIZE=64;
+
+/**
+ * A rect region is a class that implements splittable 2d rectangles.  The
+ * region may be composed of one or more rectangles that do not need to occupy
+ * the same area.  The idea being that you need to be able to have a number of
+ * disparate rectangular regions for updates.  This class uses csRect for
+ * nearly all rectangle operations.
+ *<p>
+ * To use you can Include and Exclude rectangles from this region.  When
+ * finished, this class will have a list of optimal rectangles that occupy a
+ * region.  If used properly, it will result in faster overall painting
+ * performance, since several areas will not require overwriting.
+ */
+class csRectRegion
+{
+protected:
+  /// The pointer the list of regions
+  csRect* region;
+  /// The number of regions currently stored
+  int region_count;
+  /// The size of the region buffer (in rects)
+  int region_max;
+  /// The fragment buffer, used for performing fragment operations
+  csRect  fragment[FRAGMENT_BUFFER_SIZE];
+  /// The gather marker
+  int gather_mark;
+
+  /// Pushes a new rect into the region, increases buffer if necessary
+  void pushRect(csRect const &);
+  /// Removes a rect from the region.
+  void deleteRect(int);
+
+
+  /// Controls fragmentContainedRect, used to perform all-side clipping and edge intersection.
+  void fragmentRect(csRect&, csRect&, int mode);
+  void nkSplit(csRect& r1, csRect& r2);
+  /// Work method fragments rects properly when they intersect.
+  void fragmentContainedRect(csRect &r1, csRect &r2);
+  /// Marks the current region insertion point for gather.
+  void markForGather();
+  /// Gathers all regions since the mark into the fragment buffer.
+  void gatherFragments();
+
+public:
+  /// Constructor.
+  csRectRegion();
+  /// Destructor
+  ~csRectRegion();
+
+  /// Add a rect to this region; may cause unions, but will not adjance (see csRect).
+  void Include(csRect &rect);
+  /// Exclude a rect from this region; may cause splitting. NOTE: broken!!!
+  void Exclude(csRect &rect);
+  /// Clips everything in the region to the borders given.
+  void ClipTo(csRect &clip);
+
+  /// Returns the number of rectangles in this region
+  int Count() { return region_count; }
+  /// Returns the rect at a specific index
+  csRect& RectAt(int i) {  return region[i]; }
+  /// Resets the region count to zero.
+  void makeEmpty();
+};
+
+#endif //__CS_CSRECTREGION_H__
diff --git a/client/client94/crystalspace/include/csgeom/fastsqrt.h b/client/client94/crystalspace/include/csgeom/fastsqrt.h
new file mode 100644
index 0000000..f537165
--- /dev/null
+++ b/client/client94/crystalspace/include/csgeom/fastsqrt.h
@@ -0,0 +1,27 @@
+/*
+    Copyright (C) 1998 by Jorrit Tyberghein
+    Largely rewritten by Ivan Avramovic <ivan@avramovic.com>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __FASTSQRT_H__
+#define __FASTSQRT_H__
+
+extern void BuildSqrtTable ();
+extern float FastSqrt (float n);
+
+#endif // __FASTSQRT_H__
+
diff --git a/client/client94/crystalspace/include/csgeom/frustum.h b/client/client94/crystalspace/include/csgeom/frustum.h
new file mode 100644
index 0000000..40b67e8
--- /dev/null
+++ b/client/client94/crystalspace/include/csgeom/frustum.h
@@ -0,0 +1,447 @@
+/*
+  Copyright (C) 1998-2001 by Jorrit Tyberghein
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Library General Public
+  License as published by the Free Software Foundation; either
+  version 2 of the License, or (at your option) any later version.
+
+  This library 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
+  Library General Public License for more details.
+
+  You should have received a copy of the GNU Library General Public
+  License along with this library; if not, write to the Free
+  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_FRUSTRUM_H__
+#define __CS_FRUSTRUM_H__
+
+#include "cstypes.h"
+#include "csgeom/math3d.h"
+#include "csgeom/vtpool.h"
+
+class csTransform;
+
+/**
+ * Return values for csFrustum::Classify. The routine makes a difference
+ * whenever a polygon is fully outside the frustum, fully inside, fully
+ * covers the frustum or is partly inside, partly outside.
+ */
+/// The polygon is fully outside frustum
+#define CS_FRUST_OUTSIDE	0
+/// The polygon is fully inside frustum
+#define CS_FRUST_INSIDE		1
+/// The polygon fully covers the frustum
+#define CS_FRUST_COVERED	2
+/// The polygon is partially inside frustum
+#define CS_FRUST_PARTIAL	3
+
+/**
+ * Structure for use with ClipToPlane. This structure
+ * is used in addition to a vertex to give additional information
+ * about how to interpolate additional information that goes
+ * with the vertex.
+ */
+struct csClipInfo
+{
+# define CS_CLIPINFO_ORIGINAL 0
+# define CS_CLIPINFO_ONEDGE 1
+# define CS_CLIPINFO_INSIDE 2
+  int type;	// One of CS_CLIPINFO_???
+  union
+  {
+    struct { int idx; } original;
+    struct { int i1, i2; float r; } onedge;
+    struct { csClipInfo* ci1, * ci2; float r; } inside;
+  };
+
+  csClipInfo () : type (CS_CLIPINFO_ORIGINAL) { }
+  void Clear ();
+  ~csClipInfo () { Clear (); }
+
+  /// Copy the information from another clipinfo instance to this one.
+  void Copy (csClipInfo& other)
+  {
+    if (&other == this) return;
+    Clear ();
+    type = other.type;
+    if (type == CS_CLIPINFO_INSIDE)
+    {
+      inside.r = other.inside.r;
+      inside.ci1 = new csClipInfo ();
+      inside.ci1->Copy (*other.inside.ci1);
+      inside.ci2 = new csClipInfo ();
+      inside.ci2->Copy (*other.inside.ci2);
+    }
+    else if (type == CS_CLIPINFO_ORIGINAL)
+      original.idx = other.original.idx;
+    else
+      onedge = other.onedge;
+  }
+
+  /// Move the information from another clipinfo instance to this one.
+  void Move (csClipInfo& other)
+  {
+    if (&other == this) return;
+    Clear ();
+    type = other.type;
+    if (type == CS_CLIPINFO_INSIDE)
+      inside = other.inside;
+    else if (type == CS_CLIPINFO_ORIGINAL)
+      original.idx = other.original.idx;
+    else
+      onedge = other.onedge;
+    other.type = CS_CLIPINFO_ORIGINAL;
+  }
+
+  void Dump (int indent)
+  {
+    char ind[255];
+    int i;
+    for (i = 0 ; i < indent ; i++) ind[i] = ' ';
+    ind[i] = 0;
+    switch (type)
+    {
+      case CS_CLIPINFO_ORIGINAL:
+        printf ("%s ORIGINAL idx=%d\n", ind, original.idx);
+	break;
+      case CS_CLIPINFO_ONEDGE:
+        printf ("%s ONEDGE i1=%d i2=%d r=%g\n", ind, onedge.i1, onedge.i2,
+		onedge.r);
+        break;
+      case CS_CLIPINFO_INSIDE:
+        printf ("%s INSIDE r=%g\n", ind, inside.r);
+	inside.ci1->Dump (indent+2);
+	inside.ci2->Dump (indent+2);
+	break;
+    }
+    fflush (stdout);
+  }
+};
+
+/**
+ * A general frustum. This consist of a center point (origin),
+ * a frustum polygon in 3D space (relative to center point)
+ * and a plane. The planes which go through the center and
+ * every edge of the polygon form the frustum. The plane
+ * is the back plane of the frustum.
+ * It is also possible to have an infinite frustum in which
+ * case the polygon will be NULL (not specified). The back
+ * plane can also be NULL.
+ */
+class csFrustum
+{
+private:
+  /// Reference to the pool which is used to allocate new vertex arrays.
+  csVertexArrayPool* pool;
+
+  /// The origin of this frustum
+  csVector3 origin;
+
+  /**
+   * The polygon vertices for non-wide frustum.
+   * If not NULL, the frustum is a pyramid with origin in "origin"
+   * and with the basis given by this polygon.
+   */
+  csVector3* vertices;
+  /// Number of vertices in frustum polygon
+  int num_vertices;
+  /// Max number of vertices
+  int max_vertices;
+
+  /// Back clipping plane
+  csPlane3* backplane;
+
+  /**
+   * If true we have a total wide frustum. A frustum like
+   * this does not have a polygon defining the planes but it can have
+   * a back plane. The value of this boolean is only used if there
+   * is no polygon. In other words, if the polygon is present in this
+   * frustum then 'wide' is simply ignored and can have any value.
+   */
+  bool wide;
+
+  /**
+   * If true we have a mirrored frustum where the direction of
+   * the polygon is reversed.
+   */
+  bool mirrored;
+
+  /// The reference count for this frustum
+  int ref_count;
+
+  /// Clear the frustum
+  void Clear ();
+
+  /// Ensure vertex array is able to hold at least "num" vertices
+  void ExtendVertexArray (int num);
+
+public:
+
+  /// Create a new empty frustum.
+  csFrustum (const csVector3& o) : pool (&csDefaultVertexArrayPool::GetDefaultPool()),
+  	origin (o), vertices (NULL), num_vertices (0), max_vertices (0),
+	backplane (NULL), wide (false), mirrored (false), ref_count (1)
+  { }
+
+  /// Create a new empty frustum with another pool.
+  csFrustum (const csVector3& o, csVertexArrayPool* pl) : pool (pl),
+  	origin (o), vertices (NULL), num_vertices (0), max_vertices (0),
+	backplane (NULL), wide (false), mirrored (false), ref_count (1)
+  { }
+
+  /**
+   * Create a frustum given a polygon and a backplane.
+   * The polygon is given relative to the origin 'o'.
+   * If the given polygon is NULL then we create an empty frustum.
+   */
+  csFrustum (const csVector3& o, csVector3* verts, int num_verts,
+      	csPlane3* backp = NULL);
+
+  /**
+   * Create a frustum given a number of vertices and a backplane.
+   * The vertices are not initialized but space is reserved for them.
+   * The polygon is given relative to the origin 'o'.
+   */
+  csFrustum (const csVector3& o, int num_verts,
+      	csVertexArrayPool* pl, csPlane3* backp = NULL);
+
+  /// Copy constructor.
+  csFrustum (const csFrustum &copy);
+
+  ///
+  virtual ~csFrustum ();
+
+  /// Set the origin of this frustum.
+  void SetOrigin (const csVector3& o) { origin = o; }
+
+  /// Get the origin of this frustum.
+  csVector3& GetOrigin () { return origin; }
+
+  /// Get the origin of this frustum.
+  const csVector3& GetOrigin () const { return origin; }
+
+  /**
+   * Enable/disable mirroring.
+   * If mirroring is enabled this means that the frustum polygon
+   * is given in anti-clockwise order.
+   */
+  void SetMirrored (bool m) { mirrored = m; }
+
+  /// Is this frustum mirrored?
+  bool IsMirrored () { return mirrored; }
+
+  /**
+   * Set the back plane of this frustum.
+   * The given plane is copied to this structure and can thus
+   * be reused/freed later. The plane should be specified relative
+   * to the origin point.
+   */
+  void SetBackPlane (csPlane3& plane);
+
+  /**
+   * Get the back plane.
+   */
+  csPlane3* GetBackPlane () { return backplane; }
+
+  /**
+   * Remove the back plane of this frustum.
+   */
+  void RemoveBackPlane ();
+
+  /**
+   * Add a vertex to the frustum polygon.
+   */
+  void AddVertex (const csVector3& v);
+
+  /**
+   * Get the number of vertices.
+   */
+  int GetVertexCount () { return num_vertices; }
+
+  /**
+   * Get a vertex.
+   */
+  csVector3& GetVertex (int idx)
+  {
+    CS_ASSERT (idx >= 0 && idx < num_vertices);
+    return vertices[idx];
+  }
+
+  /**
+   * Get the array of vertices.
+   */
+  csVector3* GetVertices () { return vertices; }
+
+  /**
+   * Apply a transformation to this frustum.
+   */
+  void Transform (csTransform* trans);
+
+  /**
+   * Clip this frustum to the positive side of a plane
+   * formed by the origin of this frustum, and the two given vertices.
+   * 'v1' and 'v2' are given relative to that origin.
+   */
+  void ClipToPlane (csVector3& v1, csVector3& v2);
+
+  /**
+   * Clip a frustum (defined from 0,0,0 origin) to the given plane
+   * (defined as 0-v1-v2). This routine will also fill an array
+   * of clipinfo so that you can use this information to correctly
+   * interpolate information related to the vertex (like texture mapping
+   * coordinates). Note that clipinfo needs to be preinitialized correctly
+   * with CS_CLIPINFO_ORIGINAL instances and correct indices.
+   */
+  static void ClipToPlane (csVector3* vertices, int& num_vertices,
+	csClipInfo* clipinfo, const csVector3& v1, const csVector3& v2);
+
+  /**
+   * Clip a frustum (defined from 0,0,0 origin) to the given plane.
+   * This routine will also fill an array of clipinfo so that you can
+   * use this information to correctly interpolate information related to
+   * the vertex (like texture mapping coordinates). Note that clipinfo
+   * needs to be preinitialized correctly with CS_CLIPINFO_ORIGINAL
+   * instances and correct indices.
+   */
+  static void ClipToPlane (csVector3* vertices, int& num_vertices,
+	csClipInfo* clipinfo, const csPlane3& plane);
+
+  /**
+   * Clip the polygon of this frustum to the postive side of an arbitrary plane
+   * (which should be specified relative to the origin of the frustum).
+   * Note that this clips the polygon which forms the frustum. It does
+   * not clip the frustum itself.
+   */
+  void ClipPolyToPlane (csPlane3* plane);
+
+  /**
+   * Intersect with another frustum. The other frustum
+   * must have the same origin as this one. Otherwise the
+   * result is undefined.
+   * Returns new frustum which you should delete
+   * after usage. If there is no intersection this function
+   * returns NULL.
+   */
+  csFrustum* Intersect (const csFrustum& other);
+
+  /**
+   * Intersect a convex polygon with this volume. The convex polygon
+   * is given relative to the center point (origin) of this frustum.<p>
+   *
+   * Returns a new frustum which exactly covers the intersection
+   * of the polygon with the frustum (i.e. the smallest frustum
+   * which is part of this frustum and which 'sees' exactly
+   * the same of the given polygon as this frustum).<p>
+   *
+   * This function returns NULL if there is no intersection.<p>
+   *
+   * Note that the frustum polygon of the returned csFrustum is
+   * guaranteed to be coplanar with the given polygon.
+   */
+  csFrustum* Intersect (csVector3* poly, int num);
+
+  /**
+   * Intersect a convex polygon with this volume. The convex polygon
+   * is given relative to the center point (origin) of this frustum.<p>
+   *
+   * Returns a new frustum which exactly covers the intersection
+   * of the polygon with the frustum (i.e. the smallest frustum
+   * which is part of this frustum and which 'sees' exactly
+   * the same of the given polygon as this frustum).<p>
+   *
+   * This function returns NULL if there is no intersection.<p>
+   *
+   * Note that the frustum polygon of the returned csFrustum is
+   * guaranteed to be coplanar with the given polygon.
+   */
+  static csFrustum* Intersect (
+    const csVector3& frust_origin, csVector3* frust, int num_frust,
+    csVector3* poly, int num);
+
+  /**
+   * Intersect a triangle with this volume. The triangle
+   * is given relative to the center point (origin) of this frustum.<p>
+   *
+   * Returns a new frustum which exactly covers the intersection
+   * of the triangle with the frustum (i.e. the smallest frustum
+   * which is part of this frustum and which 'sees' exactly
+   * the same of the given polygon as this frustum).<p>
+   *
+   * This function returns NULL if there is no intersection.<p>
+   *
+   * Note that the frustum polygon of the returned csFrustum is
+   * guaranteed to be coplanar with the given triangle.
+   */
+  static csFrustum* Intersect (
+    const csVector3& frust_origin, csVector3* frust, int num_frust,
+    const csVector3& v1, const csVector3& v2, const csVector3& v3);
+
+  /**
+   * Check if a polygon intersects with the frustum (i.e.
+   * is visible in the frustum). Returns one of CS_FRUST_XXX values.
+   * Frustum and polygon should be given relative to (0,0,0).
+   */
+  static int Classify (csVector3* frustum, int num_frust,
+    csVector3* poly, int num_poly);
+
+  /**
+   * This is like the above version except that it takes a vector of precalculated frustum plane normals.
+   * Use this if you have to classify a batch of polygons against the same frustum.
+   */
+  static int BatchClassify (csVector3* frustum, csVector3* frustumNormals, int num_frust,
+			    csVector3* poly, int num_poly);
+
+  /**
+   * Check if a point (given relative to the origin of the frustum)
+   * is inside the frustum.
+   */
+  bool Contains (const csVector3& point);
+
+  /**
+   * Check if a point is inside a frustum. The point and
+   * frustum are relative to (0,0,0). Note that this function
+   * does not work correctly if the point is in the other direction
+   * from the average direction of the frustum.
+   */
+  static bool Contains (csVector3* frustum, int num_frust,
+    const csVector3& point);
+
+  /**
+   * Check if a point is inside a frustum. The point and
+   * frustum are relative to (0,0,0). This function also
+   * checks if point is in front of given plane.
+   */
+  static bool Contains (csVector3* frustum, int num_frust,
+    const csPlane3& plane, const csVector3& point);
+
+  /// Return true if frustum is empty.
+  bool IsEmpty () const { return !wide && vertices == NULL; }
+
+  /// Return true if frustum is infinite.
+  bool IsInfinite () const { return wide && vertices == NULL && backplane == NULL; }
+
+  /// Return true if frustum is infinitely wide but it can still have a back plane.
+  bool IsWide () const { return wide && vertices == NULL; }
+
+  /**
+   * Make the frustum infinite (i.e. clear the polygon and
+   * the back plane).
+   */
+  void MakeInfinite ();
+
+  /**
+   * Make the frustum empty.
+   */
+  void MakeEmpty ();
+
+  /// Increment reference counter
+  void IncRef () { ref_count++; }
+  /// Decrement reference counter
+  void DecRef () { if (ref_count == 1) delete this; else ref_count--; }
+};
+
+#endif // __CS_FRUSTRUM_H__
diff --git a/client/client94/crystalspace/include/csgeom/math2d.h b/client/client94/crystalspace/include/csgeom/math2d.h
new file mode 100644
index 0000000..9568617
--- /dev/null
+++ b/client/client94/crystalspace/include/csgeom/math2d.h
@@ -0,0 +1,256 @@
+/*
+    Copyright (C) 1998-2000 by Jorrit Tyberghein
+    Largely rewritten by Ivan Avramovic <ivan@avramovic.com>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_MATH2D_H__
+#define __CS_MATH2D_H__
+
+#define CS_POLY_IN 1
+#define CS_POLY_ON 0
+#define CS_POLY_OUT -1
+
+#include "csgeom/vector2.h"
+#include "csgeom/plane2.h"
+#include "csgeom/segment.h"
+
+class csBox2;
+class csPoly2D;
+
+/**
+ * Various functions in 2D, such as 2D vector functions.
+ * This is a static class and contains only static member functions.
+ */
+class csMath2
+{
+public:
+  /**
+   * Calculates which side of a line a given point is on.
+   * Returns -1 if point v is left of line segment 's1-s2',
+   *          1 if point v is right of segment 's1-s2'
+   *       or 0 if point v lies on segment 's1-s2'.
+   */
+  static int WhichSide2D (const csVector2& v,
+                          const csVector2& s1, const csVector2& s2)
+  {
+    float k  = (s1.y - v.y)*(s2.x - s1.x);
+    float k1 = (s1.x - v.x)*(s2.y - s1.y);
+    if (k < k1) return -1;
+    else if (k > k1) return 1;
+    else return 0;
+  }
+
+  /**
+   * Calculates which side of a line a given point is on.
+   * Returns -1 if point v is left of line segment 'seg'
+   *          1 if point v is right of segment 'seg'
+   *       or 0 if point v lies on segment 'seg'.
+   */
+  static int WhichSide2D (const csVector2& v,
+                          const csSegment2& s)
+  {
+    return WhichSide2D (v, s.Start (), s.End ());
+  }
+
+  /**
+   * Calculates whether a vector lies inside a given 2D polygon.
+   * Return CS_POLY_IN, CS_POLY_OUT, or CS_POLY_ON for this vector with
+   * respect to the given polygon. The polygon is given as an array of 2D
+   * vectors with a bounding box.
+   * WARNING: does no safety checking for P or bounding_box.
+   */
+  static int InPoly2D (const csVector2& v,
+                       csVector2* P, int n, csBox2* bounding_box);
+
+  /**
+   * Calculates 2 x the area of a given triangle.
+   * Returns twice the signed area of the triangle determined by a,b,c,
+   * positive if a,b,c are oriented ccw, and negative if cw.
+   */
+  static float Area2 (const csVector2& a,
+  		      const csVector2& b,
+  		      const csVector2& c)
+  {
+    return
+      a.x * b.y - a.y * b.x +
+      a.y * c.x - a.x * c.y +
+      b.x * c.y - c.x * b.y;
+  }
+
+  /**
+   * Calculates whether a point lies to the right of a given line.
+   * Returns true iff c is strictly to the right of the directed
+   * line through a to b.
+   */
+  static float Right (const csVector2& a,
+  		      const csVector2& b,
+  		      const csVector2& c)
+  {
+    return Area2 (a, b, c) <= -SMALL_EPSILON;
+  }
+
+  /**
+   * Calculates whether a point lies to the left of a given line.
+   * Returns true iff c is strictly to the left of the directed
+   * line through a to b.
+   */
+  static float Left (const csVector2& a,
+  		     const csVector2& b,
+  		     const csVector2& c)
+  {
+    return Area2 (a, b, c) >= SMALL_EPSILON;
+  }
+
+  /**
+   * Check if the plane is visible from the given point.
+   * This function does a back-face culling test to see whether the front
+   * face of plane pl is visible from point p.
+   */
+  static bool Visible (const csVector2& p, const csPlane2& pl)
+  { return pl.Classify (p) <= 0; }
+
+  /**
+   * Check if two planes are almost equal.
+   * The function returns true iff each component of the plane equation for
+   * one plane is within .001 of the corresponding component of the other
+   * plane.
+   */
+  static bool PlanesEqual (const csPlane2& p1, const csPlane2& p2)
+  {
+    return ( ( p1.norm - p2.norm) < (float).001 ) &&
+             (  ABS (p1.CC-p2.CC) < (float).001 );
+  }
+
+  /**
+   * Check if two planes are close together.
+   * Two planes are close if there are almost equal OR if
+   * the normalized versions are almost equal.
+   */
+  static bool PlanesClose (const csPlane2& p1, const csPlane2& p2);
+};
+
+/**
+ * Some functions to perform various intersection calculations with 2D
+ * line segments.  This is a static class and contains only static member
+ * functions.
+ */
+class csIntersect2
+{
+public:
+  /**
+   * Intersect a plane with a 2D polygon and return
+   * the line segment corresponding with this intersection.
+   * Returns true if there is an intersection. If false
+   * then 'segment' will not be valid.
+   */
+  static bool IntersectPolygon (const csPlane2& plane, csPoly2D* poly,
+  	csSegment2& segment);
+
+  /**
+   * Compute the intersection of the 2D segments.  Return true if they
+   * intersect, with the intersection point returned in isect,  and the
+   * distance from a1 of the intersection in dist.
+   */
+  static bool Segments (
+    const csSegment2& a, const csSegment2& b,	// Two segments.
+    csVector2& isect, float& dist);         // intersection point and distance
+
+  /**
+   * Compute the intersection of a 2D segment and a line.  Return true if they
+   * intersect, with the intersection point returned in isect,  and the
+   * distance from a1 of the intersection in dist.
+   */
+  static bool SegmentLine (
+    const csSegment2& a,		// First segment.
+    const csSegment2& b,		// A line (end is only direction)
+    csVector2& isect, float& dist);     // intersection point and distance
+
+  /**
+   * Compute the intersection of 2D lines.  Return true if they
+   * intersect, with the intersection point returned in isect.
+   */
+  static bool Lines (
+    // Two lines (end is only direction).
+    const csSegment2& a, const csSegment2& b,
+    csVector2& isect);                      // intersection point
+
+  /**
+   * Intersect a 2D segment with a plane.  Returns true if there is an
+   * intersection, with the intersection point returned in isect.
+   * The distance from u to the intersection point is returned in dist.
+   * The distance that is returned is a normalized distance with respect
+   * to the given input vector. i.e. a distance of 0.5 means that the
+   * intersection point is halfway u and v.
+   */
+  static bool Plane (
+    const csVector2& u, const csVector2& v,
+    const csPlane2& p,                     // plane Ax+By+Cz+D=0
+    csVector2& isect,                     // intersection point
+    float& dist);                       // distance from u to isect
+
+  /**
+   * Intersect a 2D segment with a plane.  Returns true if there is an
+   * intersection, with the intersection point returned in isect.
+   * The distance from u to the intersection point is returned in dist.
+   * The distance that is returned is a normalized distance with respect
+   * to the given input vector. i.e. a distance of 0.5 means that the
+   * intersection point is halfway u and v.
+   */
+  static bool Plane (
+    const csSegment2& uv,	// Segment.
+    const csPlane2& p,                     // plane Ax+By+Cz+D=0
+    csVector2& isect,                     // intersection point
+    float& dist)                        // distance from u to isect
+  {
+    return Plane (uv.Start (), uv.End (), p, isect, dist);
+  }
+
+  /**
+   * Return the intersection point. This version does not test if
+   * there really is an intersection. It just assumes there is one.
+   */
+  static void PlaneNoTest (const csVector2& u, const csVector2& v,
+                     const csPlane2& p, csVector2& isect, float& dist)
+  {
+    float x,y, denom;
+    x = v.x-u.x;  y = v.y-u.y;
+    denom = p.norm.x*x + p.norm.y*y;
+    dist = -(p.norm*u + p.CC) / denom;
+    isect.x = u.x + dist*x;  isect.y = u.y + dist*y;
+  }
+
+  /**
+   * Return the intersection point. This version does not test if
+   * there really is an intersection. It just assumes there is one.
+   */
+  static void PlaneNoTest (const csSegment2& uv,
+                     const csPlane2& p, csVector2& isect, float& dist)
+  {
+    PlaneNoTest (uv.Start (), uv.End (), p, isect, dist);
+  }
+
+  /**
+   * Intersect 2 planes to get the point that is part of all two
+   * planes. Returns true, if there is a single point that fits.
+   * If the planes are parallel, then it will return false.
+   */
+  static bool Planes (const csPlane2& p1, const csPlane2& p2,
+                      csVector2& isect);
+
+};
+
+#endif // __CS_MATH_H__
diff --git a/client/client94/crystalspace/include/csgeom/math3d.h b/client/client94/crystalspace/include/csgeom/math3d.h
new file mode 100644
index 0000000..041bee7
--- /dev/null
+++ b/client/client94/crystalspace/include/csgeom/math3d.h
@@ -0,0 +1,451 @@
+/*
+    Copyright (C) 1998-2001 by Jorrit Tyberghein
+    Largely rewritten by Ivan Avramovic <ivan@avramovic.com>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_MATH3D_H__
+#define __CS_MATH3D_H__
+
+#ifndef __CS_CSSYSDEFS_H__
+#error "cssysdef.h must be included in EVERY source file!"
+#endif
+
+#include "csgeom/vector3.h"
+#include "csgeom/plane3.h"
+#include "csgeom/plane2.h"
+#include "csgeom/segment.h"
+
+class csDVector3;
+class csPoly3D;
+class csBox3;
+
+inline float fSqr (float f)
+{
+  return f * f;
+}
+
+/**
+ * Various assorted 3D mathematical functions.
+ * This is a static class and contains only static member functions.
+ */
+class csMath3
+{
+public:
+  /**
+   * Tests which side of a plane the given 3D point is on.
+   * Return -1 if point p is left of plane '0-v1-v2',
+   *         1 if point p is right of plane '0-v1-v2',
+   *      or 0 if point p lies on plane '0-v1-v2'.
+   * Plane '0-v1-v2' is the plane passing through points <0,0,0>, v1, and v2.
+   *<p>
+   * Warning: the result of this function when 'p' is exactly on the plane
+   * 0-v1-v2 is undefined. It should return 0 but it will not often do that
+   * due to numerical inaccuracies. So you should probably test for this
+   * case seperatelly.
+   */
+  static int WhichSide3D (const csVector3& p,
+                          const csVector3& v1, const csVector3& v2)
+  {
+//    float s = p * (v1%v2);  (original expression: expanded to the below:)
+    float s = p.x*(v1.y*v2.z-v1.z*v2.y) + p.y*(v1.z*v2.x-v1.x*v2.z) +
+              p.z*(v1.x*v2.y-v1.y*v2.x);
+    if (s < 0) return 1;
+    else if (s > 0) return -1;
+    else return 0;
+  }
+
+  /**
+   * Tests if the front face of a triangle is visible from the given point.
+   * Visibility test (backface culling) to see if the triangle formed by
+   * t1, t2, and t3 is visible from point p.
+   */
+  static bool Visible (const csVector3& p, const csVector3& t1,
+                       const csVector3& t2, const csVector3& t3);
+
+  /**
+   * Check if the plane is visible from the given point.
+   * This function does a back-face culling test to see whether the front
+   * face of plane pl is visible from point p.
+   */
+  static bool Visible (const csVector3& p, const csPlane3& pl)
+  { return pl.Classify (p) <= 0; }
+
+  /**
+   * Calculate the line, that is the result of the Intersection of
+   * triangle 1  and triangle 2. This Method returns false, if there is
+   * no intersection. If there is an intersection, the start of the line
+   * is in line[0] and the end of the line is in line[1] and the method
+   * return true;
+   */
+  static bool FindIntersection(const csVector3  tri1[3],
+                               const csVector3  tri2[3],
+                               csVector3        line[2]);
+
+  /**
+   * Calculates a vector lying a specified distance between two other vectors.
+   * Given vectors v1 and v2, this function will calculate and return vector
+   * v lying between them.
+   * If pct != -1, vector v will be the point which is pct % of the
+   * way from v1 to v2.
+   * Otherwise, if pct equals -1, v will be the point along 'v1-v2' which is
+   * distance wid from v1.
+   */
+  static void Between (const csVector3& v1, const csVector3& v2, csVector3& v,
+                       float pct, float wid);
+
+  /**
+   * Set the min and max vector if this vector exceeds their current limits.
+   * This function will check each component of vector v against the maximum
+   * and minimum values specified by min and max.  If the limits are
+   * exceeded, new min or max values will be set.
+   */
+  static void SetMinMax (const csVector3& v,
+                         csVector3& min, csVector3& max)
+  {
+    if (v.x > max.x) max.x = v.x; else if (v.x < min.x ) min.x = v.x;
+    if (v.y > max.y) max.y = v.y; else if (v.y < min.y ) min.y = v.y;
+    if (v.z > max.z) max.z = v.z; else if (v.z < min.z ) min.z = v.z;
+  }
+
+  /**
+   * Compute twice the signed area of triangle composed by three points.
+   * This function returns 2 x the area of the triangle formed by the points
+   * a, b, and c.
+   */
+  inline static float Area3 (const csVector3 &a, const csVector3 &b,
+                             const csVector3 &c)
+  {
+    csVector3 v1 = b - a;
+    csVector3 v2 = c - a;
+    return ((v1.y * v2.z + v1.z * v2.x + v1.x * v2.y) -
+            (v1.y * v2.x + v1.x * v2.z + v1.z * v2.y));
+  }
+
+  /**
+   * Calculate a plane normal given three vectors.
+   * This function will calculate the normal to the plane formed by vectors
+   * v1, v2, and v3, and store the result in norm.
+   */
+  inline static void CalcNormal (csVector3& norm,     const csVector3& v1,
+                                 const csVector3& v2, const csVector3& v3)
+  {
+    norm = (v1-v2)%(v1-v3);
+  }
+
+  /**
+   * Compute the normal given two (u,v) vectors.
+   * This function will calculate the normal to a polygon with two edges
+   * represented by v and u.  The result is stored in norm.
+   */
+  static void CalcNormal (csVector3& norm,
+                          const csVector3& v, const csVector3& u)
+  { norm = u%v; /* NOT v%u - vertexes are defined clockwise */ }
+
+  /**
+   * Calculate the plane equation given three vectors.
+   * Given three vectors v1, v2, and v3, forming a plane, this function
+   * will calculate the plane equation and return the result in 'normal'
+   * and 'D'.
+   */
+  static void CalcPlane (const csVector3& v1, const csVector3& v2,
+         const csVector3& v3, csVector3& normal, float& D)
+  {
+    CalcNormal (normal, v1, v2, v3);
+    D = - (normal * v1);
+  }
+
+  /**
+   * Check if two planes are almost equal.
+   * The function returns true iff each component of the plane equation for
+   * one plane is within .001 of the corresponding component of the other
+   * plane.
+   */
+  static bool PlanesEqual (const csPlane3& p1, const csPlane3& p2)
+  {
+    return ( ( p1.norm - p2.norm) < (float).001 ) &&
+             (  ABS (p1.DD-p2.DD) < (float).001 );
+  }
+
+  /**
+   * Check if two planes are close together.
+   * Two planes are close if there are almost equal OR if
+   * the normalized versions are almost equal.
+   */
+  static bool PlanesClose (const csPlane3& p1, const csPlane3& p2);
+
+  /**
+   * Calculate the set of outer planes between the two boxes. Is something
+   * does not intersect this set of planes then it will not be between
+   * the two boxes. The given array of planes should have place for at
+   * least eight planes. This function returns the number of planes
+   * that are put in 'planes'.
+   */
+  static int OuterPlanes (const csBox3& box1, const csBox3& box2,
+    csPlane3* planes);
+
+  /**
+   * Find all observer sides on the first box that can see the
+   * other box. Sides are numbered like this: 0=MinX(), 1=MaxX(),
+   * 2=MinY(), 3=MaxY(), 4=MinZ(), 5=MaxZ().
+   * The given array should have place for 6 sides.
+   * This function returns the number of observer sides.
+   */
+  static int FindObserverSides (const csBox3& box1, const csBox3& box2,
+  	int* sides);
+
+  /**
+   * Given two angles in radians, calculate the position on the sphere
+   * around (0,0,0) with radius 1. The first angle is the angle along
+   * the horizontal (x/z) plane. The second angle is the vertical angle.
+   */
+  static void SpherePosition (float angle_xz, float angle_vert,
+  	csVector3& pos);
+};
+
+/**
+ * Some functions to perform squared distance calculations.
+ * This is a static class and contains only static member functions.
+ */
+class csSquaredDist
+{
+public:
+  /// Returns the squared distance between two points.
+  static float PointPoint (const csVector3& p1, const csVector3& p2)
+  { return fSqr (p1.x - p2.x) + fSqr (p1.y - p2.y) + fSqr (p1.z - p2.z); }
+
+  /// Returns the squared distance between a point and a line.
+  static float PointLine (const csVector3& p,
+                          const csVector3& l1, const csVector3& l2);
+
+  /// Returns the squared distance between a point and a normalized plane.
+  static float PointPlane (const csVector3& p, const csPlane3& plane)
+  { float r = plane.Classify (p);  return r * r; }
+
+  /**
+   * Returns the squared distance between a point and a polygon.
+   * If sqdist is >= 0, then it is used as the pre-calculated point to
+   * plane distance.  V is an array of vertices, n is the number of
+   * vertices, and plane is the polygon plane.
+   */
+  static float PointPoly (const csVector3& p, csVector3 *V, int n,
+                          const csPlane3& plane, float sqdist = -1);
+};
+
+/**
+ * Some functions to perform various intersection calculations with 3D
+ * line segments.  This is a static class and contains only static member
+ * functions.
+ */
+class csIntersect3
+{
+public:
+  /**
+   * Intersect a plane with a 3D polygon and return
+   * the line segment corresponding with this intersection.
+   * Returns true if there is an intersection. If false
+   * then 'segment' will not be valid.
+   */
+  static bool IntersectPolygon (const csPlane3& plane, csPoly3D* poly,
+  	csSegment3& segment);
+
+  /**
+   * Intersect a segment with a frustum (given as a set of planes).
+   * Returns the clipped segment (i.e. the part of the segment that is
+   * visible in the frustum). Returns -1 if the segment is entirely
+   * outside the frustum. Returns 0 if the segment is not modified and
+   * returns 1 otherwise. The input segment will be modified.
+   * @@@ WARNING! This function may not work completely ok. It has only
+   * barely been tested and is now unused.
+   */
+  static int IntersectSegment (csPlane3* planes, int num_planes,
+  	csSegment3& seg);
+
+  /**
+   * Intersect a 3D segment with a triangle. Returns true if there
+   * is an intersection. In that case the intersection point will
+   * be in 'isect'.
+   */
+  static bool IntersectTriangle (const csVector3& tr1,
+  	const csVector3& tr2, const csVector3& tr3,
+	const csSegment3& seg, csVector3& isect);
+
+  /**
+   * Intersect a 3D segment with a plane.  Returns true if there is an
+   * intersection, with the intersection point returned in isect.
+   */
+  static bool Plane (
+    const csVector3& u, const csVector3& v,
+    const csVector3& normal, const csVector3& a, // plane
+    csVector3& isect, float& dist);              // intersection point
+
+  /**
+   * Intersect a 3D segment with a plane.  Returns true if there is an
+   * intersection, with the intersection point returned in isect.
+   * The distance from u to the intersection point is returned in dist.
+   * The distance that is returned is a normalized distance with respect
+   * to the given input vector. i.e. a distance of 0.5 means that the
+   * intersection point is halfway u and v.
+   */
+  static bool Plane (
+    const csVector3& u, const csVector3& v,
+    const csPlane3& p,                     // plane Ax+By+Cz+D=0
+    csVector3& isect,                     // intersection point
+    float& dist);                       // distance from u to isect
+
+  /**
+   * Intersect 3 planes to get the point that is part of all three
+   * planes. Returns true, if there is a single point that fits.
+   * If some planes are parallel, then it will return false.
+   */
+  static bool Planes (const csPlane3& p1, const csPlane3& p2,
+  	const csPlane3& p3, csVector3& isect);
+
+  /**
+   * Intersect a regular plane and an axis aligned plane and
+   * return the intersection (line) as a 2D plane. This intersection
+   * is defined on the axis aligned plane.
+   * Returns false if there is no intersection.
+   */
+  static bool PlaneXPlane (const csPlane3& p1, float x2, csPlane2& isect);
+
+  /**
+   * Intersect a regular plane and an axis aligned plane and
+   * return the intersection (line) as a 2D plane. This intersection
+   * is defined on the axis aligned plane.
+   * Returns false if there is no intersection.
+   */
+  static bool PlaneYPlane (const csPlane3& p1, float y2, csPlane2& isect);
+
+  /**
+   * Intersect a regular plane and an axis aligned plane and
+   * return the intersection (line) as a 2D plane. This intersection
+   * is defined on the axis aligned plane.
+   * Returns false if there is no intersection.
+   */
+  static bool PlaneZPlane (const csPlane3& p1, float z2, csPlane2& isect);
+
+  /**
+   * Intersect a regular plane and an axis aligned plane and
+   * return the intersection (line) as a 2D plane. This intersection
+   * is defined on the axis aligned plane.
+   * Returns false if there is no intersection.
+   */
+  static bool PlaneAxisPlane (const csPlane3& p1, int nr, float pos,
+  	csPlane2& isect)
+  {
+    switch (nr)
+    {
+      case 0: return PlaneXPlane (p1, pos, isect);
+      case 1: return PlaneYPlane (p1, pos, isect);
+      case 2: return PlaneZPlane (p1, pos, isect);
+    }
+    return false;
+  }
+
+  /**
+   * Intersect a 3D segment with the z = 0 plane.  Assumes that there
+   * is an intersection (fails if the segment is parallel to the plane),
+   * and returns the distance from u to the intersection point.
+   * The intersection point is returned in isect.
+   */
+  static float Z0Plane (
+    const csVector3& v1, const csVector3& v2,
+    csVector3& isect);                    // intersection point
+
+  /**
+   * Intersect a 3D segment with the z = 0 plane.  Assumes that there
+   * is an intersection (fails if the segment is parallel to the plane),
+   * and returns the distance from u to the intersection point.
+   * The intersection point is returned in isect.
+   */
+  static float Z0Plane (
+    const csSegment3& uv,
+    csVector3& isect)                    // intersection point
+  {
+    return Z0Plane (uv.Start (), uv.End (), isect);
+  }
+
+  /**
+   * Intersect a 3D segment with the plane z = zval. Assumes that there
+   * is an intersection (fails if the segment is parallel to the plane),
+   * and returns the distance from u to the intersection point.
+   * The intersection point is returned in isect.
+   */
+  static float ZPlane (float zval,      // plane z = zval
+    const csVector3& u, const csVector3& v,
+    csVector3& isect);                    // intersection point
+
+  /**
+   * Intersect a 3D segment with the plane z = zval. Assumes that there
+   * is an intersection (fails if the segment is parallel to the plane),
+   * and returns the distance from u to the intersection point.
+   * The intersection point is returned in isect.
+   */
+  static float ZPlane (float zval,      // plane z = zval
+    const csSegment3& uv,
+    csVector3& isect)                     // intersection point
+  {
+    return ZPlane (zval, uv.Start (), uv.End (), isect);
+  }
+
+  /**
+   * Intersect a 3D segment with the frustum plane Ax + z = 0.
+   * Assumes an intersection, and returns the intersection point in isect.
+   */
+  static float XFrustum (
+    float A, const csVector3& u, const csVector3& v, csVector3& isect);
+
+  /**
+   * Intersect a 3D segment with the frustum plane Ax + z = 0.
+   * Assumes an intersection, and returns the intersection point in isect.
+   */
+  static float XFrustum (
+    float A, const csSegment3& uv, csVector3& isect)
+  {
+    return XFrustum (A, uv.Start (), uv.End (), isect);
+  }
+
+  /**
+   * Intersect a 3D segment with the frustum plane By + z = 0.
+   * Assumes an intersection, and returns the intersection point in isect.
+   */
+  static float YFrustum (
+    float B, const csVector3& u, const csVector3& v, csVector3& isect);
+
+  /**
+   * Intersect a 3D segment with the frustum plane By + z = 0.
+   * Assumes an intersection, and returns the intersection point in isect.
+   */
+  static float YFrustum (
+    float B, const csSegment3& uv, csVector3& isect)
+  {
+    return YFrustum (B, uv.Start (), uv.End (), isect);
+  }
+
+  /**
+   * Intersect a segment with a box and returns true if it intersects.
+   * The intersection point is also returned.
+   * If 'pr' is given then a number between 0 and 1 is returned which
+   * corresponds to the position on the segment. If we were in the box
+   * this this function will also return true. In this case 'isect' will
+   * be set to the start of the segment and *pr to 0.
+   */
+  static int BoxSegment (const csBox3& box, const csSegment3& segment,
+  	csVector3& isect, float* pr = NULL);
+};
+
+#endif // __CS_MATH3D_H__
diff --git a/client/client94/crystalspace/include/csgeom/math3d_d.h b/client/client94/crystalspace/include/csgeom/math3d_d.h
new file mode 100644
index 0000000..298d49f
--- /dev/null
+++ b/client/client94/crystalspace/include/csgeom/math3d_d.h
@@ -0,0 +1,671 @@
+/*
+    Copyright (C) 1998,1999,2000 by Jorrit Tyberghein
+    Largely rewritten by Ivan Avramovic <ivan@avramovic.com>
+    Converted to double by Thomas Hieber
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __CS_MATH3D_D_H__
+#define __CS_MATH3D_D_H__
+
+#include "cstypes.h"
+
+#ifndef ABS
+#define ABS(x) ((x)<0?-(x):(x))
+#endif
+
+class csDVector3;
+class csDMatrix3;
+class csVector3;
+
+inline double dSqr (double d)
+{
+  return d * d;
+}
+
+/**
+ * A 3D vector.
+ */
+class csDVector3
+{
+public:
+  /// The X component of the vector
+  double x;
+  /// The Y component of the vector
+  double y;
+  /// The Z component of the vector
+  double z;
+
+  /**
+   * Make a new vector. The vector is not
+   * initialized. This makes the code slightly faster as
+   * csDVector3 objects are used a lot.
+   */
+  csDVector3 () {}
+
+  /**
+   * Make a new initialized vector.
+   * Creates a new vector and initializes it to m*<1,1,1>.  To create
+   * a vector initialized to the zero vector, use csDVector3(0)
+   */
+  csDVector3 (double m) : x(m), y(m), z(m) {}
+
+  /// Make a new vector and initialize with the given values.
+  csDVector3 (double ix, double iy, double iz = 0) { x = ix; y = iy; z = iz; }
+
+  /// Copy Constructor.
+  csDVector3 (const csDVector3& v) { x = v.x; y = v.y; z = v.z; }
+
+  /// Conversion from single precision vector to double.
+  csDVector3 (const csVector3&);
+
+  /// Add two vectors.
+  inline friend
+  csDVector3 operator+ (const csDVector3& v1, const csDVector3& v2)
+  { return csDVector3(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z); }
+
+  /// Subtract two vectors.
+  inline friend
+  csDVector3 operator- (const csDVector3& v1, const csDVector3& v2)
+  { return csDVector3(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z); }
+
+  /// Take the dot product of two vectors.
+  inline friend double operator* (const csDVector3& v1, const csDVector3& v2)
+  { return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; }
+
+  /// Take the cross product of two vectors.
+  inline friend
+  csDVector3 operator% (const csDVector3& v1, const csDVector3& v2)
+  {
+    return csDVector3 (v1.y*v2.z-v1.z*v2.y,
+                       v1.z*v2.x-v1.x*v2.z,
+                       v1.x*v2.y-v1.y*v2.x);
+  }
+
+  /// Take cross product of two vectors and put result in this vector.
+  void Cross (const csDVector3 & px, const csDVector3 & py)
+  {
+    x = px.y*py.z - px.z*py.y;
+    y = px.z*py.x - px.x*py.z;
+    z = px.x*py.y - px.y*py.x;
+  }
+
+  /// Multiply a vector and a scalar.
+  inline friend csDVector3 operator* (const csDVector3& v, double f)
+  { return csDVector3(v.x*f, v.y*f, v.z*f); }
+
+  /// Multiply a vector and a scalar.
+  inline friend csDVector3 operator* (double f, const csDVector3& v)
+  { return csDVector3(v.x*f, v.y*f, v.z*f); }
+
+  /// Divide a vector by a scalar.
+  inline friend csDVector3 operator/ (const csDVector3& v, double f)
+  { f = 1.0f/f; return csDVector3(v.x*f, v.y*f, v.z*f); }