To osg::AutoTransform added support for MinimumScale, MaximumScale and AutoScaleTransitionWidth parameters

and a new scheme for computing the scaling when using autoscale that introduces smooth
transitions to the scaling of the subgraph so that it looks more natural.
This commit is contained in:
Robert Osfield
2008-03-18 15:37:38 +00:00
parent b08f438946
commit 1d1dcf2cf3
6 changed files with 80 additions and 7 deletions

View File

@@ -37,8 +37,16 @@ void AutoTransform::write(DataOutputStream* out){
out->writeBool(getAutoScaleToScreen());
if ( out->getVersion() >= VERSION_0025 )
{
out->writeFloat(getMinimumScale());
out->writeFloat(getMaximumScale());
out->writeFloat(getAutoScaleTransistionWidthRatio());
}
out->writeQuat(getRotation());
out->writeVec3(getScale());
}
void AutoTransform::read(DataInputStream* in){
@@ -64,8 +72,17 @@ void AutoTransform::read(DataInputStream* in){
setAutoScaleToScreen(in->readBool());
if ( in->getVersion() >= VERSION_0025 )
{
setMinimumScale(in->readFloat());
setMaximumScale(in->readFloat());
setAutoScaleTransistionWidthRatio(in->readFloat());
}
setRotation(in->readQuat());
setScale(in->readVec3());
}
else{
throw Exception("AutoTransform::read(): Expected AutoTransform identification.");

View File

@@ -33,8 +33,9 @@
#define VERSION_0022 22
#define VERSION_0023 23
#define VERSION_0024 24
#define VERSION_0025 25
#define VERSION VERSION_0024
#define VERSION VERSION_0025
/* The BYTE_SEX tag is used to check the endian
of the IVE file being read in. The IVE format

View File

@@ -140,6 +140,18 @@ bool AutoTransform_readLocalData(Object& obj, Input& fr)
iteratorAdvanced = true;
}
if (fr.matchSequence("autoScaleTransistionWidthRatio %f"))
{
float ratio;
fr[1].getFloat(ratio);
transform.setAutoScaleTransistionWidthRatio(ratio);
fr += 2;
iteratorAdvanced = true;
}
return iteratorAdvanced;
}
@@ -167,8 +179,12 @@ bool AutoTransform_writeLocalData(const Object& obj, Output& fw)
default: fw<<"NO_ROTATION"<<std::endl; break;
}
fw.indent()<<"autoScaleToScreen "<<(transform.getAutoScaleToScreen()?"TRUE":"FALSE")<<std::endl;
if (transform.getAutoScaleTransistionWidthRatio()!=0.25)
{
fw.indent()<<"autoScaleTransistionWidthRatio "<<transform.getAutoScaleTransistionWidthRatio()<<std::endl;
}
return true;
}