本文整理汇总了C++中Window::GetCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ Window::GetCenter方法的具体用法?C++ Window::GetCenter怎么用?C++ Window::GetCenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Window
的用法示例。
在下文中一共展示了Window::GetCenter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
void TestGame::Init(const Window& window)
{
Material bricks("bricks", Texture("bricks.jpg"), 0.0f, 0, Texture("bricks_normal.jpg"), Texture("bricks_disp.png"), 0.03f, -0.5f);
Material bricks2("bricks2", Texture("bricks2.jpg"), 0.0f, 0, Texture("bricks2_normal.png"), Texture("bricks2_disp.jpg"), 0.04f, -1.0f);
//Material skin("humanFace", Texture("human.jpg"), 0.0f, 0, Texture("human_normal_inv.jpg"));
//Material skin("humanFace", Texture("human.jpg"), 0.08f, 8, Texture("human_normal_inv.jpg"));
IndexedModel square;
{
square.AddVertex(1.0f, -1.0f, 0.0f); square.AddTexCoord(Vector2f(1.0f, 1.0f));
square.AddVertex(1.0f, 1.0f, 0.0f); square.AddTexCoord(Vector2f(1.0f, 0.0f));
square.AddVertex(-1.0f, -1.0f, 0.0f); square.AddTexCoord(Vector2f(0.0f, 1.0f));
square.AddVertex(-1.0f, 1.0f, 0.0f); square.AddTexCoord(Vector2f(0.0f, 0.0f));
square.AddFace(0, 1, 2); square.AddFace(2, 1, 3);
}
Mesh customMesh("square", square.Finalize());
AddToScene((new Entity(Vector3f(0, -1, 5), Quaternion(), 32.0f))
->AddComponent(new MeshRenderer(Mesh("terrain02.obj"), Material("bricks"))));
AddToScene((new Entity(Vector3f(7,0,7)))
->AddComponent(new PointLight(Vector3f(0,1,0), 0.4f, Attenuation(0,0,1))));
AddToScene((new Entity(Vector3f(20,-11.0f,5), Quaternion(Vector3f(1,0,0), ToRadians(-60.0f)) * Quaternion(Vector3f(0,1,0), ToRadians(90.0f))))
->AddComponent(new SpotLight(Vector3f(0,1,1), 0.4f, Attenuation(0,0,0.02f), ToRadians(91.1f), 7, 1.0f, 0.5f)));
AddToScene((new Entity(Vector3f(), Quaternion(Vector3f(1,0,0), ToRadians(-45))))
->AddComponent(new DirectionalLight(Vector3f(1,1,1), 0.4f, 10, 80.0f, 1.0f)));
AddToScene((new Entity(Vector3f(0, 2, 0), Quaternion(Vector3f(0,1,0), 0.4f), 1.0f))
->AddComponent(new MeshRenderer(Mesh("plane3.obj"), Material("bricks2")))
->AddChild((new Entity(Vector3f(0, 0, 25)))
->AddComponent(new MeshRenderer(Mesh("plane3.obj"), Material("bricks2")))
->AddChild((new Entity())
->AddComponent(new CameraComponent(Matrix4f().InitPerspective(ToRadians(70.0f), window.GetAspect(), 0.1f, 1000.0f)))
->AddComponent(new FreeLook(window.GetCenter()))
->AddComponent(new FreeMove(10.0f)))));
AddToScene((new Entity(Vector3f(24,-12,5), Quaternion(Vector3f(0,1,0), ToRadians(30.0f))))
->AddComponent(new MeshRenderer(Mesh("sphere.obj"), Material("bricks"))));
AddToScene((new Entity(Vector3f(0,0,7), Quaternion(), 1.0f))
->AddComponent(new MeshRenderer(Mesh("square"), Material("bricks2"))));
}
示例2: Init
void TestGame::Init(const Window& window)
{
//Materials
Material bricks("bricks", Texture("bricks.jpg"), 0.0f, 0, Texture("bricks_normal.jpg"), Texture("bricks_disp.png"), 0.03f, -0.5f);
Material bricks2("bricks2", Texture("bricks2.jpg"), 0.0f, 0, Texture("bricks2_normal.png"), Texture("bricks2_disp.jpg"), 0.04f, -1.0f);
//Standard square mesh (1x1)
IndexedModel square;
{
square.AddVertex(1.0f, -1.0f, 0.0f); square.AddTexCoord(Vector2f(1.0f, 1.0f));
square.AddVertex(1.0f, 1.0f, 0.0f); square.AddTexCoord(Vector2f(1.0f, 0.0f));
square.AddVertex(-1.0f, -1.0f, 0.0f); square.AddTexCoord(Vector2f(0.0f, 1.0f));
square.AddVertex(-1.0f, 1.0f, 0.0f); square.AddTexCoord(Vector2f(0.0f, 0.0f));
square.AddFace(0, 1, 2); square.AddFace(2, 1, 3);
}
Mesh customMesh("square", square.Finalize());
//Light
Entity* mainLight = new Entity(Vector3f(0, 4, 0), Quaternion(Vector3f(1, 0, 0), ToRadians(270)), 1);
Entity* pointLight = new Entity(Vector3f(-1, 1.5, 0), Quaternion(Vector3f(0, 0, 0), ToRadians(0)), 1);
mainLight->AddModifier(new DirectionalLight(Vector3f(1, 1, 1), 0.4f, 10, 80, 1));
pointLight->AddModifier(new PointLight(Vector3f(0, 0, 1), 0.4f, Attenuation(0, 0, 1)));
pointLight->AddModifier(new RepetitiveLinearMotionModifier(Vector3f(1, 0, 0), 0.015f, 1));
//pointLight->AddModifier(new FreeMove(5.0f));
AddToScene(mainLight);
//AddToScene(pointLight);
//Camera
Entity* mainCamera = new Entity(Vector3f(-10, 5, 5), Quaternion(Vector3f(0, 0, 0), 0), 1);
mainCamera->AddModifier(new CameraComponent(Matrix4f().InitPerspective(ToRadians(70), window.GetAspect(), 0.1f, 1000)));
mainCamera->AddModifier(new FreeLook(window.GetCenter(), 0.15f));
mainCamera->AddModifier(new FreeMove(15));
AddToScene(mainCamera);
//Environment
/*Entity* floorPlane = new Entity(Vector3f(0, 0, 0), Quaternion(Vector3f(0, 0, 0), ToRadians(0)), 1);
Entity* floatingCube = new Entity(Vector3f(0, 1, 0), Quaternion(Vector3f(0, 0, 0), ToRadians(0)), 0.3f);
floorPlane->AddModifier(new MeshRenderer(Mesh("plane.obj"), Material("bricks")));
floatingCube->AddModifier(new MeshRenderer(Mesh("cube.obj"), Material("bricks2")));
floatingCube->AddModifier(new RepetitiveLinearMotionModifier(Vector3f(0, 1, 0), 0.01f, 2));
floatingCube->AddModifier(new RepetitiveRotationalMotionModifier(Vector3f(0, 1, 0), 0.02f, 1, false));
AddToScene(floorPlane);
AddToScene(floatingCube);*/
Entity* sphere1 = new Entity(Vector3f(0, 0, -4), Quaternion(Vector3f(0, 0, 0), ToRadians(0)), 1);
Entity* sphere2 = new Entity(Vector3f(0, 0, 1), Quaternion(Vector3f(0, 0, 0), ToRadians(0)), 1);
Entity* sphere3 = new Entity(Vector3f(0, 0, 3), Quaternion(Vector3f(0, 0, 0), ToRadians(0)), 1);
Entity* sphere4 = new Entity(Vector3f(0, 0, 5), Quaternion(Vector3f(0, 0, 0), ToRadians(0)), 1);
Entity* sphere5 = new Entity(Vector3f(0, 0, 7), Quaternion(Vector3f(0, 0, 0), ToRadians(0)), 1);
sphere1->AddModifier(new MeshRenderer(Mesh("sphere.obj"), Material("bricks")));
sphere2->AddModifier(new MeshRenderer(Mesh("sphere.obj"), Material("bricks2")));
sphere3->AddModifier(new MeshRenderer(Mesh("sphere.obj"), Material("bricks2")));
sphere4->AddModifier(new MeshRenderer(Mesh("sphere.obj"), Material("bricks2")));
sphere5->AddModifier(new MeshRenderer(Mesh("sphere.obj"), Material("bricks")));
AddToScene(sphere1);
AddToScene(sphere2);
AddToScene(sphere3);
AddToScene(sphere4);
AddToScene(sphere5);
//Physics
PhysicsEngine physicsEngine = PhysicsEngine();
PhysicsObject sphere1Rep = PhysicsObject(sphere1, new BoundingSphere(Vector3f(0, 0, -4), 1), Vector3f(0, 0, 1), Vector3f(0, 0, 0), false);
PhysicsObject sphere2Rep = PhysicsObject(sphere2, new BoundingSphere(Vector3f(0, 0, 1), 1), Vector3f(0, 0, 0), Vector3f(0, 0, 0), false);
PhysicsObject sphere3Rep = PhysicsObject(sphere3, new BoundingSphere(Vector3f(0, 0, 3), 1), Vector3f(0, 0, 0), Vector3f(0, 0, 0), false);
PhysicsObject sphere4Rep = PhysicsObject(sphere4, new BoundingSphere(Vector3f(0, 0, 5), 1), Vector3f(0, 0, 0), Vector3f(0, 0, 0), false);
PhysicsObject sphere5Rep = PhysicsObject(sphere5, new BoundingSphere(Vector3f(0, 0, 7), 1), Vector3f(0, 0, 0), Vector3f(0, 0, 0), false);
physicsEngine.AddObject(sphere1Rep);
physicsEngine.AddObject(sphere2Rep);
physicsEngine.AddObject(sphere3Rep);
physicsEngine.AddObject(sphere4Rep);
physicsEngine.AddObject(sphere5Rep);
SetPhysicsEngine(physicsEngine);
}