It is currently Thu Aug 17, 2017 6:06 am


All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: OpenSceneGraph and Polyvox
PostPosted: Mon Nov 26, 2012 2:19 pm 

Joined: Mon Oct 15, 2012 4:33 pm
Posts: 52
have you ever considered to use OpenSceneGraph http://www.openscenegraph.org/projects/ ... troduction with Polyvox? If you do not you ever think I'm starting to consider it, as engine to work on. I worked a little with him and has many features and honestly I prefer toOgre ( nothing to say to it, it's a super game engine !). The advantage for me is that you can run it with openFrameworks,(sse here: https://github.com/stmh/ofxOpenSceneGraph) and this makes it easier for certain aspects of database management, apply some effects like shadows and lights...
if anyone has ever had experience with OSG and Polyvox .. well, let me know!

Walter


Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenSceneGraph and Polyvox
PostPosted: Tue Nov 27, 2012 9:41 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1814
I'm aware of OpenSceneGraph but I've never worked with it. I would expect it to be straight forward to integrate with PolyVox as long as it provides a way for you to specify you own geometry. You should be able to copy across the index and vertex data which PolyVox provides (maybe with some conversion).


Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenSceneGraph and Polyvox
PostPosted: Tue Nov 27, 2012 10:46 am 

Joined: Mon Oct 15, 2012 4:33 pm
Posts: 52
It was very easy to integrate Polyvox to OpenSceneGraph As you said, just a matter of copy of vertices and indices! here part of the code:
Code:
   //Convienient access to the vertices and indices
   const vector<uint32_t>& vecIndices = mesh.getIndices();
   const vector<PositionMaterialNormal>& vecVertices = mesh.getVertices();

   osg::ref_ptr<osg::DrawElementsUInt> indices = new osg::DrawElementsUInt(GL_TRIANGLES, mesh.getNoOfIndices());

     for(int i = 0; i < mesh.getNoOfIndices(); i++){
      PositionMaterialNormal vert0 = vecVertices[i];
    (*indices)[i] = vecIndices[i];

    }

    // The vertex array shared by both the polygon and the border
    osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(mesh.getNoOfVertices());

    for(int i = 0; i < mesh.getNoOfVertices(); i++){
      PositionMaterialNormal vert0 = vecVertices[i];
    (*vertices)[i].set(vert0.getPosition().getX(),vert0.getPosition().getY(),vert0.getPosition().getZ());

    }

     // The normal array
    osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array(mesh.getNoOfVertices());

     for(int i = 0; i < mesh.getNoOfVertices(); i++){
          PositionMaterialNormal vert0 = vecVertices[i];
     (*normals)[0].set(vert0.getPosition().getX(),vert0.getPosition().getY(),vert0.getPosition().getZ());

    }

    // create white material
   Material *material = new Material();
   material->setDiffuse(Material::FRONT,  Vec4(1.0, 1.0, 1.0, 1.0));
   material->setSpecular(Material::FRONT, Vec4(0.0, 0.0, 0.0, 1.0));
   material->setAmbient(Material::FRONT,  Vec4(0.1, 0.1, 0.1, 1.0));
   material->setEmission(Material::FRONT, Vec4(0.0, 0.0, 0.0, 1.0));
   material->setShininess(Material::FRONT, 25.0);

    // Construct the polygon geometry
    osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
    geom->setDataVariance( osg::Object::DYNAMIC );
    geom->setUseDisplayList( false );
    geom->setUseVertexBufferObjects( true );
    geom->setVertexArray( vertices.get() );
    geom->setColorBinding( osg::Geometry::BIND_OVERALL );
    geom->addPrimitiveSet( indices.get() );

    geom->getOrCreateStateSet()->setAttribute(material);
 
    // Add them to the scene graph
    osg::ref_ptr<osg::Geode> geode = new osg::Geode;
    geode->addDrawable( geom.get() );


i have also create a Cmake project , but it must be optimized. maybe i will open another topic for this.
Also consider that OSG has a lot of features even for optimize the geometry: http://www.openscenegraph.org/documenta ... 01494.html
but i have to further explore in depth this field.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net