Added support for DOFTransforms into .osg format, and add pivot point support
to the PositionAttitudeTransform .osg support. Removed a double light reference in the osglight demo.
This commit is contained in:
@@ -147,8 +147,6 @@ osg::Node* createLights(osg::BoundingBox& bb,osg::StateSet* rootStateSet)
|
||||
mt->addChild(lightS2);
|
||||
mt->addChild(markerGeode);
|
||||
|
||||
lightGroup->addChild(lightS2);
|
||||
|
||||
lightGroup->addChild(mt);
|
||||
|
||||
return lightGroup;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
using namespace std;
|
||||
|
||||
// forward declare functions to use later.
|
||||
bool DOFTransform_readLocalData(Object& obj, Input& fr);
|
||||
@@ -26,9 +27,93 @@ bool DOFTransform_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
DOFTransform& transform = static_cast<DOFTransform&>(obj);
|
||||
DOFTransform& dof = static_cast<DOFTransform&>(obj);
|
||||
|
||||
if (fr.matchSequence("PutMatrix {"))
|
||||
{
|
||||
fr += 2; // skip over "putMatrix {"
|
||||
iteratorAdvanced = true;
|
||||
|
||||
bool matched = true;
|
||||
for(int k=0;k<16 && matched;++k)
|
||||
{
|
||||
matched = fr[k].isFloat();
|
||||
}
|
||||
if (matched)
|
||||
{
|
||||
osg::Matrix matrix;
|
||||
int k=0;
|
||||
for(int i=0;i<4;++i)
|
||||
{
|
||||
for(int j=0;j<4;++j)
|
||||
{
|
||||
fr[k].getFloat(matrix(i,j));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
dof.setPutMatrix(matrix);
|
||||
dof.setInversePutMatrix(Matrix::inverse(matrix));
|
||||
}
|
||||
|
||||
fr.advanceToEndOfCurrentBlock();
|
||||
}
|
||||
|
||||
|
||||
#define ReadVec3(A,B) { \
|
||||
if (fr[0].matchWord(B) && \
|
||||
fr[1].getFloat(vec3[0]) && \
|
||||
fr[2].getFloat(vec3[1]) && \
|
||||
fr[3].getFloat(vec3[2])) \
|
||||
{ \
|
||||
dof.A(vec3); \
|
||||
fr+=4; \
|
||||
iteratorAdvanced = true; \
|
||||
} \
|
||||
}
|
||||
|
||||
Vec3 vec3;
|
||||
|
||||
ReadVec3(setMinHPR,"minHPR")
|
||||
ReadVec3(setMaxHPR,"maxHPR")
|
||||
ReadVec3(setIncrementHPR,"incrementHPR")
|
||||
ReadVec3(setCurrentHPR,"currentHPR")
|
||||
|
||||
ReadVec3(setMinTranslate,"minTranslate")
|
||||
ReadVec3(setMaxTranslate,"maxTranslate")
|
||||
ReadVec3(setIncrementTranslate,"incrementTranslate")
|
||||
ReadVec3(setCurrentTranslate,"currentTranslate")
|
||||
|
||||
ReadVec3(setMinScale,"minScale")
|
||||
ReadVec3(setMaxScale,"maxScale")
|
||||
ReadVec3(setIncrementScale,"incrementScale")
|
||||
ReadVec3(setCurrentScale,"currentScale")
|
||||
|
||||
|
||||
if (fr.matchSequence("limitationFlags %i"))
|
||||
{
|
||||
unsigned int flags;
|
||||
fr[1].getUInt(flags);
|
||||
dof.setLimitationFlags(flags);
|
||||
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("animationOn"))
|
||||
{
|
||||
|
||||
if (fr[1].matchWord("TRUE")) dof.setAnimationOn(true);
|
||||
else if (fr[1].matchWord("FALSE")) dof.setAnimationOn(false);
|
||||
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
|
||||
}
|
||||
|
||||
#undef ReadVec3
|
||||
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
@@ -37,5 +122,28 @@ bool DOFTransform_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const DOFTransform& transform = static_cast<const DOFTransform&>(obj);
|
||||
|
||||
fw.indent()<<"PutMatrix "<<transform.getPutMatrix()<<std::endl;
|
||||
|
||||
fw.indent()<<"minHPR "<<transform.getMinHPR()<<std::endl;
|
||||
fw.indent()<<"maxHPR "<<transform.getMaxHPR()<<std::endl;
|
||||
fw.indent()<<"incrementHPR "<<transform.getIncrementHPR()<<std::endl;
|
||||
fw.indent()<<"currentHPR "<<transform.getCurrentHPR()<<std::endl;
|
||||
|
||||
fw.indent()<<"minTranslate "<<transform.getMinTranslate()<<std::endl;
|
||||
fw.indent()<<"maxTranslate "<<transform.getMaxTranslate()<<std::endl;
|
||||
fw.indent()<<"incrementTranslate "<<transform.getIncrementTranslate()<<std::endl;
|
||||
fw.indent()<<"currentTranslate "<<transform.getCurrentTranslate()<<std::endl;
|
||||
|
||||
fw.indent()<<"minScale "<<transform.getMinScale()<<std::endl;
|
||||
fw.indent()<<"axScale "<<transform.getMaxScale()<<std::endl;
|
||||
fw.indent()<<"incrementScale "<<transform.getIncrementScale()<<std::endl;
|
||||
fw.indent()<<"currentScale "<<transform.getCurrentScale()<<std::endl;
|
||||
|
||||
fw.indent()<<"limitationFlags 0x"<<hex<<transform.getLimitationFlags()<<dec<<std::endl;
|
||||
|
||||
fw.indent()<<"animationOn ";
|
||||
if (transform.getAnimationOn()) fw<<"TRUE"<<std::endl;
|
||||
else fw<<"FALSE"<<std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,19 @@ bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
transform.setAttitude(att);
|
||||
|
||||
fr += 5;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("pivot %f %f %f"))
|
||||
{
|
||||
osg::Vec3 pivot;
|
||||
fr[1].getFloat(pivot[0]);
|
||||
fr[2].getFloat(pivot[1]);
|
||||
fr[3].getFloat(pivot[2]);
|
||||
|
||||
transform.setPivotPoint(pivot);
|
||||
|
||||
fr += 4;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
@@ -65,6 +78,7 @@ bool PositionAttitudeTransform_writeLocalData(const Object& obj, Output& fw)
|
||||
|
||||
fw.indent()<<"position "<<transform.getPosition()<<std::endl;
|
||||
fw.indent()<<"attitude "<<transform.getAttitude()<<std::endl;
|
||||
fw.indent()<<"pivotPoint "<<transform.getPivotPoint()<<std::endl;
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user