framework2

Форк
0
146 строк · 4.7 Кб
1
//
2
//  ofxFBXSkeleton.cpp
3
//  ofxFBX-Example-Importer
4
//
5
//  Created by Nick Hardeman on 11/5/13.
6
//
7
//
8

9
#include "ofxFBXSrcSkeleton.h"
10
using namespace ofxFBXSource;
11

12
ofxFBXSource::Bone dummyBone;
13

14
//--------------------------------------------------------------
15
Skeleton::Skeleton() {
16
    
17
}
18

19
//--------------------------------------------------------------
20
Skeleton::~Skeleton() {
21
    
22
}
23

24
//--------------------------------------------------------------
25
void Skeleton::setup( FbxNode *pNode ) {
26
    ofxFBXSource::Node::setup( pNode );
27
    root->setup( pNode );
28
    root->setParent(*this);
29
    root->setAsRoot();
30
}
31

32
//--------------------------------------------------------------
33
//void ofxFBXSkeleton::reconstructNodeParenting() {
34
//
35
////    cout << "ofxFBXSkeleton :: rootSounce->hasParent() : " << (rootSource->getParent()==NULL) << " | " << ofGetFrameNum() << endl;
36
//
37
//    ofxFBXBone tbone = *rootSource;
38
//    root = tbone;
39
//
40
//    root.setAsRoot();
41
//    root.sourceBone = rootSource;
42
//    root.setupFromSourceBones();
43
//
44
//    // now we need to reassociate the bone parent pointers, so they are not pointing to the source bones //
45
//    // we need a way to get all of the bones as pointers, so we can easily make the association //
46
//    map< string, ofxFBXBone* > tempBones = root.getAllBones();
47
//    map< string, ofxFBXBone* >::iterator it;
48
//
49
//    // clear the parents to remove the previous listeners //
50
//    for( it = tempBones.begin(); it != tempBones.end(); ++it ) {
51
//        if( it->second->getParent() != NULL ) {
52
//            it->second->clearParent();
53
//        }
54
//    }
55
//
56
//    for( it = tempBones.begin(); it != tempBones.end(); ++it ) {
57
//        if( it->second->hasSkeletonParent() ) {
58
//            if( tempBones.count(it->second->parentBoneName) ) {
59
//                it->second->setParent( *tempBones[it->second->parentBoneName] );
60
//            }
61
//        }
62
//    }
63
//}
64

65
//--------------------------------------------------------------
66
void Skeleton::update( FbxTime& pTime, FbxPose* pPose ) {
67
    root->update( pTime, pPose );
68
}
69

70
//--------------------------------------------------------------
71
void Skeleton::update( int aAnimIndex, signed long aMillis ) {
72
    root->update( aAnimIndex, aMillis );
73
}
74

75
//--------------------------------------------------------------
76
void Skeleton::update( int aAnimIndex1, signed long aAnim1Millis, int aAnimIndex2, signed long aAnim2Millis, float aMixPct ) {
77
    root->update( aAnimIndex1, aAnim1Millis, aAnimIndex2, aAnim2Millis, aMixPct );
78
}
79

80
//--------------------------------------------------------------
81
void Skeleton::lateUpdate() {
82
    root->lateUpdate();
83
}
84

85
//--------------------------------------------------------------
86
//void Skeleton::draw( float aLen, bool aBDrawAxes ) {
87
//    root->draw( aLen, aBDrawAxes );
88
//}
89

90
//--------------------------------------------------------------
91
shared_ptr<ofxFBXSource::Bone> Skeleton::getBone( string aName ) {
92
    if( root->getName() == aName ) return root;
93
    return root->getBone( aName );
94
}
95

96
//--------------------------------------------------------------
97
//void ofxFBXSkeleton::enableAnimationForBone( string aName, bool bRecursive ) {
98
//    ofxFBXBone* bone = getBone( aName );
99
//    if(bone == NULL) {
100
//        ofLogWarning("ofxFBXSkeleton :: enableExternalControl : can not find bone with name ") << aName;
101
//        return;
102
//    }
103
//    bone->enableAnimation( bRecursive );
104
//}
105
//
106
////--------------------------------------------------------------
107
//void ofxFBXSkeleton::disableAnimationForBone( string aName, bool bRecursive ) {
108
//    ofxFBXBone* bone = getBone( aName );
109
//    if(bone == NULL) {
110
//        ofLogWarning("ofxFBXSkeleton :: enableExternalControl : can not find bone with name ") << aName;
111
//        return;
112
//    }
113
//    bone->disableAnimation( bRecursive );
114
//}
115
//
116
////--------------------------------------------------------------
117
//void ofxFBXSkeleton::enableAnimation() {
118
//    root.enableAnimation( true );
119
//}
120
//
121
////--------------------------------------------------------------
122
//void ofxFBXSkeleton::disableAnimation() {
123
//    root.disableAnimation( true );
124
//}
125

126
//--------------------------------------------------------------
127
void Skeleton::clearKeyFrames() {
128
    root->clearKeyFrames();
129
}
130

131
//--------------------------------------------------------------
132
int Skeleton::getNumBones() {
133
    return root->getNumBones();
134
}
135

136
//--------------------------------------------------------------
137
string Skeleton::toString() {
138
    string tstr = "Skeleton: " + root->getName()+ " total bones: " + ofToString( getNumBones(), 0 ) + "\n ";
139
    tstr += root->getAsString();
140
    return tstr;
141
}
142

143
//--------------------------------------------------------------
144
//map< string, shared_ptr<ofxFBXSource::Bone> > Skeleton::getAllBones() {
145
//    return root->getAllBones();
146
//}
147

148

149

150

151

152

153

154

155

156

157

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.