Hi,

I'm trying to use the calcVertexNormals function in order
to regenerate my surface normals. I first try to share all
possible vertices, then I run calcVertexNormals on the
geometry node (see the "calc" method below). The problem is
that not all normals are updated after a first run. If I
recall the "calc" method a second time, all normals are
finally updated. I can't see what the problem is...

Anything wrong in the code below?

Regards,

  Toni


Action::ResultE
CalcNormals::createShareTraverse(NodePtr& curNode)
{
  if ((curNode==NullFC)) return Action::Continue;

  GeometryPtr geo = GeometryPtr::dcast(curNode->getCore());


  if( geo != NullFC )
      createSharedIndex(geo);


  return Action::Continue;
}


Action::ResultE
CalcNormals::calcNormalsTraverse(NodePtr& curNode)
{
    if ((curNode==NullFC)) return Action::Continue;

    GeometryPtr geo = GeometryPtr::dcast(curNode->getCore());

    if( geo != NullFC )
        calcVertexNormals(geo, deg2rad(m_fCreaseAngle));

    return Action::Continue;
}


bool
CalcNormals::calc( std::vector <osg::NodePtr> &nodeList )
{
    for(unsigned int i=0;i<nodeList.size();++i)
        {
        traverse(nodeList[i],
                osgTypedMethodFunctor1ObjPtrCPtrRef     <Action::ResultE, 
CalcNormals,
NodePtr>(this, CalcNormals::createShareTraverse));
    }

        for(unsigned int i=0;i<nodeList.size();++i)
        {
        traverse(nodeList[i],
                osgTypedMethodFunctor1ObjPtrCPtrRef     <Action::ResultE, 
CalcNormals,
NodePtr>(this, CalcNormals::calcNormalsTraverse));
    }

    return true;
}

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to