本文整理汇总了C++中BVHNode::setKeyFrameRelWeight方法的典型用法代码示例。如果您正苦于以下问题:C++ BVHNode::setKeyFrameRelWeight方法的具体用法?C++ BVHNode::setKeyFrameRelWeight怎么用?C++ BVHNode::setKeyFrameRelWeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BVHNode
的用法示例。
在下文中一共展示了BVHNode::setKeyFrameRelWeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EvaluateRelativeLimbWeights
//.........这里部分代码省略.........
//Shadow items don't matter much because the nearest/furthest item is always non-shadow
if(firstItem->beginIndex() < minPosIndex)
minPosIndex = firstItem->beginIndex();
TrailItem* lastItem = trails->at(i)->lastItem();
if(lastItem->endIndex() > maxPosIndex)
maxPosIndex = trails->at(i)->lastItem()->endIndex();
while(firstItem->isShadow())
firstItem = firstItem->nextItem();
currentItems[i] = firstItem;
}
if(maxPosIndex == -1) //Time-line is empty
return;
int curPosIndex = minPosIndex;
//Position pseudo-node is not included, but it's OK as it can't be highlighted
QStringList boneNames = BVH::getValidNodeNames();
while(curPosIndex<=maxPosIndex)
{
foreach(QString bName, boneNames)
{
int sumWeight = 0;
int weightsUsed = 0;
bool emptyPosition = true;
//Temporary helper structure. Value is array of 2 integers: frame index inside
//respective animation and its frame weight
QMap<BVHNode*, QVector<int> >* usedData = new QMap<BVHNode*, QVector<int> >();
for(int i=0; i<trailsCount; i++)
{
TrailItem* item = currentItems[i];
if(item == NULL) //No more items on i-th trail
continue;
if(item->beginIndex() > curPosIndex) //We're before first item of this trail
continue;
if(item->endIndex() < curPosIndex) //Move to next item
{
currentItems[i] = item->nextItem();
item = currentItems[i];
}
if(item == NULL || item->isShadow()) //Still here?
continue;
else
emptyPosition = false;
if(item->beginIndex() <= curPosIndex && item->endIndex() >= curPosIndex)
{
int frameIndex = curPosIndex - item->beginIndex();
int frameWeight = item->getWeight(frameIndex);
if(!item->getAnimation()->bones()->contains(bName))
Announcer::Exception(NULL, "Exception: can't evaluate relative weight for limb " +bName);
// BVHNode* limb = item->getAnimation()->bones()->value(bName); NOT WORKING. REALLY NEED TO KNOW WHY
//desperate DEBUG
BVHNode* limb = item->getAnimation()->getNodeByName(bName);
QVector<int> tempData;
tempData << frameIndex << frameWeight;
usedData->insert(limb, tempData);
sumWeight += frameWeight * limb->frameData(frameIndex).weight();
weightsUsed++;
}
// else Announcer::Exception(NULL, "Lame programmer exception :("); //DEBUG
}
if(emptyPosition) //There were no valid item at this position
break; //so jump to the next one
QMapIterator<BVHNode*, QVector<int> > iter(*usedData);
while(iter.hasNext())
{
iter.next();
BVHNode* bone = iter.key();
QVector<int> tempData = iter.value();
int frame = tempData[0];
int frameW = tempData[1];
if(sumWeight==0) //Little trick if weight of current limb was 0 on all trails
bone->setKeyFrameRelWeight(frame, 1.0 / (double)weightsUsed);
else
{
int limbW = bone->frameData(frame).weight();
double relWei = (double)(frameW*limbW) / (double)sumWeight;
bone->setKeyFrameRelWeight(frame, relWei);
}
}
delete usedData;
}
curPosIndex++;
}