Сell multiplication

Grigory Krivyakin grisha992 at gmail.com
Mon Apr 13 23:38:26 PDT 2015


Hello

I try to create a simple crystal lattice and dont know how make it better. I create a original geode cell and use matrix translations:


Code:

osg::ref_ptr<osg::Group> root = new osg::Group;
osg::ref_ptr<osg::Geode> cell = Cell();

osg::ref_ptr<osg::MatrixTransform> transform = new osg::MatrixTransform;
transform->addChild(cell);
root->addChild(transform);   

for(int i = 0; i < 10; i++) {
  for(int j=0; j < 10; j++) {
    for(int k=0; k < 2; k++) {
      osg::ref_ptr<osg::MatrixTransform> transform = new osg::MatrixTransform;
      transform->setMatrix(osg::Matrix::translate(i*4.0f, j*4.0f, k*4.0f));
      transform->addChild(cell);
      root->addChild(transform);
    }
  }
}




this code creates the crystal lattice with 10 periods along axis X and Y, and 2 periods along Z, but i think it is bad way, can some one give me some advice, how make it right?


Sorry for my english. Thank you!

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








More information about the osg-users mailing list