Here I am with an example that explains my scenario.
I commented the code with questions, hoping this is clearer.


Code:

// This is a core road that contains all data and must not know of OSG at all
class Road
{
        // This method builds vertices and indexes based on the internal data
        // It must not use osg::Arrays but C arrays or std::vectors
        void getPointsAndConnections(float*& oPoints, int& oPointSize, int*& 
oConnections, int& oConnectionSize);
}

// This class can not use OSG classes either (so no osg::Array here)
class WaveFrontWriter
{
        // This method is pleased to use getPointsAndConnection() since it 
returns useful data.
        // Here I can use a C array of an std::vector, not osg::Array
        void write(Road* road) {
                road->getPointsAndConnections(vertices, vsize, indices, isize);
                // here vertices, vsize, indices, isize are used for writing 
the file ...
        }
}

// Here is the 3D representation of the road
class OsgRoad
{
        // This method is also pleased to use getPointsAndConnection() of Road 
core class
        void draw(Road* road) {
                road->getPointsAndConnections(vertices, vsize, indices, isize);
                osg::Geometry* geometry = new osg::Geometry();
                // how to use incoming C arrays (or std::vectors would be also 
nice) in the following call?
                geometry->setVertexArray(<what here?>);
                // the following call luckily accepts C arrays but ...
                // 1) does it make a copy of the passed C array? (if so, that 
means memory duplication in my case)
                // 2) if not, is it responsible of deallocation?
                addPrimitiveSet(new 
osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES, isize, indices));
        }
}




Thank you in advance.
Gianni

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=60435#60435





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to