Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

OpenSceneGraph and Polyvox
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=462
Page 1 of 1

Author:  kalwalt [ Mon Nov 26, 2012 2:19 pm ]
Post subject:  OpenSceneGraph and Polyvox

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

Author:  David Williams [ Tue Nov 27, 2012 9:41 am ]
Post subject:  Re: OpenSceneGraph and Polyvox

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).

Author:  kalwalt [ Tue Nov 27, 2012 10:46 am ]
Post subject:  Re: OpenSceneGraph and Polyvox

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.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/