Re: [osg-users] speed up the loading

2012-10-23 Thread Jason Daly
On 10/22/2012 11:15 PM, wh_xiexing wrote:
> i have hundreds of millions of points to render. i think the Geometry
> 's setVertexArray (Vec3Array) is time consuming .
> for every point , it must construct a Vec3 class, and put it into the
> array.


Not true, you can create a Vec3Array out of an array of floats with
nothing but a type cast. The Vec* and Vec*Array classes were designed to
line up data contiguously in memory so that OpenGL could use it directly
and efficiently (note that there are no virtual methods in the Vec*
classes).

There's no reason to modify OSG to do what you want:

// Construct an array of floats
float * lotsOfPoints = new float[count];

// Fill up the float array with point data
...

// Construct a Vec3Array out of the float data
ref_ptr array = new Vec3Array(count/3, (Vec3 *) lotsOfPoints);

// Assign the Vec3Array to Geometry
ref_ptr geom = new Geometry();
geom->setVertexArray(array);

--"J"

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] speed up the loading

2012-10-23 Thread Ulrich Hertlein
Hi Shawl,

On 23/10/12 14:15, wh_xiexing wrote:
>   i have hundreds of millions of points to render.i  think the Geometry 
> 's 
> setVertexArray (Vec3Array)  is time consuming .
>  
> for every point ,  it must construct a Vec3 class, and put it into the array.

Not quite sure which setVertexArray you are talking about, but the one in 
osg::Geometry is
simply a pointer assignment - nothing is copied or constructed.

/ulrich

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org