本文整理汇总了C++中LightSource::setDiffuseCoef方法的典型用法代码示例。如果您正苦于以下问题:C++ LightSource::setDiffuseCoef方法的具体用法?C++ LightSource::setDiffuseCoef怎么用?C++ LightSource::setDiffuseCoef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LightSource
的用法示例。
在下文中一共展示了LightSource::setDiffuseCoef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void Config::load(SceneRenderer * sceneRenderer, Manager * manager) {
Json::Value root; // will contains the root value after parsing.
Json::Reader reader;
std::ifstream file;
file.open(fileName);
bool parsingSuccessful = reader.parse(file, root, false);
file.close();
if(!parsingSuccessful) {
// report to the user the failure and their locations in the document.
System::Console::WriteLine("Failed to parse configuration\n");
System::Console::WriteLine(gcnew System::String(reader.getFormatedErrorMessages().c_str()));
throw std::runtime_error("Failed to parse configuration file: "+fileName);
}
Json::Value sceneJSON = root.get("scene", NULL);
Scene * scene = sceneRenderer->getScene();
Json::Value bgColorJSON = sceneJSON.get("backgroundColor", NULL);
if(bgColorJSON != NULL) {
scene->setBackgroundColor(jsonToColor(bgColorJSON));
}
Json::Value lightsJSON = sceneJSON.get("lights", NULL);
if(lightsJSON != NULL) {
Json::Value::Members lightsName = lightsJSON.getMemberNames();
for(std::vector<std::string>::iterator it = lightsName.begin(); it != lightsName.end(); it++) {
std::string lightName = *it;
Json::Value lightJSON = lightsJSON[lightName];
RGBColor lightColor = jsonToColor(lightJSON["color"]);
LightSource * light;
std::string lightTypeStr = lightJSON["type"].asString();
if(lightTypeStr == "AmbientLightSource") {
light = new AmbientLightSource(lightColor);
} else if(lightTypeStr == "PointLightSource") {
light = new PointLightSource(jsonToP3(lightJSON["position"]), lightColor);
Json::Value specularCoefJSON = lightJSON.get("specularCoef", NULL);
PointLightSource * pLight = static_cast<PointLightSource*>(light);
if(specularCoefJSON != NULL) {
pLight->setSpecularCoef(specularCoefJSON.asDouble());
}
Json::Value specularExpJSON = lightJSON.get("specularExponent", NULL);
if(specularExpJSON != NULL) {
pLight->setSpecularExponent(specularExpJSON.asDouble());
}
}
Json::Value diffuseCoefJSON = lightJSON.get("diffuseCoef", NULL);
if(diffuseCoefJSON != NULL) {
light->setDiffuseCoef(diffuseCoefJSON.asDouble());
}
//scene->addLightSource(light);
manager->getLightSources()->add(lightName, light, lightTypeStr);
}
}
Json::Value objectsJSON = sceneJSON.get("objects", NULL);
if(objectsJSON != NULL) {
Json::Value::Members objectsName = objectsJSON.getMemberNames();
for(std::vector<std::string>::iterator it = objectsName.begin(); it != objectsName.end(); it++) {
std::string objectName = *it;
Json::Value object3DJSON = objectsJSON[objectName];
Object3D * object3D;
std::string oject3DTypeStr = object3DJSON["type"].asString();
if(oject3DTypeStr == "Sphere") {
object3D = new Sphere(jsonToP3(object3DJSON["center"]),
object3DJSON["radius"].asDouble());
} else if(oject3DTypeStr == "Plane") {
if(object3DJSON.get("u", NULL) != NULL) {
object3D = new Plane(jsonToP3(object3DJSON["p"]),
jsonToP3(object3DJSON["u"]),
jsonToP3(object3DJSON["v"]));
} else {
object3D = new Plane(jsonToP3(object3DJSON["p"]),
jsonToP3(object3DJSON["normal"]));
}
} else if(oject3DTypeStr == "Triangle") {
object3D = new Triangle(jsonToP3(object3DJSON["A"]),
jsonToP3(object3DJSON["B"]),
jsonToP3(object3DJSON["C"]));
}
//scene->addObject3D(object3D);
manager->getObjects3D()->add(objectName, object3D, oject3DTypeStr);
}
}
Json::Value polyhedraJSON = sceneJSON.get("polyhedra", NULL);
if(polyhedraJSON != NULL) {
Json::Value::Members polyhedraName = polyhedraJSON.getMemberNames();
for(std::vector<std::string>::iterator it = polyhedraName.begin(); it != polyhedraName.end(); it++) {
std::string objectName = *it;
Json::Value polyhedronJSON = polyhedraJSON[objectName];
Polyhedron * polyhedron;
std::string polyhedronTypeStr = polyhedronJSON["type"].asString();
if(polyhedronTypeStr == "Parallelepiped") {
polyhedron = new Parallelepiped(jsonToP3(polyhedronJSON["A"]),
jsonToP3(polyhedronJSON["B"]),
jsonToP3(polyhedronJSON["C"]),
jsonToP3(polyhedronJSON["D"]));
} else if(polyhedronTypeStr == "Maya") {
std::vector<Triangle*> triangles;
//.........这里部分代码省略.........