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:
@@ -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.");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user