本文整理汇总了C++中UStaticMeshComponent::GetLightMapResolution方法的典型用法代码示例。如果您正苦于以下问题:C++ UStaticMeshComponent::GetLightMapResolution方法的具体用法?C++ UStaticMeshComponent::GetLightMapResolution怎么用?C++ UStaticMeshComponent::GetLightMapResolution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UStaticMeshComponent
的用法示例。
在下文中一共展示了UStaticMeshComponent::GetLightMapResolution方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetDebugLightmapSample
/** Updates GCurrentSelectedLightmapSample given a selected actor's components and the location of the click. */
void SetDebugLightmapSample(TArray<UActorComponent*>* Components, UModel* Model, int32 iSurf, FVector ClickLocation)
{
UStaticMeshComponent* SMComponent = NULL;
if (Components)
{
// Find the first supported component
for (int32 ComponentIndex = 0; ComponentIndex < Components->Num() && !SMComponent; ComponentIndex++)
{
SMComponent = Cast<UStaticMeshComponent>((*Components)[ComponentIndex]);
if (SMComponent && (!SMComponent->StaticMesh || SMComponent->LODData.Num() == 0))
{
SMComponent = NULL;
}
}
}
bool bFoundLightmapSample = false;
// Only static mesh components and BSP handled for now
if (SMComponent)
{
UStaticMesh* StaticMesh = SMComponent->StaticMesh;
check(StaticMesh);
check(StaticMesh->RenderData);
check(StaticMesh->RenderData->LODResources.Num());
// Only supporting LOD0
const int32 LODIndex = 0;
FStaticMeshLODResources& LODModel = StaticMesh->RenderData->LODResources[LODIndex];
FIndexArrayView Indices = LODModel.IndexBuffer.GetArrayView();
const bool bHasStaticLighting = SMComponent->HasStaticLighting();
if (bHasStaticLighting)
{
bool bUseTextureMap = false;
int32 LightmapSizeX = 0;
int32 LightmapSizeY = 0;
SMComponent->GetLightMapResolution(LightmapSizeX, LightmapSizeY);
if (LightmapSizeX > 0 && LightmapSizeY > 0
&& StaticMesh->LightMapCoordinateIndex >= 0
&& (uint32)StaticMesh->LightMapCoordinateIndex < LODModel.VertexBuffer.GetNumTexCoords()
)
{
bUseTextureMap = true;
}
else
{
bUseTextureMap = false;
}
// Search through the static mesh's triangles for the one that was hit (since we can't get triangle index from a line check)
for(int32 TriangleIndex = 0; TriangleIndex < Indices.Num(); TriangleIndex += 3)
{
uint32 Index0 = Indices[TriangleIndex];
uint32 Index1 = Indices[TriangleIndex + 1];
uint32 Index2 = Indices[TriangleIndex + 2];
// Transform positions to world space
FVector Position0 = SMComponent->ComponentToWorld.TransformPosition(LODModel.PositionVertexBuffer.VertexPosition(Index0));
FVector Position1 = SMComponent->ComponentToWorld.TransformPosition(LODModel.PositionVertexBuffer.VertexPosition(Index1));
FVector Position2 = SMComponent->ComponentToWorld.TransformPosition(LODModel.PositionVertexBuffer.VertexPosition(Index2));
FVector BaryCentricWeights;
// Continue if click location is in the triangle and get its barycentric weights
if (GetBarycentricWeights(Position0, Position1, Position2, ClickLocation, .001f, BaryCentricWeights))
{
RestoreSelectedLightmapSample();
if (bUseTextureMap)
{
// Fetch lightmap UV's
FVector2D LightmapUV0 = LODModel.VertexBuffer.GetVertexUV(Index0, StaticMesh->LightMapCoordinateIndex);
FVector2D LightmapUV1 = LODModel.VertexBuffer.GetVertexUV(Index1, StaticMesh->LightMapCoordinateIndex);
FVector2D LightmapUV2 = LODModel.VertexBuffer.GetVertexUV(Index2, StaticMesh->LightMapCoordinateIndex);
// Interpolate lightmap UV's to the click location
FVector2D InterpolatedUV = LightmapUV0 * BaryCentricWeights.X + LightmapUV1 * BaryCentricWeights.Y + LightmapUV2 * BaryCentricWeights.Z;
int32 PaddedSizeX = LightmapSizeX;
int32 PaddedSizeY = LightmapSizeY;
if (GLightmassDebugOptions.bPadMappings && GAllowLightmapPadding && LightmapSizeX - 2 > 0 && LightmapSizeY - 2 > 0)
{
PaddedSizeX -= 2;
PaddedSizeY -= 2;
}
const int32 LocalX = FMath::TruncToInt(InterpolatedUV.X * PaddedSizeX);
const int32 LocalY = FMath::TruncToInt(InterpolatedUV.Y * PaddedSizeY);
if (LocalX < 0 || LocalX >= PaddedSizeX
|| LocalY < 0 || LocalY >= PaddedSizeY)
{
UE_LOG(LogStaticLightingSystem, Log, TEXT("Texel selection failed because the lightmap UV's wrap!"));
}
else
{
bFoundLightmapSample = UpdateSelectedTexel(SMComponent, -1, SMComponent->LODData[LODIndex].LightMap, ClickLocation, InterpolatedUV, LocalX, LocalY, LightmapSizeX, LightmapSizeY);
}
}
break;
}
}
//.........这里部分代码省略.........