You.i Engine
CYILayoutUtility Class Reference

Detailed Description

A utility class that helps retrieving attachment positions relative to an object.

#include <utility/YiLayoutUtility.h>

Public Types

enum  AttachmentPosition {
  AttachmentPosition::TopLeft = 0,
  AttachmentPosition::TopCenter,
  AttachmentPosition::TopRight,
  AttachmentPosition::CenterLeft,
  AttachmentPosition::Center,
  AttachmentPosition::CenterRight,
  AttachmentPosition::BottomLeft,
  AttachmentPosition::BottomCenter,
  AttachmentPosition::BottomRight
}
 

Static Public Member Functions

static glm::vec3 CalculateAttachmentPosition (glm::vec3 leftTop, glm::vec3 rightBottom, AttachmentPosition attachmentPosition)
 
static glm::vec3 GetAttachmentPosition (CYISceneNode *pSceneNode, AttachmentPosition attachmentPosition)
 
static glm::vec3 GetAttachmentPosition (CYIMesh *pMesh, AttachmentPosition attachmentPosition)
 
static glm::vec3 GetAttachmentPosition (std::shared_ptr< CYIMesh > pMesh, AttachmentPosition attachmentPosition)
 
static glm::vec3 ConvertAttachmentPositionToWorldSpace (CYISceneNode *pSceneNode, glm::vec3 attachmentPosition)
 
static AttachmentPosition ConvertAttachmentPositionNameToEnum (CYIString const &rAttachmentPointName)
 

Member Enumeration Documentation

◆ AttachmentPosition

Attachment positions:

+------------------+------------------+
| | |
| | |
| | |
| | |
Left Center +---------------Center----------------+ Right Center
| | |
| | |
| | |
| | |
+------------------+------------------+
Enumerator
TopLeft 
TopCenter 
TopRight 
CenterLeft 
Center 
CenterRight 
BottomLeft 
BottomCenter 
BottomRight 

Member Function Documentation

◆ CalculateAttachmentPosition()

static glm::vec3 CYILayoutUtility::CalculateAttachmentPosition ( glm::vec3  leftTop,
glm::vec3  rightBottom,
AttachmentPosition  attachmentPosition 
)
static

Calculate the attachment position from leftTop and rightBottom vectors.

◆ ConvertAttachmentPositionNameToEnum()

static AttachmentPosition CYILayoutUtility::ConvertAttachmentPositionNameToEnum ( CYIString const &  rAttachmentPointName)
static

Returns the conversion of an attachment point name string to the AttachmentPosition enumeration.

◆ ConvertAttachmentPositionToWorldSpace()

static glm::vec3 CYILayoutUtility::ConvertAttachmentPositionToWorldSpace ( CYISceneNode pSceneNode,
glm::vec3  attachmentPosition 
)
static

Returns the conversion of pSceneNode attachmentPosition in world space.

◆ GetAttachmentPosition() [1/3]

static glm::vec3 CYILayoutUtility::GetAttachmentPosition ( CYISceneNode pSceneNode,
AttachmentPosition  attachmentPosition 
)
static

Returns one of the CYISceneNode attachment positions as glm::vec3 in local space. Child CYISceneNodes can be positioned relative to these attachment positions.

When used on a CYITextSceneNode, the tight text rectangle will be used. When used on a CYISceneView, the world logical size will be used. When used on a CYISceneNode with a mesh, the mesh Axis Aligned Bounding Box will be used. When used on a CYISceneNode without a mesh, (0,0,0) is returned.

Note
Use GetAttachmentPosition(pSceneView->GetMesh()) to find the attachment position on the mesh of a CYISceneView.

example of use:

// Positions a node anchor point at the center of another node.
CYISceneNode *pAttachedNode = GetNode("ANode");
CYISceneNode *pNodeToAttachTo = GetNode("NodeToAttachTo");
// positions pAttachedNode anchor point to the center of pNodeToAttachTo
pAttachedNode->SetPosition(GetAttachmentPosition(pNodeToAttachTo, CYISceneView::AttachmentPosition::Center));

See AttachmentPosition for the available attachment positions.

◆ GetAttachmentPosition() [2/3]

static glm::vec3 CYILayoutUtility::GetAttachmentPosition ( CYIMesh pMesh,
AttachmentPosition  attachmentPosition 
)
static

Returns one of the CYIMesh attachment positions as glm::vec3 in local space.

See also
GetAttachmentPosition(CYISceneNode *, AttachmentPosition)

◆ GetAttachmentPosition() [3/3]

static glm::vec3 CYILayoutUtility::GetAttachmentPosition ( std::shared_ptr< CYIMesh pMesh,
AttachmentPosition  attachmentPosition 
)
static

Returns one of the std::shared_ptr<CYIMesh> attachment positions as glm::vec3 in local space.

See also
GetAttachmentPosition(CYISceneNode *, AttachmentPosition)

The documentation for this class was generated from the following file: