Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 330 vs 331 for /trunk/Source Code/Geometry/Animations/AnimationControllerFileIO.cpp

Diff revisions: vs.
  @@ -19,22 +19,28 @@
19 19 nsize =static_cast<uint32_t>(_channels[j]._positionKeys.size());
20 20 file.write(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));// the number of position keys
21 21 for(vectorAlg::vecSize i(0); i< nsize; i++){// for each channel
22 - file.write(reinterpret_cast<char*>(&_channels[j]._positionKeys[i].mTime), sizeof(_channels[j]._positionKeys[i].mTime));// pos key
23 - file.write(reinterpret_cast<char*>(&_channels[j]._positionKeys[i].mValue), sizeof(_channels[j]._positionKeys[i].mValue));// pos key
22 + file.write(reinterpret_cast<char*>(&_channels[j]._positionKeys[i].mTime),
23 + sizeof(_channels[j]._positionKeys[i].mTime));// pos key
24 + file.write(reinterpret_cast<char*>(&_channels[j]._positionKeys[i].mValue),
25 + sizeof(_channels[j]._positionKeys[i].mValue));// pos key
24 26 }
25 27
26 28 nsize =static_cast<uint32_t>(_channels[j]._rotationKeys.size());
27 29 file.write(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));// the number of position keys
28 30 for(vectorAlg::vecSize i(0); i< nsize; i++){// for each channel
29 - file.write(reinterpret_cast<char*>(&_channels[j]._rotationKeys[i].mTime), sizeof(_channels[j]._rotationKeys[i].mTime));// rot key
30 - file.write(reinterpret_cast<char*>(&_channels[j]._rotationKeys[i].mValue), sizeof(_channels[j]._rotationKeys[i].mValue));// rot key
31 + file.write(reinterpret_cast<char*>(&_channels[j]._rotationKeys[i].mTime),
32 + sizeof(_channels[j]._rotationKeys[i].mTime));// rot key
33 + file.write(reinterpret_cast<char*>(&_channels[j]._rotationKeys[i].mValue),
34 + sizeof(_channels[j]._rotationKeys[i].mValue));// rot key
31 35 }
32 36
33 37 nsize =static_cast<uint32_t>(_channels[j]._scalingKeys.size());
34 38 file.write(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));// the number of position keys
35 39 for(vectorAlg::vecSize i(0); i< nsize; i++){// for each channel
36 - file.write(reinterpret_cast<char*>(&_channels[j]._scalingKeys[i].mTime), sizeof(_channels[j]._scalingKeys[i].mTime));// rot key
37 - file.write(reinterpret_cast<char*>(&_channels[j]._scalingKeys[i].mValue), sizeof(_channels[j]._scalingKeys[i].mValue));// rot key
40 + file.write(reinterpret_cast<char*>(&_channels[j]._scalingKeys[i].mTime),
41 + sizeof(_channels[j]._scalingKeys[i].mTime));// rot key
42 + file.write(reinterpret_cast<char*>(&_channels[j]._scalingKeys[i].mValue),
43 + sizeof(_channels[j]._scalingKeys[i].mValue));// rot key
38 44 }
39 45 }
40 46 }
  @@ -62,24 +68,30 @@
62 68 file.read(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));// the number of position keys
63 69 _channels[j]._positionKeys.resize(nsize);
64 70 for(vectorAlg::vecSize i(0); i< nsize; i++){// for each channel
65 - file.read(reinterpret_cast<char*>(&_channels[j]._positionKeys[i].mTime), sizeof(_channels[j]._positionKeys[i].mTime));// pos key
66 - file.read(reinterpret_cast<char*>(&_channels[j]._positionKeys[i].mValue), sizeof(_channels[j]._positionKeys[i].mValue));// pos key
71 + file.read(reinterpret_cast<char*>(&_channels[j]._positionKeys[i].mTime),
72 + sizeof(_channels[j]._positionKeys[i].mTime));// pos key
73 + file.read(reinterpret_cast<char*>(&_channels[j]._positionKeys[i].mValue),
74 + sizeof(_channels[j]._positionKeys[i].mValue));// pos key
67 75 }
68 76
69 77 nsize =static_cast<uint32_t>(_channels[j]._rotationKeys.size());
70 78 file.read(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));// the number of position keys
71 79 _channels[j]._rotationKeys.resize(nsize);
72 80 for(vectorAlg::vecSize i(0); i< nsize; i++){// for each channel
73 - file.read(reinterpret_cast<char*>(&_channels[j]._rotationKeys[i].mTime), sizeof(_channels[j]._rotationKeys[i].mTime));// pos key
74 - file.read(reinterpret_cast<char*>(&_channels[j]._rotationKeys[i].mValue), sizeof(_channels[j]._rotationKeys[i].mValue));// pos key
81 + file.read(reinterpret_cast<char*>(&_channels[j]._rotationKeys[i].mTime),
82 + sizeof(_channels[j]._rotationKeys[i].mTime));// pos key
83 + file.read(reinterpret_cast<char*>(&_channels[j]._rotationKeys[i].mValue),
84 + sizeof(_channels[j]._rotationKeys[i].mValue));// pos key
75 85 }
76 86
77 87 nsize =static_cast<uint32_t>(_channels[j]._scalingKeys.size());
78 88 file.read(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));// the number of position keys
79 89 _channels[j]._scalingKeys.resize(nsize);
80 90 for(vectorAlg::vecSize i(0); i< nsize; i++){// for each channel
81 - file.read(reinterpret_cast<char*>(&_channels[j]._scalingKeys[i].mTime), sizeof(_channels[j]._scalingKeys[i].mTime));// pos key
82 - file.read(reinterpret_cast<char*>(&_channels[j]._scalingKeys[i].mValue), sizeof(_channels[j]._scalingKeys[i].mValue));// pos key
91 + file.read(reinterpret_cast<char*>(&_channels[j]._scalingKeys[i].mTime),
92 + sizeof(_channels[j]._scalingKeys[i].mTime));// pos key
93 + file.read(reinterpret_cast<char*>(&_channels[j]._scalingKeys[i].mValue),
94 + sizeof(_channels[j]._scalingKeys[i].mValue));// pos key
83 95 }
84 96 }
85 97 _lastPositions.resize( _channels.size(), vec3<U32>());
  @@ -116,7 +128,8 @@
