Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 244 additions & 8 deletions RaniPok.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@

class RaniPokhari {
public:

float aR=0.5,aG=0.5,aB=0.5;
float dR=0.5,dG=0.5,dB=0.5;
const unsigned int SCR_WIDTH = 1000;
const unsigned int SCR_HEIGHT = 900;

Shader mainShader, reflectionShader, waterShader, lightShader, sunlight;
Model mainTemple, wall, ghantaghar, water, stairs, light, reflection;
Shader mainShader, reflectionShader, waterShader, lightShader, sunlight,sunShader;
Model mainTemple, wall, ghantaghar, water, stairs, light, reflection,sun;
Camera camera;

RaniPokhari() {
Expand All @@ -39,6 +40,7 @@ class RaniPokhari {
void loadShaders();

void applyLighting();
void applyDayLighting(float time);
glm::mat4 translate(float tx,float sy,float sz);

void Draw();
Expand All @@ -55,8 +57,9 @@ void RaniPokhari::loadModels() {
ghantaghar = Model("/home/cool/CLionProjects/RaniPokhari/rani/ghantaghar.obj");
water = Model("/home/cool/CLionProjects/RaniPokhari/rani/water.obj");
stairs = Model("/home/cool/CLionProjects/RaniPokhari/rani/stairs.obj");
light = Model("/home/cool/CLionProjects/RaniPokhari/rani/lights_and_bars.obj");
light = Model("/home/cool/CLionProjects/RaniPokhari/rani/lights_and_bars_without_sun.obj");
reflection = Model("/home/cool/CLionProjects/RaniPokhari/rani/begin_____.obj");
sun=Model("/home/cool/CLionProjects/RaniPokhari/rani/sun_only.obj");

};

Expand All @@ -72,6 +75,8 @@ void RaniPokhari::loadShaders() {
//
sunlight = Shader("/home/cool/CLionProjects/RaniPokhari/Assets/Shaders/sunlight.vert",
"/home/cool/CLionProjects/RaniPokhari/Assets/Shaders/sunlight.frag");
sunShader = Shader("/home/cool/CLionProjects/RaniPokhari/Assets/Shaders/sunShader.vert",
"/home/cool/CLionProjects/RaniPokhari/Assets/Shaders/sunShader.frag");

};

Expand All @@ -89,7 +94,7 @@ void RaniPokhari::Draw() {
waterShader.setMat4("projection", projection);
waterShader.setMat4("view", view);
glm::mat4 waterModel = glm::mat4(1.0f);
waterModel = glm::translate(waterModel,glm::vec3(0.0f, 0.0f, 0.0f)); // translate it down so it's at the center of the scene
waterModel = glm::translate(waterModel,glm::vec3(cos(glfwGetTime()),0.0, 0.0)); // translate it down so it's at the center of the scene
waterModel = glm::scale(waterModel,
glm::vec3(1.0f, 1.0f, 1.0f)); // it's a bit too big for our scene, so scale it down
waterShader.setMat4("model", waterModel);
Expand Down Expand Up @@ -145,6 +150,23 @@ glm::mat4 model2 = glm::mat4(1.0f);
lightModel = glm::scale(lightModel, glm::vec3(1.0f, 1.0f, 1.0f)); // it's a bit too big for our scene, so scale it down
sunlight.setMat4("model", lightModel);
light.Draw(sunlight);

glm::mat4 sunModel = glm::mat4(1.0f);

sunShader.use();
sunShader.setMat4("projection", projection);
sunShader.setMat4("view", view);
float t=3.14*sin(pow(glfwGetTime(),0.7));
sunModel = glm::rotate(sunModel,-t,glm::vec3(1.0)); // translate it down so it's at the center of the scene

// sunModel = glm::translate(sunModel, glm::vec3(0.0f, -sin(pow(glfwGetTime(),0.7)*90), -sin(pow(glfwGetTime(),0.7))*90)); // translate it down so it's at the center of the scene
// lightModel=translate(0,0,0);
sunModel = glm::scale(sunModel, glm::vec3(1.0f, 1.0f, 1.0f)); // it's a bit too big for our scene, so scale it down
sunShader.setMat4("model", sunModel);
sunShader.setFloat("tim",glfwGetTime());

sun.Draw(sunShader);

glDisable(GL_DEPTH_TEST);

}
Expand All @@ -155,8 +177,8 @@ void RaniPokhari::applyLighting() {
mainShader.use();
mainShader.setVec3("viewPos", camera.Position);

mainShader.setVec3("dirLight.direction", -100.0f, -34.0f, -0.3f);
mainShader.setVec3("dirLight.ambient", 0.1f, 0.1f, 0.1f);
mainShader.setVec3("dirLight.direction", 100.0f, -34.0f, -0.3f);
mainShader.setVec3("dirLight.ambient", 0.0f, 0.0f, 0.0f);
mainShader.setVec3("dirLight.diffuse", 0.4f, 0.4f, 0.4f);
mainShader.setVec3("dirLight.specular", 0.5f, 0.5f, 0.5f);
//
Expand Down Expand Up @@ -249,7 +271,7 @@ void RaniPokhari::applyLighting() {
waterShader.setVec3("viewPos", camera.Position);
//lamp1
waterShader.setVec3("dirLight.direction", -100.0f, -34.0f, -0.3f);
waterShader.setVec3("dirLight.ambient", 0.3f, 0.3f, 0.3f);
waterShader.setVec3("dirLight.ambient", 0.0f, 0.0f, 0.0f);
waterShader.setVec3("dirLight.diffuse", 0.4f, 0.4f, 0.4f);
waterShader.setVec3("dirLight.specular", 0.5f, 0.5f, 0.5f);
//lamp2
Expand Down Expand Up @@ -334,6 +356,220 @@ void RaniPokhari::applyLighting() {
// glm::mat4 model = glm::mat4(1.0f);
// waterShader.setMat4("model", model);
}

void RaniPokhari::applyDayLighting(float time) {


float currentFrame = glfwGetTime();

mainShader.use();
mainShader.setVec3("viewPos", camera.Position);

mainShader.setVec3("dirLight.direction", 100.0f, -34.0f, -0.3f);
if(time>=0.6)
{
mainShader.setVec3("dirLight.ambient", 0.6,0.6,0.6);

}
else if(time<=0.001)
{
mainShader.setVec3("dirLight.ambient", 0.001,0.001,0.001);
}
else
{
mainShader.setVec3("dirLight.ambient", time,time,time);
}

mainShader.setVec3("dirLight.diffuse", 0.4f, 0.4f, 0.4f);
mainShader.setVec3("dirLight.specular", 0.5f, 0.5f, 0.5f);
//
mainShader.setVec3("pointLights[0].position", -61.34, 7.13, 109.8);
mainShader.setVec3("pointLights[0].ambient", 0.0f, 0.0f, 0.0f);
mainShader.setVec3("pointLights[0].diffuse", 0.8f, 0.8f, 0.8f);
mainShader.setVec3("pointLights[0].specular", 1.0f, 1.0f, 1.0f);
mainShader.setFloat("pointLights[0].constant", 1.0f);
mainShader.setFloat("pointLights[0].linear", 0.09);
mainShader.setFloat("pointLights[0].quadratic", 0.032);
// point light 2
mainShader.setVec3("pointLights[1].position", -61,6, 10);
mainShader.setVec3("pointLights[1].ambient", 1.0f, 1.0f, 1.0f);
mainShader.setVec3("pointLights[1].diffuse", 0.8f, 0.8f, 0.8f);
mainShader.setVec3("pointLights[1].specular", 1.0f, 1.0f, 1.0f);
mainShader.setFloat("pointLights[1].constant", 1.0f);
mainShader.setFloat("pointLights[1].linear", 0.09);
mainShader.setFloat("pointLights[1].quadratic", 0.032);
// point light 3
mainShader.setVec3("pointLights[2].position", 42,6,110);
mainShader.setVec3("pointLights[2].ambient", 1.0f, 1.0f, 1.0f);
mainShader.setVec3("pointLights[2].diffuse", 0.8f, 0.8f, 0.8f);
mainShader.setVec3("pointLights[2].specular", 1.0f, 1.0f, 1.0f);
mainShader.setFloat("pointLights[2].constant", 1.0f);
mainShader.setFloat("pointLights[2].linear", 0.09);
mainShader.setFloat("pointLights[2].quadratic", 0.032);
// point light 4
mainShader.setVec3("pointLights[3].position", 41,6,10);
mainShader.setVec3("pointLights[3].ambient", 1.0f, 1.0f, 1.0f);
mainShader.setVec3("pointLights[3].diffuse", 0.8f, 0.8f, 0.8f);
mainShader.setVec3("pointLights[3].specular", 1.0f, 1.0f, 1.0f);
mainShader.setFloat("pointLights[3].constant", 1.0f);
mainShader.setFloat("pointLights[3].linear", 0.09);
mainShader.setFloat("pointLights[3].quadratic", 0.032);

//lamp ghntaghar
mainShader.setVec3("pointLights[4].position", -97,53,35);
mainShader.setVec3("pointLights[4].ambient", 1.0f, 1.0f, 0.0f);
mainShader.setVec3("pointLights[4].diffuse", 0.8f, 0.8f, 0.8f);
mainShader.setVec3("pointLights[4].specular", 1.0f, 1.0f, 1.0f);
mainShader.setFloat("pointLights[4].constant", 1.0f);
mainShader.setFloat("pointLights[4].linear", 0.09);
mainShader.setFloat("pointLights[4].quadratic", 0.032);

mainShader.setVec3("pointLights[6].position", 9,9,56);
mainShader.setVec3("pointLights[6].ambient", 1.0f, 1.0f, 1.0f);
mainShader.setVec3("pointLights[6].diffuse", 0.8f, 0.8f, 0.8f);
mainShader.setVec3("pointLights[6].specular", 1.0f, 1.0f, 1.0f);
mainShader.setFloat("pointLights[6].constant", 1.0f);
mainShader.setFloat("pointLights[6].linear", 0.09);
mainShader.setFloat("pointLights[6].quadratic", 0.032);
//moon
mainShader.setVec3("pointLights[5].position", -100,34,38);
mainShader.setVec3("pointLights[5].ambient", 1.0f, 1.0f, 1.0f);
mainShader.setVec3("pointLights[5].diffuse", 0.8f, 0.8f, 0.8f);
mainShader.setVec3("pointLights[5].specular", 1.0f, 1.0f, 1.0f);
mainShader.setFloat("pointLights[5].constant", 1.0f);
mainShader.setFloat("pointLights[5].linear", 0.09);
mainShader.setFloat("pointLights[5].quadratic", 0.032);

mainShader.setVec3("light.direction", -currentFrame, -currentFrame, -currentFrame);
mainShader.setVec3("viewPos", camera.Position);

// // light properties
mainShader.setVec3("light.ambient", 0.1f, 0.1f, 0.1f);
mainShader.setVec3("light.diffuse", 0.5f, 0.5f, 0.5f);
mainShader.setVec3("light.specular", 0.50f, 0.50f, 0.50f);

// material properties
mainShader.setFloat("material.shininess", 32.0f);
mainShader.setFloat("material.diffuse", 0.5f);
mainShader.setFloat("material.specular", 0.30f);

// view/projection transformations
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 500.0f);
glm::mat4 view = camera.GetViewMatrix();

mainShader.setMat4("projection", projection);
mainShader.setMat4("view", view);

// world transformation
glm::mat4 model = glm::mat4(1.0f);
mainShader.setMat4("model", model);
// mainTemple.Draw(mainShader);


// lighting for water

waterShader.use();
waterShader.setVec3("viewPos", camera.Position);
//lamp1
waterShader.setVec3("dirLight.direction", 100.0f, -34.0f, -0.3f);

if(time>=0.6)
{
waterShader.setVec3("dirLight.ambient", 0.6,0.6,0.6);
// waterShader.setVec3("dirLight.diffuse", 0.4f, 0.4f, 0.4f);
// waterShader.setVec3("dirLight.specular", 0.5f, 0.5f, 0.5f);
//
}
else if(time<=0.001)
{
waterShader.setVec3("dirLight.ambient", 0.001,0.001,0.001);
// waterShader.setVec3("dirLight.diffuse", 0.001,0.001,0.001);
// waterShader.setVec3("dirLight.specular", 0.001,0.001,0.001);


}
else
{
waterShader.setVec3("dirLight.ambient", time,time,time);
waterShader.setVec3("dirLight.diffuse", 0.4f, 0.4f, 0.4f);
waterShader.setVec3("dirLight.specular", 0.5f, 0.5f, 0.5f);
}

// waterShader.setVec3("dirLight.ambient", 0.50f, 0.50f, 0.50f);
waterShader.setVec3("dirLight.diffuse", 0.4f, 0.4f, 0.4f);
waterShader.setVec3("dirLight.specular", 0.5f, 0.5f, 0.5f);
//lamp2
waterShader.setVec3("pointLights[0].position", -61.34, 7.13, 109.8);
waterShader.setVec3("pointLights[0].ambient", 0.3f, 0.3f, 0.3f);
waterShader.setVec3("pointLights[0].diffuse", 0.8f, 0.8f, 0.8f);
waterShader.setVec3("pointLights[0].specular", 1.0f, 1.0f, 1.0f);
waterShader.setFloat("pointLights[0].constant", 1.0f);
waterShader.setFloat("pointLights[0].linear", 0.09);
waterShader.setFloat("pointLights[0].quadratic", 0.032);
// lamp3
waterShader.setVec3("pointLights[1].position", -61.0,6.0f, 10.0f);
waterShader.setVec3("pointLights[1].ambient", 0.3f, 0.3f, 0.3f);
waterShader.setVec3("pointLights[1].diffuse", 0.8f, 0.8f, 0.8f);
waterShader.setVec3("pointLights[1].specular", 1.0f, 1.0f, 1.0f);
waterShader.setFloat("pointLights[1].constant", 1.0f);
waterShader.setFloat("pointLights[1].linear", 0.09);
waterShader.setFloat("pointLights[1].quadratic", 0.032);
// lamp 4
waterShader.setVec3("pointLights[2].position", 42,6,110);
waterShader.setVec3("pointLights[2].ambient", 0.3f, 0.3f, 0.3f);
waterShader.setVec3("pointLights[2].diffuse", 0.8f, 0.8f, 0.8f);
waterShader.setVec3("pointLights[2].specular", 1.0f, 1.0f, 1.0f);
waterShader.setFloat("pointLights[2].constant", 1.0f);
waterShader.setFloat("pointLights[2].linear", 0.09);
waterShader.setFloat("pointLights[2].quadratic", 0.032);
// point light 4
waterShader.setVec3("pointLights[3].position", 41,6,10);
waterShader.setVec3("pointLights[3].ambient", 0.3f, 0.3f, 0.3f);
waterShader.setVec3("pointLights[3].diffuse", 0.8f, 0.8f, 0.8f);
waterShader.setVec3("pointLights[3].specular", 1.0f, 1.0f, 1.0f);
waterShader.setFloat("pointLights[3].constant", 1.0f);
waterShader.setFloat("pointLights[3].linear", 0.09);
waterShader.setFloat("pointLights[3].quadratic", 0.032);
//lamp ghntaghar
waterShader.setVec3("pointLights[4].position", -100,34,38);
waterShader.setVec3("pointLights[4].ambient", 0.3f, 0.3f, 0.3f);
waterShader.setVec3("pointLights[4].diffuse", 0.8f, 0.8f, 0.8f);
waterShader.setVec3("pointLights[4].specular", 1.0f, 1.0f, 1.0f);
waterShader.setFloat("pointLights[4].constant", 1.0f);
waterShader.setFloat("pointLights[4].linear", 0.09);
waterShader.setFloat("pointLights[4].quadratic", 0.032);

//moon
waterShader.setVec3("pointLights[6].position", -97,53,35);
waterShader.setVec3("pointLights[6].ambient", 1.0f, 0.0f, 0.0f);
waterShader.setVec3("pointLights[6].diffuse", 1.0f, 0.0f, 0.0f);
waterShader.setVec3("pointLights[6].specular", 1.0f, 0.0f, 0.0f);
waterShader.setFloat("pointLights[6].constant", 1.0f);
waterShader.setFloat("pointLights[6].linear", 0.09);
waterShader.setFloat("pointLights[6].quadratic", 0.032);

waterShader.setVec3("pointLights[5].position", -100,34,38);
waterShader.setVec3("pointLights[5].ambient", 1.0f, 1.0f, 1.0f);
waterShader.setVec3("pointLights[5].diffuse", 0.8f, 0.8f, 0.8f);
waterShader.setVec3("pointLights[5].specular", 1.0f, 1.0f, 1.0f);
waterShader.setFloat("pointLights[5].constant", 1.0f);
waterShader.setFloat("pointLights[5].linear", 0.09);
waterShader.setFloat("pointLights[5].quadratic", 0.032);

waterShader.setVec3("light.direction", -currentFrame, -currentFrame, -currentFrame);
waterShader.setVec3("viewPos", camera.Position);

// // light properties
waterShader.setVec3("light.ambient", 0.1f, 0.1f, 0.1f);
waterShader.setVec3("light.diffuse", 0.5f, 0.5f, 0.5f);
waterShader.setVec3("light.specular", 0.50f, 0.50f, 0.50f);

// material properties
waterShader.setFloat("material.shininess", 32.0f);
waterShader.setFloat("material.diffuse", 0.5f);
waterShader.setFloat("material.specular", 0.30f);
}

glm::mat4 RaniPokhari::scaling(float sx,float sy,float sz)
{
glm::vec4 r1(sx,0,0,0);
Expand Down
65 changes: 65 additions & 0 deletions inputHandle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <GLFW/glfw3.h>
#include "Camera.h"
#include "RaniPok.h"
#include "iostream"
class InputProcess{
public:
// const unsigned int SCR_WIDTH = 1000;
// const unsigned int SCR_HEIGHT = 900;
// bool firstMouse = true;
// float lastX = SCR_WIDTH / 2.0f;
// float lastY = SCR_HEIGHT / 2.0f;
// void mouse_callback(GLFWwindow *window,RaniPokhari *rani, double xpos=0, double ypos=0);
//
// void scroll_callback(GLFWwindow *window,RaniPokhari *rani, double xoffset, double yoffset);

void processInput(GLFWwindow *window,Camera *camera,RaniPokhari *rani);
// void mouseInput(GLFWwindow *window,RaniPokhari *rani);

};
//void InputProcess::mouseInput(GLFWwindow *window,RaniPokhari *rani) {
//// glfwSetCursorPosCallback(window,mouse_callback(window,rani));
//// glfwSetScrollCallback(window, scroll_callback(window,rani,0,0));
//}
void InputProcess::processInput(GLFWwindow *window, Camera *camera,RaniPokhari *rani) {
float speed=0.2;
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);

if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
rani->camera.ProcessKeyboard(FORWARD, speed);
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
rani->camera.ProcessKeyboard(BACKWARD, speed);
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
rani->camera.ProcessKeyboard(LEFT, speed);
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
rani->camera.ProcessKeyboard(RIGHT, speed);


}



//// glfw: whenever the mouse moves, this callback is called
//// -------------------------------------------------------
//void InputProcess:: mouse_callback(GLFWwindow *window,RaniPokhari *rani ,double xpos=0, double ypos=0) {
// if (firstMouse) {
// lastX = xpos;
// lastY = ypos;
// firstMouse = false;
// }
//
// float xoffset = xpos - lastX;
// float yoffset = lastY - ypos; // reversed since y-coordinates go from bottom to top
//
// lastX = xpos;
// lastY = ypos;
//
// rani->camera.ProcessMouseMovement(xoffset, yoffset);
//}
//
//// glfw: whenever the mouse scroll wheel scrolls, this callback is called
//// ----------------------------------------------------------------------
//void InputProcess::scroll_callback(GLFWwindow *window,RaniPokhari *rani, double xoffset=0, double yoffset=0) {
// rani->camera.ProcessMouseScroll(yoffset);
//}
10 changes: 10 additions & 0 deletions lights_and_bars_without_sun.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Blender MTL File: 'lights_and_bars_without_sun.blend'
# Material Count: 1

newmtl None
Ns 500
Ka 0.8 0.8 0.8
Kd 0.8 0.8 0.8
Ks 0.8 0.8 0.8
d 1
illum 2
Loading