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
This commit is contained in:
frohlich 2009-06-06 08:07:20 +00:00 committed by Tim Moore
parent 81a657edec
commit 704385ff0a
10 changed files with 8 additions and 267 deletions

View File

@ -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"

View File

@ -719,12 +719,6 @@
<File
RelativePath="..\..\simgear\scene\model\placement.hxx">
</File>
<File
RelativePath="..\..\simgear\scene\model\placementtrans.cxx">
</File>
<File
RelativePath="..\..\simgear\scene\model\placementtrans.hxx">
</File>
<File
RelativePath="..\..\simgear\scene\model\SGClipGroup.cxx">
</File>

View File

@ -391,10 +391,6 @@
RelativePath="..\..\simgear\scene\model\placement.hxx"
>
</File>
<File
RelativePath="..\..\simgear\scene\model\placementtrans.hxx"
>
</File>
<File
RelativePath="..\..\simgear\ephemeris\pluto.hxx"
>
@ -1047,10 +1043,6 @@
RelativePath="..\..\simgear\scene\model\placement.cxx"
>
</File>
<File
RelativePath="..\..\simgear\scene\model\placementtrans.cxx"
>
</File>
<File
RelativePath="..\..\simgear\props\props.cxx"
>

View File

@ -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 \

View File

@ -7,13 +7,10 @@
#include <simgear_config.h>
#endif
#include <simgear/compiler.h>
#include <simgear/scene/util/SGSceneUserData.hxx>
#include <simgear/scene/util/SGUpdateVisitor.hxx>
#include "placement.hxx"
#include <simgear/compiler.h>
#include <simgear/scene/util/SGSceneUserData.hxx>
////////////////////////////////////////////////////////////////////////
@ -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

View File

@ -14,10 +14,9 @@
#include <osg/ref_ptr>
#include <osg/Node>
#include <osg/Switch>
#include <osg/PositionAttitudeTransform>
#include <simgear/props/props.hxx>
#include "placementtrans.hxx"
#include <simgear/math/SGMath.hxx>
// 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<osg::Switch> _selector;
osg::ref_ptr<SGPlacementTransform> _transform;
osg::ref_ptr<osg::PositionAttitudeTransform> _transform;
};
#endif // _SG_PLACEMENT_HXX

View File

@ -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 <simgear_config.h>
#endif
#ifndef __cplusplus
# error This library requires C++
#endif
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
#include <simgear/compiler.h>
#include <simgear/constants.h>
#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<SGPlacementTransform&>(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<const SGPlacementTransform&>(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
);

View File

@ -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 <simgear/compiler.h>
#include <simgear/constants.h>
#include <simgear/math/SGMath.hxx>
#include <osg/Transform>
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

View File

@ -55,7 +55,6 @@
#include <simgear/scene/tgdb/apt_signs.hxx>
#include <simgear/scene/tgdb/obj.hxx>
#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
#include <simgear/scene/model/placementtrans.hxx>
#include "ReaderWriterSTG.hxx"
#include "TileEntry.hxx"

View File

@ -37,7 +37,6 @@
#include <simgear/bucket/newbucket.hxx>
#include <simgear/math/point3d.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/scene/model/placementtrans.hxx>
#include <osg/ref_ptr>
#include <osgDB/ReaderWriter>