@@ -59,10 +59,14 @@ void Application::Start()
59
59
{
60
60
CheckInitialization ();
61
61
62
- SetupModel ();
62
+ SetupShader ();
63
63
SetupCamera ();
64
64
SetupLight ();
65
65
66
+ SetupModel (m_assetsManager->GetAssetPath ({" models" , " backpack" , " Survival_BackPack_2.fbx" }));
67
+ LoadTexture (m_assetsManager->GetAssetPath ({" models" , " backpack" , " 1001_albedo.jpg" }), TextureType::Diffuse);
68
+ LoadTexture (m_assetsManager->GetAssetPath ({" models" , " backpack" , " 1001_metallic.jpg" }), TextureType::Specular);
69
+
66
70
while (!glfwWindowShouldClose (m_window))
67
71
{
68
72
glfwPollEvents ();
@@ -102,24 +106,34 @@ void Application::CheckInitialization()
102
106
}
103
107
}
104
108
105
- void Application::SetupModel ()
109
+ void Application::SetupShader ()
106
110
{
107
- Shader* shader = new Shader (m_assetsManager->GetAssetPath ({" shaders" , " basic_vertex.vert" }),
111
+ m_shader = new Shader (m_assetsManager->GetAssetPath ({" shaders" , " basic_vertex.vert" }),
108
112
m_assetsManager->GetAssetPath ({" shaders" , " basic_fragment.frag" }));
109
- shader->LoadAndCompile ();
113
+ m_shader->LoadAndCompile ();
114
+ }
110
115
111
- // Material* material = new Material();
112
- // material->diffuse = m_textureLoader
113
- // ->LoadTexture(g_config.modelFolder + g_config.textures.diffuseName, TextureType::Diffuse);
114
- // material->specular = m_textureLoader
115
- // ->LoadTexture(g_config.modelFolder + g_config.textures.specularName, TextureType::Specular);
116
+ void Application::SetupModel (std::string path)
117
+ {
118
+ if (m_model)
119
+ m_model->Unload ();
116
120
117
- // Model* model = m_loader->LoadModel(g_config.GetModelPath());
118
- // model->SetShader(shader);
119
- // model->SetScale(m_startModelScale);
120
- // model->SetMaterial(material);
121
+ m_model = m_loader->LoadModel (path);
122
+ m_model->SetShader (m_shader);
123
+ m_model->SetScale (m_startModelScale);
124
+ m_model->SetMaterial (new Material ());
125
+ }
121
126
122
- // m_model = model;
127
+ void Application::LoadTexture (std::string path, TextureType type)
128
+ {
129
+ if (!m_model)
130
+ throw CannotSetTexture ();
131
+
132
+ Texture texture = m_textureLoader
133
+ ->LoadTexture (path, type);
134
+
135
+ Material* material = m_model->GetMaterial ();
136
+ material->ReplaceTexture (texture, type);
123
137
}
124
138
125
139
void Application::SetupCamera ()
0 commit comments