Hi Carsten, this works like a charm, but is there a way to set the line width for the trace?
regards, keyan On 7 Nov 2011, at 16:57, Carsten Neumann wrote: > Hello Keyan, > > On 11/07/2011 08:08 AM, Keyan wrote: >> in my application, I would like to visualize the trajectory of an object. >> For this purpose, I store the coordinates at given intervals. The trajectory >> may be of limited length, e.g. the last 100 steps, or unlimited. >> >> I also want to choose the color for the trajectory segments, having a higher >> transparency for points further back in the past. >> >> What is the best way to visualize such a trajectory. I only found the >> drawLines function and the OSG::Lines objects. > > create a OSG::Geometry that contains one or more GL_LINE_STRIPs: > > OSG::GeometryRefPtr geo = OSG::Geometry::create(); > > OSG::GeoUInt8PropertyRefPtr types = OSG::GeoUInt8Property::create(); > types->push_back(GL_LINE_STRIP); > > OSG::GeoPnt3fPropertyRefPtr pos = OSG::GeoPnt3fProperty::create(); > pos->push_back(OSG::Pnt3f(0.f, 0.f, 0.f)); > // etc. for history of object positions > > OSG::Color4fPropertyRefPtr color = OSG::GeoColor4fProperty::create(); > // add colors > > OSG::GeoUInt32PropertyRefPtr lengths = OSG::GeoUInt32Property::create(); > lengths->push_back( /* lenght of first strip */); > lengths->push_back( /* lenght of second strip, if any */); > // etc. > > geo->setTypes (types); > geo->setLengths(lengths); > > geo->setProperty(pos, OSG::Geometry::PositionsIndex); > geo->setProperty(color, OSG::Geometry::ColorsIndex); > > // disable display list generation for this geometry > geo->setDlistCache(false); > > If the geometry changes frequently generating display lists is going to > hurt performance, so depending on how often you modify the trajectories > you probably want to turn it off. > > For the limited length lines where the positions basically form a > ring-buffer of the 100 last positions, you may want to use an index so > that you only have to overwrite the oldest position and color and adjust > the index - instead of rewriting all colors/positions. > > Cheers, > Carsten > > ------------------------------------------------------------------------------ > RSA(R) Conference 2012 > Save $700 by Nov 18 > Register now > http://p.sf.net/sfu/rsa-sfdev2dev1 > _______________________________________________ > Opensg-users mailing list > Opensg-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/opensg-users ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users