本文整理汇总了C++中Appearance::setTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ Appearance::setTexture方法的具体用法?C++ Appearance::setTexture怎么用?C++ Appearance::setTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Appearance
的用法示例。
在下文中一共展示了Appearance::setTexture方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processAppearances
void XMLScene::processAppearances(TiXmlElement* appearancesElement)
{
TiXmlElement* element= appearancesElement->FirstChildElement("appearance");
float ambient[4],diffuse[4],specular[4],emissive[4],shininess,sWrap,tWrap;
string textureRef,id;
Appearance* appearance;
while(element!=NULL)
{
id=element->Attribute("id");
read1Float("shininess",element,shininess);
if(element->Attribute("textureref")!=NULL)
textureRef=element->Attribute("textureref");
else textureRef="";
TiXmlElement* component = element ->FirstChildElement();
while(component != NULL){
if(component->Attribute("type")=="ambient"){
read4Float("value", element, ambient[0], ambient[1], ambient[2],
ambient[3]);}
if(component->Attribute("type")=="diffuse"){
read4Float("value", element, diffuse[0], diffuse[1], diffuse[2],
diffuse[3]);}
if(component->Attribute("type")=="specular"){
read4Float("value", element, specular[0], specular[1], specular[2],
specular[3]);
}
component=component->NextSiblingElement();
}
if(textureRef!=""){
Texture* temp = Textures[textureRef];
appearance = new Appearance(ambient,diffuse,specular,emissive,shininess,temp->getSWrap(),temp->getTWrap(),textureRef);
appearance->setTextureWrap(appearance->getSWrap(),appearance->getTWrap());
appearance->setTexture(sceneTextures[textureRef]);
}
else
appearance = new Appearance(ambient,diffuse,specular,emissive,shininess,1,1,textureRef);
appearances[id]=appearance;
element=element->NextSiblingElement("appearance");
}
}
示例2: processAppearances
void YafFile::processAppearances(TiXmlElement* appearancesElement)
{
TiXmlElement* element= appearancesElement->FirstChildElement("appearance");
float ambient[4],diffuse[4],specular[4],emissive[4],shininess,sWrap,tWrap;
string textureRef,id;
while(element!=NULL)
{
id=element->Attribute("id");
read4Float("ambient", element, ambient[0], ambient[1], ambient[2],
ambient[3]);
read4Float("emissive", element, emissive[0], emissive[1], emissive[2],
emissive[3]);
read4Float("diffuse", element, diffuse[0], diffuse[1], diffuse[2],
diffuse[3]);
read4Float("specular", element, specular[0], specular[1], specular[2],
specular[3]);
element->QueryFloatAttribute("shininess",&shininess);
if(element->Attribute("texlength_t")!=NULL)
element->QueryFloatAttribute("texlength_t",&tWrap);
else tWrap=0;
if(element->Attribute("texlength_s")!=NULL)
element->QueryFloatAttribute("texlength_s",&sWrap);
else sWrap=0;
if(element->Attribute("textureref")!=NULL)
textureRef=element->Attribute("textureref");
else textureRef="";
Appearance* appearance = new Appearance(ambient,diffuse,specular,emissive,shininess,sWrap,tWrap,textureRef);
if(textureRef!="")
{
appearance->setTextureWrap(tWrap,sWrap);
appearance->setTexture(sceneTextures[textureRef]);
}
appearances[id]=appearance;
element=element->NextSiblingElement("appearance");
}
}
示例3: pontoAux
//.........这里部分代码省略.........
appearanceElement->Attribute("specular") != NULL
){
id = appearanceElement->Attribute("id");
ap->setIdS(id);
emissiveS = appearanceElement->Attribute("emissive");
float Aemissive[4];
sscanf_s(emissiveS.c_str(),"%f %f %f %f", &Aemissive[0], &Aemissive[1], &Aemissive[2], &Aemissive[3]);
ap->setEmissive(Aemissive);
ambientS = appearanceElement->Attribute("ambient");
float Aambient[4];
sscanf_s(ambientS.c_str(),"%f %f %f %f", &Aambient[0], &Aambient[1], &Aambient[2], &Aambient[3]);
ap->setAmbient(Aambient);
diffuseS = appearanceElement->Attribute("diffuse");
float Adiffuse[4];
sscanf_s(diffuseS.c_str(),"%f %f %f %f", &Adiffuse[0], &Adiffuse[1], &Adiffuse[2], &Adiffuse[3]);
ap->setDiffuse(Adiffuse);
specularS = appearanceElement->Attribute("specular");
float Aspecular[4];
sscanf_s(specularS.c_str(),"%f %f %f %f", &Aspecular[0], &Aspecular[1], &Aspecular[2], &Aspecular[3]);
ap->setSpecular(Aspecular);
if(appearanceElement->Attribute("textureref") != NULL)
{
if(appearanceElement->QueryFloatAttribute("texlength_s",&texlength_s)==TIXML_SUCCESS &&
appearanceElement->QueryFloatAttribute("texlength_t",&texlength_t)==TIXML_SUCCESS)
{
textureref = appearanceElement->Attribute("textureref");
ap->setTextureReference(textureref);
//ap->setTexture(textureref);
ap->setTextureWrap(texlength_s,texlength_t);
ap->setShininess(shininess);
int itTexturesComp = 0;
std::vector<Texture*>::iterator it = scene->texturesComp.begin();
for(it; it != scene->texturesComp.end(); it++){
if(textureref == scene->texturesComp.at(itTexturesComp)->getTId()){
ap->setTexture((*it));
}
itTexturesComp++;
}
}
}
//printf("\tApearance attributes:\n");
//printf("\t\tId: %s \n\t\tEmissive: %s \n\t\tAmbient: %s\n", id.c_str(), emissiveS.c_str(), ambientS.c_str());
//printf("\t\tDiffuse: %s \n\t\tSpecular: %s \n\t\tTextureRef: %s \n\t\tShininess: %f\n", diffuseS.c_str(), specularS.c_str(), textureref.c_str(), shininess);
if(textureref.length()==0){}
//printf("\t\tTexLength S: %f \n\t\tTexLength T: %f\n", texlength_s, texlength_t);
scene->appearancesComp.push_back(ap);
}
else
printf("Error parsing Appearance Element\n");
appearanceElement = appearanceElement->NextSiblingElement();
}
示例4: loadPackedMedia
bool PraetoriansTerrainWater::loadPackedMedia(const char* path)
{
unsigned int signature;
unsigned short chunkid;
unsigned int chunklength;
unsigned int texturescount;///use one in this version
unsigned int watercount;
unsigned int vertexcount;
unsigned int indexcount;
Tuple3f* vertices;
unsigned short* indices;
Tuple4ub* colors;
Tuple2f* txcoords;
ArchivedFile* file;
WaterDatabase* wdatabase;
if (!(file = FileSystem::checkOut(path)))
return Logger::writeErrorLog(String("Could not load -> ") + path);
wdatabase = Gateway::getWaterDatabase();
file->read(&signature, 4);
file->read(&chunkid, 2);
file->read(&chunklength, 4);
file->read(&texturescount, 4);
for (unsigned int i = 0; i < texturescount; i++)
file->seek((256 * 256 * 4) + 6, SEEKD);
file->read(&watercount, 4);
for (unsigned int i = 0; i < watercount; i++)
{
file->read(&chunkid, 2);
file->read(&chunklength, 4);
file->seek(48, SEEKD);
file->read(&vertexcount, 4);
vertices = new Tuple3f[vertexcount];
colors = new Tuple4ub[vertexcount];
txcoords = new Tuple2f[vertexcount];
for (unsigned int j = 0; j < vertexcount; j++)
{
file->read(vertices[j], 12);
Swap(vertices[j].x, vertices[j].z);
file->read(colors[j], 4);
Swap(colors[j].x, colors[j].z);
file->read(txcoords[j], 8);
}
file->read(&indexcount, 4);
indices = new unsigned short[indexcount];
file->read(indices, indexcount * 2);
String watername = String("H2O_") + int(wdatabase->getWatersCount());
Geometry* geometry;
geometry = new Geometry(watername, indexcount, vertexcount);
geometry->setIndices(indices, false);
geometry->setVertices(vertices, false);
geometry->setColors(colors, false);
geometry->setTextureElements(txcoords, 2, false);
geometry->computeBounds();
Appearance* appearance = new Appearance();
appearance->setBlendAttributes(BlendAttributes(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
appearance->setTexture(0, wdatabase->getWaterTexture());
Model* model = new Model();
model->setAppearance(appearance);
model->setGeometry(geometry);
TransformGroup* group = new TransformGroup();
group->addChild(model);
group->updateBoundsDescriptor();
wdatabase->addWaterModel(group);
deleteArray(vertices);
deleteArray(indices);
deleteArray(colors);
deleteArray(txcoords);
}
FileSystem::checkIn(file);
return true;
}