Re: [osg-news] Trail
Brought to you by:
robertosfield
|
From: Tommy P. <tp...@id...> - 2003-05-27 14:53:07
|
> From: Robert Osfield <ro...@op...>
> Hi Tommy,
>
> On Saturday 24 May 2003 23:37, Tommy Persson wrote:
> > What is the best way to implement a trail in OSG? In performer I
> > cloned a node and used a SCS node to put it in the correct position.
> >
> > My current version in OSG is:
> >
> > void Trail::updateFrom(const osg::Vec3 & pos,
> > const osg::Vec3 & fdir,
> > const osg::Vec3 & udir) {
> >
> > Witas::Visualizer::DirectionMatrixTransform* tmat =
> > new Witas::Visualizer::DirectionMatrixTransform;
> > tmat->moveTo (pos);
> > tmat->setOrientation (fdir, udir);
> > tmat->addChild (trailShape);
> > trail->addChild(tmat);
> > }
> >
> > where trailShape is a pointer to a Drawable node and
> > DirectionMatrixTransform inherits from MatrixTransform. But this
> > implemtation ha a noticable slow down in performance. The trailShape
> > was a cone.
>
> Is the trail shape a single cone or a seperate cone for each update
> position?
> From the code above it looks like a seperate cone per position.
>
Yes, it is a seperate cone for each update. It is a helicopter that
is flying and I want to see if it follow a specific path. The
orientation of the cones reflects the orientation of the helicopter at
each point.
> What you could do is use a series of osg::Shape's, the can be
> positioned and orientated via an quaternion so would avoid the need
> for the transform which will be adding over head to cull and draw
> traversals. There is a Cone shape in the list of Shapes. Have a
> look at the osgshape example for code for setting it up.
OK, I understand how to do this now (I had missed the that you could
set the quaternion in the Cone shape). Thanks for the hint.
One question about this method. Do you duplicate the Shape and if so
is this a problem? By using a Transformation node I thought that you
just duplicated the transformation node and that this saved resources.
> If peformance really needs to be optimized then I'd consider a
> custom Drawable for managing a list of Vec3 + osg::Quat for the
> trail, then custom drawing code to render the trail as required.
I seem to run out of something since my code crashes without a core
file on the SGI-machine. On my Linux machine it just slows down.
/Tommy
|