Discussion:
[osg-users] Converting PrimitiveSet to use triangles instead of triangle strips / fans?
Jad Killian
2018-07-27 12:06:29 UTC
Permalink
Hi,

When I import a .obj file with readNodeFile, the result is a triangle strip instead of triangles. Even if the .obj file is a simple square with 4 vertices and 2 triangular faces, the resulting primitive set in the geode geometry contains
1 face, 4 indices with mode = 5 (TRIANGLE_STRIP).

I tried using the osg::Optimizer, but it doesn't seem to do anything:



Code:
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filepath.toStdString());

osgUtil::Optimizer optimizer;
optimizer.optimize(node, osgUtil::Optimizer::INDEX_MESH);



for optimizer flags I tried INDEX_MESH, TESSELLATE_GEOMETRY, DEFAULT_OPTIMIZATIONS, nothing seems to work.

Any ideas?

Thanks

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74401#74401
L. Voerman
2018-08-15 08:41:02 UTC
Permalink
I tend to use
set OSG_OPTIMIZER=INDEX_MESH VERTEX_POSTTRANSFORM VERTEX_PRETRANSFORM
for these, but there might be something else preventing the optimizer from
changing your geometry.
set OSG_OPTIMIZER=STATIC_OBJECT_DETECTION INDEX_MESH VERTEX_POSTTRANSFORM
VERTEX_PRETRANSFORM MERGE_GEOMETRY MERGE_GEODES
might do the trick
Laurens.
Post by Jad Killian
Hi,
When I import a .obj file with readNodeFile, the result is a triangle
strip instead of triangles. Even if the .obj file is a simple square with 4
vertices and 2 triangular faces, the resulting primitive set in the geode
geometry contains
1 face, 4 indices with mode = 5 (TRIANGLE_STRIP).
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filepath.toStdString());
osgUtil::Optimizer optimizer;
optimizer.optimize(node, osgUtil::Optimizer::INDEX_MESH);
for optimizer flags I tried INDEX_MESH, TESSELLATE_GEOMETRY,
DEFAULT_OPTIMIZATIONS, nothing seems to work.
Any ideas?
Thanks
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74401#74401
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Julien Valentin
2018-08-15 22:13:28 UTC
Permalink
INDEX_mesh don't reindex indexed
I fix it on my branch introducing a forceReindex parameter to the IndexMeshVisitor and use it witout an attached Optimizer
I tend to use set OSG_OPTIMIZER=INDEX_MESH VERTEX_POSTTRANSFORM VERTEX_PRETRANSFORM
for these, but there might be something else preventing the optimizer from changing your geometry.
set OSG_OPTIMIZER=STATIC_OBJECT_DETECTION  INDEX_MESH VERTEX_POSTTRANSFORM VERTEX_PRETRANSFORM MERGE_GEOMETRY MERGE_GEODES
might do the trick
Laurens.
Post by Jad Killian
Hi,
When I import a .obj file with readNodeFile, the result is a triangle strip instead of triangles. Even if the .obj file is a simple square with 4 vertices and 2 triangular faces, the resulting primitive set in the geode geometry contains
1 face, 4 indices with mode = 5 (TRIANGLE_STRIP).
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filepath.toStdString());
osgUtil::Optimizer optimizer;
optimizer.optimize(node, osgUtil::Optimizer::INDEX_MESH);
for optimizer flags I tried INDEX_MESH, TESSELLATE_GEOMETRY, DEFAULT_OPTIMIZATIONS, nothing seems to work.
Any ideas?
Thanks
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74401#74401 (http://forum.openscenegraph.org/viewtopic.php?p=74401#74401)
_______________________________________________
osg-users mailing list
()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
------------------
Post generated by Mail2Forum
------------------------
Twirling twirling twirling toward freedom

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74538#74538
Julien Valentin
2018-08-15 22:23:23 UTC
Permalink
https://github.com/openscenegraph/OpenSceneGraph/pull/596
Post by Julien Valentin
INDEX_mesh don't reindex indexed
I fix it on my branch introducing a forceReindex parameter to the IndexMeshVisitor and use it witout an attached Optimizer
I tend to use set OSG_OPTIMIZER=INDEX_MESH VERTEX_POSTTRANSFORM VERTEX_PRETRANSFORM
for these, but there might be something else preventing the optimizer from changing your geometry.
set OSG_OPTIMIZER=STATIC_OBJECT_DETECTION  INDEX_MESH VERTEX_POSTTRANSFORM VERTEX_PRETRANSFORM MERGE_GEOMETRY MERGE_GEODES
might do the trick
Laurens.
Post by Jad Killian
Hi,
When I import a .obj file with readNodeFile, the result is a triangle strip instead of triangles. Even if the .obj file is a simple square with 4 vertices and 2 triangular faces, the resulting primitive set in the geode geometry contains
1 face, 4 indices with mode = 5 (TRIANGLE_STRIP).
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filepath.toStdString());
osgUtil::Optimizer optimizer;
optimizer.optimize(node, osgUtil::Optimizer::INDEX_MESH);
for optimizer flags I tried INDEX_MESH, TESSELLATE_GEOMETRY, DEFAULT_OPTIMIZATIONS, nothing seems to work.
Any ideas?
Thanks
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74401#74401 (http://forum.openscenegraph.org/viewtopic.php?p=74401#74401)
_______________________________________________
osg-users mailing list
()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
------------------
Post generated by Mail2Forum
------------------------
Twirling twirling twirling toward freedom

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74539#74539
Jordi Torres
2018-08-16 06:01:08 UTC
Permalink
Hi,

