Re: [osg-news] Trail
Brought to you by:
robertosfield
|
From: Robert O. <ro...@op...> - 2003-05-27 08:51:56
|
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.
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.
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.
Robert.
|