MCPcopy Create free account
hub / github.com/cinder/Cinder / parseMaterial

Method parseMaterial

src/cinder/ObjLoader.cpp:146–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146void ObjLoader::parseMaterial( std::shared_ptr<IStreamCinder> material )
147{
148 Material m;
149 m.Ka[0] = m.Ka[1] = m.Ka[2] = 1.0f;
150 m.Kd[0] = m.Kd[1] = m.Kd[2] = 1.0f;
151
152 while( ! material->isEof() ) {
153 string line = material->readLine();
154 if( line.empty() || line[0] == '#' )
155 continue;
156
157 while( line.back() == '\\' && ! material->isEof() ) {
158 auto next = material->readLine();
159 line = line.substr( 0, line.size() - 1 ) + next;
160 }
161
162 string tag;
163 stringstream ss( line );
164 ss >> tag;
165 if( tag == "newmtl" ) {
166 if( m.mName.length() > 0 )
167 mMaterials[m.mName] = m;
168
169 ss >> m.mName;
170 m.Ka[0] = m.Ka[1] = m.Ka[2] = 1.0f;
171 m.Kd[0] = m.Kd[1] = m.Kd[2] = 1.0f;
172 }
173 else if( tag == "Ka" ) {
174 ss >> m.Ka[0] >> m.Ka[1] >> m.Ka[2];
175 }
176 else if( tag == "Kd" ) {
177 ss >> m.Kd[0] >> m.Kd[1] >> m.Kd[2];
178 }
179 }
180 if( m.mName.length() > 0 )
181 mMaterials[m.mName] = m;
182}
183
184void ObjLoader::parse( bool includeNormals, bool includeTexCoords )
185{

Callers

nothing calls this directly

Calls 7

readLineMethod · 0.80
backMethod · 0.80
substrMethod · 0.80
isEofMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected