| 36 | | pOsgTex = fbxTextureToOsgTexture(lTexture); |
| 37 | | } |
| 38 | | |
| 39 | | //For now only allow 1 texture |
| 40 | | break; |
| 41 | | } |
| 42 | | } |
| | 50 | pOsgDiffuseTex = fbxTextureToOsgTexture(lTexture); |
| | 51 | result.diffuseTexture = pOsgDiffuseTex.release(); |
| | 52 | result.diffuseChannel = lTexture->UVSet.Get(); |
| | 53 | } |
| | 54 | |
| | 55 | //For now only allow 1 texture |
| | 56 | break; |
| | 57 | } |
| | 58 | } |
| | 59 | |
| | 60 | // opacity map... |
| | 61 | const KFbxProperty lOpacityProperty = pFbxMat->FindProperty(KFbxSurfaceMaterial::sTransparentColor); |
| | 62 | if (lOpacityProperty.IsValid()) |
| | 63 | { |
| | 64 | int lNbTex = lOpacityProperty.GetSrcObjectCount(KFbxTexture::ClassId); |
| | 65 | for (int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++) |
| | 66 | { |
| | 67 | KFbxTexture* lTexture = KFbxCast<KFbxTexture>(lOpacityProperty.GetSrcObject(KFbxTexture::ClassId, lTextureIndex)); |
| | 68 | if (lTexture) |
| | 69 | { |
| | 70 | // TODO: if texture image does NOT have an alpha channel, should it be added? |
| | 71 | |
| | 72 | pOsgOpacityTex = fbxTextureToOsgTexture(lTexture); |
| | 73 | result.opacityTexture = pOsgOpacityTex.release(); |
| | 74 | result.opacityChannel = lTexture->UVSet.Get(); |
| | 75 | } |
| | 76 | |
| | 77 | //For now only allow 1 texture |
| | 78 | break; |
| | 79 | } |
| | 80 | } |
| | 81 | |
| | 82 | // reflection map... |
| | 83 | const KFbxProperty lReflectionProperty = pFbxMat->FindProperty(KFbxSurfaceMaterial::sReflection); |
| | 84 | if (lReflectionProperty.IsValid()) |
| | 85 | { |
| | 86 | int lNbTex = lReflectionProperty.GetSrcObjectCount(KFbxTexture::ClassId); |
| | 87 | for (int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++) |
| | 88 | { |
| | 89 | KFbxTexture* lTexture = KFbxCast<KFbxTexture>(lReflectionProperty.GetSrcObject(KFbxTexture::ClassId, lTextureIndex)); |
| | 90 | if (lTexture) |
| | 91 | { |
| | 92 | // support only spherical reflection maps... |
| | 93 | if (KFbxTexture::eUMT_ENVIRONMENT == lTexture->GetMappingType()) |
| | 94 | { |
| | 95 | pOsgReflectionTex = fbxTextureToOsgTexture(lTexture); |
| | 96 | result.reflectionTexture = pOsgReflectionTex.release(); |
| | 97 | result.reflectionChannel = lTexture->UVSet.Get(); |
| | 98 | } |
| | 99 | } |
| | 100 | |
| | 101 | //For now only allow 1 texture |
| | 102 | break; |
| | 103 | } |
| | 104 | } |
| | 105 | |
| | 106 | // emissive map... |
| | 107 | const KFbxProperty lEmissiveProperty = pFbxMat->FindProperty(KFbxSurfaceMaterial::sEmissive); |
| | 108 | if (lEmissiveProperty.IsValid()) |
| | 109 | { |
| | 110 | int lNbTex = lEmissiveProperty.GetSrcObjectCount(KFbxTexture::ClassId); |
| | 111 | for (int lTextureIndex = 0; lTextureIndex < lNbTex; lTextureIndex++) |
| | 112 | { |
| | 113 | KFbxTexture* lTexture = KFbxCast<KFbxTexture>(lEmissiveProperty.GetSrcObject(KFbxTexture::ClassId, lTextureIndex)); |
| | 114 | if (lTexture) |
| | 115 | { |
| | 116 | pOsgEmissiveTex = fbxTextureToOsgTexture(lTexture); |
| | 117 | result.emissiveTexture = pOsgEmissiveTex.release(); |
| | 118 | result.emissiveChannel = lTexture->UVSet.Get(); |
| | 119 | } |
| | 120 | |
| | 121 | //For now only allow 1 texture |
| | 122 | break; |
| | 123 | } |
| | 124 | } |
| | 125 | |
| 81 | | } |
| 82 | | } |
| 83 | | StateSetContent result(pOsgMat.release(), pOsgTex.release()); |
| 84 | | _kFbxMaterialMap.insert(KFbxMaterialMap::value_type(pFbxMat, result)); |
| | 164 | |
| | 165 | // get maps factors... |
| | 166 | result.diffuseFactor = pFbxPhong->GetDiffuseFactor().Get(); |
| | 167 | result.reflectionFactor = pFbxPhong->GetReflectionFactor().Get(); |
| | 168 | result.opacityFactor = pFbxPhong->GetTransparencyFactor().Get(); |
| | 169 | // get more factors here... |
| | 170 | } |
| | 171 | } |
| | 172 | |
| | 173 | if (_lightmapTextures) |
| | 174 | { |
| | 175 | // if using an emission map then adjust material properties accordingly... |
| | 176 | if (result.emissiveTexture) |
| | 177 | { |
| | 178 | osg::Vec4 diffuse = pOsgMat->getDiffuse(osg::Material::FRONT_AND_BACK); |
| | 179 | pOsgMat->setEmission(osg::Material::FRONT_AND_BACK, diffuse); |
| | 180 | pOsgMat->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(0,0,0,diffuse.a())); |
| | 181 | pOsgMat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0,0,0,diffuse.a())); |
| | 182 | } |
| | 183 | } |
| | 184 | |
| | 185 | _kFbxMaterialMap.insert(KFbxMaterialMap::value_type(pFbxMat, result)); |