本文整理汇总了C++中TriMesh::appendColorsRgb方法的典型用法代码示例。如果您正苦于以下问题:C++ TriMesh::appendColorsRgb方法的具体用法?C++ TriMesh::appendColorsRgb怎么用?C++ TriMesh::appendColorsRgb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriMesh
的用法示例。
在下文中一共展示了TriMesh::appendColorsRgb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeColors
// dependent on a change in parameters, write new colors to the TriMesh
void GeoDeVisualizerApp::writeColors()
{
mTriangles.getColorsRGB().clear();
vector<Color> colors;
colors.reserve(mTriangles.getNumTriangles());
DisplayMode mode = (DisplayMode)mCurParams.displayMode;
switch(mode) {
case Geography:
{
colors = mWorld.mGeoColors;
break;
}
case Colonies:
{
colors = mWorld.mGeoColors;
// add sphere of influence and location
Colony& colRef = mWorld.mColonies[mCurParams.displayColony];
mCamVars.sceneRotation.set(getAverageVertex(colRef.mLocation), mCam.getEyePoint());
for (set<u32>::iterator soiIt = colRef.mSphereInfluence.begin(); soiIt != colRef.mSphereInfluence.end(); ++soiIt) {
colors[*soiIt] = Color(0.2, 0.2, 0.2);
}
colors[colRef.mLocation] = Color(1.0, 0.0, 0.0);
break;
}
case Resources:
{
vector<u32> activeResIdxs;
for (u32 i = 0; i < mCurParams.numResources; i++) {
if (mCurParams.showResources[i]) {
activeResIdxs.push_back(i);
}
}
if (activeResIdxs.size() > 0) {
colors.insert(colors.begin(), mTriangles.getNumTriangles(), Color(0.0, 0.0, 0.0));
} else {
colors.insert(colors.begin(), mTriangles.getNumTriangles(), Color(0.2, 0.2, 0.2));
break;
}
float numIndices = activeResIdxs.size();
for(vector<u32>::iterator idxIt = activeResIdxs.begin(); idxIt != activeResIdxs.end(); ++idxIt) {
vector<f32>& activeResVals = (mWorld.resources())[*idxIt].mVals;
vector<Color>::iterator colIt = colors.begin();
for (vector<f32>::iterator valIt = activeResVals.begin(); valIt != activeResVals.end(); ++valIt) {
*colIt += (resourceColors[*idxIt] * (*valIt)) / numIndices;
colIt++;
}
}
break;
}
case Attributes:
{
colors.insert(colors.begin(), mTriangles.getNumTriangles(), Color(0.0, 0.0, 0.0));
vector<u32> activeAttrIdxs;
for (u32 i = 0; i < NUM_ATTRIBUTES; i++) {
if (mCurParams.showAttributes[i]) {
activeAttrIdxs.push_back(i);
}
}
if (activeAttrIdxs.size() == 0) {
colors.clear();
colors.insert(colors.begin(), mTriangles.getNumTriangles(), Color(0.1, 0.1, 0.1));
break;
}
map<string, Color> attrMap;
attrMap["wetness"] = Color(0.0, 0.0, 1.0);
attrMap["temperature"] = Color(1.0, 0.0, 0.0);
attrMap["elevation"] = Color(0.0, 1.0, 0);
// iterate through all active indices
for(vector<u32>::iterator idxIt = activeAttrIdxs.begin(); idxIt != activeAttrIdxs.end(); ++idxIt) {
Color colorVal = attrMap[mWorld.mAttributes[*idxIt].mName];
vector<Color>::iterator faceColorIt = colors.begin();
// iterate through all attribute values
for (vector<f32>::iterator attrIt = mWorld.mAttributes[*idxIt].mVals.begin(); attrIt != mWorld.mAttributes[*idxIt].mVals.end(); ++attrIt) {
*faceColorIt += (colorVal * (*attrIt));
faceColorIt++;
}
}
break;
}
}
// triple the colors vector so that triangles show up as solid triangles
for (vector<Color>::iterator colIt = colors.begin(); colIt != colors.end(); ++colIt) {
mTriangles.appendColorRgb(*colIt);
mTriangles.appendColorRgb(*colIt);
mTriangles.appendColorRgb(*colIt);
}
mFrame = mTriangles;
mFrame.getColorsRGB().clear();
vector<Color> frameColors(colors.size()*3, Color(0.1, 0.1, 0.1));
mFrame.appendColorsRgb(frameColors.data(), frameColors.size());
}