From 704385ff0addfc53d4182ea13141c39e695e1932 Mon Sep 17 00:00:00 2001 From: frohlich Date: Sat, 6 Jun 2009 08:07:20 +0000 Subject: [PATCH] Replace SGPlacementTrans usage with osg::PositionAttitueTransform. Remove SGPlacementTrans. Update build system. Modified Files: SimGear.dsp projects/VC7.1/SimGear.vcproj projects/VC8/SimGear.vcproj simgear/scene/model/Makefile.am simgear/scene/model/placement.cxx simgear/scene/model/placement.hxx simgear/scene/tgdb/TileEntry.cxx simgear/scene/tgdb/TileEntry.hxx Removed Files: simgear/scene/model/placementtrans.cxx simgear/scene/model/placementtrans.hxx --- SimGear.dsp | 15 --- projects/VC7.1/SimGear.vcproj | 6 - projects/VC8/SimGear.vcproj | 8 -- simgear/scene/model/Makefile.am | 2 - simgear/scene/model/placement.cxx | 12 +- simgear/scene/model/placement.hxx | 8 +- simgear/scene/model/placementtrans.cxx | 148 ------------------------- simgear/scene/model/placementtrans.hxx | 74 ------------- simgear/scene/tgdb/TileEntry.cxx | 1 - simgear/scene/tgdb/TileEntry.hxx | 1 - 10 files changed, 8 insertions(+), 267 deletions(-) delete mode 100644 simgear/scene/model/placementtrans.cxx delete mode 100644 simgear/scene/model/placementtrans.hxx diff --git a/SimGear.dsp b/SimGear.dsp index 9864af72..e79cc932 100644 --- a/SimGear.dsp +++ b/SimGear.dsp @@ -1334,21 +1334,6 @@ SOURCE=.\simgear\scene\model\placement.cxx # End Source File # Begin Source File -SOURCE=.\simgear\scene\model\placementtrans.cxx - -!IF "$(CFG)" == "SimGear - Win32 Release" - -# PROP Intermediate_Dir "Release\Lib_sgmodel" - -!ELSEIF "$(CFG)" == "SimGear - Win32 Debug" - -# PROP Intermediate_Dir "Debug\Lib_sgmodel" - -!ENDIF - -# End Source File -# Begin Source File - SOURCE=.\simgear\scene\model\shadanim.cxx !IF "$(CFG)" == "SimGear - Win32 Release" diff --git a/projects/VC7.1/SimGear.vcproj b/projects/VC7.1/SimGear.vcproj index 2ee3c73c..ae791bd2 100755 --- a/projects/VC7.1/SimGear.vcproj +++ b/projects/VC7.1/SimGear.vcproj @@ -719,12 +719,6 @@ - - - - diff --git a/projects/VC8/SimGear.vcproj b/projects/VC8/SimGear.vcproj index 5e159dc8..3c597466 100755 --- a/projects/VC8/SimGear.vcproj +++ b/projects/VC8/SimGear.vcproj @@ -391,10 +391,6 @@ RelativePath="..\..\simgear\scene\model\placement.hxx" > - - @@ -1047,10 +1043,6 @@ RelativePath="..\..\simgear\scene\model\placement.cxx" > - - diff --git a/simgear/scene/model/Makefile.am b/simgear/scene/model/Makefile.am index 82108d5a..3bf59ff0 100644 --- a/simgear/scene/model/Makefile.am +++ b/simgear/scene/model/Makefile.am @@ -12,7 +12,6 @@ include_HEADERS = \ ModelRegistry.hxx \ persparam.hxx \ placement.hxx \ - placementtrans.hxx \ CheckSceneryVisitor.hxx \ SGClipGroup.hxx \ SGMaterialAnimation.hxx \ @@ -32,7 +31,6 @@ libsgmodel_a_SOURCES = \ ModelRegistry.cxx \ persparam.cxx \ placement.cxx \ - placementtrans.cxx \ shadanim.cxx \ CheckSceneryVisitor.cxx \ SGClipGroup.cxx \ diff --git a/simgear/scene/model/placement.cxx b/simgear/scene/model/placement.cxx index 9da016ef..486113d8 100644 --- a/simgear/scene/model/placement.cxx +++ b/simgear/scene/model/placement.cxx @@ -7,13 +7,10 @@ #include #endif -#include - -#include -#include - #include "placement.hxx" +#include +#include //////////////////////////////////////////////////////////////////////// @@ -26,7 +23,7 @@ SGModelPlacement::SGModelPlacement () : _pitch_deg(0), _heading_deg(0), _selector(new osg::Switch), - _transform(new SGPlacementTransform) + _transform(new osg::PositionAttitudeTransform) { } @@ -49,6 +46,7 @@ SGModelPlacement::update() { // The cartesian position SGVec3d position = SGVec3d::fromGeod(_position); + _transform->setPosition(position.osg()); // The orientation, composed from the horizontal local orientation and the // orientation wrt the horizontal local frame @@ -58,7 +56,7 @@ SGModelPlacement::update() // the y axis 180 degrees. orient *= SGQuatd::fromRealImag(0, SGVec3d(0, 1, 0)); - _transform->setTransform(position, orient); + _transform->setAttitude(orient.osg()); } bool diff --git a/simgear/scene/model/placement.hxx b/simgear/scene/model/placement.hxx index 9a723660..97d5cda5 100644 --- a/simgear/scene/model/placement.hxx +++ b/simgear/scene/model/placement.hxx @@ -14,10 +14,9 @@ #include #include #include +#include -#include - -#include "placementtrans.hxx" +#include // Has anyone done anything *really* stupid, like making min and max macros? #ifdef min @@ -78,7 +77,6 @@ public: void setBodyAngularVelocity(const SGVec3d& velocity); private: - // Geodetic position SGGeod _position; @@ -88,7 +86,7 @@ private: double _heading_deg; osg::ref_ptr _selector; - osg::ref_ptr _transform; + osg::ref_ptr _transform; }; #endif // _SG_PLACEMENT_HXX diff --git a/simgear/scene/model/placementtrans.cxx b/simgear/scene/model/placementtrans.cxx deleted file mode 100644 index 14d8491b..00000000 --- a/simgear/scene/model/placementtrans.cxx +++ /dev/null @@ -1,148 +0,0 @@ -// placementtrans.hxx -- class for carrying transforms for placing models in the world -// -// Written by Mathias Froehlich, started April 2005. -// -// Copyright (C) 2005 Mathias Froehlich -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifndef __cplusplus -# error This library requires C++ -#endif - -#include -#include -#include - -#include -#include - -#include "placementtrans.hxx" - -SGPlacementTransform::SGPlacementTransform(void) : - _placement_offset(0, 0, 0), - _rotation(SGQuatd::unit()) -{ -} - -SGPlacementTransform::SGPlacementTransform(const SGPlacementTransform& trans, - const osg::CopyOp& copyop): - osg::Transform(trans, copyop), - _placement_offset(trans._placement_offset), - _rotation(trans._rotation) -{ - -} - -SGPlacementTransform::~SGPlacementTransform(void) -{ -} - -bool -SGPlacementTransform::computeLocalToWorldMatrix(osg::Matrix& matrix, - osg::NodeVisitor*) const -{ - if (_referenceFrame == RELATIVE_RF) { - matrix.preMultTranslate(_placement_offset.osg()); - matrix.preMultRotate(_rotation.osg()); - } else { - matrix.makeRotate(_rotation.osg()); - matrix.postMultTranslate(_placement_offset.osg()); - } - return true; -} - -bool -SGPlacementTransform::computeWorldToLocalMatrix(osg::Matrix& matrix, - osg::NodeVisitor*) const -{ - if (_referenceFrame == RELATIVE_RF) { - matrix.postMultTranslate(-_placement_offset.osg()); - matrix.postMultRotate(inverse(_rotation).osg()); - } else { - matrix.makeRotate(inverse(_rotation).osg()); - matrix.preMultTranslate(-_placement_offset.osg()); - } - return true; -} - -// Functions to read / write SGPlacementTrans from / to a .osg file, -// mostly for debugging purposes. - -namespace { - -bool PlacementTrans_readLocalData(osg::Object& obj, osgDB::Input& fr) -{ - SGPlacementTransform& trans = static_cast(obj); - SGQuatd rotation = SGQuatd::unit(); - SGVec3d placementOffset(0, 0, 0); - - if (fr[0].matchWord("rotation")) { - ++fr; - osg::Vec4d vec4; - if (fr.readSequence(vec4)) { - rotation = SGQuatd(vec4[0], vec4[1], vec4[2], vec4[3]); - fr += 4; - } else - return false; - } - if (fr[0].matchWord("placement")) { - ++fr; - if (fr.readSequence(placementOffset.osg())) - fr += 3; - else - return false; - } - trans.setTransform(placementOffset, rotation); - return true; -} - -bool PlacementTrans_writeLocalData(const osg::Object& obj, osgDB::Output& fw) -{ - const SGPlacementTransform& trans - = static_cast(obj); - const SGQuatd& rotation = trans.getRotation(); - const SGVec3d& placement = trans.getGlobalPos(); - - fw.indent() << "rotation "; - for (int i = 0; i < 4; i++) { - fw << rotation(i) << " "; - } - fw << std::endl; - int prec = fw.precision(); - fw.precision(15); - fw.indent() << "placement "; - for (int i = 0; i < 3; i++) { - fw << placement(i) << " "; - } - fw << std::endl; - fw.precision(prec); - return true; -} -} - -osgDB::RegisterDotOsgWrapperProxy g_SGPlacementTransProxy -( - new SGPlacementTransform, - "SGPlacementTransform", - "Object Node Transform SGPlacementTransform Group", - &PlacementTrans_readLocalData, - &PlacementTrans_writeLocalData -); diff --git a/simgear/scene/model/placementtrans.hxx b/simgear/scene/model/placementtrans.hxx deleted file mode 100644 index b4489bb7..00000000 --- a/simgear/scene/model/placementtrans.hxx +++ /dev/null @@ -1,74 +0,0 @@ -// placementtrans.hxx -- class for carrying transforms for placing models in the world -// -// Written by Mathias Froehlich, started April 2005. -// -// Copyright (C) 2005 Mathias Froehlich -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// - - -#ifndef _SG_PLACEMENTTRANS_HXX -#define _SG_PLACEMENTTRANS_HXX - -#ifndef __cplusplus -# error This library requires C++ -#endif - -#include -#include -#include - -#include - -class SGPlacementTransform : public osg::Transform -{ -public: - - SGPlacementTransform(void); - SGPlacementTransform(const SGPlacementTransform&, - const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); - - META_Node(simgear, SGPlacementTransform); - - void setTransform(const SGVec3d& off) - { _placement_offset = off; dirtyBound(); } - void setTransform(const SGVec3d& off, const SGQuatd& rot) - { _placement_offset = off; _rotation = rot; dirtyBound(); } - - const SGVec3d& getGlobalPos() const - { return _placement_offset; } - const SGQuatd& getRotation() const - { return _rotation; } - - virtual bool computeLocalToWorldMatrix(osg::Matrix&,osg::NodeVisitor*) const; - virtual bool computeWorldToLocalMatrix(osg::Matrix&,osg::NodeVisitor*) const; - -protected: - virtual ~SGPlacementTransform(void); - -private: - - class UpdateCallback; - - ////////////////////////////////////////////////////////////////// - // private data // - ////////////////////////////////////////////////////////////////// - - SGVec3d _placement_offset; - SGQuatd _rotation; -}; - -#endif // _SG_LOCATION_HXX diff --git a/simgear/scene/tgdb/TileEntry.cxx b/simgear/scene/tgdb/TileEntry.cxx index 772c6704..0a33e326 100644 --- a/simgear/scene/tgdb/TileEntry.cxx +++ b/simgear/scene/tgdb/TileEntry.cxx @@ -55,7 +55,6 @@ #include #include #include -#include #include "ReaderWriterSTG.hxx" #include "TileEntry.hxx" diff --git a/simgear/scene/tgdb/TileEntry.hxx b/simgear/scene/tgdb/TileEntry.hxx index d12fa920..287a9513 100644 --- a/simgear/scene/tgdb/TileEntry.hxx +++ b/simgear/scene/tgdb/TileEntry.hxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include -- 2.39.5