本文整理汇总了C++中Transform::GetPos方法的典型用法代码示例。如果您正苦于以下问题:C++ Transform::GetPos方法的具体用法?C++ Transform::GetPos怎么用?C++ Transform::GetPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform::GetPos方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnTick
void AiController::OnTick(const natU64 _dt)
{
if(!m_lifeController->IsAlive())
{
// called spawner first
//m_spawner->OnKilled(GetEntity());
Spawned* spawned = GetEntity()->GetComponent<Spawned>();
assert(spawned);
spawned->Kill();
}
else
{
// move toward player
Entity* player = m_playersManager->GetLocalPlayer();
Transform* transform_player = player->GetComponent<Transform>();
Transform* transform = GetEntity()->GetComponent<Transform>();
RigidBody* rigidbody = GetEntity()->GetComponent<RigidBody>();
glm::vec3 direction = transform_player->GetPos() - transform->GetPos();
if(direction != glm::vec3(0.f))
{
direction = glm::normalize(direction);
//transform->m_pos += static_cast<natF32>(_dt) * direction * m_speed;
direction = static_cast<natF32>(_dt) * direction;
rigidbody->ApplyLinearImpulse(direction);
}
}
}
示例2: GetEntity
glm::vec3 Transform::GetPos()
{
Transform* parent = GetEntity()->GetParent()->GetComponent<Transform>();
if(parent)
{
return m_pos + parent->GetPos();
}
else
{
return m_pos;
}
}
示例3: OnInit
void AiController::OnInit()
{
Transform* transform = GetEntity()->GetComponent<Transform>();
m_center = transform->GetPos();
m_radius = 200.0f;
m_t = 0.0f;
m_playersManager = GetEntity()->GetKernel()->GetLayer(Layer::s_LayerManager)->GetRootEntity()->GetComponent<PlayersManager>();
m_lifeController = GetEntity()->GetComponent<LifeController>();
assert(m_playersManager);
assert(m_lifeController);
}
示例4: main
int main( int argc, char* args[] )
{
srand(time(NULL));
Display display(800, 600, "Hello World!");
GameObject paddle2Obj(vertexPositions1, sizeof(vertexPositions1), indicesPositions, sizeof(indicesPositions));
Mesh testMesh(vertexPositions1, sizeof(vertexPositions1), indicesPositions, sizeof(indicesPositions));
Mesh paddle2(vertexPositions1, sizeof(vertexPositions1), indicesPositions, sizeof(indicesPositions));
Mesh paddle1(vertexPositions1, sizeof(vertexPositions1), indicesPositions, sizeof(indicesPositions));
Mesh ball(vertexPositions1, sizeof(vertexPositions1), indicesPositions, sizeof(indicesPositions));
Mesh background(vertexPositions1, sizeof(vertexPositions1), indicesPositions, sizeof(indicesPositions));
Mesh pointBlock(vertexPositions1, sizeof(vertexPositions1), indicesPositions, sizeof(indicesPositions));
Mesh skyBox(vertexPositions1, sizeof(vertexPositions1), indicesPositions, sizeof(indicesPositions));
//Shader shader(path); // Shader
Texture texture(texturePath); // Create a texture
Texture texture2(texturePath2); // Create a texture
Texture texture3(texturePath3); // Create a texture
Texture texture4(texturePath4); // Create a texture
Texture texture5(texturePath5); // Create a texture
Texture texture6(texturePath6); // Create a texture
Transform paddle1Transform; // , Transformations
Transform paddle2Transform; // , Transformations
Transform ballTransform;
Transform backgroundTransform;
Transform pointBlockTransform;
Transform skyBoxTransform;
Camera perspectiveCamera(glm::vec3(0.f, 0.f, 2.f), 70.f, (float)800.f / (float)600.f, 0.1f, 10000.0f);
Camera orthographicCamera(glm::vec3(0.f, 0.f, 3.f), -1.0f, 1.0f, -1.0f, 1.0f, 0.1f, 100.0f);
Camera renderCamera = orthographicCamera; // Camera used in the scene
GLint player1Points = 0;
GLint player2Points = 0;
float value = 0.0f;
pointBlockTransform.SetPos(glm::vec3(-0.96,0.95f, 0.f));
pointBlockTransform.SetScale(glm::vec3(0.04f, 0.04f, 0.04f));
backgroundTransform.GetPos().z = -3.0f;
backgroundTransform.SetScale(glm::vec3(5.0f, 4.8f, 1.0f));
paddle2Transform.GetPos().x = 0.9f;
paddle1Transform.GetPos().x = -0.9f;
ballTransform.GetPos().x = -0.8f;
skyBoxTransform.GetScale() *= 10000;
float ballSpeed = 15.f;
glm::vec3 ballVelocity(ballSpeed, -ballSpeed, 0.0f); // Set the initial velocity
paddle1Transform.SetScale(glm::vec3(.05f, .3f, .1f));
paddle2Transform.SetScale(glm::vec3(.05f, .3f, .1f));
ballTransform.SetScale(glm::vec3(.05f, .075f, .075f));
//paddle2Obj.transform = paddle1Transform;
double lastElapsedTime = SDL_GetTicks() - 1, deltaTime = 0.0f;
while (!display.IsWindowClosed()) /// While the window is open
{
GLint randomNo = rand() % 2 + 1;
display.Clear(0.0f, 0.0f, 0.0f, 0.0f);
// Calculate deltaTime from how long it took between frames
double elapsedTime = SDL_GetTicks();
deltaTime = (elapsedTime / lastElapsedTime) / 1000.0f;
lastElapsedTime = elapsedTime;
//cout << deltaTime << endl;
if ((ballTransform.GetPos().x) > 1) // Point for player1
{
ballTransform.GetPos().x = 0.8f;
ballTransform.GetPos().y = paddle2Transform.GetPos().y;
ballVelocity.x = -ballVelocity.x;
player1Points++; // Increase points
cout << "Player 1 Point" << endl;
if (player1Points == 20)
{
player1Points = 0;
player2Points = 0;
cout << "Player 2 wins" << endl;
}
}
else if (ballTransform.GetPos().x < -1) // Point for player2
{
ballTransform.GetPos().x = -0.8f;
ballTransform.GetPos().y = paddle1Transform.GetPos().y;
ballVelocity.x = -ballVelocity.x;
player2Points++; // Increase points
cout << "Player 2 Point" << endl;
if (player2Points == 20)
{
player2Points = 0;
player1Points = 0;
cout << "Player 2 wins" << endl;
}
}
//.........这里部分代码省略.........