Converted cout's to notify's.

This commit is contained in:
Robert Osfield 2003-08-31 22:17:53 +00:00
parent 6bb951a5bb
commit 5400f8293b
2 changed files with 2 additions and 554 deletions

View File

@ -13,558 +13,6 @@
#include <osgUtil/Optimizer>
#include <osgProducer/Viewer>
// main viewer code at bottom of file.
// experimental templated rendering code, please ignore...
// will move to osg::Geometry once complete.
// Robert Osfield, August 2003.
#if 0
struct DrawArrays
{
virtual void draw() const = 0;
};
struct DrawVertex
{
inline void operator () (const osg::Vec2* v) const { glVertex2fv(v->ptr()); }
inline void operator () (const osg::Vec3* v) const { glVertex3fv(v->ptr()); }
inline void operator () (const osg::Vec4* v) const { glVertex4fv(v->ptr()); }
};
struct DrawNormal
{
inline void operator () (const osg::Vec3* v) const { glNormal3fv(v->ptr()); }
};
struct DrawColor
{
inline void operator () (const osg::Vec4* v) const { glColor4fv(v->ptr()); }
};
struct DrawTexCoord
{
inline void operator () (const osg::Vec2* v) const { glTexCoord2fv(v->ptr()); }
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template< class F1, class T1>
struct DrawFunctor_T : public DrawArrays
{
inline DrawFunctor_T(T1* begin1, T1* end1): _begin1(begin1),_end1(end1) {}
virtual void draw() const
{
for(T1* ptr1=_begin1;
ptr1!=_end1;
++ptr1)
{
F1(ptr1);
}
}
T1* _begin1;
T1* _end1;
};
template< class F1, class T1, class I1>
struct DrawFunctor_TI : public DrawArrays
{
inline DrawFunctor_TI(T1* begin1, I1* ibegin1, I1* iend1): _begin1(begin1),_ibegin1(ibegin1),_iend1(end1) {}
virtual void draw() const
{
for(I1* iptr1=_ibegin1;
iptr1!=_iend1;
++iptr1)
{
F1(_begin1[*iptr1]);
}
}
T1* _begin1;
I1* _ibegin1;
I1* _iend1;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template< class F1, class T1, class F2, class T2>
struct DrawFunctor_TT : public DrawArrays
{
inline DrawFunctor_TT(T1* begin1, T1* end1, T2* begin2): _begin1(begin1),_end1(end1),_begin2(begin2) {}
virtual void draw() const
{
T2* ptr2=_begin2;
for(T1* ptr1=_begin1;
ptr1!=_end1;
++ptr1,++ptr2)
{
F2(ptr2);
F1(ptr1);
}
}
T1* _begin1;
T1* _end1;
T2* _begin2;
};
template< class F1, class T1, class I1, class F2, class T2>
struct DrawFunctor_TIT : public DrawArrays
{
inline DrawFunctor_TIT(T1* begin1, I1* ibegin1, I1* iend1, T2* begin2): _begin1(begin1),_ibegin1(ibegin1),_iend1(end1) {}
virtual void draw() const
{
T2* ptr2=_begin2;
for(I1* iptr1=_ibegin1;
iptr1!=_iend1;
++iptr1,++ptr2)
{
F2(_ptr2);
F1(_begin1[*iptr1]);
}
}
T1* _begin1;
I1* _ibegin1;
I1* _iend1;
T2* _begin2;
};
template< class F1, class T1, class F2, class T2, class I2>
struct DrawFunctor_TTI : public DrawArrays
{
inline DrawFunctor_TTI(T1* begin1, T1* end1, T2* begin2, I2* ibegin2): _begin1(begin1),_end1(end1),_begin2(begin2),_ibegin2(ibegin2) {}
virtual void draw() const
{
I2* iptr2 = _ibegin2;
for(T1* ptr1=_begin1;
ptr1!=_end1;
++ptr1,++iptr2)
{
F2(_begin2[*iptr2]);
F1(ptr1);
}
}
T1* _begin1;
T1* _end1;
T2* _begin2;
I2* _ibegin2;
};
template< class F1, class T1, class F2, class I1, class T2, class I2>
struct DrawFunctor_TITI : public DrawArrays
{
inline DrawFunctor_TITI(T1* begin1, I1* ibegin1, I2* iend1, T2* begin2, I2* ibegin2): _begin1(begin1),_ibegin1(ibegin1), _iend1(end1),_begin2(begin2),_ibegin2(ibegin2) {}
virtual void draw() const
{
I2* iptr2 = _ibegin2;
for(T1* iptr1=_ibegin1;
iptr1!=_iend1;
++iptr1,++iptr2)
{
F2(_begin2[*iptr2]);
F1(_begin1[*iptr1]);
}
}
T1* _begin1;
I1* _ibegin1;
I1* _iend1;
T2* _begin2;
I2* _ibegin2;
};
template< class F1, class T1, class F2, class T2, class I>
struct DrawFunctor_TT_I : public DrawArrays
{
inline DrawFunctor_TT_I(T1* begin1, T2* begin2, I* ibegin, I* iend): _begin1(begin1),_begin2(begin2),_ibegin(ibegin),_iend(iend) {}
virtual void draw() const
{
I index;
for(I* iptr=_ibegin;
iptr!=_iend;
++iptr)
{
index = *iptr;
F2(_begin2[index]);
F1(_begin1[index]);
}
}
T1* _begin1;
T2* _begin2;
I* _ibegin;
I* _iend;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template< class F1, class T1, class F2, class T2, class F3, class T3>
struct DrawFunctor_TTT : public DrawArrays
{
inline DrawFunctor_TTT(T1* begin1, T1* end1, T2* begin2, T3* begin): _begin1(begin1),_end1(end1),_begin2(begin2),_begin3(begin3) {}
virtual void draw() const
{
T2* ptr2=_begin2;
T3* ptr3=_begin3;
for(T1* ptr1=_begin1;
ptr1!=_end1;
++ptr1,++ptr2,++ptr3)
{
F3(ptr3);
F2(ptr2);
F1(ptr1);
}
}
T1* _begin1;
T1* _end1;
T2* _begin2;
T3* _begin3;
};
template< class F1, class T1, class I1, class F2, class T2, class F3, class T3>
struct DrawFunctor_TITT : public DrawArrays
{
inline DrawFunctor_TITT(T1* begin1, I1* ibegin1, I1* iend1, T2* begin2, T3* begin): _begin1(begin1),_ibegin1(ibegin1),_iend1(end1),_begin3(begin3) {}
virtual void draw() const
{
T2* ptr2=_begin2;
T3* ptr3=_begin3;
for(I1* iptr1=_ibegin1;
iptr1!=_iend1;
++iptr1,++ptr2,++ptr3)
{
F3(_ptr3);
F2(_ptr2);
F1(_begin1[*iptr1]);
}
}
T1* _begin1;
I1* _ibegin1;
I1* _iend1;
T2* _begin2;
T3* _begin3;
};
template< class F1, class T1, class F2, class T2, class I2, class F3, class T3>
struct DrawFunctor_TTIT : public DrawArrays
{
inline DrawFunctor_TTIT(T1* begin1, T1* end1, T2* begin2, I2* ibegin2, T3* begin): _begin1(begin1),_end1(end1),_begin2(begin2),_ibegin2(ibegin2),_begin3(begin3) {}
virtual void draw() const
{
I2* iptr2 = _ibegin2;
T3* ptr3 = _begin3;
for(T1* ptr1=_begin1;
ptr1!=_end1;
++ptr1,++iptr2,++ptr3)
{
F3(ptr3);
F2(_begin2[*iptr2]);
F1(ptr1);
}
}
T1* _begin1;
T1* _end1;
T2* _begin2;
I2* _ibegin2;
T3* _begin3;
};
template< class F1, class T1, class F2, class I1, class T2, class I2, class F3, class T3>
struct DrawFunctor_TITIT : public DrawArrays
{
inline DrawFunctor_TITIT(T1* begin1, I1* ibegin1, I2* iend1, T2* begin2, I2* ibegin2, T3* begin3): _begin1(begin1),_ibegin1(ibegin1), _iend1(end1),_begin2(begin2),_ibegin2(ibegin2),_begin3(begin3) {}
virtual void draw() const
{
I2* iptr2 = _ibegin2;
T3* ptr3 = _begin3;
for(I1* iptr1=_ibegin1;
iptr1!=_iend1;
++iptr1,++iptr2,++ptr3)
{
F3(ptr3);
F2(_begin2[*iptr2]);
F1(_begin1[*iptr1]);
}
}
T1* _begin1;
I1* _ibegin1;
I1* _iend1;
T2* _begin2;
I2* _ibegin2;
T3* _begin3;
};
template< class F1, class T1, class F2, class T2, class I2, class F3, class T3, class I3>
struct DrawFunctor_TTITI : public DrawArrays
{
inline DrawFunctor_TTITI(T1* begin1, T1* end1, T2* begin2, I2* ibegin2, T3* begin3, I3* ibegin3): _begin1(begin1),_end1(end1),_begin2(begin2),_ibegin2(ibegin2),_begin3(begin3),_ibegin3(begin3) {}
virtual void draw() const
{
I2* iptr2 = _ibegin2;
I3* iptr3 = _ibegin3;
for(T1* ptr1=_begin1;
ptr1!=_end1;
++ptr1,++iptr2,++iptr3)
{
F3(_begin3[*iptr3]);
F2(_begin2[*iptr2]);
F1(ptr1);
}
}
T1* _begin1;
T1* _end1;
T2* _begin2;
I2* _ibegin2;
T3* _begin3;
I3* _ibegin3;
};
template< class F1, class T1, class I1, class F2, class T2, class I2, class F3, class T3, class I3>
struct DrawFunctor_TITITI : public DrawArrays
{
inline DrawFunctor_TITITI(T1* begin1, I1* ibegin1, I2* iend1, T2* begin2, I2* ibegin2, T3* begin3, I3* ibegin3): _begin1(begin1),_ibegin1(ibegin1), _iend1(end1),_begin2(begin2),_ibegin2(ibegin2),_begin3(begin3),_ibegin3(begin3) {}
virtual void draw() const
{
I2* iptr2 = _ibegin2;
I3* iptr3 = _ibegin3;
for(I1* iptr1=_ibegin1;
iptr1!=_iend1;
++iptr1,++iptr2,++iptr3)
{
F3(_begin3[*iptr3]);
F2(_begin2[*iptr2]);
F1(_begin1[*iptr1]);
}
}
T1* _begin1;
I1* _ibegin1;
I1* _iend1;
T2* _begin2;
I2* _ibegin2;
T3* _begin3;
I3* _ibegin3;
};
template< class F1, class T1, class F2, class T2, class F3, class T3, class I>
struct DrawFunctor_TTT_I : public DrawArrays
{
inline DrawFunctor_TTT_I(T1* begin1, T2* begin2, T3* begin3, I* ibegin, I* iend): _begin1(begin1),_begin2(begin2),_begin3(begin3),_ibegin(ibegin),_iend(iend) {}
virtual void draw() const
{
I index;
for(I* iptr=_ibegin;
iptr!=_iend;
++iptr)
{
index = *iptr;
F3(_begin3[index]);
F2(_begin2[index]);
F1(_begin1[index]);
}
}
T1* _begin1;
T2* _begin2;
T3* _begin3;
I* _ibegin;
I* _iend;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// single vertex attribute
typedef DrawFunctor_T<DrawVertex,osg::Vec3> V3;
typedef DrawFunctor_TI<DrawVertex,osg::Vec3,unsigned short> V3i;
// two attributes - vertex + one other attribute
typedef DrawFunctor_TT<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3> V3N3;
typedef DrawFunctor_TT<DrawVertex,osg::Vec3,DrawColor,osg::Vec4> V3C4;
typedef DrawFunctor_TT<DrawVertex,osg::Vec3,DrawTexCoord,osg::Vec2> V3T2;
typedef DrawFunctor_TIT<DrawVertex,osg::Vec3,unsigned short,DrawNormal,osg::Vec3> V3iN3;
typedef DrawFunctor_TIT<DrawVertex,osg::Vec3,unsigned short,DrawColor,osg::Vec4> V3iC4;
typedef DrawFunctor_TIT<DrawVertex,osg::Vec3,unsigned short,DrawTexCoord,osg::Vec2> V3iT2;
typedef DrawFunctor_TTI<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3,unsigned short> V3N3i;
typedef DrawFunctor_TTI<DrawVertex,osg::Vec3,DrawColor,osg::Vec4,unsigned short> V3C4i;
typedef DrawFunctor_TTI<DrawVertex,osg::Vec3,DrawTexCoord,osg::Vec2,unsigned short> V3T2i;
typedef DrawFunctor_TT_I<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3,unsigned short> V3N3_i;
typedef DrawFunctor_TT_I<DrawVertex,osg::Vec3,DrawColor,osg::Vec4,unsigned short> V3C4_i;
typedef DrawFunctor_TT_I<DrawVertex,osg::Vec3,DrawTexCoord,osg::Vec2,unsigned short> V3T2_i;
// three attributes - vertex + two other attributes.
typedef DrawFunctor_TTT<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3,DrawColor,osg::Vec4> V3N3C4;
typedef DrawFunctor_TTT<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3,DrawTexCoord,osg::Vec2> V3N3T2;
typedef DrawFunctor_TTT<DrawVertex,osg::Vec3,DrawColor,osg::Vec4,DrawTexCoord,osg::Vec2> V3C4T2;
typedef DrawFunctor_TITT<DrawVertex,osg::Vec3,unsigned short,DrawNormal,osg::Vec3,DrawColor,osg::Vec4> V3iN3C4;
typedef DrawFunctor_TITT<DrawVertex,osg::Vec3,unsigned short,DrawNormal,osg::Vec3,DrawTexCoord,osg::Vec2> V3iN3T2;
typedef DrawFunctor_TITT<DrawVertex,osg::Vec3,unsigned short,DrawColor,osg::Vec4,DrawTexCoord,osg::Vec2> V3iC4T2;
typedef DrawFunctor_TTIT<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3,unsigned short,DrawColor,osg::Vec4> V3N3iC4;
typedef DrawFunctor_TTIT<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3,unsigned short,DrawTexCoord,osg::Vec2> V3N3iT2;
typedef DrawFunctor_TTIT<DrawVertex,osg::Vec3,DrawColor,osg::Vec4,unsigned short,DrawNormal,osg::Vec3> V3C4iN3;
typedef DrawFunctor_TTIT<DrawVertex,osg::Vec3,DrawColor,osg::Vec4,unsigned short,DrawTexCoord,osg::Vec2> V3C4iT2;
typedef DrawFunctor_TTIT<DrawVertex,osg::Vec3,DrawTexCoord,osg::Vec2,unsigned short,DrawColor,osg::Vec4> V3T2iC4;
typedef DrawFunctor_TTIT<DrawVertex,osg::Vec3,DrawTexCoord,osg::Vec2,unsigned short,DrawNormal,osg::Vec3> V3T2iN3;
typedef DrawFunctor_TTITI<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3,unsigned short,DrawColor,osg::Vec4,unsigned short> V3N3iC4i;
typedef DrawFunctor_TTITI<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3,unsigned short,DrawTexCoord,osg::Vec2,unsigned short> V3N3iT2i;
typedef DrawFunctor_TTITI<DrawVertex,osg::Vec3,DrawColor,osg::Vec4,unsigned short,DrawTexCoord,osg::Vec2,unsigned short> V3C4iT2i;
typedef DrawFunctor_TTT_I<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3,DrawColor,osg::Vec4,unsigned short> V3N3C4_i;
typedef DrawFunctor_TTT_I<DrawVertex,osg::Vec3,DrawNormal,osg::Vec3,DrawTexCoord,osg::Vec2,unsigned short> V3N3T2_i;
typedef DrawFunctor_TTT_I<DrawVertex,osg::Vec3,DrawColor,osg::Vec4,DrawTexCoord,osg::Vec2,unsigned short> V3C4T2_i;
class MyDrawable : public osg::Drawable
{
public:
MyDrawable();
virtual void drawImplementation(osg::State& state);
virtual bool computeBound() const;
enum RenderingMode
{
v,
vI,// 2
vn,
vIn,
vnI,
vInI,
vn_sI, // 5
vc,
vIc,
vnc,
vInc,
vnIc,
vInIc,
vcI,
vIcI,
vncI,
vIncI,
vnIcI,
vInIcI,
vnc_sI, // 13
vt,
vIt,
vnt,
vInt,
vnIt,
vInIt,
vct,
vIct,
vnct,
vInct,
vnIct,
vInIct,
vcIt,
vIcIt,
vncIt,
vIncIt,
vnIcIt,
vInIcIt,
vtI,
vItI,
vntI,
vIntI,
vnItI,
vInItI,
vctI,
vIctI,
vnctI,
vInctI,
vnIctI,
vInIctI,
vcItI,
vIcItI,
vncItI,
vIncItI,
vnIcItI,
vInIcItI
vnct_sI // 37
}; // 57 combinations.
GLenum _primitiveType;
ref_ptr<Vec3Array> _vertices;
ref_ptr<UShortArray> _vertexIndices;
ref_ptr<Vec3Array> _normals;
ref_ptr<UShortArray> _normalIndices;
ref_ptr<Vec4Array> _colors;
ref_ptr<UShortArray> _colorIndices;
ref_ptr<Vec2Array> _texcoords;
ref_ptr<UShortArray> _texcoordIndices;
}
#endif
int main( int argc, char **argv )
{

View File

@ -144,8 +144,8 @@ void AnimationPathManipulator::handleFrame( double time )
if (delta>=_animationPath->getPeriod())
{
double frameRate = (double)_numOfFramesSinceStartOfTimedPeriod/delta;
std::cout <<"AnimatonPath completed in "<<delta<<" seconds, completing "<<_numOfFramesSinceStartOfTimedPeriod<<" frames,"<<std::endl;
std::cout <<" average frame rate = "<<frameRate<<std::endl;
osg::notify(osg::INFO) <<"AnimatonPath completed in "<<delta<<" seconds, completing "<<_numOfFramesSinceStartOfTimedPeriod<<" frames,"<<std::endl;
osg::notify(osg::INFO) <<" average frame rate = "<<frameRate<<std::endl;
// reset counters for next loop.
_realStartOfTimedPeriod = time;