本文整理汇总了C++中Bone::addEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ Bone::addEntity方法的具体用法?C++ Bone::addEntity怎么用?C++ Bone::addEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bone
的用法示例。
在下文中一共展示了Bone::addEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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);
//.........这里部分代码省略.........