Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- Ndk::Application application;
- Nz::RenderWindow& mainWindow = application.AddWindow<Nz::RenderWindow>();
- mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test");
- Ndk::World& world = application.AddWorld();
- world.GetSystem<Ndk::RenderSystem>().SetGlobalUp(Nz::Vector3f::Up());
- Ndk::EntityHandle viewEntity = world.CreateEntity();
- viewEntity->AddComponent<Ndk::NodeComponent>();
- Ndk::CameraComponent& viewer = viewEntity->AddComponent<Ndk::CameraComponent>();
- viewer.SetTarget(&mainWindow);
- viewer.SetProjectionType(Nz::ProjectionType_Perspective);
- Nz::ModelRef model = Nz::Model::New();
- Nz::MeshRef mesh = Nz::Mesh::New();
- mesh->CreateStatic();
- Nz::SubMeshRef subMesh = mesh->BuildSubMesh(Nz::Primitive::IcoSphere(2));
- subMesh->SetMaterialIndex(0);
- model->SetMesh(mesh);
- Nz::MaterialRef mat = Nz::Material::New();
- mat->SetShader("PhongLighting");
- mat->SetDiffuseColor(Nz::Color::Green);
- mat->SetSpecularColor(Nz::Color::Black);
- mat->SetFaceFilling(Nz::FaceFilling_Fill);
- model->SetMaterial(0, mat);
- Ndk::EntityHandle cube = world.CreateEntity();
- Ndk::NodeComponent& cubeNode = cube->AddComponent<Ndk::NodeComponent>();
- Ndk::GraphicsComponent & cubeGraphics = cube->AddComponent<Ndk::GraphicsComponent>();
- cubeGraphics.Attach(model);
- Nz::Boxf cubeBox = cubeGraphics.GetBoundingVolume().aabb;
- cubeNode.SetPosition(0, 0, -10);
- Ndk::EntityHandle light = world.CreateEntity();
- Ndk::NodeComponent& lightNode = light->AddComponent<Ndk::NodeComponent>();
- Ndk::LightComponent & lightLight = light->AddComponent<Ndk::LightComponent>();
- lightLight.SetLightType(Nz::LightType_Point);
- lightLight.SetAmbientFactor(0.1f);
- lightLight.SetRadius(100);
- lightNode.SetPosition(Nz::Vector3f(5, 5, 0));
- world.GetSystem<Ndk::RenderSystem>().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(117, 122, 214)));
- Nz::Clock clock;
- while (application.Run())
- {
- cubeNode.SetRotation(Nz::Quaternionf(Nz::EulerAnglesf(clock.GetSeconds() * 10, clock.GetSeconds() * 23.2f, 0)));
- //lightLight.SetRadius(clock.GetSeconds());
- mainWindow.Display();
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement