void setupLights() { Obj.ambientIntensity = 1.0f; Obj.ambientColor = vec3(0.2,0.2,0.2); light3 l; l.on = true; l.orient = vecMath::Normalize(vec3(1.0f,0.0f,0.2f)); l.origin = vec3(0.0,1.0,0.0); l.color = vec3(1.0,0.0,0.0); Lights.push_back(l); l.on = true; l.orient = vecMath::Normalize(vec3(0.0f,1.0f,0.2f)); l.origin = vec3(0.0,-1.333,0.0); l.color = vec3(0.0,1.0,0.0); Lights.push_back(l); l.on = true; l.orient = vecMath::Normalize(vec3(1.0f,1.0f,0.2f)); l.origin = vec3(1.5,1.5,0.0); l.color = vec3(0.0,0.0,1.0); Lights.push_back(l); }
void LoadLight(TiXmlElement *element) { Light *light = NULL; // name const char* name = element->Attribute("name"); printf("Light ["); if ( name ) printf("%s",name); printf("]"); // type const char* type = element->Attribute("type"); if ( type ) { if ( COMPARE(type,"ambient") ) { printf(" - Ambient\n"); AmbientLight *l = new AmbientLight(); light = l; for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) { if ( COMPARE( child->Value(), "intensity" ) ) { Color c(1,1,1); ReadColor( child, c ); l->SetIntensity(c); printf(" intensity %f %f %f\n",c.r,c.g,c.b); } } } else if ( COMPARE(type,"direct") ) { printf(" - Direct\n"); DirectLight *l = new DirectLight(); light = l; for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) { if ( COMPARE( child->Value(), "intensity" ) ) { Color c(1,1,1); ReadColor( child, c ); l->SetIntensity(c); printf(" intensity %f %f %f\n",c.r,c.g,c.b); } else if ( COMPARE( child->Value(), "direction" ) ) { Point3 v(1,1,1); ReadVector( child, v ); l->SetDirection(v); printf(" direction %f %f %f\n",v.x,v.y,v.z); } } } else if ( COMPARE(type,"point") ) { printf(" - Point\n"); PointLight *l = new PointLight(); light = l; for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) { if ( COMPARE( child->Value(), "intensity" ) ) { Color c(1,1,1); ReadColor( child, c ); l->SetIntensity(c); printf(" intensity %f %f %f\n",c.r,c.g,c.b); } else if ( COMPARE( child->Value(), "position" ) ) { Point3 v(0,0,0); ReadVector( child, v ); l->SetPosition(v); printf(" position %f %f %f\n",v.x,v.y,v.z); } } } else { printf(" - UNKNOWN\n"); } } if ( light ) { light->SetName(name); lights.push_back(light); } }