mika vaara wrote:
> Hello everyone,
> I've just started using OpenSG (1.8) and I've got a little problem on my
> hand. I've tried drawing a Torus. It works in 2 different ways, but doesn't
> work in the third way (using corednodes). Here is a sample of my program:
> ----------------------------------------------------------------
> //first in create geometry, a simple torus
> GeometryPtr pGeometry = makeTorusGeo(50.1, 100.2, 8, 16);
>
> //then i want to create a node from this geometry. Following code works:
> OSG::NodePtr pGeometryNode = OSG::Node::create();
> OSG::beginEditCP(pGeometryNode);
> pGeometryNode->setCore(pGeometry);
> OSG::endEditCP(pGeometryNode);
>
> //this code works too:
> NodePtr pGeometryNode = makeNodeFor(pGeometry);
Yup, these both amount to the same thing. makeNodeFor is a shortcut.
Creates node, use given core. That is what you want.
> //BUT, this code doesn't seem to work ? Why ?
> NodePtr pGeometryNode = makeCoredNode<Geometry>(&pGeometry);
That creates a new core and assigns it to the pointer you send in. I.e.
the previous object pointed to by pGeometry is lost (unless you kept
another pointer to it).
This is a different use case. If you look at makeCoredNode you'll see
something like:
template<class T>
NodePtr makeCoredNode<T>(T::Ptr &pCore)
{
NodePtr pNode = Node::create();
pCore = Geometry::create();
pNode->setCore(p);
return pNode;
}
> It compiles but nothing is drawn.
Yes, because it does a different thing. makeCoredNode is used you want
to create both a new core and a new node. makeNodeFor only creates the
node and uses an existing core.
Cheers.
/Marcus
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users