当前位置: 首页>>代码示例>>C++>>正文


C++ UMaterial::IsUIMaterial方法代码示例

本文整理汇总了C++中UMaterial::IsUIMaterial方法的典型用法代码示例。如果您正苦于以下问题:C++ UMaterial::IsUIMaterial方法的具体用法?C++ UMaterial::IsUIMaterial怎么用?C++ UMaterial::IsUIMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UMaterial的用法示例。


在下文中一共展示了UMaterial::IsUIMaterial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetMaterialInterface

void FMaterialThumbnailScene::SetMaterialInterface(UMaterialInterface* InMaterial)
{
    check(PreviewActor);
    check(PreviewActor->GetStaticMeshComponent());

    bIsUIMaterial = false;
    if ( InMaterial )
    {
        // Transform the preview mesh as necessary
        FTransform Transform = FTransform::Identity;

        const USceneThumbnailInfoWithPrimitive* ThumbnailInfo = Cast<USceneThumbnailInfoWithPrimitive>(InMaterial->ThumbnailInfo);
        if ( !ThumbnailInfo )
        {
            ThumbnailInfo = USceneThumbnailInfoWithPrimitive::StaticClass()->GetDefaultObject<USceneThumbnailInfoWithPrimitive>();
        }

        UMaterial* BaseMaterial = InMaterial->GetBaseMaterial();

        // UI material thumbnails always get a 2D plane centered at the camera which is a better representation of the
        // what the material will look like on UI
        bIsUIMaterial = BaseMaterial && BaseMaterial->IsUIMaterial();
        EThumbnailPrimType PrimitiveType = bIsUIMaterial ? TPT_Plane : ThumbnailInfo->PrimitiveType.GetValue();

        switch( PrimitiveType )
        {
        case TPT_None:
        {
            bool bFoundCustomMesh = false;
            if ( ThumbnailInfo->PreviewMesh.IsValid() )
            {
                UStaticMesh* MeshToUse = Cast<UStaticMesh>(ThumbnailInfo->PreviewMesh.ResolveObject());
                if ( MeshToUse )
                {
                    PreviewActor->GetStaticMeshComponent()->SetStaticMesh(MeshToUse);
                    bFoundCustomMesh = true;
                }
            }

            if ( !bFoundCustomMesh )
            {
                // Just use a plane if the mesh was not found
                Transform.SetRotation(FQuat(FRotator(0, -90, 0)));
                PreviewActor->GetStaticMeshComponent()->SetStaticMesh(GUnrealEd->GetThumbnailManager()->EditorPlane);
            }
        }
        break;

        case TPT_Cube:
            PreviewActor->GetStaticMeshComponent()->SetStaticMesh(GUnrealEd->GetThumbnailManager()->EditorCube);
            break;

        case TPT_Sphere:
            // The sphere is a little big, scale it down to 256x256x256
            Transform.SetScale3D( FVector(0.8f) );
            PreviewActor->GetStaticMeshComponent()->SetStaticMesh(GUnrealEd->GetThumbnailManager()->EditorSphere);
            break;

        case TPT_Cylinder:
            PreviewActor->GetStaticMeshComponent()->SetStaticMesh(GUnrealEd->GetThumbnailManager()->EditorCylinder);
            break;

        case TPT_Plane:
            // The plane needs to be rotated 90 degrees to face the camera
            Transform.SetRotation(FQuat(FRotator(0, -90, 0)));
            PreviewActor->GetStaticMeshComponent()->SetStaticMesh(GUnrealEd->GetThumbnailManager()->EditorPlane);
            break;

        default:
            check(0);
        }

        PreviewActor->GetStaticMeshComponent()->SetRelativeTransform(Transform);
        PreviewActor->GetStaticMeshComponent()->UpdateBounds();

        // Center the mesh at the world origin then offset to put it on top of the plane
        const float BoundsZOffset = GetBoundsZOffset(PreviewActor->GetStaticMeshComponent()->Bounds);
        Transform.SetLocation(-PreviewActor->GetStaticMeshComponent()->Bounds.Origin + FVector(0, 0, BoundsZOffset));

        PreviewActor->GetStaticMeshComponent()->SetRelativeTransform(Transform);
    }

    PreviewActor->GetStaticMeshComponent()->SetMaterial(0, InMaterial);
    PreviewActor->GetStaticMeshComponent()->RecreateRenderState_Concurrent();
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:85,代码来源:ThumbnailHelpers.cpp


注:本文中的UMaterial::IsUIMaterial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。