bool avtSILMatrix::GetMaterialList(int index, MaterialList &matlist, const vector<unsigned char> &useSet) const { int set1size = static_cast<int>(set1.size()); int set2size = static_cast<int>(set2.size()); int usedOne = 0; int didntUseOne = 0; if (index < set1size) { if (role2 != SIL_MATERIAL) { return false; } int row = index; for (int i = 0 ; i < set2size ; i++) { int set = setsStartAt + row*set2size + i; if (useSet[set] != NoneUsed) { usedOne++; avtSILSet_p s2 = sil->GetSILSet(set2[i]); matlist.push_back(s2->GetName()); } else { didntUseOne++; } } } else { if (role1 != SIL_MATERIAL) { return false; } int column = index - set1size; for (int i = 0 ; i < set1size ; i++) { int set = setsStartAt + i*set2size + column; if (useSet[set] != NoneUsed) { usedOne++; avtSILSet_p s1 = sil->GetSILSet(set1[i]); matlist.push_back(s1->GetName()); } else { didntUseOne++; } } } return (usedOne != 0 && didntUseOne != 0 ? true : false); }
int addMaterial(IStorm3D_Material *stormMaterial) { assert(stormMaterial); Material material = createMaterial(static_cast<Storm3D_Material *> (stormMaterial), tree.get()); for(unsigned int i = 0; i < materials.size(); ++i) { if(equals(materials[i], material)) return i; } int index = materials.size(); material.materialIndex = index; materials.push_back(material); return index; }
void LoadMaterial(TiXmlElement *element) { Material *mtl = NULL; // name const char* name = element->Attribute("name"); printf("Material ["); if ( name ) printf("%s",name); printf("]"); // type const char* type = element->Attribute("type"); if ( type ) { if ( COMPARE(type,"blinn") ) { printf(" - Blinn\n"); MtlBlinn *m = new MtlBlinn(); mtl = m; for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) { Color c(1,1,1); float f=1; if ( COMPARE( child->Value(), "diffuse" ) ) { ReadColor( child, c ); m->SetDiffuse(c); printf(" diffuse %f %f %f\n",c.r,c.g,c.b); } else if ( COMPARE( child->Value(), "specular" ) ) { ReadColor( child, c ); m->SetSpecular(c); printf(" specular %f %f %f\n",c.r,c.g,c.b); } else if ( COMPARE( child->Value(), "glossiness" ) ) { ReadFloat( child, f ); m->SetGlossiness(f); printf(" glossiness %f\n",f); } } } else { printf(" - UNKNOWN\n"); } } if ( mtl ) { mtl->SetName(name); materials.push_back(mtl); } }
void avtSILRestrictionTraverser::PrepareForMaterialSearches(void) { int timingsHandle = visitTimer->StartTimer(); if (silr->GetNumCollections() < 10) { bool haveMaterialCollection = false; for (int c = 0 ; c < silr->GetNumCollections() ; c++) { avtSILCollection_p coll = silr->GetSILCollection(c); if (coll->GetRole() == SIL_MATERIAL) haveMaterialCollection = true; } if (!haveMaterialCollection) { noMaterials = true; preparedForMaterialSearches = true; visitTimer->StopTimer(timingsHandle, "Prep for material searches (early return)"); return; } } //TODO: See if this increased size is a problem. -DJB vector<bool> setIsInProcessList(silr->GetNumSets(), false); vector<int> setsToProcess; setsToProcess.push_back(silr->topSet); setIsInProcessList[silr->topSet] = true; const vector<unsigned char> &useSet = silr->useSet; for (int i = 0 ; i < setsToProcess.size() ; i++) { if (useSet[setsToProcess[i]] == NoneUsed) { continue; } if (!silr->SILSetHasMapsOut(setsToProcess[i])) { continue; } avtSILSet_p currentSet = silr->GetSILSet(setsToProcess[i]); int chunk = currentSet->GetIdentifier(); const vector<int> &mapsOut = currentSet->GetMapsOut(); for (int j = 0 ; j < mapsOut.size() ; j++) { avtSILArray_p pArray = NULL; avtSILMatrix_p pMat = NULL; int newCollIndex = 0; avtSIL::EntryType t = silr->GetCollectionSource(mapsOut[j], pArray, pMat, newCollIndex); if (t == avtSIL::COLLECTION || t == avtSIL::ARRAY) { avtSILCollection_p coll = silr->GetSILCollection(mapsOut[j]); if (coll->GetRole() == SIL_MATERIAL) { if (chunk == -1) { continue; } else { const avtSILNamespace *ns = coll->GetSubsets(); int numElems = ns->GetNumberOfElements(); int usedOne = 0; int didntUseOne = 0; MaterialList l; for (int k = 0 ; k < numElems ; k++) { int setId = ns->GetElement(k); if (useSet[setId]) { usedOne++; l.push_back( silr->GetSILSet(setId)->GetName()); } else { didntUseOne++; } } bool shouldMatSel = (usedOne != 0 && didntUseOne != 0 ? true : false); AddMaterialList(chunk, l, shouldMatSel); } } else { const avtSILNamespace *ns = coll->GetSubsets(); int numElems = ns->GetNumberOfElements(); for (int k = 0 ; k < numElems ; k++) { int setId = ns->GetElement(k); if (!setIsInProcessList[setId]) { setsToProcess.push_back(setId); setIsInProcessList[setId] = true; } } } } else { if (pMat->GetRoleForCollection(newCollIndex) == SIL_MATERIAL) { MaterialList l; bool shouldMatSel = pMat->GetMaterialList(newCollIndex, l, useSet); AddMaterialList(chunk, l, shouldMatSel); } } } } preparedForMaterialSearches = true; visitTimer->StopTimer(timingsHandle, "Getting the material list"); visitTimer->DumpTimings(); }