Material* Material::create(Properties* materialProperties) { // Check if the Properties is valid and has a valid namespace. if (!materialProperties || !(strcmp(materialProperties->getNamespace(), "material") == 0)) { GP_ERROR("Properties object must be non-null and have namespace equal to 'material'."); return NULL; } // Create new material from the file passed in. Material* material = new Material(); // Go through all the material properties and create techniques under this material. Properties* techniqueProperties = NULL; while ((techniqueProperties = materialProperties->getNextNamespace())) { if (strcmp(techniqueProperties->getNamespace(), "technique") == 0) { if (!loadTechnique(material, techniqueProperties)) { GP_ERROR("Failed to load technique for material."); SAFE_RELEASE(material); return NULL; } } } // Load uniform value parameters for this material. loadRenderState(material, materialProperties); // Set the current technique to the first found technique. if (material->getTechniqueCount() > 0) { Technique* t = material->getTechniqueByIndex(0); if (t) { material->_currentTechnique = t; } } return material; }
Material* Material::create(Properties* materialProperties) { // Check if the Properties is valid and has a valid namespace. assert(materialProperties); if (!materialProperties || !(strcmp(materialProperties->getNamespace(), "material") == 0)) { return NULL; } // Create new material from the file passed in. Material* material = new Material(); // Go through all the material properties and create techniques under this material. Properties* techniqueProperties = NULL; while ((techniqueProperties = materialProperties->getNextNamespace())) { if (strcmp(techniqueProperties->getNamespace(), "technique") == 0) { if (!loadTechnique(material, techniqueProperties)) { SAFE_RELEASE(material); return NULL; } } } // Load uniform value parameters for this material loadRenderState(material, materialProperties); // Set the current technique to the first found technique if (material->getTechniqueCount() > 0) { material->setTechnique((unsigned int)0); } return material; }