本文整理汇总了C++中ObjModel::setLight方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjModel::setLight方法的具体用法?C++ ObjModel::setLight怎么用?C++ ObjModel::setLight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjModel
的用法示例。
在下文中一共展示了ObjModel::setLight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildModel
Model* Scene::buildModel(Json::Value model) {
string type = model["class"].asString();
Model *retModel;
// menger
if(type.compare("Menger") == 0) {
vec3 center = getVec3(model.get("center", "[0,0,0]"));
printVec("center",center);
float radius = model.get("radius", "1.0").asFloat();
int subdivs = model.get("subdivisions", "2").asInt();
retModel = new Menger(center, radius, subdivs);
}
// sphere
else if(type.compare("Sphere") == 0) {
Sphere *sphere;
if(!model.isMember("ambient")) {
sphere = new Sphere(
model["radius"].asFloat(),
model["subdivs"].asInt(),
lights.size());
} else {
sphere = new Sphere(
model["radius"].asFloat(),
model["subdivs"].asInt(),
lights.size(),
getVec4(model.get("ambient","[1,0,1,1]")),
getVec4(model.get("diffuse","[1,0.8,0,1]")),
getVec4(model.get("specular","[1,0,1,1]")));
}
vector<Light*>::iterator it;
int light = 0;
for(it = lights.begin(); it != lights.end(); it++) {
sphere->setLight((*it), light++);
}
retModel = sphere;
} else if(type.compare("TexTri") == 0) {
retModel = new TexTri(model["texture"].asString().c_str());
printf("created textri\n");
} else if(type.compare("ObjModel") == 0) {
ObjModel *obj = new ObjModel(model["objfile"].asString().c_str(),
lights.size(),
getVec4(model.get("ambient","[1,1,1,1]")),
getVec4(model.get("diffuse","[1,1,1,1]")),
getVec4(model.get("specular","[1,1,1,1]")));
vector<Light*>::iterator it;
int light = 0;
for(it = lights.begin(); it != lights.end(); it++) {
obj->setLight((*it), light++);
}
retModel = obj;
} else if(type.compare("Tesseract") == 0) {
Tesseract *tess = new Tesseract( lights.size() );
vector<Light*>::iterator it;
int light = 0;
for(it = lights.begin(); it != lights.end(); it++) {
tess->setLight((*it), light++);
}
retModel = tess;
} else if(type.compare("Particles") == 0) {
Particles *part = new Particles( model.get("number",50).asInt() );
retModel = part;
}
// map model if it has an id
if(model.isMember("id")) {
string id = model["id"].asString();
nodes[id] = retModel;
idModels[id] = retModel;
}
return retModel;
}