本文整理汇总了C++中Transformable::GetOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ Transformable::GetOrigin方法的具体用法?C++ Transformable::GetOrigin怎么用?C++ Transformable::GetOrigin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transformable
的用法示例。
在下文中一共展示了Transformable::GetOrigin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Window window(0, L"asd", 800, 600);
window.ShowAWindow();
rendContext = new RenderingContext(&window);
SystemManager* SM = new SystemManager();
RenderingSystem* RS = new RenderingSystem(rendContext);
PhysicsSystem* PS = new PhysicsSystem(90.81);
SM->AddSystem(RS);
SM->AddSystem(PS);
LARGE_INTEGER StartingTime, EndingTime, ElapsedMilliseconds;
LARGE_INTEGER Frequency;
GameObject* obj = new GameObject("BOX_X.obj");
GameObject* obj2 = new GameObject("pallo.obj");
Renderable* rendComp = ComponentFactory::CreateRenderable("pallo.obj", "sample.png");
Renderable* rendComp2 = ComponentFactory::CreateRenderable("pallo.obj", "tribaltatuointi.png");
Physics* physz = ComponentFactory::CreatePhysicsComponent(PS);
Physics* physz2 = ComponentFactory::CreatePhysicsComponent(PS);
Transformable* transComp = ComponentFactory::CreateTransformable();
Transformable* transComp2 = ComponentFactory::CreateTransformable();
physz2->SetMass(5);
physz->SetMass(2.5);
physz->SetElasticity(0.6);
physz->SetForces(Vector3<float>(1000000.0f, 1000000.0f, 0.0f));
physz2->SetForces(Vector3<float>(-1000000.0f, -1000000.0f, 0.0f));
obj->AddComponent(rendComp2);
obj->AddComponent(transComp);
obj2->AddComponent(rendComp);
obj2->AddComponent(transComp2);
obj->AddComponent(physz);
obj2->AddComponent(physz2);
transComp2->SetOrigin(100, 50, -200.0f);
transComp->SetOrigin(0, 0, -200.0f);
int x = 0;
RS->Draw(obj);
RS->Draw(obj2);
while (true)
{
QueryPerformanceFrequency(&Frequency);
QueryPerformanceCounter(&StartingTime);
if (Input::isKeyPressed(Input::L))
std::cout << "X: " << transComp->GetOrigin()[0] << " Y: " << transComp->GetOrigin()[1] << " Z: " << transComp->GetOrigin()[2] << std::endl;
window.WindowMessageCheck();
if (Input::isKeyPressed(Input::W))
physz->SetForces(Vector3<float>(0.0f, 4000.0f, 0.0f));
if (Input::isKeyPressed(Input::S))
physz->SetForces(Vector3<float>(0.0f, -4000.0f, 0.0f));
if (Input::isKeyPressed(Input::D))
physz->SetForces(Vector3<float>(4000.0f, 0.0f, 0.0f));
if (Input::isKeyPressed(Input::A))
physz->SetForces(Vector3<float>(-4000.0f, 0.0f, 0.0f));
if (Input::isKeyPressed(Input::Up))
physz->SetForces(Vector3<float>(0.0f, 0.0f, -4000.0f));
if (Input::isKeyPressed(Input::Down))
physz->SetForces(Vector3<float>(0.0f, 0.0f, 4000.0f));
x++;
float al = ((transComp->GetOrigin()[0] - transComp2->GetOrigin()[0])*(transComp->GetOrigin()[0] - transComp2->GetOrigin()[0]));
float ad = ((transComp->GetOrigin()[1] - transComp2->GetOrigin()[1])*(transComp->GetOrigin()[1] - transComp2->GetOrigin()[1]));
if (sqrt(al + ad) < 50)
{
//if (x < 5)
// ;
//else
physz->collision = true;
std::cout << "Collision!"<< std::endl;
x = 0;
}
if (Input::isKeyPressed(Input::Escape))
break;
//.........这里部分代码省略.........