本文整理汇总了C++中GeometryPtr::getColors方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryPtr::getColors方法的具体用法?C++ GeometryPtr::getColors怎么用?C++ GeometryPtr::getColors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeometryPtr
的用法示例。
在下文中一共展示了GeometryPtr::getColors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeGeo
Action::ResultE changeGeo(NodePtr& node)
{
GeometryPtr geo = GeometryPtr::dcast(node->getCore());
if(geo == NullFC)
return Action::Continue;
GeoColors3fPtr colors = GeoColors3fPtr::dcast(geo->getColors());
if(colors == NullFC)
{
colors = GeoColors3f::create();
colors->resize(geo->getPositions()->getSize());
// Change the geometry to use the new colors
beginEditCP(geo, Geometry::ColorsFieldMask);
geo->setColors(colors);
// If multi-indexed, make the colors use the same index as
// the geometry
if(geo->getMFIndexMapping()->size() > 0)
{
Int16 pind = geo->calcMappingIndex(Geometry::MapPosition);
if(pind < 0)
{
FFATAL(("Multi-indexed, but no positions index???\n"));
return Action::Continue;
}
// This makes the colors use the same indices as the positions
geo->editIndexMapping(pind) |= Geometry::MapColor;
}
endEditCP (geo, Geometry::ColorsFieldMask);
}
beginEditCP(geo, Geometry::ColorsFieldMask);
beginEditCP(colors);
Real32 size = colors->getSize();
for(UInt32 i=0;i<size;++i)
{
Color3f c;
c[0] = ((Real32) i) / size;
c[1] = 0.0f;
c[2] = 0.0f;
colors->setValue(c, i);
}
endEditCP(colors);
endEditCP(geo, Geometry::ColorsFieldMask);
return Action::Continue;
}
示例2: verifyIndexMap
bool VerifyGraphOp::verifyIndexMap(GeometryPtr &geo, bool &repair)
{
repair = false;
if(geo == NullFC)
return true;
if(geo->getIndices() == NullFC)
return true;
if(!geo->getMFIndexMapping()->empty())
return true;
if(geo->getPositions() == NullFC)
return true;
UInt32 positions_size = geo->getPositions()->getSize();
UInt32 normals_size = 0;
if(geo->getNormals() != NullFC)
normals_size = geo->getNormals()->getSize();
UInt32 colors_size = 0;
if(geo->getColors() != NullFC)
colors_size = geo->getColors()->getSize();
UInt32 secondary_colors_size = 0;
if(geo->getSecondaryColors() != NullFC)
secondary_colors_size = geo->getSecondaryColors()->getSize();
UInt32 texccords_size = 0;
if(geo->getTexCoords() != NullFC)
texccords_size = geo->getTexCoords()->getSize();
UInt32 texccords1_size = 0;
if(geo->getTexCoords1() != NullFC)
texccords1_size = geo->getTexCoords1()->getSize();
UInt32 texccords2_size = 0;
if(geo->getTexCoords2() != NullFC)
texccords2_size = geo->getTexCoords2()->getSize();
UInt32 texccords3_size = 0;
if(geo->getTexCoords3() != NullFC)
texccords3_size = geo->getTexCoords3()->getSize();
/*
printf("sizes: %u %u %u %u %u %u %u %u\n", positions_size, normals_size,
colors_size, secondary_colors_size,
texccords_size, texccords1_size,
texccords2_size, texccords3_size);
*/
if((positions_size == normals_size || normals_size == 0) &&
(positions_size == colors_size || colors_size == 0) &&
(positions_size == secondary_colors_size || secondary_colors_size == 0) &&
(positions_size == texccords_size || texccords_size == 0) &&
(positions_size == texccords1_size || texccords1_size == 0) &&
(positions_size == texccords2_size || texccords2_size == 0) &&
(positions_size == texccords3_size || texccords3_size == 0)
)
{
UInt16 indexmap = 0;
if(positions_size > 0)
indexmap |= Geometry::MapPosition;
if(normals_size > 0)
indexmap |= Geometry::MapNormal;
if(colors_size > 0)
indexmap |= Geometry::MapColor;
if(secondary_colors_size > 0)
indexmap |= Geometry::MapSecondaryColor;
if(texccords_size > 0)
indexmap |= Geometry::MapTexCoords;
if(texccords1_size > 0)
indexmap |= Geometry::MapTexCoords1;
if(texccords2_size > 0)
indexmap |= Geometry::MapTexCoords2;
if(texccords3_size > 0)
indexmap |= Geometry::MapTexCoords3;
beginEditCP(geo, Geometry::IndexMappingFieldMask);
geo->editMFIndexMapping()->push_back(indexmap);
endEditCP(geo, Geometry::IndexMappingFieldMask);
repair = true;
return false;
}
else
{
return false;
}
}
示例3: verifyGeometry
/** Verify geometry method. */
Action::ResultE VerifyGraphOp::verifyGeometry(NodePtr &node)
{
GeometryPtr geo = GeometryPtr::dcast(node->getCore());
if(geo == NullFC)
return Action::Continue;
if(geo->getPositions() == NullFC)
return Action::Continue;
UInt32 start_errors = _numErrors;
Int32 positions_size = geo->getPositions()->getSize();
Int32 normals_size = 0;
if(geo->getNormals() != NullFC)
normals_size = geo->getNormals()->getSize();
Int32 colors_size = 0;
if(geo->getColors() != NullFC)
colors_size = geo->getColors()->getSize();
Int32 secondary_colors_size = 0;
if(geo->getSecondaryColors() != NullFC)
secondary_colors_size = geo->getSecondaryColors()->getSize();
Int32 texccords_size = 0;
if(geo->getTexCoords() != NullFC)
texccords_size = geo->getTexCoords()->getSize();
Int32 texccords1_size = 0;
if(geo->getTexCoords1() != NullFC)
texccords1_size = geo->getTexCoords1()->getSize();
Int32 texccords2_size = 0;
if(geo->getTexCoords2() != NullFC)
texccords2_size = geo->getTexCoords2()->getSize();
Int32 texccords3_size = 0;
if(geo->getTexCoords3() != NullFC)
texccords3_size = geo->getTexCoords3()->getSize();
UInt32 pos_errors = 0;
UInt32 norm_errors = 0;
UInt32 col_errors = 0;
UInt32 col2_errors = 0;
UInt32 tex0_errors = 0;
UInt32 tex1_errors = 0;
UInt32 tex2_errors = 0;
UInt32 tex3_errors = 0;
PrimitiveIterator it;
for(it = geo->beginPrimitives(); it != geo->endPrimitives(); ++it)
{
for(UInt32 v=0; v < it.getLength(); ++v)
{
if(it.getPositionIndex(v) >= positions_size)
++pos_errors;
if(it.getNormalIndex(v) >= normals_size)
++norm_errors;
if(it.getColorIndex(v) >= colors_size)
++col_errors;
if(it.getSecondaryColorIndex(v) >= secondary_colors_size)
++col2_errors;
if(it.getTexCoordsIndex(v) >= texccords_size)
++tex0_errors;
if(it.getTexCoordsIndex1(v) >= texccords1_size)
++tex1_errors;
if(it.getTexCoordsIndex2(v) >= texccords2_size)
++tex2_errors;
if(it.getTexCoordsIndex3(v) >= texccords3_size)
++tex3_errors;
}
}
if(norm_errors > 0)
{
norm_errors = 0;
if(_verbose) SINFO << "removed corrupted normals!\n";
beginEditCP(geo);
geo->setNormals(NullFC);
endEditCP(geo);
}
if(col_errors > 0)
{
col_errors = 0;
if(_verbose) SINFO << "removed corrupted colors!\n";
beginEditCP(geo);
geo->setColors(NullFC);
endEditCP(geo);
}
if(tex0_errors > 0)
{
tex0_errors = 0;
if(_verbose) SINFO << "removed corrupted tex coords0!\n";
beginEditCP(geo);
geo->setTexCoords(NullFC);
//.........这里部分代码省略.........