本文整理汇总了C++中GeometryUnrecPtr::getNormals方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryUnrecPtr::getNormals方法的具体用法?C++ GeometryUnrecPtr::getNormals怎么用?C++ GeometryUnrecPtr::getNormals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeometryUnrecPtr
的用法示例。
在下文中一共展示了GeometryUnrecPtr::getNormals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
//.........这里部分代码省略.........
if ( (meshIndexMask & 4) && normalPtr->size() > 0 )
{
geoPtr->setNormals ( normalPtr );
normalIndexPtr = GeoUInt32Property::create();
if(!isSingleIndex)
geoPtr->setIndex(normalIndexPtr, Geometry::NormalsIndex);
}
else
{
geoPtr->setNormals ( NULL );
}
if (meshI->mtlPtr == NULL)
{
meshI->mtlPtr = SimpleTexturedMaterial::create();
meshI->mtlPtr->setDiffuse( Color3f( .8f, .8f, .8f ) );
meshI->mtlPtr->setSpecular( Color3f( 1.f, 1.f, 1.f ) );
meshI->mtlPtr->setShininess( 20.f );
}
geoPtr->setMaterial ( meshI->mtlPtr );
for ( faceI = meshI->faceList.begin();
faceI != meshI->faceList.end(); faceI++)
{
n = UInt32(faceI->tieVec.size());
// add the lens entry
lensPtr->push_back(n);
// add the type entry
typePtr->push_back(GL_POLYGON);
// create the index values
for (i = 0; i < n; i++)
{
if (isSingleIndex)
{
posIndexPtr->push_back(faceI->tieVec[i].index[0]);
}
else
{
posIndexPtr->push_back(faceI->tieVec[i].index[0]);
if(texIndexPtr != NULL)
texIndexPtr->push_back(faceI->tieVec[i].index[1]);
if(normalIndexPtr != NULL)
normalIndexPtr->push_back(faceI->tieVec[i].index[2]);
}
}
}
if(isSingleIndex)
{
geoPtr->setIndex(posIndexPtr, Geometry::PositionsIndex);
geoPtr->setIndex(posIndexPtr, Geometry::NormalsIndex );
geoPtr->setIndex(posIndexPtr, Geometry::TexCoordsIndex);
}
// need to port the geometry functions ...
createSharedIndex( geoPtr );
// check if we have normals
// need to port the geometry functions ...
if(geoPtr->getNormals() == NULL)
calcVertexNormals(geoPtr);
// create and link the node
nodePtr = Node::create();
nodePtr->setCore( geoPtr );
if (meshList.size() > 1)
{
if (rootPtr == NULL)
{
rootPtr = Node::create();
GroupUnrecPtr tmpPtr = Group::create();
rootPtr->setCore ( tmpPtr );
rootPtr->addChild(nodePtr);
}
else
{
rootPtr->addChild(nodePtr);
}
}
else
{
rootPtr = nodePtr;
}
}
}
}
SceneFileHandler::the()->updateReadProgress(100);
commitChanges();
return NodeTransitPtr(rootPtr);
}
示例2: processTransformations
void MergeGraphOp::processTransformations(Node * const node)
{
MFUnrecChildNodePtr::const_iterator mfit = node->getMFChildren()->begin();
MFUnrecChildNodePtr::const_iterator mfen = node->getMFChildren()->end ();
std::vector<Node *> toAdd;
std::vector<Node *> toSub;
for ( ; mfit != mfen; ++mfit )
{
bool special=isInExcludeList(*mfit);
bool leaf=isLeaf(*mfit);
bool empty=true;
//if a transformation:
if ((*mfit)->getCore()->getType().isDerivedFrom(
Transform::getClassType()))
{
if (!leaf && !special)
{
//try to apply it to children geometries
//move all "moveable" children one level up
//if empty after that, delete it
MFUnrecChildNodePtr::const_iterator it2 =
(*mfit)->getMFChildren()->begin();
MFUnrecChildNodePtr::const_iterator en2 =
(*mfit)->getMFChildren()->end ();
for ( ; it2 != en2; ++it2 )
{
if (!isInExcludeList(*it2))
{
//check if geometry
if ((*it2)->getCore()->getType().isDerivedFrom(
Geometry::getClassType()))
{
if(!isLeaf(*it2))
{
//hmm...bad tree...
empty=false;
}
else
{
//it is a leaf geometry, so apply the transformation
Geometry *geo_old =
dynamic_cast<Geometry *>(
(*it2)->getCore());
//GeometryPtr geo = geo_old->clone();
GeometryUnrecPtr geo =
dynamic_pointer_cast<Geometry>(
OSG::deepClone(geo_old, "Material"));
Transform *t =
dynamic_cast<Transform *>(
(*mfit)->getCore());
GeoPnt3fProperty *pos = dynamic_cast<GeoPnt3fProperty *>(geo->getPositions());
GeoVec3fProperty *norm = dynamic_cast<GeoVec3fProperty *>(geo->getNormals());
GeoColor3fProperty *color = dynamic_cast<GeoColor3fProperty *>(geo->getColors());
GeoColor3fProperty *scolor = dynamic_cast<GeoColor3fProperty *>(geo->getSecondaryColors());
GeoVec3fProperty *texcoord0 = dynamic_cast<GeoVec3fProperty *>(geo->getTexCoords());
GeoVec3fProperty *texcoord1 = dynamic_cast<GeoVec3fProperty *>(geo->getTexCoords1());
GeoVec3fProperty *texcoord2 = dynamic_cast<GeoVec3fProperty *>(geo->getTexCoords2());
GeoVec3fProperty * texcoord3 = dynamic_cast<GeoVec3fProperty *>(geo->getTexCoords3());
Matrix m=t->getMatrix();
if(pos!=NULL)
{
for(UInt32 i = 0; i < pos->size(); ++i)
{
Pnt3f p=pos->getValue(i);
m.multFull(p, p);
pos->setValue(p,i);
}
}
if(norm!=NULL)
{
for(UInt32 i = 0; i < norm->size(); ++i)
{
Vec3f n=norm->getValue(i);
m.mult(n, n);
n.normalize();
norm->setValue(n,i);
}
}
if(color != NULL && _color_is_vector)
{
for(UInt32 i = 0; i < color->size(); ++i)
{
Color3f c = color->getValue(i);
Vec3f v;
v.setValue(c.getValuesRGB());
m.mult(v, v);
v.normalize();
c.setValuesRGB(v[0], v[1], v[2]);
color->setValue(c,i);
}
}
//.........这里部分代码省略.........