Added shells for DOFTransform and PositionAttitudeTransform to the .osg

loader, still need to fill in the saving and loading of paramters.

Went through the distribution remove old API usage.
This commit is contained in:
Robert Osfield
2002-08-06 17:07:05 +00:00
parent ffb2d3826b
commit e01f9eb891
15 changed files with 130 additions and 33 deletions

View File

@@ -130,6 +130,10 @@ SOURCE=..\..\..\src\osgPlugins\osg\Drawable.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\osg\DOFTransforms.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\osg\EarthSky.cpp
# End Source File
# Begin Source File
@@ -222,6 +226,10 @@ SOURCE=..\..\..\src\osgPlugins\osg\PolygonOffset.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\osg\PositionAttitudeTransform.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgPlugins\osg\Projection.cpp
# End Source File
# Begin Source File

View File

@@ -11,7 +11,7 @@
namespace osg{
/** DOFTransform - encapsulates Multigen DOF behavior*/
class SG_EXPORT DOFTransform : public MatrixTransform
class SG_EXPORT DOFTransform : public Transform
{
public:
/** constructor*/
@@ -19,7 +19,7 @@ class SG_EXPORT DOFTransform : public MatrixTransform
/**copy constructor*/
DOFTransform(const DOFTransform& dof, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
MatrixTransform(dof, copyop),
Transform(dof, copyop),
_minHPR(dof._minHPR),
_maxHPR(dof._maxHPR),
_currentHPR(dof._currentHPR),

View File

@@ -65,7 +65,7 @@ osg::Node* decorate_with_clip_node(osg::Node* subgraph)
//osg::Material* material = new osg::Material;
osg::PolygonMode* polymode = new osg::PolygonMode;
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE_ON);
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
osg::Group* wireframe_subgraph = osgNew osg::Group;
wireframe_subgraph->setStateSet(stateset);

View File

@@ -315,7 +315,7 @@ int main( int argc, char **argv )
osg::StateSet* dstate = new osg::StateSet;
dstate->setRenderBinDetails(4,"RenderBin");
dstate->setMode(GL_CULL_FACE,osg::StateAttribute::OVERRIDE_OFF);
dstate->setMode(GL_CULL_FACE,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
dstate->setAttributeAndModes(stencil,osg::StateAttribute::ON);
dstate->setAttributeAndModes(clipplane,osg::StateAttribute::ON);

View File

@@ -114,11 +114,11 @@ int main( int argc, char **argv )
polyoffset->setUnits(-1.0f);
osg::PolygonMode* polymode = new osg::PolygonMode;
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE_ON);
stateset->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE_ON);
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE_ON);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE_OFF);
stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE_OFF);
stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
// osg::LineStipple* linestipple = new osg::LineStipple;
// linestipple->setFactor(1);

View File

@@ -2,7 +2,7 @@
#include <osg/Group>
#include <osg/Sequence>
#include <osg/Transform>
#include <osg/MatrixTransform>
#include <osgDB/ReadFile>
@@ -173,7 +173,7 @@ int main( int argc, char **argv )
osg::Matrix matrix;
matrix.makeTranslate(x, 0.0, 0.0);
osg::Transform* xform = osgNew osg::Transform;
osg::MatrixTransform* xform = osgNew osg::MatrixTransform;
xform->setMatrix(matrix);
xform->addChild(seqNode);

View File

@@ -15,9 +15,9 @@ void StateSetManipulator::setStateSet(StateSet *drawState)
{
_drawState=drawState;
if(!_drawState.valid()) return;
_backface = (_drawState->getMode(GL_CULL_FACE)==osg::StateAttribute::ON);
_lighting =(_drawState->getMode(GL_LIGHTING)==osg::StateAttribute::ON);
_texture =(_drawState->getMode(GL_TEXTURE_2D)==osg::StateAttribute::ON);
_backface = (_drawState->getMode(GL_CULL_FACE)&osg::StateAttribute::ON);
_lighting =(_drawState->getMode(GL_LIGHTING)&osg::StateAttribute::ON);
_texture =(_drawState->getTextureMode(0,GL_TEXTURE_2D)&osg::StateAttribute::ON);
}
StateSet *StateSetManipulator::getStateSet()
@@ -41,7 +41,7 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa)
case 'b' :
_backface = !_backface;
if( _backface ) _drawState->setMode(GL_CULL_FACE,osg::StateAttribute::ON);
else _drawState->setMode(GL_CULL_FACE,osg::StateAttribute::OVERRIDE_OFF);
else _drawState->setMode(GL_CULL_FACE,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
aa.requestRedraw();
return true;
break;
@@ -49,15 +49,15 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa)
case 'l' :
_lighting = !_lighting ;
if( _lighting ) _drawState->setMode(GL_LIGHTING,osg::StateAttribute::ON);
else _drawState->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE_OFF);
else _drawState->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
aa.requestRedraw();
return true;
break;
case 't' :
_texture = !_texture;
if (_texture) _drawState->setMode(GL_TEXTURE_2D,osg::StateAttribute::INHERIT);
else _drawState->setMode(GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE_OFF);
if (_texture) _drawState->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::INHERIT);
else _drawState->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
aa.requestRedraw();
return true;
break;