116 128 for(uint32_t i(0); i< nsize; i++){
117 129 _animations[i].Load(file);
118 130 }
119 - for(uint32_t i(0); i< _animations.size(); i++){// get all the animation names so I can reference them by name and get the correct id
131 + // get all the animation names so I can reference them by name and get the correct id
132 + for(uint32_t i(0); i< _animations.size(); i++){
120 133 _animationNameToId.insert(hashMapImpl<stringImpl, uint32_t>::value_type(_animations[i]._name, i));
121 134 }
122 135
  @@ -153,20 +166,28 @@
153 166 D_PRINT_FN(Locale::get("LOAD_ANIMATIONS_END"), _bones.size());
154 167 }
155 168
156 - void SceneAnimator::SaveSkeleton(std::ofstream& file, Bone* parent){
169 + void SceneAnimator::SaveSkeleton(std::ofstream& file, Bone* parent) {
157 170 uint32_t nsize = static_cast<uint32_t>(parent->_name.size());
158 - file.write(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));// the number of chars
159 - file.write(parent->_name.c_str(), nsize);// the name of the bone
160 - file.write(reinterpret_cast<char*>(&parent->_offsetMatrix), sizeof(parent->_offsetMatrix));// the bone offsets
161 - file.write(reinterpret_cast<char*>(&parent->_originalLocalTransform), sizeof(parent->_originalLocalTransform));// original bind pose
162 - nsize = static_cast<uint32_t>(parent->_children.size());// number of children
163 - file.write(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));// the number of children
164 - for( vectorImpl<Bone*>::iterator it = parent->_children.begin(); it != parent->_children.end(); ++it)// continue for all children
171 + // the number of chars
172 + file.write(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));
173 + // the name of the bone
174 + file.write(parent->_name.c_str(), nsize);
175 + // the bone offsets
176 + file.write(reinterpret_cast<char*>(&parent->_offsetMatrix), sizeof(parent->_offsetMatrix));
177 + // original bind pose
178 + file.write(reinterpret_cast<char*>(&parent->_originalLocalTransform), sizeof(parent->_originalLocalTransform));
179 + // number of children
180 + nsize = static_cast<uint32_t>(parent->_children.size());
181 + // the number of children
182 + file.write(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));
183 + // continue for all children
184 + for (vectorImpl<Bone*>::iterator it = parent->_children.begin(); it != parent->_children.end(); ++it) {
165 185 SaveSkeleton(file, *it);
186 + }
166 187 }
167 188
168 189 Bone* SceneAnimator::LoadSkeleton(std::ifstream& file, Bone* parent){
169 - Bone* internalNode = New Bone();// create a node
190 + Bone* internalNode = MemoryManager_NEW Bone();// create a node
170 191 internalNode->_parent = parent; //set the parent, in the case this is theroot node, it will be null
171 192 uint32_t nsize=0;
172 193 file.read(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));// the number of chars
  @@ -175,16 +196,19 @@
175 196 temp[nsize]=0;
176 197 internalNode->_name = temp;
177 198 _bonesByName[internalNode->_name] = internalNode;// use the name as a key
178 - file.read(reinterpret_cast<char*>(&internalNode->_offsetMatrix), sizeof(internalNode->_offsetMatrix));// the bone offsets
179 - file.read(reinterpret_cast<char*>(&internalNode->_originalLocalTransform), sizeof(internalNode->_originalLocalTransform));// original bind pose
180 -
181 - internalNode->_localTransform = internalNode->_originalLocalTransform;// a copy saved
199 + // the bone offsets
200 + file.read(reinterpret_cast<char*>(&internalNode->_offsetMatrix), sizeof(internalNode->_offsetMatrix));
201 + // original bind pose
202 + file.read(reinterpret_cast<char*>(&internalNode->_originalLocalTransform), sizeof(internalNode->_originalLocalTransform));
203 + // a copy saved
204 + internalNode->_localTransform = internalNode->_originalLocalTransform;
182 205 CalculateBoneToWorldTransform(internalNode);
206 + // the number of children
207 + file.read(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));
183 208
184 - file.read(reinterpret_cast<char*>(&nsize), sizeof(uint32_t));// the number of children
185 -
209 + // recursivly call this function on all children
186 210 // continue for all child nodes and assign the created internal nodes as our children
187 - for( U32 a = 0; a < nsize && file; a++){// recursivly call this function on all children
211 + for( U32 a = 0; a < nsize && file; a++) {
188 212 internalNode->_children.push_back(LoadSkeleton(file, internalNode));
189 213 }
190 214 return internalNode;