void Scene::_parseOrthographicCamera( ){ float position[3], lookAt[3], up[3]; _checkToken( "OrthographicCamera" ); _nextToken( ); _checkToken( "{" ); _nextToken( ); _checkToken( "position" ); for( int i = 0; i < 3; i++ ){ _nextToken( ); position[i] = _parseFloat( ); } Point3 pPosition(position); _nextToken( ); _checkToken( "lookAt" ); for( int i = 0; i < 3; i++ ){ _nextToken( ); lookAt[i] = _parseFloat( ); } Point3 pLookAt(lookAt); _nextToken( ); _checkToken( "up" ); for( int i = 0; i < 3; i++ ){ _nextToken( ); up[i] = _parseFloat( ); } Vec3 vUp(up); _nextToken( ); _checkToken( "}" ); // Fill me in! }
void Scene::_parseViewPlane( ){ size_t w, h, s; double p; _nextToken( ); _checkToken( "ViewPlane"); _nextToken( ); _checkToken( "{"); _nextToken( ); _checkToken( "width"); _nextToken( ); w = _parseInt( ); _nextToken( ); _checkToken( "height" ); _nextToken( ); h = _parseInt( ); _nextToken( ); _checkToken( "pixelsize" ); _nextToken( ); p = _parseFloat( ); _nextToken( ); _checkToken( "sampleCount" ); _nextToken( ); s = _parseInt( ); _nextToken( ); _checkToken( "}" ); // Fill me in! }
void Scene::_parsePointLight(uint id){ float vec[4]; _checkToken( "PointLight"); _nextToken( ); _checkToken( "{"); _nextToken( ); _checkToken("position"); for( int i = 0; i < 3; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } Point3 position(vec); _nextToken( ); _checkToken("ambientColor"); for( int i = 0; i < 4; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } RGBAColor ambient(vec); _nextToken( ); _checkToken( "diffuseColor"); for( int i = 0; i < 4; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } RGBAColor diffuse(vec); _nextToken( ); _checkToken("specularColor"); for( int i = 0; i < 4; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } RGBAColor specular(vec); _nextToken( ); _checkToken("constant_attenuation"); _nextToken( ); float constant_attenuation = _parseFloat( ); _nextToken( ); _checkToken("linear_attenuation"); _nextToken( ); float linear_attenuation = _parseFloat( ); _nextToken( ); _checkToken("quadratic_attenuation"); _nextToken( ); float quadratic_attenuation = _parseFloat( ); _nextToken( ); _checkToken( "}"); // Fill me in! }
void Scene::_parseSphere(int i){ float vec[3]; _checkToken( "Sphere"); _nextToken( ); _checkToken( "{" ); _nextToken( ); _checkToken( "center" ); for( int i = 0; i < 3; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } Point3 center(vec[0], vec[1], vec[2]); _nextToken( ); _checkToken( "radius" ); _nextToken( ); float radius = _parseFloat( ); _nextToken( ); _checkToken("}"); // Fill me in! }
void Scene::_parsePhongMaterial(uint id){ float vec[4]; _checkToken( "PhongMaterial"); _nextToken( ); _checkToken( "{"); _nextToken( ); _checkToken("ambientColor"); for( int i = 0; i < 4; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } RGBAColor ambient(vec); _nextToken( ); _checkToken( "diffuseColor"); for( int i = 0; i < 4; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } RGBAColor diffuse(vec); _nextToken( ); _checkToken("specularColor"); for( int i = 0; i < 4; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } RGBAColor specular(vec); _nextToken( ); _checkToken("shininess"); float shininess = _parseFloat( ); _nextToken( ); float indexOfRefraction = 10; if( std::strcmp(_currentToken, "indexOfRefraction") == 0 ){ indexOfRefraction = _parseFloat( ); } _nextToken( ); _checkToken( "}"); // Fill me in! }
void Scene::_parseBackground( ){ unsigned char vec[3]; _nextToken( ); _checkToken( "Background" ); _nextToken( ); _checkToken( "{"); _nextToken( ); _checkToken( "color" ); for( int i = 0; i < 3; i++ ){ _nextToken( ); vec[i] = _parseFloat( ); } _nextToken( ); _checkToken( "}" ); // Fill me in! }
void OptionManager::callOptionHandler (const char* name, const char* value) { if (!typeMap.find(name)) throw Error("Property \"%s\" not defined", name); OPTION_TYPE type = typeMap.at(name); int x = 0, y = 0; float f = 0, r = 0, g = 0, b = 0; switch (type) { case OPTION_STRING: stringSetters.at(name)(value); break; case OPTION_INT: if (_parseInt(value, x) < 0) throw Error("Cannot recognize \"%s\" as an integer value", value); intSetters.at(name)(x); break; case OPTION_BOOL: if (_parseBool(value, x) < 0) throw Error("Cannot recognize \"%s\" as a boolean value", value); boolSetters.at(name)(x); break; case OPTION_FLOAT: if (_parseFloat(value, f) < 0) throw Error("Cannot recognize \"%s\" as a float value", value); floatSetters.at(name)(f); break; case OPTION_COLOR: if (_parseColor(value, r, g, b) < 0) throw Error("Cannot recognize \"%s\" as a color value", value); colorSetters.at(name)(r, g, b); break; case OPTION_XY: if (_parseSize(value, x, y) < 0) throw Error("Cannot recognize \"%s\" as a pair of integers", value); xySetters.at(name)(x, y); break; default: throw Error("Option type not supported"); } }