View File

@@ -988,16 +988,16 @@ void Viewer::keyboard(unsigned char key, int x, int y)
if( backface )
globalStateSet->setMode(GL_CULL_FACE,osg::StateAttribute::ON);
else
globalStateSet->setMode(GL_CULL_FACE,osg::StateAttribute::OVERRIDE_OFF);
globalStateSet->setMode(GL_CULL_FACE,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
break;
case 'l' :
lighting = 1 - lighting ;
if( lighting )
globalStateSet->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE_ON);
globalStateSet->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
else
globalStateSet->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE_OFF);
globalStateSet->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
break;
case 'L' :
@@ -1024,7 +1024,7 @@ void Viewer::keyboard(unsigned char key, int x, int y)
// use blank texture to override all local texture in scene graph.
// thus causing them to all use the same texture attribute, hence
// preventing a state attribute change due to unused textures.
globalStateSet->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE_OFF);
globalStateSet->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
// static osg::ref_ptr<osg::Texture> blank_texture = osgNew osg::Texture;
// globalStateSet->setTextureAttribute(0,blank_texture.get());
}

View File

@@ -36,8 +36,8 @@
#include <osg/StateSet>
#include <osg/Material>
#include <osg/Texture>
#include <osg/Transform>
#include <osg/Transparency>
#include <osg/MatrixTransform>
#include <osg/BlendFunc>
#include <osg/CullFace>
#include <osg/FrontFace>
#include <osg/PolygonMode>
@@ -107,7 +107,7 @@ ObjectCache::MaterialMap ObjectCache::materials;
ObjectCache::TextureMap ObjectCache::textures;
ObjectCache::NodeMap ObjectCache::nodos;
static void makeTransform(MatrixTransform *matriz_active, osg::Transform *nodo) {
static void makeTransform(MatrixTransform *matriz_active, osg::MatrixTransform *nodo) {
// Original
osg::Matrix m(matriz_active->getElem(0),matriz_active->getElem(1),matriz_active->getElem(2),matriz_active->getElem(3),
matriz_active->getElem(4),matriz_active->getElem(5),matriz_active->getElem(6),matriz_active->getElem(7),
@@ -140,12 +140,14 @@ void OSGVisitor::applyCoordinate3(Coordinate3 *coord) {
coord3_active=coord;
}
void OSGVisitor::applyMatrixTransform(MatrixTransform *tr) {
void OSGVisitor::applyMatrixTransform(MatrixTransform *tr)
{
makeTransform(tr,parent);
}
void OSGVisitor::applySeparator(Separator *sep) {
osg::Transform *group=new osg::Transform();
void OSGVisitor::applySeparator(Separator *sep)
{
osg::MatrixTransform *group=new osg::MatrixTransform();
if (root==0) {
root=group;
}
@@ -228,7 +230,7 @@ void OSGVisitor::makeGeode(osg::Geode *geode, osg::Geometry *geometry, bool twoS
} else {
//osg::notify(osg::INFO) << "Deactivating culling for this object" << std::endl;
state->setAttributeAndModes(cull,osg::StateAttribute::OFF);
osg::Transparency *transp=new osg::Transparency();
osg::BlendFunc *transp=new osg::BlendFunc();
transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
state->setAttribute(transp);
state->setMode(GL_BLEND,osg::StateAttribute::ON);

View File

@@ -22,11 +22,12 @@
#include "mynodevisitor.h"
#include <osg/Group>
#include <osg/MatrixTransform>
#include <osg/Geometry>
class OSGVisitor: public MyNodeVisitor {
osg::Node *root;
osg::Transform *parent;
osg::MatrixTransform *parent;
Coordinate3 *coord3_active;
TextureCoordinate *tcoord_active;
Texture2 *texture_active;

View File

@@ -0,0 +1,41 @@
#include "osg/DOFTransform"
#include "osgDB/Registry"
#include "osgDB/Input"
#include "osgDB/Output"
using namespace osg;
using namespace osgDB;
// forward declare functions to use later.
bool DOFTransform_readLocalData(Object& obj, Input& fr);
bool DOFTransform_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_DOFTransformProxy
(
osgNew osg::DOFTransform,
"DOFTransform",
"Object Node Transform DOFTransform Group",
&DOFTransform_readLocalData,
&DOFTransform_writeLocalData,
DotOsgWrapper::READ_AND_WRITE
);
bool DOFTransform_readLocalData(Object& obj, Input& fr)
{
bool iteratorAdvanced = false;
DOFTransform& transform = static_cast<DOFTransform&>(obj);
return iteratorAdvanced;
}
bool DOFTransform_writeLocalData(const Object& obj, Output& fw)
{
const DOFTransform& transform = static_cast<const DOFTransform&>(obj);
return true;
}

View File

@@ -10,6 +10,7 @@ CXXFILES =\
ConvexPlanerOccluder.cpp\
CullFace.cpp\
Depth.cpp\
DOFTransform.cpp\
Drawable.cpp\
EarthSky.cpp\
Fog.cpp\
@@ -35,6 +36,7 @@ CXXFILES =\
Point.cpp\
PolygonMode.cpp\
PolygonOffset.cpp\
PositionAttitudeTransform.cpp\
Projection.cpp\
ReaderWriterOSG.cpp\
ShadeModel.cpp\

View File

@@ -0,0 +1,40 @@
#include "osg/PositionAttitudeTransform"
#include "osgDB/Registry"
#include "osgDB/Input"
#include "osgDB/Output"
using namespace osg;
using namespace osgDB;
// forward declare functions to use later.
bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr);
bool PositionAttitudeTransform_writeLocalData(const Object& obj, Output& fw);
// register the read and write functions with the osgDB::Registry.
RegisterDotOsgWrapperProxy g_PositionAttitudeTransformProxy
(
osgNew osg::PositionAttitudeTransform,
"PositionAttitudeTransform",
"Object Node Transform PositionAttitudeTransform Group",
&PositionAttitudeTransform_readLocalData,
&PositionAttitudeTransform_writeLocalData,
DotOsgWrapper::READ_AND_WRITE
);
bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr)
{
bool iteratorAdvanced = false;
PositionAttitudeTransform& transform = static_cast<PositionAttitudeTransform&>(obj);
return iteratorAdvanced;
}
bool PositionAttitudeTransform_writeLocalData(const Object& obj, Output& fw)
{
const PositionAttitudeTransform& transform = static_cast<const PositionAttitudeTransform&>(obj);
return true;
}

View File

@@ -141,7 +141,7 @@ bool GeoState_readLocalData(Object& obj, Input& fr)
StateAttribute::GLModeValue mode;
if (fr[0].matchWord("transparency") && StateSet_matchModeStr(fr[1].getStr(),mode))
{
if (mode==StateAttribute::ON || mode==StateAttribute::OVERRIDE_ON)
if (mode&StateAttribute::ON)
{
statset.setRenderingHint(StateSet::TRANSPARENT_BIN);
}
@@ -585,8 +585,8 @@ bool StateSet_matchModeStr(const char* str,StateAttribute::GLModeValue& mode)
if (strcmp(str,"INHERIT")==0) mode = StateAttribute::INHERIT;
else if (strcmp(str,"ON")==0) mode = StateAttribute::ON;
else if (strcmp(str,"OFF")==0) mode = StateAttribute::OFF;
else if (strcmp(str,"OVERRIDE_ON")==0) mode = StateAttribute::OVERRIDE_ON;
else if (strcmp(str,"OVERRIDE_OFF")==0) mode = StateAttribute::OVERRIDE_OFF;
else if (strcmp(str,"OVERRIDE_ON")==0) mode = StateAttribute::OVERRIDE|StateAttribute::ON;
else if (strcmp(str,"OVERRIDE_OFF")==0) mode = StateAttribute::OVERRIDE|StateAttribute::OFF;
else if (strcmp(str,"OVERRIDE|ON")==0) mode = StateAttribute::OVERRIDE|StateAttribute::ON;
else if (strcmp(str,"OVERRIDE|OFF")==0) mode = StateAttribute::OVERRIDE|StateAttribute::OFF;
else if (strcmp(str,"PROTECTED|ON")==0) mode = StateAttribute::PROTECTED|StateAttribute::ON;

View File

@@ -21,6 +21,9 @@ using namespace osgUtil;
void Optimizer::optimize(osg::Node* node, unsigned int options)
{
return;
if (options & COMBINE_ADJACENT_LODS)
{
CombineLODsVisitor clv;