HI Ben,

The osg-users mailing list/forum is the appropriate place for support.

I've read your post, the code you provided and screenshots and don't really
know what to make of it all.  I'd guess that others will be similarly
confused but what might be work and what might not be.

I don't understand why you are subclassing from OSG classes for this type
of work, for 3rd parties like ourselves not party to the the code in these
subclasses and without any knowledge of why felt the need to do this
subclassing it really kinda hard to know where you are going with this code.

I couldn't spot any obvious errors in your code, but I sure wouldn't write
a tool to visualize a road network in the way you have - having lots of
separate scene graph objects and state will introduce CPU and GPU overheads
that will prevent getting the best performance for your system.

You don't mention what hardware/GL driver/OS/OSG version you are using.
This is all is important when trying to track down problems.  It could be
that you have a buggy OpenGL driver and little to do with your own code.
There isn't much we can say to help at this point as there is just way too
many unknowns about your software, hardware, OS, exactly nature of the
problem etc.

Robert.


On 30 August 2014 12:32, Ben Morgan <nee...@gmail.com> wrote:

> I did post this question on StackOverflow (
>
> http://stackoverflow.com/questions/25576762/warped-scene-with-two-sets-of-geodes
> ), but I assume that this is a more appropriate place for questions.
>
> I have a few objects that I want to combine into a scene graph:
>
> Street inherits from Geode and has a Geometry child drawable made up
> of a GL_LINE_STRIP.
> Pointer inherits from PositionAttitudeTransform and contains a Geode
> which contains two Geometry polygons.
>
> When I add a bunch of Streets to a Group, it looks just fine. When I
> add only the Pointer to a Group, it also looks fine. But if I somehow
> have them both in the scene, the second one is screwed up. (This does
> not happen if I have only two Pointers.) I posted some screenshots on
> the StackOverflow site, in case you want to see them. Probably I’m
> making some simple mistake—but I can’t see it!
>
> Here is some code that causes the problem (I tried to shorten it a little):
>
> // My libraries:
> #include <asl/util/draw.h>
> #include <asl/util/color.h>
> using namespace asl;
>
> #include <straph/point.h>
> #include <straph/straph.h>
> using namespace straph;
>
> // Standard and OSG libraries:
> #include <utility>
> #include <boost/tuple/tuple.hpp> // tie
> using namespace std;
>
> #include <osg/ref_ptr>
> #include <osg/Array>
> #include <osg/Geometry>
> #include <osg/Group>
> #include <osg/LineWidth>
> using namespace osg;
>
> #include <osgUtil/Optimizer>
> #include <osgViewer/Viewer>
> #include <osgViewer/ViewerEventHandlers>
> using namespace osgViewer;
>
> Geode* createStreet(const straph::Polyline& path, double width, const
> Color& color)
> {
>     ref_ptr<Geometry> geom (new Geometry);
>
>     // Set the shape:
>     ref_ptr<Vec3dArray> array (new Vec3dArray(path.size()));
>     for (unsigned i = 0; i < path.size(); ++i) {
>         (*array)[i] = toVec3d(path[i]);
>     }
>     geom->setVertexArray(array.get());
>     geom->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP, 0,
> array->size()));
>
>     // Set the normals:
>     ref_ptr<Vec3Array> normals (new Vec3Array(1));
>     (*normals)[0].set( 0.0f, 0.0f, 1.0f );
>     geom->setNormalArray( normals.get() );
>     geom->setNormalBinding( Geometry::BIND_OVERALL );
>
>     // Set the colors:
>     ref_ptr<Vec4Array> colors = new Vec4Array();
>     colors->push_back(color.get());
>     geom->setColorArray(colors);
>     geom->setColorBinding(osg::Geometry::BIND_OVERALL);
>
>     Geode* g = new Geode();
>     g->addDrawable(geom.get());
>
>     // Set the line width.
>     ref_ptr<LineWidth> lwidth (new LineWidth);
>     lwidth->setWidth(width);
>     g->getOrCreateStateSet()->setAttributeAndModes(lwidth,
> StateAttribute::ON);
>
>     return g;
> }
>
> Group* load_streets()
> {
>     unique_ptr<Straph> graph = read_shapefile("mexico/roads", 6);
>
>     Group* root = new Group();
>     boost::graph_traits<straph::Straph>::edge_iterator ei, ee;
>     for (boost::tie(ei, ee) = edges(*graph); ei != ee; ++ei) {
>         const straph::Segment& s = (*graph)[*ei];
>         root->addChild(createStreet(s.polyline, 2.0,
> TangoColor::Aluminium4));
>     }
>     return root;
> }
>
> int main(int, char**)
> {
>     Group* root = load_streets();
>     Pointer* p = new Pointer(6.0, TangoColor::Scarlet3, TangoColor::Black);
>     root->addChild(p);
>
>     Viewer viewer;
>     viewer.setSceneData(root);
>     viewer.getCamera()->setClearColor(Color(TangoColor::White).get());
>     viewer.run();
> }
>
> Thanks for the help! :-)
> 
> –Ben Morgan
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to