Esempio n. 1
0
//-------------------------------------------------------------------------------------------------------------------------------------------
void transferTextureInfo(FbxTexture* texture, int blendMode, Texture* modelTexture){
    FbxFileTexture* fileTexture = FbxCast<FbxFileTexture>(texture);
    FbxProceduralTexture* proceduralTexture = FbxCast<FbxProceduralTexture>(texture);

    modelTexture->TextureName = texture->GetName();
    if (fileTexture){
        Image* image = loadImage(fileTexture->GetFileName(), &Texture::Images);
        modelTexture->Image = image;
    }
    else if (proceduralTexture){
        LOG_WARNING << "Procedural texture ! "
                    << "Texture name: " << modelTexture->TextureName;
    }

    modelTexture->ScaleU = texture->GetScaleU();
    modelTexture->ScaleV = texture->GetScaleV();
    modelTexture->TranslateU = texture->GetTranslationU();
    modelTexture->TranslateV = texture->GetTranslationV();
    modelTexture->IsSwapUV = texture->GetSwapUV();
    modelTexture->RotateU = texture->GetRotationU();
    modelTexture->RotateV = texture->GetRotationV();
    modelTexture->RotateW = texture->GetRotationW();

    const char* lAlphaSources[] = { "None", "RGB Intensity", "Black" };
    modelTexture->AlphaSource = lAlphaSources[texture->GetAlphaSource()];
    modelTexture->CropLeft = texture->GetCroppingLeft();
    modelTexture->CropRight = texture->GetCroppingRight();
    modelTexture->CropTop = texture->GetCroppingTop();
    modelTexture->CropBottom = texture->GetCroppingBottom();

    const char* lMappingTypes[] = { "Null", "Planar", "Spherical", "Cylindrical",
                                    "Box", "Face", "UV", "Environment" };
    modelTexture->MappingType = lMappingTypes[texture->GetMappingType()];

    const char* lBlendModes[] = { "Translucent", "Add", "Modulate", "Modulate2" };
    if (blendMode >= 0){
        modelTexture->BlendMode = lBlendModes[blendMode];
    }
    modelTexture->Alpha = texture->GetDefaultAlpha();

    if (fileTexture){
        const char* lMaterialUses[] = { "Model Material", "Default Material" };
        modelTexture->MaterialUsed = lMaterialUses[fileTexture->GetMaterialUse()];
    }

    const char* pTextureUses[] = { "Standard", "Shadow Map", "Light Map",
                                   "Spherical Reflexion Map", "Sphere Reflexion Map", "Bump Normal Map" };
    modelTexture->TextureUsed = pTextureUses[texture->GetTextureUse()];

    LOG_INFO << "Texture information: \n" << modelTexture->ToString();

    LOG_DEBUG << "Read texture successfully!";
}