------------------------------------------------------------------------------------------------ Imports the given file into the given scene structure.
| 99 | // ------------------------------------------------------------------------------------------------ |
| 100 | // Imports the given file into the given scene structure. |
| 101 | void CSMImporter::InternReadFile( const std::string& pFile, |
| 102 | aiScene* pScene, IOSystem* pIOHandler) { |
| 103 | std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb")); |
| 104 | |
| 105 | // Check whether we can read from the file |
| 106 | if (file == nullptr) { |
| 107 | throw DeadlyImportError( "Failed to open CSM file ", pFile, "."); |
| 108 | } |
| 109 | |
| 110 | // allocate storage and copy the contents of the file to a memory buffer |
| 111 | std::vector<char> mBuffer2; |
| 112 | TextFileToBuffer(file.get(),mBuffer2); |
| 113 | const char* buffer = &mBuffer2[0]; |
| 114 | const char *end = &mBuffer2[mBuffer2.size() - 1] + 1; |
| 115 | std::unique_ptr<aiAnimation> anim(new aiAnimation()); |
| 116 | int first = 0, last = 0x00ffffff; |
| 117 | |
| 118 | // now process the file and look out for '$' sections |
| 119 | while (true) { |
| 120 | SkipSpaces(&buffer, end); |
| 121 | if ('\0' == *buffer) { |
| 122 | break; |
| 123 | } |
| 124 | |
| 125 | if ('$' == *buffer) { |
| 126 | ++buffer; |
| 127 | if (TokenMatchI(buffer,"firstframe",10)) { |
| 128 | SkipSpaces(&buffer, end); |
| 129 | first = strtol10(buffer,&buffer); |
| 130 | } |
| 131 | else if (TokenMatchI(buffer,"lastframe",9)) { |
| 132 | SkipSpaces(&buffer, end); |
| 133 | last = strtol10(buffer,&buffer); |
| 134 | } |
| 135 | else if (TokenMatchI(buffer,"rate",4)) { |
| 136 | SkipSpaces(&buffer, end); |
| 137 | float d = { 0.0f }; |
| 138 | buffer = fast_atoreal_move(buffer,d); |
| 139 | anim->mTicksPerSecond = d; |
| 140 | } |
| 141 | else if (TokenMatchI(buffer,"order",5)) { |
| 142 | std::vector< aiNodeAnim* > anims_temp; |
| 143 | anims_temp.reserve(30); |
| 144 | while (true) { |
| 145 | SkipSpaces(&buffer, end); |
| 146 | if (IsLineEnd(*buffer) && SkipSpacesAndLineEnd(&buffer, end) && *buffer == '$') |
| 147 | break; // next section |
| 148 | |
| 149 | // Construct a new node animation channel and setup its name |
| 150 | anims_temp.push_back(new aiNodeAnim()); |
| 151 | aiNodeAnim* nda = anims_temp.back(); |
| 152 | |
| 153 | char *ot = nda->mNodeName.data; |
| 154 | const char *ot_end = nda->mNodeName.data + AI_MAXLEN; |
| 155 | while (!IsSpaceOrNewLine(*buffer) && buffer != end && ot != ot_end) { |
| 156 | *ot++ = *buffer++; |
| 157 | } |
| 158 |
nothing calls this directly
no test coverage detected