void SDFloader::read(std::string file) { // delete eventually existing scene scene_.materials.clear(); scene_.shapes.clear(); scene_.cameras.clear(); scene_.lights.clear(); std::ifstream f; std::string s; f.open(file, std::ios::in); while (!f.eof()) { // Solange noch Daten vorliegen getline(f, s); // Lese eine Zeile std::istringstream iss(s); std::string sub; iss >> sub; if(sub == "define"){ iss >> sub; if(sub == "material") add_material(iss); else if(sub == "shape") add_shape(iss); else if(sub == "camera") add_camera(iss); else if(sub == "light") add_light(iss); } else if(sub == "transform")
const char* create_material(const char *mat, colour_t diffuse, colour_t specular_colour, scalar_t specular_exp ) { material_t *matPtr; matPtr = (material_t *)malloc( sizeof( material_t ) ); matPtr->diffuse.r = diffuse.r; matPtr->diffuse.g = diffuse.g; matPtr->diffuse.b = diffuse.b; matPtr->diffuse.a = 1.0; matPtr->specular_colour.r = specular_colour.r; matPtr->specular_colour.g = specular_colour.g; matPtr->specular_colour.b = specular_colour.b; matPtr->specular_colour.a = 1.0; matPtr->specular_exp = specular_exp; if ( add_material( mat, matPtr ) != TCL_OK ) { free( matPtr ); return "Material already exists"; } return NULL; }
/** When this method is called, the writer must write the material. @return The writer should return true, if writing succeeded, false otherwise.*/ bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat ) { if(mImportStage!=General) return true; const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId(); Material *ma = add_material((char*)str_mat_id.c_str()); this->uid_effect_map[cmat->getInstantiatedEffect()] = ma; this->uid_material_map[cmat->getUniqueId()] = ma; return true; }
PathSpatialGizmoPlugin::PathSpatialGizmoPlugin() { Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8)); Ref<SpatialMaterial> path_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); path_color.a = 0.8; path_material->set_albedo(path_color); path_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); path_material->set_line_width(3); path_material->set_cull_mode(SpatialMaterial::CULL_DISABLED); path_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); Ref<SpatialMaterial> path_thin_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); path_color.a = 0.4; path_thin_material->set_albedo(path_color); path_thin_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); path_thin_material->set_line_width(1); path_thin_material->set_cull_mode(SpatialMaterial::CULL_DISABLED); path_thin_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); add_material("path_material", path_material); add_material("path_thin_material", path_thin_material); create_handle_material("handles"); }
struct Material *rna_Main_materials_new(Main *UNUSED(bmain), const char *name) { ID *id= (ID *)add_material(name); id_us_min(id); return (Material *)id; }