There is an option in the obj plugin to avoid tristrips. It's probably
better to try this cause tristripping is not cheap depending on the
geometry.

From the top of my head is something like "noTrisStripPolygons".

Hope it helps.

El jue., 16 ago. 2018 12:30 a. m., Julien Valentin <
Post by Julien Valentin
INDEX_mesh don't reindex indexed
I fix it on my branch introducing a forceReindex parameter to the
IndexMeshVisitor and use it witout an attached Optimizer
I tend to use set OSG_OPTIMIZER=INDEX_MESH VERTEX_POSTTRANSFORM
VERTEX_PRETRANSFORM
for these, but there might be something else preventing the optimizer
from changing your geometry.
set OSG_OPTIMIZER=STATIC_OBJECT_DETECTION INDEX_MESH
VERTEX_POSTTRANSFORM VERTEX_PRETRANSFORM MERGE_GEOMETRY MERGE_GEODES
might do the trick
Laurens.
Post by Jad Killian
Hi,
When I import a .obj file with readNodeFile, the result is a triangle
strip instead of triangles. Even if the .obj file is a simple square with 4
vertices and 2 triangular faces, the resulting primitive set in the geode
geometry contains
Post by Jad Killian
1 face, 4 indices with mode = 5 (TRIANGLE_STRIP).
osg::ref_ptr<osg::Node> node =
osgDB::readNodeFile(filepath.toStdString());
Post by Jad Killian
osgUtil::Optimizer optimizer;
optimizer.optimize(node, osgUtil::Optimizer::INDEX_MESH);
for optimizer flags I tried INDEX_MESH, TESSELLATE_GEOMETRY,
DEFAULT_OPTIMIZATIONS, nothing seems to work.
Post by Jad Killian
Any ideas?
Thanks
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74401#74401 (
http://forum.openscenegraph.org/viewtopic.php?p=74401#74401)
Post by Jad Killian
_______________________________________________
osg-users mailing list
()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
(http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
)
------------------
Post generated by Mail2Forum
------------------------
Twirling twirling twirling toward freedom
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74538#74538
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Julien Valentin
2018-08-16 19:40:45 UTC
Permalink
Hi Jordi
I admit I haven't read the question but the topic title remind me of a pr i haven't made...
Should'nt it be default obj plugin behavior not to strip instead of an option one have to set?
Is this pr valid to you?
https://github.com/openscenegraph/OpenSceneGraph/pull/597
Cheers
Hi, 
There is an option in the obj plugin to avoid tristrips. It's probably better to try this cause tristripping is not cheap depending on the geometry. 
From the top of my head is something like "noTrisStripPolygons". 
Hope it helps.
Post by Julien Valentin
INDEX_mesh don't reindex indexed
I fix it on my branch introducing a forceReindex parameter to the IndexMeshVisitor and use it witout an attached Optimizer
I tend to use set OSG_OPTIMIZER=INDEX_MESH VERTEX_POSTTRANSFORM VERTEX_PRETRANSFORM
for these, but there might be something else preventing the optimizer from changing your geometry.
set OSG_OPTIMIZER=STATIC_OBJECT_DETECTION  INDEX_MESH VERTEX_POSTTRANSFORM VERTEX_PRETRANSFORM MERGE_GEOMETRY MERGE_GEODES
might do the trick
Laurens.
Post by Jad Killian
Hi,
When I import a .obj file with readNodeFile, the result is a triangle strip instead of triangles. Even if the .obj file is a simple square with 4 vertices and 2 triangular faces, the resulting primitive set in the geode geometry contains
1 face, 4 indices with mode = 5 (TRIANGLE_STRIP).
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filepath.toStdString());
osgUtil::Optimizer optimizer;
optimizer.optimize(node, osgUtil::Optimizer::INDEX_MESH);
for optimizer flags I tried INDEX_MESH, TESSELLATE_GEOMETRY, DEFAULT_OPTIMIZATIONS, nothing seems to work.
Any ideas?
Thanks
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74401#74401 (http://forum.openscenegraph.org/viewtopic.php?p=74401#74401) (http://forum.openscenegraph.org/viewtopic.php?p=74401#74401 (http://forum.openscenegraph.org/viewtopic.php?p=74401#74401))
_______________________________________________
osg-users mailing list
  ()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org))
  ------------------
