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-13 21:48:59
|
Update of /cvsroot/simspark/simspark/spark/plugin/sparkmonitor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv885/sparkmonitor Added Files: .cvsignore Makefile.am export.cpp sparkmonitor.cpp sparkmonitor.h sparkmonitor_c.cpp sparkmonitorclient.cpp sparkmonitorclient.h sparkmonitorclient_c.cpp Log Message: - added spark specific plugins --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in --- NEW FILE: export.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: export.cpp,v 1.1 2005/12/13 21:48:50 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 "sparkmonitor.h" #include "sparkmonitorclient.h" #include <zeitgeist/zeitgeist.h> using namespace oxygen; ZEITGEIST_EXPORT_BEGIN() ZEITGEIST_EXPORT(SparkMonitor); ZEITGEIST_EXPORT(SparkMonitorClient); ZEITGEIST_EXPORT_END() --- NEW FILE: sparkmonitorclient_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: sparkmonitorclient_c.cpp,v 1.1 2005/12/13 21:48:50 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 "sparkmonitorclient.h" using namespace std; using namespace oxygen; FUNCTION(SparkMonitorClient, getServer) { return obj->GetServer(); } FUNCTION(SparkMonitorClient, setServer) { string inServer; if ( (in.GetSize() != 1) || (! in.GetValue(in[0], inServer)) ) { return false; } obj->SetServer(inServer); return true; } FUNCTION(SparkMonitorClient, setClientTypeTCP) { obj->SetClientType(NetControl::ST_TCP); return true; } FUNCTION(SparkMonitorClient, setClientTypeUDP) { obj->SetClientType(NetControl::ST_UDP); return true; } FUNCTION(SparkMonitorClient, getPort) { return obj->GetPort(); } FUNCTION(SparkMonitorClient, setPort) { int inPort; if ( (in.GetSize() != 1) || (! in.GetValue(in[0], inPort)) ) { return false; } obj->SetPort(inPort); return true; } void CLASS(SparkMonitorClient)::DefineClass() { DEFINE_BASECLASS(oxygen/SimControlNode); DEFINE_FUNCTION(getServer); DEFINE_FUNCTION(setServer); DEFINE_FUNCTION(getPort); DEFINE_FUNCTION(setPort); DEFINE_FUNCTION(setClientTypeTCP); DEFINE_FUNCTION(setClientTypeUDP); } --- NEW FILE: sparkmonitor_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: sparkmonitor_c.cpp,v 1.1 2005/12/13 21:48:50 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 "sparkmonitor.h" void CLASS(SparkMonitor)::DefineClass() { DEFINE_BASECLASS(oxygen/BaseParser); } --- NEW FILE: sparkmonitorclient.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: sparkmonitorclient.h,v 1.1 2005/12/13 21:48:50 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 SPARK_SPARKMONITORCLIENT_H #define SPARK_SPARKMONITORCLIENT_H #include <sfsexp/sexp.h> #include <zeitgeist/class.h> #include <oxygen/simulationserver/netclient.h> #include <oxygen/sceneserver/sceneserver.h> #include <oxygen/sceneserver/scene.h> #include <oxygen/sceneserver/sceneimporter.h> #include <oxygen/gamecontrolserver/predicate.h> class SparkMonitorClient : public oxygen::NetClient { public: SparkMonitorClient(); virtual ~SparkMonitorClient(); /** called once when the simulation is started */ virtual void InitSimulation(); /** called once before the simulation is shut down */ virtual void DoneSimulation(); /** called when a new simulation cycle starts, before the simulation is stepped */ virtual void StartCycle(); protected: /** parses a received message */ void ParseMessage(const std::string& msg); void ParseCustomPredicates(sexp_t* sexp, oxygen::PredicateList& pList); /** parses the given s-expression into a ParameterList and transfers it to a registered user monitor */ void ParseCustomPredicates(sexp_t* sexp); virtual void OnLink(); virtual void OnUnlink(); protected: /** cached reference to the SceneServer */ boost::shared_ptr<oxygen::SceneServer> mSceneServer; /** cached reference to the current active scene */ boost::shared_ptr<oxygen::Scene> mActiveScene; /** chached reference to the scene importer */ boost::shared_ptr<oxygen::SceneImporter> mSceneImporter; /** the root node of the managed scene */ boost::shared_ptr<oxygen::BaseNode> mManagedScene; }; DECLARE_CLASS(SparkMonitorClient); #endif // SPARKMONITORCLIENT_H --- NEW FILE: sparkmonitorclient.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: sparkmonitorclient.cpp,v 1.1 2005/12/13 21:48:50 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 "sparkmonitorclient.h" #include <oxygen/monitorserver/custommonitor.h> #include <zeitgeist/logserver/logserver.h> #include <netinet/in.h> #include <rcssnet/exception.hpp> #include <cerrno> using namespace oxygen; using namespace zeitgeist; using namespace rcss::net; using namespace salt; using namespace boost; using namespace std; SparkMonitorClient::SparkMonitorClient() : NetClient() { } SparkMonitorClient::~SparkMonitorClient() { } void SparkMonitorClient::OnLink() { // setup SceneServer reference mSceneServer = shared_dynamic_cast<SceneServer> (GetCore()->Get("/sys/server/scene")); if (mSceneServer.get() == 0) { GetLog()->Error() << "(SparkMonitor) ERROR: SceneServer not found\n"; } } void SparkMonitorClient::OnUnlink() { mSceneServer.reset(); if (mManagedScene.get() != 0) { mManagedScene->UnlinkChildren(); mManagedScene.reset(); } } void SparkMonitorClient::InitSimulation() { if (! Connect()) { return; } // get the SceneImporter mSceneImporter = shared_dynamic_cast<SceneImporter> (GetCore()->Get("/sys/server/scene/RubySceneImporter")); if (mSceneImporter.get() == 0) { GetLog()->Error() << "(SparkMonitorClient) ERROR: cannot create" << "a RubySceneImporter instance\n"; } // send the monitor init string SendMessage("(init)"); } void SparkMonitorClient::DoneSimulation() { mActiveScene.reset(); mSceneImporter.reset(); CloseConnection(); } void SparkMonitorClient::StartCycle() { ReadFragments(); string msg; while (mNetMessage->Extract(mNetBuffer, msg)) { ParseMessage(msg); } } void SparkMonitorClient::ParseCustomPredicates(sexp_t* sexp, PredicateList& pList) { if ( (sexp == 0) || (sexp->ty != SEXP_VALUE) ) { return; } Predicate& pred = pList.AddPredicate(); pred.name = sexp->val; sexp = sexp->next; while (sexp != 0) { if (sexp->ty == SEXP_VALUE) { pred.parameter.AddValue(sexp->val); } sexp = sexp->next; } } void SparkMonitorClient::ParseCustomPredicates(sexp_t* sexp) { // ( (name param1 param2 ...) (name param1 param2 ...) ... ) if (sexp == 0) { return; } // get list of registered CustomMonitor objects TLeafList customList; ListChildrenSupportingClass<CustomMonitor>(customList); if (customList.empty()) { return; } // parse predicates PredicateList pList; sexp = sexp->list; while (sexp != 0) { if (sexp->ty == SEXP_LIST) { sexp_t* sPred = sexp->list; ParseCustomPredicates(sPred,pList); } sexp = sexp->next; } // pass predicates to all registered CustomMonitor objects for ( TLeafList::iterator iter = customList.begin(); iter != customList.end(); ++iter ) { shared_static_cast<CustomMonitor>((*iter)) ->ParseCustomPredicates(pList); } } void SparkMonitorClient::ParseMessage(const string& msg) { if ( (mSceneServer.get() == 0) || (mSceneImporter.get() == 0) ) { return; } mActiveScene = mSceneServer->GetActiveScene(); if (mActiveScene.get() == 0) { return; } if (mManagedScene.get() == 0) { mManagedScene = shared_dynamic_cast<BaseNode> (GetCore()->New("oxygen/BaseNode")); mActiveScene->AddChildReference(mManagedScene); } // parse s-expressions; we expect a leading list of custom // predicates followed by the RubySceneGraph expressions /** ( (predicate parameter ...) (predicate parameter ...) ... ) (RubySceneGraph Header) (RubySceneGraph Body) ) **/ char* msgBuf = const_cast<char*>(msg.c_str()); pcont_t* pcont = init_continuation(msgBuf); sexp_t* sexp_custom = iparse_sexp(msgBuf,msg.size(),pcont); if (sexp_custom == 0) { destroy_sexp(sexp_custom); destroy_continuation(pcont); return; } ParseCustomPredicates(sexp_custom); mSceneImporter->ParseScene(string(pcont->lastPos), mManagedScene, shared_ptr<ParameterList>()); destroy_sexp(sexp_custom); destroy_continuation(pcont); } --- NEW FILE: Makefile.am --- pkglib_LTLIBRARIES = sparkmonitor.la sparkmonitor_la_SOURCES = \ export.cpp \ sparkmonitor.cpp \ sparkmonitor_c.cpp \ sparkmonitor.h \ sparkmonitorclient.h \ sparkmonitorclient.cpp \ sparkmonitorclient_c.cpp sparkmonitor_la_LDFLAGS = -module -version-info 0:0:0 -L${top_srcdir}/utility/sfsexp/ sparkmonitor_la_LIBADD = -lsexp AM_CPPFLAGS = -I${top_srcdir}/lib -I${top_srcdir}/utility @RUBY_CPPFLAGS@ --- NEW FILE: sparkmonitor.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: sparkmonitor.h,v 1.1 2005/12/13 21:48:50 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 SPARKMONITOR_H__ #define SPARKMONITOR_H__ #include <oxygen/monitorserver/monitorsystem.h> #include <oxygen/sceneserver/sceneserver.h> #include <oxygen/sceneserver/scene.h> #include <oxygen/sceneserver/transform.h> #include <kerosin/sceneserver/staticmesh.h> #include <kerosin/sceneserver/light.h> #include <oxygen/physicsserver/body.h> class SparkMonitor : public oxygen::MonitorSystem { public: SparkMonitor(); virtual ~SparkMonitor(); /** If a monitor sends information to the world model, this * function is called to process it. * @param data data sent from monitor to monitorsystem via SPADES. */ void ParseMonitorMessage(const std::string& data); /** This function will be called periodically to get information * about the current state of the world. * \param items holds a list of additional name value pairs. These * predicates are collected from MonitorItem objects registered to * the MonitorServer. The monitor should transfer them to the * client if possible. */ virtual std::string GetMonitorInfo(const oxygen::PredicateList& pList); /** This function is called once for every MonitorSystem each time * a new client connects. It should return any header/setup * information that is needed. * \param items holds a list of additional name value * pairs. These predicates are collected from MonitorItem objects * registered to the MonitorServer. The monitor should transfer * them to the client if possible. */ virtual std::string GetMonitorHeaderInfo(const oxygen::PredicateList& pList); protected: virtual void OnLink(); virtual void OnUnlink(); void DescribeCustomPredicates(std::stringstream& ss,const oxygen::PredicateList& pList); void DescribeActiveScene(std::stringstream& ss); void DescribeScene(std::stringstream& ss, boost::shared_ptr<oxygen::BaseNode> node); void DescribeNode(std::stringstream& ss, boost::shared_ptr<oxygen::BaseNode> node); void DescribeTransform(std::stringstream& ss, boost::shared_ptr<oxygen::Transform> transform); void DescribeMesh(std::stringstream& ss, boost::shared_ptr<kerosin::StaticMesh> mesh); void DescribeLight(std::stringstream& ss, boost::shared_ptr<kerosin::Light> light); protected: /** cached reference to the SceneServer */ boost::shared_ptr<oxygen::SceneServer> mSceneServer; /** cached reference to the current active scene */ boost::shared_ptr<oxygen::Scene> mActiveScene; /** true, if the full state is generated */ bool mFullState; }; DECLARE_CLASS(SparkMonitor); #endif // SPARKMONITOR_H__ --- NEW FILE: sparkmonitor.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: sparkmonitor.cpp,v 1.1 2005/12/13 21:48:50 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 "sparkmonitor.h" #include <zeitgeist/logserver/logserver.h> #include <kerosin/sceneserver/singlematnode.h> #include <kerosin/materialserver/material.h> #include <oxygen/monitorserver/monitorcmdparser.h> #include <oxygen/sceneserver/sceneserver.h> #include <sstream> using namespace kerosin; using namespace oxygen; using namespace zeitgeist; using namespace boost; using namespace salt; using namespace std; SparkMonitor::SparkMonitor() : oxygen::MonitorSystem() { mFullState = true; } SparkMonitor::~SparkMonitor() { } void SparkMonitor::OnLink() { // setup SceneServer reference mSceneServer = shared_dynamic_cast<SceneServer> (GetCore()->Get("/sys/server/scene")); if (mSceneServer.get() == 0) { GetLog()->Error() << "(SparkMonitor) ERROR: SceneServer not found\n"; } } void SparkMonitor::OnUnlink() { mSceneServer.reset(); mActiveScene.reset(); } void SparkMonitor::ParseMonitorMessage(const std::string& data) { // pass the received string on to all installed CommandParsers TLeafList items; ListChildrenSupportingClass<MonitorCmdParser>(items); for ( TLeafList::iterator iter = items.begin(); iter != items.end(); ++iter ) { shared_static_cast<MonitorCmdParser>(*iter) ->ParseMonitorMessage(data); } } string SparkMonitor::GetMonitorInfo(const PredicateList& pList) { stringstream ss; mFullState = false; DescribeCustomPredicates(ss,pList); DescribeActiveScene(ss); return ss.str(); } string SparkMonitor::GetMonitorHeaderInfo(const PredicateList& pList) { stringstream ss; mFullState = true; DescribeCustomPredicates(ss,pList); DescribeActiveScene(ss); return ss.str(); } void SparkMonitor::DescribeCustomPredicates(stringstream& ss,const PredicateList& pList) { ss << "("; for ( PredicateList::TList::const_iterator iter = pList.begin(); iter != pList.end(); ++iter ) { const Predicate& pred = (*iter); ss << "("; ss << pred.name; const ParameterList& paramList = pred.parameter; ParameterList::TVector::const_iterator pIter = paramList.begin(); std::string param; while ( (pIter != paramList.end()) && (paramList.AdvanceValue(pIter, param)) ) { ss << " "; ss << param; } ss << ")"; } ss << ")"; } void SparkMonitor::DescribeLight(stringstream& ss, shared_ptr<Light> light) { ss << "(node Light "; const RGBA& diff = light->GetDiffuse(); ss << "(setDiffuse " << diff.r() << " " << diff.g() << " " << diff.b() << " " << diff.a() << ") "; const RGBA& amb = light->GetAmbient(); ss << "(setAmbient " << amb.r() << " " << amb.g() << " " << amb.b() << " " << amb.a() << ") "; const RGBA& spec = light->GetSpecular(); ss << "(setSpecular " << spec.r() << " " << spec.g() << " " << spec.b() << " " << spec.a() << ")"; } void SparkMonitor::DescribeTransform(stringstream& ss, shared_ptr<Transform> transform) { const float precision = 0.005; const Matrix& mat = transform->GetLocalTransform(); if (mFullState) { ss << "(node Transform"; } else { ss << "(node"; } // include transform data only for fullstate or a modified // transform node bool update = false; if (mFullState) { update = true; } else { if (SceneServer::GetTransformMark() == transform->GetChangedMark()) { const salt::Matrix& current = transform->GetLocalTransform(); const salt::Matrix& old = transform->GetOldLocalTransform(); for (int i=0;i<16;++i) { const float d = fabs(current.m[i] - old.m[i]); if (d > precision) { update = true; break; } } } } if (update) { ss << " (setLocalTransform "; for (int i=0;i<16;++i) { ss << mat.m[i] << " "; } ss << ")"; } } void SparkMonitor::DescribeMesh(stringstream& ss, boost::shared_ptr<StaticMesh> mesh) { shared_ptr<SingleMatNode> singleMat = shared_dynamic_cast<SingleMatNode>(mesh); if (singleMat.get() != 0) { ss << "(node SingleMatNode"; } else { ss << "(node StaticMesh"; } ss << " (load " << mesh->GetMeshName(); const ParameterList& params = mesh->GetMeshParameter(); for ( ParameterList::TVector::const_iterator iter = params.begin(); iter != params.end(); ++iter ) { string str; params.GetValue(iter,str); ss << " " << str; } ss << ")"; const Vector3f& scale = mesh->GetScale(); ss << " (setScale " << scale[0] << " " << scale[1] << " " << scale[2] << ")"; if (singleMat.get() != 0) { shared_ptr<Material> mat = singleMat->GetMaterial(); if (mat.get() != 0) { ss << " (setMaterial " << mat->GetName() << ")"; } } } void SparkMonitor::DescribeNode(stringstream& ss, shared_ptr<BaseNode> node) { // Transform node shared_ptr<Transform> transform = shared_dynamic_cast<Transform>(node); if (transform.get() != 0) { DescribeTransform(ss,transform); return; } if (mFullState) { // StaticMesh node shared_ptr<StaticMesh> mesh = shared_dynamic_cast<StaticMesh>(node); if (mesh.get() != 0) { DescribeMesh(ss,mesh); return; } // Light node shared_ptr<Light> light = shared_dynamic_cast<Light>(node); if (light.get() != 0) { DescribeLight(ss,light); return; } } if (mFullState) { // default to BaseNode ss << "(node BaseNode"; } else { ss << "(node"; } } void SparkMonitor::DescribeActiveScene(stringstream& ss) { if (mSceneServer.get() == 0) { return; } mActiveScene = mSceneServer->GetActiveScene(); if (mActiveScene.get() != 0) { if (mActiveScene->GetModified()) { // send a full scene update if nodes have been // added or removed (on scene import, agent // connect/disconnect etc.) mFullState = true; } if (mFullState) { ss << "(RubySceneGraph 0 1)"; } else { ss << "(RubyDeltaScene 0 1)"; } DescribeScene(ss,mActiveScene); } ss << endl; } void SparkMonitor::DescribeScene(stringstream& ss, shared_ptr<BaseNode> node) { DescribeNode(ss, node); for (TLeafList::iterator i = node->begin(); i!= node->end(); ++i) { shared_ptr<BaseNode> baseNode = shared_dynamic_cast<BaseNode>(*i); if (baseNode.get() == 0) { continue; } DescribeScene(ss,baseNode); } ss << ")"; } |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:48:58
|
Update of /cvsroot/simspark/simspark/spark/plugin/sexpparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv885/sexpparser Added Files: .cvsignore Makefile.am export.cpp sexpparser.cpp sexpparser.h sexpparser_c.cpp Log Message: - added spark specific plugins --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in --- NEW FILE: export.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: export.cpp,v 1.1 2005/12/13 21:48:50 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 "sexpparser.h" #include <zeitgeist/zeitgeist.h> using namespace oxygen; ZEITGEIST_EXPORT_BEGIN() ZEITGEIST_EXPORT(SexpParser); ZEITGEIST_EXPORT_END() --- NEW FILE: sexpparser_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: sexpparser_c.cpp,v 1.1 2005/12/13 21:48:50 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 "sexpparser.h" void CLASS(SexpParser)::DefineClass() { DEFINE_BASECLASS(oxygen/BaseParser); } --- NEW FILE: sexpparser.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: sexpparser.cpp,v 1.1 2005/12/13 21:48:50 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 "sexpparser.h" using namespace oxygen; using namespace zeitgeist; using namespace std; using namespace boost; shared_ptr<PredicateList> SexpParser::Parse(const std::string& input) { size_t len = input.length(); shared_ptr<PredicateList> predList(new PredicateList); if (len == 0) { return predList; } char* c = const_cast<char*>(input.c_str()); pcont_t* pcont = init_continuation(c); sexp_t* sexp = iparse_sexp(c,input.size(),pcont); while (sexp != 0) { SexpToPredicate(predList,sexp); destroy_sexp(sexp); sexp = iparse_sexp(c,input.size(),pcont); } destroy_continuation(pcont); return predList; } string SexpParser::Generate(boost::shared_ptr<PredicateList> input) { if (input.get() == 0) { return ""; } stringstream ss; PredicateList& list = *input.get(); for ( PredicateList::TList::const_iterator i = list.begin(); i != list.end(); ++i ) PredicateToString(ss,*i); return ss.str(); } void SexpParser::SexpToList(ParameterList& arguments, const sexp_t* const sexp) { sexp_t* s = const_cast<sexp_t*>(sexp); while (s != 0) { if (s->ty == SEXP_VALUE) { arguments.AddValue(string(s->val)); } else { ParameterList& elem = arguments.AddList(); SexpToList(elem,s->list); } s = s->next; } } void SexpParser::SexpToPredicate (shared_ptr<PredicateList>& predList, const sexp_t* const sexp) { // throw away outer brackets (i.e. we have a list at the top // level) if (sexp->ty != SEXP_LIST) { return; } sexp_t* s = const_cast<sexp_t*>(sexp->list); if ( (s == 0) || (s->ty != SEXP_VALUE) ) { return; } Predicate& predicate = predList->AddPredicate(); predicate.name = string(s->val); SexpToList(predicate.parameter,s->next); } void SexpParser::ListToString(stringstream& ss, const ParameterList& lst) { string space; for ( ParameterList::TVector::const_iterator i = lst.begin(); i != lst.end(); ++i ) { if (i->type() == typeid(string)) { ss << space; ss << boost::any_cast<string>(*i); } else if (i->type() == typeid(float)) { ss << space; ss << boost::any_cast<float>(*i); } else if (i->type() == typeid(int)) { ss << space; ss <<boost::any_cast<int>(*i); } else if (i->type() == typeid(ParameterList)) { const any* v = &(*i); const ParameterList* lst = any_cast<ParameterList>(v); ss << space; ss << '('; ListToString(ss,*lst); ss << ')'; } else { ss << space; ss << "(error data format unknown)"; } space = " "; } } void SexpParser::PredicateToString(stringstream& ss, const Predicate& plist) { ss << '('; ss << plist.name; ss << ' '; ListToString(ss,plist.parameter); ss << ')'; } --- NEW FILE: Makefile.am --- pkglib_LTLIBRARIES = sexpparser.la sexpparser_la_LIBADD = -lsexp sexpparser_la_SOURCES = export.cpp \ sexpparser.cpp sexpparser_c.cpp sexpparser.h sexpparser_la_LDFLAGS = -module -version-info 0:0:0 -L${top_srcdir}/utility/sfsexp/ AM_CPPFLAGS = -I${top_srcdir}/lib -I${top_srcdir}/utility @RUBY_CPPFLAGS@ --- NEW FILE: sexpparser.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: sexpparser.h,v 1.1 2005/12/13 21:48:50 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 SEXPPARSER_H #define SEXPPARSER_H #include <sstream> #include <sfsexp/sexp.h> #include <oxygen/gamecontrolserver/baseparser.h> #include <zeitgeist/class.h> class SexpParser : public oxygen::BaseParser { public: SexpParser() { } ~SexpParser() { } virtual boost::shared_ptr<oxygen::PredicateList> Parse(const std::string& input); virtual std::string Generate(boost::shared_ptr<oxygen::PredicateList> input); private: void SexpToList(zeitgeist::ParameterList& arguments, const sexp_t* const sexp); void SexpToPredicate(boost::shared_ptr<oxygen::PredicateList>& predicate, const sexp_t* const sexp); void ListToString(std::stringstream& ss, const zeitgeist::ParameterList& lst); void PredicateToString(std::stringstream& ss, const oxygen::Predicate& predicate); }; DECLARE_CLASS(SexpParser); #endif // SEXPPARSER_H |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:48:58
|
Update of /cvsroot/simspark/simspark/spark/plugin/rubysceneimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv885/rubysceneimporter Added Files: .cvsignore Makefile.am export.cpp rubysceneimporter.cpp rubysceneimporter.h rubysceneimporter_c.cpp Log Message: - added spark specific plugins --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in --- NEW FILE: export.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: export.cpp,v 1.1 2005/12/13 21:48:50 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 "rubysceneimporter.h" ZEITGEIST_EXPORT_BEGIN() ZEITGEIST_EXPORT(RubySceneImporter); ZEITGEIST_EXPORT_END() --- NEW FILE: rubysceneimporter.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: rubysceneimporter.cpp,v 1.1 2005/12/13 21:48:50 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 "rubysceneimporter.h" #include <zeitgeist/logserver/logserver.h> #include <zeitgeist/fileserver/fileserver.h> #include <zeitgeist/scriptserver/scriptserver.h> #include <boost/scoped_array.hpp> using namespace zeitgeist; using namespace oxygen; using namespace boost; using namespace std; /** (RubySceneGraph <version major> <version minor>) ( (template varName1 varName2 ...) (define varName value) (node <NodeName> method param param ... method param ... (node <NodeName> method param param ... method param ... ) (node <NodeName> method param param ... method param ... ) method param param ... method param ... ) */ RubySceneImporter::RubySceneImporter() : SceneImporter() { mVersionMajor = 0; mVersionMinor = 0; mDeltaScene = false; mAutoUnlink = false; } RubySceneImporter::~RubySceneImporter() { } void RubySceneImporter::SetUnlinkOnCompleteScenes(bool unlink) { mAutoUnlink = unlink; } bool RubySceneImporter::ImportScene(const std::string& fileName, shared_ptr<BaseNode> root, shared_ptr<ParameterList> parameter) { // try to open the file shared_ptr<salt::RFile> file = GetFile()->Open(fileName); if (file.get() == 0) { GetLog()->Error() << "(RubySceneImporter) ERROR: cannot open file '" << fileName << "'\n"; return false; } mFileName = fileName; // read entire file into a temporary buffer scoped_array<char> buffer(new char[file->Size() + 1]); file->Read(buffer.get(), file->Size()); buffer[file->Size()] = 0; return ParseScene(buffer.get(), file->Size(), root, parameter); } bool RubySceneImporter::ParseScene(const std::string& scene, shared_ptr<BaseNode> root, shared_ptr<ParameterList> parameter) { mFileName = "<from string>"; return ParseScene(scene.c_str(),scene.size(),root,parameter); } bool RubySceneImporter::ParseScene(const char* scene, int size, boost::shared_ptr<oxygen::BaseNode> root, boost::shared_ptr<zeitgeist::ParameterList> parameter) { // parse s-expressions pcont_t* pcont = init_continuation(const_cast<char*>(scene)); sexp_t* sexp = iparse_sexp(const_cast<char*>(scene),size,pcont); // read scene magic and version if ( (sexp == 0) || (! ReadHeader(sexp)) || (mVersionMajor != 0) || (mVersionMinor != 1) ) { destroy_sexp(sexp); destroy_continuation(pcont); return false; } // advance to next sexpression- the scene graph PushParameter(parameter); destroy_sexp(sexp); sexp = iparse_sexp(const_cast<char*>(scene),size,pcont); if ( (! mDeltaScene) && (mAutoUnlink) ) { root->UnlinkChildren(); } bool ok = mDeltaScene ? ReadDeltaGraph(sexp,root) : ReadGraph(sexp,root); destroy_sexp(sexp); destroy_continuation(pcont); PopParameter(); return ok; } void RubySceneImporter::PushParameter(shared_ptr<ParameterList> parameter) { mParameterStack.push_back(ParamEnv(parameter)); } void RubySceneImporter::PopParameter() { if (mParameterStack.empty()) { GetLog()->Debug() << "(RubySceneImporter) ERROR: PopParameter " << "called on empty stack\n"; return; } mParameterStack.pop_back(); } RubySceneImporter::ParamEnv& RubySceneImporter::GetParamEnv() { if (mParameterStack.empty()) { GetLog()->Debug() << "(RubySceneImporter) ERROR: GetParamEnv " << "called on empty stack\n"; static ParamEnv nullEnv; return nullEnv; } return mParameterStack.back(); } bool RubySceneImporter::ReadHeader(sexp_t* sexp) { // (RubySceneGraph <int majorVersion> <int minorVersion>) if ( (sexp == 0) || (sexp->ty != SEXP_LIST) || (sexp->list == 0) ) { return false; } sexp = sexp->list; if (sexp->ty != SEXP_VALUE) { return false; } string val(sexp->val); mDeltaScene = false; if (val == "RubyDeltaScene") { mDeltaScene = true; } else if (val != "RubySceneGraph") { return false; } // try to advance to version number sexp = sexp->next; if ( (sexp == 0) || (sexp->ty != SEXP_VALUE) ) { return false; } string mastr(sexp->val); int major = atoi(mastr.c_str()); if (major < 0) { return false; } sexp = sexp->next; if ( (sexp == 0) || (sexp->ty != SEXP_VALUE) ) { return false; } string mistr(sexp->val); int minor = atoi(mistr.c_str()); if (minor < 0) { return false; } mVersionMajor = major; mVersionMinor = minor; return true; } shared_ptr<Object> RubySceneImporter::CreateInstance(const string& className) { static const string prefixes[] = { "", "oxygen/", "kerosin/" }; const int n = sizeof(prefixes)/sizeof(string); for (int i=0;i<n;++i) { string name = prefixes[i] + className; if (GetCore()->ExistsClass(name)) { return GetCore()->New(name); } } return shared_ptr<Object>(); } shared_ptr<BaseNode> RubySceneImporter::CreateNode(sexp_t* sexp) { if (sexp == 0) { return shared_ptr<BaseNode>(); } string className(sexp->val); // create a class instance shared_ptr<Object> obj = CreateInstance(className); if (obj.get() == 0) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': unknown class '" << className << "'\n"; return shared_ptr<BaseNode>(); } shared_ptr<BaseNode> node = shared_dynamic_cast<BaseNode>(obj); if (node.get() == 0) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << className << "': is not derived from BaseNode'\n"; return shared_ptr<BaseNode>(); } return node; } bool RubySceneImporter::ReplaceVariable(string& param) { // replace a template parameter const ParamEnv& env = GetParamEnv(); param.erase(param.begin(),param.begin()+1); TParameterMap::const_iterator iter = env.parameterMap.find(param); if (iter == env.parameterMap.end()) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': unknown parameter '" << param << "'\n"; return false; } int idx = (*iter).second; if (idx >= env.parameter->GetSize()) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': parameter value '" << param << "' not supplied\n"; return false; } string value; ParameterList::TVector::const_iterator pIter = (*env.parameter)[idx]; if (! env.parameter->AdvanceValue(pIter,value)) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': failed to read parameter value '" << param << "'\n"; return false; } param = value; return true; } bool RubySceneImporter::EvalParameter(sexp_t* sexp, string& value) { const boost::shared_ptr<ScriptServer>& script = GetScript(); if (script.get() == 0) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': cannot get ScriptServer to eval expression\n"; return false; } if (sexp->ty != SEXP_VALUE) { return false; } string pred = sexp->val; if (pred != "eval") { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': unknown expression type '" << pred << "' in parameter list\n"; return false; } string expr; sexp = sexp->next; while (sexp != 0) { string atom; if (sexp->ty == SEXP_VALUE) { atom = sexp->val; if ( (atom[0] == '$') && (! ReplaceVariable(atom)) ) { return false; } } else { if (! EvalParameter(sexp->list, atom)) { return false; } } expr = expr + atom; expr = expr + " "; sexp = sexp->next; } if (expr.empty()) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': empty eval expression in parameter list\n"; return false; } GCValue gcValue; if (! script->Eval(expr, gcValue)) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': failed to eval expression " << expr << "\n"; return false; } if (! gcValue.GetString(value)) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': failed to get string result form expresion result\n"; return false; } return true; } bool RubySceneImporter::ReadMethodCall(sexp_t* sexp, shared_ptr<BaseNode> node) { if (sexp == 0) { return false; } // read the method name string method = sexp->val; sexp = sexp->next; // collect the parameters ParameterList parameter; while (sexp != 0) { string param; if (sexp->ty == SEXP_LIST) { if (! EvalParameter(sexp->list,param)) { return false; } } else { param = sexp->val; if ( (param[0] == '$') && (! ReplaceVariable(param)) ) { return false; } } parameter.AddValue(param); sexp = sexp->next; } // invoke the method on the object shared_ptr<Class> theClass = node->GetClass(); if (theClass.get() == 0) { GetLog()->Error() << "(RubySceneImporter) ERROR: cannot get class object for node " << node->GetFullPath() << "\n"; return false; } if (! theClass->SupportsCommand(method)) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': unknown method name '" << method << "' for node '" << node->GetFullPath() << "' (a " << theClass->GetName() << ")\n"; return false; } node->Invoke(method, parameter); return true; } bool RubySceneImporter::ParseDefine(sexp_t* sexp) { string varname = sexp->val; sexp = sexp->next; if ( (varname[0] != '$') || (varname.size() < 2) ) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': parameter name expected\n"; return false; } varname.erase(varname.begin(),varname.begin()+1); if (sexp == 0) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': define without value\n"; return false; } string value; if (sexp->ty == SEXP_LIST) { if (sexp->ty == SEXP_LIST) { if (! EvalParameter(sexp->list,value)) { return false; } } } else { value = sexp->val; if ( (value[0] == '$') && (! ReplaceVariable(value)) ) { return false; } } ParamEnv& env = GetParamEnv(); TParameterMap::const_iterator iter = env.parameterMap.find(varname); if (iter == env.parameterMap.end()) { // create a new variable env.parameter->AddValue(value); env.parameterMap[varname] = (env.parameterMap.size() - 1); } else { // update value of existing variable ParameterList::TVector::iterator valIter = (*env.parameter)[(*iter).second]; (*valIter) = value; } return true; } bool RubySceneImporter::ParseTemplate(sexp_t* sexp) { if (sexp == 0) { return false; } ParamEnv& env = GetParamEnv(); while ( (sexp != 0) && (sexp->ty == SEXP_VALUE) ) { string param = sexp->val; if (param.size() == 0) { sexp = sexp->next; continue; } if ( (param[0] != '$') || (param.size() < 2) ) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': template parameter name expected\n"; return false; } param.erase(param.begin(),param.begin()+1); TParameterMap::const_iterator iter = env.parameterMap.find(param); if (iter != env.parameterMap.end()) { GetLog()->Error() << "(RubySceneImporter) ERROR: in file '" << mFileName << "': duplicate template parameter name '" << param << "'\n"; return false; } int idx = env.parameterMap.size(); env.parameterMap[param] = idx; sexp = sexp->next; } return true; } bool RubySceneImporter::ReadDeltaGraph(sexp_t* sexp, shared_ptr<BaseNode> root) { TLeafList::const_iterator iter = root->begin(); while (sexp != 0) { switch (sexp->ty) { case SEXP_VALUE: { string name(sexp->val); if (name == "node") { while ( (sexp != 0) && (sexp->ty != SEXP_LIST) ) { sexp = sexp->next; } continue; } else { return ReadMethodCall(sexp, root); } } break; case SEXP_LIST: { sexp_t* sub = sexp->list; if (sub != 0) { shared_ptr<BaseNode> node; if ( (sub->ty == SEXP_VALUE) && (string(sub->val) == "node") ) { node = shared_dynamic_cast<BaseNode>(*iter); if (iter != node->end()) { ++iter; } } else { node = root; } if (! ReadDeltaGraph(sub, node)) { return false; } } } break; default: return false; } sexp = sexp->next; } return true; } bool RubySceneImporter::ReadGraph(sexp_t* sexp, shared_ptr<BaseNode> root) { while (sexp != 0) { switch (sexp->ty) { case SEXP_VALUE: { string name(sexp->val); if (name == "node") { sexp = sexp->next; shared_ptr<BaseNode> node = CreateNode(sexp); if (node.get() == 0) { return false; } root->AddChildReference(node); root = node; } else if (name == "select") { sexp = sexp->next; string name(sexp->val); shared_ptr<BaseNode> node = shared_dynamic_cast<BaseNode>(root->GetChild(name)); if (node.get() == 0) { GetLog()->Error() << "ERROR: Select: " << name << " not found\n"; return false; } root = node; } else if (name == "pwd") { GetLog()->Error() << "DEBUG: pwd: " << root->GetFullPath() << "\n"; } else if (name == "template") { sexp = sexp->next; return ParseTemplate(sexp); } else if (name == "define") { sexp = sexp->next; return ParseDefine(sexp); } else { return ReadMethodCall(sexp, root); } } break; case SEXP_LIST: if (! ReadGraph(sexp->list,root)) { return false; } break; default: return false; } sexp = sexp->next; } return true; } --- NEW FILE: Makefile.am --- pkglib_LTLIBRARIES = rubysceneimporter.la rubysceneimporter_la_SOURCES = export.cpp \ rubysceneimporter.cpp rubysceneimporter.h \ rubysceneimporter_c.cpp # -module tells automake we're not building a library but a loadable module # so we don't need the "lib" prefix in the module name rubysceneimporter_la_LDFLAGS = -module -avoid-version -L${top_srcdir}/utility/sfsexp/ rubysceneimporter_la_LIBADD = -lsexp AM_CPPFLAGS = -I${top_srcdir}/lib -I${top_srcdir}/utility @RUBY_CPPFLAGS@ --- NEW FILE: rubysceneimporter_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: rubysceneimporter_c.cpp,v 1.1 2005/12/13 21:48:50 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 "rubysceneimporter.h" FUNCTION(RubySceneImporter,setUnlinkOnCompleteScenes) { bool inUnlink; if ( (in.GetSize() != 1) || (! in.GetValue(in[0], inUnlink)) ) { return false; } obj->SetUnlinkOnCompleteScenes(inUnlink); return true; } void CLASS(RubySceneImporter)::DefineClass() { DEFINE_BASECLASS(oxygen/SceneImporter); DEFINE_FUNCTION(setUnlinkOnCompleteScenes); } --- NEW FILE: rubysceneimporter.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: rubysceneimporter.h,v 1.1 2005/12/13 21:48:50 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 RUBYSCENEIMPORTER_H #define RUBYSCENEIMPORTER_H #include <oxygen/sceneserver/sceneimporter.h> #include <oxygen/sceneserver/basenode.h> #include <sfsexp/sexp.h> class RubySceneImporter : public oxygen::SceneImporter { protected: //! mapping from parameter name to parameter index typedef std::map<std::string, int> TParameterMap; //! a parameter environment struct ParamEnv { TParameterMap parameterMap; boost::shared_ptr<zeitgeist::ParameterList> parameter; ParamEnv(); ParamEnv(boost::shared_ptr<zeitgeist::ParameterList> p) : parameter(p) {}; }; typedef std::list<ParamEnv> TParameterStack; public: RubySceneImporter(); virtual ~RubySceneImporter(); virtual bool ImportScene(const std::string& fileName, boost::shared_ptr<oxygen::BaseNode> root, boost::shared_ptr<zeitgeist::ParameterList> parameter); virtual bool ParseScene(const std::string& scene, boost::shared_ptr<oxygen::BaseNode> root, boost::shared_ptr<zeitgeist::ParameterList> parameter); /** constrols the behavior of the importer for complete scenes (instead of delta scenes). if 'unlink' is true, the scene below the root node given in ImportScene will automatically be unlinked before the scene is imported */ void SetUnlinkOnCompleteScenes(bool unlink); protected: virtual bool ParseScene(const char* scene, int size, boost::shared_ptr<oxygen::BaseNode> root, boost::shared_ptr<zeitgeist::ParameterList> parameter); bool ReadHeader(sexp_t* sexp); bool ReadGraph(sexp_t* sexp, boost::shared_ptr<oxygen::BaseNode> root); bool ReadDeltaGraph(sexp_t* sexp, boost::shared_ptr<oxygen::BaseNode> root); boost::shared_ptr<zeitgeist::Object> CreateInstance(const std::string& className); bool ReadMethodCall(sexp_t* _sexp, boost::shared_ptr<oxygen::BaseNode> node); bool ReplaceVariable(std::string& param); bool EvalParameter(sexp_t* sexp, std::string& value); boost::shared_ptr<oxygen::BaseNode> CreateNode(sexp_t* sexp); bool ParseTemplate(sexp_t* sexp); bool ParseDefine(sexp_t* sexp); void PushParameter(boost::shared_ptr<zeitgeist::ParameterList> parameter); void PopParameter(); ParamEnv& GetParamEnv(); protected: /** true if a scene is automatically unlinked before a new scene is imported */ bool mAutoUnlink; /** true, if a delta scene is applied */ bool mDeltaScene; /** the major version of the scen graph file */ float mVersionMajor; /** the minor version of the scen graph file */ float mVersionMinor; /** the last supplied fileName */ std::string mFileName; /** a stack of parameter environments */ TParameterStack mParameterStack; }; DECLARE_CLASS(RubySceneImporter); #endif // RUBYSCENEIMPORTER_H |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:48:58
|
Update of /cvsroot/simspark/simspark/spark/plugin/openglsyssdl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv885/openglsyssdl Added Files: Makefile.am export.cpp openglsystemsdl.cpp openglsystemsdl.h openglsystemsdl_c.cpp Log Message: - added spark specific plugins --- NEW FILE: export.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: export.cpp,v 1.1 2005/12/13 21:48:48 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 "openglsystemsdl.h" #include <zeitgeist/zeitgeist.h> ZEITGEIST_EXPORT_BEGIN() ZEITGEIST_EXPORT(OpenGLSystemSDL); ZEITGEIST_EXPORT_END() --- NEW FILE: openglsystemsdl.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: openglsystemsdl.cpp,v 1.1 2005/12/13 21:48:48 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 "openglsystemsdl.h" #include <zeitgeist/logserver/logserver.h> #include <zeitgeist/scriptserver/scriptserver.h> #include <GL/gl.h> #include <SDL/SDL.h> using namespace std; using namespace boost; using namespace kerosin; using namespace zeitgeist; OpenGLSystemSDL *gInputSystem; OpenGLSystemSDL::OpenGLSystemSDL() : OpenGLSystem() { } OpenGLSystemSDL::~OpenGLSystemSDL() { SDL_Quit(); } void OpenGLSystemSDL::Update() { // Our SDL event placeholder. SDL_Event event; // Grab all the events off the queue. while( SDL_PollEvent( &event ) ) { } } void OpenGLSystemSDL::SwapBuffers() { SDL_GL_SwapBuffers(); } bool OpenGLSystemSDL::Init() { int result = SDL_Init(SDL_INIT_VIDEO); if( result < 0 ) { GetLog()->Error() << "ERROR: (OpenGLSystemSDL) Could not init SDL." << "SDL_Init returned error " << result << "\n"; return false; } const SDL_VideoInfo* info = SDL_GetVideoInfo(); int redBits; int greenBits; int blueBits; int alphaBits; int depthBits; int stencilBits; bool doubleBuffer; bool fullScreen; int xRes, yRes; string title; bool getConfig = ( GetScript()->GetVariable("Viewport.RedBits", redBits) && GetScript()->GetVariable("Viewport.GreenBits", greenBits) && GetScript()->GetVariable("Viewport.BlueBits", blueBits) && GetScript()->GetVariable("Viewport.AlphaBits", alphaBits) && GetScript()->GetVariable("Viewport.DepthBits", depthBits) && GetScript()->GetVariable("Viewport.StencilBits", stencilBits) && GetScript()->GetVariable("Viewport.DoubleBuffer", doubleBuffer) && GetScript()->GetVariable("Viewport.FullScreen", fullScreen) && GetScript()->GetVariable("Viewport.XRes", xRes) && GetScript()->GetVariable("Viewport.YRes", yRes) && GetScript()->GetVariable("Application.Title", title) ); if (! getConfig) { GetLog()->Error() << "(OpenGLSystemSDL) error reading config from ScriptServer\n"; return false; } GetLog()->Normal() << "(OpenGLSystemSDL) bits per channel (RGB): " << redBits << " " << greenBits << " " << blueBits << "\n"; GetLog()->Normal() << "(OpenGLSystemSDL)" << " depth bits= " << depthBits << " alpha depth= " << alphaBits << " stencil depth= " << stencilBits << "\n"; GetLog()->Normal() << "(OpenGLSystemSDL)" << " doubleBuffer= " << doubleBuffer << " fullScreen= " << fullScreen << "\n"; GetLog()->Normal() << "(OpenGLSystemSDL)" << " xRes = " << xRes << " yRes = " << yRes << "\n"; SDL_GL_SetAttribute(SDL_GL_RED_SIZE, redBits); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, greenBits); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, blueBits); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, alphaBits); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthBits); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBits); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, doubleBuffer ? 1:0); int flags = SDL_OPENGL; if (fullScreen) { flags |= SDL_FULLSCREEN; } SDL_Surface *screen = SDL_SetVideoMode (xRes, yRes, info->vfmt->BitsPerPixel, flags); if (screen == 0) { GetLog()->Error() << "ERROR: (OpenGLSystemSDL) SDL_SetVideoMode() failed\n"; return false; } SDL_WarpMouse(xRes/2,yRes/2); SDL_WM_SetCaption(title.c_str(), NULL); glClear(GL_COLOR_BUFFER_BIT); GetLog()->Normal() << "(OpenGLSystemSDL) Initialized OpenGL Window\n"; const unsigned char* glRenderer = glGetString(GL_RENDERER); const unsigned char* glVersion = glGetString(GL_VERSION); const unsigned char* glExtensions = glGetString(GL_EXTENSIONS); GetLog()->Normal() << "(OpenGLSystemSDL) GL_RENDERER: " << glRenderer << "\n"; GetLog()->Normal() << "(OpenGLSystemSDL) GL_VERSION: " << glVersion << "\n"; GetLog()->Normal() << "(OpenGLSystemSDL) GL_EXTENSIONS: " << glExtensions << "\n"; GetLog()->Normal() << "(OpenGLSystemSDL) GL_MAX_LIGHTS: " << GL_MAX_LIGHTS << "\n"; return true; } --- NEW FILE: Makefile.am --- if BUILD_KEROSIN pkglib_LTLIBRARIES = openglsyssdl.la endif openglsyssdl_la_SOURCES = \ export.cpp \ openglsystemsdl.cpp \ openglsystemsdl_c.cpp # -module tells automake we're not building a library but a loadable module # so we don't need the "lib" prefix in the module name openglsyssdl_la_LDFLAGS = -module -version-info 0:0:0 AM_CPPFLAGS = -I${top_srcdir}/lib @RUBY_CPPFLAGS@ --- NEW FILE: openglsystemsdl.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: openglsystemsdl.h,v 1.1 2005/12/13 21:48:48 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. OpenGLSystemSDL HISTORY: 04.12.05 - MR - Initial version */ #ifndef OPENGLSYSTEMSDL_H__ #define OPENGLSYSTEMSDL_H__ #include <kerosin/openglserver/openglsystem.h> class OpenGLSystemSDL : public kerosin::OpenGLSystem { // // functions // public: OpenGLSystemSDL(); virtual ~OpenGLSystemSDL(); //! init the opengl subsystem virtual bool Init(); //! called periodically to allow for any event processing virtual void Update(); /** called after each frame in order to swap buffer in OpenGLSystems that support double buffering */ virtual void SwapBuffers(); }; DECLARE_CLASS(OpenGLSystemSDL); #endif //OPENGLSYSTEMSDL_H__ --- NEW FILE: openglsystemsdl_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: openglsystemsdl_c.cpp,v 1.1 2005/12/13 21:48:48 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 "openglsystemsdl.h" void CLASS(OpenGLSystemSDL)::DefineClass() { DEFINE_BASECLASS(kerosin/OpenGLSystem); } |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:48:57
|
Update of /cvsroot/simspark/simspark/spark/plugin/inputsdl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv885/inputsdl Added Files: .cvsignore Makefile.am export.cpp inputdevicesdl.h inputdevicesdl_c.cpp inputsystemsdl.cpp inputsystemsdl.h inputsystemsdl_c.cpp keyboardsdl.cpp keyboardsdl.h keyboardsdl_c.cpp mousesdl.cpp mousesdl.h mousesdl_c.cpp timersdl.cpp timersdl.h timersdl_c.cpp Log Message: - added spark specific plugins --- NEW FILE: mousesdl.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: mousesdl.h,v 1.1 2005/12/13 21:48:48 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. MouseSDL HISTORY: 22.08.02 - MK - Initial version */ #ifndef MOUSESDL_H__ #define MOUSESDL_H__ #include "inputdevicesdl.h" class MouseSDL : public InputDeviceSDL { // // functions // public: MouseSDL(); virtual ~MouseSDL(); //! init the device virtual bool Init(kerosin::InputSystem* inputSystem); //! this filters an SDL specific input virtual int EventFilter(const SDL_Event* event); }; DECLARE_CLASS(MouseSDL); #endif //MOUSESDL_H__ --- NEW FILE: keyboardsdl.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: keyboardsdl.cpp,v 1.1 2005/12/13 21:48:48 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 "keyboardsdl.h" #include <kerosin/inputserver/inputserver.h> #include <zeitgeist/logserver/logserver.h> using namespace kerosin; KeyboardSDL::KeyboardSDL() { SetupSymMap(); } KeyboardSDL::~KeyboardSDL() { } void KeyboardSDL::SetupSymMap() { mSymbols.clear(); // symbols taken from <SDL/SDL_keysm.h> mSymbols[SDLK_BACKSPACE] = InputServer::IC_BACKSPACE; mSymbols[SDLK_TAB] = InputServer::InputServer::IC_TAB; // SDLK_CLEAR ?? mSymbols[SDLK_RETURN] = InputServer::IC_RETURN; mSymbols[SDLK_PAUSE] = InputServer::IC_PAUSE; mSymbols[SDLK_ESCAPE] = InputServer::IC_ESCAPE; mSymbols[SDLK_SPACE] = InputServer::IC_SPACE; // SDLK_EXCLAIM // SDLK_QUOTEDBL // SDLK_HASH // SDLK_DOLLAR // SDLK_AMPERSAND // SDLK_QUOTE // SDLK_LEFTPAREN // SDLK_RIGHTPAREN // SDLK_ASTERISK // SDLK_PLUS mSymbols[SDLK_COMMA] = InputServer::IC_COMMA; mSymbols[SDLK_MINUS] = InputServer::IC_MINUS; mSymbols[SDLK_PERIOD] = InputServer::IC_PERIOD; mSymbols[SDLK_SLASH] = InputServer::IC_SLASH; mSymbols[SDLK_0] = InputServer::IC_0; mSymbols[SDLK_1] = InputServer::IC_1; mSymbols[SDLK_2] = InputServer::IC_2; mSymbols[SDLK_3] = InputServer::IC_3; mSymbols[SDLK_4] = InputServer::IC_4; mSymbols[SDLK_5] = InputServer::IC_5; mSymbols[SDLK_6] = InputServer::IC_6; mSymbols[SDLK_7] = InputServer::IC_7; mSymbols[SDLK_8] = InputServer::IC_8; mSymbols[SDLK_9] = InputServer::IC_9; // SDLK_COLON mSymbols[SDLK_SEMICOLON] = InputServer::IC_SEMICOLON; // SDLK_LESS // SDLK_EQUALS mSymbols[SDLK_EQUALS] = InputServer::IC_EQUALS; // SDLK_GREATER // SDLK_QUESTION // SDLK_AT mSymbols[SDLK_LEFTBRACKET] = InputServer::IC_LBRACKET; mSymbols[SDLK_BACKSLASH] = InputServer::IC_BACKSLASH; mSymbols[SDLK_RIGHTBRACKET] = InputServer::IC_RBRACKET; // SDLK_CARET // SDLK_UNDERSCORE // SDLK_BACKQUOTE mSymbols[SDLK_a] = InputServer::IC_A; mSymbols[SDLK_b] = InputServer::IC_B; mSymbols[SDLK_c] = InputServer::IC_C; mSymbols[SDLK_d] = InputServer::IC_D; mSymbols[SDLK_e] = InputServer::IC_E; mSymbols[SDLK_f] = InputServer::IC_F; mSymbols[SDLK_g] = InputServer::IC_G; mSymbols[SDLK_h] = InputServer::IC_H; mSymbols[SDLK_i] = InputServer::IC_I; mSymbols[SDLK_j] = InputServer::IC_J; mSymbols[SDLK_k] = InputServer::IC_K; mSymbols[SDLK_l] = InputServer::IC_L; mSymbols[SDLK_m] = InputServer::IC_M; mSymbols[SDLK_n] = InputServer::IC_N; mSymbols[SDLK_o] = InputServer::IC_O; mSymbols[SDLK_p] = InputServer::IC_P; mSymbols[SDLK_q] = InputServer::IC_Q; mSymbols[SDLK_r] = InputServer::IC_R; mSymbols[SDLK_s] = InputServer::IC_S; mSymbols[SDLK_t] = InputServer::IC_T; mSymbols[SDLK_u] = InputServer::IC_U; mSymbols[SDLK_v] = InputServer::IC_V; mSymbols[SDLK_w] = InputServer::IC_W; mSymbols[SDLK_x] = InputServer::IC_X; mSymbols[SDLK_y] = InputServer::IC_Y; mSymbols[SDLK_z] = InputServer::IC_Z; mSymbols[SDLK_DELETE] = InputServer::IC_DELETE; // SDLK_WORLD_0 // [...] // SDLK_WORLD_95 mSymbols[SDLK_KP0] = InputServer::IC_KP0; mSymbols[SDLK_KP1] = InputServer::IC_KP1; mSymbols[SDLK_KP2] = InputServer::IC_KP2; mSymbols[SDLK_KP3] = InputServer::IC_KP3; mSymbols[SDLK_KP4] = InputServer::IC_KP4; mSymbols[SDLK_KP5] = InputServer::IC_KP5; mSymbols[SDLK_KP6] = InputServer::IC_KP6; mSymbols[SDLK_KP7] = InputServer::IC_KP7; mSymbols[SDLK_KP8] = InputServer::IC_KP8; mSymbols[SDLK_KP9] = InputServer::IC_KP9; mSymbols[SDLK_KP_PERIOD] = InputServer::IC_KP_DECIMAL; mSymbols[SDLK_KP_DIVIDE] = InputServer::IC_KP_DIVIDE; mSymbols[SDLK_KP_MULTIPLY] = InputServer::IC_KP_MULTIPLY; mSymbols[SDLK_KP_MINUS] = InputServer::IC_KP_MINUS; mSymbols[SDLK_KP_PLUS] = InputServer::IC_KP_PLUS; mSymbols[SDLK_KP_ENTER] = InputServer::IC_KP_ENTER; // SDLK_KP_EQUALS mSymbols[SDLK_UP] = InputServer::IC_UP; mSymbols[SDLK_DOWN] = InputServer::IC_DOWN; mSymbols[SDLK_RIGHT] = InputServer::IC_RIGHT; mSymbols[SDLK_LEFT] = InputServer::IC_LEFT; mSymbols[SDLK_INSERT] = InputServer::IC_INSERT; mSymbols[SDLK_HOME] = InputServer::IC_HOME; mSymbols[SDLK_END] = InputServer::IC_END; mSymbols[SDLK_PAGEUP] = InputServer::IC_PAGEUP; mSymbols[SDLK_PAGEDOWN] = InputServer::IC_PAGEDOWN; mSymbols[SDLK_F1] = InputServer::IC_F1; mSymbols[SDLK_F2] = InputServer::IC_F2; mSymbols[SDLK_F3] = InputServer::IC_F3; mSymbols[SDLK_F4] = InputServer::IC_F4; mSymbols[SDLK_F5] = InputServer::IC_F5; mSymbols[SDLK_F6] = InputServer::IC_F6; mSymbols[SDLK_F7] = InputServer::IC_F7; mSymbols[SDLK_F8] = InputServer::IC_F8; mSymbols[SDLK_F9] = InputServer::IC_F9; mSymbols[SDLK_F10] = InputServer::IC_F10; mSymbols[SDLK_F11] = InputServer::IC_F11; mSymbols[SDLK_F12] = InputServer::IC_F12; // SDLK_F13 // SDLK_F14 // SDLK_F15 mSymbols[SDLK_NUMLOCK] = InputServer::IC_NUMLOCK; mSymbols[SDLK_CAPSLOCK] = InputServer::IC_CAPSLOCK; mSymbols[SDLK_SCROLLOCK] = InputServer::IC_SCROLLOCK; mSymbols[SDLK_RSHIFT] = InputServer::IC_RSHIFT; mSymbols[SDLK_LSHIFT] = InputServer::IC_LSHIFT; mSymbols[SDLK_RCTRL] = InputServer::IC_RCTRL; mSymbols[SDLK_LCTRL] = InputServer::IC_LCTRL; mSymbols[SDLK_RALT] = InputServer::IC_RALT; mSymbols[SDLK_LALT] = InputServer::IC_LALT; // SDLK_RMETA // SDLK_LMETA mSymbols[SDLK_LSUPER] = InputServer::IC_LSUPER; mSymbols[SDLK_RSUPER] = InputServer::IC_RSUPER; // SDLK_MODE // SDLK_COMPOSE // SDLK_HELP mSymbols[SDLK_PRINT] = InputServer::IC_PRINT; // SDLK_SYSREQ // SDLK_BREAK // SDLK_MENU // SDLK_POWER // SDLK_EURO // SDLK_UNDO } bool KeyboardSDL::Init(kerosin::InputSystem *inputSystem) { return InputDevice::Init(inputSystem); } bool KeyboardSDL::TranslateSymbol(int& sym) { TSymMap::iterator iter = mSymbols.find(sym); if (iter == mSymbols.end()) { return false; } sym = (*iter).second; return true; } int KeyboardSDL::EventFilter(const SDL_Event* event) { // we only want keyboard events if ( (event->type != SDL_KEYDOWN) && (event->type != SDL_KEYUP) ) { return 1; } unsigned int& modState = mInputSystem->GetInputServer()->mModifierState; if (event->key.keysym.mod & KMOD_LSHIFT) { modState |= InputServer::eLShift; } if (event->key.keysym.mod & KMOD_RSHIFT) { modState |= InputServer::eRShift; } if (event->key.keysym.mod & KMOD_LALT) { modState |= InputServer::eLAlt; } if (event->key.keysym.mod & KMOD_RALT) { modState |= InputServer::eRAlt; } if (event->key.keysym.sym == 0) { return 1; } int sym = event->key.keysym.sym; if (! TranslateSymbol(sym)) { GetLog()->Warning() << "(KeyboardSDL) WARNING: encountered unknown SDL key symbol " << sym << "\n"; return 1; } InputServer::Input input(InputServer::eButton, sym); input.data.l = (event->type == SDL_KEYDOWN); mInputSystem->AddInputInternal(input); return 0; } --- NEW FILE: timersdl.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: timersdl.h,v 1.1 2005/12/13 21:48:48 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. TimerSDL HISTORY: 24.10.02 - MK - Initial version */ #ifndef TIMERSDL_H__ #define TIMERSDL_H__ #include "inputdevicesdl.h" /** \class TimerSDL returns the elapsed time since the last call in milliseconds. */ class TimerSDL : public InputDeviceSDL { // // functions // public: TimerSDL(); virtual ~TimerSDL(); //! init the device virtual bool Init(kerosin::InputSystem* inputSystem); //! this filters an SDL specific input virtual int EventFilter(const SDL_Event* event); //! return an Input void GetInput(kerosin::InputServer::Input &input); protected: unsigned long mLastTicks; }; DECLARE_CLASS(TimerSDL); #endif //MOUSESDL_H__ --- NEW FILE: mousesdl.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: mousesdl.cpp,v 1.1 2005/12/13 21:48:48 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 "mousesdl.h" #include <zeitgeist/logserver/logserver.h> using namespace kerosin; MouseSDL::MouseSDL() { } MouseSDL::~MouseSDL() { } bool MouseSDL::Init(kerosin::InputSystem* inputSystem) { return InputDevice::Init(inputSystem); } int MouseSDL::EventFilter(const SDL_Event* event) { // we only want mouse events switch (event->type) { case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { InputServer::Input input(InputServer::eButton); switch (event->button.button) { case SDL_BUTTON_LEFT: input.code = mInputSystem->GetInputServer()->IC_MOUSE_LEFT; break; case SDL_BUTTON_RIGHT: input.code = mInputSystem->GetInputServer()->IC_MOUSE_RIGHT; break; case SDL_BUTTON_MIDDLE: input.code = mInputSystem->GetInputServer()->IC_MOUSE_MIDDLE; break; default: return 1; } input.data.l = (event->type == SDL_MOUSEBUTTONDOWN); mInputSystem->AddInputInternal(input); return 0; } break; case SDL_MOUSEMOTION: { InputServer::Input input ( InputServer::eAxis, mInputSystem->GetInputServer()->IC_AXISX ); input.data.l = event->motion.xrel; mInputSystem->AddInputInternal(input); input.code = mInputSystem->GetInputServer()->IC_AXISY; input.data.l = event->motion.yrel; mInputSystem->AddInputInternal(input); return 0; } break; } return 1; } --- NEW FILE: inputsystemsdl.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: inputsystemsdl.h,v 1.1 2005/12/13 21:48:48 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. InputSystemSDL HISTORY: 21.08.02 - MK - Initial version */ #ifndef INPUTSYSTEMSDL_H__ #define INPUTSYSTEMSDL_H__ #include <deque> #include <kerosin/inputserver/inputsystem.h> #include <kerosin/inputserver/inputserver.h> #include <kerosin/openglserver/openglserver.h> #include <SDL/SDL.h> struct SDL_mutex; class TimerSDL; class InputSystemSDL : public kerosin::InputSystem { // // functions // public: InputSystemSDL(); virtual ~InputSystemSDL(); virtual bool Init(kerosin::InputServer* inputServer); virtual bool CreateDevice(const std::string& deviceName); SDL_mutex* GetMutex() const; int EventFilter(const SDL_Event* event); //! add the input to the queue virtual void AddInput(kerosin::InputServer::Input& input); //! retrieve an input from the queue virtual bool GetInput(kerosin::InputServer::Input& input); protected: virtual bool UpdateTimerInput(kerosin::InputServer::Input& input); // // members // private: SDL_mutex* mMutex; boost::shared_ptr<TimerSDL> mTimer; }; DECLARE_CLASS(InputSystemSDL); #endif //INPUTSYSTEMSDL_H__ --- NEW FILE: keyboardsdl.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: keyboardsdl.h,v 1.1 2005/12/13 21:48:48 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. KeyboardSDL HISTORY: 22.08.02 - MK - Initial version */ #ifndef KEYBOARDSDL_H__ #define KEYBOARDSDL_H__ #include "inputdevicesdl.h" class KeyboardSDL : public InputDeviceSDL { // // functions // public: KeyboardSDL(); virtual ~KeyboardSDL(); //! init the device virtual bool Init(kerosin::InputSystem* inputSystem); //! this filters an SDL specific input virtual int EventFilter(const SDL_Event* event); protected: /** sets up the mapping from SDL key constants to InputServer key constants */ void SetupSymMap(); /** translates a SDL key constant to an InputServer key constant. returns true on success */ bool TranslateSymbol(int& sym); protected: typedef std::map<int,int> TSymMap; //! mapping fomr SDL key constants to InputServer key constants TSymMap mSymbols; }; DECLARE_CLASS(KeyboardSDL); #endif //KEYBOARDSDL_H__ --- NEW FILE: inputsystemsdl_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: inputsystemsdl_c.cpp,v 1.1 2005/12/13 21:48:48 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 "inputsystemsdl.h" void CLASS(InputSystemSDL)::DefineClass() { DEFINE_BASECLASS(kerosin/InputSystem); } --- NEW FILE: inputdevicesdl.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: inputdevicesdl.h,v 1.1 2005/12/13 21:48:48 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. InputDeviceSDL HISTORY: 21.08.02 - MK - Initial version */ #ifndef INPUTDEVICESDL_H__ #define INPUTDEVICESDL_H__ #include <kerosin/inputserver/inputdevice.h> #include <kerosin/inputserver/inputserver.h> #include <SDL/SDL.h> /** \class InputDeviceSDL This class introduces SDL-specific callback functions for the event filtering. */ class InputDeviceSDL : public kerosin::InputDevice { // // functions // public: //! this filters an SDL specific input virtual int EventFilter(const SDL_Event* event) = 0; }; DECLARE_ABSTRACTCLASS(InputDeviceSDL); #endif //INPUTDEVICESDL_H__ --- NEW FILE: inputsystemsdl.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: inputsystemsdl.cpp,v 1.1 2005/12/13 21:48:48 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 "inputsystemsdl.h" #include "inputdevicesdl.h" #include <kerosin/inputserver/inputserver.h> #include <zeitgeist/logserver/logserver.h> #include <SDL/SDL_thread.h> #include "timersdl.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; /*! This function is used to filter SDL Events and delegate them to the input device which registered for the event type. NOTE: This function may run in a different thread, so care has to be taken when accessing the global object. Things to watch out for: - gDeviceList changes (done by individual devices (construction/destruction)) handled - Events are pushed into a device (done by EventFilter) - Events are taken out of a device (this is done by the inputserver) */ InputSystemSDL *gInputSystem; static int EventFilterCallback(const SDL_Event *event) { if (gInputSystem) { return gInputSystem->EventFilter(event); } else { return 1; } } InputSystemSDL::InputSystemSDL() : InputSystem(), mMutex(NULL) { gInputSystem = this; } InputSystemSDL::~InputSystemSDL() { SDL_LockMutex(mMutex); SDL_SetEventFilter(NULL); gInputSystem = NULL; SDL_UnlockMutex(mMutex); SDL_DestroyMutex(mMutex); mMutex = NULL; } bool InputSystemSDL::Init(InputServer *inputServer) { if (InputSystem::Init(inputServer) == false) return false; // here we check whether SDL has been initialized prior to adding this // input is part of the video subsystem (because of event loops, etc..) if (!SDL_WasInit(SDL_INIT_VIDEO)) { GetLog()->Error() << "ERROR: (InputSystemSDL) SDL not initialized!" << std::endl; return false; } // we need a mutex object mMutex = SDL_CreateMutex(); // setup the filtering function SDL_SetEventFilter(EventFilterCallback); return true; } bool InputSystemSDL::CreateDevice(const std::string &deviceName) { // first, we mangle the deviceName to avoid nameclashes std::string mangledName = deviceName + "SDL"; shared_ptr<InputDevice> device = shared_static_cast<InputDevice>(GetCore()->New(mangledName)); if (device.get() == NULL) { GetLog()->Error() << "ERROR: (InputSystemSDL) Creating device '" << mangledName << "'" << std::endl; return false; } // initialize the device if (device->Init(this) == false) { GetLog()->Error() << "ERROR: (InputSystemSDL) Initializing device '" << mangledName << "'" << std::endl; return false; } // some special case handling for the timer (FIXME) if (mangledName.compare("TimerSDL") == 0) { mTimer = shared_static_cast<TimerSDL>(device); } else { SDL_LockMutex(mMutex); // try to link the device into the inputserver if (AddChildReference(device) == false) { GetLog()->Error() << "ERROR: (InputSystemSDL) Linking device '" << mangledName << "'" << std::endl; SDL_UnlockMutex(mMutex); return false; } SDL_UnlockMutex(mMutex); } return true; } int InputSystemSDL::EventFilter(const SDL_Event *event) { int ret = 1; SDL_LockMutex(mMutex); // loop through all children for (TLeafList::iterator i = mChildren.begin(); i!=mChildren.end(); ++i) { shared_ptr<InputDeviceSDL> device = shared_static_cast<InputDeviceSDL>(*i); // every device gets a chance to filter the event, the first one // who claims it, gets it if (device->EventFilter(event) == 0) { ret = 0; break; } } SDL_UnlockMutex(mMutex); return ret; } void InputSystemSDL::AddInput(kerosin::InputServer::Input &input) { SDL_LockMutex(mMutex); InputSystem::AddInput(input); SDL_UnlockMutex(mMutex); } bool InputSystemSDL::GetInput(kerosin::InputServer::Input &input) { SDL_LockMutex(mMutex); bool ret = InputSystem::GetInput(input); SDL_UnlockMutex(mMutex); return ret; } bool InputSystemSDL::UpdateTimerInput(InputServer::Input &input) { if (mTimer.get() == NULL) { return false; } else { mTimer->GetInput(input); return true; } } --- NEW FILE: export.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: export.cpp,v 1.1 2005/12/13 21:48:48 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 "inputsystemsdl.h" #include "inputdevicesdl.h" #include "keyboardsdl.h" #include "mousesdl.h" #include "timersdl.h" #include <zeitgeist/zeitgeist.h> ZEITGEIST_EXPORT_BEGIN() ZEITGEIST_EXPORT(InputSystemSDL); ZEITGEIST_EXPORT(InputDeviceSDL); ZEITGEIST_EXPORT(KeyboardSDL); ZEITGEIST_EXPORT(MouseSDL); ZEITGEIST_EXPORT(TimerSDL); ZEITGEIST_EXPORT_END() --- NEW FILE: timersdl_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: timersdl_c.cpp,v 1.1 2005/12/13 21:48:48 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 "timersdl.h" void CLASS(TimerSDL)::DefineClass() { DEFINE_BASECLASS(InputDeviceSDL); } --- NEW FILE: mousesdl_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: mousesdl_c.cpp,v 1.1 2005/12/13 21:48:48 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 "mousesdl.h" void CLASS(MouseSDL)::DefineClass() { DEFINE_BASECLASS(InputDeviceSDL); } --- NEW FILE: inputdevicesdl_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) 2004 RoboCup Soccer Server 3D Maintenance Group $Id: inputdevicesdl_c.cpp,v 1.1 2005/12/13 21:48:48 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 "inputdevicesdl.h" void CLASS(InputDeviceSDL)::DefineClass() { DEFINE_BASECLASS(kerosin/InputDevice); } --- NEW FILE: Makefile.am --- if BUILD_KEROSIN pkglib_LTLIBRARIES = inputsdl.la endif inputsdl_la_SOURCES = export.cpp \ inputdevicesdl.h inputdevicesdl_c.cpp \ inputsystemsdl.cpp \ inputsystemsdl.h \ inputsystemsdl_c.cpp \ keyboardsdl.cpp \ keyboardsdl.h \ keyboardsdl_c.cpp \ mousesdl.cpp \ mousesdl.h \ mousesdl_c.cpp \ timersdl.cpp \ timersdl.h \ timersdl_c.cpp # -module tells automake we're not building a library but a loadable module # so we don't need the "lib" prefix in the module name inputsdl_la_LDFLAGS = -module -version-info 0:0:0 AM_CPPFLAGS = -I${top_srcdir}/lib @RUBY_CPPFLAGS@ --- NEW FILE: timersdl.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: timersdl.cpp,v 1.1 2005/12/13 21:48:48 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 "timersdl.h" #include <zeitgeist/logserver/logserver.h> using namespace kerosin; TimerSDL::TimerSDL() : mLastTicks(0) { } TimerSDL::~TimerSDL() { } bool TimerSDL::Init(kerosin::InputSystem *inputSystem) { if (InputDevice::Init(inputSystem) == false) { return false; } mLastTicks = SDL_GetTicks(); return true; } int TimerSDL::EventFilter(const SDL_Event* event) { return 1; } void TimerSDL::GetInput(kerosin::InputServer::Input& input) { input.type = InputServer::eAxis; input.code = mInputSystem->GetInputServer()->IC_AXIST; unsigned int ticks = SDL_GetTicks(); // FIXME: ticks might wrap input.data.l = ticks - mLastTicks; mLastTicks = ticks; } --- NEW FILE: keyboardsdl_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: keyboardsdl_c.cpp,v 1.1 2005/12/13 21:48:48 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 "keyboardsdl.h" void CLASS(KeyboardSDL)::DefineClass() { DEFINE_BASECLASS(InputDeviceSDL); } --- NEW FILE: .cvsignore --- .deps .libs Makefile Makefile.in *.la *.lo |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:48:56
|
Update of /cvsroot/simspark/simspark/spark/plugin/filesystemstd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv885/filesystemstd Added Files: .cvsignore Makefile.am export.cpp filesystemstd.cpp filesystemstd.h filesystemstd_c.cpp Log Message: - added spark specific plugins --- NEW FILE: .cvsignore --- .deps .libs Makefile Makefile.in *.la *.lo --- NEW FILE: export.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: export.cpp,v 1.1 2005/12/13 21:48:48 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 "filesystemstd.h" #include <zeitgeist/zeitgeist.h> ZEITGEIST_EXPORT_BEGIN() ZEITGEIST_EXPORT(FileSystemSTD); ZEITGEIST_EXPORT_END() --- NEW FILE: filesystemstd_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: filesystemstd_c.cpp,v 1.1 2005/12/13 21:48:48 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 "filesystemstd.h" void CLASS(FileSystemSTD)::DefineClass() { DEFINE_BASECLASS(zeitgeist/FileSystem); } --- NEW FILE: Makefile.am --- pkglib_LTLIBRARIES = filesystemstd.la filesystemstd_la_SOURCES = export.cpp \ filesystemstd.cpp filesystemstd.h \ filesystemstd_c.cpp # -module tells automake we're not building a library but a loadable module # so we don't need the "lib" prefix in the module name filesystemstd_la_LDFLAGS = -module -version-info 0:0:0 AM_CPPFLAGS = -I${top_srcdir}/lib @RUBY_CPPFLAGS@ --- NEW FILE: filesystemstd.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: filesystemstd.cpp,v 1.1 2005/12/13 21:48:48 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 "filesystemstd.h" #include <salt/fileclasses.h> using namespace boost; using namespace salt; using namespace std; // constructor FileSystemSTD::FileSystemSTD() { } // destructor FileSystemSTD::~FileSystemSTD() { } bool FileSystemSTD::SetPath(const string& inPath) { // release memory for old path mPath = inPath; return true; } // // This function is really simple. It appends inName to mPath and // tries to open the combined name as a readonly file. // shared_ptr<salt::RFile> FileSystemSTD::Open(const string& inName) { shared_ptr<salt::RFile> file(new StdFile()); std::string fileName = mPath + inName; if(! file->Open(fileName.c_str())) { file.reset(); } return file; } int FileSystemSTD::ForEachFile(const string& expression, TCallback callback, void* param) { // todo return 0; } --- NEW FILE: filesystemstd.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: filesystemstd.h,v 1.1 2005/12/13 21:48:48 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. FileSystemSTD */ #ifndef FILESYSTEMSTD_H__ #define FILESYSTEMSTD_H__ #include <string> #include <zeitgeist/fileserver/filesystem.h> /** \class FileSystemSTD FileSystemSTD - The 'Standard' File System OK, this one is really simple. It just loads a file from a given base directory ... no fancy conversions, just a simple Open("blah"). */ class FileSystemSTD : public zeitgeist::FileSystem { // // Methods // public: FileSystemSTD(); virtual ~FileSystemSTD(); virtual boost::shared_ptr<salt::RFile> Open(const std::string& inName); virtual bool SetPath(const std::string& inPath); virtual int ForEachFile(const std::string& expression, TCallback callback, void* param); // // members // protected: std::string mPath; }; DECLARE_CLASS(FileSystemSTD); #endif //__FILESYS_STD_H__ |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:48:55
|
Update of /cvsroot/simspark/simspark/spark/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv885 Added Files: Makefile.am Log Message: - added spark specific plugins --- NEW FILE: Makefile.am --- SUBDIRS = \ filesystemstd \ inputsdl \ openglsyssdl \ sexpparser \ rubysceneimporter\ sparkmonitor\ sparkagent |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:46:53
|
Update of /cvsroot/simspark/simspark/spark/plugin/sexpparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv481/sexpparser Log Message: Directory /cvsroot/simspark/simspark/spark/plugin/sexpparser added to the repository |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:46:50
|
Update of /cvsroot/simspark/simspark/spark/plugin/inputsdl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv481/inputsdl Log Message: Directory /cvsroot/simspark/simspark/spark/plugin/inputsdl added to the repository |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:46:50
|
Update of /cvsroot/simspark/simspark/spark/plugin/sparkagent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv481/sparkagent Log Message: Directory /cvsroot/simspark/simspark/spark/plugin/sparkagent added to the repository |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:46:50
|
Update of /cvsroot/simspark/simspark/spark/plugin/rubysceneimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv481/rubysceneimporter Log Message: Directory /cvsroot/simspark/simspark/spark/plugin/rubysceneimporter added to the repository |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:46:50
|
Update of /cvsroot/simspark/simspark/spark/plugin/filesystemstd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv481/filesystemstd Log Message: Directory /cvsroot/simspark/simspark/spark/plugin/filesystemstd added to the repository |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:46:50
|
Update of /cvsroot/simspark/simspark/spark/plugin/openglsyssdl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv481/openglsyssdl Log Message: Directory /cvsroot/simspark/simspark/spark/plugin/openglsyssdl added to the repository |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:46:50
|
Update of /cvsroot/simspark/simspark/spark/plugin/sparkmonitor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv481/sparkmonitor Log Message: Directory /cvsroot/simspark/simspark/spark/plugin/sparkmonitor added to the repository |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:40:31
|
Update of /cvsroot/simspark/simspark/spark/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31802/plugin Log Message: Directory /cvsroot/simspark/simspark/spark/plugin added to the repository |
|
From: Markus R. <rol...@us...> - 2005-12-13 21:26:48
|
Update of /cvsroot/simspark/simspark/spark/oxygen/simulationserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28317 Modified Files: netclient.cpp Log Message: - include cerrno to make it compile on debian testing/unstable with gcc4 Index: netclient.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/simulationserver/netclient.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** netclient.cpp 5 Dec 2005 21:21:18 -0000 1.1 --- netclient.cpp 13 Dec 2005 21:26:40 -0000 1.2 *************** *** 24,27 **** --- 24,28 ---- #include <netinet/in.h> #include <rcssnet/exception.hpp> + #include <cerrno> using namespace oxygen; |
|
From: Markus R. <rol...@us...> - 2005-12-05 21:50:17
|
Update of /cvsroot/simspark/simspark/spark/zeitgeist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22368 Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in zeitgeist-config |
|
From: Markus R. <rol...@us...> - 2005-12-05 21:50:17
|
Update of /cvsroot/simspark/simspark/spark/zeitgeist/logserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22368/logserver Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in zeitgeist-config |
|
From: Markus R. <rol...@us...> - 2005-12-05 21:50:17
|
Update of /cvsroot/simspark/simspark/spark/zeitgeist/fileserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22368/fileserver Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in zeitgeist-config |
|
From: Markus R. <rol...@us...> - 2005-12-05 21:50:17
|
Update of /cvsroot/simspark/simspark/spark/zeitgeist/randomserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22368/randomserver Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in zeitgeist-config |
|
From: Markus R. <rol...@us...> - 2005-12-05 21:50:16
|
Update of /cvsroot/simspark/simspark/spark/zeitgeist/telnetserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22368/telnetserver Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in zeitgeist-config |
|
From: Markus R. <rol...@us...> - 2005-12-05 21:50:16
|
Update of /cvsroot/simspark/simspark/spark/zeitgeist/scriptserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22368/scriptserver Added Files: .cvsignore Log Message: --- NEW FILE: .cvsignore --- *.la *.lo .deps .libs Makefile Makefile.in zeitgeist-config |
|
From: Markus R. <rol...@us...> - 2005-12-05 21:44:16
|
Update of /cvsroot/simspark/simspark/spark/salt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21112 Modified Files: Makefile.am Log Message: *** empty log message *** Index: Makefile.am =================================================================== RCS file: /cvsroot/simspark/simspark/spark/salt/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile.am 5 Dec 2005 20:56:00 -0000 1.1 --- Makefile.am 5 Dec 2005 21:44:00 -0000 1.2 *************** *** 25,29 **** path.cpp \ plane.cpp \ ! gcc/sharedlibrary.cpp libpkginclude_HEADERS = \ --- 25,29 ---- path.cpp \ plane.cpp \ ! sharedlibrary.cpp libpkginclude_HEADERS = \ |
Update of /cvsroot/simspark/simspark/spark/kerosin/sceneserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/sceneserver Added Files: .cvsignore axis.cpp axis.h axis_c.cpp box.cpp box.h box_c.cpp ccylinder.cpp ccylinder.h ccylinder_c.cpp light.cpp light.h light_c.cpp singlematnode.cpp singlematnode.h singlematnode_c.cpp sphere.cpp sphere.h sphere_c.cpp staticmesh.cpp staticmesh.h staticmesh_c.cpp Log Message: --- NEW FILE: axis.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: axis.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 "axis.h" #include "../openglserver/openglserver.h" #include <kerosin/openglserver/glbase.h> using namespace kerosin; Axis::Axis() : mSize(10.0f) { } void Axis::RenderInternal() { RGBA colX(1,0,0,1); RGBA colY(0,1,0,1); RGBA colZ(0,0,1,1); // X glColor3fv(colX); glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,colX); glBegin(GL_LINE_LOOP); glVertex3f(0,0,0); glVertex3f(mSize,0,0); glEnd(); // Y glColor3fv(colY); glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,colY); glBegin(GL_LINE_LOOP); glVertex3f(0,0,0); glVertex3f(0,mSize,0); glEnd(); // Z glColor3fv(colZ); glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,colZ); glColor3f(0, 0, 1); glBegin(GL_LINE_LOOP); glVertex3f(0,0,0); glVertex3f(0,0,mSize); glEnd(); } float Axis::GetSize() { return mSize; } void Axis::SetSize(float size) { mSize = std::max<float>(0.1f,size); } --- NEW FILE: light_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: light_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. 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 "light.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; using namespace salt; FUNCTION(Light,setRadius) { float inRadius; if ( (in.GetSize() != 1) || (! in.GetValue(in.begin(), inRadius)) ) { return false; } obj->SetRadius(inRadius); return true; } FUNCTION(Light,getRadius) { return obj->GetRadius(); } 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(Light,setDiffuse) { RGBA m; if (! readRGBA(in,m)) { return false; } obj->SetDiffuse(m); return true; } FUNCTION(Light,setAmbient) { RGBA m; if (! readRGBA(in,m)) { return false; } obj->SetAmbient(m); return true; } FUNCTION(Light,setSpecular) { RGBA m; if (! readRGBA(in,m)) { return false; } obj->SetSpecular(m); return true; } void CLASS(Light)::DefineClass() { DEFINE_BASECLASS(oxygen/BaseNode); DEFINE_FUNCTION(setRadius); DEFINE_FUNCTION(getRadius); DEFINE_FUNCTION(setAmbient); DEFINE_FUNCTION(setDiffuse); DEFINE_FUNCTION(setSpecular); } --- NEW FILE: staticmesh.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: staticmesh.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 "staticmesh.h" #include <zeitgeist/logserver/logserver.h> #include <kerosin/openglserver/openglserver.h> #include <kerosin/materialserver/material.h> #include <kerosin/materialserver/materialserver.h> using namespace boost; using namespace kerosin; using namespace salt; using namespace std; using namespace zeitgeist; using namespace oxygen; StaticMesh::StaticMesh() : mScale(1.0f,1.0f,1.0f) { } StaticMesh::~StaticMesh() { } void StaticMesh::ComputeBoundingBox() { } void StaticMesh::CalcBoundingBox() { mLocalBoundingBox.Init(); if (mMesh.get() == 0) { return; } const int n = mMesh->GetVertexCount() * 3; const float* arPos = mMesh->GetPos().get(); if (arPos == 0) { return; } for (int i = 0; i<n; ++i) { const float* v = arPos + (i * 3); mLocalBoundingBox.Encapsulate ( v[0]*mScale[0], v[1]*mScale[1], v[2]*mScale[2] ); } } void StaticMesh::RenderInternal() { if (mMesh.get() == 0) { return; } const float* pos = mMesh->GetPos().get(); if (pos == 0) { return; } glVertexPointer(3, GL_FLOAT, 0, pos); glEnableClientState (GL_VERTEX_ARRAY); const float* tex = mMesh->GetTexCoords().get(); if (tex != 0) { glTexCoordPointer(3, GL_FLOAT, 0, tex); glEnableClientState (GL_TEXTURE_COORD_ARRAY); } const float* normal = mMesh->GetNormals().get(); if (normal != 0) { glNormalPointer(GL_FLOAT, 0, normal); glEnableClientState(GL_NORMAL_ARRAY); } glCullFace(GL_BACK); glEnable(GL_CULL_FACE); glScalef(mScale[0],mScale[1],mScale[2]); TriMesh::TFaces::const_iterator iter = mMesh->GetFaces().begin(); int i=0; while (iter != mMesh->GetFaces().end()) { const shared_ptr<Material> material = mMaterials[i]; if (material.get() != 0) { material->Bind(); const TriMesh::Face& face = (*iter); const shared_ptr<IndexBuffer>& idx = face.indeces; glDrawElements(GL_TRIANGLES, idx->GetNumIndex(), GL_UNSIGNED_INT, idx->GetIndex().get()); } ++i; ++iter; } glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY ); glDisableClientState(GL_NORMAL_ARRAY); } const Vector3f& StaticMesh::GetScale() { return mScale; } void StaticMesh::SetScale(const salt::Vector3f& scale) { mScale = scale; } bool StaticMesh::Load(const std::string& name) { ParameterList parameter; return Load(name,parameter); } bool StaticMesh::Load(const std::string& name, const ParameterList& parameter) { mMeshName = name; mMeshParameter = parameter; mMesh.reset(); mMaterials.clear(); ComputeBoundingBox(); shared_ptr<GeometryServer> geometryServer = shared_dynamic_cast<GeometryServer> (GetCore()->Get("/sys/server/geometry")); if (geometryServer.get() == 0) { GetLog()->Error() << "(StaticMesh) ERROR: cannot get GeometryServer\n"; return false; } shared_ptr<MaterialServer> materialServer = shared_dynamic_cast<MaterialServer> (GetCore()->Get("/sys/server/material")); if (materialServer.get() == 0) { GetLog()->Error() << "(StaticMesh) ERROR: cannot get MaterialServer\n"; return false; } mMesh = geometryServer->GetMesh(name,parameter); if (mMesh.get() == 0) { return false; } ComputeBoundingBox(); // load corresponding materials for ( TriMesh::TFaces::const_iterator iter = mMesh->GetFaces().begin(); iter != mMesh->GetFaces().end(); ++iter ) { const TriMesh::Face& face = (*iter); shared_ptr<Material> material = materialServer->GetMaterial(face.material); if (material.get() == 0) { material = materialServer->GetMaterial("default"); } mMaterials.push_back(material); } return true; } const shared_ptr<TriMesh> StaticMesh::GetMesh() { return mMesh; } const std::string& StaticMesh::GetMeshName() { return mMeshName; } const ParameterList& StaticMesh::GetMeshParameter() { return mMeshParameter; } --- NEW FILE: axis.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: axis.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_AXIS_H #define KEROSIN_AXIS_H #include <oxygen/sceneserver/basenode.h> namespace kerosin { class Axis : public oxygen::BaseNode { // // Functions // public: Axis(); /** returns the size of an axis */ float GetSize(); /** sets the size of an axis */ void SetSize(float size); protected: virtual void RenderInternal(); protected: // size of an axis float mSize; }; DECLARE_CLASS(Axis); } //namespace kerosin #endif //KEROSIN_AXIS_H --- NEW FILE: sphere_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: sphere_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 "sphere.h" using namespace boost; using namespace kerosin; FUNCTION(Sphere,setRadius) { float inRadius; if ( (in.GetSize() != 1) || (! in.GetValue(in.begin(), inRadius)) ) { return false; } obj->SetRadius(inRadius); return true; } void CLASS(Sphere)::DefineClass() { DEFINE_BASECLASS(kerosin/SingleMatNode); DEFINE_FUNCTION(setRadius); } --- NEW FILE: ccylinder_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: ccylinder_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 "ccylinder.h" using namespace boost; using namespace kerosin; using namespace salt; FUNCTION(CCylinder,setParams) { float inRadius; float inLength; if ( (in.GetSize() != 2) || (! in.GetValue(in[0], inRadius)) || (! in.GetValue(in[1], inLength)) ) { return false; } obj->SetParams(inRadius,inLength); return true; } FUNCTION(CCylinder,getRadius) { return obj->GetRadius(); } FUNCTION(CCylinder,getLength) { return obj->GetLength(); } void CLASS(CCylinder)::DefineClass() { DEFINE_BASECLASS(kerosin/SingleMatNode); DEFINE_FUNCTION(setParams); DEFINE_FUNCTION(getRadius); DEFINE_FUNCTION(getLength); } --- NEW FILE: singlematnode_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: singlematnode_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 "singlematnode.h" using namespace boost; using namespace kerosin; using namespace std; FUNCTION(SingleMatNode,setMaterial) { string inName; if ( (in.GetSize() != 1) || (! in.GetValue(in.begin(), inName)) ) { return false; } return obj->SetMaterial(inName); } void CLASS(SingleMatNode)::DefineClass() { DEFINE_BASECLASS(kerosin/StaticMesh); DEFINE_FUNCTION(setMaterial); } --- NEW FILE: sphere.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: sphere.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_SPHERE_H #define KEROSIN_SPHERE_H #include "singlematnode.h" namespace kerosin { class Material; /** \class Sphere is a SingleMatNode that automatically loads and renders a sphere mesh. It exports functions to scale the unit sphere to different sizes. */ class Sphere : public SingleMatNode { // // Function // public: Sphere(); virtual ~Sphere(); // sets the sphere radius float GetRadius() const; // returns the sphere radius void SetRadius(float radius); protected: virtual void OnLink(); }; DECLARE_CLASS(Sphere); } //namespace kerosin #endif //KEROSIN_SPHERE_H --- NEW FILE: ccylinder.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: ccylinder.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_CCYLINDER_H #define KEROSIN_CCYLINDER_H #include "singlematnode.h" namespace kerosin { class Material; /** CCylinder is a SingleMatNode that creates and renders a capped cylinder mesh with the given length and radius */ class CCylinder : public SingleMatNode { // // Function // public: CCylinder(); virtual ~CCylinder(); /** sets the parameters of the capped cylinder. \param radius is the radius of the caps, and of the cylinder itself \param length is the height of the cylinder, not counting the caps */ void SetParams(float radius, float length); /** returns the parameters of the capped cylinder */ void GetParams(float& radius, float& length) const; /** returns the radius of the capped cylinder */ float GetRadius(); /** returns the length of the capped cylinder */ float GetLength(); // // Members // protected: /** the radius of the caps and the cylinder */ float mRadius; /** the height of the clinder, not counting the caps */ float mLength; }; DECLARE_CLASS(CCylinder); } //namespace kerosin #endif //KEROSIN_CCYLINDER_H --- NEW FILE: ccylinder.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: ccylinder.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 "ccylinder.h" #include <kerosin/openglserver/openglserver.h> #include <kerosin/materialserver/material.h> using namespace boost; using namespace kerosin; using namespace zeitgeist; using namespace salt; CCylinder::CCylinder() : SingleMatNode() { } CCylinder::~CCylinder() { } void CCylinder::SetParams(float radius, float length) { ParameterList parameter; parameter.AddValue(radius); parameter.AddValue(length); Load("StdCCylinder",parameter); mRadius = radius; mLength = length; } void CCylinder::GetParams(float& radius, float& length) const { radius = mRadius; length = mLength; } float CCylinder::GetRadius() { return mRadius; } float CCylinder::GetLength() { return mLength; } --- NEW FILE: box_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: box_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 "box.h" using namespace boost; using namespace kerosin; using namespace salt; FUNCTION(Box,setExtents) { Vector3f inExtents; if ( (in.GetSize() != 3) || (! in.GetValue(in.begin(), inExtents)) ) { return false; } obj->SetExtents(inExtents); return true; } void CLASS(Box)::DefineClass() { DEFINE_BASECLASS(kerosin/SingleMatNode); DEFINE_FUNCTION(setExtents); } --- NEW FILE: sphere.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: sphere.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 "sphere.h" #include <kerosin/openglserver/openglserver.h> #include <kerosin/materialserver/material.h> using namespace kerosin; using namespace zeitgeist; using namespace boost; using namespace salt; Sphere::Sphere() : SingleMatNode() { } Sphere::~Sphere() { } void Sphere::OnLink() { Load("StdUnitSphere"); } float Sphere::GetRadius() const { return mScale[0]; } void Sphere::SetRadius(float radius) { mScale[0] = radius; mScale[1] = radius; mScale[2] = radius; } --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs --- NEW FILE: box.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: box.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 "box.h" #include <kerosin/openglserver/openglserver.h> #include <kerosin/materialserver/material.h> using namespace boost; using namespace kerosin; using namespace zeitgeist; using namespace salt; Box::Box() : SingleMatNode() { } Box::~Box() { } void Box::OnLink() { Load("StdUnitBox"); } void Box::SetExtents(const salt::Vector3f& extents) { mScale = extents; } const Vector3f& Box::GetExtents() { return mScale; } --- NEW FILE: staticmesh_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: staticmesh_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 "staticmesh.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; using namespace salt; using namespace std; FUNCTION(StaticMesh,load) { // load <fileName> parameter ... string inFileName; if ( (in.GetSize() == 0) || (! in.GetValue(in[0],inFileName)) ) { return false; } ParameterList parameter(in); // remove filename argument parameter.Pop_Front(); return obj->Load(inFileName, parameter); } FUNCTION(StaticMesh,setScale) { Vector3f inScale; if ( (in.GetSize() == 0) || (! in.GetValue(in[0], inScale)) ) { return false; } obj->SetScale(inScale); return true; } void CLASS(StaticMesh)::DefineClass() { DEFINE_BASECLASS(oxygen/BaseNode); DEFINE_FUNCTION(load); DEFINE_FUNCTION(setScale); } --- NEW FILE: light.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: light.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. 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 "light.h" #include <kerosin/renderserver/renderserver.h> #include <kerosin/openglserver/openglserver.h> #include <zeitgeist/logserver/logserver.h> /* // define the symbol BOOL to prevent opcode.h to typedef BOOL #define BOOL BOOL #include <opcode/Opcode.h> */ using namespace boost; using namespace kerosin; using namespace salt; Light::Light() : mDiffuse(1.0f,1.0f,1.0f,1.0f), mAmbient(0.0f,0.0f,0.0f,1.0f), mSpecular(1.0f,1.0f,1.0f,1.0f), mGLLight(-1), mVP(0), mFP(0), mCacheFlushed(true) { } float Light::GetRadius() const { return mRadius; } void Light::SetRadius(float radius) { mRadius = radius; FlushCache(); } void Light::SetAmbient(const RGBA& ambient) { mAmbient = ambient; } const RGBA& Light::GetAmbient() { return mAmbient; } void Light::SetDiffuse(const RGBA& diffuse) { mDiffuse = diffuse; } const RGBA& Light::GetDiffuse() { return mDiffuse; } void Light::SetSpecular(const RGBA& specular) { mSpecular = specular; } const RGBA& Light::GetSpecular() { return mSpecular; } void Light::Prepare() { if (mGLLight < 0) { // no light allocated return; } const Vector3f& pos = GetWorldTransform().Pos(); float light_pos[4]; light_pos[0]=pos[0]; light_pos[1]=pos[1]; light_pos[2]=pos[2]; light_pos[3]=1.0f; glLightfv(mGLLight, GL_AMBIENT, mAmbient); glLightfv(mGLLight, GL_DIFFUSE, mDiffuse); glLightfv(mGLLight, GL_POSITION,light_pos); glEnable(mGLLight); /* glEnable(GL_VERTEX_PROGRAM_ARB); glBindProgramARB(GL_VERTEX_PROGRAM_ARB, mVP); glEnable(GL_FRAGMENT_PROGRAM_ARB); glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, mFP); // publish light color to fragment program glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, mDiffuseR, mDiffuseG, mDiffuseB, 1.0f); glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, -1.0f/(mRadius*mRadius), 1.0f, 1.0f, 1.0f); */ } void Light::RenderLitMesh(boost::shared_ptr<StaticMesh> /*mesh*/) { /* if (mCacheFlushed || (GetWorldTransform().Pos()-mOldPos).SquareLength() > 0.1 || !mesh->GetWorldTransform().IsEqual(mMeshOldTransform)) { // if the cache wasn't flushed, we will flush it now if (!mCacheFlushed) FlushCache(); // cache the old position mOldPos = GetWorldTransform().Pos(); // cache the mesh old position mMeshOldTransform = mesh->GetWorldTransform(); // give each derived light a chance to find potentially lit triangles DeterminePotentiallyLitTriangles(mesh, mTriangles); //printf("%d\n", mTriangles.size()); // fill cache indices mesh->FillIndexBuffers(mCachedIndices, mTriangles); // mark that we contain valid data mCacheFlushed = false; } mesh->Render(mCachedIndices); glDisable(GL_FRAGMENT_PROGRAM_ARB); glDisable(GL_VERTEX_PROGRAM_ARB); */ } void Light::FlushCache() { const unsigned int n = mCachedIndices.size(); for (unsigned int i=0; i<n; ++i) { mCachedIndices[i].Flush(); } mCacheFlushed = true; } void Light::ComputeBoundingBox() { mLocalBoundingBox.minVec.Set(-mRadius,-mRadius,-mRadius); mLocalBoundingBox.maxVec.Set(mRadius,mRadius,mRadius); } void Light::OnLink() { mOpenGLServer = shared_dynamic_cast<OpenGLServer> (GetCore()->Get("sys/server/opengl")); if (mOpenGLServer.get() == 0) { GetLog()->Error() << "(Light) ERROR: OpenGLServer not found\n"; } else { mGLLight = mOpenGLServer->AllocLight(); if (mGLLight < 0) { GetLog()->Error() << "(Light) ERROR: No more OpenGL lights available\n"; } #if 0 mVP = mOpenGLServer->LoadARBVertexProgram("sys/program/omnilight.vp"); if (mVP == 0) { GetLog()->Error() << "(Light) ERROR: Could not load vertex program\n"; } mFP = mOpenGLServer->LoadARBFragmentProgram("sys/program/omnilight.fp"); if (mFP == 0) { GetLog()->Error() << "(Light) ERROR: Could not load fragment program\n"; } #endif } } void Light::OnUnlink() { if ( (mOpenGLServer.get() != 0) && (mGLLight >= 0) ) { mOpenGLServer->PutLight(mGLLight); mGLLight = -1; } mOpenGLServer.reset(); } void Light::DeterminePotentiallyLitTriangles(boost::shared_ptr<StaticMesh>& /*mesh*/, std::vector<unsigned int>& /*triangles*/) { /* Opcode::SphereCache cache; Sphere sphere; sphere.Set(Point(GetWorldTransform().Pos().x(), GetWorldTransform().Pos().y(), GetWorldTransform().Pos().z()), 1.5f*mRadius); mesh->FindInfluencedTriangles(cache, sphere, triangles); */ } --- NEW FILE: light.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: light.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_LIGHT_H #define KEROSIN_LIGHT_H #include <kerosin/openglserver/glbase.h> #include "staticmesh.h" #include "oxygen/geometryserver/indexbuffer.h" #include "oxygen/sceneserver/basenode.h" namespace kerosin { class OpenGLServer; class Light : public oxygen::BaseNode { // // Function // public: Light(); //! gets the light radius float GetRadius() const; //! sets the light radius void SetRadius(float radius); //! Enable render settings of this light virtual void Prepare(); //! draw lit triangles of mesh void RenderLitMesh(boost::shared_ptr<StaticMesh> mesh); //! flush the internal cached geometry void FlushCache(); //! update the bounding box void ComputeBoundingBox(); //! sets the ambient light intensity void SetAmbient(const RGBA& ambient); //! returns the ambient light intensity const RGBA& GetAmbient(); //! sets the diffuse light intensity void SetDiffuse(const RGBA& diffuse); //! returns the diffuse light intensitye const RGBA& GetDiffuse(); //! sets the specular light intensity void SetSpecular(const RGBA& specular); //! returns the specular light intensity const RGBA& GetSpecular(); protected: /** set up RenderServer reference */ virtual void OnLink(); /** reset RenderServer reference */ virtual void OnUnlink(); virtual void DeterminePotentiallyLitTriangles(boost::shared_ptr<StaticMesh>& mesh, std::vector<unsigned int>& triangles); // // Members // protected: /** the diffuse light intensity */ RGBA mDiffuse; /** the ambient light intensity */ RGBA mAmbient; /** the specular light intensity */ RGBA mSpecular; /** the allocated OpenGL light constant */ int mGLLight; float mRadius; unsigned int mVP; unsigned int mFP; //! position used to invalidate the cache salt::Vector3f mOldPos; //! mesh transform used to invalidate the cache salt::Matrix mMeshOldTransform; //! state of the cache bool mCacheFlushed; // indices of influenced triangles std::vector<unsigned int> mTriangles; // per-material cached indices std::vector<oxygen::IndexBuffer> mCachedIndices; /** reference to the RenderServer */ boost::shared_ptr<OpenGLServer> mOpenGLServer; }; DECLARE_CLASS(Light); } //namespace kerosin #endif //KEROSIN_LIGHT_H --- NEW FILE: staticmesh.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: staticmesh.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_STATICMESH_H #define KEROSIN_STATICMESH_H #include <kerosin/renderserver/rendernode.h> #include <oxygen/geometryserver/geometryserver.h> namespace kerosin { class Material; /** \class StaticMesh is a Render that renders a TriMesh. The mesh is imported using the GeometryServer and all referenced materials are automatically loaded using the MaterialServer. */ class StaticMesh : public RenderNode { // // Types // public: typedef std::vector<oxygen::IndexBuffer> TIndexBuffers; // // Function // public: StaticMesh(); ~StaticMesh(); /** loads the mesh with the given name and parameters*/ bool Load(const std::string& name, const zeitgeist::ParameterList& parameter); /** loads the mesh with the given name */ bool Load(const std::string& name); /** empty! this prevents the bounding box from being updated, as it cannot change */ virtual void ComputeBoundingBox(); /** calculates the local bounding box */ void CalcBoundingBox(); /** returns the scale vector that is used to render the mesh */ const salt::Vector3f& GetScale(); /** sets the scale vector that is used to render the mesh */ void SetScale(const salt::Vector3f& scale); /** renders the node */ virtual void RenderInternal(); /** returns the managed mesh */ const boost::shared_ptr<oxygen::TriMesh> GetMesh(); /** returns the name of the loaded mesh */ const std::string& GetMeshName(); /** returns the parameter list of the loaded mesh */ const zeitgeist::ParameterList& GetMeshParameter(); // // Members // protected: /** vector of scale factors along each axis */ salt::Vector3f mScale; /** the mesh to render */ boost::shared_ptr<oxygen::TriMesh> mMesh; /** the materials used to render the mesh */ std::vector<boost::shared_ptr<Material> > mMaterials; /** the name of the loaded mesh */ std::string mMeshName; /** the list of parameters the mesh was loaded with */ zeitgeist::ParameterList mMeshParameter; }; DECLARE_CLASS(StaticMesh); } //namespace kerosin #endif //KEROSIN_STATICMESH_H --- NEW FILE: singlematnode.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: singlematnode.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_SINGLEMATNODE_H #define KEROSIN_SINGLEMATNODE_H #include "staticmesh.h" namespace kerosin { class Material; /** \class SingleMatNode is a BaseNode that renders itself using a single material. It provides methods to manage this material. */ class SingleMatNode : public StaticMesh { // // Function // public: SingleMatNode(); virtual ~SingleMatNode(); /** queries the MaterialServer for the material \param name and caches a reference to it. It returns true on success. */ bool SetMaterial(const std::string& name); /** returns the material assigned to this node */ boost::shared_ptr<Material> GetMaterial(); }; DECLARE_CLASS(SingleMatNode); } //namespace kerosin #endif //KEROSIN_SINGLEMATNODE_H --- NEW FILE: axis_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: axis_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 "axis.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; FUNCTION(Axis,setSize) { float inSize; if ( (in.GetSize() != 1) || (! in.GetValue(in.begin(),inSize)) ) { return false; } obj->SetSize(inSize); return true; } FUNCTION(Axis,getSize) { return obj->GetSize(); } void CLASS(Axis)::DefineClass() { DEFINE_BASECLASS(oxygen/BaseNode); DEFINE_FUNCTION(setSize); DEFINE_FUNCTION(getSize); } --- NEW FILE: box.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: box.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_BOX_H #define KEROSIN_BOX_H #include "singlematnode.h" namespace kerosin { class Material; /** Box is a SingleMatNode that automatically loads and renders a box mesh that is scaled to the given extents. */ class Box : public SingleMatNode { // // Function // public: Box(); virtual ~Box(); /** sets the extents box */ void SetExtents(const salt::Vector3f& extents); /** returns the extents of box */ const salt::Vector3f& GetExtents(); protected: virtual void OnLink(); }; DECLARE_CLASS(Box); } //namespace kerosin #endif //KEROSIN_BOX_H --- NEW FILE: singlematnode.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: singlematnode.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 "singlematnode.h" #include <zeitgeist/logserver/logserver.h> #include <kerosin/materialserver/materialserver.h> using namespace boost; using namespace kerosin; using namespace zeitgeist; SingleMatNode::SingleMatNode() : StaticMesh () { } SingleMatNode::~SingleMatNode() { } bool SingleMatNode::SetMaterial(const std::string& name) { mMaterials.clear(); shared_ptr<MaterialServer> materialServer = shared_dynamic_cast<MaterialServer> (GetCore()->Get("/sys/server/material")); if (materialServer.get() == 0) { GetLog()->Error() << "(SingleMatNode) ERROR: Cannot find MaterialServer\n"; return false; } shared_ptr<Material> material = materialServer->GetMaterial(name); if (material.get() == 0) { return false; } mMaterials.push_back(material); return true; } shared_ptr<Material> SingleMatNode::GetMaterial() { if (mMaterials.empty()) { return shared_ptr<Material>(); } return mMaterials.front(); } |
|
From: Markus R. <rol...@us...> - 2005-12-05 21:38:34
|
Update of /cvsroot/simspark/simspark/spark/kerosin/renderserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19774/renderserver Added Files: .cvsignore customrender.cpp customrender.h customrender_c.cpp rendercontrol.cpp rendercontrol.h rendercontrol_c.cpp rendernode.cpp rendernode.h rendernode_c.cpp renderserver.cpp renderserver.h renderserver_c.cpp Log Message: --- NEW FILE: customrender.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: customrender.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. CustomRender */ #include "customrender.h" using namespace kerosin; CustomRender::CustomRender() { } CustomRender::~CustomRender() { } --- NEW FILE: .cvsignore --- *.lo .deps .dirstamp .libs --- NEW FILE: rendernode.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: rendernode.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. RenderNode */ #ifndef KEROSIN_RENDERNODE_H #define KEROSIN_RENDERNODE_H #include <oxygen/sceneserver/basenode.h> namespace kerosin { /** RenderNode is the base class for all nodes which are part of the scene hierarchy and are able to render itself. */ class RenderNode : public oxygen::BaseNode { // // Functions // public: RenderNode(); virtual ~RenderNode(); /** renders the node */ virtual void RenderInternal() = 0; }; DECLARE_ABSTRACTCLASS(RenderNode); } //namespace kerosin #endif //KEROSIN_RENDERNODE_H --- NEW FILE: rendernode.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: rendernode.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. RenderNode */ #include "rendernode.h" using namespace kerosin; RenderNode::RenderNode() { } RenderNode::~RenderNode() { } --- NEW FILE: renderserver_c.cpp --- #include "renderserver.h" using namespace boost; using namespace kerosin; using namespace zeitgeist; void CLASS(RenderServer)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Leaf); } --- NEW FILE: rendernode_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: rendernode_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 "rendernode.h" using namespace kerosin; void CLASS(RenderNode)::DefineClass() { DEFINE_BASECLASS(oxygen/BaseNode); } --- NEW FILE: renderserver.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: renderserver.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 "renderserver.h" #include <oxygen/sceneserver/sceneserver.h> #include <oxygen/sceneserver/scene.h> #include <oxygen/sceneserver/camera.h> #include <kerosin/openglserver/openglserver.h> #include <kerosin/sceneserver/staticmesh.h> #include <kerosin/sceneserver/light.h> #include <zeitgeist/logserver/logserver.h> using namespace boost; using namespace oxygen; using namespace kerosin; using namespace salt; using namespace zeitgeist; RenderServer::RenderServer() : Leaf() { } RenderServer::~RenderServer() { } void RenderServer::OnLink() { // setup SceneServer reference mSceneServer = shared_dynamic_cast<SceneServer> (GetCore()->Get("/sys/server/scene")); if (mSceneServer.get() == 0) { GetLog()->Error() << "(RenderServer) ERROR: SceneServer not found\n"; } // setup OpenGLServer reference mOpenGLServer = shared_dynamic_cast<OpenGLServer> (GetCore()->Get("sys/server/opengl")); if (mOpenGLServer.get() == 0) { GetLog()->Error() << "(RenderServer) ERROR: OpenGLServer not found\n"; } else { mAmbientVP = 0; #if 0 mAmbientVP = mOpenGLServer->LoadARBVertexProgram ("/sys/program/ambient.vp"); if (mAmbientVP == 0) { GetLog()->Error() << "(RenderServer) ERROR: Could not load vertex program\n"; } #endif } } void RenderServer::OnUnlink() { mSceneServer.reset(); mOpenGLServer.reset(); mActiveScene.reset(); } bool RenderServer::GetActiveScene() { if (mSceneServer.get() == 0) { mActiveScene.reset(); } mActiveScene = mSceneServer->GetActiveScene(); if (mActiveScene.get() == 0) { GetLog()->Error() << "(RenderServer) ERROR: found no active scene\n"; return false; } return true; } void RenderServer::RenderFancyLighting(const salt::Frustum& /*frustum*/, boost::shared_ptr<oxygen::Camera>& /*camera*/, TLeafList& /*myLights*/, TLeafList& /*allMeshes*/, TLeafList& /*visibleMeshes*/) { #if 0 glEnable(GL_VERTEX_PROGRAM_ARB); glBindProgramARB(GL_VERTEX_PROGRAM_ARB, mAmbientVP); glColor3f(0.1f,0.1f,0.1f); mActiveScene->RenderAmbient(); // render lights glBlendFunc(GL_ONE, GL_ONE); glEnable(GL_BLEND); //glEnable(GL_ALPHA_TEST); //glAlphaFunc(GL_GREATER, 0.0f); glDepthMask(0); glDepthFunc(GL_EQUAL); for (TLeafList::iterator i=myLights.begin(); i != myLights.end(); ++i) { shared_ptr<Light> light = shared_static_cast<Light>(*i); // only render the light if it is visible if (frustum.Intersects(light->GetWorldBoundingBox())!=Frustum::FS_OUTSIDE) { for (TLeafList::iterator j=visibleMeshes.begin(); j != visibleMeshes.end(); ++j) { shared_ptr<StaticMesh> mesh = shared_static_cast<StaticMesh>(*j); // we only have to render meshes, whose bounding volume intersects the light volume if (light->GetWorldBoundingBox().Intersects(mesh->GetWorldBoundingBox())) { Matrix toObjectSpace; toObjectSpace.Identity(); toObjectSpace = mesh->GetWorldTransform(); toObjectSpace.InvertRotationMatrix(); //light->GetWorldTransform().Pos().Dump(); light->Prepare(); Vector3f lightPos = toObjectSpace.Transform(light->GetWorldTransform().Pos()); Vector3f viewPos = toObjectSpace.Transform(camera->GetWorldTransform().Pos()); glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 0, lightPos.x(), lightPos.y(), lightPos.z(), 1.0f); glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, 1, viewPos.x(), viewPos.y(), viewPos.z(), 1.0f); light->RenderLitMesh(shared_static_cast<StaticMesh>(*j)); } } } } glDisable(GL_BLEND); glDepthMask(1); glActiveTextureARB(GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE2_ARB); glDisable(GL_TEXTURE_2D); glEnable(GL_VERTEX_PROGRAM_ARB); glBindProgramARB(GL_VERTEX_PROGRAM_ARB, mAmbientVP); // standard rendering mActiveScene->Render(); glDisable(GL_VERTEX_PROGRAM_ARB); #endif } void RenderServer::Render() { if (! GetActiveScene()) { return; } // get a camera to render with shared_ptr<Camera> camera = shared_static_cast<Camera>(mActiveScene->GetChildOfClass("Camera", true)); if (camera.get() == 0) { GetLog()->Error() << "(RenderServer) ERROR: found no camera node in the active scene\n"; return; } glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glColor3f(1,1,1); // set the view transformation BindCamera(camera); #if 0 // get the view frustum from the camera Frustum frustum; camera->DescribeFrustum(frustum); // cull lights and geometries against the frustum TLeafList myLights; TLeafList allMeshes; TLeafList visibleMeshes; mActiveScene->GetChildrenSupportingClass("Light", myLights, true); mActiveScene->GetChildrenSupportingClass("StaticMesh", allMeshes, true); TLeafList::iterator i; for (i = allMeshes.begin(); i != allMeshes.end(); ++i) { // try to cull meshes, which are outside the viewing frustum if (frustum.Intersects(shared_static_cast<StaticMesh>(*i)->GetWorldBoundingBox())!=Frustum::FS_OUTSIDE) { visibleMeshes.push_back(*i); } } #endif // actual rendering // ambient pass glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); TLeafList lights; mActiveScene->ListChildrenSupportingClass<Light>(lights,true); if (lights.size() == 0) { // no lights in the scene, disable lighting glDisable(GL_LIGHTING); } else { glEnable(GL_LIGHTING); glShadeModel (GL_SMOOTH); // prepare all lights for ( TLeafList::iterator iter = lights.begin(); iter != lights.end(); ++iter ) { (shared_static_cast<Light>(*iter))->Prepare(); } } // standard rendering RenderScene(mActiveScene); // reset GL lights glDisable(GL_LIGHTING); #if 0 // test for fancy lighting support - disabled for now const bool doFancyLighting = false; /*openglServer->SupportsFancyLighting()*/ if (doFancyLighting) { RenderFancyLighting(frustum, camera, myLights, allMeshes, visibleMeshes); } else #endif } void RenderServer::RenderScene(boost::shared_ptr<BaseNode> node) { // test for and render using a RenderNode shared_ptr<RenderNode> renderNode = shared_dynamic_cast<RenderNode>(node); if (renderNode.get() != 0) { glPushMatrix(); glMultMatrixf(node->GetWorldTransform().m); renderNode->RenderInternal(); glPopMatrix(); } // traverse the the hierarchy for (TLeafList::iterator i = node->begin(); i!= node->end(); ++i) { shared_ptr<BaseNode> node = shared_dynamic_cast<BaseNode>(*i); if (node.get() == 0) { continue; } RenderScene(node); } } void RenderServer::BindCamera(boost::shared_ptr<Camera>& camera) { camera->Bind(); // adjust the viewport glViewport( camera->GetViewportX(), camera->GetViewportY(), camera->GetViewportWidth(), camera->GetViewportHeight() ); // set depth range glDepthRange(0, 1); // setup the projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMultMatrixf(camera->GetProjectionTransform().m); // initialize the modelview stack glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMultMatrixf(camera->GetViewTransform().m); } --- NEW FILE: rendercontrol.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: rendercontrol.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 "rendercontrol.h" #include "customrender.h" #include <zeitgeist/logserver/logserver.h> #include <kerosin/renderserver/renderserver.h> #include <kerosin/openglserver/openglserver.h> using namespace kerosin; using namespace oxygen; using namespace zeitgeist; using namespace boost; using namespace std; RenderControl::RenderControl() { mFramesRendered = 0; } RenderControl::~RenderControl() { } void RenderControl::OnLink() { mRenderServer = shared_dynamic_cast<RenderServer> (GetCore()->Get("/sys/server/render")); if (mRenderServer.get() == 0) { GetLog()->Error() << "(RenderControl) ERROR: RenderServer not found\n"; } mOpenGLServer = shared_dynamic_cast<OpenGLServer> (GetCore()->Get("/sys/server/opengl")); if (mOpenGLServer.get() == 0) { GetLog()->Error() << "(RenderControl) ERROR: OpenGLServer not found\n"; } } void RenderControl::OnUnlink() { mRenderServer.reset(); mOpenGLServer.reset(); } void RenderControl::RenderCustom() { // get list of registered CustomMonitor objects TLeafList customList; ListChildrenSupportingClass<CustomRender>(customList); for ( TLeafList::iterator iter = customList.begin(); iter != customList.end(); ++iter ) { shared_static_cast<CustomRender>((*iter)) ->Render(); } } void RenderControl::EndCycle() { // update the window (pumps event loop, etc..) and render the // current frame mOpenGLServer->Update(); mRenderServer->Render(); RenderCustom(); mOpenGLServer->SwapBuffers(); ++mFramesRendered; } int RenderControl::GetFramesRendered() { return mFramesRendered; } --- NEW FILE: customrender_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: customrender_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 "customrender.h" using namespace kerosin; using namespace std; void CLASS(CustomRender)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Leaf); } --- NEW FILE: customrender.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: customrender.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. CustomRender */ #ifndef KEROSIN_CUSTOMRENDER_H #define KEROSIN_CUSTOMRENDER_H #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> namespace kerosin { /** CustomRender is the base class for all nodes installed below the Spark RenderControl node. This serves as a hook mechanism to render objects or overlays that are not part of the scene graph */ class CustomRender : public zeitgeist::Leaf { // // Functions // public: CustomRender(); virtual ~CustomRender(); virtual void Render() = 0; }; DECLARE_ABSTRACTCLASS(CustomRender); } //namespace kerosin #endif //KEROSIN_CUSTOMRENDER_H --- NEW FILE: rendercontrol.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: rendercontrol.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_RENDERCONTROL_H #define KEROSIN_RENDERCONTROL_H #include <oxygen/simulationserver/simcontrolnode.h> namespace kerosin { class RenderServer; class OpenGLServer; /** \class RenderControl is a SimControlNode that renders the current scene and pumps the SDL event loop at the end of each simulation cycle, counting the total number of frames rendered */ class RenderControl : public oxygen::SimControlNode { public: RenderControl(); virtual ~RenderControl(); /** returns the total number of rendered frames */ int GetFramesRendered(); /** renders the scene at the end of each simulation cycle */ virtual void EndCycle(); protected: virtual void OnLink(); virtual void OnUnlink(); void RenderCustom(); protected: /** cached reference to the RenderServer */ boost::shared_ptr<kerosin::RenderServer> mRenderServer; /** cached reference to the OpenGLServer */ boost::shared_ptr<kerosin::OpenGLServer> mOpenGLServer; /** total frames rendered */ int mFramesRendered; }; DECLARE_CLASS(RenderControl); } // namespace kerosin #endif // KEROSIN_RENDERCONTROL_H --- NEW FILE: renderserver.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: renderserver.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. 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. RenderServer NOTE: HISTORY: 25.08.03 - MR - Initial version TODO: TOFIX: */ #ifndef KEROSIN_RENDERSERVER_H #define KEROSIN_RENDERSERVER_H #include <salt/frustum.h> #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> namespace oxygen { class Scene; class SceneServer; class Camera; class BaseNode; } namespace kerosin { class OpenGLServer; class RenderServer : public zeitgeist::Leaf { // // Functions // public: RenderServer(); ~RenderServer(); //! display the current active scene void Render(); //! render the scene with fancy lighting void RenderFancyLighting(const salt::Frustum& frustum, boost::shared_ptr<oxygen::Camera>& camera, TLeafList& myLights, TLeafList& allMeshes, TLeafList& visibleMeshes); protected: /** get the active scene node from the sceneServer */ bool RenderServer::GetActiveScene(); /** set up SceneServer reference */ virtual void OnLink(); /** reset SceneServer reference */ virtual void OnUnlink(); /** render a scene recursively. \param node the scene base node */ void RenderScene(boost::shared_ptr<oxygen::BaseNode> node); /** sets the OpenGl view parameters for a camera */ void BindCamera(boost::shared_ptr<oxygen::Camera>& camera); // // Members // protected: /** reference to the current active scene */ boost::shared_ptr<oxygen::Scene> mActiveScene; /** reference to the SceneServer */ boost::shared_ptr<oxygen::SceneServer> mSceneServer; /** reference to the OpenGLServer */ boost::shared_ptr<kerosin::OpenGLServer> mOpenGLServer; unsigned int mAmbientVP; }; DECLARE_CLASS(RenderServer); } //namespace kerosin #endif // KEROSIN_RENDERSERVER_H --- NEW FILE: rendercontrol_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: rendercontrol_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 "rendercontrol.h" using namespace kerosin; using namespace std; FUNCTION(RenderControl, getFramesRendered) { return obj->GetFramesRendered(); } void CLASS(RenderControl)::DefineClass() { DEFINE_BASECLASS(oxygen/SimControlNode); DEFINE_FUNCTION(getFramesRendered); } |