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...> - 2006-02-23 13:38:42
|
Update of /cvsroot/simspark/simspark/spark/oxygen/geometryserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16269 Modified Files: geometryserver.cpp geometryserver.h Log Message: - factored out registration of a new mesh into the public method RegisterMesh() Index: geometryserver.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/geometryserver/geometryserver.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** geometryserver.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- geometryserver.cpp 23 Feb 2006 13:38:36 -0000 1.2 *************** *** 133,138 **** if (meshName == "") { - mesh->SetName(name); meshName = name; } --- 133,138 ---- if (meshName == "") { meshName = name; + mesh->SetName(name); } *************** *** 142,146 **** << importer->GetName() << "'\n"; ! mMeshMap[meshName] = mesh; return mesh; } --- 142,147 ---- << importer->GetName() << "'\n"; ! RegisterMesh(mesh); ! return mesh; } *************** *** 152,153 **** --- 153,181 ---- } + void GeometryServer::RegisterMesh(shared_ptr<TriMesh> mesh) + { + if (mesh.get() == 0) + { + GetLog()->Debug() << "(GeometryServer) RegisterMesh called with NULL mesh\n"; + return; + } + + std::string name = mesh->GetName(); + if (name.empty()) + { + GetLog()->Error() << "(GeometryServer) Cannot register a mesh without a name\n"; + return; + } + + TMeshMap::iterator iter = mMeshMap.find(name); + if (iter != mMeshMap.end()) + { + GetLog()->Debug() << "(GeometryServer) replacing mesh " << name << "\n"; + } + + mMeshMap[name] = mesh; + GetLog()->Normal() << "(GeometryServer) mesh " << name << " registered\n"; + } + + + Index: geometryserver.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/geometryserver/geometryserver.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** geometryserver.h 5 Dec 2005 21:16:49 -0000 1.1 --- geometryserver.h 23 Feb 2006 13:38:36 -0000 1.2 *************** *** 54,57 **** --- 54,62 ---- (const std::string& name, const zeitgeist::ParameterList& parameter); + /** register a trimesh to the GeometryServer. The name of the mesh + has to be set + */ + void RegisterMesh(boost::shared_ptr<TriMesh> mesh); + protected: /** registers the standard mesh importer */ |
From: Markus R. <rol...@us...> - 2006-02-22 22:54:51
|
Update of /cvsroot/simspark/simspark/spark/salt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27982 Modified Files: plane.h plane.cpp Log Message: - indentation Index: plane.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/salt/plane.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** plane.h 5 Dec 2005 20:56:00 -0000 1.1 --- plane.h 22 Feb 2006 22:54:46 -0000 1.2 *************** *** 43,111 **** enum EPlaneSide { ! PLANESIDE_BACK = 0, ! PLANESIDE_ONPLANE = 1, ! PLANESIDE_FRONT = 2, ! PLANESIDE_SPLIT = 3, ! PLANESIDE_FORCE_32BIT = 0xffffffff // used to force the enum to be 32-bit wide ! }; /** defines possible dominant plane values */ enum EPlane { ! PLANE_XY = 0, ! PLANE_XZ = 1, ! PLANE_YZ = 2, ! PLANE_FORCE_32BIT = 0xffffffff // used to force the enum to be 32-bit wide }; ! /** ! * A mathematical plane is modeled by this class. It can be used to ! * classify points against planes (in front, on plane, ! * etc...). Several useful functions for constructing a plane are ! * provided. A plane is defined by the formula. Ax+By+Cz+D=0. The ! * vector formed by the coefficients <A,B,C> is the normal vector to ! * the plane. ! */ class Plane { // Members public: /** the normal vector of the modeled plane */ ! Vector3f normal; /** the distance */ ! float d; // Methods public: /** empty constructor for an undefined plane */ ! f_inline Plane() {} // empty constructor ... performance /** constructs a plane from a normal and a point on the plane */ ! f_inline Plane(const Vector3f& norm, const Vector3f& pnt) { normal=norm; d=-((norm.x()*pnt.x()) + (norm.y()*pnt.y()) + (norm.z()*pnt.z())); } /** constructs a plane from normal and constant D. If normal is a * unit vector, then D is the distance to the origin */ ! f_inline Plane(const Vector3f& norm, const float D) { normal=norm; d=D; } /** constructs a plane from 3 distinct points */ ! f_inline Plane(const Vector3f& v1, const Vector3f &v2, const Vector3f &v3) { normal=(v2-v1).Cross(v3-v1).Normalized(); d=-normal.Dot(v1); } // inline functions /** calculates the orientation of v to the plane */ ! f_inline EPlaneSide GetOrientation(const Vector3f &v, float delta=0.0001f) const { float dist=normal.Dot(v)+d; if (dist<-delta) return PLANESIDE_BACK; if (dist>delta) return PLANESIDE_FRONT; return PLANESIDE_ONPLANE; } /** calculates the dominant plane */ ! f_inline EPlane GetDominantPlane() const { return (gAbs(normal.y()) > gAbs(normal.x()) ? (gAbs(normal.z()) > gAbs(normal.y()) ? PLANE_XY : PLANE_XZ) : (gAbs(normal.z()) > gAbs(normal.x()) ? PLANE_XY : PLANE_YZ)); } /** calculates the distance from v to the plane */ ! f_inline float GetDistanceTo(const Vector3f &v) const { return normal.Dot(v) + d; } - /** calculates the relationship between the plane and the box */ EPlaneSide ClassifyBox(const AABB3& bb) const; --- 43,146 ---- enum EPlaneSide { ! PLANESIDE_BACK = 0, ! PLANESIDE_ONPLANE = 1, ! PLANESIDE_FRONT = 2, ! PLANESIDE_SPLIT = 3, + // used to force the enum to be 32-bit wide + PLANESIDE_FORCE_32BIT = 0xffffffff + }; /** defines possible dominant plane values */ enum EPlane { ! PLANE_XY = 0, ! PLANE_XZ = 1, ! PLANE_YZ = 2, ! ! // used to force the enum to be 32-bit wide ! PLANE_FORCE_32BIT = 0xffffffff }; ! /** A mathematical plane is modeled by this class. It can be used to ! classify points against planes (in front, on plane, ! etc...). Several useful functions for constructing a plane are ! provided. A plane is defined by the formula. Ax+By+Cz+D=0. The ! vector formed by the coefficients <A,B,C> is the normal vector ! to the plane. ! */ ! class Plane { // Members public: + /** the normal vector of the modeled plane */ ! Vector3f normal; /** the distance */ ! float d; // Methods public: + /** empty constructor for an undefined plane */ ! f_inline Plane() {} // empty constructor ... performance /** constructs a plane from a normal and a point on the plane */ ! f_inline Plane(const Vector3f& norm, const Vector3f& pnt) ! { ! normal=norm; ! d=-((norm.x()*pnt.x()) + (norm.y()*pnt.y()) + (norm.z()*pnt.z())); ! } /** constructs a plane from normal and constant D. If normal is a * unit vector, then D is the distance to the origin */ ! f_inline Plane(const Vector3f& norm, const float D) ! { ! normal=norm; d=D; ! } /** constructs a plane from 3 distinct points */ ! f_inline Plane(const Vector3f& v1, const Vector3f &v2, const Vector3f &v3) ! { ! normal=(v2-v1).Cross(v3-v1).Normalized(); ! d=-normal.Dot(v1); ! } // inline functions /** calculates the orientation of v to the plane */ ! f_inline EPlaneSide GetOrientation(const Vector3f &v, float delta=0.0001f) const ! { ! float dist=normal.Dot(v)+d; ! if (dist<-delta) return PLANESIDE_BACK; ! if (dist>delta) return PLANESIDE_FRONT; ! ! return PLANESIDE_ONPLANE; ! } /** calculates the dominant plane */ ! f_inline EPlane GetDominantPlane() const ! { ! return ( ! gAbs(normal.y()) > gAbs(normal.x()) ? ! ( ! gAbs(normal.z()) > gAbs(normal.y()) ? ! PLANE_XY : PLANE_XZ ! ) : ! ( ! gAbs(normal.z()) > gAbs(normal.x()) ? ! PLANE_XY : PLANE_YZ ! ) ! ); ! } /** calculates the distance from v to the plane */ ! f_inline float GetDistanceTo(const Vector3f &v) const { return normal.Dot(v) + d; } /** calculates the relationship between the plane and the box */ EPlaneSide ClassifyBox(const AABB3& bb) const; *************** *** 116,133 **** /** sets up a plane from a normal and a point on the plane */ f_inline void Set(const Vector3f& norm, const Vector3f& pnt) ! { normal=norm; d=-((norm.x()*pnt.x()) + (norm.y()*pnt.y()) + (norm.z()*pnt.z())); } /** sets up a plane from normal and constant D. If normal is a * unit vector, then D is the distance to the origin */ ! f_inline void Set(const Vector3f& norm, const float D) { normal=norm; d=D; } /** sets up a plane from 3 distinct points */ ! f_inline void Set(const Vector3f& v1, const Vector3f &v2, const Vector3f &v3) { normal=(v2-v1).Cross(v3-v1).Normalized(); d=-normal.Dot(v1); } /** the assignment operator for planes */ f_inline const Plane& operator=(const Plane& p) ! { normal=p.normal; d=p.d; return *this; } ! }; --- 151,182 ---- /** sets up a plane from a normal and a point on the plane */ f_inline void Set(const Vector3f& norm, const Vector3f& pnt) ! { ! normal=norm; ! d=-((norm.x()*pnt.x()) + (norm.y()*pnt.y()) + (norm.z()*pnt.z())); ! } /** sets up a plane from normal and constant D. If normal is a * unit vector, then D is the distance to the origin */ ! f_inline void Set(const Vector3f& norm, const float D) ! { ! normal=norm; ! d=D; ! } /** sets up a plane from 3 distinct points */ ! f_inline void Set(const Vector3f& v1, const Vector3f &v2, const Vector3f &v3) ! { ! normal=(v2-v1).Cross(v3-v1).Normalized(); ! d=-normal.Dot(v1); ! } /** the assignment operator for planes */ f_inline const Plane& operator=(const Plane& p) ! { ! normal=p.normal; ! d=p.d; ! return *this; ! } }; Index: plane.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/salt/plane.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** plane.cpp 5 Dec 2005 20:56:00 -0000 1.1 --- plane.cpp 22 Feb 2006 22:54:46 -0000 1.2 *************** *** 1,4 **** ! /* -*- mode: c++ -*- ! this file is part of rcssserver3D Fri May 9 2003 --- 1,4 ---- ! /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- ! this file is part of rcssserver3D Fri May 9 2003 *************** *** 9,18 **** 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 --- 9,18 ---- 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 *************** *** 25,94 **** EPlaneSide Plane::ClassifyBox(const AABB3& bb) const { ! Vector3f posFarPt; ! Vector3f negFarPt; ! if(normal.x()>0) // right ! if(normal.y()>0) // right, top ! if(normal.z()>0) // right, top, front ! { ! posFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.maxVec.z()); ! negFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.minVec.z()); ! } ! else // right, top, back ! { ! posFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.minVec.z()); ! negFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.maxVec.z()); ! } ! else // right, bottom ! if(normal.z()>0) // right, bottom, front ! { ! posFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.maxVec.z()); ! negFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.minVec.z()); ! } ! else // right, bottom, back ! { ! posFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.minVec.z()); ! negFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.maxVec.z()); ! } ! else ! if(normal.y()>0) // left, top ! if(normal.z()>0) // left, top, front ! { ! posFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.maxVec.z()); ! negFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.minVec.z()); ! } ! else // left, top, back ! { ! posFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.minVec.z()); ! negFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.maxVec.z()); ! } ! else // left, bottom ! if(normal.z()>0) // left, bottom, front ! { ! posFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.maxVec.z()); ! negFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.minVec.z()); ! } ! else // left, bottom, back ! { ! posFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.minVec.z()); ! negFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.maxVec.z()); ! } ! // BOX IS "OUTSIDE" ! if (GetOrientation(negFarPt, 0.0f)==PLANESIDE_FRONT) return PLANESIDE_FRONT; ! // BOX IS "INSIDE" ! if (GetOrientation(posFarPt, 0.0f)==PLANESIDE_BACK) return PLANESIDE_BACK; ! return PLANESIDE_SPLIT; } void Plane::Normalize() { ! float l=normal.Length(); ! float iLen = 1.0f/l; ! normal.x()*=iLen; ! normal.y()*=iLen; ! normal.z()*=iLen; ! d*=iLen; } --- 25,100 ---- EPlaneSide Plane::ClassifyBox(const AABB3& bb) const { ! Vector3f posFarPt; ! Vector3f negFarPt; ! if(normal.x()>0) // right ! if(normal.y()>0) // right, top ! if(normal.z()>0) // right, top, front ! { ! posFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.maxVec.z()); ! negFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.minVec.z()); ! } ! else // right, top, back ! { ! posFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.minVec.z()); ! negFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.maxVec.z()); ! } ! else // right, bottom ! if(normal.z()>0) // right, bottom, front ! { ! posFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.maxVec.z()); ! negFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.minVec.z()); ! } ! else // right, bottom, back ! { ! posFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.minVec.z()); ! negFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.maxVec.z()); ! } ! else ! if(normal.y()>0) // left, top ! if(normal.z()>0) // left, top, front ! { ! posFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.maxVec.z()); ! negFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.minVec.z()); ! } ! else // left, top, back ! { ! posFarPt.Set(bb.minVec.x(),bb.maxVec.y(),bb.minVec.z()); ! negFarPt.Set(bb.maxVec.x(),bb.minVec.y(),bb.maxVec.z()); ! } ! else // left, bottom ! if(normal.z()>0) // left, bottom, front ! { ! posFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.maxVec.z()); ! negFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.minVec.z()); ! } ! else // left, bottom, back ! { ! posFarPt.Set(bb.minVec.x(),bb.minVec.y(),bb.minVec.z()); ! negFarPt.Set(bb.maxVec.x(),bb.maxVec.y(),bb.maxVec.z()); ! } ! // BOX IS "OUTSIDE" ! if (GetOrientation(negFarPt, 0.0f)==PLANESIDE_FRONT) ! { ! return PLANESIDE_FRONT; ! } ! // BOX IS "INSIDE" ! if (GetOrientation(posFarPt, 0.0f)==PLANESIDE_BACK) ! { ! return PLANESIDE_BACK; ! } ! return PLANESIDE_SPLIT; } void Plane::Normalize() { ! float l=normal.Length(); ! float iLen = 1.0f/l; ! normal.x()*=iLen; ! normal.y()*=iLen; ! normal.z()*=iLen; ! d*=iLen; } |
From: Markus R. <rol...@us...> - 2006-02-22 19:42:16
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24229 Modified Files: roselements.cpp roselements.h rosimporter.cpp rosimporter.h Log Message: - implemented parsing of graphical representation within complex shapes, still needs translation into our own TrimMesh class Index: roselements.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/roselements.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** roselements.h 19 Feb 2006 14:16:58 -0000 1.3 --- roselements.h 22 Feb 2006 19:42:07 -0000 1.4 *************** *** 66,69 **** --- 66,72 ---- #define RA_INSTANCENAME "instanceName" + // ComplexShape + #define RA_VERTEXLIST "vertexList" + class RosElements { *************** *** 92,95 **** --- 95,100 ---- RE_VERTEXLIST, RE_VERTEX, + RE_GRAPHICALREPRESENTATION, + RE_POLYGON, RE_MACRO, Index: roselements.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/roselements.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** roselements.cpp 19 Feb 2006 14:16:58 -0000 1.3 --- roselements.cpp 22 Feb 2006 19:42:07 -0000 1.4 *************** *** 66,69 **** --- 66,71 ---- ROS_DEFINE_ELEMENT(RE_VERTEXLIST,"VertexList"); ROS_DEFINE_ELEMENT(RE_VERTEX,"Vertex"); + ROS_DEFINE_ELEMENT(RE_GRAPHICALREPRESENTATION, "GraphicalRepresentation"); + ROS_DEFINE_ELEMENT(RE_POLYGON,"Polygon"); ROS_DEFINE_ELEMENT(RE_MACRO, "Macro"); Index: rosimporter.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** rosimporter.cpp 19 Feb 2006 15:04:01 -0000 1.7 --- rosimporter.cpp 22 Feb 2006 19:42:07 -0000 1.8 *************** *** 32,35 **** --- 32,36 ---- #include <oxygen/physicsserver/body.h> #include <oxygen/physicsserver/hingejoint.h> + #include <oxygen/geometryserver/trimesh.h> #include <kerosin/openglserver/glbase.h> #include <kerosin/materialserver/materialserver.h> *************** *** 87,91 **** } ! bool RosImporter::ImportScene(const std::string& fileName, shared_ptr<BaseNode> parent, shared_ptr<ParameterList> parameter) --- 88,92 ---- } ! bool RosImporter::ImportScene(const string& fileName, shared_ptr<BaseNode> parent, shared_ptr<ParameterList> parameter) *************** *** 111,115 **** } ! bool RosImporter::ParseScene(const std::string& scene, shared_ptr<BaseNode> parent, shared_ptr<ParameterList> parameter) --- 112,116 ---- } ! bool RosImporter::ParseScene(const string& scene, shared_ptr<BaseNode> parent, shared_ptr<ParameterList> parameter) *************** *** 226,231 **** } ! bool RosImporter::ReadAttribute(TiXmlElement* element, const std::string& attribute, ! std::string& value, bool succeedIfMissing) { if (element == 0) --- 227,232 ---- } ! bool RosImporter::ReadAttribute(TiXmlElement* element, const string& attribute, ! string& value, bool succeedIfMissing) { if (element == 0) *************** *** 250,254 **** } ! bool RosImporter::ReadAttribute(TiXmlElement* element, const std::string& attribute, double& value, bool succeedIfMissing) { --- 251,255 ---- } ! bool RosImporter::ReadAttribute(TiXmlElement* element, const string& attribute, double& value, bool succeedIfMissing) { *************** *** 1185,1190 **** --- 1186,1314 ---- transform->SetName(name); + // TODO: read <Appearance> tag, does ist always 'ref' to the + // surrounding compley shape? + + TriMesh mesh; + if (! ReadGraphicalRep(parent, element, mesh)) + { + return false; + } + GetLog()->Debug() << "(RosImporter) read complex shape " << name << "\n"; return true; } + + bool RosImporter::ReadGraphicalRep(shared_ptr<BaseNode> parent, TiXmlElement* element, TriMesh& mesh) + { + TiXmlElement* graphRepElem = GetFirstChild(element, RosElements::RE_GRAPHICALREPRESENTATION); + if (graphRepElem == 0) + { + string name = S_UNNAMED; + ReadAttribute(element, RA_NAME, name, true); + + GetLog()->Error() << "(RosImporter) ERROR: missing graphical representation in " + << GetXMLPath(element) << " name " << name << " \n"; + + return false; + } + + string vertexListName; + if (! ReadAttribute(graphRepElem, RA_VERTEXLIST, vertexListName)) + { + return false; + } + + TVertexListMap::const_iterator iter = mVertexListMap.find(vertexListName); + if (iter == mVertexListMap.end()) + { + string name; + ReadAttribute(element, RA_NAME, name, true); + + GetLog()->Error() << "(RosImporter) ERROR: undefined vertex list " << vertexListName << " in " + << GetXMLPath(element) << " name " << name << " \n"; + + return false; + } + + const TVertexList& vertexList = (*iter).second; + + TComplexGeomList geomList; + if (! ReadComplexElements(graphRepElem, geomList)) + { + return false; + } + + return true; + } + + bool RosImporter::ReadComplexElements(TiXmlElement* element, TComplexGeomList& geomList) + { + // TODO: read TriangleStrips + + for ( + TiXmlNode* node = GetFirstChild(element, RosElements::RE_POLYGON); + node != 0; + node = element->IterateChildren(node) + ) + { + TiXmlElement* element = static_cast<TiXmlElement*>(node); + + RosElements::ERosElement type = GetType(element); + switch (type) + { + default: + GetLog()->Error() << "(RosImporter::ReadComplexElements) ERROR: skipping unknown element " + << GetXMLPath(element) << "\n"; + break; + + case RosElements::RE_POLYGON: + ComplexGeom geom(CG_Polygon); + if (! ReadComplexGeom(element, geom)) + { + return false; + } + + GetLog()->Debug() << "(RosImporter) read polygon with " << geom.vertices.size() << " vertices\n"; + geomList.push_back(geom); + break; + } + } + + return true; + } + + bool RosImporter::ReadComplexGeom(TiXmlElement* element, ComplexGeom& geom) + { + for ( + TiXmlNode* node = GetFirstChild(element, RosElements::RE_VERTEX); + node != 0; + node = element->IterateChildren(node) + ) + { + TiXmlElement* element = static_cast<TiXmlElement*>(node); + + RosElements::ERosElement type = GetType(element); + switch (type) + { + default: + GetLog()->Error() << "(RosImporter::ReadComplexGeom) ERROR: skipping unknown element " + << GetXMLPath(element) << "\n"; + break; + + case RosElements::RE_VERTEX: + { + string ref; + if (! ReadAttribute(element, RA_REF, ref)) + { + return false; + } + + geom.vertices.push_back(ref); + break; + } + } + } + + return true; + } Index: rosimporter.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** rosimporter.h 19 Feb 2006 15:04:01 -0000 1.6 --- rosimporter.h 22 Feb 2006 19:42:07 -0000 1.7 *************** *** 34,37 **** --- 34,38 ---- class ContactJointHandler; class Body; + class TriMesh; } *************** *** 100,103 **** --- 101,130 ---- typedef std::map<std::string, TVertexList> TVertexListMap; + /** define a list of string references into a vertex list */ + typedef std::list<std::string> TVertexRefList; + + /** the possible types of complex geoms that make up a + ComplexShape + */ + enum EComplexGeom + { + CG_None = 0, + CG_Polygon, + CG_TriangleStrip + }; + + struct ComplexGeom + { + public: + EComplexGeom type; + TVertexRefList vertices; + + public: + ComplexGeom(EComplexGeom t = CG_None) : type(t) {} + }; + + /** defines a list of complex geoms */ + typedef std::list<ComplexGeom> TComplexGeomList; + public: RosImporter(); *************** *** 174,178 **** bool ReadVertexList(TiXmlElement* element); bool ReadComplexShape(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); ! protected: --- 201,207 ---- bool ReadVertexList(TiXmlElement* element); bool ReadComplexShape(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); ! bool ReadGraphicalRep(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, oxygen::TriMesh& mesh); ! bool ReadComplexElements(TiXmlElement* element, TComplexGeomList& geomList); ! bool ReadComplexGeom(TiXmlElement* element, ComplexGeom& geom); protected: |
From: Markus R. <rol...@us...> - 2006-02-19 15:45:44
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29040 Modified Files: property.cpp Log Message: - unicode compile fix Index: property.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/property.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** property.cpp 18 Feb 2006 19:50:03 -0000 1.7 --- property.cpp 19 Feb 2006 15:45:37 -0000 1.8 *************** *** 90,94 **** #define FORMAT_FLAG(_i, _flag)\ ! wxString((_i & _flag) ? #_flag" " : "") Property::Property() --- 90,94 ---- #define FORMAT_FLAG(_i, _flag)\ ! wxString((_i & _flag) ? _T(#_flag" ") : _T("")) Property::Property() |
From: Markus R. <rol...@us...> - 2006-02-19 15:04:13
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8248 Modified Files: rosimporter.cpp rosimporter.h Log Message: - an object within a 'movable' tag has not necessarily a physical Body - added a valid flag to the physical description - moved decision whether to create a Body to function HasBody() - when macros are instantiated with a translation or rotation, an additional Transform node is required. Therefore GetJointParentBody has to walk up the hierarchy Index: rosimporter.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** rosimporter.cpp 19 Feb 2006 14:16:58 -0000 1.6 --- rosimporter.cpp 19 Feb 2006 15:04:01 -0000 1.7 *************** *** 139,142 **** --- 139,150 ---- } + bool RosImporter::HasBody(const Physical& physical, ENodeContext context) + { + return ( + (physical.valid) && + (context == NC_MOVABLE) + ); + } + bool RosImporter::ParseScene(const char* scene, int size, shared_ptr<BaseNode> parent, *************** *** 468,477 **** ) { ! TiXmlElement* element = static_cast<TiXmlElement*>(node); ! if (element == 0) { continue; } bool ok = true; --- 476,485 ---- ) { ! if (IgnoreNode(node)) { continue; } + TiXmlElement* element = static_cast<TiXmlElement*>(node); bool ok = true; *************** *** 676,679 **** --- 684,689 ---- bool RosImporter::ReadPhysical(TiXmlElement* element, Physical& physical, ENodeContext context) { + physical.valid = false; + if (context != NC_MOVABLE) { *************** *** 684,717 **** if (physElem == 0) { ! string name = S_UNNAMED; ! ReadAttribute(element, RA_NAME, name, true); ! ! GetLog()->Error() << "(RosImporter) ERROR: missing physical attributes in " ! << GetXMLPath(element) << " name " << name << "\n"; ! return false; } ! // we must have a mass TiXmlElement* massElem = GetFirstChild(physElem, RosElements::RE_MASS); ! if (massElem == 0) { - string name = S_UNNAMED; - ReadAttribute(element, RA_NAME, name, true); - - GetLog()->Error() << "(RosImporter) ERROR: missing mass element in physical attributes in " - << GetXMLPath(element) << "name " << name << " \n"; return false; } ! if (! ReadAttribute(massElem, RA_VALUE, physical.mass)) ! { ! return false; ! } // check for mass center TiXmlElement* centerElem = GetFirstChild(physElem,RosElements::RE_CENTEROFMASS); ! if (centerElem != 0) { ! ReadVector(centerElem, physical.massCenter); } --- 694,721 ---- if (physElem == 0) { ! return true; } ! // check for mass TiXmlElement* massElem = GetFirstChild(physElem, RosElements::RE_MASS); ! if ( ! (massElem != 0) && ! (! ReadAttribute(massElem, RA_VALUE, physical.mass)) ! ) { return false; } ! // a mass value is enough for a valid physical body description ! physical.valid = true; // check for mass center TiXmlElement* centerElem = GetFirstChild(physElem,RosElements::RE_CENTEROFMASS); ! if ( ! (centerElem != 0) && ! (! ReadVector(centerElem, physical.massCenter)) ! ) { ! return false; } *************** *** 761,782 **** ccylinder->SetMaterial(appear.ref); ! // add body? ! switch (context) { ! case NC_ELEMENTS: ! break; ! ! case NC_MOVABLE: ! { ! shared_ptr<Body> body = shared_dynamic_cast<Body> ! (GetCore()->New("/oxygen/Body")); ! transform->AddChildReference(body); ! body->SetName(S_BODY+name); ! body->SetCappedCylinderTotal(physical.mass, radius, height); ! //! TODO: set mass center ! break; ! } } --- 765,778 ---- ccylinder->SetMaterial(appear.ref); ! if (HasBody(physical, context)) { ! shared_ptr<Body> body = shared_dynamic_cast<Body> ! (GetCore()->New("/oxygen/Body")); ! transform->AddChildReference(body); ! body->SetName(S_BODY+name); ! body->SetCappedCylinderTotal(physical.mass, radius, height); ! //! TODO: set mass center } *************** *** 831,852 **** sphere->SetMaterial(appear.ref); ! // add body? ! switch (context) { ! case NC_ELEMENTS: ! break; ! ! case NC_MOVABLE: ! { ! shared_ptr<Body> body = shared_dynamic_cast<Body> ! (GetCore()->New("/oxygen/Body")); ! transform->AddChildReference(body); ! body->SetName(S_BODY+name); ! body->SetSphereTotal(physical.mass, radius); ! //! TODO: set mass center ! break; ! } } --- 827,840 ---- sphere->SetMaterial(appear.ref); ! if (HasBody(physical, context)) { ! shared_ptr<Body> body = shared_dynamic_cast<Body> ! (GetCore()->New("/oxygen/Body")); ! transform->AddChildReference(body); ! body->SetName(S_BODY+name); ! body->SetSphereTotal(physical.mass, radius); ! //! TODO: set mass center } *************** *** 904,925 **** box->SetMaterial(appear.ref); ! // add body? ! switch (context) { ! case NC_ELEMENTS: ! break; ! ! case NC_MOVABLE: ! { ! shared_ptr<Body> body = shared_dynamic_cast<Body> ! (GetCore()->New("/oxygen/Body")); ! transform->AddChildReference(body); ! body->SetName(S_BODY+name); ! body->SetBoxTotal(physical.mass, boxDim); ! //! TODO: set mass center ! break; ! } } --- 892,905 ---- box->SetMaterial(appear.ref); ! if (HasBody(physical, context)) { ! shared_ptr<Body> body = shared_dynamic_cast<Body> ! (GetCore()->New("/oxygen/Body")); ! transform->AddChildReference(body); ! body->SetName(S_BODY+name); ! body->SetBoxTotal(physical.mass, boxDim); ! //! TODO: set mass center } *************** *** 968,972 **** shared_ptr<Body> RosImporter::GetJointParentBody(shared_ptr<BaseNode> parent) { ! return parent->FindChildSupportingClass<Body>(); } --- 948,965 ---- shared_ptr<Body> RosImporter::GetJointParentBody(shared_ptr<BaseNode> parent) { ! for ( ! shared_ptr<BaseNode> node = parent; ! node.get() != 0; ! node = shared_dynamic_cast<BaseNode>(node->GetParent().lock()) ! ) ! { ! shared_ptr<Body> body = node->FindChildSupportingClass<Body>(); ! if (body.get() != 0) ! { ! return body; ! } ! } ! ! return shared_ptr<Body>(); } Index: rosimporter.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** rosimporter.h 19 Feb 2006 14:16:58 -0000 1.5 --- rosimporter.h 19 Feb 2006 15:04:01 -0000 1.6 *************** *** 78,81 **** --- 78,82 ---- { public: + bool valid; double mass; salt::Vector3f massCenter; *************** *** 83,87 **** public: Physical() ! : mass(0.0), massCenter(0.0, 0.0, 0.0) {} }; --- 84,88 ---- public: Physical() ! : valid(false), mass(0.0), massCenter(0.0, 0.0, 0.0) {} }; *************** *** 119,123 **** --- 120,126 ---- TiXmlElement* GetFirstChild(TiXmlNode* node, RosElements::ERosElement type); TiXmlElement* IterateChildren(TiXmlNode* node, RosElements::ERosElement type); + bool IgnoreNode(const TiXmlNode* node) const; + bool HasBody(const Physical& physical, ENodeContext context); RosElements::ERosElement GetType(const TiXmlElement* element) const; |
From: Markus R. <rol...@us...> - 2006-02-19 14:17:07
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20791 Modified Files: roselements.cpp roselements.h rosimporter.cpp rosimporter.h Log Message: - implemented parsing of compound node - initial parsing of comples shapes - implemented registry of vertex lists - presence of name attribute is not required - made some error messages more descriptive Index: roselements.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/roselements.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** roselements.h 19 Feb 2006 13:16:18 -0000 1.2 --- roselements.h 19 Feb 2006 14:16:58 -0000 1.3 *************** *** 87,90 **** --- 87,96 ---- RE_CAPPEDCYLINDER, + RE_COMPOUND, + + RE_COMPLEXSHAPE, + RE_VERTEXLIST, + RE_VERTEX, + RE_MACRO, RE_USE, Index: roselements.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/roselements.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** roselements.cpp 19 Feb 2006 13:19:18 -0000 1.2 --- roselements.cpp 19 Feb 2006 14:16:58 -0000 1.3 *************** *** 53,56 **** --- 53,57 ---- ROS_DEFINE_ELEMENT(RE_ELEMENTS,"Elements"); ROS_DEFINE_ELEMENT(RE_MOVABLE,"Movable"); + ROS_DEFINE_ELEMENT(RE_COMPOUND,"Compound"); ROS_DEFINE_ELEMENT(RE_TRANSLATION, "Translation"); *************** *** 62,65 **** --- 63,70 ---- ROS_DEFINE_ELEMENT(RE_CAPPEDCYLINDER,"CappedCylinder"); + ROS_DEFINE_ELEMENT(RE_COMPLEXSHAPE,"ComplexShape"); + ROS_DEFINE_ELEMENT(RE_VERTEXLIST,"VertexList"); + ROS_DEFINE_ELEMENT(RE_VERTEX,"Vertex"); + ROS_DEFINE_ELEMENT(RE_MACRO, "Macro"); ROS_DEFINE_ELEMENT(RE_USE, "Use"); Index: rosimporter.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** rosimporter.cpp 19 Feb 2006 13:19:18 -0000 1.5 --- rosimporter.cpp 19 Feb 2006 14:16:58 -0000 1.6 *************** *** 53,56 **** --- 53,57 ---- static const string S_VISUAL("visual_"); static const string S_MACRO("macro_"); + static const string S_UNNAMED("<unnamed>"); RosImporter::TMacroMap RosImporter::mMacroMap; *************** *** 118,121 **** --- 119,142 ---- } + bool RosImporter::IgnoreNode(const TiXmlNode* node) const + { + if (node == 0) + { + return true; + } + + switch(node->Type()) + { + case TiXmlNode::ELEMENT: + return false; + + default: + /** ignore declarations, comments and other + unknown node types + */ + return true; + } + } + bool RosImporter::ParseScene(const char* scene, int size, shared_ptr<BaseNode> parent, *************** *** 154,174 **** ) { ! if (node == 0) { continue; } - switch(node->Type()) - { - case TiXmlNode::ELEMENT: - break; - - default: - /** ignore declarations, comments and other - unknown node types - */ - continue; - } - TiXmlElement* element = static_cast<TiXmlElement*>(node); bool ok = true; --- 175,183 ---- ) { ! if (IgnoreNode(node)) { continue; } TiXmlElement* element = static_cast<TiXmlElement*>(node); bool ok = true; *************** *** 193,196 **** --- 202,209 ---- ok = ReadMacro(parent, element); break; + + case RosElements::RE_VERTEXLIST: + ok = ReadVertexList(element); + break; } *************** *** 217,222 **** if (! succeedIfMissing) { GetLog()->Error() << "(RosImporter) ERROR: missing string attribute " << attribute << " in " ! << GetXMLPath(element) << "\n"; return false; } --- 230,238 ---- if (! succeedIfMissing) { + string name = S_UNNAMED; + ReadAttribute(element, RA_NAME, name, true); + GetLog()->Error() << "(RosImporter) ERROR: missing string attribute " << attribute << " in " ! << GetXMLPath(element) << " name " << name << " \n"; return false; } *************** *** 238,243 **** if (! succeedIfMissing) { GetLog()->Error() << "(RosImporter) ERROR: missing float attribute " << attribute << " in " ! << GetXMLPath(element) << "\n"; return false; } --- 254,262 ---- if (! succeedIfMissing) { + string name = S_UNNAMED; + ReadAttribute(element, RA_NAME, name, true); + GetLog()->Error() << "(RosImporter) ERROR: missing float attribute " << attribute << " in " ! << GetXMLPath(element) << " name " << name << "\n"; return false; } *************** *** 257,262 **** ) { GetLog()->Error() << "(RosImporter) ERROR: missing color attributes in " ! << GetXMLPath(element) << "\n"; return false; } --- 276,284 ---- ) { + string name = S_UNNAMED; + ReadAttribute(element, RA_NAME, name, true); + GetLog()->Error() << "(RosImporter) ERROR: missing color attributes in " ! << GetXMLPath(element) << " name " << name << "\n"; return false; } *************** *** 282,287 **** if (! succeedIfMissing) { GetLog()->Error() << "(RosImporter) ERROR: invalid or missing vector attributes in " ! << GetXMLPath(element) << "\n"; return false; } --- 304,312 ---- if (! succeedIfMissing) { + string name = S_UNNAMED; + ReadAttribute(element, RA_NAME, name, true); + GetLog()->Error() << "(RosImporter) ERROR: invalid or missing vector attributes in " ! << GetXMLPath(element) << " name " << name << "\n"; return false; } *************** *** 396,416 **** ) { ! if (node == 0) { continue; } - switch(node->Type()) - { - case TiXmlNode::ELEMENT: - break; - - default: - /** ignore declarations, comments and other - unknown node types - */ - continue; - } - TiXmlElement* childElement = static_cast<TiXmlElement*>(node); if (! ReadElements(parent, childElement, context)) --- 421,429 ---- ) { ! if (IgnoreNode(node)) { continue; } TiXmlElement* childElement = static_cast<TiXmlElement*>(node); if (! ReadElements(parent, childElement, context)) *************** *** 423,426 **** --- 436,461 ---- } + bool RosImporter::ReadCompound(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) + { + string name; + Trans trans; + + if ( + (! ReadAttribute(element, RA_NAME, name, true)) || + (! ReadTrans(element, trans)) + ) + { + return false; + } + + // transform + shared_ptr<Transform> transform = CreateTransform(parent, trans); + transform->SetName(name); + + GetLog()->Debug() << "(RosImporter) read compound node " << name << "\n"; + + return ReadChildElements(parent, element, context); + } + bool RosImporter::ReadElements(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) { *************** *** 455,458 **** --- 490,497 ---- break; + case RosElements::RE_COMPOUND: + ok = ReadCompound(parent,element,context); + break; + case RosElements::RE_MOVABLE: ok = ReadMovable(parent,element,context); *************** *** 482,485 **** --- 521,528 ---- ok = ReadUse(parent,element,context); break; + + case RosElements::RE_COMPLEXSHAPE: + ok = ReadComplexShape(parent,element,context); + break; } *************** *** 641,656 **** if (physElem == 0) { GetLog()->Error() << "(RosImporter) ERROR: missing physical attributes in " ! << GetXMLPath(element) << "\n"; return false; } - // we must have a mass TiXmlElement* massElem = GetFirstChild(physElem, RosElements::RE_MASS); if (massElem == 0) { GetLog()->Error() << "(RosImporter) ERROR: missing mass element in physical attributes in " ! << GetXMLPath(element) << "\n"; return false; } --- 684,704 ---- if (physElem == 0) { + string name = S_UNNAMED; + ReadAttribute(element, RA_NAME, name, true); + GetLog()->Error() << "(RosImporter) ERROR: missing physical attributes in " ! << GetXMLPath(element) << " name " << name << "\n"; return false; } // we must have a mass TiXmlElement* massElem = GetFirstChild(physElem, RosElements::RE_MASS); if (massElem == 0) { + string name = S_UNNAMED; + ReadAttribute(element, RA_NAME, name, true); + GetLog()->Error() << "(RosImporter) ERROR: missing mass element in physical attributes in " ! << GetXMLPath(element) << "name " << name << " \n"; return false; } *************** *** 689,693 **** if ( ! (! ReadAttribute(element, RA_NAME, name)) || (! ReadAttribute(element, RA_RADIUS, radius)) || (! ReadAttribute(element, RA_HEIGHT, height)) || --- 737,741 ---- if ( ! (! ReadAttribute(element, RA_NAME, name, true)) || (! ReadAttribute(element, RA_RADIUS, radius)) || (! ReadAttribute(element, RA_HEIGHT, height)) || *************** *** 759,763 **** if ( ! (! ReadAttribute(element, RA_NAME, name)) || (! ReadAttribute(element, RA_RADIUS, radius)) || (! ReadTrans(element, trans)) || --- 807,811 ---- if ( ! (! ReadAttribute(element, RA_NAME, name, true)) || (! ReadAttribute(element, RA_RADIUS, radius)) || (! ReadTrans(element, trans)) || *************** *** 829,833 **** if ( ! (! ReadAttribute(element, RA_NAME, name)) || (! ReadAttribute(element, RA_LENGTH, length)) || (! ReadAttribute(element, RA_WIDTH, width)) || --- 877,881 ---- if ( ! (! ReadAttribute(element, RA_NAME, name, true)) || (! ReadAttribute(element, RA_LENGTH, length)) || (! ReadAttribute(element, RA_WIDTH, width)) || *************** *** 954,958 **** if ( ! (! ReadAttribute(element, RA_NAME, name)) || (! ReadAnchorPoint(element, anchor)) || (! ReadAxis(element, axis)) --- 1002,1006 ---- if ( ! (! ReadAttribute(element, RA_NAME, name, true)) || (! ReadAnchorPoint(element, anchor)) || (! ReadAxis(element, axis)) *************** *** 1053,1054 **** --- 1101,1197 ---- return ok; } + + bool RosImporter::ReadVertexList(TiXmlElement* element) + { + string listName; + if (! ReadAttribute(element, RA_NAME, listName)) + { + return false; + } + + mVertexListMap[listName] = TVertexList(); + + // work with a reference in to the map to avoid an expensive copy + TVertexList& vertices = mVertexListMap[listName]; + + for ( + TiXmlNode* node = GetFirstChild(element, RosElements::RE_VERTEX); + node != 0; + node = element->IterateChildren(node) + ) + { + if (IgnoreNode(node)) + { + continue; + } + + TiXmlElement* element = static_cast<TiXmlElement*>(node); + + RosElements::ERosElement type = GetType(element); + switch (type) + { + default: + GetLog()->Error() << "(RosImporter::ReadVertices) ERROR: skipping unknown element " + << GetXMLPath(element) << "\n"; + break; + + case RosElements::RE_VERTEX: + { + Vector3f vec; + string name; + + if ( + (! ReadAttribute(element, RA_NAME, name)) || + (! ReadVector(element, vec)) + ) + { + return false; + } + + vertices[name] = vec; + break; + } + } + } + + GetLog()->Debug() << "(RosImporter) read vertex list " << listName << "\n"; + return true; + } + + bool RosImporter::ReadComplexShape(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) + { + string name; + Trans trans; + Appearance appear; + Physical physical; + TVertexList vertices; + + if ( + (! ReadAttribute(element, RA_NAME, name, true)) || + (! ReadTrans(element, trans)) || + (! ReadAppearance(element, appear)) || + (! ReadPhysical(element, physical, context)) + ) + { + return false; + } + + // look for an inlined vertex list and parse it + TiXmlElement* vertListElem = + GetFirstChild(element, RosElements::RE_VERTEXLIST); + + if ( + (vertListElem != 0) && + (! ReadVertexList(vertListElem)) + ) + { + return false; + } + + shared_ptr<Transform> transform = CreateTransform(parent, trans); + transform->SetName(name); + + GetLog()->Debug() << "(RosImporter) read complex shape " << name << "\n"; + + return true; + } Index: rosimporter.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** rosimporter.h 19 Feb 2006 13:19:18 -0000 1.4 --- rosimporter.h 19 Feb 2006 14:16:58 -0000 1.5 *************** *** 91,94 **** --- 91,102 ---- typedef std::map<std::string, boost::shared_ptr<TiXmlElement> > TMacroMap; + /** define a mapping from name to vertex name as defined within a + VertexList element + */ + typedef std::map<std::string, salt::Vector3f> TVertexList; + + /** define a mapping from name to vertex list name */ + typedef std::map<std::string, TVertexList> TVertexListMap; + public: RosImporter(); *************** *** 111,114 **** --- 119,123 ---- TiXmlElement* GetFirstChild(TiXmlNode* node, RosElements::ERosElement type); TiXmlElement* IterateChildren(TiXmlNode* node, RosElements::ERosElement type); + bool IgnoreNode(const TiXmlNode* node) const; RosElements::ERosElement GetType(const TiXmlElement* element) const; *************** *** 137,140 **** --- 146,150 ---- bool ReadElements(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); + bool ReadCompound(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); bool ReadMovable(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); *************** *** 159,162 **** --- 169,176 ---- bool ReadHinge(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); + bool ReadVertexList(TiXmlElement* element); + bool ReadComplexShape(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); + + protected: /** the last supplied fileName */ *************** *** 172,175 **** --- 186,192 ---- double mGlobalCFM; + /** the registry of vertex lists */ + TVertexListMap mVertexListMap; + /** the static macro registry is shared across RosImporter instances |
From: Markus R. <rol...@us...> - 2006-02-19 13:22:05
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27797 Modified Files: sparkglcanvas.cpp Log Message: - apply a faktor to mouse move delta to reduce sensitivity to mouse movements Index: sparkglcanvas.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparkglcanvas.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sparkglcanvas.cpp 8 Jan 2006 14:15:27 -0000 1.3 --- sparkglcanvas.cpp 19 Feb 2006 13:21:56 -0000 1.4 *************** *** 215,218 **** --- 215,220 ---- static long lastY = 0; + const double fkt = 0.5; + if (first) { *************** *** 225,229 **** { Input input(Input::eAxis, Input::IC_AXISX); ! input.mData.l = (event.GetX() - lastX); AddInput(input); } --- 227,231 ---- { Input input(Input::eAxis, Input::IC_AXISX); ! input.mData.l = static_cast<long>((event.GetX() - lastX) * fkt); AddInput(input); } *************** *** 231,235 **** { Input input(Input::eAxis, Input::IC_AXISY); ! input.mData.l = (event.GetY() - lastY); AddInput(input); } --- 233,237 ---- { Input input(Input::eAxis, Input::IC_AXISY); ! input.mData.l = static_cast<long>((event.GetY() - lastY) * fkt); AddInput(input); } |
From: Markus R. <rol...@us...> - 2006-02-19 13:19:28
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25404 Modified Files: roselements.cpp rosimporter.cpp rosimporter.h Log Message: - ignore comments and other unknown XML elements - treat unknown RoSimML tags like <elements> tag - implemented a macro registry that stores XML subtrees indexed by string - implemented RoSim macro definition and instsncing Index: roselements.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/roselements.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** roselements.cpp 18 Feb 2006 19:52:14 -0000 1.1 --- roselements.cpp 19 Feb 2006 13:19:18 -0000 1.2 *************** *** 62,65 **** --- 62,72 ---- ROS_DEFINE_ELEMENT(RE_CAPPEDCYLINDER,"CappedCylinder"); + ROS_DEFINE_ELEMENT(RE_MACRO, "Macro"); + ROS_DEFINE_ELEMENT(RE_USE, "Use"); + + ROS_DEFINE_ELEMENT(RE_HINGE,"Hinge"); + ROS_DEFINE_ELEMENT(RE_ANCHORPOINT,"AnchorPoint"); + ROS_DEFINE_ELEMENT(RE_AXIS,"Axis"); + ROS_DEFINE_ELEMENT(RE_GLOBALPHYSICALPARAMETERS,"GlobalPhysicalParameters"); ROS_DEFINE_ELEMENT(RE_PHYSICALATTRIBUTES,"PhysicalAttributes"); Index: rosimporter.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** rosimporter.cpp 19 Feb 2006 11:11:58 -0000 1.4 --- rosimporter.cpp 19 Feb 2006 13:19:18 -0000 1.5 *************** *** 52,55 **** --- 52,58 ---- static const string S_GEOM("geometry_"); static const string S_VISUAL("visual_"); + static const string S_MACRO("macro_"); + + RosImporter::TMacroMap RosImporter::mMacroMap; RosImporter::RosImporter() : SceneImporter() *************** *** 151,160 **** ) { ! TiXmlElement* element = static_cast<TiXmlElement*>(node); ! if (element == 0) { continue; } bool ok = true; --- 154,175 ---- ) { ! if (node == 0) ! { ! continue; ! } ! ! switch(node->Type()) { + case TiXmlNode::ELEMENT: + break; + + default: + /** ignore declarations, comments and other + unknown node types + */ continue; } + TiXmlElement* element = static_cast<TiXmlElement*>(node); bool ok = true; *************** *** 173,176 **** --- 188,196 ---- case RosElements::RE_SCENE: ok = ReadScene(parent, element); + break; + + case RosElements::RE_MACRO: + ok = ReadMacro(parent, element); + break; } *************** *** 376,379 **** --- 396,416 ---- ) { + if (node == 0) + { + continue; + } + + switch(node->Type()) + { + case TiXmlNode::ELEMENT: + break; + + default: + /** ignore declarations, comments and other + unknown node types + */ + continue; + } + TiXmlElement* childElement = static_cast<TiXmlElement*>(node); if (! ReadElements(parent, childElement, context)) *************** *** 408,413 **** --- 445,452 ---- { default: + // treat unknown tags like a <element> tag GetLog()->Error() << "(RosImporter::ReadElements) ERROR: skipping unknown element " << GetXMLPath(element) << "\n"; + ok = ReadElements(parent, element, context); break; *************** *** 439,442 **** --- 478,485 ---- ok = ReadHinge(parent,element,context); break; + + case RosElements::RE_USE: + ok = ReadUse(parent,element,context); + break; } *************** *** 921,925 **** shared_ptr<Body> body1 = GetJointParentBody(parent); ! if (! ReadChildElements(parent, element, context)) { return false; --- 964,970 ---- shared_ptr<Body> body1 = GetJointParentBody(parent); ! //! Todo: figure out if all objects below a joint node are ! //implicitly movable, i.e. are created with a Body node ! if (! ReadChildElements(parent, element, NC_MOVABLE)) { return false; *************** *** 934,938 **** { GetLog()->Error() << "(RosImporter::ReadHinge) found no bodies to attach hinge to in " ! << GetXMLPath(element) << "\n"; return false; } --- 979,983 ---- { GetLog()->Error() << "(RosImporter::ReadHinge) found no bodies to attach hinge to in " ! << GetXMLPath(element) << " named " << name << "\n"; return false; } *************** *** 950,951 **** --- 995,1054 ---- GetLog()->Debug() << "(RosImporter) created hinge joint " << name << "\n"; } + + bool RosImporter::ReadMacro(shared_ptr<BaseNode> parent, TiXmlElement* element) + { + string name; + if (! ReadAttribute(element, RA_NAME, name)) + { + return false; + } + + shared_ptr<TiXmlElement> macro(new TiXmlElement(*element)); + mMacroMap[name] = macro; + + GetLog()->Debug() << "(RosImporter) defined macro " << name << "\n"; + } + + bool RosImporter::ReadUse(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) + { + string name; + string instance; + Trans trans; + + if ( + (! ReadAttribute(element, RA_MACRONAME, name)) || + (! ReadAttribute(element, RA_INSTANCENAME, instance, true)) || + (! ReadTrans(element, trans)) + ) + { + return false; + } + + TMacroMap::const_iterator iter = mMacroMap.find(name); + if (iter == mMacroMap.end()) + { + GetLog()->Error() << "(RosImporter) use of undefined macro " << name << " in " + << GetXMLPath(element) << "\n"; + return false; + } + + // todo: <SubstituteSurfaces> + // todo: <SubstituteAllSurfaces> + + if (instance.empty()) + { + instance = name; + } + + shared_ptr<Transform> transform = CreateTransform(parent, trans); + transform->SetName(S_MACRO+instance); + + GetLog()->Debug() << "(RosImporter) START instancing macro " << name << "\n"; + + shared_ptr<TiXmlElement> tree = (*iter).second; + bool ok = ReadElements(transform, tree.get(), context); + + GetLog()->Debug() << "(RosImporter) END instancing macro " << name << "\n"; + + return ok; + } Index: rosimporter.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** rosimporter.h 19 Feb 2006 10:44:28 -0000 1.3 --- rosimporter.h 19 Feb 2006 13:19:18 -0000 1.4 *************** *** 23,27 **** #define ROSIMPORTER_H ! #include <list> #include <oxygen/sceneserver/sceneimporter.h> #include <tinyxml/tinyxml.h> --- 23,27 ---- #define ROSIMPORTER_H ! #include <map> #include <oxygen/sceneserver/sceneimporter.h> #include <tinyxml/tinyxml.h> *************** *** 86,89 **** --- 86,94 ---- }; + /** define a registry of macros; a macro is a XML subtree with the + <Macro> node a the root element + */ + typedef std::map<std::string, boost::shared_ptr<TiXmlElement> > TMacroMap; + public: RosImporter(); *************** *** 126,129 **** --- 131,137 ---- bool ReadScene(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element); + bool ReadMacro(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element); + bool ReadUse(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); + bool ReadChildElements(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); *************** *** 146,150 **** bool ReadAxis(TiXmlElement* element, salt::Vector3f& axis); - boost::shared_ptr<oxygen::Body> RosImporter::GetJointParentBody(boost::shared_ptr<oxygen::BaseNode> parent); boost::shared_ptr<oxygen::Body> RosImporter::GetJointChildBody(boost::shared_ptr<oxygen::BaseNode> parent); --- 154,157 ---- *************** *** 165,168 **** --- 172,179 ---- double mGlobalCFM; + /** the static macro registry is shared across RosImporter + instances + */ + static TMacroMap mMacroMap; }; |
From: Markus R. <rol...@us...> - 2006-02-19 13:16:24
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24949 Modified Files: roselements.h Log Message: - added hinge and macro elements Index: roselements.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/roselements.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** roselements.h 18 Feb 2006 19:52:14 -0000 1.1 --- roselements.h 19 Feb 2006 13:16:18 -0000 1.2 *************** *** 62,65 **** --- 62,69 ---- #define RA_VALUE "value" + // Use + #define RA_MACRONAME "macroName" + #define RA_INSTANCENAME "instanceName" + class RosElements { *************** *** 83,86 **** --- 87,97 ---- RE_CAPPEDCYLINDER, + RE_MACRO, + RE_USE, + + RE_HINGE, + RE_ANCHORPOINT, + RE_AXIS, + RE_GLOBALPHYSICALPARAMETERS, RE_PHYSICALATTRIBUTES, |
From: Markus R. <rol...@us...> - 2006-02-19 13:15:35
|
Update of /cvsroot/simspark/simspark/spark/oxygen/physicsserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24038 Modified Files: hingejoint.h hingejoint.cpp Log Message: - added method SetAxis() that takes an arbitrary axis vector Index: hingejoint.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/hingejoint.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** hingejoint.cpp 12 Feb 2006 11:36:52 -0000 1.4 --- hingejoint.cpp 19 Feb 2006 13:15:26 -0000 1.5 *************** *** 85,97 **** { // calculate hinge axis (pos. x, relative to world transform) ! Vector3f right(GetWorldTransform().Rotate(Vector3f(1,0,0))); ! dJointSetHingeAxis(mODEJoint, right[0], right[1], right[2]); break; } case AI_SECOND: { ! // calculate hinge axis (pos. y, relative to world transform) ! Vector3f forward(GetWorldTransform().Rotate(Vector3f(0,1,0))); ! dJointSetHingeAxis(mODEJoint, forward[0], forward[1], forward[2]); break; } --- 85,95 ---- { // calculate hinge axis (pos. x, relative to world transform) ! SetAxis(Vector3f(1,0,0)); break; } case AI_SECOND: { ! // calculate hinge axis (pos. y, relative to world transform) ! SetAxis(Vector3f(0,1,0)); break; } *************** *** 99,104 **** { // calculate hinge axis (pos. z, relative to world transform) ! Vector3f up(GetWorldTransform().Rotate(Vector3f(0,0,1))); ! dJointSetHingeAxis(mODEJoint, up[0], up[1], up[2]); break; } --- 97,101 ---- { // calculate hinge axis (pos. z, relative to world transform) ! SetAxis(Vector3f(0,0,1)); break; } *************** *** 108,111 **** --- 105,114 ---- } + void HingeJoint::SetAxis(const Vector3f& axis) + { + Vector3f absAxis(GetWorldTransform().Rotate(axis)); + dJointSetHingeAxis(mODEJoint, absAxis[0], absAxis[1], absAxis[2]); + } + Vector3f HingeJoint::GetAxis() { Index: hingejoint.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/hingejoint.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** hingejoint.h 12 Feb 2006 11:36:52 -0000 1.4 --- hingejoint.h 19 Feb 2006 13:15:26 -0000 1.5 *************** *** 45,55 **** salt::Vector3f GetAnchor(EBodyIndex idx); ! /** Sets the joint axis. The connected bodies movements will be ! constrained to move around this axis. */ void SetAxis(EAxisIndex idx); ! /** Returns the hinge axis in the local coordinate system ! */ salt::Vector3f GetAxis(); --- 45,61 ---- salt::Vector3f GetAnchor(EBodyIndex idx); ! /** Sets the joint axis in the local coordinate system. The ! connected bodies movements will be constrained to move around ! this axis. */ void SetAxis(EAxisIndex idx); ! /** Sets the joint axis in the local coordinate system. The ! connected bodies movements will be constrained to move around ! this axis. ! */ ! void SetAxis(const salt::Vector3f& axis); ! ! /** Returns the hinge axis in the local coordinate system */ salt::Vector3f GetAxis(); |
From: Oliver O. <fr...@us...> - 2006-02-19 12:56:16
|
Update of /cvsroot/simspark/simspark/spark In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13129 Modified Files: acinclude.m4 Log Message: fixed ruby check Index: acinclude.m4 =================================================================== RCS file: /cvsroot/simspark/simspark/spark/acinclude.m4,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** acinclude.m4 19 Dec 2005 20:09:16 -0000 1.1 --- acinclude.m4 19 Feb 2006 12:56:07 -0000 1.2 *************** *** 18,22 **** AC_PATH_PROGS(RUBY,[$ruby ruby],no) # Test ruby interpreter ! if test $ruby = no; then AC_MSG_ERROR(Could not find Ruby Interpreter. Please use --with-ruby option.) fi --- 18,22 ---- AC_PATH_PROGS(RUBY,[$ruby ruby],no) # Test ruby interpreter ! if test $RUBY = no; then AC_MSG_ERROR(Could not find Ruby Interpreter. Please use --with-ruby option.) fi |
From: Markus R. <rol...@us...> - 2006-02-19 11:12:07
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3172 Modified Files: rosimporter.cpp Log Message: - use the MaterialServer::RegisterMaterial() method instead of directly instancing a new material. This assures that multiple runs of the RosImporter don't create multiple instanes of one material definition Index: rosimporter.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** rosimporter.cpp 19 Feb 2006 10:44:28 -0000 1.3 --- rosimporter.cpp 19 Feb 2006 11:11:58 -0000 1.4 *************** *** 33,36 **** --- 33,37 ---- #include <oxygen/physicsserver/hingejoint.h> #include <kerosin/openglserver/glbase.h> + #include <kerosin/materialserver/materialserver.h> #include <kerosin/materialserver/materialsolid.h> #include <kerosin/sceneserver/box.h> *************** *** 272,276 **** bool RosImporter::ReadAppearenceDef(TiXmlElement* element) { ! shared_ptr<Node> materialServer = shared_dynamic_cast<Node> (GetCore()->Get("/sys/server/material")); --- 273,277 ---- bool RosImporter::ReadAppearenceDef(TiXmlElement* element) { ! shared_ptr<MaterialServer> materialServer = shared_dynamic_cast<MaterialServer> (GetCore()->Get("/sys/server/material")); *************** *** 314,318 **** material->SetDiffuse(rgba); ! materialServer->AddChildReference(material); GetLog()->Debug() << "(RosImporter) defined SolidMaterial " << name << "\n"; --- 315,319 ---- material->SetDiffuse(rgba); ! materialServer->RegisterMaterial(material); GetLog()->Debug() << "(RosImporter) defined SolidMaterial " << name << "\n"; |
From: Markus R. <rol...@us...> - 2006-02-19 11:10:21
|
Update of /cvsroot/simspark/simspark/spark/kerosin/materialserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2008 Modified Files: materialserver.cpp materialserver.h Log Message: - added method RegisterMaterial() that checks for and removesm a previous material instance with the same name before registering the new material. Index: materialserver.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/materialserver/materialserver.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** materialserver.h 5 Dec 2005 21:38:22 -0000 1.1 --- materialserver.h 19 Feb 2006 11:10:11 -0000 1.2 *************** *** 43,46 **** --- 43,49 ---- virtual ~MaterialServer(); + //! registers a new material + void RegisterMaterial(boost::shared_ptr<Material> material); + //! returns a cached material boost::shared_ptr<Material> GetMaterial(const std::string &name); Index: materialserver.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/materialserver/materialserver.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** materialserver.cpp 5 Dec 2005 21:38:22 -0000 1.1 --- materialserver.cpp 19 Feb 2006 11:10:11 -0000 1.2 *************** *** 38,41 **** --- 38,66 ---- } + void MaterialServer::RegisterMaterial(shared_ptr<Material> material) + { + if (material.get() == 0) + { + return; + } + + // remove any previous material with the same name + shared_ptr<Material> previous = + shared_dynamic_cast<Material>(GetChild(material->GetName())); + + if (previous.get() != 0) + { + GetLog()->Debug() << "(MaterialServer) removing material " + << material->GetName() << "\n"; + RemoveChildReference(previous); + } + + // register new material + AddChildReference(material); + + GetLog()->Debug() << "(MaterialServer) registered material " + << material->GetName() << "\n"; + } + shared_ptr<Material> MaterialServer::GetMaterial(const std::string& name) { |
From: Markus R. <rol...@us...> - 2006-02-19 10:44:33
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23688 Modified Files: rosimporter.h rosimporter.cpp Log Message: - create a capped cylinder as a supplement for the yet unsupported cylinder - added support for the hinge joint Index: rosimporter.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rosimporter.cpp 18 Feb 2006 19:54:57 -0000 1.2 --- rosimporter.cpp 19 Feb 2006 10:44:28 -0000 1.3 *************** *** 31,34 **** --- 31,35 ---- #include <oxygen/physicsserver/contactjointhandler.h> #include <oxygen/physicsserver/body.h> + #include <oxygen/physicsserver/hingejoint.h> #include <kerosin/openglserver/glbase.h> #include <kerosin/materialserver/materialsolid.h> *************** *** 46,50 **** using namespace std; ! #define S_FROMSTRING "<from string>"; RosImporter::RosImporter() : SceneImporter() --- 47,54 ---- using namespace std; ! static const string S_FROMSTRING("<from string>"); ! static const string S_BODY("body_"); ! static const string S_GEOM("geometry_"); ! static const string S_VISUAL("visual_"); RosImporter::RosImporter() : SceneImporter() *************** *** 79,83 **** bool RosImporter::ImportScene(const std::string& fileName, ! shared_ptr<BaseNode> root, shared_ptr<ParameterList> parameter) { --- 83,87 ---- bool RosImporter::ImportScene(const std::string& fileName, ! shared_ptr<BaseNode> parent, shared_ptr<ParameterList> parameter) { *************** *** 99,115 **** buffer[file->Size()] = 0; ! return ParseScene(buffer.get(), file->Size(), root, parameter); } bool RosImporter::ParseScene(const std::string& scene, ! shared_ptr<BaseNode> root, shared_ptr<ParameterList> parameter) { mFileName = S_FROMSTRING; ! return ParseScene(scene.c_str(),scene.size(),root,parameter); } bool RosImporter::ParseScene(const char* scene, int size, ! shared_ptr<BaseNode> root, shared_ptr<zeitgeist::ParameterList> parameter) { --- 103,119 ---- buffer[file->Size()] = 0; ! return ParseScene(buffer.get(), file->Size(), parent, parameter); } bool RosImporter::ParseScene(const std::string& scene, ! shared_ptr<BaseNode> parent, shared_ptr<ParameterList> parameter) { mFileName = S_FROMSTRING; ! return ParseScene(scene.c_str(),scene.size(),parent,parameter); } bool RosImporter::ParseScene(const char* scene, int size, ! shared_ptr<BaseNode> parent, shared_ptr<zeitgeist::ParameterList> parameter) { *************** *** 167,171 **** case RosElements::RE_SCENE: ! ok = ReadScene(root, element); } --- 171,175 ---- case RosElements::RE_SCENE: ! ok = ReadScene(parent, element); } *************** *** 341,347 **** } ! bool RosImporter::ReadScene(shared_ptr<BaseNode> root, TiXmlElement* element) { ! if (root.get() == 0) { return false; --- 345,351 ---- } ! bool RosImporter::ReadScene(shared_ptr<BaseNode> parent, TiXmlElement* element) { ! if (parent.get() == 0) { return false; *************** *** 360,374 **** // SimulationParameters stepLength="" standardLength="" applyDynamicsForceFactor="" ! TiXmlElement* elements = GetFirstChild(element, RosElements::RE_ELEMENTS); ! if (elements == 0) { ! // empty scene? ! return true; } ! return ReadElements(root, elements, NC_ELEMENTS); } ! bool RosImporter::ReadElements(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) { GetLog()->Debug() << "(RosImporter) reading elements node\n"; --- 364,389 ---- // SimulationParameters stepLength="" standardLength="" applyDynamicsForceFactor="" ! return ReadChildElements(parent, element, NC_ELEMENTS); ! } ! ! bool RosImporter::ReadChildElements(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) ! { ! for ( ! TiXmlNode* node = GetFirstChild(element, RosElements::RE_ELEMENTS); ! node != 0; ! node = element->IterateChildren(node) ! ) { ! TiXmlElement* childElement = static_cast<TiXmlElement*>(node); ! if (! ReadElements(parent, childElement, context)) ! { ! return false; ! } } ! return true; } ! bool RosImporter::ReadElements(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) { GetLog()->Debug() << "(RosImporter) reading elements node\n"; *************** *** 397,422 **** case RosElements::RE_ELEMENTS: ! ok = ReadElements(root,element,context); break; case RosElements::RE_MOVABLE: ! ok = ReadMovable(root,element,context); break; case RosElements::RE_BOX: ! ok = ReadBox(root,element,context); break; case RosElements::RE_SPHERE: ! ok = ReadSphere(root,element,context); break; case RosElements::RE_CYLINDER: ! ok = ReadCylinder(root,element,context); break; case RosElements::RE_CAPPEDCYLINDER: ! ok = ReadCappedCylinder(root,element,context); break; } --- 412,441 ---- case RosElements::RE_ELEMENTS: ! ok = ReadElements(parent,element,context); break; case RosElements::RE_MOVABLE: ! ok = ReadMovable(parent,element,context); break; case RosElements::RE_BOX: ! ok = ReadBox(parent,element,context); break; case RosElements::RE_SPHERE: ! ok = ReadSphere(parent,element,context); break; case RosElements::RE_CYLINDER: ! ok = ReadCylinder(parent,element,context); break; case RosElements::RE_CAPPEDCYLINDER: ! ok = ReadCappedCylinder(parent,element,context); break; + + case RosElements::RE_HINGE: + ok = ReadHinge(parent,element,context); + break; } *************** *** 430,434 **** } ! bool RosImporter::ReadMovable(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) { GetLog()->Debug() << "(RosImporter) reading moveable node\n"; --- 449,453 ---- } ! bool RosImporter::ReadMovable(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) { GetLog()->Debug() << "(RosImporter) reading moveable node\n"; *************** *** 459,463 **** case RosElements::RE_ELEMENTS: ! ok = ReadElements(root,element,context); break; } --- 478,482 ---- case RosElements::RE_ELEMENTS: ! ok = ReadElements(parent,element,context); break; } *************** *** 495,499 **** } ! shared_ptr<Transform> RosImporter::CreateTransform(shared_ptr<BaseNode> root, const Trans& trans) { shared_ptr<Transform> transform = shared_dynamic_cast<Transform> --- 514,518 ---- } ! shared_ptr<Transform> RosImporter::CreateTransform(shared_ptr<BaseNode> parent, const Trans& trans) { shared_ptr<Transform> transform = shared_dynamic_cast<Transform> *************** *** 503,507 **** transform->SetLocalPos(trans.translate); ! root->AddChildReference(transform); return transform; } --- 522,526 ---- transform->SetLocalPos(trans.translate); ! parent->AddChildReference(transform); return transform; } *************** *** 610,640 **** } ! bool RosImporter::ReadCylinder(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) { ! string name; ! double radius; ! double height; ! Trans trans; ! Appearance appear; ! Physical physical; ! ! if ( ! (! ReadAttribute(element, RA_NAME, name)) || ! (! ReadAttribute(element, RA_RADIUS, radius)) || ! (! ReadAttribute(element, RA_HEIGHT, height)) || ! (! ReadTrans(element, trans)) || ! (! ReadAppearance(element, appear)) || ! (! ReadPhysical(element, physical, context)) ! ) ! { ! return false; ! } ! ! //! todo: Cylinder primitive not yet supported ! GetLog()->Error() << "(RosImporter) Cylinder primitive not supported\n"; ! return true; } ! bool RosImporter::ReadCappedCylinder(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) { string name; --- 629,639 ---- } ! bool RosImporter::ReadCylinder(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) { ! GetLog()->Debug() << "(RosImporter) cylinder geom unsupported yet. Created a capped cylinder geom\n"; ! return ReadCappedCylinder(parent, element, context); } ! bool RosImporter::ReadCappedCylinder(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) { string name; *************** *** 658,662 **** // transform ! shared_ptr<Transform> transform = CreateTransform(root, trans); transform->SetName(name); --- 657,661 ---- // transform ! shared_ptr<Transform> transform = CreateTransform(parent, trans); transform->SetName(name); *************** *** 664,670 **** shared_ptr<CCylinder> ccylinder = shared_dynamic_cast<CCylinder> (GetCore()->New("/kerosin/CCylinder")); - transform->AddChildReference(ccylinder); ccylinder->SetParams(radius, height); ccylinder->SetMaterial(appear.ref); --- 663,669 ---- shared_ptr<CCylinder> ccylinder = shared_dynamic_cast<CCylinder> (GetCore()->New("/kerosin/CCylinder")); transform->AddChildReference(ccylinder); + ccylinder->SetName(S_VISUAL+name); ccylinder->SetParams(radius, height); ccylinder->SetMaterial(appear.ref); *************** *** 683,687 **** transform->AddChildReference(body); ! body->SetCylinderTotal(physical.mass, radius, height); //! TODO: set mass center break; --- 682,687 ---- transform->AddChildReference(body); ! body->SetName(S_BODY+name); ! body->SetCappedCylinderTotal(physical.mass, radius, height); //! TODO: set mass center break; *************** *** 692,695 **** --- 692,696 ---- shared_ptr<CCylinderCollider> collider = shared_dynamic_cast<CCylinderCollider> (GetCore()->New("/oxygen/CCylinderCollider")); + collider->SetName(S_GEOM+name); transform->AddChildReference(collider); *************** *** 702,709 **** GetLog()->Debug() << "(RosImporter) created capped cylinder " << name << "\n"; ! return true; } ! bool RosImporter::ReadSphere(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) { string name; --- 703,710 ---- GetLog()->Debug() << "(RosImporter) created capped cylinder " << name << "\n"; ! return ReadChildElements(transform, element, context); } ! bool RosImporter::ReadSphere(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) { string name; *************** *** 725,729 **** // transform ! shared_ptr<Transform> transform = CreateTransform(root, trans); transform->SetName(name); --- 726,730 ---- // transform ! shared_ptr<Transform> transform = CreateTransform(parent, trans); transform->SetName(name); *************** *** 734,737 **** --- 735,739 ---- transform->AddChildReference(sphere); + sphere->SetName(S_VISUAL+name); sphere->SetRadius(radius); sphere->SetMaterial(appear.ref); *************** *** 750,753 **** --- 752,756 ---- transform->AddChildReference(body); + body->SetName(S_BODY+name); body->SetSphereTotal(physical.mass, radius); //! TODO: set mass center *************** *** 768,776 **** GetLog()->Debug() << "(RosImporter) created sphere " << name << "\n"; ! ! return true; } ! bool RosImporter::ReadBox(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) { string name; --- 771,778 ---- GetLog()->Debug() << "(RosImporter) created sphere " << name << "\n"; ! return ReadChildElements(transform, element, context); } ! bool RosImporter::ReadBox(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) { string name; *************** *** 796,800 **** // transform ! shared_ptr<Transform> transform = CreateTransform(root, trans); transform->SetName(name); --- 798,802 ---- // transform ! shared_ptr<Transform> transform = CreateTransform(parent, trans); transform->SetName(name); *************** *** 806,809 **** --- 808,812 ---- Vector3f boxDim = Vector3f(length, width, height); + box->SetName(S_VISUAL+name); box->SetExtents(boxDim); box->SetMaterial(appear.ref); *************** *** 822,825 **** --- 825,829 ---- transform->AddChildReference(body); + body->SetName(S_BODY+name); body->SetBoxTotal(physical.mass, boxDim); //! TODO: set mass center *************** *** 833,836 **** --- 837,841 ---- transform->AddChildReference(collider); + collider->SetName(S_GEOM+name); collider->SetBoxLengths(boxDim); *************** *** 840,844 **** GetLog()->Debug() << "(RosImporter) created box " << name << "\n"; ! return true; } --- 845,950 ---- GetLog()->Debug() << "(RosImporter) created box " << name << "\n"; + return ReadChildElements(transform, element, context); + } ! bool RosImporter::ReadAnchorPoint(TiXmlElement* element, Vector3f& anchor) ! { ! TiXmlElement* anchorElem = GetFirstChild(element,RosElements::RE_ANCHORPOINT); ! if (anchorElem == 0) ! { ! GetLog()->Error() << "(RosImporter) ERROR: missing anchorpoint in " ! << GetXMLPath(element) << "\n"; ! return false; ! } ! ! return ReadVector(anchorElem, anchor); ! } ! ! bool RosImporter::ReadAxis(TiXmlElement* element, salt::Vector3f& axis) ! { ! TiXmlElement* axisElem = GetFirstChild(element,RosElements::RE_AXIS); ! if (axisElem == 0) ! { ! GetLog()->Error() << "(RosImporter) ERROR: missing axis in " ! << GetXMLPath(element) << "\n"; ! return false; ! } ! ! return ReadVector(axisElem, axis); ! } ! ! shared_ptr<Body> RosImporter::GetJointParentBody(shared_ptr<BaseNode> parent) ! { ! return parent->FindChildSupportingClass<Body>(); ! } ! ! shared_ptr<Body> RosImporter::GetJointChildBody(shared_ptr<BaseNode> parent) ! { ! // find the body created most recently ! Leaf::TLeafList children; ! parent->ListChildrenSupportingClass<Transform>(children,false); ! ! for ( ! Leaf::TLeafList::reverse_iterator iter = children.rbegin(); ! iter != children.rend(); ! ++iter ! ) ! { ! shared_ptr<Body> body = ! (*iter)->FindChildSupportingClass<Body>(false); ! ! if (body.get() != 0) ! { ! return body; ! } ! } ! ! return shared_ptr<Body>(); ! } ! ! bool RosImporter::ReadHinge(shared_ptr<BaseNode> parent, TiXmlElement* element, ENodeContext context) ! { ! string name; ! Vector3f anchor; ! Vector3f axis; ! ! if ( ! (! ReadAttribute(element, RA_NAME, name)) || ! (! ReadAnchorPoint(element, anchor)) || ! (! ReadAxis(element, axis)) ! ) ! { ! return false; ! } ! ! shared_ptr<Body> body1 = GetJointParentBody(parent); ! ! if (! ReadChildElements(parent, element, context)) ! { ! return false; ! } ! ! shared_ptr<Body> body2 = GetJointChildBody(parent); ! ! if ( ! (body1.get() == 0) && ! (body2.get() == 0) ! ) ! { ! GetLog()->Error() << "(RosImporter::ReadHinge) found no bodies to attach hinge to in " ! << GetXMLPath(element) << "\n"; ! return false; ! } ! ! shared_ptr<HingeJoint> hinge = shared_dynamic_cast<HingeJoint> ! (GetCore()->New("/oxygen/HingeJoint")); ! ! parent->AddChildReference(hinge); ! ! hinge->SetName(name); ! hinge->Attach(body1, body2); ! hinge->SetAnchor(anchor); ! hinge->SetAxis(axis); ! ! GetLog()->Debug() << "(RosImporter) created hinge joint " << name << "\n"; } Index: rosimporter.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rosimporter.h 18 Feb 2006 19:54:57 -0000 1.2 --- rosimporter.h 19 Feb 2006 10:44:28 -0000 1.3 *************** *** 23,26 **** --- 23,27 ---- #define ROSIMPORTER_H + #include <list> #include <oxygen/sceneserver/sceneimporter.h> #include <tinyxml/tinyxml.h> *************** *** 32,35 **** --- 33,37 ---- class Transform; class ContactJointHandler; + class Body; } *************** *** 44,56 **** enum ENodeContext { ! /** the node is read within an <Elements> tag, where no physical bodies are created */ NC_ELEMENTS, ! /** the node is read within an <Movable> tag, where ! physical bodies are created */ ! NC_MOVABLE }; --- 46,58 ---- enum ENodeContext { ! /** the node is read within a <Elements> tag, where no physical bodies are created */ NC_ELEMENTS, ! /** the node is read within a <Movable> tag or a joint ! node, where physical bodies are created */ ! NC_MOVABLE, }; *************** *** 81,85 **** public: Physical() ! : mass(1.0), massCenter(0.0, 0.0, 0.0) {} }; --- 83,87 ---- public: Physical() ! : mass(0.0), massCenter(0.0, 0.0, 0.0) {} }; *************** *** 89,102 **** 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); protected: virtual bool ParseScene(const char* scene, int size, ! boost::shared_ptr<oxygen::BaseNode> root, boost::shared_ptr<zeitgeist::ParameterList> parameter); --- 91,104 ---- virtual bool ImportScene(const std::string& fileName, ! boost::shared_ptr<oxygen::BaseNode> parent, boost::shared_ptr<zeitgeist::ParameterList> parameter); virtual bool ParseScene(const std::string& scene, ! boost::shared_ptr<oxygen::BaseNode> parent, boost::shared_ptr<zeitgeist::ParameterList> parameter); protected: virtual bool ParseScene(const char* scene, int size, ! boost::shared_ptr<oxygen::BaseNode> parent, boost::shared_ptr<zeitgeist::ParameterList> parameter); *************** *** 109,113 **** boost::shared_ptr<oxygen::Transform> CreateTransform ! (boost::shared_ptr<oxygen::BaseNode> root, const Trans& trans); boost::shared_ptr<oxygen::ContactJointHandler> --- 111,115 ---- boost::shared_ptr<oxygen::Transform> CreateTransform ! (boost::shared_ptr<oxygen::BaseNode> parent, const Trans& trans); boost::shared_ptr<oxygen::ContactJointHandler> *************** *** 122,128 **** bool ReadAppearenceDef(TiXmlElement* element); ! bool ReadScene(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element); ! bool ReadElements(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); ! bool ReadMovable(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); bool ReadTrans(TiXmlElement* element, Trans& trans); --- 124,133 ---- bool ReadAppearenceDef(TiXmlElement* element); ! bool ReadScene(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element); ! ! bool ReadChildElements(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); ! ! bool ReadElements(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); ! bool ReadMovable(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); bool ReadTrans(TiXmlElement* element, Trans& trans); *************** *** 133,140 **** bool ReadPhysical(TiXmlElement* element, Physical& physical, ENodeContext context); ! bool ReadBox(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); ! bool ReadSphere(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); ! bool ReadCylinder(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); ! bool ReadCappedCylinder(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); protected: --- 138,154 ---- bool ReadPhysical(TiXmlElement* element, Physical& physical, ENodeContext context); ! bool ReadBox(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); ! bool ReadSphere(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); ! bool ReadCylinder(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); ! bool ReadCappedCylinder(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); ! ! bool ReadAnchorPoint(TiXmlElement* element, salt::Vector3f& anchor); ! bool ReadAxis(TiXmlElement* element, salt::Vector3f& axis); ! ! ! boost::shared_ptr<oxygen::Body> RosImporter::GetJointParentBody(boost::shared_ptr<oxygen::BaseNode> parent); ! boost::shared_ptr<oxygen::Body> RosImporter::GetJointChildBody(boost::shared_ptr<oxygen::BaseNode> parent); ! ! bool ReadHinge(boost::shared_ptr<oxygen::BaseNode> parent, TiXmlElement* element, ENodeContext context); protected: |
From: Markus R. <rol...@us...> - 2006-02-18 19:55:03
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16781 Modified Files: rosimporter.cpp rosimporter.h Log Message: - initial working version of the rosimporter. All basic primitives (box, sphere, cappedyclinder) except plane and cylinder are supported, complex bodies and joints missing. Physical properties and colliders are setup. Index: rosimporter.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rosimporter.cpp 24 Jan 2006 19:16:32 -0000 1.1 --- rosimporter.cpp 18 Feb 2006 19:54:57 -0000 1.2 *************** *** 21,29 **** --- 21,45 ---- */ #include "rosimporter.h" + #include <tinyxml/xmlfunctions.h> #include <zeitgeist/logserver/logserver.h> #include <zeitgeist/fileserver/fileserver.h> + #include <oxygen/sceneserver/basenode.h> + #include <oxygen/sceneserver/transform.h> + #include <oxygen/physicsserver/boxcollider.h> + #include <oxygen/physicsserver/spherecollider.h> + #include <oxygen/physicsserver/ccylindercollider.h> + #include <oxygen/physicsserver/contactjointhandler.h> + #include <oxygen/physicsserver/body.h> + #include <kerosin/openglserver/glbase.h> + #include <kerosin/materialserver/materialsolid.h> + #include <kerosin/sceneserver/box.h> + #include <kerosin/sceneserver/sphere.h> + #include <kerosin/sceneserver/ccylinder.h> + #include <kerosin/renderserver/renderserver.h> #include <boost/scoped_array.hpp> + using namespace salt; using namespace zeitgeist; + using namespace kerosin; using namespace oxygen; using namespace boost; *************** *** 34,37 **** --- 50,55 ---- RosImporter::RosImporter() : SceneImporter() { + mGlobalERP = 0.2; + mGlobalCFM = 0.0001; } *************** *** 40,73 **** } ! TiXmlElement* RosImporter::GetFirstChild(TiXmlNode* node, const std::string& type) { ! TiXmlNode* childNode ! = node->FirstChild(type.c_str()); ! ! if ( ! (childNode == 0) || ! (childNode->Type() != TiXmlNode::ELEMENT) ! ) ! { ! return 0; ! } ! ! return static_cast<TiXmlElement*>(childNode); } ! TiXmlElement* RosImporter::IterateChildren(TiXmlNode* node, const std::string& type) { ! TiXmlNode* childNode ! = node->Parent()->IterateChildren(type.c_str(),node); ! if ( ! (childNode == 0) || ! (childNode->Type() != TiXmlNode::ELEMENT) ! ) ! { ! return 0; ! } ! return static_cast<TiXmlElement*>(childNode); } --- 58,79 ---- } ! RosElements::ERosElement RosImporter::GetType(const TiXmlElement* element) const { ! return RosElements::GetInstance().Lookup(GetXMLValue(element)); } ! string RosImporter::GetName(RosElements::ERosElement element) const { ! return RosElements::GetInstance().Lookup(element); ! } ! TiXmlElement* RosImporter::GetFirstChild(TiXmlNode* node, RosElements::ERosElement type) ! { ! return ::GetFirstChild(node, GetName(type)); ! } ! TiXmlElement* RosImporter::IterateChildren(TiXmlNode* node, RosElements::ERosElement type) ! { ! return ::IterateChildren(node, GetName(type)); } *************** *** 105,110 **** bool RosImporter::ParseScene(const char* scene, int size, ! boost::shared_ptr<oxygen::BaseNode> root, ! boost::shared_ptr<zeitgeist::ParameterList> parameter) { TiXmlDocument document; --- 111,116 ---- bool RosImporter::ParseScene(const char* scene, int size, ! shared_ptr<BaseNode> root, ! shared_ptr<zeitgeist::ParameterList> parameter) { TiXmlDocument document; *************** *** 114,118 **** { GetLog()->Error() << "(RosImporter) ERROR: xml parsing error: " ! << document.ErrorDesc() << std::endl; return false; } --- 120,124 ---- { GetLog()->Error() << "(RosImporter) ERROR: xml parsing error: " ! << document.ErrorDesc() << "\n"; return false; } *************** *** 121,140 **** if (xmlRoot == 0) { ! // empty doc ! return true; } for ( TiXmlNode* node = xmlRoot->FirstChild(); ! xmlRoot != 0; node = xmlRoot->IterateChildren(node) ) { TiXmlElement* element = static_cast<TiXmlElement*>(node); ! std::string value(node->Value()); } return true; } --- 127,844 ---- if (xmlRoot == 0) { ! GetLog()->Error() << "(RosImporter) ERROR: empty xml document\n"; ! return false; } + if ( + (GetType(xmlRoot) != RosElements::RE_SIMULATION) && + (GetType(xmlRoot) != RosElements::RE_ROSIINCLUDEFILE) + ) + { + GetLog()->Error() << "(RosImporter) ERROR: unknown xml root element type " + << GetXMLValue(xmlRoot) << "\n"; + return false; + } for ( TiXmlNode* node = xmlRoot->FirstChild(); ! node != 0; node = xmlRoot->IterateChildren(node) ) { TiXmlElement* element = static_cast<TiXmlElement*>(node); + if (element == 0) + { + continue; + } ! bool ok = true; ! ! RosElements::ERosElement type = GetType(element); ! switch (type) ! { ! default: ! GetLog()->Error() << "(RosImporter::ParseScene) ERROR: skipping unknown toplevel element " ! << GetXMLPath(element) << "\n"; ! break; ! ! case RosElements::RE_APPEARANCEDEFINITION: ! ok = ReadAppearenceDef(element); ! break; ! ! case RosElements::RE_SCENE: ! ok = ReadScene(root, element); ! } ! ! if (! ok) ! { ! break; ! } ! ! } ! ! return true; ! } ! ! bool RosImporter::ReadAttribute(TiXmlElement* element, const std::string& attribute, ! std::string& value, bool succeedIfMissing) ! { ! if (element == 0) ! { ! return false; ! } ! ! if (! GetXMLAttribute(element, attribute, value)) ! { ! if (! succeedIfMissing) ! { ! GetLog()->Error() << "(RosImporter) ERROR: missing string attribute " << attribute << " in " ! << GetXMLPath(element) << "\n"; ! return false; ! } ! } ! ! return true; ! } ! ! bool RosImporter::ReadAttribute(TiXmlElement* element, const std::string& attribute, ! double& value, bool succeedIfMissing) ! { ! if (element == 0) ! { ! return false; ! } ! ! if (! GetXMLAttribute(element, attribute, value)) ! { ! if (! succeedIfMissing) ! { ! GetLog()->Error() << "(RosImporter) ERROR: missing float attribute " << attribute << " in " ! << GetXMLPath(element) << "\n"; ! return false; ! } ! } ! ! return true; ! } ! ! ! bool RosImporter::ReadRGBA(TiXmlElement* element, RGBA& rgba) ! { ! int r,g,b; ! if ( ! (! GetXMLAttribute(element, RA_R, r)) || ! (! GetXMLAttribute(element, RA_G, g)) || ! (! GetXMLAttribute(element, RA_B, b)) ! ) ! { ! GetLog()->Error() << "(RosImporter) ERROR: missing color attributes in " ! << GetXMLPath(element) << "\n"; ! return false; ! } ! ! rgba.r() = (static_cast<float>(r) / 255.0); ! rgba.g() = (static_cast<float>(g) / 255.0); ! rgba.b() = (static_cast<float>(b) / 255.0); ! ! double a; ! rgba.a() = GetXMLAttribute(element, RA_A, a) ? a : 1.0; ! ! return true; ! } ! ! bool RosImporter::ReadVector(TiXmlElement* element, Vector3f& vec, bool succeedIfMissing) ! { ! if ( ! (! GetXMLAttribute(element, RA_X, vec[0])) || ! (! GetXMLAttribute(element, RA_Y, vec[1])) || ! (! GetXMLAttribute(element, RA_Z, vec[2])) ! ) ! { ! if (! succeedIfMissing) ! { ! GetLog()->Error() << "(RosImporter) ERROR: invalid or missing vector attributes in " ! << GetXMLPath(element) << "\n"; ! return false; ! } ! } ! ! return true; ! } ! ! bool RosImporter::ReadAppearenceDef(TiXmlElement* element) ! { ! shared_ptr<Node> materialServer = shared_dynamic_cast<Node> ! (GetCore()->Get("/sys/server/material")); ! ! if (materialServer.get() == 0) ! { ! GetLog()->Error() << "(RosImporter) failed to lookup MaterialServer node\n"; ! return false; ! } ! ! string name; ! if (! ReadAttribute(element, RA_NAME, name)) ! { ! return false; ! } ! ! RGBA rgba; ! ! TiXmlElement* colorElem = GetFirstChild(element, RosElements::RE_COLOR); ! if (colorElem == 0) ! { ! // default to a white material ! GetLog()->Debug() << "(RosImporter) missing color attribute in AppearanceDefinition\n"; ! rgba = RGBA(1.0,1.0,1.0,1.0); ! } ! ! ! if (! ReadRGBA(colorElem, rgba)) ! { ! return false; ! } ! ! shared_ptr<MaterialSolid> material = shared_dynamic_cast<MaterialSolid> ! (GetCore()->New("/kerosin/MaterialSolid")); ! ! if (material.get() == 0) ! { ! return false; ! } ! ! material->SetName(name); ! material->SetDiffuse(rgba); ! ! materialServer->AddChildReference(material); ! GetLog()->Debug() << "(RosImporter) defined SolidMaterial " << name << "\n"; ! ! return true; ! } ! ! bool RosImporter::ReadAmbientLight(TiXmlElement* element) ! { ! RGBA rgba; ! TiXmlElement* colorElem = GetFirstChild(element, RosElements::RE_AMBIENTLIGHTCOLOR); ! if ( ! (colorElem == 0) || ! (! ReadRGBA(colorElem, rgba)) ! ) ! { ! return false; ! } ! ! shared_ptr<RenderServer> renderServer = shared_dynamic_cast<RenderServer> ! (GetCore()->Get("/sys/server/render")); ! ! if (renderServer.get() == 0) ! { ! GetLog()->Error() << "(RosImporter) failed to lookup RenderServer node\n"; ! return false; ! } ! ! renderServer->SetAmbientColor(rgba); ! return true; ! } ! ! bool RosImporter::ReadScene(shared_ptr<BaseNode> root, TiXmlElement* element) ! { ! if (root.get() == 0) ! { ! return false; ! } ! ! GetLog()->Debug() << "(RosImporter) reading scene node\n"; ! ! ReadDefaultAppearance(element); ! ReadGlobalPhsyParams(element); ! ReadAmbientLight(element); ! ! // TODO: ! // Background surface="..." ! // AmbientLightColor r="" g="" b="" ! // GlobalPhysicalParameters gravity="" erp="" cfm="" defaultRollingFrictionCoefficient="" ! // SimulationParameters stepLength="" standardLength="" applyDynamicsForceFactor="" ! ! TiXmlElement* elements = GetFirstChild(element, RosElements::RE_ELEMENTS); ! if (elements == 0) ! { ! // empty scene? ! return true; ! } ! ! return ReadElements(root, elements, NC_ELEMENTS); ! } ! ! bool RosImporter::ReadElements(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) ! { ! GetLog()->Debug() << "(RosImporter) reading elements node\n"; ! ! for ( ! TiXmlNode* node = element->FirstChild(); ! node != 0; ! node = element->IterateChildren(node) ! ) ! { ! TiXmlElement* element = static_cast<TiXmlElement*>(node); ! if (element == 0) ! { ! continue; ! } ! ! bool ok = true; ! ! RosElements::ERosElement type = GetType(element); ! switch (type) ! { ! default: ! GetLog()->Error() << "(RosImporter::ReadElements) ERROR: skipping unknown element " ! << GetXMLPath(element) << "\n"; ! break; ! ! case RosElements::RE_ELEMENTS: ! ok = ReadElements(root,element,context); ! break; ! ! case RosElements::RE_MOVABLE: ! ok = ReadMovable(root,element,context); ! break; ! ! case RosElements::RE_BOX: ! ok = ReadBox(root,element,context); ! break; ! ! case RosElements::RE_SPHERE: ! ok = ReadSphere(root,element,context); ! break; ! ! case RosElements::RE_CYLINDER: ! ok = ReadCylinder(root,element,context); ! break; ! ! case RosElements::RE_CAPPEDCYLINDER: ! ok = ReadCappedCylinder(root,element,context); ! break; ! } ! ! if (! ok) ! { ! return false; ! } ! } ! ! return true; ! } ! ! bool RosImporter::ReadMovable(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) ! { ! GetLog()->Debug() << "(RosImporter) reading moveable node\n"; ! ! context = NC_MOVABLE; ! ! for ( ! TiXmlNode* node = element->FirstChild(); ! node != 0; ! node = element->IterateChildren(node) ! ) ! { ! TiXmlElement* element = static_cast<TiXmlElement*>(node); ! if (element == 0) ! { ! continue; ! } ! ! bool ok = true; ! ! RosElements::ERosElement type = GetType(element); ! switch (type) ! { ! default: ! GetLog()->Error() << "(RosImporter::ReadMovable) ERROR: skipping unknown element " ! << GetXMLPath(element) << "\n"; ! break; ! ! case RosElements::RE_ELEMENTS: ! ok = ReadElements(root,element,context); ! break; ! } ! ! if (! ok) ! { ! return false; ! } ! } ! ! return true; ! } ! ! bool RosImporter::ReadTrans(TiXmlElement* element, Trans& trans) ! { ! TiXmlElement* transElem = GetFirstChild(element,RosElements::RE_TRANSLATION); ! if (transElem != 0) ! { ! if (! ReadVector(transElem, trans.translate)) ! { ! return false; ! } ! } ! ! TiXmlElement* rotElem = GetFirstChild(element,RosElements::RE_ROTATION); ! if (rotElem != 0) ! { ! if (! ReadVector(rotElem, trans.rotate)) ! { ! return false; ! } ! } ! ! return true; ! } ! ! shared_ptr<Transform> RosImporter::CreateTransform(shared_ptr<BaseNode> root, const Trans& trans) ! { ! shared_ptr<Transform> transform = shared_dynamic_cast<Transform> ! (GetCore()->New("/oxygen/Transform")); ! ! transform->SetLocalRotationDeg(trans.rotate); ! transform->SetLocalPos(trans.translate); ! ! root->AddChildReference(transform); ! return transform; ! } ! ! shared_ptr<ContactJointHandler> RosImporter::CreateContactJointHandler() ! { ! shared_ptr<ContactJointHandler> handler = shared_dynamic_cast<ContactJointHandler> ! (GetCore()->New("/oxygen/ContactJointHandler")); ! ! handler->SetContactSoftERPMode(true); ! handler->SetContactSoftERP(mGlobalERP); ! handler->SetContactSoftCFMMode(true); ! handler->SetContactSoftCFM(mGlobalCFM); ! ! return handler; ! } ! ! ! bool RosImporter::ReadGlobalPhsyParams(TiXmlElement* element) ! { ! // prsetset defaults ! mGlobalERP = 0.2; ! mGlobalCFM = 0.0001; ! ! /** TODO: figure out how RoSim interprets the gravity value (a ! single value, not a vector) ! */ ! double gravity = 1.0; ! ! TiXmlElement* physElem = GetFirstChild(element, RosElements::RE_GLOBALPHYSICALPARAMETERS); ! if (physElem == 0) ! { ! return true; ! } ! ! ReadAttribute(physElem, RA_GRAVITY, gravity, true); ! ReadAttribute(physElem, RA_ERP, mGlobalERP, true); ! ReadAttribute(physElem, RA_CFM, mGlobalCFM, true); ! } ! ! bool RosImporter::ReadDefaultAppearance(TiXmlElement* element) ! { ! TiXmlElement* appearElem = GetFirstChild(element,RosElements::RE_DEFAULTAPPEARANCE); ! if (appearElem != 0) ! { ! return ReadAttribute(appearElem, RA_REF, mDefaultAppearance.ref); ! } ! ! // fall back to predefined MaterialServer default material ! mDefaultAppearance.ref = "default"; ! return true; ! } ! ! bool RosImporter::ReadAppearance(TiXmlElement* element, Appearance& appear) ! { ! TiXmlElement* appearElem = GetFirstChild(element,RosElements::RE_APPEARANCE); ! if (appearElem != 0) ! { ! return ReadAttribute(appearElem, RA_REF, appear.ref); ! } ! ! appear = mDefaultAppearance; ! return true; ! } ! ! bool RosImporter::ReadPhysical(TiXmlElement* element, Physical& physical, ENodeContext context) ! { ! if (context != NC_MOVABLE) ! { ! return true; ! } ! ! TiXmlElement* physElem = GetFirstChild(element,RosElements::RE_PHYSICALATTRIBUTES); ! if (physElem == 0) ! { ! GetLog()->Error() << "(RosImporter) ERROR: missing physical attributes in " ! << GetXMLPath(element) << "\n"; ! return false; ! } ! ! ! // we must have a mass ! TiXmlElement* massElem = GetFirstChild(physElem, RosElements::RE_MASS); ! if (massElem == 0) ! { ! GetLog()->Error() << "(RosImporter) ERROR: missing mass element in physical attributes in " ! << GetXMLPath(element) << "\n"; ! return false; ! } ! ! if (! ReadAttribute(massElem, RA_VALUE, physical.mass)) ! { ! return false; ! } ! ! // check for mass center ! TiXmlElement* centerElem = GetFirstChild(physElem,RosElements::RE_CENTEROFMASS); ! if (centerElem != 0) ! { ! ReadVector(centerElem, physical.massCenter); ! } ! ! // TODO: read friction def ! ! return true; ! } ! ! bool RosImporter::ReadCylinder(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) ! { ! string name; ! double radius; ! double height; ! Trans trans; ! Appearance appear; ! Physical physical; ! ! if ( ! (! ReadAttribute(element, RA_NAME, name)) || ! (! ReadAttribute(element, RA_RADIUS, radius)) || ! (! ReadAttribute(element, RA_HEIGHT, height)) || ! (! ReadTrans(element, trans)) || ! (! ReadAppearance(element, appear)) || ! (! ReadPhysical(element, physical, context)) ! ) ! { ! return false; } + //! todo: Cylinder primitive not yet supported + GetLog()->Error() << "(RosImporter) Cylinder primitive not supported\n"; return true; } + bool RosImporter::ReadCappedCylinder(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) + { + string name; + double radius; + double height; + Trans trans; + Appearance appear; + Physical physical; + + if ( + (! ReadAttribute(element, RA_NAME, name)) || + (! ReadAttribute(element, RA_RADIUS, radius)) || + (! ReadAttribute(element, RA_HEIGHT, height)) || + (! ReadTrans(element, trans)) || + (! ReadAppearance(element, appear)) || + (! ReadPhysical(element, physical, context)) + ) + { + return false; + } + + // transform + shared_ptr<Transform> transform = CreateTransform(root, trans); + transform->SetName(name); + + // visual + shared_ptr<CCylinder> ccylinder = shared_dynamic_cast<CCylinder> + (GetCore()->New("/kerosin/CCylinder")); + + transform->AddChildReference(ccylinder); + + ccylinder->SetParams(radius, height); + ccylinder->SetMaterial(appear.ref); + + // add body? + switch (context) + { + case NC_ELEMENTS: + break; + + case NC_MOVABLE: + { + shared_ptr<Body> body = shared_dynamic_cast<Body> + (GetCore()->New("/oxygen/Body")); + + transform->AddChildReference(body); + + body->SetCylinderTotal(physical.mass, radius, height); + //! TODO: set mass center + break; + } + } + + // geometry + shared_ptr<CCylinderCollider> collider = shared_dynamic_cast<CCylinderCollider> + (GetCore()->New("/oxygen/CCylinderCollider")); + + transform->AddChildReference(collider); + collider->SetParams(radius, height); + + // collision handler + shared_ptr<ContactJointHandler> handler = CreateContactJointHandler(); + collider->AddChildReference(handler); + + GetLog()->Debug() << "(RosImporter) created capped cylinder " << name << "\n"; + + return true; + } + + bool RosImporter::ReadSphere(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) + { + string name; + double radius; + Trans trans; + Appearance appear; + Physical physical; + + if ( + (! ReadAttribute(element, RA_NAME, name)) || + (! ReadAttribute(element, RA_RADIUS, radius)) || + (! ReadTrans(element, trans)) || + (! ReadAppearance(element, appear)) || + (! ReadPhysical(element, physical, context)) + ) + { + return false; + } + + // transform + shared_ptr<Transform> transform = CreateTransform(root, trans); + transform->SetName(name); + + // visual + shared_ptr<Sphere> sphere = shared_dynamic_cast<Sphere> + (GetCore()->New("/kerosin/Sphere")); + + transform->AddChildReference(sphere); + + sphere->SetRadius(radius); + sphere->SetMaterial(appear.ref); + + // add body? + switch (context) + { + case NC_ELEMENTS: + break; + + case NC_MOVABLE: + { + shared_ptr<Body> body = shared_dynamic_cast<Body> + (GetCore()->New("/oxygen/Body")); + + transform->AddChildReference(body); + + body->SetSphereTotal(physical.mass, radius); + //! TODO: set mass center + break; + } + } + + // geometry + shared_ptr<SphereCollider> collider = shared_dynamic_cast<SphereCollider> + (GetCore()->New("/oxygen/SphereCollider")); + + transform->AddChildReference(collider); + collider->SetRadius(radius); + + // collision handler + shared_ptr<ContactJointHandler> handler = CreateContactJointHandler(); + collider->AddChildReference(handler); + + GetLog()->Debug() << "(RosImporter) created sphere " << name << "\n"; + + return true; + } + + bool RosImporter::ReadBox(shared_ptr<BaseNode> root, TiXmlElement* element, ENodeContext context) + { + string name; + double length; + double width; + double height; + Trans trans; + Appearance appear; + Physical physical; + + if ( + (! ReadAttribute(element, RA_NAME, name)) || + (! ReadAttribute(element, RA_LENGTH, length)) || + (! ReadAttribute(element, RA_WIDTH, width)) || + (! ReadAttribute(element, RA_HEIGHT, height)) || + (! ReadTrans(element, trans)) || + (! ReadAppearance(element, appear)) || + (! ReadPhysical(element, physical, context)) + ) + { + return false; + } + + // transform + shared_ptr<Transform> transform = CreateTransform(root, trans); + transform->SetName(name); + + // visual + shared_ptr<Box> box = shared_dynamic_cast<Box> + (GetCore()->New("/kerosin/Box")); + + transform->AddChildReference(box); + + Vector3f boxDim = Vector3f(length, width, height); + box->SetExtents(boxDim); + box->SetMaterial(appear.ref); + + // add body? + switch (context) + { + case NC_ELEMENTS: + break; + + case NC_MOVABLE: + { + shared_ptr<Body> body = shared_dynamic_cast<Body> + (GetCore()->New("/oxygen/Body")); + + transform->AddChildReference(body); + + body->SetBoxTotal(physical.mass, boxDim); + //! TODO: set mass center + break; + } + } + + // geometry + shared_ptr<BoxCollider> collider = shared_dynamic_cast<BoxCollider> + (GetCore()->New("/oxygen/BoxCollider")); + + transform->AddChildReference(collider); + collider->SetBoxLengths(boxDim); + + // collision handler + shared_ptr<ContactJointHandler> handler = CreateContactJointHandler(); + collider->AddChildReference(handler); + + GetLog()->Debug() << "(RosImporter) created box " << name << "\n"; + + return true; + } Index: rosimporter.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/rosimporter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rosimporter.h 24 Jan 2006 19:16:32 -0000 1.1 --- rosimporter.h 18 Feb 2006 19:54:57 -0000 1.2 *************** *** 24,33 **** #include <oxygen/sceneserver/sceneimporter.h> - #include <oxygen/sceneserver/basenode.h> #include <tinyxml/tinyxml.h> class RosImporter : public oxygen::SceneImporter { public: RosImporter(); virtual ~RosImporter(); --- 24,88 ---- #include <oxygen/sceneserver/sceneimporter.h> #include <tinyxml/tinyxml.h> + #include "roselements.h" + + namespace oxygen + { + class BaseNode; + class Transform; + class ContactJointHandler; + } + + namespace kerosin + { + class RGBA; + } class RosImporter : public oxygen::SceneImporter { public: + enum ENodeContext + { + /** the node is read within an <Elements> tag, where no + physical bodies are created + */ + NC_ELEMENTS, + + /** the node is read within an <Movable> tag, where + physical bodies are created + */ + NC_MOVABLE + }; + + struct Trans + { + public: + salt::Vector3f translate; + salt::Vector3f rotate; + + public: + Trans() + : translate(0.0, 0.0, 0.0), rotate (0.0, 0.0, 0.0) {} + + }; + + struct Appearance + { + public: + std::string ref; + }; + + struct Physical + { + public: + double mass; + salt::Vector3f massCenter; + + public: + Physical() + : mass(1.0), massCenter(0.0, 0.0, 0.0) {} + }; + + public: RosImporter(); virtual ~RosImporter(); *************** *** 46,55 **** boost::shared_ptr<zeitgeist::ParameterList> parameter); ! TiXmlElement* GetFirstChild(TiXmlNode* node, const std::string& type); ! TiXmlElement* IterateChildren(TiXmlNode* node, const std::string& type); protected: /** the last supplied fileName */ std::string mFileName; }; --- 101,154 ---- boost::shared_ptr<zeitgeist::ParameterList> parameter); ! ! TiXmlElement* GetFirstChild(TiXmlNode* node, RosElements::ERosElement type); ! TiXmlElement* IterateChildren(TiXmlNode* node, RosElements::ERosElement type); ! ! RosElements::ERosElement GetType(const TiXmlElement* element) const; ! std::string GetName(RosElements::ERosElement element) const; ! ! boost::shared_ptr<oxygen::Transform> CreateTransform ! (boost::shared_ptr<oxygen::BaseNode> root, const Trans& trans); ! ! boost::shared_ptr<oxygen::ContactJointHandler> ! RosImporter::CreateContactJointHandler(); ! ! bool ReadAmbientLight(TiXmlElement* element); ! ! bool ReadAttribute(TiXmlElement* element, const std::string& attribute, double& value, bool succeedIfMissing=false); ! bool ReadAttribute(TiXmlElement* element, const std::string& attribute, std::string& value, bool succeedIfMissing=false); ! bool ReadRGBA(TiXmlElement* element, kerosin::RGBA& rgba); ! bool ReadVector(TiXmlElement* element, salt::Vector3f& vec, bool succeedIfMissing = false); ! ! bool ReadAppearenceDef(TiXmlElement* element); ! bool ReadScene(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element); ! bool ReadElements(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); ! bool ReadMovable(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); ! ! bool ReadTrans(TiXmlElement* element, Trans& trans); ! bool ReadDefaultAppearance(TiXmlElement* element); ! bool ReadGlobalPhsyParams(TiXmlElement* element); ! ! bool ReadAppearance(TiXmlElement* element, Appearance& appear); ! bool ReadPhysical(TiXmlElement* element, Physical& physical, ENodeContext context); ! ! bool ReadBox(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); ! bool ReadSphere(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); ! bool ReadCylinder(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); ! bool ReadCappedCylinder(boost::shared_ptr<oxygen::BaseNode> root, TiXmlElement* element, ENodeContext context); protected: /** the last supplied fileName */ std::string mFileName; + + /** the default appearence definition if omitted in a ROS node */ + Appearance mDefaultAppearance; + + /** default global erp value */ + double mGlobalERP; + + /** default global cfm value */ + double mGlobalCFM; + }; |
From: Markus R. <rol...@us...> - 2006-02-18 19:53:10
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16509 Modified Files: Makefile.am Log Message: - added roselements.cpp Index: Makefile.am =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rosimporter/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile.am 24 Jan 2006 19:16:32 -0000 1.1 --- Makefile.am 18 Feb 2006 19:53:06 -0000 1.2 *************** *** 3,6 **** --- 3,7 ---- rosimporter_la_SOURCES =\ export.cpp \ + roselements.cpp\ rosimporter.cpp\ rosimporter.h \ |
From: Markus R. <rol...@us...> - 2006-02-18 19:52:20
|
Update of /cvsroot/simspark/simspark/spark/plugin/rosimporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16039 Added Files: roselements.h roselements.cpp Log Message: - implemented a lookup table for RoSimML XML-Element names --- NEW FILE: roselements.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: roselements.h,v 1.1 2006/02/18 19:52:14 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 ROSELEMENTS_H #define ROSELEMENTS_H #include <map> #include <string> //! RoSim XML Attributes // common #define RA_NAME "name" // AppearanceDefinition #define RA_COLOR "Color" #define RA_R "r" #define RA_G "g" #define RA_B "b" #define RA_A "a" // Vector #define RA_X "x" #define RA_Y "y" #define RA_Z "z" // Box #define RA_LENGTH "length" #define RA_WIDTH "width" #define RA_HEIGHT "height" // Sphere #define RA_RADIUS "radius" // Appearance #define RA_REF "ref" // GlobalPhysicalParameters #define RA_GRAVITY "gravity" #define RA_ERP "erp" #define RA_CFM "cfm" // PhysicalAttributes #define RA_VALUE "value" class RosElements { public: enum ERosElement { RE_INVALID = 0, RE_ROSIINCLUDEFILE, RE_SIMULATION, RE_SCENE, RE_ELEMENTS, RE_MOVABLE, RE_TRANSLATION, RE_ROTATION, RE_BOX, RE_SPHERE, RE_CYLINDER, RE_CAPPEDCYLINDER, RE_GLOBALPHYSICALPARAMETERS, RE_PHYSICALATTRIBUTES, RE_MASS, RE_CENTEROFMASS, RE_APPEARANCEDEFINITION, RE_APPEARANCE, RE_DEFAULTAPPEARANCE, RE_AMBIENTLIGHTCOLOR, RE_COLOR }; typedef std::map<std::string, ERosElement> TElementMap; typedef std::map<ERosElement, std::string> TReverseMap; public: static RosElements& GetInstance(); ~RosElements(); ERosElement Lookup(const std::string& value) const; std::string Lookup(ERosElement element) const; protected: void SetupMap(); private: RosElements(); protected: TElementMap mMap; TReverseMap mReverseMap; }; #endif // ROSELEMENTS_H --- NEW FILE: roselements.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: roselements.cpp,v 1.1 2006/02/18 19:52:14 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 "roselements.h" using namespace std; RosElements::RosElements() { SetupMap(); } RosElements::~RosElements() { } RosElements& RosElements::GetInstance() { static RosElements theInstance; return theInstance; } #define ROS_DEFINE_ELEMENT(_elem, _str)\ mMap[_str] = _elem;\ mReverseMap[_elem] = _str; void RosElements::SetupMap() { mMap.clear(); ROS_DEFINE_ELEMENT(RE_ROSIINCLUDEFILE,"RoSiIncludeFile"); ROS_DEFINE_ELEMENT(RE_SIMULATION,"Simulation"); ROS_DEFINE_ELEMENT(RE_SCENE,"Scene"); ROS_DEFINE_ELEMENT(RE_ELEMENTS,"Elements"); ROS_DEFINE_ELEMENT(RE_MOVABLE,"Movable"); ROS_DEFINE_ELEMENT(RE_TRANSLATION, "Translation"); ROS_DEFINE_ELEMENT(RE_ROTATION, "Rotation"); ROS_DEFINE_ELEMENT(RE_BOX,"Box"); ROS_DEFINE_ELEMENT(RE_SPHERE,"Sphere"); ROS_DEFINE_ELEMENT(RE_CYLINDER,"Cylinder"); ROS_DEFINE_ELEMENT(RE_CAPPEDCYLINDER,"CappedCylinder"); ROS_DEFINE_ELEMENT(RE_GLOBALPHYSICALPARAMETERS,"GlobalPhysicalParameters"); ROS_DEFINE_ELEMENT(RE_PHYSICALATTRIBUTES,"PhysicalAttributes"); ROS_DEFINE_ELEMENT(RE_MASS,"Mass"); ROS_DEFINE_ELEMENT(RE_CENTEROFMASS, "CenterOfMass"); ROS_DEFINE_ELEMENT(RE_APPEARANCEDEFINITION, "AppearanceDefinition"); ROS_DEFINE_ELEMENT(RE_APPEARANCE, "Appearance"); ROS_DEFINE_ELEMENT(RE_DEFAULTAPPEARANCE, "DefaultAppearance"); ROS_DEFINE_ELEMENT(RE_AMBIENTLIGHTCOLOR,"AmbientLightColor"); ROS_DEFINE_ELEMENT(RE_COLOR, "Color"); } string RosElements::Lookup(ERosElement element) const { TReverseMap::const_iterator iter = mReverseMap.find(element); if (iter == mReverseMap.end()) { return ""; } return (*iter).second; } RosElements::ERosElement RosElements::Lookup(const std::string& value) const { TElementMap::const_iterator iter = mMap.find(value); if (iter == mMap.end()) { return RE_INVALID; } return (*iter).second; } |
From: Markus R. <rol...@us...> - 2006-02-18 19:50:10
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15196 Modified Files: property.h property.cpp Log Message: - added properties for ContactJointHandler Index: property.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/property.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** property.cpp 12 Feb 2006 11:39:09 -0000 1.6 --- property.cpp 18 Feb 2006 19:50:03 -0000 1.7 *************** *** 39,43 **** #include <oxygen/physicsserver/contactjointhandler.h> #include <oxygen/physicsserver/dragcontroller.h> ! using namespace std; --- 39,43 ---- #include <oxygen/physicsserver/contactjointhandler.h> #include <oxygen/physicsserver/dragcontroller.h> ! #include <kerosin/materialserver/materialsolid.h> using namespace std; *************** *** 46,49 **** --- 46,50 ---- using namespace zeitgeist; using namespace oxygen; + using namespace kerosin; inline wxString FormatVector3(const Vector3f& vec) *************** *** 83,86 **** --- 84,92 ---- } + inline wxString FormatRGBA(const RGBA& col) + { + return wxString::Format(_T("(%.2f, %.2f, %.2f, %.2f)"),col.r(),col.g(),col.b(),col.a()); + } + #define FORMAT_FLAG(_i, _flag)\ wxString((_i & _flag) ? #_flag" " : "") *************** *** 105,108 **** --- 111,115 ---- mClassMap[_T("/classes/oxygen/ContactJointHandler")] = CL_CONTACTJOINTHANDLER; mClassMap[_T("/classes/oxygen/DragController")] = CL_DRAGCONTROLLER; + mClassMap[_T("/classes/kerosin/MaterialSolid")] = CL_MATERIALSOLID; } *************** *** 173,176 **** --- 180,191 ---- } + void Property::GenSolidMaterialProperty(shared_ptr<Leaf> leaf, TEntryList& entries) const + { + const MaterialSolid& mat = *shared_static_cast<MaterialSolid>(leaf); + entries.push_back(Entry(_T("GetAmbient"),FormatRGBA(mat.GetAmbient()))); + entries.push_back(Entry(_T("GetDiffuse"),FormatRGBA(mat.GetDiffuse()))); + entries.push_back(Entry(_T("GetSpecular"),FormatRGBA(mat.GetSpecular()))); + } + void Property::GenJointEntries(shared_ptr<Leaf> leaf, TEntryList& entries) const { *************** *** 374,377 **** --- 389,396 ---- GenDragControllerEntries(leaf, entries); break; + + case CL_MATERIALSOLID: + GenSolidMaterialProperty(leaf, entries); + break; } } Index: property.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/property.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** property.h 12 Feb 2006 11:19:25 -0000 1.4 --- property.h 18 Feb 2006 19:50:03 -0000 1.5 *************** *** 46,50 **** CL_COLLISIONHANDLER, CL_CONTACTJOINTHANDLER, ! CL_DRAGCONTROLLER }; --- 46,51 ---- CL_COLLISIONHANDLER, CL_CONTACTJOINTHANDLER, ! CL_DRAGCONTROLLER, ! CL_MATERIALSOLID }; *************** *** 86,90 **** void GenContactJointEntries(boost::shared_ptr<zeitgeist::Leaf> leaf, TEntryList& entries) const; void GenDragControllerEntries(boost::shared_ptr<zeitgeist::Leaf> leaf, TEntryList& entries) const; ! void GetClassList(boost::shared_ptr<zeitgeist::Class> cl, TClassList& clList) const; --- 87,91 ---- void GenContactJointEntries(boost::shared_ptr<zeitgeist::Leaf> leaf, TEntryList& entries) const; void GenDragControllerEntries(boost::shared_ptr<zeitgeist::Leaf> leaf, TEntryList& entries) const; ! void GenSolidMaterialProperty(boost::shared_ptr<zeitgeist::Leaf> leaf, TEntryList& entries) const; void GetClassList(boost::shared_ptr<zeitgeist::Class> cl, TClassList& clList) const; |
From: Markus R. <rol...@us...> - 2006-02-18 19:48:12
|
Update of /cvsroot/simspark/simspark/spark/oxygen/sceneserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14374 Modified Files: transform.h transform.cpp transform_c.cpp Log Message: - renamed SetLocalRotation() to SetLocalRotationDeg() - added method SetLocalRotationRad() Index: transform.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/sceneserver/transform.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** transform.cpp 5 Dec 2005 21:21:17 -0000 1.1 --- transform.cpp 18 Feb 2006 19:48:06 -0000 1.2 *************** *** 98,102 **** } ! void Transform::SetLocalRotation(const salt::Vector3f &rot) { mChangedMark = SceneServer::GetTransformMark(); --- 98,102 ---- } ! void Transform::SetLocalRotationRad(const salt::Vector3f &rot) { mChangedMark = SceneServer::GetTransformMark(); *************** *** 104,110 **** Vector3f pos = mLocalTransform.Pos(); ! mLocalTransform.RotationX(gDegToRad(rot[0])); ! mLocalTransform.RotateY(gDegToRad(rot[1])); ! mLocalTransform.RotateZ(gDegToRad(rot[2])); mLocalTransform.Pos() = pos; --- 104,110 ---- Vector3f pos = mLocalTransform.Pos(); ! mLocalTransform.RotationX(rot[0]); ! mLocalTransform.RotateY(rot[1]); ! mLocalTransform.RotateZ(rot[2]); mLocalTransform.Pos() = pos; *************** *** 112,115 **** --- 112,125 ---- } + void Transform::SetLocalRotationDeg(const salt::Vector3f &rot) + { + SetLocalRotationRad(Vector3f( + gDegToRad(rot[0]), + gDegToRad(rot[1]), + gDegToRad(rot[2]) + ) + ); + } + void Transform::OnLink() { Index: transform_c.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/sceneserver/transform_c.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** transform_c.cpp 5 Dec 2005 21:21:17 -0000 1.1 --- transform_c.cpp 18 Feb 2006 19:48:06 -0000 1.2 *************** *** 56,60 **** } ! obj->SetLocalRotation(inRot); return true; } --- 56,60 ---- } ! obj->SetLocalRotationDeg(inRot); return true; } Index: transform.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/sceneserver/transform.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** transform.h 5 Dec 2005 21:21:17 -0000 1.1 --- transform.h 18 Feb 2006 19:48:06 -0000 1.2 *************** *** 71,76 **** void SetLocalPos(const salt::Vector3f &pos); /** sets the local rotation of this node in degrees */ ! void SetLocalRotation(const salt::Vector3f &rot); /** returns the current transform mark */ --- 71,79 ---- void SetLocalPos(const salt::Vector3f &pos); + /** sets the local rotation of this node in rad */ + void SetLocalRotationRad(const salt::Vector3f &rot); + /** sets the local rotation of this node in degrees */ ! void SetLocalRotationDeg(const salt::Vector3f &rot); /** returns the current transform mark */ |
From: Markus R. <rol...@us...> - 2006-02-18 19:46:58
|
Update of /cvsroot/simspark/simspark/spark/oxygen/sceneserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14011 Modified Files: sceneserver.cpp Log Message: - added some debug messages to ImportScene() Index: sceneserver.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/sceneserver/sceneserver.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sceneserver.cpp 5 Dec 2005 21:21:17 -0000 1.1 --- sceneserver.cpp 18 Feb 2006 19:46:54 -0000 1.2 *************** *** 200,203 **** --- 200,213 ---- } + if (root.get() == 0) + { + GetLog()->Error() + << "(SceneServer) ERROR: NULL node given as ImportScene " + << "root node, fileName was " << fileName << "\n"; + } + + GetLog()->Debug() << "(SceneServer) ImportScene fileName=" << fileName + << " root=" << root->GetFullPath() << "\n"; + TLeafList importer; ListChildrenSupportingClass<SceneImporter>(importer); *************** *** 218,221 **** --- 228,234 ---- shared_static_cast<SceneImporter>(*iter); + GetLog()->Debug() + << "(SceneServer) trying importer " << importer->GetName() << std::endl; + if (importer->ImportScene(fileName,root,parameter)) { |
From: Markus R. <rol...@us...> - 2006-02-18 19:43:16
|
Update of /cvsroot/simspark/simspark/spark/kerosin/renderserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12214/renderserver Modified Files: renderserver.h renderserver.cpp Log Message: - added member mAmbientColor - added function SetAmbientColor - made the OpenGL clear color configurable Index: renderserver.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/renderserver/renderserver.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** renderserver.h 5 Dec 2005 21:38:23 -0000 1.1 --- renderserver.h 18 Feb 2006 19:43:13 -0000 1.2 *************** *** 42,45 **** --- 42,46 ---- #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> + #include <kerosin/openglserver/glbase.h> namespace oxygen *************** *** 73,76 **** --- 74,80 ---- TLeafList& visibleMeshes); + /** sets the ambient color of the scene */ + void SetAmbientColor(const RGBA& ambient); + protected: /** get the active scene node from the sceneServer */ *************** *** 106,109 **** --- 110,114 ---- unsigned int mAmbientVP; + RGBA mAmbientColor; }; Index: renderserver.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/renderserver/renderserver.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** renderserver.cpp 5 Dec 2005 21:38:23 -0000 1.1 --- renderserver.cpp 18 Feb 2006 19:43:13 -0000 1.2 *************** *** 38,41 **** --- 38,42 ---- RenderServer::RenderServer() : Leaf() { + mAmbientColor = RGBA(0.0,0.0,0.0,0.0); } *************** *** 199,203 **** } ! glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glColor3f(1,1,1); --- 200,210 ---- } ! glClearColor( ! mAmbientColor.r(), ! mAmbientColor.g(), ! mAmbientColor.b(), ! mAmbientColor.a() ! ); ! glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glColor3f(1,1,1); *************** *** 333,334 **** --- 340,346 ---- glMultMatrixf(camera->GetViewTransform().m); } + + void RenderServer::SetAmbientColor(const RGBA& ambient) + { + mAmbientColor = ambient; + } |
From: Markus R. <rol...@us...> - 2006-02-18 19:41:54
|
Update of /cvsroot/simspark/simspark/spark/kerosin/materialserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11891/materialserver Modified Files: materialsolid.h materialsolid.cpp Log Message: - const correctness Index: materialsolid.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/materialserver/materialsolid.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** materialsolid.cpp 5 Dec 2005 21:38:22 -0000 1.1 --- materialsolid.cpp 18 Feb 2006 19:41:48 -0000 1.2 *************** *** 70,74 **** } ! const RGBA& MaterialSolid::GetAmbient() { return mAmbient; --- 70,74 ---- } ! const RGBA& MaterialSolid::GetAmbient() const { return mAmbient; *************** *** 80,84 **** } ! const RGBA& MaterialSolid::GetDiffuse() { return mDiffuse; --- 80,84 ---- } ! const RGBA& MaterialSolid::GetDiffuse() const { return mDiffuse; *************** *** 90,94 **** } ! const RGBA& MaterialSolid::GetSpecular() { return mSpecular; --- 90,94 ---- } ! const RGBA& MaterialSolid::GetSpecular() const { return mSpecular; *************** *** 100,104 **** } ! const RGBA& MaterialSolid::GetEmission() { return mEmission; --- 100,104 ---- } ! const RGBA& MaterialSolid::GetEmission() const { return mEmission; Index: materialsolid.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/materialserver/materialsolid.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** materialsolid.h 5 Dec 2005 21:38:22 -0000 1.1 --- materialsolid.h 18 Feb 2006 19:41:48 -0000 1.2 *************** *** 44,48 **** /** returns the ambient material reflectance */ ! const RGBA& GetAmbient(); /** sets the diffuse material reflectance */ --- 44,48 ---- /** returns the ambient material reflectance */ ! const RGBA& GetAmbient() const; /** sets the diffuse material reflectance */ *************** *** 50,54 **** /** returns the diffuse material reflectancee */ ! const RGBA& GetDiffuse(); /** sets the specular material reflectance */ --- 50,54 ---- /** returns the diffuse material reflectancee */ ! const RGBA& GetDiffuse() const; /** sets the specular material reflectance */ *************** *** 56,60 **** /** returns the specular material reflectance */ ! const RGBA& GetSpecular(); /** sets the light emission */ --- 56,60 ---- /** returns the specular material reflectance */ ! const RGBA& GetSpecular() const; /** sets the light emission */ *************** *** 62,66 **** /** returns the light emission */ ! const RGBA& GetEmission(); protected: --- 62,66 ---- /** returns the light emission */ ! const RGBA& GetEmission() const; protected: |
From: Markus R. <rol...@us...> - 2006-02-18 19:41:05
|
Update of /cvsroot/simspark/simspark/spark/kerosin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11550 Modified Files: Makefile.am Log Message: - added openglserver/glbase.h to the list of installed headers Index: Makefile.am =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.am 25 Dec 2005 19:22:06 -0000 1.4 --- Makefile.am 18 Feb 2006 19:40:58 -0000 1.5 *************** *** 145,148 **** --- 145,149 ---- textureserver/textureserver.h \ openglserver/openglserver.h \ + openglserver/glbase.h \ renderserver/renderserver.h \ renderserver/rendernode.h \ |
From: Markus R. <rol...@us...> - 2006-02-18 19:34:08
|
Update of /cvsroot/simspark/simspark/spark/utility/tinyxml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8455 Modified Files: Makefile.am Added Files: xmlfunctions.cpp xmlfunctions.h Log Message: - implemented some support functions for the tinyXML parser --- NEW FILE: xmlfunctions.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: xmlfunctions.h,v 1.1 2006/02/18 19:33:59 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 XMLFUNCTIONS_H #define XMLFUNCTIONS_H #include <string> class TiXmlElement; class TiXmlNode; extern void SetXMLAttribute(TiXmlElement& element, const std::string& name, const std::string& value); extern void SetXMLAttribute(TiXmlElement& element, const std::string& name, int value); extern void SetXMLDoubleAttribute(TiXmlElement& element, const std::string& name, double value); extern bool GetXMLAttribute(const TiXmlElement* element, const std::string& attrName, std::string& str); extern bool GetXMLAttribute(const TiXmlElement* element, const std::string& attrName, int& i); extern bool GetXMLAttribute(const TiXmlElement* element, const std::string& attrName, double& d); extern bool GetXMLAttribute(const TiXmlElement* element, const std::string& attrName, float& f); extern std::string GetXMLValue(const TiXmlNode* node); extern TiXmlElement* GetFirstChild(TiXmlNode* node, const std::string& type); extern TiXmlElement* IterateChildren(TiXmlNode* node, const std::string& type); extern std::string GetXMLPath(TiXmlNode* node); #endif // XMLFUNCTIONS_H Index: Makefile.am =================================================================== RCS file: /cvsroot/simspark/simspark/spark/utility/tinyxml/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile.am 24 Jan 2006 19:14:54 -0000 1.1 --- Makefile.am 18 Feb 2006 19:33:59 -0000 1.2 *************** *** 5,9 **** tinyxml.cpp\ tinyxmlerror.cpp\ ! tinyxmlparser.cpp --- 5,11 ---- tinyxml.cpp\ tinyxmlerror.cpp\ ! tinyxmlparser.cpp\ ! xmlfunctions.cpp ! --- NEW FILE: xmlfunctions.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: xmlfunctions.cpp,v 1.1 2006/02/18 19:33:59 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 "xmlfunctions.h" #include "tinyxml.h" using namespace std; extern void SetXMLAttribute(TiXmlElement& element, const string& name, const string& value) { element.SetAttribute(name.c_str(), value.c_str()); } extern void SetXMLAttribute(TiXmlElement& element, const string& name, int value) { element.SetAttribute(name.c_str(), value); } extern void SetXMLDoubleAttribute(TiXmlElement& element, const string& name, double value) { element.SetDoubleAttribute(name.c_str(),value); } extern bool GetXMLAttribute(const TiXmlElement* element, const string& attrName, string& str) { const char* attr = element->Attribute(attrName.c_str()); if (attr == 0) { return false; } str = attr; return true; } extern bool GetXMLAttribute(const TiXmlElement* element, const string& attrName, int& i) { const char* attr = element->Attribute(attrName.c_str(),&i); if (attr == 0) { return false; } return true; } extern bool GetXMLAttribute(const TiXmlElement* element, const std::string& attrName, float& f) { double d; bool ok = GetXMLAttribute(element, attrName, d); f = d; return ok; } extern bool GetXMLAttribute(const TiXmlElement* element, const string& attrName, double& d) { const char* attr = element->Attribute(attrName.c_str(),&d); if (attr == 0) { return false; } return true; } extern string GetXMLValue(const TiXmlNode* node) { if (node == 0) { return ""; } return node->Value(); } extern TiXmlElement* GetFirstChild(TiXmlNode* node, const string& type) { TiXmlNode* childNode = node->FirstChild(type.c_str()); if ( (childNode == 0) || (childNode->Type() != TiXmlNode::ELEMENT) ) { return 0; } return static_cast<TiXmlElement*>(childNode); } extern TiXmlElement* IterateChildren(TiXmlNode* node, const string& type) { TiXmlNode* childNode = node->Parent()->IterateChildren(type.c_str(),node); if ( (childNode == 0) || (childNode->Type() != TiXmlNode::ELEMENT) ) { return 0; } return static_cast<TiXmlElement*>(childNode); } extern string GetXMLPath(TiXmlNode* node) { if (node == 0) { return ""; } return GetXMLPath(node->Parent()) + "/" + node->Value(); } |
From: Markus R. <rol...@us...> - 2006-02-15 01:08:28
|
Update of /cvsroot/simspark/simspark/spark/spark In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13421 Modified Files: spark.rb Log Message: - fixed a typo Index: spark.rb =================================================================== RCS file: /cvsroot/simspark/simspark/spark/spark/spark.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** spark.rb 24 Jan 2006 19:31:11 -0000 1.4 --- spark.rb 15 Feb 2006 01:08:19 -0000 1.5 *************** *** 320,324 **** # use the ros scene importer to import scenes ! importeBundle 'rosimporter' sceneServer.initSceneImporter("RosImporter"); --- 320,324 ---- # use the ros scene importer to import scenes ! importBundle 'rosimporter' sceneServer.initSceneImporter("RosImporter"); |