Skip to content

Commit

Permalink
Added Lamborhinhi outside ICTC and texture on the floor
Browse files Browse the repository at this point in the history
  • Loading branch information
rabinadk1 committed Mar 3, 2020
1 parent 2999c90 commit dceea1a
Show file tree
Hide file tree
Showing 15 changed files with 2,057 additions and 11,520 deletions.
2 changes: 1 addition & 1 deletion Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ int Renderer::w_width = 1072;
int Renderer::w_height = 804;

// Camera
Camera Renderer::camera = Camera(glm::vec3(0.f, 0.f, 3.0f));
Camera Renderer::camera = Camera(glm::vec3(0.f, 0.f, 30.0f));

// Callback function for printing debug statements
void GLDebugMessageCallback(GLenum source, GLenum type, GLuint id,
Expand Down
34 changes: 26 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ int main()
glEnable(GL_DEPTH_TEST);

const float planeVertices[] = {
-1, 0, -1,
1, 0, -1,
1, 0, 1,
-1, 0, 1};
// positions //texture coordinates
-1, 0, -1, 0, 1,
1, 0, -1, 1, 1,
1, 0, 1, 1, 0,
-1, 0, 1, 0, 0};

const uint planeIndices[] = {
0, 1, 2,
Expand All @@ -94,15 +95,23 @@ int main()
const IndexBuffer planeIB(planeIndices, sizeof(planeIndices) / sizeof(uint));

VertexBufferLayout planeLayout;
// positions
planeLayout.Push<float>(3);
// texture coordinates
planeLayout.Push<float>(2);

planeVA.AddBuffer(planeVB, planeLayout);
Shader planeShader("res/shaders/lamp.glsl");

Shader planeShader("res/shaders/renderTexture.glsl");
glm::mat4 planeModelMatrix = glm::translate(glm::mat4(1.f), glm::vec3(10.f, -1.75f, 0.f));
planeModelMatrix = glm::scale(planeModelMatrix, glm::vec3(100.f));
planeShader.Bind();
planeShader.SetUniform("u_Model", planeModelMatrix);

Texture planeTexture("res/images/groundTexture.png");
planeTexture.Bind();
planeShader.SetUniform("u_Texture", 0);

const float vertices[] = {
// front
-1.0, -1.0, 1.0,
Expand Down Expand Up @@ -157,6 +166,7 @@ int main()
// model Loading
Model home("res/objects/ICTC/ictc.fbx");
Model room("res/objects/ICTC/ICTCRoom.fbx");
Model car("res/objects/car/Lamborghini_Aventador.fbx");
Model glass("res/objects/ICTC/ictc_glass.fbx");

Shader lightingShader("res/shaders/lightingMap.glsl");
Expand All @@ -169,11 +179,14 @@ int main()
lightingShader.SetUniform("u_Light.linear", 0.002f);
lightingShader.SetUniform("u_Light.quadratic", 0.0013f);

glm::mat4 lightingModelMatrix = glm::translate(glm::mat4(1.f), glm::vec3(0.f, -1.75f, 0.f));
lightingModelMatrix = glm::scale(lightingModelMatrix, glm::vec3(0.2f));
lightingShader.SetUniform("u_Model", lightingModelMatrix);
lightingShader.SetUniform("u_Material.shininess", 128.0f);

glm::mat4 lightingModelMatrix = glm::translate(glm::mat4(1.f), glm::vec3(0.f, -1.75f, 0.f));
// lightingModelMatrix = glm::scale(lightingModelMatrix, glm::vec3(2.f));

glm::mat4 carModelMatrix = glm::translate(glm::mat4(1.f), glm::vec3(7.f, -1.75f, 5.f));
carModelMatrix = glm::scale(carModelMatrix, glm::vec3(0.01f));

/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
Expand All @@ -191,6 +204,7 @@ int main()
// projection transformation
const glm::mat4 lookAt = Renderer::camera.GetViewMatrix();
lightingShader.Bind();
lightingShader.SetUniform("u_Model", lightingModelMatrix);
lightingShader.SetUniform("u_ViewPos", Renderer::camera.GetPosition());
lightingShader.SetUniform("u_View", lookAt);
const glm::mat4 projection = glm::perspective(glm::radians(Renderer::camera.GetFOV()),
Expand All @@ -201,6 +215,9 @@ int main()
room.Draw(lightingShader);
glass.Draw(lightingShader);

lightingShader.SetUniform("u_Model", carModelMatrix);
car.Draw(lightingShader);

// also draw the lamp object
lampShader.Bind();
lampShader.SetUniform("u_Projection", projection);
Expand All @@ -212,6 +229,7 @@ int main()
planeShader.SetUniform("u_Projection", projection);
planeShader.SetUniform("u_View", lookAt);

planeTexture.Bind();
Renderer::Draw(planeVA, planeIB);

/* Swap front and back buffers */
Expand Down
Binary file added res/images/groundTexture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 0 additions & 57 deletions res/objects/ICTC/ICTC.mtl

This file was deleted.

Loading

0 comments on commit dceea1a

Please sign in to comment.