本文整理汇总了C++中Bone::addChildBone方法的典型用法代码示例。如果您正苦于以下问题:C++ Bone::addChildBone方法的具体用法?C++ Bone::addChildBone怎么用?C++ Bone::addChildBone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bone
的用法示例。
在下文中一共展示了Bone::addChildBone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeBoneParent
void Armature::changeBoneParent(Bone *bone, const std::string& parentName)
{
CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!");
if(bone->getParentBone())
{
bone->getParentBone()->getChildren().eraseObject(bone);
bone->setParentBone(nullptr);
}
if (!parentName.empty())
{
Bone *boneParent = _boneDic.at(parentName);
if (boneParent)
{
boneParent->addChildBone(bone);
if (_topBoneList.contains(bone))
{
_topBoneList.eraseObject(bone);
}
}
else
{
_topBoneList.pushBack(bone);
}
}
}
示例2: addBone
void Armature::addBone(Bone *bone, const std::string& parentName)
{
CCASSERT( bone != nullptr, "Argument must be non-nil");
CCASSERT(_boneDic.at(bone->getName()) == nullptr, "bone already added. It can't be added again");
if (!parentName.empty())
{
Bone *boneParent = _boneDic.at(parentName);
if (boneParent)
{
boneParent->addChildBone(bone);
}
else
{
_topBoneList.pushBack(bone);
}
}
else
{
_topBoneList.pushBack(bone);
}
bone->setArmature(this);
_boneDic.insert(bone->getName(), bone);
addChild(bone);
}
示例3: loadSkeleton
void Skeleton::loadSkeleton(const String& fileName) {
OSFILE *inFile = OSBasics::open(fileName.c_str(), "rb");
if(!inFile) {
return;
}
bonesEntity = new Entity();
bonesEntity->visible = false;
addChild(bonesEntity);
unsigned int numBones;
float t[3],rq[4],s[3];
OSBasics::read(&numBones, sizeof(unsigned int), 1, inFile);
unsigned int namelen;
char buffer[1024];
Matrix4 mat;
unsigned int hasParent, boneID;
for(int i=0; i < numBones; i++) {
OSBasics::read(&namelen, sizeof(unsigned int), 1, inFile);
memset(buffer, 0, 1024);
OSBasics::read(buffer, 1, namelen, inFile);
Bone *newBone = new Bone(String(buffer));
OSBasics::read(&hasParent, sizeof(unsigned int), 1, inFile);
if(hasParent == 1) {
OSBasics::read(&boneID, sizeof(unsigned int), 1, inFile);
newBone->parentBoneId = boneID;
} else {
newBone->parentBoneId = -1;
}
OSBasics::read(t, sizeof(float), 3, inFile);
OSBasics::read(s, sizeof(float), 3, inFile);
OSBasics::read(rq, sizeof(float), 4, inFile);
bones.push_back(newBone);
Quaternion bq;
bq.set(rq[0], rq[1], rq[2], rq[3]);
newBone->baseRotation = bq;
newBone->baseScale = Vector3(s[0], s[1], s[2]);
newBone->basePosition = Vector3(t[0], t[1], t[2]);
newBone->setPosition(t[0], t[1], t[2]);
newBone->setRotationQuat(rq[0], rq[1], rq[2], rq[3]);
newBone->setScale(s[0], s[1], s[2]);
newBone->rebuildTransformMatrix();
newBone->setBaseMatrix(newBone->getTransformMatrix());
newBone->setBoneMatrix(newBone->getTransformMatrix());
OSBasics::read(t, sizeof(float), 3, inFile);
OSBasics::read(s, sizeof(float), 3, inFile);
OSBasics::read(rq, sizeof(float), 4, inFile);
Quaternion q;
q.set(rq[0], rq[1], rq[2], rq[3]);
Matrix4 m = q.createMatrix();
m.setPosition(t[0], t[1], t[2]);
newBone->setRestMatrix(m);
}
Bone *parentBone;
for(int i=0; i < bones.size(); i++) {
if(bones[i]->parentBoneId != -1) {
parentBone = bones[bones[i]->parentBoneId];
parentBone->addChildBone(bones[i]);
bones[i]->setParentBone(parentBone);
parentBone->addChild(bones[i]);
} else {
bonesEntity->addChild(bones[i]);
}
}
OSBasics::close(inFile);
}
示例4: loadSkeleton
void Skeleton::loadSkeleton(const String& fileName) {
OSFILE *inFile = OSBasics::open(fileName.c_str(), "rb");
if(!inFile) {
return;
}
bonesEntity = new SceneEntity();
bonesEntity->visible = false;
addChild(bonesEntity);
unsigned int numBones;
float t[3],rq[4],s[3];
OSBasics::read(&numBones, sizeof(unsigned int), 1, inFile);
unsigned int namelen;
char buffer[1024];
Matrix4 mat;
unsigned int hasParent, boneID;
for(int i=0; i < numBones; i++) {
OSBasics::read(&namelen, sizeof(unsigned int), 1, inFile);
memset(buffer, 0, 1024);
OSBasics::read(buffer, 1, namelen, inFile);
Bone *newBone = new Bone(String(buffer));
OSBasics::read(&hasParent, sizeof(unsigned int), 1, inFile);
if(hasParent == 1) {
OSBasics::read(&boneID, sizeof(unsigned int), 1, inFile);
newBone->parentBoneId = boneID;
} else {
newBone->parentBoneId = -1;
}
OSBasics::read(t, sizeof(float), 3, inFile);
OSBasics::read(s, sizeof(float), 3, inFile);
OSBasics::read(rq, sizeof(float), 4, inFile);
bones.push_back(newBone);
newBone->setPosition(t[0], t[1], t[2]);
newBone->setRotationQuat(rq[0], rq[1], rq[2], rq[3]);
newBone->setScale(s[0], s[1], s[2]);
newBone->rebuildTransformMatrix();
newBone->setBaseMatrix(newBone->getTransformMatrix());
newBone->setBoneMatrix(newBone->getTransformMatrix());
OSBasics::read(t, sizeof(float), 3, inFile);
OSBasics::read(s, sizeof(float), 3, inFile);
OSBasics::read(rq, sizeof(float), 4, inFile);
Quaternion q;
q.set(rq[0], rq[1], rq[2], rq[3]);
Matrix4 m = q.createMatrix();
m.setPosition(t[0], t[1], t[2]);
newBone->setRestMatrix(m);
}
Bone *parentBone;
// SceneEntity *bProxy;
for(int i=0; i < bones.size(); i++) {
if(bones[i]->parentBoneId != -1) {
parentBone = bones[bones[i]->parentBoneId];
parentBone->addChildBone(bones[i]);
bones[i]->setParentBone(parentBone);
parentBone->addEntity(bones[i]);
// addEntity(bones[i]);
SceneLine *connector = new SceneLine(bones[i], parentBone);
connector->depthTest = false;
bonesEntity->addEntity(connector);
connector->setColor(((Number)(rand() % RAND_MAX)/(Number)RAND_MAX),((Number)(rand() % RAND_MAX)/(Number)RAND_MAX),((Number)(rand() % RAND_MAX)/(Number)RAND_MAX),1.0f);
} else {
// bProxy = new SceneEntity();
// addEntity(bProxy);
// bProxy->addEntity(bones[i]);
bonesEntity->addChild(bones[i]);
}
// bones[i]->visible = false;
}
OSBasics::close(inFile);
}
示例5: loadSkeleton
void Skeleton::loadSkeleton(const String& fileName) {
OSFILE *inFile = OSBasics::open(fileName.c_str(), "rb");
if(!inFile) {
return;
}
bonesEntity = new SceneEntity();
bonesEntity->visible = false;
addChild(bonesEntity);
unsigned int numBones;
float t[3],rq[4],s[3];
OSBasics::read(&numBones, sizeof(unsigned int), 1, inFile);
unsigned int namelen;
char buffer[1024];
Matrix4 mat;
unsigned int hasParent, boneID;
for(int i=0; i < numBones; i++) {
OSBasics::read(&namelen, sizeof(unsigned int), 1, inFile);
memset(buffer, 0, 1024);
OSBasics::read(buffer, 1, namelen, inFile);
Bone *newBone = new Bone(String(buffer));
OSBasics::read(&hasParent, sizeof(unsigned int), 1, inFile);
if(hasParent == 1) {
OSBasics::read(&boneID, sizeof(unsigned int), 1, inFile);
newBone->parentBoneId = boneID;
} else {
newBone->parentBoneId = -1;
}
OSBasics::read(t, sizeof(float), 3, inFile);
OSBasics::read(s, sizeof(float), 3, inFile);
OSBasics::read(rq, sizeof(float), 4, inFile);
bones.push_back(newBone);
newBone->setPosition(t[0], t[1], t[2]);
newBone->setRotationQuat(rq[0], rq[1], rq[2], rq[3]);
newBone->setScale(s[0], s[1], s[2]);
newBone->rebuildTransformMatrix();
newBone->setBaseMatrix(newBone->getTransformMatrix());
newBone->setBoneMatrix(newBone->getTransformMatrix());
OSBasics::read(t, sizeof(float), 3, inFile);
OSBasics::read(s, sizeof(float), 3, inFile);
OSBasics::read(rq, sizeof(float), 4, inFile);
Quaternion q;
q.set(rq[0], rq[1], rq[2], rq[3]);
Matrix4 m = q.createMatrix();
m.setPosition(t[0], t[1], t[2]);
newBone->setRestMatrix(m);
}
Bone *parentBone;
// SceneEntity *bProxy;
for(int i=0; i < bones.size(); i++) {
if(bones[i]->parentBoneId != -1) {
parentBone = bones[bones[i]->parentBoneId];
parentBone->addChildBone(bones[i]);
bones[i]->setParentBone(parentBone);
parentBone->addEntity(bones[i]);
// addEntity(bones[i]);
SceneLine *connector = new SceneLine(bones[i], parentBone);
connector->depthTest = false;
bonesEntity->addEntity(connector);
connector->setColor(((Number)(rand() % RAND_MAX)/(Number)RAND_MAX),((Number)(rand() % RAND_MAX)/(Number)RAND_MAX),((Number)(rand() % RAND_MAX)/(Number)RAND_MAX),1.0f);
} else {
// bProxy = new SceneEntity();
// addEntity(bProxy);
// bProxy->addEntity(bones[i]);
bonesEntity->addChild(bones[i]);
}
// bones[i]->visible = false;
}
/*
unsigned int numAnimations, activeBones,boneIndex,numPoints,numCurves, curveType;
OSBasics::read(&numAnimations, sizeof(unsigned int), 1, inFile);
//Logger::log("numAnimations: %d\n", numAnimations);
for(int i=0; i < numAnimations; i++) {
OSBasics::read(&namelen, sizeof(unsigned int), 1, inFile);
memset(buffer, 0, 1024);
OSBasics::read(buffer, 1, namelen, inFile);
float length;
OSBasics::read(&length, 1, sizeof(float), inFile);
SkeletonAnimation *newAnimation = new SkeletonAnimation(buffer, length);
OSBasics::read(&activeBones, sizeof(unsigned int), 1, inFile);
// Logger::log("activeBones: %d\n", activeBones);
//.........这里部分代码省略.........