bhanu406 Newbie
Joined: 18 Nov 2016 Posts: 15
|
Posted: Tue Mar 14, 2017 5:40 am Post subject: Frame Rate |
|
|
Hi,
I am trying to add more than 3000 .3ds models to the scene at different places. I am getting too low frame rate i.e 2.6. Is there any algorithms to improve the frame rate in osg. I tried with following code
osg::ref_ptr<osg::Group> root = new osg::Group;
osg::Node* loadedModel = osgDB::readNodeFile("tree.3ds");
for (int i = 0; i<3500; ++i)
{
float x = randomValue(0.5f, 6.5f);
float y = randomValue(0.5f, 6.5f);
float z = randomValue(0.0f, 1.0f);
osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform;
trans->setMatrix(osg::Matrix::scale(0.001, 0.001, 0.001) * osg::Matrix::translate(x, y, z));
trans->addChild(loadedModel);
osg::ref_ptr<osg::Group> parent = new osg::Group;
parent->addChild( trans.get());
root->addChild(parent.get());
}
...
Thank you!
Cheers,
Bhanu |
|
robertosfield OSG Project Lead
Joined: 18 Mar 2009 Posts: 11604
|
Posted: Tue Mar 14, 2017 8:24 am Post subject: Frame Rate |
|
|
HI Bhanu,
Have a look at the osgforest example, it has various approach to
rendering large numbers of trees. The example uses texture quads as
the basis but the approaches can be generalized.
Robert.
On 14 March 2017 at 05:40, Bhanu Chandra <> wrote:
Quote:
|
Hi,
I am trying to add more than 3000 .3ds models to the scene at different places. I am getting too low frame rate i.e 2.6. Is there any algorithms to improve the frame rate in osg. I tried with following code
osg::ref_ptr<osg::Group> root = new osg::Group;
osg::Node* loadedModel = osgDB::readNodeFile("tree.3ds");
for (int i = 0; i<3500; ++i)
{
float x = randomValue(0.5f, 6.5f);
float y = randomValue(0.5f, 6.5f);
float z = randomValue(0.0f, 1.0f);
osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform;
trans->setMatrix(osg::Matrix::scale(0.001, 0.001, 0.001) * osg::Matrix::translate(x, y, z));
trans->addChild(loadedModel);
osg::ref_ptr<osg::Group> parent = new osg::Group;
parent->addChild( trans.get());
root->addChild(parent.get());
}
...
Thank you!
Cheers,
Bhanu
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70478#70478
|
------------------
Post generated by Mail2Forum |
|