You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(153) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(48) |
Feb
(46) |
Mar
(12) |
Apr
(4) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
(263) |
Mar
(235) |
Apr
(66) |
May
(42) |
Jun
(270) |
Jul
(65) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Markus R. <rol...@us...> - 2005-12-05 21:38:33
|
Update of /cvsroot/simspark/simspark/spark/kerosin/imageserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/imageserver Added Files: .cvsignore image.cpp image.h imageserver.cpp imageserver.h imageserver_c.cpp Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs --- NEW FILE: imageserver_c.cpp --- #include "imageserver.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; void CLASS(ImageServer)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Leaf); } --- NEW FILE: image.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: image.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_IMAGE_H #define KEROSIN_IMAGE_H /* Image - A Wrapper for the DevIL Library NOTE: HISTORY: 11.07.01 - MK - Initial version 28.08.01 - MK - Added support for a palette 29.08.01 - MK - Rewrite for DevIL 03.09.01 - MK - OpenGL texture support TODO: - add RGB access - image creation TOFIX: */ #include <IL/il.h> namespace kerosin { class Image { public: // constructor/destructor Image(); virtual ~Image(); // this makes the image active void Bind(); // image information ILuint Width(); // width ILuint Height(); // height ILuint Depth(); // depth (==1 for 2d images, >1 for 3d images) ILuint BitsPP(); // bits per pixel ILuint BytesPP(); // bytes per pixel ILuint Type(); // format of pixels ILuint Format(); // byte format of image ILubyte*Data(); bool HasAlpha(); // does the format have an alpha channel bool Create(int w, int h, int b, void *data = NULL); // the interface functions ... these *have* to be implemented by derived classes //virtual bool Create() = 0; //virtual void SetPixel(int x, int y, long color) const = 0; //virtual long GetPixel(int x, int y) const = 0; /* virtual long MakeCol(int a, int r, int g, int b) const = 0; virtual void GetCol(long col, int& a, int& r, int& g, int& b) const = 0; virtual int GetA(long col) const = 0; virtual int GetR(long col) const = 0; virtual int GetG(long col) const = 0; virtual int GetB(long col) const = 0; // accessors f_inline void SetWidth (int inWidth) { mWidth = inWidth; } f_inline void SetHeight(int inHeight) { mHeight = inHeight; } */ protected: ILuint mId; // the DevIL ID which this image is bound to }; } // namespace kerosin #endif //KEROSIN_IMAGE_H --- NEW FILE: imageserver.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2004 RoboCup Soccer Server 3D Maintenance Group $Id: imageserver.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "imageserver.h" #include "image.h" #include <salt/fileclasses.h> #include <zeitgeist/fileserver/fileserver.h> #include <zeitgeist/logserver/logserver.h> #include <boost/scoped_ptr.hpp> using namespace boost; using namespace kerosin; using namespace salt; using namespace zeitgeist; using namespace std; shared_ptr<FileServer> gFileServer; //------------------------------------------------------------------------------------------------ // FileServer hooks for DevIL //------------------------------------------------------------------------------------------------ ILHANDLE ILAPIENTRY FSOpen(const ILstring inName) { return (ILHANDLE)(gFileServer->Register(inName)); } ILvoid ILAPIENTRY FSClose(ILHANDLE handle) { gFileServer->Close((FileServer::THandle)handle); } ILboolean ILAPIENTRY FSEof(ILHANDLE handle) { shared_ptr<salt::RFile> file = gFileServer->Get((FileServer::THandle)handle); return file->Eof(); } ILint ILAPIENTRY FSGetc(ILHANDLE handle) { shared_ptr<salt::RFile> file = gFileServer->Get((FileServer::THandle)handle); return file->Getc(); } ILint ILAPIENTRY FSRead(void *buffer, ILuint size, ILuint count, ILHANDLE handle) { shared_ptr<salt::RFile> file = gFileServer->Get((FileServer::THandle)handle); return file->Read(buffer, size, count); } ILint ILAPIENTRY FSSeek(ILHANDLE handle, ILint offset, ILint origin) { shared_ptr<salt::RFile> file = gFileServer->Get((FileServer::THandle)handle); return file->Seek(offset, origin); } ILint ILAPIENTRY FSTell(ILHANDLE handle) { shared_ptr<salt::RFile> file = gFileServer->Get((FileServer::THandle)handle); return file->Tell(); } //------------------------------------------------------------------------------------------------ // ImageServer implementation //------------------------------------------------------------------------------------------------ // constructor ImageServer::ImageServer() { // initialize DevIL ilInit(); // and setup the default behavior // (this might come out of a config file at a later point) ilEnable(IL_FILE_OVERWRITE); ilEnable(IL_ORIGIN_SET); ilOriginFunc(IL_ORIGIN_UPPER_LEFT); // register FileServer hooks for DevIL ilSetRead( FSOpen, FSClose, FSEof, FSGetc, FSRead, FSSeek, FSTell); } // // This function loads the file inName. If inType is IL_TYPE_UNKNOWN, // then the library will try to find a handler by the file extension provided. // This behavior is done automatically by the library! // boost::shared_ptr<Image> ImageServer::Load(const string& inName, ILenum inType) { // create a new image boost::shared_ptr<Image> image(new Image()); // make it active with DevIL image->Bind(); // set the file server gFileServer = shared_static_cast<FileServer>(GetCore()->Get("/sys/server/file")); // load the image ilLoad(inType, (ILstring)inName.c_str()); // set the file server to 0 again gFileServer.reset(); // check for errors if(HandleErrors() == true) { // release the image and return return boost::shared_ptr<Image>(); } return image; } bool ImageServer::Save(const boost::shared_ptr<Image> &inImage, const string& inName, ILenum inType) { // make the image active inImage->Bind(); // set the file server gFileServer = shared_static_cast<FileServer>(GetCore()->Get("/sys/server/file")); // save the image ilSave(inType, (ILstring)inName.c_str()); // set the file server to 0 again gFileServer.reset(); // check for errors if(HandleErrors() == true) { return false; } return true; } // // This routine checks for DevIL errors and logs them. The function returns // 'true' if an error has occured and 'false' if not. // bool ImageServer::HandleErrors() { bool ret = false; ILenum error; // check if we have any errors and log them accordingly while ((error = ilGetError()) != IL_NO_ERROR) { ret = true; string msg; switch(error) { case IL_INVALID_ENUM : msg = "invalid enum"; break; case IL_OUT_OF_MEMORY : msg = "out of memory"; break; case IL_FORMAT_NOT_SUPPORTED : msg = "format not supported"; break; case IL_INTERNAL_ERROR : msg = "internal error"; break; case IL_INVALID_VALUE : msg = "invalid value"; break; case IL_ILLEGAL_OPERATION : msg = "illegal operation"; break; case IL_ILLEGAL_FILE_VALUE : msg = "illegal file value"; break; case IL_INVALID_FILE_HEADER : msg = "invalid file header"; break; case IL_INVALID_PARAM : msg = "invalid param"; break; case IL_COULD_NOT_OPEN_FILE : msg = "could not open file"; break; case IL_INVALID_EXTENSION : msg = "invalid extension"; break; case IL_FILE_ALREADY_EXISTS : msg = "file already exists"; break; case IL_OUT_FORMAT_SAME : msg = "out format same"; break; case IL_STACK_OVERFLOW : msg ="stack overflow"; break; case IL_STACK_UNDERFLOW : msg ="stack underflow"; break; case IL_INVALID_CONVERSION : msg = "invalid conversion"; break; case IL_BAD_DIMENSIONS : msg = "bad dimensions"; break; case IL_FILE_READ_ERROR : //case IL_FILE_WRITE_ERROR : msg = "file read/write error"; break; case IL_LIB_GIF_ERROR : msg = "lib gif error"; break; case IL_LIB_JPEG_ERROR : msg = "lib jpeg error"; break; case IL_LIB_PNG_ERROR : msg = "lib png error"; break; case IL_LIB_TIFF_ERROR : msg = "lib tiff error"; break; case IL_LIB_MNG_ERROR : msg = "lib mng error"; break; default: msg = "unknown IL error"; break; } GetLog()->Error() << "(ImageServer) ERROR: DevIL returned error " << error << " (" << msg << ")\n"; } return ret; } --- NEW FILE: imageserver.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: imageserver.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_IMAGESERVER_H #define KEROSIN_IMAGESERVER_H #include <IL/il.h> #include <zeitgeist/class.h> namespace kerosin { class Image; /* ImageServer - Global Interface For All Image-Related Functionality What the ImageServer does: - Load/Save images - Create images with different formats - Conversion between formats NOTE: HISTORY: 14.07.01 - MK - Initial version 29.07.01 - MK - Uses classserver 29.08.01 - MK - Doesn't use classserver anymore :( - Switched to DevIL for image loading needs, since the task of supporting all major formats would have been too time consuming - Cleaned up the interface of the imageserver quite a bit 11.10.01 - MK - Made singleton functionality more secure 02.10.02 - MK - Moved to Kerosin TODO: - Image creation - Image conversion - Pixel-level access TOFIX: */ class ImageServer : public zeitgeist::Leaf { public: ImageServer(); // load/save /** interpret the file with the filter associated with inExt */ boost::shared_ptr<Image> Load(const std::string& inName, ILenum inType = IL_TYPE_UNKNOWN); /** interpret the file with the filter associated with inExt */ bool Save(const boost::shared_ptr<Image> &inImage, const std::string& inName, ILenum inType = IL_TYPE_UNKNOWN); private: /** some internal error checking */ bool HandleErrors(); }; DECLARE_CLASS(ImageServer); } // namespace kerosin #endif //KEROSIN_IMAGESERVER_H --- NEW FILE: image.cpp --- #include "image.h" using namespace kerosin; // constructor Image::Image() { // let's create a DevIL ID for this image ilGenImages(1, &mId); } // destructor Image::~Image() { // free the image with DevIL ilDeleteImages(1, &mId); } void Image::Bind() { ilBindImage(mId); } ILuint Image::Width() { Bind(); return ilGetInteger(IL_IMAGE_WIDTH); } ILuint Image::Height() { Bind(); return ilGetInteger(IL_IMAGE_HEIGHT); } ILuint Image::Depth() { Bind(); return ilGetInteger(IL_IMAGE_DEPTH); } ILuint Image::BitsPP() { Bind(); return ilGetInteger(IL_IMAGE_BITS_PER_PIXEL ); } ILuint Image::BytesPP() { Bind(); return ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL ); } ILuint Image::Type() { Bind(); return ilGetInteger(IL_IMAGE_TYPE); } ILuint Image::Format() { Bind(); return ilGetInteger(IL_IMAGE_FORMAT); } ILubyte* Image::Data() { Bind(); return ilGetData(); } bool Image::HasAlpha() { Bind(); ILuint format = Format(); switch(format) { case IL_RGB: case IL_BGR: return false; break; case IL_RGBA: case IL_BGRA: return true; break; default: return false; } } bool Image::Create(int w, int h, int b, void *data) { Bind(); if(b==3) { ilTexImage(w, h, 1, b, IL_RGB, IL_UNSIGNED_BYTE, data); } else { ilTexImage(w, h, 1, b, IL_RGBA, IL_UNSIGNED_BYTE, data); } return true; } |
From: Markus R. <rol...@us...> - 2005-12-05 21:38:33
|
Update of /cvsroot/simspark/simspark/spark/kerosin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774 Added Files: .cvsignore Makefile.am kerosin.cpp kerosin.h Log Message: --- NEW FILE: .cvsignore --- .deps .libs Makefile Makefile.in kerosin-config libkerosin*.la libkerosin*.lo --- NEW FILE: Makefile.am --- if BUILD_KEROSIN if DEBUG pkglib_LTLIBRARIES = libkerosin_debug.la libkerosin_debug_la_SOURCES = $(sources) nodist_libkerosin_debug_la_SOURCES = openglserver/glextensionreg.cpp libkerosin_debug_la_CXXFLAGS = -O -g -W -Wall libkerosin_debug_la_LIBADD = @FREETYPE_LIBADD@ -lSDL -lIL -lGL libkerosin_debug_la_LDFLAGS = -version-info @kerosin_version_info@ else pkglib_LTLIBRARIES = libkerosin.la libkerosin_la_SOURCES = $(sources) nodist_libkerosin_la_SOURCES = openglserver/glextensionreg.cpp libkerosin_la_CXXFLAGS = -O2 libkerosin_la_LIBADD = @FREETYPE_LIBADD@ -lSDL -lIL -lGL libkerosin_la_LDFLAGS = -version-info @kerosin_version_info@ endif bin_SCRIPTS = kerosin-config BUILT_SOURCES = openglserver/glextensionreg.h nobase_nodist_libpkginclude_HEADERS = openglserver/glextensionreg.h openglserver/glextensionreg.cpp: ${top_srcdir}/utility/glextgen/glextensionreg.cpp @echo "Copying generated glextension sources" cp ${top_srcdir}/utility/glextgen/glextensionreg.cpp $@ openglserver/glextensionreg.h: ${top_srcdir}/utility/glextgen/glextensionreg.h cp ${top_srcdir}/utility/glextgen/glextensionreg.h $@ ${top_srcdir}/utility/glextgen/glextensionreg.cpp ${top_srcdir}/utility/glextgen/glextensionreg.h: cd ${top_srcdir}/utility/glextgen/ && $(MAKE) $(AM_MAKEFLAGS) all endif AM_CPPFLAGS = -I${top_srcdir}/lib -I$(top_srcdir)/lib/kerosin/sceneserver/helper @FREETYPE_CPPFLAGS@ @RUBY_CPPFLAGS@ ## define include directory local to the pkgincludedir libpkgincludedir = $(includedir)/@PACKAGE@/kerosin ## architecture independent data (scripts) to be installed and distributed dist_pkgdata_DATA = \ kerosin.rb \ inputserver/german.scan.rb \ openglserver/glbase.h sources = \ fontserver/font.cpp \ fontserver/fontserver.cpp \ fontserver/fontserver_c.cpp \ fontserver/glyph.cpp \ imageserver/image.cpp \ imageserver/imageserver.cpp \ imageserver/imageserver_c.cpp \ inputserver/inputdevice.cpp \ inputserver/inputdevice_c.cpp \ inputserver/inputserver.cpp \ inputserver/inputserver_c.cpp \ inputserver/inputsystem.cpp \ inputserver/inputsystem_c.cpp \ inputserver/scancodemap.cpp \ inputserver/inputcontrol.cpp \ inputserver/inputcontrol_c.cpp \ inputserver/inputitem.cpp \ inputserver/inputitem_c.cpp \ kerosin.cpp \ materialserver/material.cpp \ materialserver/material_c.cpp \ materialserver/material2dtexture.cpp \ materialserver/material2dtexture_c.cpp \ materialserver/materialsolid.cpp \ materialserver/materialsolid_c.cpp \ materialserver/materialserver.cpp \ materialserver/materialserver_c.cpp \ sceneserver/axis.cpp \ sceneserver/axis_c.cpp \ sceneserver/helper/NVMeshMender.cpp \ sceneserver/helper/nv_algebra.cpp \ sceneserver/light.cpp \ sceneserver/light_c.cpp \ sceneserver/singlematnode.cpp \ sceneserver/singlematnode_c.cpp \ sceneserver/box.cpp \ sceneserver/box_c.cpp \ sceneserver/sphere.cpp \ sceneserver/sphere_c.cpp \ sceneserver/ccylinder.cpp \ sceneserver/ccylinder_c.cpp \ sceneserver/staticmesh.cpp \ sceneserver/staticmesh_c.cpp \ soundserver/soundserver.cpp \ soundserver/soundserver_c.cpp \ textureserver/texture.cpp \ textureserver/texture2d.cpp \ textureserver/textureserver.cpp \ textureserver/textureserver_c.cpp \ openglserver/openglserver.cpp \ openglserver/openglserver_c.cpp \ openglserver/openglsystem_c.cpp \ renderserver/renderserver.cpp \ renderserver/renderserver_c.cpp \ renderserver/rendernode.cpp \ renderserver/rendernode_c.cpp \ renderserver/rendercontrol.cpp \ renderserver/rendercontrol_c.cpp \ renderserver/customrender.cpp \ renderserver/customrender_c.cpp nobase_libpkginclude_HEADERS = \ fontserver/font.h \ fontserver/fontserver.h \ fontserver/glyph.h \ imageserver/image.h \ imageserver/imageserver.h \ inputserver/inputdevice.h \ inputserver/inputserver.h \ inputserver/inputsystem.h \ inputserver/scancodemap.h \ inputserver/inputcontrol.h \ inputserver/inputitem.h \ kerosin.h \ materialserver/material.h \ materialserver/materialserver.h \ sceneserver/axis.h \ sceneserver/helper/NVMeshMender.h \ sceneserver/helper/nv_math/nv_algebra.h \ sceneserver/helper/nv_math/nv_math.h \ sceneserver/helper/nv_math/nv_mathdecl.h \ materialserver/material2dtexture.h \ materialserver/materialsolid.h \ sceneserver/singlematnode.h \ sceneserver/light.h \ sceneserver/sphere.h \ sceneserver/box.h \ sceneserver/ccylinder.h \ sceneserver/staticmesh.h \ soundserver/soundeffect.h \ soundserver/soundmodule.h \ soundserver/soundobject.h \ soundserver/soundserver.h \ soundserver/soundstream.h \ soundserver/soundsystem.h \ textureserver/texture.h \ textureserver/texture2d.h \ textureserver/textureserver.h \ openglserver/openglserver.h \ renderserver/renderserver.h \ renderserver/rendernode.h \ renderserver/rendercontrol.h \ renderserver/customrender.h --- NEW FILE: kerosin.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: kerosin.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Kerosin HISTORY: 11.07.2002 MK - initial version */ #ifndef KEROSIN_KEROSIN_H #define KEROSIN_KEROSIN_H #include "soundserver/soundserver.h" #include "inputserver/inputserver.h" #include "inputserver/inputsystem.h" #include "inputserver/inputdevice.h" #include "inputserver/inputcontrol.h" #include "inputserver/inputitem.h" #include "imageserver/imageserver.h" #include "fontserver/fontserver.h" #include "fontserver/font.h" #include "openglserver/openglserver.h" #include "openglserver/openglsystem.h" #include "renderserver/renderserver.h" #include "renderserver/rendercontrol.h" #include "renderserver/rendernode.h" #include "textureserver/textureserver.h" #include "textureserver/texture.h" #include "materialserver/materialserver.h" #include "materialserver/material.h" #include "materialserver/material2dtexture.h" #include "materialserver/materialsolid.h" // scene graph #include "sceneserver/singlematnode.h" #include "sceneserver/box.h" #include "sceneserver/axis.h" #include "sceneserver/light.h" #include "sceneserver/sphere.h" #include "sceneserver/ccylinder.h" #include "sceneserver/staticmesh.h" // control aspect #include <zeitgeist/zeitgeist.h> namespace kerosin { /** This is the main class, which initializes the Kerosin framework. It * registers all internal classes and automatically runs the default init * script 'sys/script/default.rb' if it exists. */ class Kerosin { // // types // public: protected: private: // // functions // public: /** initializes the kerosin framework \param zg is a reference to an already initialized zeitgeist framwork in which the internal kerosin libraries get installed */ Kerosin(zeitgeist::Zeitgeist &zg); virtual ~Kerosin() {}; protected: private: Kerosin(const Kerosin& obj); Kerosin& operator=(const Kerosin& obj); // // members // public: protected: private: }; } //namespace kerosin #endif //KEROSIN_KEROSIN_H --- NEW FILE: kerosin.cpp --- /* -*- mode: c++; c-basic-indent: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: kerosin.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "kerosin.h" #include <zeitgeist/scriptserver/scriptserver.h> using namespace kerosin; using namespace zeitgeist; Kerosin::Kerosin(zeitgeist::Zeitgeist &zg) { zg.GetCore()->RegisterClassObject(new CLASS(SoundServer), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(InputServer), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(InputSystem), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(InputItem), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(InputDevice), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(InputControl), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(ImageServer), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(FontServer), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(OpenGLServer), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(OpenGLSystem), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(RenderServer), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(RenderControl), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(RenderNode), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(TextureServer), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(MaterialServer), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(Material), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(Material2DTexture), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(MaterialSolid), "kerosin/"); // scene graph zg.GetCore()->RegisterClassObject(new CLASS(SingleMatNode), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(Axis), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(Light), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(StaticMesh), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(Box), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(CCylinder), "kerosin/"); zg.GetCore()->RegisterClassObject(new CLASS(Sphere), "kerosin/"); // load default setting zg.GetCore()->GetRoot()->GetScript()->RunInitScript ( "kerosin.rb", "lib/kerosin" ); } |
From: Markus R. <rol...@us...> - 2005-12-05 21:38:32
|
Update of /cvsroot/simspark/simspark/spark/kerosin/sceneserver/helper In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/sceneserver/helper Added Files: .cvsignore NVMeshMender.cpp NVMeshMender.h nv_algebra.cpp Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs --- NEW FILE: nv_algebra.cpp --- /*********************************************************************NVMH1**** File: nv_algebra.cpp Copyright (C) 1999, 2000 NVIDIA Corporation This file is provided without support, instruction, or implied warranty of any kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is not liable under any circumstances for any damages or loss whatsoever arising from the use or inability to use this file or items derived from it. Comments: ******************************************************************************/ #ifndef _nv_algebra_h_ #include <nv_math/nv_math.h> #endif #ifndef _WIN32 [...1430 lines suppressed...] res -= nv_scalar(1.3888397e-03); res *= x_sqr; res += nv_scalar(4.16666418e-02); res *= x_sqr; res -= nv_scalar(4.999999963e-01); res *= x_sqr; res += nv_one; return res; } void nv_is_valid(const vec3& v) { assert(!_isnan(v.x) && !_isnan(v.y) && !_isnan(v.z) && _finite(v.x) && _finite(v.y) && _finite(v.z)); } void nv_is_valid(nv_scalar lambda) { assert(!_isnan(lambda) && _finite(lambda)); } --- NEW FILE: NVMeshMender.h --- #ifndef _NVMeshMender_H_ #define _NVMeshMender_H_ /*********************************************************************NVMH2**** Copyright (C) 1999, 2000, 2001, 2002 NVIDIA Corporation This file is provided without support, instruction, or implied warranty of any kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is not liable under any circumstances for any damages or loss whatsoever arising from the use or inability to use this file or items derived from it. Questions to sim...@nv... Comments: This tool is designed to help condition meshes for use in vertex & pixel shaders. It can generate normals, texture coordinates, and perhaps most importantly, texture space basis matrices. It also can fix common texuring problems that come up when bump mapping, including Texture Mirroring - When two one halves of a character use the same part of a texture. Cylindrical TexGen - When the rendering relies on cylindrical wrapping, texture space computation won't work right. Stretched Basis - When two adjacend faces use wildly different texture mappings, causing stretching that can ruin per-pixel lighting. Here is an example usage scenario : Say you have positions & indices & normals, and want textures, and tangents, and binormals. and assume that positions, indices, and normals are in STL arrays: vpos, triIndices and vnor respectively. std::vector<float> vpos; std::vector<int> triIndices; std::vector<float> vnor; ... NVMeshMender aMender; std::vector<NVMeshMender::VertexAttribute> inputAtts; // What you have std::vector<NVMeshMender::VertexAttribute> outputAtts; // What you want. NVMeshMender::VertexAttribute posAtt; posAtt.Name_ = "position"; posAtt.floatVector_ = vpos; NVMeshMender::VertexAttribute triIndAtt; triIndAtt.Name_ = "indices"; triIndAtt.intVector_ = triIndices; NVMeshMender::VertexAttribute norAtt; norAtt.Name_ = "normal"; norAtt.floatVector_ = vnor; std::vector<float> texCoords; NVMeshMender::VertexAttribute texCoordAtt; texCoordAtt.Name_ = "tex0"; texCoordAtt.floatVector_;// = texCoords; NVMeshMender::VertexAttribute tgtSpaceAtt; tgtSpaceAtt.Name_ = "tangent"; NVMeshMender::VertexAttribute binormalAtt; binormalAtt.Name_ = "binormal"; inputAtts.push_back(posAtt); inputAtts.push_back(triIndAtt); inputAtts.push_back(norAtt); outputAtts.push_back(posAtt); outputAtts.push_back(triIndAtt); outputAtts.push_back(norAtt); outputAtts.push_back(texCoordAtt); outputAtts.push_back(tgtSpaceAtt); outputAtts.push_back(binormalAtt); // All inputs except for indices are assumed to be sets of 3 floats // "indices" are assumed to be unsigned ints // "tex0" is used for the tangent space calculation // "tex0" is the only coordinate set generated, and the texture matrix applies only to it // All unknown attribute types, including "tex1", "tex2", "random_attribute", "weights", "bones", etc. // are simply passed through. They will be duplicated as needed just like positions, normals, etc. bool bSuccess = aMender.Munge( inputAtts, // these are my positions & indices outputAtts, // these are the outputs I requested, plus extra stuff generated on my behalf 3.141592654f / 2.5f, // tangent space smooth angle NULL, // no Texture matrix applied to my tex0 coords FixTangents, // fix degenerate bases & texture mirroring FixCylindricalTexGen // handle cylidrically mapped textures via vertex duplication WeightNormalsByFaceSize // weight vertex normals by the triangle's size ); if ( !bSuccess ) return false; vpos = outputAtts[0].floatVector_; // Note that there may be more vertices than you sent in. vnor = outputAtts[2].floatVector_; std::vector<float> texCoords = outputAtts[3].floatVector_; // texcoords std::vector<float> vtgt = outputAtts[4].floatVector_; // tgts triIndices = outputAtts[1].intVector_; // new indices. std::vector<float> vbin = outputAtts[5].floatVector_; // binormals. // Now the outputAtts may contain more vertex then you sent in ! // This is because in handling tangent space smoothing, and solving texture mirroring & // cylindrical texture wrapping problems, we partially duplicate vertices. // All attributes are duplicated, even unknowns. // You may also get things you didn't ask for. For instance, if you ask for tangent space, // in other words, you ask for "tangent" or "binormal", you will get "normal", "tex0", // "tangent" and "binormal". You can then ignore things in the output vector that you don't want. // If you ask for FixCylindricalTexGen, it will fix any absolute change in texture coordinates > 0.5 // across a single edge. Therefore, if you pass in a single quad or cube, it won't work. Any more // complicated or tessellated mesh should work fine. ******************************************************************************/ #include <vector> #include <string> class NVMeshMender { private : mutable std::vector< std::string > LastErrors_; struct Edge { unsigned int v0; unsigned int v1; unsigned int face; unsigned int face2; bool operator==( const Edge& rhs ) const { return ( ( v0 == rhs.v0 ) && ( v1 == rhs.v1 ) ); } bool operator<( const Edge& rhs ) const { if ( v0 < rhs.v0 ) { return true; } if ( v0 > rhs.v0 ) { return false; } return ( v1 < rhs.v1 ); } }; public : void SetLastError( const std::string& rhs ) const { LastErrors_.push_back( rhs ); } std::string GetLastError() const { std::string aString; if ( LastErrors_.size() > 0 ) { aString = LastErrors_.back(); } return aString; } struct VertexAttribute { std::string Name_; typedef std::vector< int > IntVector; IntVector intVector_; typedef std::vector< float > FloatVector; FloatVector floatVector_; VertexAttribute& operator=( const VertexAttribute& rhs ) { Name_ = rhs.Name_; intVector_ = rhs.intVector_; floatVector_ = rhs.floatVector_; return *this; } VertexAttribute( const char* pName = "" ) : Name_(pName) {;} VertexAttribute( const VertexAttribute& rhs ) { *this = rhs; } bool operator==( const VertexAttribute& rhs ) { return ( Name_ == rhs.Name_ ); } bool operator<( const VertexAttribute& rhs ) { return ( Name_ < rhs.Name_ ); } }; typedef std::vector< VertexAttribute > VAVector; enum Option { FixTangents, DontFixTangents, FixCylindricalTexGen, DontFixCylindricalTexGen, WeightNormalsByFaceSize, DontWeightNormalsByFaceSize }; bool NVMeshMender::Munge( const NVMeshMender::VAVector& input, NVMeshMender::VAVector& output, const float bSmoothCreaseAngleRadians = 3.141592654f / 3.0f, const float* pTextureMatrix = 0, const Option _FixTangents = FixTangents, const Option _FixCylindricalTexGen = FixCylindricalTexGen, const Option _WeightNormalsByFaceSize = WeightNormalsByFaceSize ); bool NVMeshMender::MungeD3DX( const NVMeshMender::VAVector& input, NVMeshMender::VAVector& output, const float bSmoothCreaseAngleRadians = 3.141592654f / 3.0f, const float* pTextureMatrix = 0, const Option _FixTangents = FixTangents, const Option _FixCylindricalTexGen = FixCylindricalTexGen, const Option _WeightNormalsByFaceSize = WeightNormalsByFaceSize ); }; #endif //_NVMeshMender_H_ --- NEW FILE: NVMeshMender.cpp --- /*********************************************************************NVMH2**** Copyright (C) 1999, 2000, 2001, 2002 NVIDIA Corporation This file is provided without support, instruction, or implied warranty of any kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is not liable under any circumstances for any damages or loss whatsoever arising from the use or inability to use this file or items derived from it. Questions to sim...@nv... Comments: This tool is designed to help condition meshes for use in vertex & pixel shaders. It can generate normals, texture coordinates, and perhaps most importantly, texture space basis matrices. It also can fix common texuring problems that come up when bump mapping, including Texture Mirroring - When two one halves of a character use the same part of a texture. Cylindrical TexGen - When the rendering relies on cylindrical wrapping, texture space computation won't work right. Stretched Basis - When two adjacend faces use wildly different texture mappings, causing stretching that can ruin per-pixel lighting. Here is an example usage scenario : Say you have positions & indices, and want textures, normals, and tangents. NVMeshMender aMender; MVMeshMender::VAVector inputAtts; // this is what you have MVMeshMender::VAVector outputAtts; // this is what you want MVMeshMender::VertexAttribute att; // this is my working attribute att.Name_ = "position"; for ( int p = 0; p < number_of_vertices; ++p ) { att.floatVector_.push_back( myPositions[ p ].x ); att.floatVector_.push_back( myPositions[ p ].y ); att.floatVector_.push_back( myPositions[ p ].z ); } att.floatVector.clear(); att.Name_ = "indices"; for ( int i = 0; i < number_of_indices; ++i ) { att.intVector_.push_back( myIndices[ i ] ); } // All inputs except for indices are assumed to be sets of 3 floats // "indices" are assumed to be unsigned ints // "tex0" is used for the tangent space calculation // "tex0" is the only coordinate set generated, and the texture matrix applies only to it // All unknown attribute types, including "tex1", "tex2", "random_attribute", "weights", "bones", etc. // are simply passed through. They will be duplicated as needed just like positions, normals, etc. bool bSuccess = aMender.Munge( inputAtts, // these are my positions & indices outputAtts, // these are the outputs I requested, plus extra stuff generated on my behalf 3.141592654f / 2.5f, // tangent space smooth angle NULL, // no Texture matrix applied to my tex0 coords FixTangents, // fix degenerate bases & texture mirroring FixCylindricalTexGen // handle cylidrically mapped textures via vertex duplication WeightNormalsByFaceSize // weight vertex normals by the triangle's size ); if ( !bSuccess ) return false; // Now the outputAtts may contain more vertex then you sent in ! // This is because in handling tangent space smoothing, and solving texture mirroring & // cylindrical texture wrapping problems, we partially duplicate vertices. // All attributes are duplicated, even unknowns. // You may also get things you didn't ask for. For instance, if you ask for tangent space, // in other words, you ask for "tangent" or "binormal", you will get "normal", "tex0", // "tangent" and "binormal". You can then ignore things in the output vector that you don't want. // If you ask for FixCylindricalTexGen, it will fix any absolute change in texture coordinates > 0.5 // across a single edge. Therefore, if you pass in a single quad or cube, it won't work. Any more // complicated or tessellated mesh should work fine. ******************************************************************************/ #ifdef _WIN32 # pragma warning (disable : 4786) #endif #include "NVMeshMender.h" #include "nv_math/nv_math.h" #include <map> #include <set> #include <assert.h> bool NVMeshMender::Munge( const NVMeshMender::VAVector& input, NVMeshMender::VAVector& output, const float bSmoothCreaseAngleRadians, const float* pTextureMatrix, const Option _FixTangents, const Option _FixCylindricalTexGen, const Option _WeightNormalsByFaceSize ) { typedef std::map< std::string, unsigned int > Mapping; typedef std::set< Edge > EdgeSet; typedef std::vector< std::set< unsigned int > > IdenticalVertices; IdenticalVertices IdenticalVertices_; // make room for potential tex coords, normals, binormals and tangents output.resize( input.size() + 4 ); Mapping inmap; Mapping outmap; for ( unsigned int a = 0; a < input.size(); ++a ) { inmap[ input[ a ].Name_ ] = a; } for ( unsigned int b = 0; b < output.size(); ++b ) { output[ b ].intVector_.clear(); output[ b ].floatVector_.clear(); outmap[ output[ b ].Name_ ] = b; } for ( unsigned int c = 0; c < output.size(); ++c ) { // for every output that has a match in the input, just copy it over Mapping::iterator in = inmap.find( output[ c ].Name_ ); if ( in != inmap.end() ) { // copy over existing indices, position, or whatever output[ c ] = input[ (*in).second ]; } } if ( inmap.find( "indices" ) == inmap.end() ) { SetLastError( "Missing indices from input" ); return false; } if ( outmap.find( "indices" ) == outmap.end() ) { SetLastError( "Missing indices from output" ); return false; } // Go through all required outputs & generate as necessary if ( inmap.find( "position" ) == inmap.end() ) { SetLastError( "Missing position from input" ); return false; } if ( outmap.find( "position" ) == outmap.end() ) { SetLastError( "Missing position from output" ); return false; } Mapping::iterator pos = outmap.find( "position" ); VertexAttribute::FloatVector& positions = output[ (*pos).second ].floatVector_; vec3* pPositions = (vec3*)( &( positions[ 0 ] ) ); std::set< unsigned int > EmptySet; for ( unsigned int i = 0; i < positions.size(); i += 3 ) { IdenticalVertices_.push_back( EmptySet ); } // initialize all attributes for ( unsigned int att = 0; att < output.size(); ++att ) { if ( output[ att ].Name_ != "indices" ) { if ( output[ att ].floatVector_.size() == 0 ) { output[ att ].floatVector_ = positions; } } } Mapping::iterator ind = outmap.find( "indices" ); VertexAttribute::IntVector& indices = output[ (*ind).second ].intVector_; int* pIndices = (int*)( &( indices[ 0 ] ) ); vec3* pNormals = 0; //vec3* pBiNormals = 0; //vec3* pTangents = 0; vec3* pTex0 = 0; bool bNeedNormals = false; bool bNeedTexCoords = false; bool bComputeTangentSpace = false; // see if texture coords are needed if ( outmap.find( "tex0" ) != outmap.end() ) { bNeedTexCoords = true; } // see if tangent or binormal are needed if ( ( outmap.find( "binormal" ) != outmap.end() ) || ( outmap.find( "tangent" ) != outmap.end() ) ) { bComputeTangentSpace = true; } // see if normals are needed if ( outmap.find( "normal" ) != outmap.end() ) { bNeedNormals = true; } // Compute normals. Mapping::iterator want = outmap.find( "normal" ); bool have_normals = ( inmap.find( "normal" ) != inmap.end() ) ? true : false; if ( bNeedNormals || bComputeTangentSpace ) { // see if normals are provided if ( !have_normals ) { // create normals if ( want == outmap.end() ) { VertexAttribute norAtt; norAtt.Name_ = "normal"; output.push_back( norAtt ); outmap[ "normal" ] = output.size() - 1; want = outmap.find( "normal" ); } // just initialize array so it's the correct size output[ (*want).second ].floatVector_ = positions; //VertexAttribute::FloatVector& normals = output[ (*want).second ].floatVector_; // zero out normals for ( unsigned n = 0; n < positions.size(); ++n ) { output[ (*want).second ].floatVector_[ n ] = nv_zero; } pNormals = (vec3*)( &( output[ (*want).second ].floatVector_[0] ) ); // calculate face normals for each face // & add its normal to vertex normal total for ( unsigned int t = 0; t < indices.size(); t += 3 ) { vec3 edge0; vec3 edge1; edge0 = pPositions[ indices[ t + 1 ] ] - pPositions[ indices[ t + 0 ] ]; edge1 = pPositions[ indices[ t + 2 ] ] - pPositions[ indices[ t + 0 ] ]; edge0.normalize(); edge1.normalize(); vec3 faceNormal = edge0 ^ edge1; if ( _WeightNormalsByFaceSize == DontWeightNormalsByFaceSize ) { // Renormalize face normal, so it's not weighted by face size faceNormal.normalize(); } else { // Leave it as-is, to weight by face size naturally by the cross product result } pNormals[ indices[ t + 0 ] ] += faceNormal; pNormals[ indices[ t + 1 ] ] += faceNormal; pNormals[ indices[ t + 2 ] ] += faceNormal; } // Renormalize each vertex normal for ( unsigned int v = 0; v < output[ (*want).second ].floatVector_.size() / 3; ++v ) pNormals[v].normalize(); } } // Compute texture coordinates. if ( bNeedTexCoords || bComputeTangentSpace ) { if ( outmap.find("tex0") == outmap.end() ) { VertexAttribute texCoordAtt; texCoordAtt.Name_ = "tex0"; output.push_back( texCoordAtt ); outmap[ "tex0" ] = output.size() - 1; } want = outmap.find("tex0"); Mapping::iterator have = inmap.find( "tex0" ); bool have_texcoords = (have != inmap.end()); // see if texcoords are provided if ( have_texcoords ) output[ (*want).second ].floatVector_ = input[ (*have).second ].floatVector_; else { // just initialize array so it's the correct size output[ (*want).second ].floatVector_ = positions; pTex0 = (vec3*)( &(output[ (*want).second ].floatVector_[ 0 ]) ); // Generate cylindrical coordinates // Find min and max positions for object bounding box vec3 maxPosition( -FLT_MAX, -FLT_MAX, -FLT_MAX ); vec3 minPosition( FLT_MAX, FLT_MAX, FLT_MAX ); // there are 1/3 as many vectors as floats const unsigned int theCount = static_cast<unsigned int>(positions.size() / 3.0f); for ( unsigned int i = 0; i < theCount; ++i ) { maxPosition.x = nv_max( maxPosition.x, pPositions[ i ].x ); maxPosition.y = nv_max( maxPosition.y, pPositions[ i ].y ); maxPosition.z = nv_max( maxPosition.z, pPositions[ i ].z ); minPosition.x = nv_min( minPosition.x, pPositions[ i ].x ); minPosition.y = nv_min( minPosition.y, pPositions[ i ].y ); minPosition.z = nv_min( minPosition.z, pPositions[ i ].z ); } // Find major, minor and other axis for cylindrical texgen vec3 delta = maxPosition - minPosition; delta.x = (float)fabs( delta.x ); delta.y = (float)fabs( delta.y ); delta.z = (float)fabs( delta.z ); bool maxx,maxy,maxz; maxx = maxy = maxz = false; bool minz,miny,minx; minx = miny = minz = false; float deltaMajor = 0.0; if ( ( delta.x >= delta.y ) && ( delta.x >= delta.z ) ) { maxx = true; deltaMajor = delta.x; if ( delta.y > delta.z ) { minz = true; } else { miny = true; } } else if ( ( delta.z >= delta.y ) && ( delta.z >= delta.x ) ) { maxz = true; deltaMajor = delta.z; if ( delta.y > delta.x ) { minx = true; } else { miny = true; } } else if ( ( delta.y >= delta.z ) && ( delta.y >= delta.x ) ) { maxy = true; deltaMajor = delta.y; if ( delta.x > delta.z ) { minz = true; } else { minx = true; } } for ( unsigned int p = 0; p < theCount; ++p ) { // Find position relative to center of bounding box vec3 texCoords = ( ( maxPosition + minPosition ) / 2.0f ) - pPositions[ p ]; float Major = 0.0, Minor = 0.0, Other = nv_zero; if ( maxx ) { Major = texCoords.x; if ( miny ) { Minor = texCoords.y; Other = texCoords.z; } else { Minor = texCoords.z; Other = texCoords.y; } } else if ( maxy ) { Major = texCoords.y; if ( minx ) { Minor = texCoords.x; Other = texCoords.z; } else { Minor = texCoords.z; Other = texCoords.x; } } else if ( maxz ) { Major = texCoords.z; if ( miny ) { Minor = texCoords.y; Other = texCoords.x; } else { Minor = texCoords.x; Other = texCoords.y; } } float longitude = nv_zero; // Prevent zero or near-zero from being passed into atan2 if ( fabs( Other ) < 0.0001f ) { if ( Other >= nv_zero ) { Other = 0.0001f; } else { Other = -0.0001f; } } // perform cylindrical mapping onto object, and remap from -pi,pi to -1,1 longitude = (float)(( atan2( Minor, Other ) ) / 3.141592654); texCoords.x = 0.5f * longitude + 0.5f; texCoords.y = (Major/deltaMajor) + 0.5f; texCoords.x = nv_max( texCoords.x, nv_zero ); texCoords.y = nv_max( texCoords.y, nv_zero ); texCoords.x = nv_min( texCoords.x, 1.0f ); texCoords.y = nv_min( texCoords.y, 1.0f ); pTex0[ p ].x = texCoords.x-0.25f; if ( pTex0[ p ].x < nv_zero ) pTex0[ p ].x += 1.0; pTex0[ p ].y = 1.0f-texCoords.y; pTex0[ p ].z = 1.0f; } } if ( _FixCylindricalTexGen == FixCylindricalTexGen ) { Mapping::iterator texIter = outmap.find( "tex0" ); VertexAttribute::FloatVector& texcoords = ( output[ (*texIter).second ].floatVector_ ); const unsigned int theSize = indices.size(); for ( unsigned int f = 0; f < theSize; f += 3 ) { for ( int v = 0; v < 3; ++v ) { int start = f + v; int end = start + 1; if ( v == 2 ) { end = f; } float dS = texcoords[ indices[ end ] * 3 + 0 ] - texcoords[ indices[ start ] * 3 + 0 ]; float newS = nv_zero; bool bDoS = false; unsigned int theOneToChange = start; if ( fabs( dS ) >= 0.5f ) { bDoS = true; if ( texcoords[ indices[ start ] * 3 + 0 ] < texcoords[ indices[ end ] * 3 + 0 ] ) { newS = texcoords[ indices[ start ]* 3 + 0 ] + 1.0f; } else { theOneToChange = end; newS = texcoords[ indices[ end ] * 3 + 0 ] + 1.0f; } } if ( bDoS == true ) { unsigned int theNewIndex = texcoords.size() / 3; // Duplicate every part of the vertex for ( unsigned int att = 0; att < output.size(); ++att ) { // No new indices are created, just vertex attributes if ( output[ att ].Name_ != "indices" ) { if ( output[ att ].Name_ == "tex0" ) { output[ att ].floatVector_.push_back( newS ); // y output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 1 ] ); // x output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 2 ] ); // z } else { // *3 b/c we are looking up 3vectors in an array of floats output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 0 ] ); // x output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 1 ] ); // y output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 2 ] ); // z } } } IdenticalVertices_.push_back( EmptySet ); IdenticalVertices_[ indices[ theOneToChange ] ].insert( theNewIndex ); IdenticalVertices_[ theNewIndex ].insert( indices[ theOneToChange ] ); // point to where the new vertices will go indices[ theOneToChange ] = theNewIndex; } } // for v { for ( int v = 0; v < 3; ++v ) { int start = f + v; int end = start + 1; if ( v == 2 ) { end = f; } float dT = texcoords[ indices[ end ] * 3 + 1 ] - texcoords[ indices[ start ] * 3 + 1 ]; float newT = nv_zero; bool bDoT = false; unsigned int theOneToChange = start; if ( fabs( dT ) >= 0.5f ) { bDoT = true; if ( texcoords[ indices[ start ] * 3 + 1 ] < texcoords[ indices[ end ] * 3 + 1 ] ) { newT = texcoords[ indices[ start ] * 3 + 1 ] + 1.0f; } else { theOneToChange = end; newT = texcoords[ indices[ end ] * 3 + 1 ] + 1.0f; } } if ( bDoT == true ) { unsigned int theNewIndex = texcoords.size() / 3; // Duplicate every part of the vertex for ( unsigned int att = 0; att < output.size(); ++att ) { // No new indices are created, just vertex attributes if ( output[ att ].Name_ != "indices" ) { if ( output[ att ].Name_ == "tex0" ) { output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 0 ] ); // x output[ att ].floatVector_.push_back( newT ); // y output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 2 ] ); // z } else { // *3 b/c we are looking up 3vectors in an array of floats output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 0 ] ); // x output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 1 ] ); // y output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 2 ] ); // z } } } IdenticalVertices_.push_back( EmptySet ); IdenticalVertices_[ theNewIndex ].insert( indices[ theOneToChange ] ); IdenticalVertices_[ indices[ theOneToChange ] ].insert( theNewIndex ); // point to where the new vertices will go indices[ theOneToChange ] = theNewIndex; } } } // for v } // for f } // if fix texgen if (pTextureMatrix) { const mat4 M( pTextureMatrix[0], pTextureMatrix[1], pTextureMatrix[2], pTextureMatrix[3], pTextureMatrix[4], pTextureMatrix[5], pTextureMatrix[6], pTextureMatrix[7], pTextureMatrix[8], pTextureMatrix[9], pTextureMatrix[10], pTextureMatrix[11], pTextureMatrix[12], pTextureMatrix[13], pTextureMatrix[14], pTextureMatrix[15]); Mapping::iterator texIter = outmap.find("tex0"); VertexAttribute::FloatVector& texcoords = output[(*texIter).second].floatVector_; // now apply matrix for (unsigned int v = 0; v < texcoords.size(); v += 3) { vec3& V = *reinterpret_cast<vec3*>(&texcoords[v]); V = V * M; } } } if ( bComputeTangentSpace ) { Mapping::iterator texIter = outmap.find( "tex0" ); vec3* tex = (vec3*)&( output[ (*texIter).second ].floatVector_[ 0 ] ); typedef std::vector< vec3 > VecVector; // create tangents want = outmap.find( "tangent" ); if ( want == outmap.end() ) { VertexAttribute tanAtt; tanAtt.Name_ = "tangent"; output.push_back( tanAtt ); outmap[ "tangent" ] = output.size() - 1; want = outmap.find( "tangent" ); } // just initialize array so it's the correct size output[ (*want).second ].floatVector_ = positions; // create binormals want = outmap.find( "binormal" ); if ( want == outmap.end() ) { VertexAttribute binAtt; binAtt.Name_ = "binormal"; output.push_back( binAtt ); outmap[ "binormal" ] = output.size() - 1; want = outmap.find( "binormal" ); } // just initialize array so it's the correct size output[ (*want).second ].floatVector_ = positions; // Create a vector of s,t and sxt for each face of the model VecVector sVector; VecVector tVector; VecVector sxtVector; const unsigned int theSize = indices.size(); // for each face, calculate its S,T & SxT vector, & store its edges for ( unsigned int f = 0; f < theSize; f += 3 ) { vec3 edge0; vec3 edge1; vec3 s; vec3 t; // grap position & tex coords again in case they were reallocated pPositions = (vec3*)( &( positions[ 0 ] ) ); tex = (vec3*)&( output[ (*texIter).second ].floatVector_[ 0 ] ); // create an edge out of x, s and t edge0.x = pPositions[ indices[ f + 1 ] ].x - pPositions[ indices[ f ] ].x; edge0.y = tex[ indices[ f + 1 ] ].x - tex[ indices[ f ] ].x; edge0.z = tex[ indices[ f + 1 ] ].y - tex[ indices[ f ] ].y; // create an edge out of x, s and t edge1.x = pPositions[ indices[ f + 2 ] ].x - pPositions[ indices[ f ] ].x; edge1.y = tex[ indices[ f + 2 ] ].x - tex[ indices[ f ] ].x; edge1.z = tex[ indices[ f + 2 ] ].y - tex[ indices[ f ] ].y; vec3 sxt = edge0 ^ edge1; float a = sxt.x; float b = sxt.y; float c = sxt.z; float ds_dx = nv_zero; if ( fabs( a ) > nv_eps ) { ds_dx = - b / a; } float dt_dx = nv_zero; if ( fabs( a ) > nv_eps ) { dt_dx = - c / a; } // create an edge out of y, s and t edge0.x = pPositions[ indices[ f + 1 ] ].y - pPositions[ indices[ f ] ].y; // create an edge out of y, s and t edge1.x = pPositions[ indices[ f + 2 ] ].y - pPositions[ indices[ f ] ].y; sxt = edge0 ^ edge1; a = sxt.x; b = sxt.y; c = sxt.z; float ds_dy = nv_zero; if ( fabs( a ) > nv_eps ) { ds_dy = -b / a; } float dt_dy = nv_zero; if ( fabs( a ) > nv_eps ) { dt_dy = -c / a; } // create an edge out of z, s and t edge0.x = pPositions[ indices[ f + 1 ] ].z - pPositions[ indices[ f ] ].z; // create an edge out of z, s and t edge1.x = pPositions[ indices[ f + 2 ] ].z - pPositions[ indices[ f ] ].z; sxt = edge0 ^ edge1; a = sxt.x; b = sxt.y; c = sxt.z; float ds_dz = nv_zero; if ( fabs( a ) > nv_eps ) { ds_dz = -b / a; } float dt_dz = nv_zero; if ( fabs( a ) > nv_eps ) { dt_dz = -c / a; } // generate coordinate frame from the gradients s = vec3( ds_dx, ds_dy, ds_dz ); t = vec3( dt_dx, dt_dy, dt_dz ); s.normalize(); t.normalize(); sxt = s ^ t; sxt.normalize(); // save vectors for this face sVector.push_back( s ); tVector.push_back( t ); sxtVector.push_back( sxt ); if ( _FixTangents == FixTangents ) { // Look for each edge of the triangle in the edge map, in order to find // a neighboring face along the edge for ( int e = 0; e < 3; ++e ) { Edge edge; int start = f + e; int end = start + 1; if ( e == 2 ) { end = f; } // order vertex indices ( low, high ) edge.v0 = (unsigned int)nv_min( (nv_scalar)indices[ start ], (nv_scalar)indices[ end ] ); edge.v1 = (unsigned int)nv_max( (nv_scalar)indices[ start ], (nv_scalar)indices[ end ] ); EdgeSet Edges; EdgeSet::iterator iter = Edges.find( edge ); // if we are the only triangle with this edge... if ( iter == Edges.end() ) { // ...then add us to the set of edges edge.face = f / 3; Edges.insert( edge ); } else { // otherwise, check our neighbor's s,t & sxt vectors vs our own const float sAgreement = dot(s, sVector[(*iter).face]); const float tAgreement = dot(t, tVector[(*iter).face]); const float sxtAgreement = dot(sxt, sxtVector[(*iter).face]); // Check Radian angle split limit const float epsilon = (float)cos( bSmoothCreaseAngleRadians ); // if the discontinuity in s, t, or sxt is greater than some epsilon, // duplicate the vertex so it won't smooth with its neighbor anymore if ( ( fabs( sAgreement ) < epsilon ) || ( fabs( tAgreement ) < epsilon ) || ( fabs( sxtAgreement ) < epsilon ) ) { // Duplicate two vertices of this edge for this triangle only. // This way the faces won't smooth with each other, thus // preventing the tangent basis from becoming degenerate // divide by 3 b/c vector is of floats and not vectors const unsigned int theNewIndex = positions.size() / 3; // Duplicate every part of the vertex for ( unsigned int att = 0; att < output.size(); ++att ) { // No new indices are created, just vertex attributes if ( output[ att ].Name_ != "indices" ) { // *3 b/c we are looking up 3vectors in an array of floats output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ start ] * 3 + 0 ] ); // x output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ start ] * 3 + 1 ] ); // y output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ start ] * 3 + 2 ] ); // z output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ end ] * 3 + 0 ] ); // x output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ end ] * 3 + 1 ] ); // y output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ end ] * 3 + 2 ] ); // z } } IdenticalVertices_.push_back( EmptySet ); IdenticalVertices_.push_back( EmptySet ); // point to where the new vertices will go indices[ start ] = theNewIndex; indices[ end ] = theNewIndex + 1; } // Now that the vertices are duplicated, smoothing won't occur over this edge, // because the two faces will sum their tangent basis vectors into separate indices } } } // if fixtangents } // Allocate std::vector & Zero out average basis for tangent space smoothing VecVector avgS; VecVector avgT; for ( unsigned int p = 0; p < positions.size(); p += 3 ) { avgS.push_back( vec3_null ); // do S avgT.push_back( vec3_null ); // now t } // go through faces and add up the bases for each vertex const int theFaceCount = indices.size() / 3; for ( unsigned int face = 0; face < (unsigned int)theFaceCount; ++face ) { // sum bases, so we smooth the tangent space across edges avgS[ pIndices[ face * 3 ] ] += sVector[ face ]; avgT[ pIndices[ face * 3 ] ] += tVector[ face ]; avgS[ pIndices[ face * 3 + 1 ] ] += sVector[ face ]; avgT[ pIndices[ face * 3 + 1 ] ] += tVector[ face ]; avgS[ pIndices[ face * 3 + 2 ] ] += sVector[ face ]; avgT[ pIndices[ face * 3 + 2 ] ] += tVector[ face ]; } if ( _FixCylindricalTexGen == FixCylindricalTexGen ) { for ( unsigned int v = 0; v < IdenticalVertices_.size(); ++v ) { // go through each vertex & sum up it's true neighbors for ( std::set< unsigned int >::iterator iter = IdenticalVertices_[ v ].begin(); iter != IdenticalVertices_[ v ].end(); ++iter ) { avgS[ v ] += avgS[ *iter ]; avgT[ v ] += avgT[ *iter ]; } } } Mapping::iterator tangent = outmap.find( "tangent" ); Mapping::iterator binormal = outmap.find( "binormal" ); // now renormalize for ( unsigned int b = 0; b < positions.size(); b += 3 ) { *reinterpret_cast<vec3*>(&output[(*tangent).second].floatVector_[b]) = normalize(avgS[b / 3]); // s *reinterpret_cast<vec3*>(&output[(*binormal).second].floatVector_[b]) = normalize(avgT[b / 3]); // T } } // At this point, tex coords, normals, binormals and tangents should be generated if necessary, // and other attributes are simply copied as available return true; } |
From: Markus R. <rol...@us...> - 2005-12-05 21:38:32
|
Update of /cvsroot/simspark/simspark/spark/kerosin/soundserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/soundserver Added Files: .cvsignore soundeffect.h soundmodule.h soundobject.h soundserver.cpp soundserver.h soundserver_c.cpp soundstream.h soundsystem.h Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs --- NEW FILE: soundserver_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: soundserver_c.cpp,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "soundserver.h" #include "soundeffect.h" #include "soundmodule.h" #include "soundstream.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; using namespace std; FUNCTION(SoundServer,init) { string inSndSysName; return( (in.GetSize() == 1) && (in.GetValue(in.begin(), inSndSysName)) && (obj->Init(inSndSysName)) ); } FUNCTION(SoundServer,getCPU) { return obj->GetCPU(); } FUNCTION(SoundServer,playStream) { string inName; if ( (in.GetSize() != 1) || (! in.GetValue(in.begin(), inName)) ) { return false; } shared_ptr<SoundStream> stream = obj->LoadStream(inName); if (stream.get() == 0) { return false; } stream->Play(); return true; } FUNCTION(SoundServer,playModule) { string inName; if ( (in.GetSize() != 1) || (! in.GetValue(in.begin(), inName)) ) { return false; } shared_ptr<SoundModule> module = obj->LoadModule(inName); if (module.get() == 0) { return false; } module->Play(); return true; } FUNCTION(SoundServer,playEffect) { string inName; if ( (in.GetSize() != 1) || (! in.GetValue(in.begin(), inName)) ) { return false; } shared_ptr<SoundEffect> effect = obj->LoadEffect(inName); if (effect.get() == 0) { return false; } effect->Play(); return true; } void CLASS(SoundServer)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Leaf); DEFINE_FUNCTION(init); DEFINE_FUNCTION(getCPU); DEFINE_FUNCTION(playStream); DEFINE_FUNCTION(playModule); DEFINE_FUNCTION(playEffect); } --- NEW FILE: soundsystem.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: soundsystem.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_SOUNDSYSTEM_H #define KEROSIN_SOUNDSYSTEM_H #include <zeitgeist/leaf.h> namespace kerosin { class SoundEffect; class SoundStream; class SoundModule; class SoundServer; /* SoundSystem Here we define the interface which an actual SoundSystem will need to implement. Actual SoundSystems would be derived from this interface as ClassServer plugins. You would (in general) associate a SoundSystem with a SoundLibrary, such as FMOD or BASS. NOTE: HISTORY: 18.09.01 - MK - Initial version TODO: - much more functionality (volume control, 3D sounds) TOFIX: */ class SoundSystem : public zeitgeist::Leaf { public: SoundSystem() : zeitgeist::Leaf() {} virtual ~SoundSystem() {} virtual bool Init(int inFreq) = 0; virtual void Shutdown() = 0; virtual float GetCPU() = 0; virtual SoundEffect* CreateEffect(SoundServer &soundServer) = 0; virtual SoundStream* CreateStream(SoundServer &soundServer) = 0; virtual SoundModule* CreateModule(SoundServer &soundServer) = 0; }; } //namespace kerosin #endif //KEROSIN_SOUNDSYSTEM_H --- NEW FILE: soundstream.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: soundstream.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_SOUNDSTREAM_H #define KEROSIN_SOUNDSTREAM_H #include "soundobject.h" namespace kerosin { class SoundStream : public SoundObject { public: SoundStream(SoundServer &inServer) : SoundObject(inServer) {} virtual ~SoundStream() {} virtual void Load(const std::string& inName) = 0; virtual void Load(void *inBuffer, int inSize) = 0; virtual void Play() = 0; }; } //namespace kerosin #endif //KEROSIN_SOUNDSTREAM_H --- NEW FILE: soundmodule.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: soundmodule.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_SOUNDMODULE_H #define KEROSIN_SOUNDMODULE_H #include "soundobject.h" namespace kerosin { class SoundModule : public SoundObject { public: SoundModule(SoundServer &inServer) : SoundObject(inServer) {} virtual ~SoundModule() {} virtual void Load(const std::string& inName) = 0; virtual void Load(void *inBuffer, int inSize) = 0; virtual void Play() = 0; }; } //namespace kerosin #endif //KEROSIN_SOUNDMODULE_H --- NEW FILE: soundserver.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: soundserver.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_SOUNDSERVER_H #define KEROSIN_SOUNDSERVER_H /* $Id: soundserver.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ SoundServer The SoundServer is the engine object which lets the application satisfy its audio needs. The SoundServer is an access layer to a specific SoundSystem. Another purpose of the SoundServer is managing a cache of SoundObjects. Actually, we use three distinctive caches, one for effects, one for modules and one for streams. NOTE: HISTORY: 18.09.01 - MK - Initial version 20.09.01 - MK - Added caching 11.10.01 - MK - Made singleton functionality more secure TODO: - expose more functionality TOFIX: */ #include <list> #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> namespace kerosin { // forward declarations class SoundSystem; class SoundObject; class SoundEffect; class SoundStream; class SoundModule; class SystemWindow; class SoundServer : public zeitgeist::Leaf { // // Types // public: // sound quality levels enum ESoundQuality { SOUNDQUALITY_BEST = 48000, // above CD quality (slowest) SOUNDQUALITY_GOOD = 44100, // CD quality SOUNDQUALITY_AVERAGE = 22000, // radio quality SOUNDQUALITY_BAD = 11000, // bad quality SOUNDQUALITY_VERYBAD = 8000 // very bad quality (fastest) }; private: #ifdef HAVE_HASH_MAP typedef std::hash_map<std::string, boost::shared_ptr<SoundObject> > TSoundHashMap; #else typedef std::map<std::string, boost::shared_ptr<SoundObject> > TSoundHashMap; #endif // // Methods // public: SoundServer(); virtual ~SoundServer(); bool Init(const std::string &sndSysName); float GetCPU(); boost::shared_ptr<SoundEffect> LoadEffect(const std::string& inName); boost::shared_ptr<SoundStream> LoadStream(const std::string& inName); boost::shared_ptr<SoundModule> LoadModule(const std::string& inName); // // Members // private: //! this function resets the cached sounds in the hashmaps void Reset(); //! a helper function which wraps some common loading code (trivial rejects, etc..) bool LoadSoundObject(const std::string& inName, const TSoundHashMap& map, boost::shared_ptr<SoundObject> &soundObject) const; boost::shared_ptr<SoundSystem> mSoundSystem; TSoundHashMap mEffects; TSoundHashMap mModules; TSoundHashMap mStreams; ESoundQuality mQuality; // the frequency which will be used [default=SOUNDQUALITY_BEST] // make singleton functionality more secure SoundServer(const SoundServer&); SoundServer& operator=(const SoundServer&); }; DECLARE_CLASS(SoundServer); } //namespace kerosin #endif //KEROSIN_SOUNDSERVER_H --- NEW FILE: soundobject.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: soundobject.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_SOUNDOBJECT_H #define KEROSIN_SOUNDOBJECT_H #include <string> namespace kerosin { class SoundServer; class SoundObject { public: SoundObject(SoundServer &inServer) : mServer(inServer), mFileName("<null>") {} virtual ~SoundObject() {} void SetFileName(const std::string& inName) { mFileName = inName; } const std::string& GetFileName() const { return mFileName; } protected: // this is a reference to the server the sound belongs to SoundServer& mServer; private: // the name of the file this sound came from std::string mFileName; }; } //namespace kerosin #endif //KEROSIN_SOUNDOBJECT_H --- NEW FILE: soundeffect.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: soundeffect.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_SOUNDEFFECT_H #define KEROSIN_SOUNDEFFECT_H #include "soundobject.h" namespace kerosin { class SoundEffect : public SoundObject { public: SoundEffect(SoundServer &inServer) : SoundObject(inServer) {} virtual ~SoundEffect() {} virtual void Load(const std::string& inName) = 0; virtual void Load(void *inBuffer, int inSize) = 0; virtual void Play() = 0; }; } //namespace kerosin #endif //KEROSIN_SOUNDEFFECT_H --- NEW FILE: soundserver.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2004 RoboCup Soccer Server 3D Maintenance Group $Id: soundserver.cpp,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "soundserver.h" #include "soundsystem.h" #include "soundeffect.h" #include "soundstream.h" #include "soundmodule.h" #include <salt/fileclasses.h> #include <zeitgeist/fileserver/fileserver.h> #include <zeitgeist/logserver/logserver.h> #include <zeitgeist/core.h> #include <boost/scoped_ptr.hpp> //------------------------------------------------------------------------------------------------ // SoundServer implementation //------------------------------------------------------------------------------------------------ using namespace boost; using namespace kerosin; using namespace salt; using namespace std; using namespace zeitgeist; // constructor SoundServer::SoundServer() : Leaf(), mQuality(SOUNDQUALITY_BEST) { } SoundServer::~SoundServer() { Reset(); } bool SoundServer::Init(const std::string &sndSysName) { GetLog()->Normal().Printf("SoundServer::Init -> '%s'\n", sndSysName.c_str()); Reset(); // create the soundsystem mSoundSystem = shared_static_cast<SoundSystem>(GetCore()->New(sndSysName)); if(!mSoundSystem) { // could not create SoundSystem GetLog()->Error().Printf("ERROR: Unable to create '%s'\n", sndSysName.c_str()); return false; } // we have a soundsystem, so initialize it if(mSoundSystem->Init(mQuality) == false) { // something happened when we wanted to initialize the soundsystem GetLog()->Error().Printf("ERROR: Could not init '%s'\n", sndSysName.c_str()); return false; } return true; } float SoundServer::GetCPU() { return mSoundSystem->GetCPU(); } boost::shared_ptr<SoundEffect> SoundServer::LoadEffect(const string& inName) { shared_ptr<SoundObject> soundObject; if (LoadSoundObject(inName, mEffects, soundObject) == false) return shared_ptr<SoundEffect>(); if (soundObject) { GetLog()->Debug() << "Found a cached sound" << endl; return shared_static_cast<SoundEffect>(soundObject); } // we don't have the sound in the cache, so create it shared_ptr<SoundEffect> effect(mSoundSystem->CreateEffect(*this)); // now, we want to load the file from our fileserver shared_ptr<FileServer> fileServer = shared_static_cast<FileServer>(GetCore()->Get("/sys/server/file")); shared_ptr<salt::RFile> file = fileServer->Open(inName.c_str()); if(file.get() == NULL) { GetLog()->Error() << "ERROR: Could not open file" << endl; // could not open file for some strange reason return shared_ptr<SoundEffect>(); } shared_ptr<char> buffer(new char[file->Size()]); file->Read(buffer.get(), file->Size()); effect->Load(buffer.get(), file->Size()); effect->SetFileName(inName); // now, we have to add it to the cache mEffects[inName] = effect; return effect; } boost::shared_ptr<SoundStream> SoundServer::LoadStream(const string& inName) { GetLog()->Debug() << "SoundServer::LoadStream " << inName << endl; shared_ptr<SoundObject> soundObject; if (LoadSoundObject(inName, mStreams, soundObject) == false) return shared_ptr<SoundStream>(); if (soundObject) { GetLog()->Debug() << "Found a cached sound" << endl; return shared_static_cast<SoundStream>(soundObject); } // we don't have the sound in the cache, so create it shared_ptr<SoundStream> stream(mSoundSystem->CreateStream(*this)); // now, we want to load the file from our fileserver shared_ptr<FileServer> fileServer = shared_static_cast<FileServer>(GetCore()->Get("/sys/server/file")); shared_ptr<salt::RFile> file = fileServer->Open(inName.c_str()); if(file.get() == NULL) { GetLog()->Error() << "ERROR: Could not open file" << endl; // could not open file for some strange reason return shared_ptr<SoundStream>(); } char* buffer = new char[file->Size()]; file->Read(buffer, file->Size()); stream->Load(buffer, file->Size()); stream->SetFileName(inName); // now, we have to add it to the cache mStreams[inName] = stream; return stream; } boost::shared_ptr<SoundModule> SoundServer::LoadModule(const string& inName) { shared_ptr<SoundObject> soundObject; if (LoadSoundObject(inName, mModules, soundObject) == false) return shared_ptr<SoundModule>(); if (soundObject) { GetLog()->Debug() << "Found a cached sound" << endl; return shared_static_cast<SoundModule>(soundObject); } // we don't have the sound in the cache, so create it shared_ptr<SoundModule> module(mSoundSystem->CreateModule(*this)); // now, we want to load the file from our fileserver shared_ptr<FileServer> fileServer = shared_static_cast<FileServer>(GetCore()->Get("/sys/server/file")); shared_ptr<salt::RFile> file = fileServer->Open(inName.c_str()); if(file.get() == NULL) { GetLog()->Error() << "ERROR: Could not open file" << endl; // could not open file for some strange reason return shared_ptr<SoundModule>(); } shared_ptr<char> buffer(new char[file->Size()]); file->Read(buffer.get(), file->Size()); module->Load(buffer.get(), file->Size()); module->SetFileName(inName); // now, we have to add it to the cache mModules[inName] = module; return module; } void SoundServer::Reset() { mSoundSystem.reset(); TSoundHashMap::const_iterator i; mEffects.clear(); mModules.clear(); mStreams.clear(); } bool SoundServer::LoadSoundObject(const std::string& inName, const TSoundHashMap& map, boost::shared_ptr<SoundObject> &soundObject) const { // if we have no sound system loaded, then we can't load a sound if (mSoundSystem.get() == NULL) { GetLog()->Error() << "ERROR: No SoundSystem loaded!" << endl; soundObject = shared_ptr<SoundObject>(); return false; } // we have a sound system, so let's check if the sound has been loaded already TSoundHashMap::const_iterator i = map.find(inName); if(i != map.end()) { soundObject = (*i).second; } else { soundObject = shared_ptr<SoundObject>(); } return true; } |
From: Markus R. <rol...@us...> - 2005-12-05 21:38:32
|
Update of /cvsroot/simspark/simspark/spark/kerosin/materialserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/materialserver Added Files: .cvsignore material.cpp material.h material2dtexture.cpp material2dtexture.h material2dtexture_c.cpp material_c.cpp materialserver.cpp materialserver.h materialserver_c.cpp materialsolid.cpp materialsolid.h materialsolid_c.cpp Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs --- NEW FILE: materialsolid.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: materialsolid.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_MATERIALSOLID_H #define KEROSIN_MATERIALSOLID_H #include "material.h" #include <kerosin/openglserver/glbase.h> #include <salt/vector.h> namespace kerosin { class MaterialSolid : public Material { // // Functions // public: MaterialSolid(); virtual ~MaterialSolid(); virtual void Bind(); /** sets the ambient material reflectance */ void SetAmbient(const RGBA& ambient); /** returns the ambient material reflectance */ const RGBA& GetAmbient(); /** sets the diffuse material reflectance */ void SetDiffuse(const RGBA& diffuse); /** returns the diffuse material reflectancee */ const RGBA& GetDiffuse(); /** sets the specular material reflectance */ void SetSpecular(const RGBA& specular); /** returns the specular material reflectance */ const RGBA& GetSpecular(); /** sets the light emission */ void SetEmission(const RGBA& emission); /** returns the light emission */ const RGBA& GetEmission(); protected: /** sets up all lighting material properties */ void SetupMaterial(); // // Members // protected: /** the ambient material refeflectance */ RGBA mAmbient; /** the diffuse material reflectance */ RGBA mDiffuse; /** the specular material reflectance */ RGBA mSpecular; /** the emitted light intensity of the material */ RGBA mEmission; }; DECLARE_CLASS(MaterialSolid); }; #endif // KEROSIN_MATERIALSOLID_H --- NEW FILE: materialserver.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: materialserver.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_MATERIALSERVER_H #define KEROSIN_MATERIALSERVER_H #include <zeitgeist/class.h> #include <zeitgeist/node.h> namespace kerosin { class Material; class MaterialServer : public zeitgeist::Node { // // types // private: // // functions // public: MaterialServer(); virtual ~MaterialServer(); //! returns a cached material boost::shared_ptr<Material> GetMaterial(const std::string &name); protected: virtual void OnLink(); }; DECLARE_CLASS(MaterialServer); } //kerosin #endif //KEROSIN_MATERIALSERVER_H --- NEW FILE: material_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: material_c.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "material.h" using namespace zeitgeist; using namespace kerosin; void CLASS(Material)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Leaf); } --- NEW FILE: materialsolid_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: materialsolid_c.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "materialsolid.h" using namespace zeitgeist; using namespace kerosin; using namespace salt; using namespace boost; static bool readRGBA(const zeitgeist::ParameterList& in, RGBA& m) { if ( (in.GetSize() != 4) || (! in.GetValue(in[0], m.r())) || (! in.GetValue(in[1], m.g())) || (! in.GetValue(in[2], m.b())) || (! in.GetValue(in[3], m.a())) ) { return false; } return true; } FUNCTION(MaterialSolid,setAmbient) { RGBA m; if (! readRGBA(in,m)) { return false; } obj->SetAmbient(m); return true; } FUNCTION(MaterialSolid,setDiffuse) { RGBA m; if (! readRGBA(in,m)) { return false; } obj->SetDiffuse(m); return true; } FUNCTION(MaterialSolid,setSpecular) { RGBA m; if (! readRGBA(in,m)) { return false; } obj->SetSpecular(m); return true; } FUNCTION(MaterialSolid,setEmission) { RGBA m; if (! readRGBA(in,m)) { return false; } obj->SetEmission(m); return true; } void CLASS(MaterialSolid)::DefineClass() { DEFINE_BASECLASS(kerosin/Material); DEFINE_FUNCTION(setAmbient); DEFINE_FUNCTION(setDiffuse); DEFINE_FUNCTION(setSpecular); DEFINE_FUNCTION(setEmission); } --- NEW FILE: material2dtexture.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: material2dtexture.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "material2dtexture.h" #include <kerosin/textureserver/textureserver.h> #include <kerosin/textureserver/texture.h> #include <kerosin/openglserver/openglserver.h> #include <zeitgeist/logserver/logserver.h> #include <zeitgeist/scriptserver/scriptserver.h> using namespace zeitgeist; using namespace kerosin; using namespace boost; using namespace std; Material2DTexture::Material2DTexture() : MaterialSolid() { } Material2DTexture::~Material2DTexture() { } bool Material2DTexture::LoadTexture(const std::string& texName, shared_ptr<Texture>& store) { shared_ptr<ScriptServer> scriptServer = GetCore()->GetScriptServer(); shared_ptr<TextureServer> textureServer = shared_dynamic_cast<TextureServer> (GetCore()->Get("/sys/server/texture")); store.reset(); if (textureServer.get() == 0) { GetLog()->Error() << "(Material2DTexture) ERROR: cannot find TextureServer\n"; return false; } store = textureServer->GetTexture(texName); return (store.get() != 0); } bool Material2DTexture::SetDiffuseTexture(const std::string& texName) { return LoadTexture(texName,mTexDiffuse); } bool Material2DTexture::SetNormalTexture(const std::string& texName) { return LoadTexture(texName,mTexNormal); } bool Material2DTexture::SetSpecularTexture(const std::string& texName) { return LoadTexture(texName,mTexSpecular); } void Material2DTexture::Bind() { SetupMaterial(); if (mTexDiffuse.get() != 0) { glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); mTexDiffuse->Bind(); } if (mTexNormal.get() != 0) { glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); mTexNormal->Bind(); } if (mTexSpecular.get() != 0) { glActiveTextureARB(GL_TEXTURE2_ARB); glEnable(GL_TEXTURE_2D); mTexSpecular->Bind(); } } --- NEW FILE: material2dtexture_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: material2dtexture_c.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "material2dtexture.h" using namespace zeitgeist; using namespace kerosin; using namespace std; FUNCTION(Material2DTexture,setDiffuseTexture) { string inName; if ( (in.GetSize() != 1) || (! in.GetValue(in[0], inName)) ) { return false; } return obj->SetDiffuseTexture(inName); } FUNCTION(Material2DTexture,setNormalTexture) { string inName; if ( (in.GetSize() != 1) || (! in.GetValue(in[0], inName)) ) { return false; } return obj->SetNormalTexture(inName); } FUNCTION(Material2DTexture,setSpecularTexture) { string inName; if ( (in.GetSize() != 1) || (! in.GetValue(in[0], inName)) ) { return false; } return obj->SetSpecularTexture(inName); } void CLASS(Material2DTexture)::DefineClass() { DEFINE_BASECLASS(kerosin/MaterialSolid); DEFINE_FUNCTION(setDiffuseTexture); DEFINE_FUNCTION(setNormalTexture); DEFINE_FUNCTION(setSpecularTexture); } --- NEW FILE: material.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: material.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_MATERIAL_H #define KEROSIN_MATERIAL_H #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> #include <string> namespace kerosin { class Material : public zeitgeist::Leaf { // // Functions // public: Material(); virtual ~Material(); /** binds the managed material, i.e. sets all necessary OpenGL states */ virtual void Bind() = 0; }; DECLARE_ABSTRACTCLASS(Material); } //namespace kerosin #endif //KEROSIN_MATERIAL_H --- NEW FILE: materialsolid.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: materialsolid.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "materialsolid.h" #include <kerosin/openglserver/openglserver.h> using namespace kerosin; using namespace zeitgeist; using namespace salt; using namespace boost; using namespace std; MaterialSolid::MaterialSolid() : Material(), mAmbient(0.2f,0.2f,0.2f,1.0f), mDiffuse(1.0f,1.0f,1.0f,1.0f), mSpecular(0.0f,0.0f,0.0f,1.0f), mEmission(0.0f,0.0f,0.0f,1.0f) { } MaterialSolid::~MaterialSolid() { } void MaterialSolid::SetupMaterial() { // set ambient material reflectance glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,mAmbient); // set diffuse material reflectance glColor3fv(mDiffuse); glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,mDiffuse); // set specular material reflectance glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,mSpecular); // set light emission glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,mEmission); } void MaterialSolid::Bind() { SetupMaterial(); glDisable(GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } void MaterialSolid::SetAmbient(const RGBA& ambient) { mAmbient = ambient; } const RGBA& MaterialSolid::GetAmbient() { return mAmbient; } void MaterialSolid::SetDiffuse(const RGBA& diffuse) { mDiffuse = diffuse; } const RGBA& MaterialSolid::GetDiffuse() { return mDiffuse; } void MaterialSolid::SetSpecular(const RGBA& specular) { mSpecular = specular; } const RGBA& MaterialSolid::GetSpecular() { return mSpecular; } void MaterialSolid::SetEmission(const RGBA& emission) { mEmission = emission; } const RGBA& MaterialSolid::GetEmission() { return mEmission; } --- NEW FILE: materialserver.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: materialserver.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "materialserver.h" #include <zeitgeist/logserver/logserver.h> #include <zeitgeist/scriptserver/scriptserver.h> #include "material.h" #include "materialsolid.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; MaterialServer::MaterialServer() : Node() { } MaterialServer::~MaterialServer() { } shared_ptr<Material> MaterialServer::GetMaterial(const std::string& name) { shared_ptr<Material> material = shared_dynamic_cast<Material>(GetChild(name)); if (material.get() == 0) { GetLog()->Error() << "(MaterialServer) ERROR: Unknown material '" << name << "'\n"; } return material; } void MaterialServer::OnLink() { // create the default material shared_ptr<MaterialSolid> defMat = shared_dynamic_cast<MaterialSolid> (GetCore()->New("kerosin/MaterialSolid")); defMat->SetName("default"); AddChildReference(defMat); } --- NEW FILE: material2dtexture.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: material2dtexture.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_MATERIAL2DTEXTURE_H #define KEROSIN_MATERIAL2DTEXTURE_H #include "materialsolid.h" namespace kerosin { class Texture; class Material2DTexture : public MaterialSolid { // // Functions // public: Material2DTexture(); virtual ~Material2DTexture(); /** loads the diffuse texture */ bool SetDiffuseTexture(const std::string& texName); /** loads the normal texture */ bool SetNormalTexture(const std::string& texName); /** loads the specular texture */ bool SetSpecularTexture(const std::string& texName); /** binds the managed material, i.e. sets all necessary OpenGL states */ virtual void Bind(); protected: /** tries to load the texturee texName and stores a reference */ bool LoadTexture(const std::string& texName, boost::shared_ptr<Texture>& store); // // Members // protected: /** the diffuse texture */ boost::shared_ptr<Texture> mTexDiffuse; /** the normal texture */ boost::shared_ptr<Texture> mTexNormal; /** the specular texture */ boost::shared_ptr<Texture> mTexSpecular; }; DECLARE_CLASS(Material2DTexture); }; #endif // KEROSIN_MATERIAL2DTEXTURE_H --- NEW FILE: material.cpp --- #include "material.h" using namespace boost; using namespace kerosin; using namespace std; using namespace zeitgeist; Material::Material() : Leaf() { } Material::~Material() { } --- NEW FILE: materialserver_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: materialserver_c.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "materialserver.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; void CLASS(MaterialServer)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Node); } |
Update of /cvsroot/simspark/simspark/spark/kerosin/textureserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/textureserver Added Files: .cvsignore texture.cpp texture.h texture2d.cpp texture2d.h textureserver.cpp textureserver.h textureserver_c.cpp Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs --- NEW FILE: texture2d.cpp --- #include "texture2d.h" #include "../openglserver/openglserver.h" #include "../imageserver/image.h" using namespace kerosin; Texture2D::Texture2D(const boost::shared_ptr<TextureServer> &textureServer) : Texture(textureServer) { } Texture2D::~Texture2D() { } void Texture2D::Bind() const { if (mTexID != 0) { glBindTexture(GL_TEXTURE_2D, mTexID); } } void Texture2D::Enable() const { glEnable(GL_TEXTURE_2D); } void Texture2D::Disable() const { glDisable(GL_TEXTURE_2D); } void Texture2D::Create(boost::shared_ptr<Image> &image) { mWidth = image->Width(); mHeight = image->Height(); Acquire(); Bind(); glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE ); if(image->HasAlpha()) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mWidth, mHeight, 0, image->Format(), image->Type(), image->Data()); else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, mWidth, mHeight, 0, image->Format(), image->Type(), image->Data()); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); } void Texture2D::Clamp() const { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); } void Texture2D::ClampToEdge() const { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } void Texture2D::Repeat() const { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } --- NEW FILE: textureserver.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: textureserver.cpp,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "textureserver.h" #include <zeitgeist/logserver/logserver.h> #include "../openglserver/openglserver.h" #include "../imageserver/imageserver.h" #include "texture2d.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; TextureServer::TextureServer() : Leaf() { } TextureServer::~TextureServer() { } void TextureServer::OnLink() { // setup OpenGLServer reference mOpenGLServer = shared_dynamic_cast<OpenGLServer> (GetCore()->Get("sys/server/opengl")); if (mOpenGLServer.get() == 0) { GetLog()->Error() << "(TextureServer) ERROR: OpenGLServer not found\n"; } // setup ImageServer reference mImageServer = shared_dynamic_cast<ImageServer> (GetCore()->Get("sys/server/image")); if (mImageServer.get() == 0) { GetLog()->Error() << "(TextureServer) ERROR: ImageServer not found\n"; } } void TextureServer::OnUnlink() { mOpenGLServer.reset(); mImageServer.reset(); } boost::shared_ptr<OpenGLServer> TextureServer::GetOpenGLServer() const { return mOpenGLServer; } boost::shared_ptr<Texture> TextureServer::GetTexture(const std::string &name) { TTextureCache::iterator entry = mTextureCache.find(name); if (entry != mTextureCache.end()) { // we already have a match return (*entry).second; } if (mImageServer.get() == 0) { return shared_ptr<Texture>(); } // no match for that name, so we have to load it shared_ptr<Image> image = mImageServer->Load(name.c_str()); if (! image.get()) { return shared_ptr<Texture>(); } Texture2D *tex2D = new Texture2D(shared_static_cast<TextureServer> (make_shared(GetSelf()))); tex2D->Create(image); shared_ptr<Texture> texture(tex2D); // register the texture, so we will find it later mTextureCache[name] = texture; return texture; } --- NEW FILE: textureserver.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: textureserver.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_TEXTURESERVER_H #define KEROSIN_TEXTURESERVER_H #ifdef HAVE_CONFIG_H #ifdef PACKAGE_BUGREPORT #undef PACKAGE_BUGREPORT #endif #ifdef PACKAGE_NAME #undef PACKAGE_NAME #endif #ifdef PACKAGE_STRING #undef PACKAGE_STRING #endif #ifdef PACKAGE_TARNAME #undef PACKAGE_TARNAME #endif #ifdef PACKAGE_VERSION #undef PACKAGE_VERSION #endif #include <config.h> #endif #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> #if HAVE_HASH_MAP #include <hash_map> #else #include <map> #endif namespace kerosin { #if 0 } #endif class OpenGLServer; class ImageServer; class Texture; class TextureServer : public zeitgeist::Leaf { // // types // private: #if HAVE_HASH_MAP typedef std::hash_map<std::string, boost::shared_ptr<Texture> > TTextureCache; #else typedef std::map<std::string, boost::shared_ptr<Texture> > TTextureCache; #endif // // functions // public: TextureServer(); virtual ~TextureServer(); /** retrieve pointer to the OpenGL server ... used by Textures to check extensions */ boost::shared_ptr<OpenGLServer> GetOpenGLServer() const; /** load (or returned cached) texture */ boost::shared_ptr<Texture> GetTexture(const std::string &name); protected: /** set up the OpenGLServer and ImageServer reference */ virtual void OnLink(); /** reset OpenGLServer and ImageServer reference */ virtual void OnUnlink(); // // members // private: /** reference to the OpenGLServer */ boost::shared_ptr<OpenGLServer> mOpenGLServer; /** reference to the ImageServer */ boost::shared_ptr<ImageServer> mImageServer; /** registry of cached textures */ TTextureCache mTextureCache; }; DECLARE_CLASS(TextureServer); } //kerosin #endif //KEROSIN_TEXTURESERVER_H --- NEW FILE: texture.cpp --- #include "texture.h" #include "../openglserver/openglserver.h" using namespace boost; using namespace kerosin; Texture::Texture(const boost::shared_ptr<TextureServer> &textureServer) : mTexID(0), mWidth(0), mHeight(0), mTextureServer(textureServer) { } Texture::~Texture() { Reset(); } void Texture::Reset() { if (mTexID) { glDeleteTextures(1, &mTexID); mTexID = 0; } } void Texture::Acquire() { Reset(); glGenTextures(1, &mTexID); } unsigned int Texture::GetWidth() const { return mWidth; } unsigned int Texture::GetHeight() const { return mHeight; } boost::shared_ptr<TextureServer> Texture::GetTextureServer() const { return make_shared(mTextureServer); } --- NEW FILE: texture2d.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: texture2d.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_TEXTURE2D_H #define KEROSIN_TEXTURE2D_H #include "texture.h" namespace kerosin { class Image; class Texture2D : public Texture { // // functions // public: Texture2D(const boost::shared_ptr<TextureServer> &textureServer); ~Texture2D(); //! bind the texture contained in this object to the corresponding target (user code is responsible for setting correct enables and tex units) virtual void Bind() const; //! enable the target associated with a texture type (e.g. GL_TEXTURE_2D) virtual void Enable() const; //! disable the target associated with a texture type (e.g. GL_TEXTURE_2D) virtual void Disable() const; virtual void Clamp() const; virtual void ClampToEdge() const; virtual void Repeat() const; void Create(boost::shared_ptr<Image> &image); }; } //kerosin #endif //KEROSIN_TEXTURE2D_H --- NEW FILE: textureserver_c.cpp --- #include "textureserver.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; void CLASS(TextureServer)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Leaf); } --- NEW FILE: texture.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: texture.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_TEXTURE_H #define KEROSIN_TEXTURE_H #include <boost/weak_ptr.hpp> #include <boost/shared_ptr.hpp> namespace kerosin { class TextureServer; /* \class Texture This is the base class of all OpenGL based textures. In OpenGL a texture is represented by a so-called texture ID. This is a simple handle. The basic operations for creating/deleting this handle are contained in this class. Usually, textures are created via the texture server. NOTE: HISTORY: 14.10.02 - MK - Initial version TODO: - support mipmap building (currently done only when SGIS_generate_mipmap is supported) TOFIX: */ class Texture { // // functions // public: Texture(const boost::shared_ptr<TextureServer> &textureServer); virtual ~Texture(); //! release the associated OpenGL texture void Reset(); //! acquire an OpenGL texture handle (texture not loaded) void Acquire(); //! bind the texture contained in this object to the corresponding target (user code is responsible for setting correct enables and tex units) virtual void Bind() const = 0; //! enable the target associated with a texture type (e.g. GL_TEXTURE_2D) virtual void Enable() const = 0; //! disable the target associated with a texture type (e.g. GL_TEXTURE_2D) virtual void Disable() const = 0; virtual void Clamp() const = 0; virtual void ClampToEdge() const = 0; virtual void Repeat() const = 0; // accessors unsigned int GetWidth() const; unsigned int GetHeight() const; boost::shared_ptr<TextureServer> GetTextureServer() const; // // members // protected: unsigned int mTexID; // OpenGL texture handle (initialized to 0) unsigned int mWidth; // width of texture unsigned int mHeight; // height of texture private: boost::weak_ptr<TextureServer> mTextureServer; // texture server, which created this object }; } #endif //KEROSIN_TEXTURE_H |
From: Markus R. <rol...@us...> - 2005-12-05 21:38:31
|
Update of /cvsroot/simspark/simspark/spark/kerosin/sceneserver/helper/nv_math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/sceneserver/helper/nv_math Added Files: nv_algebra.h nv_math.h nv_mathdecl.h Log Message: --- NEW FILE: nv_algebra.h --- /*********************************************************************NVMH1**** File: nv_algebra.h Copyright (C) 1999, 2002 NVIDIA Corporation This file is provided without support, instruction, or implied warranty of any kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is not liable under any circumstances for any damages or loss whatsoever arising from the use or inability to use this file or items derived from it. Comments: ******************************************************************************/ #ifndef _nv_algebra_h_ #define _nv_algebra_h_ struct DECLSPEC_NV_MATH vec2 { vec2() { } vec2(nv_scalar x, nv_scalar y) : x(x), y(y) { } vec2(const nv_scalar* xy) : x(xy[0]), y(xy[1]) { } vec2(const vec2& u) : x(u.x), y(u.y) { } vec2(const vec3&); bool operator==(const vec2 & u) const { return (u.x == x && u.y == y) ? true : false; } bool operator!=(const vec2 & u) const { return !(*this == u ); } vec2 & operator*=(const nv_scalar & lambda) { x*= lambda; y*= lambda; return *this; } vec2 & operator-=(const vec2 & u) { x-= u.x; y-= u.y; return *this; } vec2 & operator+=(const vec2 & u) { x+= u.x; y+= u.y; return *this; } nv_scalar & operator[](int i) { return vec_array[i]; } const nv_scalar operator[](int i) const { return vec_array[i]; } union { struct { nv_scalar x,y; // standard names for components }; struct { nv_scalar s,t; // standard names for components }; nv_scalar vec_array[2]; // array access }; }; inline const vec2 operator+(const vec2& u, const vec2& v) { return vec2(u.x + v.x, u.y + v.y); } inline const vec2 operator-(const vec2& u, const vec2& v) { return vec2(u.x - v.x, u.y - v.y); } inline const vec2 operator*(const nv_scalar s, const vec2& u) { return vec2(s * u.x, s * u.y); } inline const vec2 operator/(const vec2& u, const nv_scalar s) { return vec2(u.x / s, u.y / s); } inline const vec2 operator*(const vec2&u, const vec2&v) { return vec2(u.x * v.x, u.y * v.y); } struct DECLSPEC_NV_MATH vec3 { vec3() { } vec3(nv_scalar x, nv_scalar y, nv_scalar z) : x(x), y(y), z(z) { } vec3(const nv_scalar* xyz) : x(xyz[0]), y(xyz[1]), z(xyz[2]) { } vec3(const vec2& u) : x(u.x), y(u.y), z(1.0f) { } vec3(const vec3& u) : x(u.x), y(u.y), z(u.z) { } vec3(const vec4&); bool operator==(const vec3 & u) const { return (u.x == x && u.y == y && u.z == z) ? true : false; } bool operator!=( const vec3& rhs ) const { return !(*this == rhs ); } vec3 & operator*=(const nv_scalar & lambda) { x*= lambda; y*= lambda; z*= lambda; return *this; } vec3 operator - () const { return vec3(-x, -y, -z); } vec3 & operator-=(const vec3 & u) { x-= u.x; y-= u.y; z-= u.z; return *this; } vec3 & operator+=(const vec3 & u) { x+= u.x; y+= u.y; z+= u.z; return *this; } nv_scalar normalize(); nv_scalar sq_norm() const { return x * x + y * y + z * z; } nv_scalar norm() const { return sqrtf(sq_norm()); } nv_scalar & operator[](int i) { return vec_array[i]; } const nv_scalar operator[](int i) const { return vec_array[i]; } union { struct { nv_scalar x,y,z; // standard names for components }; struct { nv_scalar s,t,r; // standard names for components }; nv_scalar vec_array[3]; // array access }; }; inline const vec3 operator+(const vec3& u, const vec3& v) { return vec3(u.x + v.x, u.y + v.y, u.z + v.z); } inline const vec3 operator-(const vec3& u, const vec3& v) { return vec3(u.x - v.x, u.y - v.y, u.z - v.z); } inline const vec3 operator^(const vec3& u, const vec3& v) { return vec3(u.y * v.z - u.z * v.y, u.z * v.x - u.x * v.z, u.x * v.y - u.y * v.x); } inline const vec3 operator*(const nv_scalar s, const vec3& u) { return vec3(s * u.x, s * u.y, s * u.z); } inline const vec3 operator/(const vec3& u, const nv_scalar s) { return vec3(u.x / s, u.y / s, u.z / s); } inline const vec3 operator*(const vec3& u, const vec3& v) { return vec3(u.x * v.x, u.y * v.y, u.z * v.z); } inline vec2::vec2(const vec3& u) { nv_scalar k = 1 / u.z; x = k * u.x; y = k * u.y; } struct DECLSPEC_NV_MATH vec4 { vec4() { } vec4(nv_scalar x, nv_scalar y, nv_scalar z, nv_scalar w) : x(x), y(y), z(z), w(w) { } vec4(const nv_scalar* xyzw) : x(xyzw[0]), y(xyzw[1]), z(xyzw[2]), w(xyzw[3]) { } vec4(const vec3& u) : x(u.x), y(u.y), z(u.z), w(1.0f) { } vec4(const vec4& u) : x(u.x), y(u.y), z(u.z), w(u.w) { } bool operator==(const vec4 & u) const { return (u.x == x && u.y == y && u.z == z && u.w == w) ? true : false; } bool operator!=( const vec4& rhs ) const { return !(*this == rhs ); } vec4 & operator*=(const nv_scalar & lambda) { x*= lambda; y*= lambda; z*= lambda; w*= lambda; return *this; } vec4 & operator-=(const vec4 & u) { x-= u.x; y-= u.y; z-= u.z; w-= u.w; return *this; } vec4 & operator+=(const vec4 & u) { x+= u.x; y+= u.y; z+= u.z; w+= u.w; return *this; } vec4 operator - () const { return vec4(-x, -y, -z, -w); } nv_scalar & operator[](int i) { return vec_array[i]; } const nv_scalar operator[](int i) const { return vec_array[i]; } union { struct { nv_scalar x,y,z,w; // standard names for components }; struct { nv_scalar s,t,r,q; // standard names for components }; nv_scalar vec_array[4]; // array access }; }; inline const vec4 operator+(const vec4& u, const vec4& v) { return vec4(u.x + v.x, u.y + v.y, u.z + v.z, u.w + v.w); } inline const vec4 operator-(const vec4& u, const vec4& v) { return vec4(u.x - v.x, u.y - v.y, u.z - v.z, u.w - v.w); } inline const vec4 operator*(const nv_scalar s, const vec4& u) { return vec4(s * u.x, s * u.y, s * u.z, s * u.w); } inline const vec4 operator/(const vec4& u, const nv_scalar s) { return vec4(u.x / s, u.y / s, u.z / s, u.w / s); } inline const vec4 operator*(const vec4& u, const vec4& v) { return vec4(u.x * v.x, u.y * v.y, u.z * v.z, u.w * v.w); } inline vec3::vec3(const vec4& u) { x = u.x; y = u.y; z = u.z; } // quaternion struct quat; /* for all the matrices...a<x><y> indicates the element at row x, col y For example: a01 <-> row 0, col 1 */ struct DECLSPEC_NV_MATH mat3 { mat3(); mat3(const nv_scalar * array); mat3(const mat3 & M); mat3( const nv_scalar& f0, const nv_scalar& f1, const nv_scalar& f2, const nv_scalar& f3, const nv_scalar& f4, const nv_scalar& f5, const nv_scalar& f6, const nv_scalar& f7, const nv_scalar& f8 ) : a00( f0 ), a10( f1 ), a20( f2 ), a01( f3 ), a11( f4 ), a21( f5 ), a02( f6 ), a12( f7 ), a22( f8) { } const vec3 col(const int i) const { return vec3(&mat_array[i * 3]); } const vec3 operator[](int i) const { return vec3(mat_array[i], mat_array[i + 3], mat_array[i + 6]); } const nv_scalar& operator()(const int& i, const int& j) const { return mat_array[ j * 3 + i ]; } nv_scalar& operator()(const int& i, const int& j) { return mat_array[ j * 3 + i ]; } void set_row(int i, const vec3 & v) { mat_array[i] = v.x; mat_array[i + 3] = v.y; mat_array[i + 6] = v.z; } void set_col(int i, const vec3 & v) { mat_array[i * 3] = v.x; mat_array[i * 3 + 1] = v.y; mat_array[i * 3 + 2] = v.z; } void set_rot(const nv_scalar & theta, const vec3 & v); void set_rot(const vec3 & u, const vec3 & v); union { struct { nv_scalar a00, a10, a20; // standard names for components nv_scalar a01, a11, a21; // standard names for components nv_scalar a02, a12, a22; // standard names for components }; nv_scalar mat_array[9]; // array access }; }; const vec3 operator*(const mat3&, const vec3&); const vec3 operator*(const vec3&, const mat3&); struct DECLSPEC_NV_MATH mat4 { mat4(); mat4(const nv_scalar * array); mat4(const mat4 & M); mat4( const nv_scalar& f0, const nv_scalar& f1, const nv_scalar& f2, const nv_scalar& f3, const nv_scalar& f4, const nv_scalar& f5, const nv_scalar& f6, const nv_scalar& f7, const nv_scalar& f8, const nv_scalar& f9, const nv_scalar& f10, const nv_scalar& f11, const nv_scalar& f12, const nv_scalar& f13, const nv_scalar& f14, const nv_scalar& f15 ) : a00( f0 ), a10( f1 ), a20( f2 ), a30( f3 ), a01( f4 ), a11( f5 ), a21( f6 ), a31( f7 ), a02( f8 ), a12( f9 ), a22( f10), a32( f11), a03( f12), a13( f13), a23( f14), a33( f15) { } const vec4 col(const int i) const { return vec4(&mat_array[i * 4]); } const vec4 operator[](const int& i) const { return vec4(mat_array[i], mat_array[i + 4], mat_array[i + 8], mat_array[i + 12]); } const nv_scalar& operator()(const int& i, const int& j) const { return mat_array[ j * 4 + i ]; } nv_scalar& operator()(const int& i, const int& j) { return mat_array[ j * 4 + i ]; } void set_col(int i, const vec4 & v) { mat_array[i * 4] = v.x; mat_array[i * 4 + 1] = v.y; mat_array[i * 4 + 2] = v.z; mat_array[i * 4 + 3] = v.w; } void set_row(int i, const vec4 & v) { mat_array[i] = v.x; mat_array[i + 4] = v.y; mat_array[i + 8] = v.z; mat_array[i + 12] = v.w; } mat3 & get_rot(mat3 & M) const; quat & get_rot(quat & q) const; void set_rot(const quat & q); void set_rot(const mat3 & M); void set_rot(const nv_scalar & theta, const vec3 & v); void set_rot(const vec3 & u, const vec3 & v); void set_translation(const vec3 & t); vec3 & get_translation(vec3 & t) const; mat4 operator*(const mat4&) const; union { struct { nv_scalar a00, a10, a20, a30; // standard names for components nv_scalar a01, a11, a21, a31; // standard names for components nv_scalar a02, a12, a22, a32; // standard names for components nv_scalar a03, a13, a23, a33; // standard names for components }; struct { nv_scalar _11, _12, _13, _14; // standard names for components nv_scalar _21, _22, _23, _24; // standard names for components nv_scalar _31, _32, _33, _34; // standard names for components nv_scalar _41, _42, _43, _44; // standard names for components }; union { struct { nv_scalar b00, b10, b20, p; // standard names for components nv_scalar b01, b11, b21, q; // standard names for components nv_scalar b02, b12, b22, r; // standard names for components nv_scalar x, y, z, w; // standard names for components }; }; nv_scalar mat_array[16]; // array access }; }; const vec4 operator*(const mat4&, const vec4&); const vec4 operator*(const vec4&, const mat4&); // quaternion struct DECLSPEC_NV_MATH quat { public: quat(nv_scalar x = 0, nv_scalar y = 0, nv_scalar z = 0, nv_scalar w = 1); quat(const quat& quat); quat(const vec3& axis, nv_scalar angle); quat(const mat3& rot); quat& operator=(const quat& quat); quat operator-() { return quat(-x, -y, -z, -w); } quat Inverse(); void Normalize(); void FromMatrix(const mat3& mat); void ToMatrix(mat3& mat) const; quat& operator*=(const quat& quat); static const quat Identity; nv_scalar& operator[](int i) { return comp[i]; } const nv_scalar operator[](int i) const { return comp[i]; } union { struct { nv_scalar x, y, z, w; }; nv_scalar comp[4]; }; }; const quat operator*(const quat&, const quat&); extern quat & conj(quat & p, const quat & q); extern quat & add_quats(quat & p, const quat & q1, const quat & q2); extern nv_scalar dot(const quat & p, const quat & q); extern quat & dot(nv_scalar s, const quat & p, const quat & q); extern quat & slerp_quats(quat & p, nv_scalar s, const quat & q1, const quat & q2); extern quat & axis_to_quat(quat & q, const vec3 & a, const nv_scalar phi); extern mat3 & quat_2_mat(mat3 &M, const quat &q ); extern quat & mat_2_quat(quat &q,const mat3 &M); // constant algebraic values const nv_scalar array16_id[] = { nv_one, nv_zero, nv_zero, nv_zero, nv_zero, nv_one, nv_zero, nv_zero, nv_zero, nv_zero, nv_one, nv_zero, nv_zero, nv_zero, nv_zero, nv_one}; const nv_scalar array16_null[] = { nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero}; const nv_scalar array16_scale_bias[] = { nv_zero_5, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero_5, nv_zero, nv_zero, nv_zero, nv_zero, nv_zero_5, nv_zero, nv_zero_5, nv_zero_5, nv_zero_5, nv_one}; const nv_scalar array9_id[] = { nv_one, nv_zero, nv_zero, nv_zero, nv_one, nv_zero, nv_zero, nv_zero, nv_one}; const vec2 vec2_null(nv_zero,nv_zero); const vec4 vec4_one(nv_one,nv_one,nv_one,nv_one); const vec3 vec3_one(nv_one,nv_one,nv_one); const vec3 vec3_null(nv_zero,nv_zero,nv_zero); const vec3 vec3_x(nv_one,nv_zero,nv_zero); const vec3 vec3_y(nv_zero,nv_one,nv_zero); const vec3 vec3_z(nv_zero,nv_zero,nv_one); const vec3 vec3_neg_x(-nv_one,nv_zero,nv_zero); const vec3 vec3_neg_y(nv_zero,-nv_one,nv_zero); const vec3 vec3_neg_z(nv_zero,nv_zero,-nv_one); const vec4 vec4_null(nv_zero,nv_zero,nv_zero,nv_zero); const vec4 vec4_x(nv_one,nv_zero,nv_zero,nv_zero); const vec4 vec4_neg_x(-nv_one,nv_zero,nv_zero,nv_zero); const vec4 vec4_y(nv_zero,nv_one,nv_zero,nv_zero); const vec4 vec4_neg_y(nv_zero,-nv_one,nv_zero,nv_zero); const vec4 vec4_z(nv_zero,nv_zero,nv_one,nv_zero); const vec4 vec4_neg_z(nv_zero,nv_zero,-nv_one,nv_zero); const vec4 vec4_w(nv_zero,nv_zero,nv_zero,nv_one); const vec4 vec4_neg_w(nv_zero,nv_zero,nv_zero,-nv_one); const quat quat_id(nv_zero,nv_zero,nv_zero,nv_one); const mat4 mat4_id(array16_id); const mat3 mat3_id(array9_id); const mat4 mat4_null(array16_null); const mat4 mat4_scale_bias(array16_scale_bias); // normalizes a vector and return a reference of itself extern vec3 & normalize(vec3 & u); extern vec4 & normalize(vec4 & u); // Computes the squared magnitude inline nv_scalar nv_sq_norm(const vec3 & n) { return n.x * n.x + n.y * n.y + n.z * n.z; } inline nv_scalar nv_sq_norm(const vec4 & n) { return n.x * n.x + n.y * n.y + n.z * n.z + n.w * n.w; } // Computes the magnitude inline nv_scalar nv_norm(const vec3 & n) { return sqrtf(nv_sq_norm(n)); } inline nv_scalar nv_norm(const vec4 & n) { return sqrtf(nv_sq_norm(n)); } // computes the cross product ( v cross w) and stores the result in u // i.e. u = v cross w extern vec3 & cross(vec3 & u, const vec3 & v, const vec3 & w); // computes the dot product ( v dot w) and stores the result in u // i.e. u = v dot w extern nv_scalar & dot(nv_scalar & u, const vec3 & v, const vec3 & w); extern nv_scalar dot(const vec3 & v, const vec3 & w); extern nv_scalar & dot(nv_scalar & u, const vec4 & v, const vec4 & w); extern nv_scalar dot(const vec4 & v, const vec4 & w); extern nv_scalar & dot(nv_scalar & u, const vec3 & v, const vec4 & w); extern nv_scalar dot(const vec3 & v, const vec4 & w); extern nv_scalar & dot(nv_scalar & u, const vec4 & v, const vec3 & w); extern nv_scalar dot(const vec4 & v, const vec3 & w); // compute the reflected vector R of L w.r.t N - vectors need to be // normalized // // R N L // _ _ // |\ ^ /| // \ | / // \ | / // \|/ // + extern vec3 & reflect(vec3 & r, const vec3 & n, const vec3 & l); // Computes u = v * lambda + u extern vec3 & madd(vec3 & u, const vec3 & v, const nv_scalar & lambda); // Computes u = v * lambda extern vec3 & mult(vec3 & u, const vec3 & v, const nv_scalar & lambda); // Computes u = v * w extern vec3 & mult(vec3 & u, const vec3 & v, const vec3 & w); // Computes u = v + w extern vec3 & add(vec3 & u, const vec3 & v, const vec3 & w); // Computes u = v - w extern vec3 & sub(vec3 & u, const vec3 & v, const vec3 & w); // Computes u = u * s extern vec3 & scale(vec3 & u, const nv_scalar s); extern vec4 & scale(vec4 & u, const nv_scalar s); // Computes u = M * v extern vec3 & mult(vec3 & u, const mat3 & M, const vec3 & v); extern vec4 & mult(vec4 & u, const mat4 & M, const vec4 & v); // Computes u = v * M extern vec3 & mult(vec3 & u, const vec3 & v, const mat3 & M); extern vec4 & mult(vec4 & u, const vec4 & v, const mat4 & M); // Computes u = M(4x4) * v and divides by w extern vec3 & mult_pos(vec3 & u, const mat4 & M, const vec3 & v); // Computes u = M(4x4) * v extern vec3 & mult_dir(vec3 & u, const mat4 & M, const vec3 & v); // Computes u = M(4x4) * v and does not divide by w (assumed to be 1) extern vec3 & mult(vec3& u, const mat4& M, const vec3& v); // Computes u = v * M(4x4) and divides by w extern vec3 & mult_pos(vec3 & u, const vec3 & v, const mat4 & M); // Computes u = v * M(4x4) extern vec3 & mult_dir(vec3 & u, const vec3 & v, const mat4 & M); // Computes u = v * M(4x4) and does not divide by w (assumed to be 1) extern vec3 & mult(vec3& u, const vec3& v, const mat4& M); // Computes A += B extern mat4 & add(mat4 & A, const mat4 & B); extern mat3 & add(mat3 & A, const mat3 & B); // Computes C = A * B extern mat4 & mult(mat4 & C, const mat4 & A, const mat4 & B); extern mat3 & mult(mat3 & C, const mat3 & A, const mat3 & B); // Computes B = Transpose(A) // T // B = A extern mat3 & transpose(mat3 & B, const mat3 & A); extern mat4 & transpose(mat4 & B, const mat4 & A); extern mat3 & transpose(mat3 & B); extern mat4 & transpose(mat4 & B); // Computes B = inverse(A) // -1 // B = A extern mat4 & invert(mat4 & B, const mat4 & A); extern mat3 & invert(mat3 & B, const mat3 & A); // Computes B = inverse(A) // T T // (R t) (R -R t) // assuming that A = (0 1) so that B = (0 1) // B = A extern mat4 & invert_rot_trans(mat4 & B, const mat4 & A); extern mat4 & look_at(mat4 & M, const vec3 & eye, const vec3 & center, const vec3 & up); extern mat4 & frustum(mat4 & M, const nv_scalar l, const nv_scalar r, const nv_scalar b, const nv_scalar t, const nv_scalar n, const nv_scalar f); extern mat4 & perspective(mat4 & M, const nv_scalar fovy, const nv_scalar aspect, const nv_scalar n, const nv_scalar f); // quaternion extern quat & normalize(quat & p); extern quat & conj(quat & p); extern quat & conj(quat & p, const quat & q); extern quat & add_quats(quat & p, const quat & q1, const quat & q2); extern quat & axis_to_quat(quat & q, const vec3 & a, const nv_scalar phi); extern mat3 & quat_2_mat(mat3 &M, const quat &q ); extern quat & mat_2_quat(quat &q,const mat3 &M); extern quat & mat_2_quat(quat &q,const mat4 &M); // surface properties extern mat3 & tangent_basis(mat3 & basis,const vec3 & v0,const vec3 & v1,const vec3 & v2,const vec2 & t0,const vec2 & t1,const vec2 & t2, const vec3 & n); // linear interpolation inline nv_scalar lerp(nv_scalar t, nv_scalar a, nv_scalar b) { return a * (nv_one - t) + t * b; } inline vec3 & lerp(vec3 & w, const nv_scalar & t, const vec3 & u, const vec3 & v) { w.x = lerp(t, u.x, v.x); w.y = lerp(t, u.y, v.y); w.z = lerp(t, u.z, v.z); return w; } // utilities inline nv_scalar nv_min(const nv_scalar & lambda, const nv_scalar & n) { return (lambda < n ) ? lambda : n; } inline nv_scalar nv_max(const nv_scalar & lambda, const nv_scalar & n) { return (lambda > n ) ? lambda : n; } inline nv_scalar nv_clamp(nv_scalar u, const nv_scalar min, const nv_scalar max) { u = (u < min) ? min : u; u = (u > max) ? max : u; return u; } extern nv_scalar nv_random(); extern quat & trackball(quat & q, vec2 & pt1, vec2 & pt2, nv_scalar trackballsize); extern vec3 & cube_map_normal(int i, int x, int y, int cubesize, vec3 & v); // geometry // computes the area of a triangle extern nv_scalar nv_area(const vec3 & v1, const vec3 & v2, const vec3 &v3); // computes the perimeter of a triangle extern nv_scalar nv_perimeter(const vec3 & v1, const vec3 & v2, const vec3 &v3); // find the inscribed circle extern nv_scalar nv_find_in_circle( vec3 & center, const vec3 & v1, const vec3 & v2, const vec3 &v3); // find the circumscribed circle extern nv_scalar nv_find_circ_circle( vec3 & center, const vec3 & v1, const vec3 & v2, const vec3 &v3); // fast cosine functions extern nv_scalar fast_cos(const nv_scalar x); extern nv_scalar ffast_cos(const nv_scalar x); // determinant nv_scalar det(const mat3 & A); extern void nv_is_valid(const vec3& v); extern void nv_is_valid(nv_scalar lambda); #endif //_nv_algebra_h_ --- NEW FILE: nv_math.h --- /*********************************************************************NVMH1**** File: nv_math.h Copyright (C) 1999, 2002 NVIDIA Corporation This file is provided without support, instruction, or implied warranty of any kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is not liable under any circumstances for any damages or loss whatsoever arising from the use or inability to use this file or items derived from it. Comments: ******************************************************************************/ #ifndef _nv_math_h_ #define _nv_math_h_ #ifndef _nv_mathdecl_h_ #include "nv_mathdecl.h" #endif // _nv_mathdecl_h_ #include <assert.h> #include <math.h> #ifdef _WIN32 #include <limits> #else #include <limits.h> #endif #ifdef MACOS #define sqrtf sqrt #define sinf sin #define cosf cos #define tanf tan #endif #include <memory.h> #include <stdlib.h> #include <float.h> typedef float nv_scalar; #define nv_zero nv_scalar(0) #define nv_zero_5 nv_scalar(0.5) #define nv_one nv_scalar(1.0) #define nv_two nv_scalar(2) #define nv_half_pi nv_scalar(3.14159265358979323846264338327950288419716939937510582 * 0.5) #define nv_quarter_pi nv_scalar(3.14159265358979323846264338327950288419716939937510582 * 0.25) #define nv_pi nv_scalar(3.14159265358979323846264338327950288419716939937510582) #define nv_two_pi nv_scalar(3.14159265358979323846264338327950288419716939937510582 * 2.0) #define nv_oo_pi nv_one / nv_pi #define nv_oo_two_pi nv_one / nv_two_pi #define nv_oo_255 nv_one / nv_scalar(255) #define nv_oo_128 nv_one / nv_scalar(128) #define nv_to_rad nv_pi / nv_scalar(180) #define nv_to_deg nv_scalar(180) / nv_pi #define nv_eps nv_scalar(10e-6) #define nv_double_eps nv_scalar(10e-6) * nv_two #define nv_big_eps nv_scalar(10e-6) #define nv_small_eps nv_scalar(10e-2) struct vec2; struct vec2t; struct vec3; struct vec3t; struct vec4; struct vec4t; #ifndef _nv_algebra_h_ #include "nv_algebra.h" #endif // _nv_algebra_h_ #endif //_nv_math_h_ --- NEW FILE: nv_mathdecl.h --- /*********************************************************************NVMH1**** File: nv_mathdecl.h Copyright (C) 1999, 2002 NVIDIA Corporation This file is provided without support, instruction, or implied warranty of any kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is not liable under any circumstances for any damages or loss whatsoever arising from the use or inability to use this file or items derived from it. Comments: ******************************************************************************/ #ifndef _nv_mathdecl_h_ #define _nv_mathdecl_h_ #ifdef NV_MATH_DLL #ifdef NV_MATH_EXPORTS #define DECLSPEC_NV_MATH __declspec(dllexport) #else #define DECLSPEC_NV_MATH __declspec(dllimport) #endif #else #define DECLSPEC_NV_MATH #endif #endif // _nv_mathdecl_h_ |
From: Markus R. <rol...@us...> - 2005-12-05 21:38:31
|
Update of /cvsroot/simspark/simspark/spark/kerosin/openglserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/openglserver Added Files: .cvsignore glbase.h glextensionreg.cpp glextensionreg.h openglserver.cpp openglserver.h openglserver_c.cpp openglsystem.h openglsystem_c.cpp Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs glextensionreg.cpp glextensionreg.h --- NEW FILE: openglsystem_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: openglsystem_c.cpp,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "openglsystem.h" using namespace kerosin; void CLASS(OpenGLSystem)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Node); } --- NEW FILE: glextensionreg.h --- #line 2 "utility/glextgen/tocopy/header_begin.txt" #ifndef GLEXTENSIONREG_H__ #define GLEXTENSIONREG_H__ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) #define WIN32_LEAN_AND_MEAN 1 #include <windows.h> #endif #define GL_GLEXT_PROTOTYPES #include <GL/gl.h> #include <GL/glext.h> #if defined(_WIN32) #include <GL/wglext.h> #else #include <GL/glx.h> #include <GL/glxext.h> [...1043 lines suppressed...] #endif //_WIN32 GLExtensionReg(); ~GLExtensionReg(); void Init(GLExtGenFunctionPointers *funPtr = 0, GLExtGenExtensions *ext = 0); bool QueryGLExtension(const char *name); #if defined(_WIN32) bool QueryWGLExtension(const char *name); HDC GetHDC() const { return mHDC; } void SetHDC(HDC hdc){ mHDC = hdc; } #endif //_WIN32 }; } // end kerosin #line 141 "utility/glextgen/script/glbackend.rb" #if defined(_WIN32) #line 146 "utility/glextgen/script/glbackend.rb" #endif //_WIN32 #line 2 "utility/glextgen/tocopy/header_end.txt" #endif //GLEXTENSIONREG_H__ --- NEW FILE: openglsystem.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: openglsystem.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_OPENGLSYSTEM_H #define KEROSIN_OPENGLSYSTEM_H /* \class OpenGLSystem HISTORY: 04.12.05 - Initial version */ #include <zeitgeist/node.h> namespace kerosin { class OpenGLSystem : public zeitgeist::Node { // // functions // public: //! init the opengl subsystem virtual bool Init() = 0; //! called periodically to allow for any event processing virtual void Update() = 0; /** called after each frame in order to swap buffer in OpenGLSystems that support double buffering */ virtual void SwapBuffers() = 0; protected: // // members // protected: }; DECLARE_ABSTRACTCLASS(OpenGLSystem); } // namespace kerosin #endif //KEROSIN_OPENGLSYSTEM_H --- NEW FILE: glbase.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: glbase.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_GLBASE_H #define KEROSIN_GLBASE_H namespace kerosin { class RGBA { public: union { float v[4]; struct { float r; float g; float b; float a; } c; } data; public: RGBA() { data.c.r = 1.0f; data.c.g = 1.0f; data.c.b = 1.0f; data.c.a = 1.0f; } RGBA(float rr, float gg, float bb, float aa) { data.c.r = rr; data.c.g = gg; data.c.b = bb; data.c.a = aa; } float& r() { return data.c.r; } float& g() { return data.c.g; } float& b() { return data.c.b; } float& a() { return data.c.a; } const float& r() const { return data.c.r; } const float& g() const { return data.c.g; } const float& b() const { return data.c.b; } const float& a() const { return data.c.a; } float* v() { return data.v; } const float* v() const { return data.v; } operator float* () { return data.v; } operator const float*() const { return data.v; } }; }; #endif // KEROSIN_GLBASE_H --- NEW FILE: openglserver.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: openglserver.cpp,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "openglserver.h" #include "openglsystem.h" #include <zeitgeist/scriptserver/scriptserver.h> #include <zeitgeist/fileserver/fileserver.h> #include <zeitgeist/logserver/logserver.h> using namespace std; namespace kerosin { class MapHolder { public: //! this structure will be used to map program names to OpenGL IDs #if HAVE_HASH_MAP typedef hash_map<string, unsigned int> TProgramCache; #else typedef map<string, unsigned int> TProgramCache; #endif TProgramCache mPrograms; }; } using namespace boost; using namespace kerosin; using namespace zeitgeist; OpenGLServer::OpenGLServer() : Leaf(), mExtensionReg(new GLExtensionReg()), mWantsToQuit(false), mHolder( new MapHolder() ) { } OpenGLServer::~OpenGLServer() { } boost::shared_ptr<GLExtensionReg> OpenGLServer::GetExtensionReg() const { return mExtensionReg; } void OpenGLServer::Quit() { mWantsToQuit = true; } bool OpenGLServer::WantsToQuit() const { return mWantsToQuit; } void OpenGLServer::Update() { if (mGLSystem.get() == 0) { return; } mGLSystem->Update(); } void OpenGLServer::SwapBuffers() const { if (mGLSystem.get() == 0) { return; } mGLSystem->SwapBuffers(); } unsigned int OpenGLServer::LoadARBProgram(GLenum /*target*/, const char* /*fileName*/) { #if 0 // only try to load stuff if the extension is supported if (!mExtensionReg->Has_GL_ARB_vertex_program()) { return 0; } // before actually loading, try the cache MapHolder::TProgramCache::iterator entry = mHolder->mPrograms.find(fileName); if (entry != mHolder->mPrograms.end()) { // we already have a match return (*entry).second; } unsigned int id = 0; // open file shared_ptr<FileServer> fileServer = shared_static_cast<FileServer>(GetCore()->Get("/sys/server/file")); salt::RFile *file = fileServer->Open(fileName); if (!file) return 0; unsigned char *buffer = new unsigned char[file->Size()+1]; file->Read(buffer, file->Size()); glGenProgramsARB(1, &id); glBindProgramARB(target, id); // try to load the actual program glProgramStringARB(target, GL_PROGRAM_FORMAT_ASCII_ARB, file->Size(), buffer); // free memory delete file; delete []buffer; const unsigned char* error = glGetString(GL_PROGRAM_ERROR_STRING_ARB); // if an error occured, display error message if (error[0] != 0) { int i; glDeleteProgramsARB(1, &id); glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &i); GetCore()->GetLogServer()->Error() << "ERROR: Loading ARB program (Pos: " << i << ")..." << endl; GetCore()->GetLogServer()->Error() << " => " << error << endl; return 0; } // enter program into the cache mHolder->mPrograms[fileName] = id; return id; #else return 0; #endif } unsigned int OpenGLServer::LoadARBVertexProgram(const char* fileName) { // only try to load stuff if the extension is supported if (!mExtensionReg->Has_GL_ARB_vertex_program()) { return 0; } return LoadARBProgram(GL_VERTEX_PROGRAM_ARB, fileName); } unsigned int OpenGLServer::LoadARBFragmentProgram(const char* /*fileName*/) { // only try to load stuff if the extension is supported // if (!mExtensionReg->Has_GL_ARB_fragment_program()) // { // return 0; // } // return LoadARBProgram(GL_FRAGMENT_PROGRAM_ARB, fileName); return 0; } bool OpenGLServer::Init(const string& openGLSysName) { GetLog()->Normal() << "(OpenGLServer) Init " << openGLSysName << "\n"; mGLSystem.reset(); if (! openGLSysName.empty()) { // create the OpenGLSystem mGLSystem = shared_dynamic_cast<OpenGLSystem> (GetCore()->New(openGLSysName)); if(mGLSystem.get() == 0) { // could not create OpenGLSystem GetLog()->Error() << "(OpenGLServer) ERROR: unable to create " << openGLSysName << "\n"; return false; } if (mGLSystem->Init() == false) { GetLog()->Error() << "(InputServer) ERROR: unable to initialize " << openGLSysName << "\n"; return false; } } mExtensionReg->Init(); // if (!mExtensionReg->Has_GL_ARB_vertex_program() || !mExtensionReg->Has_GL_ARB_fragment_program()) // { // GetLog()->Normal() << "WARNING: GL_ARB_vertex_program not supported. " // << "disabling fancy lighting\n" << endl; mSupportsFancyLighting = false; // prepare the set of available lights for (int i=0;i<GL_MAX_LIGHTS;++i) { mAvailableLights.insert(GL_LIGHT0+i); } return true; } /*! Set up the OpenGL viewport, initialize extension registry */ bool OpenGLServer::ConstructInternal() { return true; } void OpenGLServer::ToggleFancyLighting() { if (mSupportsFancyLighting) mSupportsFancyLighting = false; else mSupportsFancyLighting = true; } int OpenGLServer::AllocLight() { if (mAvailableLights.size() == 0) { return -1; } TLightSet::iterator iter = mAvailableLights.begin(); int l = (*iter); mAvailableLights.erase(iter); return l; } void OpenGLServer::PutLight(int l) { glDisable(l); mAvailableLights.insert(l); } --- NEW FILE: openglserver_c.cpp --- #include "openglserver.h" using namespace std; using namespace boost; using namespace kerosin; using namespace zeitgeist; FUNCTION(OpenGLServer,init) { string openGLSysName; return ( (in.GetSize() == 1) && (in.GetValue(in.begin(), openGLSysName)) && (obj->Init(openGLSysName)) ); } void CLASS(OpenGLServer)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Leaf); DEFINE_FUNCTION(init); } --- NEW FILE: glextensionreg.cpp --- #line 241 "utility/glextgen/script/glbackend.rb" #include "glextensionreg.h" using namespace kerosin; #line 2 "utility/glextgen/tocopy/cpp_begin.txt" #include <string.h> #if !defined(_WIN32) #include <GL/glx.h> #include <GL/glxext.h> #endif #define GET_PROC_ADDRESS(ptr, function) function = (ptr)GetProcedure( #function ); if (function == NULL) return false; void* GetProcedure(const char *name) { #if defined(_WIN32) void *t = wglGetProcAddress(name); [...3385 lines suppressed...] wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) GetProcedure("wglGetExtensionsStringEXT"); mExtensions.mWGL_ARB_extensions_string = wglGetExtensionsStringARB != NULL; mExtensions.mWGL_EXT_extensions_string = wglGetExtensionsStringEXT != NULL; #line 304 "utility/glextgen/script/glbackend.rb" #endif //_WIN32 if (ext) memcpy(ext, &mExtensions, sizeof(GLExtGenExtensions)); if (funPtr) { #line 313 "utility/glextgen/script/glbackend.rb" #if defined(_WIN32) #line 316 "utility/glextgen/script/glbackend.rb" #endif //_WIN32 } } --- NEW FILE: openglserver.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: openglserver.h,v 1.1 2005/12/05 21:38:23 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_OPENGLSERVER_H #define KEROSIN_OPENGLSERVER_H #include <string> #include <set> #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> #include "glextensionreg.h" namespace kerosin { #if 0 } #endif class MapHolder; class OpenGLSystem; class OpenGLServer : public zeitgeist::Leaf { // // types // protected: //! this structure will be used to map program names to OpenGL IDs // #if HAVE_HASH_MAP // typedef std::hash_map<std::string, unsigned int> TProgramCache; // #else // typedef std::map<std::string, unsigned int> TProgramCache; // #endif //! set of OpenGL light constants typedef std::set<int> TLightSet; // // functions // public: OpenGLServer(); ~OpenGLServer(); /** Initializes the OpenGLServer and sets up the OpenGLSystem with the given class name. Passing an empty string for openGLSysName is correct. In this case OpenGLServer assumes, that the OpenGL context is already setup */ bool Init(const std::string& openGLSysName); boost::shared_ptr<GLExtensionReg> GetExtensionReg() const; //! if this is called, the application will 'want to quit' void Quit(); //! true if somebody called 'Quit' bool WantsToQuit() const; //! pump event loop of OpenGLSubSystem void Update(); //! swap opengl buffer void SwapBuffers() const; //! vertex and fragment program loading unsigned int LoadARBProgram(GLenum target, const char* fileName); //! vertex and fragment program loading unsigned int LoadARBVertexProgram(const char* fileName); //! vertex and fragment program loading unsigned int LoadARBFragmentProgram(const char* fileName); bool SupportsFancyLighting() const { return mSupportsFancyLighting; } void ToggleFancyLighting(); /** returns the next availble GL light constant or -1 if no more lights are available */ int AllocLight(); /** marks the GL light constant as available */ void PutLight(int l); protected: //! set up opengl viewport virtual bool ConstructInternal(); // // members // protected: //! this contains information on all available extensions boost::shared_ptr<GLExtensionReg> mExtensionReg; //! a flag, which can be used to control the shutdown of the display window and the application bool mWantsToQuit; //! cache of loaded vertex and fragment programs (assumes that path names to the programs are unique) boost::shared_ptr< MapHolder > mHolder; //! flag whether the OpenGL-driver can do fancy lighting or not bool mSupportsFancyLighting; //! the set of available OpenGL light constants TLightSet mAvailableLights; //! the OpenGL subsystem used boost::shared_ptr<OpenGLSystem> mGLSystem; }; DECLARE_CLASS(OpenGLServer); } //namespace kerosin #endif //KEROSIN_OPENGLSERVER_H |
Update of /cvsroot/simspark/simspark/spark/kerosin/inputserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/inputserver Added Files: .cvsignore inputcontrol.cpp inputcontrol.h inputcontrol_c.cpp inputdevice.cpp inputdevice.h inputdevice_c.cpp inputitem.cpp inputitem.h inputitem_c.cpp inputserver.cpp inputserver.h inputserver_c.cpp inputsystem.cpp inputsystem.h inputsystem_c.cpp scancodemap.cpp scancodemap.h Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs --- NEW FILE: inputsystem_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: inputsystem_c.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inputsystem.h" using namespace kerosin; void CLASS(InputSystem)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Node); } --- NEW FILE: inputcontrol.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: inputcontrol.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_INPUTCONTROL_H #define KEROSIN_INPUTCONTROL_H #include <oxygen/simulationserver/simcontrolnode.h> #include <kerosin/inputserver/inputserver.h> namespace oxygen { class FPSController; } namespace kerosin { /** \class InputControl is a SimControlNode that processes any pending input events from the InputServer at the begin of each simulation cycle. It defines and handles a set of default events and can be customized by registering InputItems to it. If set, InputControl disables the automatic time stepping of the SimulationServer and steps the simulation using the real time passed. */ class InputControl : public oxygen::SimControlNode { public: // define common input constants enum ECmds { CmdTimer = 1, CmdMouseX = 2, CmdMouseY = 3, CmdUp = 4, CmdDown = 5, CmdLeft = 6, CmdRight = 7, CmdForward = 8, CmdBackward = 9, CmdMouseLook = 10, CmdQuit = 11, // first user defined input constant CmdUser = 12 }; public: InputControl(); virtual ~InputControl(); /** sets the location of the FPS Controller to be used */ bool SetFPSController(const std::string& path); /** sets the FPSController to be used */ void SetFPSController(boost::shared_ptr<oxygen::FPSController> controller); /** sets the horizontal mouse sensitivity */ void SetHorizontalSensitivity(float s); /** returns the horizontal mouse sensitivity */ float GetHorizontalSensitivity(); /** sets the horizontal mouse sensitivity */ void SetVerticalSensitivity(float s); /** returns the vertical mouse sensitivity */ float GetVerticalSensitivity(); /** returns the size of the last time step */ float GetDeltaTime(); /** if set the deltatime read from the InputServer is automatically passed to the SimulationServer. The automatic time stepping of the SimulationServer is disabled and this ControlNode takes the responsibility to advance the time, default true. This useful if the simulation speed should be locked to the real time passed. */ void SetAdvanceTime(bool advance); /** returns the advance time mode */ bool GetAdvanceTime(); /** called once when the simulation is started */ virtual void InitSimulation(); /** processes pending input events at the start of each simulation cycle */ virtual void StartCycle(); /** This function creates an instance of class 'inputItem' and adds it as a child node below this control node */ bool RegisterInputItem(const std::string& inputItem, const std::string& name); protected: virtual void OnLink(); virtual void OnUnlink(); protected: /** the controlled FPSController */ boost::shared_ptr<oxygen::FPSController> mFPSController; /** cached reference to the InputServer */ boost::shared_ptr<kerosin::InputServer> mInputServer; /** the size of the last time step */ float mDeltaTime; /** horizontal mouse sensitivity */ float mHorSens; /** vertical mouse sensitivity */ float mVertSens; /** true, if the deltatime read from the InputServer is automatically passed to the SimulationServer. */ bool mAdvanceTime; /** true, if mouse look is currently activated */ bool mMouseLook; }; DECLARE_CLASS(InputControl); } // namespace kerosin #endif // KEROSIN_INPUTCONTROL_H --- NEW FILE: inputdevice.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: inputdevice.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_INPUTDEVICE_H #define KEROSIN_INPUTDEVICE_H /* \class InputDevice InputDevice An InputDevice is the abstract base class which creates input for the inputserver. Common InputDevice would be the Keyboard and Mouse, but less common 'devices' such as AI agents (think of them pushing the controls) or time are also possible. The input devices are managed by the input server. As the application only communicates with the input server in general this makes adding new input devices transparent to the application (Good Thing(TM)). HISTORY: 21.08.02 - MK - Initial version */ #include <zeitgeist/leaf.h> #include "inputsystem.h" namespace kerosin { class InputDevice : public zeitgeist::Leaf { // // functions // public: InputDevice(); ~InputDevice(); //! init the device virtual bool Init(kerosin::InputSystem* inputSystem); // // members // protected: InputSystem* mInputSystem; }; DECLARE_CLASS(InputDevice); } //namespace kerosin #endif //KEROSIN_INPUTDEVICE_H --- NEW FILE: inputcontrol_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: inputcontrol_c.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inputcontrol.h" using namespace kerosin; using namespace std; FUNCTION(InputControl, setAdvanceTime) { bool inAdvance; if ( (in.GetSize() != 1) || (! in.GetValue(in[0], inAdvance)) ) { return false; } obj->SetAdvanceTime(inAdvance); return true; } FUNCTION(InputControl, getAdvanceTime) { return obj->GetAdvanceTime(); } FUNCTION(InputControl,setFPSController) { string inPath; if ( (in.GetSize() != 1) || (! in.GetValue(in[0], inPath)) ) { return false; } obj->SetFPSController(inPath); return true; } void CLASS(InputControl)::DefineClass() { DEFINE_BASECLASS(oxygen/SimControlNode); DEFINE_FUNCTION(setAdvanceTime); DEFINE_FUNCTION(getAdvanceTime); DEFINE_FUNCTION(setFPSController); } --- NEW FILE: inputitem.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: inputitem.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_INPUTITEM_H #define KEROSIN_INPUTITEM_H #include <boost/shared_ptr.hpp> #include "inputserver.h" #include <zeitgeist/leaf.h> namespace kerosin { /** InputItem is the base class for all nodes installed below the Spark InputControl node. This serves as a hook mechanism to register custom command ids to the InputServer and to process them */ class InputItem : public zeitgeist::Leaf { public: InputItem(); virtual ~InputItem(); /** this method is called every time an input unknown to the parent InputControl node is received */ virtual void ProcessInput(const InputServer::Input& input) = 0; }; DECLARE_ABSTRACTCLASS(InputItem); } // namespace kerosin #endif // KEROSIN_INPUTITEM_H --- NEW FILE: inputcontrol.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: inputcontrol.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inputcontrol.h" #include "inputitem.h" #include <oxygen/simulationserver/simulationserver.h> #include <oxygen/sceneserver/fpscontroller.h> #include <zeitgeist/logserver/logserver.h> #include <zeitgeist/scriptserver/scriptserver.h> using namespace kerosin; using namespace oxygen; using namespace zeitgeist; using namespace boost; using namespace std; InputControl::InputControl() { mDeltaTime = 0; mHorSens = 0.3; mVertSens = 0.3; mAdvanceTime = true; mMouseLook = false; } InputControl::~InputControl() { } bool InputControl::SetFPSController(const std::string& path) { if (path.empty()) { mFPSController.reset(); return true; } shared_ptr<Leaf> leaf = GetCore()->Get(path); if (leaf.get() == 0) { GetLog()->Error() << "(InputControl) ERROR: invalid path " << path << "'\n"; return false; } mFPSController = shared_dynamic_cast<FPSController> (GetCore()->Get(path)); if (mFPSController.get() == 0) { // the path is valid but doesn't point to an FPSController; // for convenience search below for a controller mFPSController = leaf->FindChildSupportingClass<FPSController>(true); } if (mFPSController.get() == 0) { GetLog()->Error() << "(InputControl) ERROR: no FPSController found at '" << path << "'\n"; return false; } return true; } void InputControl::SetFPSController(shared_ptr<FPSController> controller) { mFPSController = controller; } void InputControl::OnLink() { shared_ptr<ScriptServer> scriptServer = GetCore()->GetScriptServer(); // publish common command constants to the scripts scriptServer->CreateVariable("Command.Quit", CmdQuit); scriptServer->CreateVariable("Command.Timer", CmdTimer); scriptServer->CreateVariable("Command.MouseX", CmdMouseX); scriptServer->CreateVariable("Command.MouseY", CmdMouseY); scriptServer->CreateVariable("Command.Left", CmdLeft); scriptServer->CreateVariable("Command.Right", CmdRight); scriptServer->CreateVariable("Command.Forward", CmdForward); scriptServer->CreateVariable("Command.Backward", CmdBackward); scriptServer->CreateVariable("Command.Up", CmdUp); scriptServer->CreateVariable("Command.Down", CmdDown); scriptServer->CreateVariable("Command.Mouselook", CmdMouseLook); mInputServer = shared_dynamic_cast<InputServer> (GetCore()->Get("/sys/server/input")); if (mInputServer.get() == 0) { GetLog()->Error() << "(InputControl) ERROR: InputServer not found\n"; } } void InputControl::OnUnlink() { // we have to make sure, the inputServer is shut down before the // opengl server, as the opengl server shuts down SDL ... this // will conflict with the input server mInputServer->Unlink(); mInputServer.reset(); mFPSController.reset(); } void InputControl::SetHorizontalSensitivity(float s) { mHorSens = s; } void InputControl::SetVerticalSensitivity(float s) { mVertSens = s; } float InputControl::GetHorizontalSensitivity() { return mHorSens; } float InputControl::GetVerticalSensitivity() { return mVertSens; } void InputControl::InitSimulation() { if (mAdvanceTime) { // this node will step the simulation time GetSimulationServer()->SetAutoTimeMode(false); } } void InputControl::StartCycle() { // Process incoming input mDeltaTime = 0.0f; static InputServer::Input input; while (mInputServer->GetInput(input)) { switch (input.id) { case CmdQuit: GetSimulationServer()->Quit(); break; case CmdMouseLook: mMouseLook = (input.data.l == 1); break; case CmdTimer: mDeltaTime = (float) input.data.l/1000.0f; break; case CmdMouseX: if ( (mMouseLook) && (mFPSController.get() != 0) ) { mFPSController->AdjustHAngle(mHorSens*(float)input.data.l); } break; case CmdMouseY: if ( (mMouseLook) && (mFPSController.get() != 0) ) { mFPSController->AdjustVAngle(mVertSens*(float)input.data.l); } break; case CmdUp: if (mFPSController.get() != 0) { mFPSController->Up(input.data.l!=0); } break; case CmdDown: if (mFPSController.get() != 0) { mFPSController->Down(input.data.l!=0); } break; case CmdLeft: if (mFPSController.get() != 0) { mFPSController->StrafeLeft(input.data.l!=0); } break; case CmdRight: if (mFPSController.get() != 0) { mFPSController->StrafeRight(input.data.l!=0); } break; case CmdForward: if (mFPSController.get() != 0) { mFPSController->Forward(input.data.l!=0); } break; case CmdBackward: if (mFPSController.get() != 0) { mFPSController->Backward(input.data.l!=0); } break; default: // pass unknown events on to the registered InputItems TLeafList items; ListChildrenSupportingClass<InputItem>(items); for ( TLeafList::iterator iter = items.begin(); iter != items.end(); ++iter ) { shared_static_cast<InputItem>(*iter) ->ProcessInput(input); } break; } } if (mAdvanceTime) { // pass the delta time on to the SimulationServer GetSimulationServer()->AdvanceTime(mDeltaTime); } } float InputControl::GetDeltaTime() { return mDeltaTime; } void InputControl::SetAdvanceTime(bool advance) { mAdvanceTime = advance; } bool InputControl::GetAdvanceTime() { return mAdvanceTime; } bool InputControl::RegisterInputItem(const string& inputItemName, const string& name) { // check if a input item of the requested type was already created shared_ptr<InputItem> inputItem = shared_dynamic_cast<InputItem>(GetChildOfClass(inputItemName)); if (inputItem.get() != 0) { return true; } // create the input item inputItem = shared_dynamic_cast<InputItem>(GetCore()->New(inputItemName)); if (inputItem.get() == 0) { GetLog()->Error() << "ERROR: (InputControl) Cannot create input item '" << inputItemName << "'" << std::endl; return false; } // link the input item in the hierarchy inputItem->SetName(name); if (! AddChildReference(inputItem)) { GetLog()->Error() << "ERROR: (InputControl) Cannot link the input item '" << inputItemName << "' to the hierarchy\n"; return false; } GetLog()->Debug() << "(InputControl) Registered input item '" << inputItemName << "'\n"; return true; } --- NEW FILE: inputsystem.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: inputsystem.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_INPUTSYSTEM_H #define KEROSIN_INPUTSYSTEM_H /* \class InputSystem An input system is the basic abstraction for an input API. You would want to have a specific input system for SDL, DirectX, Windows API, X, etc.. The job of InputSystem is: - Initialize the input API - Initialize the inputcodes used in the InputServer - Handle the creation of individual devices HISTORY: 21.08.02 - MK - Initial version */ #include "inputserver.h" #include <deque> #include <zeitgeist/node.h> namespace kerosin { class InputSystem : public zeitgeist::Node { // // functions // public: InputSystem(); virtual ~InputSystem(); //! init the subsystem virtual bool Init(kerosin::InputServer* inputServer); /** creates an instance of a device via zeitgeist object creation. Should use name mangling. */ virtual bool CreateDevice(const std::string& deviceName) = 0; /** Add the input to the queue. Uses AddInputInternal. This was necessary to allow derived classes to wrap this call in a mutex and use the definitely unwrapped addition via AddInputInternal(). */ virtual void AddInput(InputServer::Input& input); /** this is the actual addition of input to the queue. It should only be used by InputDevices! */ void AddInputInternal(InputServer::Input& input); //! retrieve an input from the queue virtual bool GetInput(InputServer::Input& input); InputServer* GetInputServer() { return mInputServer; } protected: virtual bool UpdateTimerInput(InputServer::Input &input); // // members // protected: InputServer* mInputServer; private: std::deque<InputServer::Input> mInputQueue; }; DECLARE_ABSTRACTCLASS(InputSystem); } // namespace kerosin #endif //KEROSIN_INPUTSYSTEM_H --- NEW FILE: inputserver_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: inputserver_c.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inputserver.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; using namespace std; FUNCTION(InputServer,init) { string inInputSysName; return ( (in.GetSize() == 1) && (in.GetValue(in.begin(), inInputSysName)) && (obj->Init(inInputSysName)) ); } FUNCTION(InputServer,createDevice) { string inDeviceName; return ( (in.GetSize() == 1) && (in.GetValue(in.begin(), inDeviceName)) && (obj->CreateDevice(inDeviceName)) ); } FUNCTION(InputServer,reset) { obj->Reset(); return true; } FUNCTION(InputServer,bindCommand) { string inDesc; int inCmd; return( (in.GetSize() == 2) && (in.GetValue(in[0], inDesc)) && (in.GetValue(in[1], inCmd)) && (obj->BindCommand(inDesc,inCmd)) ); } FUNCTION(InputServer,setScanCodeMapping) { string inName; if ( (in.GetSize() != 1) || (! in.GetValue(in.begin(),inName)) ) { return false; } obj->SetScanCodeMapping(inName); return true; } FUNCTION(InputServer,addCode) { int inIc; string inName; int inNoMod; int inShiftMod; int inAltMod; if ( (in.GetSize() != 5) || (! in.GetValue(in[0],inIc)) || (! in.GetValue(in[1],inName)) || (! in.GetValue(in[2],inNoMod)) || (! in.GetValue(in[3],inShiftMod)) || (! in.GetValue(in[4],inAltMod)) ) { return false; } obj->AddCode(inIc,inName,inNoMod,inShiftMod,inAltMod); return true; } void CLASS(InputServer)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Node); DEFINE_FUNCTION(init); DEFINE_FUNCTION(createDevice); DEFINE_FUNCTION(reset); DEFINE_FUNCTION(bindCommand); DEFINE_FUNCTION(setScanCodeMapping); DEFINE_FUNCTION(addCode); } --- NEW FILE: inputdevice_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: inputdevice_c.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inputdevice.h" using namespace kerosin; void CLASS(InputDevice)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Leaf); } --- NEW FILE: inputitem.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: inputitem.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inputitem.h" using namespace kerosin; InputItem::InputItem() { } InputItem::~InputItem() { } --- NEW FILE: inputdevice.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2004 RoboCup Soccer Server 3D Maintenance Group $Id: inputdevice.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inputdevice.h" using namespace kerosin; using namespace zeitgeist; InputDevice::InputDevice() : mInputSystem(0) { } InputDevice::~InputDevice() { } bool InputDevice::Init(kerosin::InputSystem* inputSystem) { mInputSystem = inputSystem; return (mInputSystem != 0); } --- NEW FILE: inputsystem.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2004 RoboCup Soccer Server 3D Maintenance Group $Id: inputsystem.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inputsystem.h" using namespace kerosin; using namespace zeitgeist; InputSystem::InputSystem() : mInputServer(NULL) { } InputSystem::~InputSystem() { } bool InputSystem::Init(kerosin::InputServer* inputServer) { mInputServer = inputServer; return (mInputServer != 0); } void InputSystem::AddInput(InputServer::Input& input) { AddInputInternal(input); } bool InputSystem::GetInput(InputServer::Input& input) { static bool hasDoneTimer = false; if (mInputQueue.size() > 0) { input = mInputQueue.front(); mInputQueue.pop_front(); return true; } if (!hasDoneTimer) { hasDoneTimer = true; return UpdateTimerInput(input); } else { hasDoneTimer = false; return false; } } void InputSystem::AddInputInternal(InputServer::Input& input) { mInputQueue.push_back(input); } bool InputSystem::UpdateTimerInput(InputServer::Input &/*input*/) { return false; } --- NEW FILE: inputserver.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: inputserver.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "inputserver.h" #include "inputsystem.h" #include "inputdevice.h" #include "scancodemap.h" #include <zeitgeist/logserver/logserver.h> #include <zeitgeist/scriptserver/scriptserver.h> #include <sstream> using namespace boost; using namespace kerosin; using namespace std; using namespace zeitgeist; const InputServer::TInputCode InputServer::IC_1 = 0x02; const InputServer::TInputCode InputServer::IC_2 = 0x03; const InputServer::TInputCode InputServer::IC_3 = 0x04; const InputServer::TInputCode InputServer::IC_4 = 0x05; const InputServer::TInputCode InputServer::IC_5 = 0x06; const InputServer::TInputCode InputServer::IC_6 = 0x07; const InputServer::TInputCode InputServer::IC_7 = 0x08; const InputServer::TInputCode InputServer::IC_8 = 0x09; const InputServer::TInputCode InputServer::IC_9 = 0x0a; const InputServer::TInputCode InputServer::IC_0 = 0x0b; // function keys const InputServer::TInputCode InputServer::IC_F1 = 0x3b; const InputServer::TInputCode InputServer::IC_F2 = 0x3c; const InputServer::TInputCode InputServer::IC_F3 = 0x3d; const InputServer::TInputCode InputServer::IC_F4 = 0x3e; const InputServer::TInputCode InputServer::IC_F5 = 0x3f; const InputServer::TInputCode InputServer::IC_F6 = 0x40; const InputServer::TInputCode InputServer::IC_F7 = 0x41; const InputServer::TInputCode InputServer::IC_F8 = 0x42; const InputServer::TInputCode InputServer::IC_F9 = 0x43; const InputServer::TInputCode InputServer::IC_F10 = 0x44; const InputServer::TInputCode InputServer::IC_F11 = 0x57; const InputServer::TInputCode InputServer::IC_F12 = 0x58; // alphabet const InputServer::TInputCode InputServer::IC_A = 0x1e; const InputServer::TInputCode InputServer::IC_B = 0x30; const InputServer::TInputCode InputServer::IC_C = 0x2e; const InputServer::TInputCode InputServer::IC_D = 0x20; const InputServer::TInputCode InputServer::IC_E = 0x12; const InputServer::TInputCode InputServer::IC_F = 0x21; const InputServer::TInputCode InputServer::IC_G = 0x22; const InputServer::TInputCode InputServer::IC_H = 0x23; const InputServer::TInputCode InputServer::IC_I = 0x17; const InputServer::TInputCode InputServer::IC_J = 0x24; const InputServer::TInputCode InputServer::IC_K = 0x25; const InputServer::TInputCode InputServer::IC_L = 0x26; const InputServer::TInputCode InputServer::IC_M = 0x32; const InputServer::TInputCode InputServer::IC_N = 0x31; const InputServer::TInputCode InputServer::IC_O = 0x18; const InputServer::TInputCode InputServer::IC_P = 0x19; const InputServer::TInputCode InputServer::IC_Q = 0x10; const InputServer::TInputCode InputServer::IC_R = 0x13; const InputServer::TInputCode InputServer::IC_S = 0x1f; const InputServer::TInputCode InputServer::IC_T = 0x14; const InputServer::TInputCode InputServer::IC_U = 0x16; const InputServer::TInputCode InputServer::IC_V = 0x2f; const InputServer::TInputCode InputServer::IC_W = 0x11; const InputServer::TInputCode InputServer::IC_X = 0x2d; const InputServer::TInputCode InputServer::IC_Y = 0x15; const InputServer::TInputCode InputServer::IC_Z = 0x2c; // keypad const InputServer::TInputCode InputServer::IC_KP0 = 0x52; const InputServer::TInputCode InputServer::IC_KP1 = 0x4f; const InputServer::TInputCode InputServer::IC_KP2 = 0x50; const InputServer::TInputCode InputServer::IC_KP3 = 0x51; const InputServer::TInputCode InputServer::IC_KP4 = 0x4b; const InputServer::TInputCode InputServer::IC_KP5 = 0x4c; const InputServer::TInputCode InputServer::IC_KP6 = 0x4d; const InputServer::TInputCode InputServer::IC_KP7 = 0x47; const InputServer::TInputCode InputServer::IC_KP8 = 0x48; const InputServer::TInputCode InputServer::IC_KP9 = 0x49; const InputServer::TInputCode InputServer::IC_KP_DECIMAL = 0x53; const InputServer::TInputCode InputServer::IC_KP_DIVIDE = 0xb5; const InputServer::TInputCode InputServer::IC_KP_MULTIPLY = 0x37; const InputServer::TInputCode InputServer::IC_KP_MINUS = 0x4a; const InputServer::TInputCode InputServer::IC_KP_PLUS = 0x4e; const InputServer::TInputCode InputServer::IC_KP_ENTER = 0x8d; // arrows + home/end pad const InputServer::TInputCode InputServer::IC_UP = 0xc8; const InputServer::TInputCode InputServer::IC_DOWN = 0xd0; const InputServer::TInputCode InputServer::IC_LEFT = 0xcb; const InputServer::TInputCode InputServer::IC_RIGHT = 0xcd; const InputServer::TInputCode InputServer::IC_INSERT = 0xd2; const InputServer::TInputCode InputServer::IC_DELETE = 0xd3; const InputServer::TInputCode InputServer::IC_HOME = 0xc7; const InputServer::TInputCode InputServer::IC_END = 0xcf; const InputServer::TInputCode InputServer::IC_PAGEUP = 0xc9; const InputServer::TInputCode InputServer::IC_PAGEDOWN = 0xd1; // key state modifier keys const InputServer::TInputCode InputServer::IC_NUMLOCK = 0x45; const InputServer::TInputCode InputServer::IC_CAPSLOCK = 0x3a; const InputServer::TInputCode InputServer::IC_SCROLLOCK = 0x46; const InputServer::TInputCode InputServer::IC_LSHIFT = 0x2a; const InputServer::TInputCode InputServer::IC_RSHIFT = 0x36; const InputServer::TInputCode InputServer::IC_LCTRL = 0x1d; const InputServer::TInputCode InputServer::IC_RCTRL = 0x9d; const InputServer::TInputCode InputServer::IC_LALT = 0x38; const InputServer::TInputCode InputServer::IC_RALT = 0xb8; const InputServer::TInputCode InputServer::IC_LSUPER = 0xdb; // Left "Windows" key const InputServer::TInputCode InputServer::IC_RSUPER = 0xdc; // Right "Windows" key // other keys (cursor control, punctuation) const InputServer::TInputCode InputServer::IC_ESCAPE = 0x01; const InputServer::TInputCode InputServer::IC_PRINT = 0xb7; const InputServer::TInputCode InputServer::IC_PAUSE = 0xc5; const InputServer::TInputCode InputServer::IC_GRAVE = 0x29; const InputServer::TInputCode InputServer::IC_MINUS = 0x0c; const InputServer::TInputCode InputServer::IC_EQUALS = 0x0d; const InputServer::TInputCode InputServer::IC_BACKSLASH = 0x2b; const InputServer::TInputCode InputServer::IC_BACKSPACE = 0x0e; const InputServer::TInputCode InputServer::IC_TAB = 0x0f; const InputServer::TInputCode InputServer::IC_LBRACKET = 0x1a; const InputServer::TInputCode InputServer::IC_RBRACKET = 0x1b; const InputServer::TInputCode InputServer::IC_RETURN = 0x1c; const InputServer::TInputCode InputServer::IC_SEMICOLON = 0x27; const InputServer::TInputCode InputServer::IC_APOSTROPHE= 0x28; const InputServer::TInputCode InputServer::IC_OEM_102 = 0x56; // German <>| const InputServer::TInputCode InputServer::IC_COMMA = 0x33; const InputServer::TInputCode InputServer::IC_PERIOD = 0x34; const InputServer::TInputCode InputServer::IC_SLASH = 0x35; const InputServer::TInputCode InputServer::IC_SPACE = 0x39; // mouse buttons const InputServer::TInputCode InputServer::IC_MOUSE_LEFT = 0x1000; // left const InputServer::TInputCode InputServer::IC_MOUSE_RIGHT = 0x1001; // right const InputServer::TInputCode InputServer::IC_MOUSE_MIDDLE = 0x1002; // middle //mouse axis const InputServer::TInputCode InputServer::IC_AXISX = 0x2000; const InputServer::TInputCode InputServer::IC_AXISY = 0x2001; const InputServer::TInputCode InputServer::IC_AXISZ = 0x2002; // timer const InputServer::TInputCode InputServer::IC_AXIST = 0x3000; InputServer::InputServer() : Node(), mModifierState(eNone), mScanCodeMap(new ScanCodeMap()) { // default to a german keyboard layout mScanCodeScript = "german.scan.rb"; } InputServer::~InputServer() { Reset(); } bool InputServer::Init(const std::string &inputSysName) { GetLog()->Normal() << "(InputServer) Init " << inputSysName << "\n"; Reset(); // push our variables into the scriptserver GetScript()->CreateVariable("Input.IC_1", IC_1); GetScript()->CreateVariable("Input.IC_2", IC_2); GetScript()->CreateVariable("Input.IC_3", IC_3); GetScript()->CreateVariable("Input.IC_4", IC_4); GetScript()->CreateVariable("Input.IC_5", IC_5); GetScript()->CreateVariable("Input.IC_6", IC_6); GetScript()->CreateVariable("Input.IC_7", IC_7); GetScript()->CreateVariable("Input.IC_8", IC_8); GetScript()->CreateVariable("Input.IC_9", IC_9); GetScript()->CreateVariable("Input.IC_0", IC_0); // function keys GetScript()->CreateVariable("Input.IC_F1", IC_F1); GetScript()->CreateVariable("Input.IC_F2", IC_F2); GetScript()->CreateVariable("Input.IC_F3", IC_F3); GetScript()->CreateVariable("Input.IC_F4", IC_F4); GetScript()->CreateVariable("Input.IC_F5", IC_F5); GetScript()->CreateVariable("Input.IC_F6", IC_F6); GetScript()->CreateVariable("Input.IC_F7", IC_F7); GetScript()->CreateVariable("Input.IC_F8", IC_F8); GetScript()->CreateVariable("Input.IC_F9", IC_F9); GetScript()->CreateVariable("Input.IC_F10", IC_F10); GetScript()->CreateVariable("Input.IC_F11", IC_F11); GetScript()->CreateVariable("Input.IC_F12", IC_F12); // alphabet GetScript()->CreateVariable("Input.IC_A", IC_A); GetScript()->CreateVariable("Input.IC_B", IC_B); GetScript()->CreateVariable("Input.IC_C", IC_C); GetScript()->CreateVariable("Input.IC_D", IC_D); GetScript()->CreateVariable("Input.IC_E", IC_E); GetScript()->CreateVariable("Input.IC_F", IC_F); GetScript()->CreateVariable("Input.IC_G", IC_G); GetScript()->CreateVariable("Input.IC_H", IC_H); GetScript()->CreateVariable("Input.IC_I", IC_I); GetScript()->CreateVariable("Input.IC_J", IC_J); GetScript()->CreateVariable("Input.IC_K", IC_K); GetScript()->CreateVariable("Input.IC_L", IC_L); GetScript()->CreateVariable("Input.IC_M", IC_M); GetScript()->CreateVariable("Input.IC_N", IC_N); GetScript()->CreateVariable("Input.IC_O", IC_O); GetScript()->CreateVariable("Input.IC_P", IC_P); GetScript()->CreateVariable("Input.IC_Q", IC_Q); GetScript()->CreateVariable("Input.IC_R", IC_R); GetScript()->CreateVariable("Input.IC_S", IC_S); GetScript()->CreateVariable("Input.IC_T", IC_T); GetScript()->CreateVariable("Input.IC_U", IC_U); GetScript()->CreateVariable("Input.IC_V", IC_V); GetScript()->CreateVariable("Input.IC_W", IC_W); GetScript()->CreateVariable("Input.IC_X", IC_X); GetScript()->CreateVariable("Input.IC_Y", IC_Y); GetScript()->CreateVariable("Input.IC_Z", IC_Z); // keypad GetScript()->CreateVariable("Input.IC_KP0", IC_KP0); GetScript()->CreateVariable("Input.IC_KP1", IC_KP1); GetScript()->CreateVariable("Input.IC_KP2", IC_KP2); GetScript()->CreateVariable("Input.IC_KP3", IC_KP3); GetScript()->CreateVariable("Input.IC_KP4", IC_KP4); GetScript()->CreateVariable("Input.IC_KP5", IC_KP5); GetScript()->CreateVariable("Input.IC_KP6", IC_KP6); GetScript()->CreateVariable("Input.IC_KP7", IC_KP7); GetScript()->CreateVariable("Input.IC_KP8", IC_KP8); GetScript()->CreateVariable("Input.IC_KP9", IC_KP9); GetScript()->CreateVariable("Input.IC_KP_DECIMAL", IC_KP_DECIMAL); GetScript()->CreateVariable("Input.IC_KP_DIVIDE", IC_KP_DIVIDE); GetScript()->CreateVariable("Input.IC_KP_MULTIPLY", IC_KP_MULTIPLY); GetScript()->CreateVariable("Input.IC_KP_MINUS", IC_KP_MINUS); GetScript()->CreateVariable("Input.IC_KP_PLUS", IC_KP_PLUS); GetScript()->CreateVariable("Input.IC_KP_ENTER", IC_KP_ENTER); // arrows + home/end pad GetScript()->CreateVariable("Input.IC_UP", IC_UP); GetScript()->CreateVariable("Input.IC_DOWN", IC_DOWN); GetScript()->CreateVariable("Input.IC_LEFT", IC_LEFT); GetScript()->CreateVariable("Input.IC_RIGHT", IC_RIGHT); GetScript()->CreateVariable("Input.IC_INSERT", IC_INSERT); GetScript()->CreateVariable("Input.IC_DELETE", IC_DELETE); GetScript()->CreateVariable("Input.IC_HOME", IC_HOME); GetScript()->CreateVariable("Input.IC_END", IC_END); GetScript()->CreateVariable("Input.IC_PAGEUP", IC_PAGEUP); GetScript()->CreateVariable("Input.IC_PAGEDOWN", IC_PAGEDOWN); // key state modifier keys GetScript()->CreateVariable("Input.IC_NUMLOCK", IC_NUMLOCK); GetScript()->CreateVariable("Input.IC_CAPSLOCK", IC_CAPSLOCK); GetScript()->CreateVariable("Input.IC_SCROLLOCK", IC_SCROLLOCK); GetScript()->CreateVariable("Input.IC_LSHIFT", IC_LSHIFT); GetScript()->CreateVariable("Input.IC_RSHIFT", IC_RSHIFT); GetScript()->CreateVariable("Input.IC_LCTRL", IC_LCTRL); GetScript()->CreateVariable("Input.IC_RCTRL", IC_RCTRL); GetScript()->CreateVariable("Input.IC_LALT", IC_LALT); GetScript()->CreateVariable("Input.IC_RALT", IC_RALT); GetScript()->CreateVariable("Input.IC_LSUPER", IC_LSUPER); // Left "Windows" key GetScript()->CreateVariable("Input.IC_RSUPER", IC_RSUPER); // Right "Windows" key // other keys (cursor control, punctuation) GetScript()->CreateVariable("Input.IC_ESCAPE", IC_ESCAPE); GetScript()->CreateVariable("Input.IC_PRINT", IC_PRINT); GetScript()->CreateVariable("Input.IC_PAUSE", IC_PAUSE); GetScript()->CreateVariable("Input.IC_GRAVE", IC_GRAVE); GetScript()->CreateVariable("Input.IC_MINUS", IC_MINUS); GetScript()->CreateVariable("Input.IC_EQUALS", IC_EQUALS); GetScript()->CreateVariable("Input.IC_BACKSLASH", IC_BACKSLASH); GetScript()->CreateVariable("Input.IC_BACKSPACE", IC_BACKSPACE); GetScript()->CreateVariable("Input.IC_TAB", IC_TAB); GetScript()->CreateVariable("Input.IC_LBRACKET", IC_LBRACKET); GetScript()->CreateVariable("Input.IC_RBRACKET", IC_RBRACKET); GetScript()->CreateVariable("Input.IC_RETURN", IC_RETURN); GetScript()->CreateVariable("Input.IC_SEMICOLON", IC_SEMICOLON); GetScript()->CreateVariable("Input.IC_APOSTROPHE", IC_APOSTROPHE); GetScript()->CreateVariable("Input.IC_OEM_102", IC_OEM_102); // German <>| GetScript()->CreateVariable("Input.IC_COMMA", IC_COMMA); GetScript()->CreateVariable("Input.IC_PERIOD", IC_PERIOD); GetScript()->CreateVariable("Input.IC_SLASH", IC_SLASH); GetScript()->CreateVariable("Input.IC_SPACE", IC_SPACE); // mouse buttons GetScript()->CreateVariable("Input.IC_MOUSE_LEFT", IC_MOUSE_LEFT);// left GetScript()->CreateVariable("Input.IC_MOUSE_RIGHT", IC_MOUSE_RIGHT);// right GetScript()->CreateVariable("Input.IC_MOUSE_MIDDLE", IC_MOUSE_MIDDLE); // middle //mouse axis GetScript()->CreateVariable("Input.IC_AXISX", IC_AXISX); GetScript()->CreateVariable("Input.IC_AXISY", IC_AXISY); GetScript()->CreateVariable("Input.IC_AXISZ", IC_AXISZ); // timer GetScript()->CreateVariable("Input.IC_AXIST", IC_AXIST); // create the inputsystem shared_ptr<InputSystem> inputSystem = shared_dynamic_cast<InputSystem>(GetCore()->New(inputSysName)); if(inputSystem.get() == 0) { // could not create InputSystem GetLog()->Error() << "(InputServer) ERROR: unable to create " << inputSysName << "\n"; return false; } inputSystem->SetName("inputsystem"); if (inputSystem->Init(this) == false) { GetLog()->Error() << "(InputServer) ERROR: unable to initialize " << inputSysName << "\n"; Reset(); return false; } AddChildReference(inputSystem); // import the scan code map GetScript()->RunInitScript ( mScanCodeScript, "lib/kerosin/inputserver", ScriptServer::IS_COMMON ); return true; } shared_ptr<InputSystem> InputServer::GetInputSystem() { shared_ptr<InputSystem> inputSystem = shared_dynamic_cast<InputSystem> (GetChild("inputsystem")); return inputSystem; } bool InputServer::CreateDevice(const std::string &deviceName) { GetLog()->Normal() << "(InputServer) CreateDevice " << deviceName << "\n"; shared_ptr<InputSystem> inputSystem = GetInputSystem(); if (inputSystem.get() == 0) { GetLog()->Error() << "(InputSystem) ERROR: no InputSystem installed\n"; return false; } if (inputSystem.get() == 0) { return false; } return inputSystem->CreateDevice(deviceName); } void InputServer::Reset() { shared_ptr<InputSystem> inputSystem = GetInputSystem(); if (inputSystem.get() != 0) { inputSystem->Unlink(); inputSystem.reset(); } mScanCodeMap->Reset(); } bool InputServer::GetInput(Input &input, bool raw) { shared_ptr<InputSystem> inputSystem = GetInputSystem(); if (inputSystem.get() == 0) { GetLog()->Error() << "(InputServer) ERROR: no InputSystem installed\n"; input.id = -1; return false; } if (! inputSystem->GetInput(input)) { input.id = -1; return false; } if ( (input.type == eUser) || (raw) ) { // return eUser input return true; } // translate raw input to binding TBindMap::iterator bindListIter = mBindings.find(input.code); if (bindListIter == mBindings.end()) { input.id = -1; return false; } // we have an entry for the scan code TBindList& bindList = (*bindListIter).second; for ( TBindList::const_iterator bindIter = bindList.begin(); bindIter != bindList.end(); ++bindIter ) { const Bind& bind = (*bindIter); //printf("Looking at: %d %d %d", (*bind).code, (*bind).cmd, (*bind).modifier); if (bind.modifier == mModifierState) { if (input.type == eButton) { if ((bind.event == eKeyUpDown) || (bind.event == eKeyUp && input.data.l == 0) || (bind.event == eKeyDown && input.data.l == 1) ) { input.id = bind.cmd; return true; } } else if (input.type == eAxis) { input.id = bind.cmd; return true; } } } input.id = -1; return false; } bool InputServer::BindCommand(const std::string &desc, int cmd) { // first we have to translate the description to a correct Bind // struct Bind bind; if (! ParseBindDescription(bind, desc)) { return false; } // GetLog()->Normal() << "Binding " << cmd << endl; // GetLog()->Normal() << " code: " << bind.code << endl; // GetLog()->Normal() << " modifier: " << bind.modifier << endl; // GetLog()->Normal() << " event: " << bind.event << endl; bind.cmd = cmd; mBindings[bind.code].push_front(bind); return true; } void InputServer::SetScanCodeMapping(const std::string &name) { mScanCodeScript = name; } void InputServer::AddCode(TInputCode ic, const std::string &name, char noMod, char shiftMod, char altMod) { mScanCodeMap->AddCode(ic, name, noMod, shiftMod, altMod); } bool InputServer::ParseBindDescription(Bind &bind, const std::string &desc) { stringstream s(desc); string current; list<string> tokens; while(!s.eof()) { getline(s, current,' '); if (current.size()) { tokens.push_back(current); } } if (tokens.size() == 0) { GetLog()->Error() << "(InputServer) ERROR: Empty bind description? '" << desc << "'" << endl; return false; } // separated string is in tokens first we handle all the modifiers bind.modifier = eNone; while (tokens.size() > 1) { current = tokens.front(); tokens.pop_front(); bind.modifier |= ParseModifier(current); } // at this point only a single string is in the tokenlist current = tokens.front(); tokens.pop_front(); // current now holds the event to which to bind to, plus (maybe) // its pressed/release modifier bind.event = eKeyUpDown; if (current[0]=='+') { bind.event = eKeyDown; } else if (current[0]=='-') { bind.event = eKeyUp; } if (bind.event != eKeyUpDown) { current = current.substr(1); } bind.code = mScanCodeMap->GetCode(current); if (bind.code == 0) { GetLog()->Error() << "ERROR: Erroneous code description '" << current << "'" << endl; return false; } return true; } int InputServer::ParseModifier(const std::string &modifier) const { if (modifier == "lshift") return eLShift; if (modifier == "rshift") return eRShift; if (modifier == "shift") return eShift; if (modifier == "lctrl") return eLCtrl; if (modifier == "rctrl") return eRCtrl; if (modifier == "ctrl") return eCtrl; if (modifier == "lalt") return eLAlt; if (modifier == "ralt") return eRAlt; if (modifier == "alt") return eAlt; return eNone; } bool InputServer::TranslateCode(TInputCode code, unsigned long state, char &ch) const { state = mModifierState; return mScanCodeMap->TranslateCode(code, state, ch); } void InputServer::Invoke(int cmd) { Input input; input.type = eUser; input.code = -1; input.id = cmd; input.data.l = 0; shared_ptr<InputSystem> inputSystem = GetInputSystem(); if (inputSystem.get() == 0) { GetLog()->Error() << "(InputServer) ERROR: no InputSystem installed\n"; return; } inputSystem->AddInput(input); } --- NEW FILE: scancodemap.cpp --- #include "scancodemap.h" using namespace kerosin; ScanCodeMap::ScanCodeMap() { } ScanCodeMap::~ScanCodeMap() { } kerosin::InputServer::TInputCode ScanCodeMap::GetCode(const std::string &name) const { // loop through all entries in the map and find the one, which matches the symbolic name for (TScanCodeEntryMap::const_iterator i = mScanCodes.begin(); i != mScanCodes.end(); ++i) { if ((*i).second->name == name) return (*i).first; } return 0; } bool ScanCodeMap::TranslateCode(kerosin::InputServer::TInputCode code, unsigned long state, char &ch) const { if ((state & InputServer::eShift) && (state & InputServer::eAlt)) return false; TScanCodeEntryMap::const_iterator entry = mScanCodes.find(code); if (entry != mScanCodes.end()) { if (state & InputServer::eShift) { ch = (*entry).second->shiftModifier; return ch != 0; } if (state & InputServer::eAlt) { ch = (*entry).second->altModifier; return ch != 0; } ch = (*entry).second->noModifier; return ch != 0; } return false; } void ScanCodeMap::Reset() { for (TScanCodeEntryMap::iterator i = mScanCodes.begin(); i != mScanCodes.end(); ++i) { delete (*i).second; } } void ScanCodeMap::AddCode(InputServer::TInputCode ic, const std::string &name, char noMod, char shiftMod, char altMod) { TScanCodeEntry *entry = new TScanCodeEntry(); entry->Set(name, noMod, shiftMod, altMod); mScanCodes[ic] = entry; } --- NEW FILE: scancodemap.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: scancodemap.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_SCANCODEMAP_H #define KEROSIN_SCANCODEMAP_H /* \class ScanCodeMap $Id: scancodemap.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ ScanCodeMap This object can be used to translate from characters to scancodes and vice versa. It is necessary to allow for country specific keyboard layouts. NOTE: HISTORY: 30.09.02 - MK - Initial version TODO: TOFIX: */ #include <map> #include "inputserver.h" namespace kerosin { class ScanCodeMap { // // types // public: // character representations of the scancode this struct is associated with // the altModifier is only really used on German keyboards struct TScanCodeEntry { std::string name; // name of the key char noModifier; // no modifiers '<' char shiftModifier; // shift modifier '>' char altModifier; // alt modifier '|' void Set(const std::string &keyName, char noMod, char shiftMod, char altMod) { name = keyName; noModifier = noMod; shiftModifier = shiftMod; altModifier = altMod; } }; protected: typedef std::map<kerosin::InputServer::TInputCode, TScanCodeEntry*> TScanCodeEntryMap; // // functions // public: ScanCodeMap(); ~ScanCodeMap(); InputServer::TInputCode GetCode(const std::string &name) const; bool TranslateCode(InputServer::TInputCode code, unsigned long state, char &ch) const; void Reset(); void AddCode(InputServer::TInputCode ic, const std::string &name, char noMod, char shiftMod, char altMod); protected: //! this is the map which the translation process is based on TScanCodeEntryMap mScanCodes; }; } //namespace kerosin #endif //KEROSIN_SCANCODEMAP_H --- NEW FILE: inputserver.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: inputserver.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_INPUTSERVER_H #define KEROSIN_INPUTSERVER_H #include <zeitgeist/node.h> namespace kero... [truncated message content] |
From: Markus R. <rol...@us...> - 2005-12-05 21:38:30
|
Update of /cvsroot/simspark/simspark/spark/kerosin/fontserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/fontserver Added Files: .cvsignore font.cpp font.h fontserver.cpp fontserver.h fontserver_c.cpp glyph.cpp glyph.h Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs --- NEW FILE: font.cpp --- #include "font.h" #include <stdio.h> #include <stdarg.h> #include <salt/gmath.h> #include <boost/scoped_array.hpp> #include <zeitgeist/logserver/logserver.h> #include <zeitgeist/scriptserver/scriptserver.h> #include "fontserver.h" #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) #define WIN32_LEAN_AND_MEAN 1 #include <windows.h> #endif #include <GL/gl.h> using namespace kerosin; using namespace salt; Font::Font(FontServer &fontServer) : mTexID(0), mRowHeight(0), mSize(0), mFontServer(fontServer) { } Font::~Font() { } bool Font::Init(const std::string &name, unsigned int size, FT_Face face) { mName = name; mSize = size; if (mTexID != 0) { glDeleteTextures(1, &mTexID); mTexID = 0; GLenum error = glGetError(); if (error) { mFontServer.GetLog()->Debug() << "(Font) ERROR: glGetError() reports error " << error << " after deleting my font texture\n"; return false; } } int dpiHRes, dpiVRes; bool getConfig = ( mFontServer.GetScript()->GetVariable("Viewport.DpiHRes", dpiHRes) && mFontServer.GetScript()->GetVariable("Viewport.DpiVRes", dpiVRes) ); if (! getConfig) { mFontServer.GetLog()->Debug() << "(Font) ERROR: cannot read Viewport dpi values from ScriptServer\n"; return false; } FT_Set_Char_Size( face, /* handle to face object */ 0, /* char_width in 1/64th of points */ 64*size, /* char_height in 1/64th of points */ dpiHRes, /* horizontal device resolution */ dpiVRes /* vertical device resolution */ ); // x resolution of font texture unsigned int x = 256; // y resolution of font texture ... to be determined unsigned int y = 0; // the current maximum height unsigned int curMaxHeight = 0; // we also want to determine the (maximum) height of a row mRowHeight = 0; // here we will store the maximum height of each row std::vector<unsigned int> heights; // first pass to determine dimensions Glyph glyph; for(int i=32; i<128; ++i) { if (! glyph.LoadGlyph(face, i)) { mFontServer.GetLog()->Debug() << "(Font) ERROR: LoadGlyph() failed in first pass\n"; return false; } curMaxHeight = gMax(curMaxHeight, glyph.mByteHeight); if(x+glyph.mByteWidth > 256) { // move to next row x = glyph.mByteWidth+1; y+= curMaxHeight+1; mRowHeight = gMax(mRowHeight, curMaxHeight); heights.push_back(curMaxHeight); curMaxHeight = 0; } else { x+= glyph.mByteWidth+1; } } // calculate the texture height (has to be power of two) unsigned int requiredHeight = 1; y+=1; while(requiredHeight < y) { requiredHeight*=2; } // setup image buffer now we create a texture that is big enough for // this data boost::scoped_array<unsigned char> imageBuffer (new unsigned char[256*requiredHeight]); // clear the image memset(imageBuffer.get(), 0x00, 256*requiredHeight*sizeof(unsigned char)); // copy glyphs to the imageBuffer x=0; y=0; curMaxHeight = 0; // loop through our characters for(int i=32; i<128; ++i) { if (glyph.LoadGlyph(face, i) == false) { mFontServer.GetLog()->Debug() << "(Font) ERROR: LoadGlyph() failed in second pass\n"; return false; } curMaxHeight = gMax(curMaxHeight, glyph.mByteHeight); if(x+glyph.mByteWidth+1>256) { x=0; y+=curMaxHeight+1; // height of a row of characters plus 2 pixels space curMaxHeight = 0; } if(glyph.mByteWidth*glyph.mByteHeight > 0) { for (unsigned int copyY = 0; copyY < glyph.mByteHeight; ++copyY) { for (unsigned int copyX = 0; copyX < glyph.mByteWidth; ++copyX) { imageBuffer[(y+1+copyY)*256 + x+1+copyX] = glyph.mData[copyY*glyph.mByteWidth + copyX]; } } mMetrics[i-32].mByteWidth = glyph.mByteWidth; mMetrics[i-32].mByteHeight = glyph.mByteHeight; mMetrics[i-32].mXOffset = glyph.mXOffset; mMetrics[i-32].mYOffset = glyph.mYOffset; mMetrics[i-32].mAdvance = glyph.mAdvance; mMetrics[i-32].mTC1.Set((x+0.5f)/256.0f, (y+0.5f)/(float)requiredHeight); mMetrics[i-32].mTC2.Set((x+1.5f+glyph.mByteWidth)/256.0f, (y+1.5f+glyph.mByteHeight)/(float)requiredHeight); } x += glyph.mByteWidth+1; } // Spacing of a blank should be similar to 'i' mMetrics[' '-32].mAdvance = mMetrics['i'-32].mAdvance; glGenTextures(1, &mTexID); GLenum error = glGetError(); if (error) { mFontServer.GetLog()->Debug() << "(Font) ERROR: glGetError() reports error " << error << " after generating my font texture()\n"; mTexID = 0; return false; } glBindTexture(GL_TEXTURE_2D, mTexID); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA8, 256, requiredHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, imageBuffer.get()); glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); error = glGetError(); if (error) { mFontServer.GetLog()->Debug() << "(Font) ERROR: glGetError() reports error " << error << " after binding my font texture()\n"; return false; } return true; } bool Font::Bind(int vRows) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, mTexID); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); // int xRes; // int yRes; //if (!mFontServer.GetScript()->GetVariable("Viewport.xRes", xRes)) return false; //if (!mFontServer.GetScript()->GetVariable("Viewport.yRes", yRes)) return false; if(vRows == -1) { glOrtho(0, 1024, 768, 0, 1, 1000); } else { glOrtho(0, 1024*(mRowHeight*vRows/(float)768), mRowHeight*vRows, 0, 1, 1000); } return true; } void Font::Dump() { glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(0,0); glTexCoord2f(1, 0); glVertex2f(255, 0); glTexCoord2f(1, 1); glVertex2f(255, 255); glTexCoord2f(0, 1); glVertex2f(0, 255); glEnd(); } void Font::DrawString(float x, float y, const char *string) { const char *c = string; float curx; float cury; y += mRowHeight; while(*c != 0) { int i = *c-32; // rebase the index if(i>=0 && i<96) { GlyphMetric &metric = mMetrics[i]; curx = x; cury = y; curx+= metric.mXOffset; cury-= metric.mYOffset; glBegin(GL_QUADS); glTexCoord2f(metric.mTC1.x(), metric.mTC1.y()); glVertex2f(curx,cury); glTexCoord2f(metric.mTC2.x(), metric.mTC1.y()); glVertex2f(curx+metric.mByteWidth, cury); glTexCoord2f(metric.mTC2.x(), metric.mTC2.y()); glVertex2f(curx+metric.mByteWidth, cury+metric.mByteHeight); glTexCoord2f(metric.mTC1.x(), metric.mTC2.y()); glVertex2f(curx, cury+metric.mByteHeight); glEnd(); x+=(float)metric.mAdvance; } ++c; } } void Font::Printf(float x, float y, const char *format, ...) { char buffer[4096]; va_list args; va_start(args, format); vsprintf(buffer, format, args); va_end(args); DrawString(x, y, buffer); } void Font::RowPrintf(float x, float row, const char *format, ...) { char buffer[4096]; va_list args; va_start(args, format); vsprintf(buffer, format, args); va_end(args); DrawString(x, row*mRowHeight, buffer); } float Font::GetStringWidth(const char* string, int numChar) { if (numChar == -1) numChar = strlen(string); const char *c = string; float len = 0; int chCount = 0; while ( (*c != 0) && (chCount < numChar) ) { int i = *c-32; // rebase the index if(i>=0 && i<96) { GlyphMetric &metric = mMetrics[i]; len += metric.mAdvance; } ++c; ++chCount; } return len; } float Font::GetRowHeight() { return (float)mRowHeight; } const std::string& Font::GetName() const { return mName; } unsigned int Font::GetSize() const { return mSize; } --- NEW FILE: glyph.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: glyph.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_GLYPH_H #define KEROSIN_GLYPH_H // strange as this may seem #include <ft2build.h> #include FT_FREETYPE_H #include <boost/shared_array.hpp> namespace kerosin { class Glyph { public: Glyph(); bool LoadGlyph(FT_Face face, unsigned int charCode); unsigned int mByteWidth; unsigned int mByteHeight; unsigned int mXOffset; unsigned int mYOffset; unsigned int mAdvance; boost::shared_array<unsigned char> mData; private: void Reset(); }; } //namespace kerosin #endif //KEROSIN_GLYPH_H --- NEW FILE: glyph.cpp --- #include "glyph.h" using namespace kerosin; Glyph::Glyph() { Reset(); } bool Glyph::LoadGlyph(FT_Face face, unsigned int charCode) { int error = FT_Load_Char( face, charCode, FT_LOAD_RENDER); if (error) { return false; } Reset(); mByteWidth = face->glyph->bitmap.width; mByteHeight = face->glyph->bitmap.rows; mData.reset(new unsigned char[mByteWidth*mByteHeight]); //printf("Glyph: '%c' %d\n", charCode, face->glyph->bitmap.pitch); //printf(" Res: %dx%d\n", face->glyph->bitmap.width, face->glyph->bitmap.rows); for(int y=0; y<face->glyph->bitmap.rows; ++y) { for(int x=0; x<face->glyph->bitmap.width; ++x) { mData[y*mByteWidth + x] = face->glyph->bitmap.buffer[y*face->glyph->bitmap.pitch + x]; } } mXOffset = face->glyph->metrics.horiBearingX >> 6; mYOffset = face->glyph->metrics.horiBearingY >> 6; mAdvance = face->glyph->advance.x >> 6; //printf(" Offset: %dx%d\n", mXOffset, mYOffset); //printf(" Advance:%d\n", mAdvance); return true; } void Glyph::Reset() { mByteWidth = 0; mByteHeight = 0; mXOffset = 0; mYOffset = 0; mAdvance = 0; mData.reset(NULL); } --- NEW FILE: fontserver_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: fontserver_c.cpp,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "fontserver.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; using namespace std; FUNCTION(FontServer,getFont) { string inName; int inSize; if ( (in.GetSize() != 2) || (! in.GetValue(in[0], inName)) || (! in.GetValue(in[1], inSize)) ) { return false; } return (obj->GetFont(inName,inSize).get() != 0); } void CLASS(FontServer)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Leaf); DEFINE_FUNCTION(getFont); } --- NEW FILE: font.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: font.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_FONT_H #define KEROSIN_FONT_H #include <string> #include <salt/vector.h> #include "glyph.h" namespace kerosin { class FontServer; /** Font allows the use of a 'texture'-based font. The font is loaded from Fluid Studios Font Files, which can be generated with a small utility from any Windows font. Care has to be taken, that the resulting font will fit in a 256x256 texture! Our font will only contain characters for the ASCII value range 32-128 ... this should cover the major alphanumeric characters! NOTE: HISTORY: 08.10.01 - MK - Initial version 12.10.01 - MK - This now supports fonts generated with Fluid Studios Font Generator 16.10.01 - MK - Calculates minimum texture size required - Only needs one pixel in-between characters when placing them in the texture 16.10.01 - MR - Added support to calculate the width of a string printed with this font 02.10.02 - MK - Moved to Kerosin (major changes) TODO: - better texture usage TOFIX: - ImageServer activation hack (see FIXME in cpp file) */ class Font { private: struct GlyphMetric { unsigned int mByteWidth; unsigned int mByteHeight; unsigned int mXOffset; unsigned int mYOffset; unsigned int mAdvance; salt::Vector2f mTC1; salt::Vector2f mTC2; }; public: Font(FontServer &fontServer); ~Font(); bool Init(const std::string &name, unsigned int size, FT_Face face); bool Bind(int vRows = -1); void Dump(); void DrawString(float x, float y, const char *string); void Printf(float x, float y, const char *format, ...); void RowPrintf(float x, float row, const char *format, ...); /**! calculates the width of a string, printed with this font. Set numChar to a value between 1 and strlen(string) to calculate intermediate string lengths. A value of -1 (which is the default value) calculates the width if the whole string */ float GetStringWidth(const char* string, int numChar = -1); //! returns the height in pixels of a row float GetRowHeight(); //! returns the name of the font const std::string& GetName() const; //! returns the size of the font unsigned int GetSize() const; private: //! the metrics of all glyphs GlyphMetric mMetrics[96]; //! OpenGL Texture ID unsigned int mTexID; //! height (in pixels) of a row unsigned int mRowHeight; //! font name std::string mName; //! size of font unsigned int mSize; //! reference to the fontserver FontServer& mFontServer; }; } // namespace kerosin #endif //KEROSIN_FONT_H --- NEW FILE: fontserver.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: fontserver.h,v 1.1 2005/12/05 21:38:22 rollmark Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KEROSIN_FONTSERVER_H #define KEROSIN_FONTSERVER_H #include <zeitgeist/leaf.h> #include <zeitgeist/class.h> // strange as this may seem #include <ft2build.h> #include FT_FREETYPE_H namespace kerosin { class Font; /* The fontserver manages Font objects. It prevents a single font from being loaded several times by the runtime system. NOTE: HISTORY: 15.10.01 - MK - Initial version 02.10.02 - MK - Moved to Kerosin (major changes) TODO: TOFIX: */ class FontServer : public zeitgeist::Leaf { public: FontServer(); ~FontServer(); //! load a font with a given size boost::shared_ptr<Font> GetFont(const std::string &name, unsigned int size = 12); //! test if a specific font has been loaded boost::shared_ptr<Font> FindFont(const std::string &name, unsigned int size) const; //! setup opengl states for font rendering void Begin(); //! reset opengl states after font rendering void End(); protected: bool LoadFont(const std::string &name, unsigned int size, boost::shared_ptr<Font> &font); private: typedef std::list<boost::shared_ptr<kerosin::Font> > TFontList; //! the registry of loaded fonts TFontList mFonts; //! FreeType FT_Library mFreeTypeLib; }; DECLARE_CLASS(FontServer); } //namespace kerosin #endif //KEROSIN_FONTSERVER_H --- NEW FILE: fontserver.cpp --- #include "fontserver.h" #include "font.h" #include <boost/scoped_array.hpp> #include <salt/fileclasses.h> #include <zeitgeist/fileserver/fileserver.h> #include <zeitgeist/logserver/logserver.h> #include <zeitgeist/scriptserver/scriptserver.h> #include <kerosin/openglserver/openglserver.h> using namespace kerosin; using namespace std; using namespace boost; FontServer::FontServer() { FT_Init_FreeType(&mFreeTypeLib); } FontServer::~FontServer() { mFonts.clear(); } shared_ptr<kerosin::Font> FontServer::GetFont(const string &name, unsigned int size) { shared_ptr<kerosin::Font> theFont = FindFont(name, size); if(theFont.get() != 0) { return theFont; } // we don't have a cached entry, so we have to create // a new font object and insert it into our registry theFont.reset(new Font(*this)); if(! LoadFont(name, size, theFont)) { return shared_ptr<kerosin::Font>(); } // insert the value in our registry mFonts.push_back(theFont); return theFont; } shared_ptr<kerosin::Font> FontServer::FindFont(const string &name, unsigned int size) const { for (TFontList::const_iterator i = mFonts.begin(); i != mFonts.end(); ++i) { if ( ((*i)->GetName().compare(name) == 0) && ((*i)->GetSize() == size) ) { return (*i); } } return shared_ptr<kerosin::Font>(); } bool FontServer::LoadFont(const string &name, unsigned int size, shared_ptr<kerosin::Font> &font) { shared_ptr<salt::RFile> file = GetFile()->Open(name.c_str()); if (file.get() == 0) { // try with prefixed fontPath string fontPath; if(GetScript()->GetVariable("System.FontPath", fontPath)) { file = GetFile()->Open((fontPath+name).c_str()); } } if (file.get() == 0) { GetLog()->Error() << "(FontServer) ERROR: font file '" << name << "' not found\n"; return false; } unsigned int fileSize = file->Size(); scoped_array<unsigned char> buffer(new unsigned char[fileSize]); file->Read(buffer.get(), fileSize); FT_Face face; int error = FT_New_Memory_Face(mFreeTypeLib, buffer.get(), fileSize, 0, &face); if (error == FT_Err_Unknown_File_Format) { GetLog()->Error() << "(FontServer) ERROR: Unknown file format\n"; } else if (error) { GetLog()->Error() << "(FontServer) ERROR: Could not create face\n"; } if (error) { FT_Done_Face(face); return false; } bool ok = font->Init(name, size, face); FT_Done_Face(face); return ok; } void FontServer::Begin() { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(0,0,-1); glColor4f(1,1,1,1); } void FontServer::End() { glDisable(GL_BLEND); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); } |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:46
|
Update of /cvsroot/simspark/simspark/spark/kerosin/soundserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/soundserver Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/soundserver added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:35
|
Update of /cvsroot/simspark/simspark/spark/kerosin/materialserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/materialserver Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/materialserver added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:35
|
Update of /cvsroot/simspark/simspark/spark/kerosin/imageserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/imageserver Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/imageserver added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:35
|
Update of /cvsroot/simspark/simspark/spark/kerosin/renderserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/renderserver Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/renderserver added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:34
|
Update of /cvsroot/simspark/simspark/spark/kerosin/sceneserver/helper In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/sceneserver/helper Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/sceneserver/helper added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:34
|
Update of /cvsroot/simspark/simspark/spark/kerosin/sceneserver/helper/nv_math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/sceneserver/helper/nv_math Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/sceneserver/helper/nv_math added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:34
|
Update of /cvsroot/simspark/simspark/spark/kerosin/sceneserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/sceneserver Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/sceneserver added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:34
|
Update of /cvsroot/simspark/simspark/spark/kerosin/inputserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/inputserver Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/inputserver added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:34
|
Update of /cvsroot/simspark/simspark/spark/kerosin/textureserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/textureserver Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/textureserver added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:34
|
Update of /cvsroot/simspark/simspark/spark/kerosin/fontserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/fontserver Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/fontserver added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:34:27
|
Update of /cvsroot/simspark/simspark/spark/kerosin/openglserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19109/openglserver Log Message: Directory /cvsroot/simspark/simspark/spark/kerosin/openglserver added to the repository |
From: Markus R. <rol...@us...> - 2005-12-05 21:24:55
|
Update of /cvsroot/simspark/simspark/spark/oxygen/simulationserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16714/simulationserver Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs |
From: Markus R. <rol...@us...> - 2005-12-05 21:24:55
|
Update of /cvsroot/simspark/simspark/spark/oxygen/physicsserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16714/physicsserver Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs |
From: Markus R. <rol...@us...> - 2005-12-05 21:24:54
|
Update of /cvsroot/simspark/simspark/spark/oxygen/agentaspect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16714/agentaspect Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs |
From: Markus R. <rol...@us...> - 2005-12-05 21:24:54
|
Update of /cvsroot/simspark/simspark/spark/oxygen/controlaspect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16714/controlaspect Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs |