本文整理汇总了C++中Skeleton::getBone方法的典型用法代码示例。如果您正苦于以下问题:C++ Skeleton::getBone方法的具体用法?C++ Skeleton::getBone怎么用?C++ Skeleton::getBone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skeleton
的用法示例。
在下文中一共展示了Skeleton::getBone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _updateRenderQueue
//-----------------------------------------------------------------------
void Entity::_updateRenderQueue(RenderQueue* queue) {
SubEntityList* subEntList;
// Check we're not using a manual LOD
if (mMeshLodIndex > 0 && mMesh->isLodManual()) {
// Use alternate subentities
assert((mMeshLodIndex-1) < mLodSubEntityList.size() &&
"No LOD SubEntityList - did you build the manual LODs after creating the entity?");
// index - 1 as we skip index 0 (original lod)
subEntList = mLodSubEntityList[mMeshLodIndex - 1];
} else {
subEntList = &mSubEntityList;
}
// Add each SubEntity to the queue
SubEntityList::iterator i, iend;
iend = subEntList->end();
for (i = subEntList->begin(); i != iend; ++i) {
queue->addRenderable(*i, mRenderQueueID, RENDERABLE_DEFAULT_PRIORITY);
}
// Since we know we're going to be rendered, take this opportunity to
// cache bone matrices & apply world matrix to them
if (mMesh->hasSkeleton()) {
cacheBoneMatrices();
//--- pass this point, we are sure that the transformation matrix of each bone and tagPoint have been updated
// 挂到骨头上的子物体
ChildObjectList::iterator child_itr = mChildObjectList.begin();
ChildObjectList::iterator child_itr_end = mChildObjectList.end();
for( ; child_itr != child_itr_end; child_itr++) {
(*child_itr).second->_updateRenderQueue(queue);
}
}
// HACK to display bones
// This won't work if the entity is not centered at the origin
// TODO work out a way to allow bones to be rendered when Entity not centered
if (mDisplaySkeleton && mMesh->hasSkeleton()) {
Skeleton* pSkel = mMesh->getSkeleton();
int numBones = pSkel->getNumBones();
for (int b = 0; b < numBones; ++b) {
Bone* bone = pSkel->getBone(b);
queue->addRenderable(bone, mRenderQueueID);
}
}
}
示例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: 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);
}
示例4: 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();
}
示例5: fitToTargetSkeleton
void Skeleton::fitToTargetSkeleton(const Skeleton &target)
{
// find root bone
int rootId = -1;
for(unsigned int i = 0; i < mBones.size(); ++i)
{
if(mBones[i].parent == -1)
{
rootId = i;
break;
}
}
// is a root in the skeleton
if(rootId == -1)
{
LOG("no root bone found");
return;
}
// check for consistency
if(mBones.size() != target.getNumBones())
{
LOG("skeletons does not match");
return;
}
// init stack with root
std::vector<int> ndStack(0);
ndStack.push_back(rootId);
// level pt
int sp = 0;
while((unsigned int)sp < ndStack.size())
{
Bone& cur = mBones[ndStack[sp]];
for(unsigned int j = 0; j < cur.children.size(); ++j)
{
ndStack.push_back(cur.children[j]);
}
sp++;
}
// apply all rotations according stack order
for(unsigned int k = 0; k < ndStack.size(); ++k)
{
// get current bone
unsigned int l = ndStack[k];
Bone& _tB = mBones[l];
// transform rotation from other bone
Bone _oB;
target.getBone(l, _oB);
_tB.R = _oB.R;
// offset is the fathers end position
if(_tB.parent > -1 && (unsigned int)_tB.parent < mBones.size())
{
Bone& _pP = mBones[_tB.parent];
_tB.t = _pP.t + _pP.R.col(1) * _pP.length;
}
else
{
// LOG("no t correction for bone " << l);
}
mJoints[_tB.j0] = _tB.t;
mJoints[_tB.j1] = _tB.t + _tB.R.col(1) * _tB.length;
}
}
示例6: loadModelAndSkeletonDae
//.........这里部分代码省略.........
if (last < 0)
break;
closed[last] = true;;
}
else if ((pos = line.find("<node id=")) != std::string::npos) {
int parent = findLastOpen(closed);
std::string name = line.substr((pos = line.find_first_of("\"")) + 1, line.find_first_of("\"", pos + 1) - (pos + 1));
getline(fileStream, line);
std::string::iterator begIt = line.begin() + (pos = line.find_first_of(">")) + 1;
std::string::iterator endIt = line.begin() + line.find_first_of("<", pos + 1);
std::vector<float> mat; mat.reserve(16);
split(begIt, endIt, ' ', mat);
glm::mat4 m;
for (unsigned int i = 0; i < 16; i++)
m[i / 4][i % 4] = mat[i];
s.addBone(glm::transpose(m), findLastOpen(closed));
closed.push_back(false);
}
}
if (!fileStream.good()) {
std::cout << "File is in incorrect format " << path << std::endl;
return false;
}
//add inverse bind pose matrices
for (unsigned int i = 0; i < bindPoses.size(); i++) {
s.getBone(i)->inverseBindMatrix = glm::transpose(bindPoses[i]) * bindShapeMatrix;
}
s.fixScale();
//sort weights
std::vector<std::vector<float> > wSorted;
std::vector<std::vector<int> > jSorted;
wSorted.reserve(weightJoints.size());
jSorted.reserve(weightJoints.size());
for (unsigned int i = 0; i < weightJoints.size(); i++) {
wSorted.push_back(std::vector<float>()); wSorted.back().reserve(weightJoints[i].size());
jSorted.push_back(std::vector<int>()); jSorted.back().reserve(weightJoints[i].size());
for (unsigned int j = 0; j < weightJoints[i].size(); j++) {
if (j == 0) {
wSorted[i].push_back(w[weightWeights[i][j]]);
jSorted[i].push_back(weightJoints[i][j]);
}
else {
for (unsigned int k = 0; k < wSorted[i].size(); k++) {
if (w[weightWeights[i][j]] > wSorted[i][k]) {
wSorted[i].insert(wSorted[i].begin() + k, w[weightWeights[i][j]]);
jSorted[i].insert(jSorted[i].begin() + k, weightJoints[i][j]);
break;
}
if (k == wSorted[i].size() - 1) {
wSorted[i].push_back(w[weightWeights[i][j]]);
jSorted[i].push_back(weightJoints[i][j]);
break;
}
}
}
}