MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / _writeMaterial_lib3ds

Method _writeMaterial_lib3ds

dae23ds_lib3ds/src/DAE23dsWriter.cpp:430–582  ·  view source on GitHub ↗

--------------------------------------------------------------------

Source from the content-addressed store, hash-verified

428 }
429 //--------------------------------------------------------------------
430 void Writer::_writeMaterial_lib3ds( const COLLADAFW::Material* material )
431 {
432 _Log("mat "
433 //<<"uid="<<it->first.toAscii()
434 <<",name=" <<material->getName()
435 <<",effect="<<material->getInstantiatedEffect().toAscii()
436 <<",oid="<<material->getOriginalId()
437 <<",uid="<<material->getUniqueId().toAscii()
438 );
439
440 const COLLADAFW::EffectCommon* effectCommon = getEffectCommon(material);
441 assert(effectCommon);
442 _Log("effect type="<<effectCommon->getShaderType()
443 <<",oid="<<effectCommon->getOriginalId()
444 );
445
446 Lib3dsMaterial *_3dsMtrl = lib3ds_material_new( material->getName().c_str() );
447 lib3ds_file_insert_material(get3dsFile(), _3dsMtrl, -1);
448 {
449 //shader type
450 switch( effectCommon->getShaderType() )
451 {
452 case COLLADAFW::EffectCommon::SHADER_BLINN: _3dsMtrl->shading = LIB3DS_SHADING_METAL; break;
453 case COLLADAFW::EffectCommon::SHADER_CONSTANT: _3dsMtrl->shading = LIB3DS_SHADING_FLAT; break;
454 case COLLADAFW::EffectCommon::SHADER_PHONG: _3dsMtrl->shading = LIB3DS_SHADING_PHONG; break;
455 case COLLADAFW::EffectCommon::SHADER_LAMBERT: _3dsMtrl->shading = LIB3DS_SHADING_GOURAUD; break;
456
457 case COLLADAFW::EffectCommon::SHADER_UNKNOWN:
458 default:
459 _3dsMtrl->shading = LIB3DS_SHADING_WIRE_FRAME;
460 }
461 //------------------------ emission ---------------------------
462 //------------------------ ambient ---------------------------
463 if( effectCommon->getAmbient().isTexture() ){
464 //how to set in .3ds format
465 }
466 if( effectCommon->getAmbient().isColor() ){
467 _3dsMtrl->ambient[0] = effectCommon->getAmbient().getColor().getRed();
468 _3dsMtrl->ambient[1] = effectCommon->getAmbient().getColor().getGreen();
469 _3dsMtrl->ambient[2] = effectCommon->getAmbient().getColor().getBlue();
470 }
471 _Log("\t amb "
472 << _3dsMtrl->ambient[0] <<" "
473 << _3dsMtrl->ambient[1] <<" "
474 << _3dsMtrl->ambient[2]);
475 //------------------------ color ---------------------------
476 //if( effectCommon->getDiffuse().isTexture() ){
477 // assignTextureName( _3dsMtrl->texture1_map, effectCommon->getDiffuse(), effectCommon);
478
479 // _3dsMtrl->texture1_map.scale[0] = _3dsMtrl->texture1_map.scale[1] = 1.0;
480 // _3dsMtrl->texture1_map.percent = 1.0;
481 // _3DSDEBUG("\t color tex:"<< _3dsMtrl->texture1_map.name <<"\n" );
482 //}
483 //_3DSDEBUG("\t color "
484 // << mayaMtrl2.color.value.r <<" "
485 // << mayaMtrl2.color.value.g <<" "
486 // << mayaMtrl2.color.value.b <<"\n");
487

Callers

nothing calls this directly

Calls 15

lib3ds_material_newFunction · 0.85
toAsciiMethod · 0.80
getUniqueIdMethod · 0.80
c_strMethod · 0.80
getNameMethod · 0.45
getShaderTypeMethod · 0.45
isTextureMethod · 0.45
getAmbientMethod · 0.45
isColorMethod · 0.45
getRedMethod · 0.45
getColorMethod · 0.45

Tested by

no test coverage detected