Olivier Tournaire wrote:
> Thank you Carsten for the patch.
> 
> 
>     attached is a patch that adds a flipNormals function. It compiles
>     for me, but it's untested, so if you like I'd appreciate if you
>     could give it a try and let me know if it works.
> 
> 
> I will try it as soon as I know how I get a Geometry* from 
> SceneFileHandler::the()->read(...) which seems to return a 
> NodeTransitPtr. Any hint ?

1. Store the NodeTransitPtr in a NodeRefPtr.
2. Get the Core from the Node.
3. Cast the Core to Geometry. (assuming there are no transform/material 
groups in the way)

I.e.

NodeRefPtr node = SceneFileHandler::the()-read(...);
GeometryRefPtr geo = dynamic_pointer_cast<Geometry>(node->getCore());
if (!geo) {
     std::cout << "Oh noes! There are other cores in the way!\n";
     return false;
}

GeoVectorProperty* normals = geo->getNormals();
..

If you get stuck inside the if, try this to search all nodes for the 
first geometry core:

GeometryRefPtr geo;
std::vector<NodeRefPtr> children;
children.push_back(node);

while(!children.empty()) {
    NodeRefPtr n = children.back();

    geo = dynamic_pointer_cast<Geometry>(n->getCore());
    if (geo) {
       break;
    }
    children.pop_back();
    children.insert(children.end(), n->getMFChildren().begin(),
                                    n->getMFChildren().end());
}

if (!geo) {
   std::cout << "Oh noes. No geometry read by scenefilehandler?!?"
   return false;
}

// yay
geo->getNormals();

/Marcus




------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to