first 15 fishes, but we need better movement
This commit is contained in:
parent
5f116faf2a
commit
546c120b14
@ -127,9 +127,9 @@ void renderScene()
|
||||
//glUniform3f(glGetUniformLocation(program, "light_dir"), 2, 1, 0);
|
||||
|
||||
drawObject(program, shipContext, shipModelMatrix, glm::vec3(0.6f));
|
||||
drawObject(program, sphereContext, glm::eulerAngleY(time / 2) * glm::translate(glm::vec3(-5, 0, 0))*glm::scale(glm::vec3(0.7f)), glm::vec3(0.0f, 0.6f, 0.8f));
|
||||
drawObject(program, sphereContext, glm::eulerAngleY(time / 2) * glm::translate(glm::vec3(-5, 0, 0))* glm::eulerAngleXZ(0.4f, 0.6f) * glm::eulerAngleY(time * 2) * glm::translate(glm::vec3(-1, 0, 0)) *glm::scale(glm::vec3(0.2f)), glm::vec3(0.7f, 0.6f, 0.8f));
|
||||
drawObjectTexture(programTex, sphereContext, glm::eulerAngleY(time / 2) * glm::translate(glm::vec3(-5, 0, 0)) * glm::eulerAngleXZ(0.7f, 0.5f) * glm::eulerAngleY(time * 2) * glm::translate(glm::vec3(-1, 0, 0)) * glm::scale(glm::vec3(0.2f)), texture::grid);
|
||||
drawObject(program, sphereContext, glm::eulerAngleY(time / 2) * glm::translate(glm::vec3(2, 0, 0))*glm::scale(glm::vec3(0.7f)), glm::vec3(0.0f, 0.6f, 0.8f));
|
||||
//drawObject(program, sphereContext, glm::eulerAngleY(time / 2) * glm::translate(glm::vec3(-5, 0, 0))* glm::eulerAngleXZ(0.4f, 0.6f) * glm::eulerAngleY(time * 2) * glm::translate(glm::vec3(-1, 0, 0)) *glm::scale(glm::vec3(0.2f)), glm::vec3(0.7f, 0.6f, 0.8f));
|
||||
//drawObjectTexture(programTex, sphereContext, glm::eulerAngleY(time / 2) * glm::translate(glm::vec3(-5, 0, 0)) * glm::eulerAngleXZ(0.7f, 0.5f) * glm::eulerAngleY(time * 2) * glm::translate(glm::vec3(-1, 0, 0)) * glm::scale(glm::vec3(0.2f)), texture::grid);
|
||||
|
||||
drawObject(programSun, sphereContext, glm::translate(lightPos), glm::vec3(1.0f, 0.8f, 0.2f));
|
||||
|
||||
|
@ -20,9 +20,10 @@ Core::RenderContext skyboxContext;
|
||||
Core::RenderContext seafloorContext;
|
||||
Core::RenderContext shipContext;
|
||||
Core::RenderContext sphereContext;
|
||||
Core::RenderContext firstFishContext;
|
||||
|
||||
glm::vec3 planetPositions[10];
|
||||
float planetSpreadFactor = 15.0;
|
||||
glm::vec3 firstFishPositions[15];
|
||||
float firstFishSpreadFactor = 15.0;
|
||||
|
||||
glm::vec2 previousMousePosition = glm::vec2(0, 0);
|
||||
glm::vec2 mousePositionDifference = glm::vec2(0, 0);
|
||||
@ -37,8 +38,8 @@ glm::vec3 lightDir = glm::normalize(glm::vec3(0.0f, -1.0f, 0.0f));
|
||||
|
||||
glm::quat rotation = glm::quat(1, 0, 0, 0);
|
||||
|
||||
GLuint textureAsteroid;
|
||||
GLuint textureSkybox;
|
||||
GLuint textureFirstFish;
|
||||
|
||||
void keyboard(unsigned char key, int x, int y)
|
||||
{
|
||||
@ -125,16 +126,16 @@ void renderScene()
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glClearColor(0.0f, 0.1f, 0.3f, 1.0f);
|
||||
|
||||
float time = glutGet(GLUT_ELAPSED_TIME) / 1000.f;
|
||||
|
||||
glm::mat4 shipInitialTransformation = glm::translate(glm::vec3(0,-0.25f,0)) * glm::rotate(glm::radians(180.0f), glm::vec3(0,1,0)) * glm::scale(glm::vec3(0.25f));
|
||||
glm::mat4 shipModelMatrix = glm::translate(cameraPos + cameraDir * 0.5f) * glm::mat4_cast(glm::inverse(rotation)) * shipInitialTransformation;
|
||||
drawObjectColor(shipContext, shipModelMatrix, glm::vec3(0.6f));
|
||||
drawObjectColor(seafloorContext, glm::translate(glm::vec3(0,-15,0)) * glm::scale(glm::vec3(5.0f, 1.0f, 5.0f)), glm::vec3(0.7098f, 0.7098f, 0.7098f));
|
||||
//drawObjectColor(skyboxContext, glm::translate(glm::vec3(0, -15, 0)) * glm::scale(glm::vec3(1.0f, 1.0f, 1.0f)), glm::vec3(0.7098f, 0.7098f, 0.7098f));
|
||||
|
||||
drawObjectTexture(sphereContext, glm::translate(glm::vec3(0,0,0)), textureAsteroid);
|
||||
drawObjectTexture(skyboxContext, glm::translate(glm::vec3(0, -15, 0)) * glm::scale(glm::vec3(1.0f, 1.0f, 1.0f)), textureSkybox);
|
||||
|
||||
for (int i = 0; i < 10; i++) drawObjectTexture(sphereContext, glm::translate(planetPositions[i]), textureAsteroid);
|
||||
for (int i = 0; i < 15; i++) drawObjectTexture(firstFishContext, glm::eulerAngleY(time / 2) * glm::translate(glm::vec3(-5, 0, 0)) * glm::translate(firstFishPositions[i]) * glm::scale(glm::vec3(0.6f)), textureFirstFish);
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
@ -159,12 +160,12 @@ void init()
|
||||
programColor = shaderLoader.CreateProgram("shaders/shader_color.vert", "shaders/shader_color.frag");
|
||||
programTexture = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
|
||||
loadModelToContext("models/ship.obj", shipContext);
|
||||
loadModelToContext("models/sphere.obj", sphereContext);
|
||||
loadModelToContext("models/seafloor.obj", seafloorContext);
|
||||
loadModelToContext("models/skybox.obj", skyboxContext);
|
||||
textureAsteroid = Core::LoadTexture("textures/asteroid.png");
|
||||
loadModelToContext("models/first_fish.obj", firstFishContext);
|
||||
textureSkybox = Core::LoadTexture("textures/skybox.png");
|
||||
for (int i = 0; i < 10; i++) planetPositions[i] = glm::ballRand(planetSpreadFactor);
|
||||
textureFirstFish = Core::LoadTexture("textures/first_fish.png");
|
||||
for (int i = 0; i < 15; i++) firstFishPositions[i] = glm::ballRand(firstFishSpreadFactor);
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
|
Loading…
Reference in New Issue
Block a user