コード例 #1
0
bool parseMaterial(XMLElement* node, MaterialMap& materials) {
  const char* attr;
  attr = node->Attribute("name");
  if (!attr || strlen(attr) == 0) {
    cerr << "WARNING: material tag is missing a name" << endl;
    return false;
  }
  string name(attr);
  auto material_iter = materials.find(name);
  bool already_in_map = false;
  if (material_iter != materials.end()) {
    already_in_map = true;
  }

  Vector4d rgba;
  XMLElement* color_node = node->FirstChildElement("color");
  if (color_node) {
    if (!parseVectorAttribute(color_node, "rgba", rgba)) {
      cerr << "WARNING: color tag is missing rgba attribute" << endl;
      return false;
    }
    materials[name] = rgba;
  } else if (!already_in_map) {
    cerr << "WARNING: material \"" << name
         << "\" is not a simple color material (so is currently unsupported)"
         << endl;
    return false;
  }
  return true;
}
コード例 #2
0
ファイル: Mesh.cpp プロジェクト: elmordo/hairy-octo-archer
void Mesh::render(const MaterialMap &mats) const {
	// index aktualni skupiny
	size_t index = 0;

	// pomocny seznam materialu pro predavani vertexgrupe pri renderu
	MaterialMap localMats;

	// iterace nad skupinami a jejich vykresleni
	for (VGList::const_iterator pos = vg.begin(); pos != vg.end(); pos++, index++) {
		// vyhodnoceni materialu

		// pokud index v danem seznamu existuje, zapise se
		MaterialMap::const_iterator matPos = mats.find(index);

		if (matPos != mats.end()) {
			localMats[0] = matPos->second;
		} else {
			localMats[0] = 0x0;
		}


		pos->render(localMats);
	}
}
コード例 #3
0
ファイル: GothOgre_Mtl.cpp プロジェクト: raduetsya/GothOgre
//------------------------------------------------------------------------
Mtl::MaterialIterator::MaterialIterator( const MaterialMap& _materialMap )
    : IteratorWrapper<MaterialMap, MaterialMap::const_iterator, MaterialPtr>
      ( _materialMap.begin(), _materialMap.end() )
{
}