Skip to content
Snippets Groups Projects

Feature/08 model loading

Closed Jan Delember requested to merge feature/08_Model_Loading into develop
14 files
+ 8050
128
Compare changes
  • Side-by-side
  • Inline

Files

@@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include "phx/assimp_loader.hpp"
#include "phx/input_system.hpp"
#include "phx/light.hpp"
#include "phx/material.hpp"
@@ -52,6 +53,7 @@ int main(int, char**) {
if (key == 'f') is_showing_framerate = !is_showing_framerate;
});
/*
phx::Entity* triangle = scene.CreateEntity();
triangle->AddComponent<phx::Transform>();
phx::Mesh* mesh = triangle->AddComponent<phx::Mesh>();
@@ -63,14 +65,23 @@ int main(int, char**) {
mesh->SetNormals(normals);
std::vector<unsigned int> indices = {0u, 1u, 2u};
mesh->SetIndices(indices);
phx::Material* material = triangle->AddComponent<phx::Material>();
*/
phx::AssimpLoader loader(&scene);
phx::Entity* bunny =
loader.LoadModelFile("../../../resources/models/bunny.obj")[0];
phx::Material* material = bunny->AddComponent<phx::Material>();
material->SetDiffuseColor(glm::vec3(1.0f, 0.71f, 0.75f));
material->SetSpecularColor(glm::vec3(1.0f, 1.0f, 1.0f));
material->SetAmbientColor(glm::vec3(0.2f, 0.2f, 0.2f));
material->SetShininess(500.0f);
phx::Transform* bunny_transform = bunny->AddComponent<phx::Transform>();
bunny_transform->SetTranslation(glm::vec3(0.0f, -0.1f, 0.0f));
phx::Entity* main_light = scene.CreateEntity();
main_light->AddComponent<phx::Transform>();
phx::Transform* light_transform = main_light->AddComponent<phx::Transform>();
light_transform->SetTranslation(glm::vec3(1.0f, 1.0f, 0.0f));
phx::Light* light = main_light->AddComponent<phx::Light>();
light->SetType(phx::Light::Type::kDirectional);
light->SetColor(glm::vec3(1.0f, 1.0f, 1.0f));
@@ -87,7 +98,7 @@ int main(int, char**) {
int framecount = 0;
while (is_running) {
camera_transform->SetTranslation(
glm::vec3(3.0f * sin(0.2 * step), 0.0f, 3.0f * cos(0.2 * step)));
glm::vec3(0.3f * sin(0.2 * step), 0.0f, 0.3f * cos(0.2 * step)));
camera_transform->LookAt(glm::vec3(0.0f, 0.0f, 0.0f));
// render it, so far no way to cancel
Loading