Read the text line that defines a plane and push it into the vector container.
214 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
215 boost::char_separator<char> space{
" "};
216 tokenizer tok{_text,space};
217 tokenizer::iterator it = tok.begin();
224 std::string plane_name = *it; it++;
226 tmp = *it; distance = atof(tmp.c_str()); it++;it++;
227 tmp = *it; nX = atof(tmp.c_str()); it++;
228 tmp = *it; nY = atof(tmp.c_str()); it++;
229 tmp = *it; nZ = atof(tmp.c_str()); it++;it++;
231 if (tmp ==
"@checker")
233 float col1_r, col1_g, col1_b, col2_r, col2_g, col2_b; it++;it++;
235 tmp = *it; col1_r = atof(tmp.c_str());it++;
236 tmp = *it; col1_g = atof(tmp.c_str());it++;
237 tmp = *it; col1_b = atof(tmp.c_str());it++; it++; it++;
238 tmp = *it; col2_r = atof(tmp.c_str());it++;
239 tmp = *it; col2_g = atof(tmp.c_str());it++;
240 tmp = *it; col2_b = atof(tmp.c_str());it++; it++;
243 if (tmp ==
"@specularHardness")
246 float specularHardness;
247 tmp = *it; specularHardness = atof(tmp.c_str());
249 geo::Shape* plane =
new geo::Plane(distance,ngl::Vec3(nX,nY,nZ),ngl::Colour(col1_r,col1_g,col1_b,1), ngl::Colour(col2_r,col2_g,col2_b,1));
250 plane->getMaterial()->m_spec_hardness = specularHardness;
251 _scene_objects.push_back(plane);
253 std::cout <<
"OK! Plane " << plane_name <<
" has been parsed successfully.\n";
257 geo::Shape* plane =
new geo::Plane(distance,ngl::Vec3(nX,nY,nZ),ngl::Colour(col1_r,col1_g,col1_b,1), ngl::Colour(col2_r,col2_g,col2_b,1));
258 _scene_objects.push_back(plane);
260 std::cout <<
"OK! Plane " << plane_name <<
" has been parsed successfully.\n";
265 float col_r, col_g, col_b;
267 tmp = *it; col_r = atof(tmp.c_str()); it++;
268 tmp = *it; col_g = atof(tmp.c_str()); it++;
269 tmp = *it; col_b = atof(tmp.c_str()); it++; it++;
272 if(tmp ==
"@specularHardness")
275 float specularHardness;
276 tmp = *it; specularHardness = atof(tmp.c_str());
278 geo::Shape* plane =
new geo::Plane(distance,ngl::Vec3(nX,nY,nZ),ngl::Colour(col_r,col_g,col_b,1));
279 plane->getMaterial()->m_spec_hardness = specularHardness;
280 _scene_objects.push_back(plane);
282 std::cout <<
"OK! Plane " << plane_name <<
" has been parsed successfully.\n";
286 geo::Shape* plane =
new geo::Plane(distance,ngl::Vec3(nX,nY,nZ),ngl::Colour(col_r,col_g,col_b,1));
287 _scene_objects.push_back(plane);
288 std::cout <<
"OK! Plane " << plane_name <<
" has been parsed successfully.\n";
Inherits from shape. Implements functionability for plane shape and its materials. and the ray-plane intersections algorithms.
Semi abstract class with virtual methods that holds all the calls for getting intersections, getting normals, also for specifying the properties of the material that will be hold by the Material member of this class.