Post generated by Mail2Forum
------------------------
Twirling twirling twirling toward freedom
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74538#74538 (http://forum.openscenegraph.org/viewtopic.php?p=74538#74538)
_______________________________________________
osg-users mailing list
()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
------------------
Post generated by Mail2Forum
------------------------
Twirling twirling twirling toward freedom

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74556#74556
Julien Valentin
2018-08-16 19:50:42 UTC
Permalink
Oups made mistake in given pr good one is
I should have also remove the comment talking about perf enancement (so 90's)
Tristrip is good for HW but Optimizer generate multiple patch so duplicate one prim set into several (Draw Overhead)
Indexed Triangles nowadays have realy good perf

https://github.com/openscenegraph/OpenSceneGraph/pull/598
Post by Julien Valentin
Hi Jordi
I admit I haven't read the question but the topic title remind me of a pr i haven't made...
Should'nt it be default obj plugin behavior not to strip instead of an option one have to set?
Is this pr valid to you?
https://github.com/openscenegraph/OpenSceneGraph/pull/597
Cheers
Hi, 
There is an option in the obj plugin to avoid tristrips. It's probably better to try this cause tristripping is not cheap depending on the geometry. 
From the top of my head is something like "noTrisStripPolygons". 
Hope it helps.
Post by Julien Valentin
INDEX_mesh don't reindex indexed
I fix it on my branch introducing a forceReindex parameter to the IndexMeshVisitor and use it witout an attached Optimizer
I tend to use set OSG_OPTIMIZER=INDEX_MESH VERTEX_POSTTRANSFORM VERTEX_PRETRANSFORM
for these, but there might be something else preventing the optimizer from changing your geometry.
set OSG_OPTIMIZER=STATIC_OBJECT_DETECTION  INDEX_MESH VERTEX_POSTTRANSFORM VERTEX_PRETRANSFORM MERGE_GEOMETRY MERGE_GEODES
might do the trick
Laurens.
Post by Jad Killian
Hi,
When I import a .obj file with readNodeFile, the result is a triangle strip instead of triangles. Even if the .obj file is a simple square with 4 vertices and 2 triangular faces, the resulting primitive set in the geode geometry contains
1 face, 4 indices with mode = 5 (TRIANGLE_STRIP).
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filepath.toStdString());
osgUtil::Optimizer optimizer;
optimizer.optimize(node, osgUtil::Optimizer::INDEX_MESH);
for optimizer flags I tried INDEX_MESH, TESSELLATE_GEOMETRY, DEFAULT_OPTIMIZATIONS, nothing seems to work.
Any ideas?
Thanks
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74401#74401 (http://forum.openscenegraph.org/viewtopic.php?p=74401#74401) (http://forum.openscenegraph.org/viewtopic.php?p=74401#74401 (http://forum.openscenegraph.org/viewtopic.php?p=74401#74401))
_______________________________________________
osg-users mailing list
  ()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org) (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org))
  ------------------
Post generated by Mail2Forum
------------------------
Twirling twirling twirling toward freedom
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74538#74538 (http://forum.openscenegraph.org/viewtopic.php?p=74538#74538)
_______________________________________________
osg-users mailing list
()
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
------------------
Post generated by Mail2Forum
------------------------
Twirling twirling twirling toward freedom

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

Loading...