Added scale parameter into PositionAttitudeTransform.

Added pivotPoint parameter into AnimationPathCallack.
This commit is contained in:
Robert Osfield
2004-02-22 11:58:44 +00:00
parent e36ceae483
commit ac812539d8
10 changed files with 74 additions and 21 deletions

View File

@@ -31,6 +31,7 @@ void AnimationPathCallback::write(DataOutputStream* out){
throw Exception("AnimationPathCallback::write(): Could not cast this osg::AnimationPathCallback to an osg::Object.");
// Write AnimationPathCallback's properties.
out->writeVec3(_pivotPoint);
out->writeDouble(_timeOffset);
out->writeDouble(_timeMultiplier);
out->writeDouble(_firstTime);
@@ -61,6 +62,7 @@ void AnimationPathCallback::read(DataInputStream* in){
else
throw Exception("AnimationPathCallback::read(): Could not cast this osg::AnimationPathCallback to an osg::Object.");
// Read AnimationPathCallback's properties
_pivotPoint = in->readVec3();
_timeOffset = in->readDouble();
_timeMultiplier = in->readDouble();
_firstTime = in->readDouble();

View File

@@ -32,6 +32,7 @@ void PositionAttitudeTransform::write(DataOutputStream* out){
out->writeVec3(getPosition());
out->writeQuat(getAttitude());
out->writeVec3(getScale());
out->writeVec3(getPivotPoint());
}
@@ -51,6 +52,7 @@ void PositionAttitudeTransform::read(DataInputStream* in){
// Read PositionAttitudeTransform's properties
setPosition(in->readVec3());
setAttitude(in->readQuat());
setScale(in->readVec3());
setPivotPoint(in->readVec3());
}

View File

@@ -388,6 +388,7 @@ osg::Drawable* ReaderWriterOBJ::makeDrawable_duplicateCoords(GLMmodel* obj, GLMg
// geometry
osg::Geometry* geom = new osg::Geometry;
geom->setUseDisplayList(false);
// geom->setUseVertexBufferObjects(true);
// primitives are only triangles
@@ -491,6 +492,7 @@ osg::Drawable* ReaderWriterOBJ::makeDrawable_useSeperateIndices(GLMmodel* obj, G
// geometry
osg::Geometry* geom = new osg::Geometry;
geom->setUseDisplayList(false);
// geom->setUseVertexBufferObjects(true);
// the following code for mapping the coords, normals and texcoords
@@ -604,15 +606,15 @@ osg::Drawable* ReaderWriterOBJ::makeDrawable_useSeperateIndices(GLMmodel* obj, G
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,ntris*3));
}
#if 0
osgUtil::TriStripVisitor tsv;
tsv.stripify(*geom);
#endif
if (obj->numnormals==0)
{
osgUtil::SmoothingVisitor tsv;
tsv.smooth(*geom);
}
return geom;
}

View File

@@ -167,18 +167,33 @@ bool AnimationPathCallback_readLocalData(osg::Object &obj, osgDB::Input &fr)
osg::AnimationPathCallback *apc = dynamic_cast<osg::AnimationPathCallback*>(&obj);
if (!apc) return false;
bool itrAdvanced = false;
bool iteratorAdvanced = false;
if (fr.matchSequence("pivotPoint %f %f %f"))
{
osg::Vec3 pivot;
fr[1].getFloat(pivot[0]);
fr[2].getFloat(pivot[1]);
fr[3].getFloat(pivot[2]);
apc->setPivotPoint(pivot);
fr += 4;
iteratorAdvanced = true;
}
if (fr.matchSequence("timeOffset %f"))
{
fr[1].getFloat(apc->_timeOffset);
fr+=2;
itrAdvanced = true;
iteratorAdvanced = true;
}
else if(fr.matchSequence("timeMultiplier %f"))
{
fr[1].getFloat(apc->_timeMultiplier);
fr+=2;
itrAdvanced = true;
iteratorAdvanced = true;
}
static osg::ref_ptr<osg::AnimationPath> s_path = new osg::AnimationPath;
@@ -187,10 +202,10 @@ bool AnimationPathCallback_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osg::AnimationPath* animpath = dynamic_cast<osg::AnimationPath*>(object.get());
if (animpath) apc->setAnimationPath(animpath);
itrAdvanced = true;
iteratorAdvanced = true;
}
return itrAdvanced;
return iteratorAdvanced;
}
@@ -202,6 +217,7 @@ bool AnimationPathCallback_writeLocalData(const osg::Object &obj, osgDB::Output
if (!apc) return false;
fw.indent() <<"pivotPoint " <<apc->getPivotPoint()<<std::endl;
fw.indent() <<"timeOffset " <<apc->_timeOffset<<std::endl;
fw.indent() <<"timeMultiplier " <<apc->_timeMultiplier << std::endl;

View File

@@ -55,7 +55,20 @@ bool PositionAttitudeTransform_readLocalData(Object& obj, Input& fr)
iteratorAdvanced = true;
}
if (fr.matchSequence("pivot %f %f %f"))
if (fr.matchSequence("scale %f %f %f"))
{
osg::Vec3 scale;
fr[1].getFloat(scale[0]);
fr[2].getFloat(scale[1]);
fr[3].getFloat(scale[2]);
transform.setScale(scale);
fr += 4;
iteratorAdvanced = true;
}
if (fr.matchSequence("pivotPoint %f %f %f"))
{
osg::Vec3 pivot;
fr[1].getFloat(pivot[0]);
@@ -78,6 +91,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()<<"scale "<<transform.getScale()<<std::endl;
fw.indent()<<"pivotPoint "<<transform.getPivotPoint()<<std::endl;