本文整理汇总了C++中TransformComponent::GetScale方法的典型用法代码示例。如果您正苦于以下问题:C++ TransformComponent::GetScale方法的具体用法?C++ TransformComponent::GetScale怎么用?C++ TransformComponent::GetScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransformComponent
的用法示例。
在下文中一共展示了TransformComponent::GetScale方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetScale
Vec3 TransformComponent::GetScale(bool Relative) const
{
//Entity* P = m_Entity->GetParent();
Vec3 Sc = m_Scale;
if(m_HasParent) {
TransformComponent* t = (TransformComponent*)m_RelativeTo->GetComponentByType(CT_TRANSFORM);
if(t) Sc *= t->GetScale(Relative);
}
/*if(P && !Relative && m_InheritScale)
{
TransformComponent* t = GetTransformComponent(P);
if(t) Sc *= t->GetScale(Relative);
P->Destroy();
}*/
return Sc;
}
示例2: CircleCollider
CollisionComponent*
CollisionComponent::Factory(GameObject &gameObject, Collider *collider)
{
if (nullptr == collider)
{
TransformComponent *transform = static_cast<TransformComponent*>(gameObject.FilterComponent("Transform").front().get());
SDL_Rect pos = transform->GetPosition();
SDL_Rect *scale = transform->GetScale();
collider = new CircleCollider(Vector2D((float)pos.x, (float)pos.y), (scale->h/2));
}
CollisionComponent *collisionComponent = new CollisionComponent(collider);
gameObject.RegisterComponent(Component(new CollisionComponent(collider)));
return collisionComponent;
}
示例3: GetTransform
Mat4 TransformComponent::GetTransform(bool Relative)
{
if(m_Updated)
{
/* To do: Optimize. */
m_Transform = Mat4::Identity;
if(m_Position.x + m_Position.y + m_Position.z != 0.0f) m_Transform = Translation(m_Position);
if(!m_FirstPerson) {
if(m_Orientation.w != 0.0f) m_Transform *= m_Orientation.ToMat();
} else {
Quat pitch = Quat(Vec3(1,0,0), m_FirstPersonYRot);
Quat yaw = Quat(Vec3(0,1,0), m_FirstPersonXRot);
m_Orientation = yaw * pitch;
if(m_Orientation.w != 0.0f) m_Transform *= m_Orientation.ToMat();
}
m_Transform *= SandboxSimulator::Scale(m_Scale);
m_NormalMatrix = m_Orientation.ToMat().Inverse().Transpose();
m_Updated = false;
}
//Entity* Parent = m_Entity->GetParent();
if(m_HasParent) {
TransformComponent* t = (TransformComponent*)m_RelativeTo->GetComponentByType(CT_TRANSFORM);
if(t)
{
Mat4 ret = m_Transform;
ret = t->GetOrientation(false).ToMat() * ret;
ret = SandboxSimulator::Translation(t->GetPosition(false)) * ret;
ret = SandboxSimulator::Scale(t->GetScale()) * ret;
return ret;
}
}
/*if(Parent && !m_Simulated && !Relative && (m_InheritPosition || m_InheritOrientation || m_InheritScale))
{
TransformComponent* t = GetTransformComponent(Parent);
if(t)
{
if(m_InheritPosition && m_InheritOrientation && m_InheritScale) return t->GetTransform(Relative) * m_Transform;
Matrix4 ret = m_Transform;
if(m_InheritOrientation) ret = t->GetOrientation(false).ToMatrix() * ret;
if(m_InheritPosition ) ret = Translation(t->GetPosition(false)) * ret;
if(m_InheritScale ) ret = Reality::Scale(t->GetScale()) * ret;
return ret;
}
}*/
return m_Transform;
}
示例4: Draw
void GraphicsComponent::Draw(SpriteBatch* spriteBatch)
{
TransformComponent* transformComponent = owner->GetComponent<TransformComponent>(TransformComponent::name);
sprite->Draw(spriteBatch, transformComponent->GetPosition(), transformComponent->GetRotation(), transformComponent->GetScale());
}