本文整理汇总了C++中TransformComponent::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ TransformComponent::GetPosition方法的具体用法?C++ TransformComponent::GetPosition怎么用?C++ TransformComponent::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransformComponent
的用法示例。
在下文中一共展示了TransformComponent::GetPosition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
CollisionComponent::Update(GameObject& gameObject, double)
{
TransformComponent *transform = static_cast<TransformComponent*>(gameObject.FilterComponent("Transform").front().get());
SDL_Rect pos = transform->GetPosition();
this->_collider->SetPosition(Vector2D((float)pos.x, (float)pos.y));
}
示例2: GetPosition
Vec3 TransformComponent::GetPosition(bool Relative) const
{
//Entity* P = m_Parent->GetParent();
Vec3 Pos = m_Position;
if(m_HasParent) {
TransformComponent* t = (TransformComponent*)m_RelativeTo->GetComponentByType(CT_TRANSFORM);
if(t) Pos += t->GetPosition(Relative);
}
/*if(P && !Relative && m_InheritPosition)
{
TransformComponent* t = GetTransformComponent(P);
if(t) Pos += t->GetPosition(Relative);
P->Destroy();
}*/
return Pos;
}
示例3: 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;
}
示例4: 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;
}
示例5: ProcessAI
void ProcessAI( World *pWorld )
{
g_PlayerList.Clear();
for ( ImplementingComponentIterator<PlayerComponent> iterator( *pWorld->GetComponentManager() ); iterator.GetBaseComponent(); iterator.Advance() )
{
if ( iterator->m_Avatar )
{
TransformComponent *pTransform = iterator->m_Avatar->GetFirst<TransformComponent>();
if ( pTransform )
{
g_PlayerList.New( *iterator, pTransform->GetPosition() );
}
}
}
QueryComponents< AIComponentChasePlayer, AvatarControllerComponent, UpdateAI_ChasePlayer >( pWorld );
}
示例6: UpdateAI_ChasePlayer
void UpdateAI_ChasePlayer( AIComponentChasePlayer *pAiComponent, AvatarControllerComponent *pController )
{
PlayerComponent *pTarget = NULL;
float pTargetDistanceSquared = NumericLimits<float>::Maximum;
Simd::Vector3 targetPosition = Simd::Vector3::Zero;
Simd::Vector3 myPosition = Simd::Vector3::Zero;
TransformComponent *pTransform = pAiComponent->GetComponentCollection()->GetFirst<TransformComponent>();
if ( pTransform )
{
myPosition = pTransform->GetPosition();
for (PlayerList::Iterator iter = g_PlayerList.Begin(); iter != g_PlayerList.End(); ++iter)
{
float d = (iter->Second() - myPosition).GetMagnitudeSquared();
if ( d < pTargetDistanceSquared )
{
pTargetDistanceSquared = d;
pTarget = iter->First();
targetPosition = iter->Second();
}
}
}
if ( pTarget )
{
Simd::Vector3 moveDir = (targetPosition - myPosition).GetNormalized();
pController->m_MoveDir.SetX( moveDir.GetElement(0));
pController->m_MoveDir.SetY( moveDir.GetElement(1));
pController->m_AimDir = Simd::Vector3::Zero;
pController->m_bShoot = false;
}
else
{
pController->m_MoveDir = Simd::Vector2::Zero;
pController->m_AimDir = Simd::Vector3::Zero;
pController->m_bShoot = false;
}
}
示例7: Finalize
void BulletBodyComponent::Finalize( const BulletBodyComponentDefinition &definition )
{
BulletWorldComponent *pBulletWorldComponent = GetWorld()->GetComponents().GetFirst<BulletWorldComponent>();
HELIUM_ASSERT( pBulletWorldComponent );
HELIUM_ASSERT( definition.m_BodyDefinition );
TransformComponent *pTransform = GetComponentCollection()->GetFirst<TransformComponent>();
HELIUM_ASSERT( pTransform );
m_Body.Initialize(
*pBulletWorldComponent->GetBulletWorld(),
*definition.m_BodyDefinition,
pTransform ? pTransform->GetPosition() : Simd::Vector3::Zero,
pTransform ? pTransform->GetRotation() : Simd::Quat::IDENTITY);
btVector3 velocity;
ConvertToBullet(definition.m_InitialVelocity, velocity);
m_Body.GetBody()->setLinearVelocity(velocity);
m_Body.GetBody()->setUserPointer( this );
m_AssignedGroups = definition.m_AssignedGroups;
m_TrackPhysicalContactGroupMask = definition.m_TrackPhysicalContactGroupMask;
}
示例8: Draw
void GraphicsComponent::Draw(SpriteBatch* spriteBatch)
{
TransformComponent* transformComponent = owner->GetComponent<TransformComponent>(TransformComponent::name);
sprite->Draw(spriteBatch, transformComponent->GetPosition(), transformComponent->GetRotation(), transformComponent->GetScale());
}