Hi Julien, On 7 January 2015 at 07:12, Julien Valentin <[email protected]> wrote:
> I understand your feeling about the example, it was just for preliminary > test... > No problem, I'm happy for work in progress to be checked in as long as it's a stepping stone rather than a final destination. > If you want I'm working on a TransformFeedBackGeometry that integrate > better in osg > (As interleaved_attribs is not allowed in osg it only works for > separate_buffer feedback mode: > the only difference with a normal Geometry is that all vecArray are stored > in a differents buffers. > ) > Interleaved arrays is interesting problem to tackle, how to implement them in a way that is generic enough for various classes that read vertex arrays to handle is the key challenge. Currently the use of std::vector in the osg::Array subclasses is part of the restriction, if one would way to do this for an interleaved array then you'd need to create a range of small classes that are interleaved i.e. Vec3_Vec3_Vec4 etc. However, this approach would be really long winded and wouldn't be comptible with any of the present classes that read from arrays. One approach I have considered is to have osg::Array not use std::vector<> instead just implement a std::vector<> like interface to make it compatible, then have the osg::Array hold a pointer to a Buffer, the offset into the buffer and the stride of the Buffer. For a standard Vec3Array then Buffer would just similar to what a std::vector<Vec3> would hold, with the offset set to 0, stride set to 12 bytes. The iterators would pass back a Vec3 and increment by 12 bytes. If one then wanted the Vec3Array to share a Buffer that is interleaved, say with a Vec3 and Vec4 you'd have an offset of 0, but a stride of 28, with the iterators incrementing by 28 bytes as it moves through the Buffer. With this approach one would need to have a mechanism for setting up the Buffer in a way that is done silently behind the scenes when using the OSG in the traditional way with non interleaved arrays, but still allow one to construct the various Vec3Array etc by passing in a Buffer that you've pre-allocated with the appropriate sizes, offsets and strides. The osg::Geometry class would then check for interleaved arrays and use the GL interleaved calls for the whole Buffer rather than each individual array. While this might be a possible route forward it isn't a trivial change, retaining decent backwards compatibility being one of the challenges. An another approach is to simple have a custom Drawable or Geometry subclass that implements interleaved arrays. > But I face the problem that one could want to generate partially their > geometry( for ex: generate vertexcoord but keep texcoord), so i may add > properties for it. > I'm not clear on your suggestion. Is it that you'd want to set up an interleaved VBO that gets passed to the GPU with vertex and texcoord arrays all in place, then have a shader write to jut the vertex coords of the interleaved VBO? Robert.
_______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
