本文整理汇总了C++中UPaperSprite::ConvertWorldSpaceToTextureSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ UPaperSprite::ConvertWorldSpaceToTextureSpace方法的具体用法?C++ UPaperSprite::ConvertWorldSpaceToTextureSpace怎么用?C++ UPaperSprite::ConvertWorldSpaceToTextureSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UPaperSprite
的用法示例。
在下文中一共展示了UPaperSprite::ConvertWorldSpaceToTextureSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertMarqueeToSourceTextureSpace
bool FSpriteEditorViewportClient::ConvertMarqueeToSourceTextureSpace(/*out*/ FIntPoint& OutStartPos, /*out*/ FIntPoint& OutDimension)
{
FSpriteGeometryEditMode* GeometryEditMode = ModeTools->GetActiveModeTyped<FSpriteGeometryEditMode>(FSpriteGeometryEditMode::EM_SpriteGeometry);
check(GeometryEditMode);
const FVector2D MarqueeStartPos = GeometryEditMode->GetMarqueeStartPos();
const FVector2D MarqueeEndPos = GeometryEditMode->GetMarqueeEndPos();
bool bSuccessful = false;
UPaperSprite* Sprite = SourceTextureViewComponent->GetSprite();
UTexture2D* SpriteSourceTexture = Sprite->GetSourceTexture();
if (SpriteSourceTexture != nullptr)
{
// Calculate world space positions
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(Viewport, GetScene(), EngineShowFlags));
FSceneView* View = CalcSceneView(&ViewFamily);
const FVector StartPos = View->PixelToWorld(MarqueeStartPos.X, MarqueeStartPos.Y, 0);
const FVector EndPos = View->PixelToWorld(MarqueeEndPos.X, MarqueeEndPos.Y, 0);
// Convert to source texture space to work out the pixels dragged
FVector2D TextureSpaceStartPos = Sprite->ConvertWorldSpaceToTextureSpace(StartPos);
FVector2D TextureSpaceEndPos = Sprite->ConvertWorldSpaceToTextureSpace(EndPos);
if (TextureSpaceStartPos.X > TextureSpaceEndPos.X)
{
Swap(TextureSpaceStartPos.X, TextureSpaceEndPos.X);
}
if (TextureSpaceStartPos.Y > TextureSpaceEndPos.Y)
{
Swap(TextureSpaceStartPos.Y, TextureSpaceEndPos.Y);
}
const FIntPoint SourceTextureSize(SpriteSourceTexture->GetImportedSize());
const int32 SourceTextureWidth = SourceTextureSize.X;
const int32 SourceTextureHeight = SourceTextureSize.Y;
FIntPoint TSStartPos;
TSStartPos.X = FMath::Clamp<int32>((int32)TextureSpaceStartPos.X, 0, SourceTextureWidth - 1);
TSStartPos.Y = FMath::Clamp<int32>((int32)TextureSpaceStartPos.Y, 0, SourceTextureHeight - 1);
FIntPoint TSEndPos;
TSEndPos.X = FMath::Clamp<int32>((int32)TextureSpaceEndPos.X, 0, SourceTextureWidth - 1);
TSEndPos.Y = FMath::Clamp<int32>((int32)TextureSpaceEndPos.Y, 0, SourceTextureHeight - 1);
const FIntPoint TextureSpaceDimensions = TSEndPos - TSStartPos;
if ((TextureSpaceDimensions.X > 0) || (TextureSpaceDimensions.Y > 0))
{
OutStartPos = TSStartPos;
OutDimension = TextureSpaceDimensions;
bSuccessful = true;
}
}
return bSuccessful;
}
示例2: WorldSpaceToTextureSpace
FVector2D FSpriteEditorViewportClient::WorldSpaceToTextureSpace(const FVector& SourcePoint) const
{
UPaperSprite* Sprite = GetSpriteBeingEdited();
return Sprite->ConvertWorldSpaceToTextureSpace(SourcePoint);
}