MCPcopy Create free account
hub / github.com/assimp/assimp / InternReadFile

Method InternReadFile

code/AssetLib/CSM/CSMLoader.cpp:101–302  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Imports the given file into the given scene structure.

Source from the content-addressed store, hash-verified

99// ------------------------------------------------------------------------------------------------
100// Imports the given file into the given scene structure.
101void 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

Callers

nothing calls this directly

Calls 15

DeadlyImportErrorFunction · 0.85
TokenMatchIFunction · 0.85
strtol10Function · 0.85
fast_atoreal_moveFunction · 0.85
IsLineEndFunction · 0.85
IsSpaceOrNewLineFunction · 0.85
strtoul10Function · 0.85
TranslationClass · 0.85
aiMatrix4x4Class · 0.85
warnMethod · 0.80
SkipSpacesFunction · 0.50
SkipSpacesAndLineEndFunction · 0.50

Tested by

no test coverage detected