本文整理汇总了C++中Skeleton::getBoneCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Skeleton::getBoneCount方法的具体用法?C++ Skeleton::getBoneCount怎么用?C++ Skeleton::getBoneCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skeleton
的用法示例。
在下文中一共展示了Skeleton::getBoneCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: togglePinnedStatus
void SkeletonTool::togglePinnedStatus(int columnIndex, int frame, bool shiftPressed)
{
Skeleton skeleton;
buildSkeleton(skeleton, columnIndex);
if (!skeleton.getRootBone() || !skeleton.getRootBone()->getStageObject())
return;
Skeleton::Bone *bone = skeleton.getBoneByColumnIndex(columnIndex);
assert(bone);
if (!bone)
return;
TogglePinnedStatusUndo *undo = new TogglePinnedStatusUndo(this, frame);
for (int i = 0; i < skeleton.getBoneCount(); i++) {
TStageObject *obj = skeleton.getBone(i)->getStageObject();
if (obj) {
undo->addBoneId(obj->getId());
obj->setKeyframeWithoutUndo(frame);
}
}
getApplication()->getCurrentXsheet()->notifyXsheetChanged();
getApplication()->getCurrentObject()->notifyObjectIdChanged(false);
undo->setOldTemp(m_temporaryPinnedColumns);
bool isTemporaryPinned = m_temporaryPinnedColumns.count(columnIndex) > 0;
if (shiftPressed || isTemporaryPinned) {
if (isTemporaryPinned)
m_temporaryPinnedColumns.erase(columnIndex);
else
m_temporaryPinnedColumns.insert(columnIndex);
} else {
TXsheet *xsh = TTool::getApplication()->getCurrentXsheet()->getXsheet();
TAffine placement = xsh->getPlacement(bone->getStageObject()->getId(), frame);
TStageObjectId rootId = skeleton.getRootBone()->getStageObject()->getId();
TAffine rootPlacement = xsh->getPlacement(rootId, frame);
int pinnedStatus = bone->getPinnedStatus();
if (pinnedStatus != Skeleton::Bone::PINNED) {
int oldPinned = -1;
for (int i = 0; i < skeleton.getBoneCount(); i++) {
TStageObject *obj = skeleton.getBone(i)->getStageObject();
if (obj->getPinnedRangeSet()->isPinned(frame)) {
oldPinned = i;
break;
}
}
int lastFrame = 1000000;
if (oldPinned >= 0) {
assert(skeleton.getBone(oldPinned) != bone);
TStageObject *obj = skeleton.getBone(oldPinned)->getStageObject();
const TPinnedRangeSet::Range *range = obj->getPinnedRangeSet()->getRange(frame);
assert(range && range->first <= frame && frame <= range->second);
lastFrame = range->second;
TPinnedRangeSet *rangeSet = obj->getPinnedRangeSet();
rangeSet->removeRange(frame, range->second);
obj->invalidate();
undo->setOldRange(oldPinned, frame, range->second, rangeSet->getPlacement());
} else {
for (int i = 0; i < skeleton.getBoneCount(); i++) {
TStageObject *obj = skeleton.getBone(i)->getStageObject();
const TPinnedRangeSet::Range *range = obj->getPinnedRangeSet()->getNextRange(frame);
if (range) {
assert(range->first > frame);
if (range->first - 1 < lastFrame)
lastFrame = range->first - 1;
}
}
}
TStageObject *obj = bone->getStageObject();
TPinnedRangeSet *rangeSet = obj->getPinnedRangeSet();
rangeSet->setRange(frame, lastFrame);
if (frame == 0) {
// this code should be moved elsewhere, possibly in the stageobject implementation
// the idea is to remove the normal
TStageObject *rootObj = skeleton.getRootBone()->getStageObject();
rootObj->setStatus(TStageObject::XY);
placement = rootObj->getPlacement(0).inv() * placement;
rootObj->setStatus(TStageObject::IK);
rangeSet->setPlacement(placement);
rootObj->invalidate();
}
undo->setNewRange(bone->getColumnIndex(), frame, lastFrame, rangeSet->getPlacement());
}
}
undo->setNewTemp(m_temporaryPinnedColumns);
TUndoManager::manager()->add(undo);
}
示例2: drawSkeleton
void SkeletonTool::drawSkeleton(const Skeleton &skeleton, int row)
{
bool buildingSkeleton = m_mode.getValue() == BUILD_SKELETON;
bool ikEnabled = m_mode.getValue() == INVERSE_KINEMATICS;
TXsheet *xsh = getXsheet();
std::vector<int> showBoneIndex;
int i;
for (i = 0; i < skeleton.getBoneCount(); i++) {
Skeleton::Bone *bone = skeleton.getBone(i);
TStageObjectId id = bone->getStageObject()->getId();
bool canShow = canShowBone(bone, xsh, row);
if (!canShow)
continue;
showBoneIndex.push_back(i);
}
bool changingParent = dynamic_cast<ParentChangeTool *>(m_dragTool) != 0;
TStageObjectId currentObjectId = TTool::getApplication()->getCurrentObject()->getObjectId();
std::string currentHandle = xsh->getStageObject(currentObjectId)->getHandle();
for (i = 0; i < (int)showBoneIndex.size(); i++) {
Skeleton::Bone *bone = skeleton.getBone(showBoneIndex[i]);
TStageObjectId id = bone->getStageObject()->getId();
bool isCurrent = id == currentObjectId;
if (isCurrent && buildingSkeleton && m_parentProbeEnabled) {
if (!m_magicLinks.empty()) {
drawBone(bone->getCenter(), m_magicLinks[0].m_h1.m_pos, false);
}
drawBone(bone->getCenter(), m_parentProbe, true);
} else if (ikEnabled) {
if (bone->getParent())
drawIKBone(bone->getCenter(), bone->getParent()->getCenter());
} else if (bone->getParent() || isCurrent) {
double pixelSize = getPixelSize();
TPointD a = bone->getCenter();
TPointD b, pm;
if (bone->getParent()) {
b = bone->getParent()->getCenter();
pm = (a + b) * 0.5;
} else {
pm = b = a + TPointD(0, 60) * pixelSize;
}
bool boneIsVisible = false;
if (buildingSkeleton) {
boneIsVisible = true;
if (bone->isSelected())
drawBone(a, b, true);
else if (!m_showOnlyActiveSkeleton.getValue())
drawBone(a, b, false);
else
boneIsVisible = false;
}
if (boneIsVisible && isCurrent) {
// draw change parent gadget
double r = pixelSize * 5;
if (isPicking()) {
// int code = TD_ResetParent + bone->getStageObject()->getId().getIndex();
glPushName(TD_ChangeParent);
tglDrawDisk(pm, r);
glPopName();
} else {
if (m_device == TD_ChangeParent) {
glColor4d(0.47 * alpha, 0.6 * alpha, 0.65 * alpha, alpha);
r *= 1.5;
} else
glColor4d(0.37 * alpha, 0.5 * alpha, 0.55 * alpha, alpha);
glRectd(pm.x - r, pm.y - r, pm.x + r, pm.y + r);
glColor3d(0, 0, 0);
tglDrawRect(pm.x - r, pm.y - r, pm.x + r, pm.y + r);
}
}
}
}
for (i = 0; i < (int)showBoneIndex.size(); i++) {
Skeleton::Bone *bone = skeleton.getBone(showBoneIndex[i]);
if (!m_showOnlyActiveSkeleton.getValue() || bone->isSelected())
drawJoint(bone->getCenter(),
currentObjectId == bone->getStageObject()->getId() &&
currentHandle.find("H") != 0);
}
}
示例3: draw
void SkeletonTool::draw()
{
// parent object reference system
//glColor3d(1,0,0);
//tglDrawRect(0,0,100,100);
if (m_label != "")
ToolUtils::drawBalloon(m_labelPos, m_label, TPixel32::Red, TPoint(20, -20), false);
bool ikEnabled = m_mode.getValue() == INVERSE_KINEMATICS;
assert(glGetError() == GL_NO_ERROR);
// l'xsheet, oggetto (e relativo placement), frame corrente
TTool::Application *app = TTool::getApplication();
TXsheet *xsh = getXsheet();
assert(xsh);
TStageObjectId objId = app->getCurrentObject()->getObjectId();
// se l'oggetto corrente non e' una colonna non disegno nulla
if (!objId.isColumn())
return;
TStageObject *pegbar = xsh->getStageObject(objId);
int col = objId.getIndex();
int frame = app->getCurrentFrame()->getFrame();
if (m_currentFrame != frame)
m_temporaryPinnedColumns.clear();
TAffine aff = getMatrix();
// puo' suggere che il placement degeneri (es.: c'e' uno h-scale = 0%)
if (fabs(aff.det()) < 0.00001)
return;
// m_unit = getPixelSize() * sqrt(fabs(aff.det()));
if (!ikEnabled)
drawLevelBoundingBox(frame, col);
glPushMatrix();
tglMultMatrix(aff.inv());
// camera stand reference system
//glColor3d(0,1,0);
//tglDrawRect(0,0,100,100);
bool changingParent = dynamic_cast<ParentChangeTool *>(m_dragTool) != 0;
// !changingParent &&
if (m_mode.getValue() == BUILD_SKELETON && !xsh->getStageObjectParent(objId).isColumn()) {
if (!changingParent)
drawHooks();
}
Skeleton skeleton;
buildSkeleton(skeleton, col);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
drawSkeleton(skeleton, frame);
glDisable(GL_BLEND);
TXshCell cell = xsh->getCell(frame, objId.getIndex());
Skeleton::Bone *rootBone = skeleton.getRootBone();
for (int i = 0; i < skeleton.getBoneCount(); i++) {
Skeleton::Bone *bone = skeleton.getBone(i);
TStageObjectId currentId = bone->getStageObject()->getId();
bool isCurrent = (currentId == objId);
TPointD pos = bone->getCenter();
if (isCurrent && m_mode.getValue() != BUILD_SKELETON) {
drawDrawingBrowser(cell, pos);
}
bool isActiveChain = bone->isSelected();
glColor3d(0, 1, 0);
if (ikEnabled) {
drawIKJoint(bone);
} else {
TPointD pos = bone->getCenter();
if (isCurrent && m_mode.getValue() == ANIMATE) {
drawMainGadget(pos);
}
}
}
m_currentFrame = frame;
if (m_dragTool)
m_dragTool->draw();
glPopMatrix();
}