add more fish
This commit is contained in:
parent
44164da244
commit
1611666e96
49319
grafika_projekt/models/fangtooth.obj
Normal file
49319
grafika_projekt/models/fangtooth.obj
Normal file
File diff suppressed because it is too large
Load Diff
BIN
grafika_projekt/models/great white shark.max
Normal file
BIN
grafika_projekt/models/great white shark.max
Normal file
Binary file not shown.
11018
grafika_projekt/models/shark.obj
Normal file
11018
grafika_projekt/models/shark.obj
Normal file
File diff suppressed because it is too large
Load Diff
@ -37,6 +37,8 @@ void main()
|
||||
vec3 R = reflect(-normalize(lightDir),normal);
|
||||
float ambient = 0.2;
|
||||
float specular = pow(max(0,dot(R,V)),1000);
|
||||
gl_FragColor = vec4(color*(ambient + (1-ambient)*diffuse)+vec3(1)*specular*0.2, 1.0) * (1.0f - depth) + vec4(depth * vec3(0.0f, 0.109f, 0.447f), 1.0f);
|
||||
//gl_FragColor = vec4(color*(ambient + (1-ambient)*diffuse)+vec3(1)*specular*0.2, 1.0);
|
||||
//gl_FragColor = vec4(color*(ambient + (1-ambient)*diffuse)+vec3(1)*specular*0.2, 1.0) * (1.0f - depth) + vec4(depth * vec3(0.0f, 0.109f, 0.447f), 1.0f);
|
||||
|
||||
//Odkomentowac jak sie nie chce mgly i zakomentowac wyzej (patrz skybox.frag tez)
|
||||
gl_FragColor = vec4(color*(ambient + (1-ambient)*diffuse)+vec3(1)*specular*0.2, 1.0);
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ float logisticDepth(float depth, float steepness, float offset)
|
||||
void main()
|
||||
{
|
||||
float depth = logisticDepth(gl_FragCoord.z, 0.1f, 3.0f);
|
||||
FragColor = texture(skybox, TexCoords)* (1.0f - depth) + vec4(depth * vec3(0.0f, 0.109f, 0.447f), 1.0f);
|
||||
//FragColor = texture(skybox, TexCoords);
|
||||
//FragColor = texture(skybox, TexCoords)* (1.0f - depth) + vec4(depth * vec3(0.0f, 0.109f, 0.447f), 1.0f);
|
||||
|
||||
//Odkomentowac jak sie nie chce mgly i zakomentowac wyzej (patrz shader_tex.frag tez)
|
||||
FragColor = texture(skybox, TexCoords);
|
||||
}
|
@ -22,11 +22,14 @@ GLuint textureSubmarine;
|
||||
GLuint textureBubble;
|
||||
GLuint textureFloor;
|
||||
GLuint textureFish;
|
||||
GLuint textureShark;
|
||||
GLuint textureFangtooth;
|
||||
|
||||
unsigned int cubemapTexture, skyboxVAO;
|
||||
unsigned int cubeVAO, cubeVBO;
|
||||
|
||||
std::vector<glm::vec3> bubbleArray[300];
|
||||
|
||||
float old_x, old_y = -1;
|
||||
glm::vec3 cursorDiff;
|
||||
glm::vec3 lightDir = glm::normalize(glm::vec3(1.0f, -10.f, -1.0f));
|
||||
@ -45,27 +48,71 @@ Core::Shader_Loader shaderLoader;
|
||||
Core::RenderContext submarineContext;
|
||||
Core::RenderContext floorContext;
|
||||
Core::RenderContext fishContext;
|
||||
Core::RenderContext fangtoothContext;
|
||||
Core::RenderContext sharkContext;
|
||||
Core::RenderContext bubbleContext;
|
||||
|
||||
std::vector<glm::vec3> fishKeyPoints({
|
||||
glm::vec3(-18.0f, -10.0f, -10.0f),
|
||||
glm::vec3(-10.0f, -5.0f, -12.0f),
|
||||
glm::vec3(8.0f, -3.0f, -3.0f),
|
||||
glm::vec3(5.0f, 0.0f, 3.0f),
|
||||
glm::vec3(3.0f, 2.0f, 4.0f),
|
||||
glm::vec3(8.0f, 5.0f, 9.0f),
|
||||
glm::vec3(14.0f, 6.0f, 15.0f),
|
||||
glm::vec3(15.0f, 12.0f, 12.0f),
|
||||
glm::vec3(10.0f, 17.0f, 15.0f),
|
||||
glm::vec3(5.0f, 10.0f, 7.0f),
|
||||
glm::vec3(-1.0f, 4.0f, 8.0f),
|
||||
glm::vec3(-8.0f, 0.0f, 3.0f),
|
||||
glm::vec3(-12.0f, -6.0f, -3.0f),
|
||||
glm::vec3(-15.0f, -8.0f, -6.0f),
|
||||
glm::vec3(-18.0f, -10.0f, -10.0f),
|
||||
std::vector<glm::vec3> fishKeyPointsFirst({
|
||||
glm::vec3(0.0f, -130.0f, 0.0f),
|
||||
glm::vec3(50.0f, -130.0f, 25.0f),
|
||||
glm::vec3(75.0f, -130.0f, 75.0f),
|
||||
glm::vec3(40.0f, -130.0f, 100.0f),
|
||||
glm::vec3(-25.0f, -130.0f, 85.0f),
|
||||
glm::vec3(-60.0f, -130.0f, 75.0f),
|
||||
glm::vec3(-75.0f, -130.0f, 70.0f),
|
||||
glm::vec3(-100.0f, -130.0f, 35.0f),
|
||||
glm::vec3(-90.0f, -130.0f, 0.0f),
|
||||
glm::vec3(-105.0f, -130.0f, -50.0f),
|
||||
glm::vec3(-95.0f, -130.0f, -75.0f),
|
||||
glm::vec3(-115.0f, -130.0f, -100.0f),
|
||||
glm::vec3(-75.0f, -130.0f, -120.0f),
|
||||
glm::vec3(-70.0f, -130.0f, -135.0f),
|
||||
glm::vec3(-35.0f, -130.0f, -120.0f),
|
||||
glm::vec3(10.0f, -130.0f, -150.0f),
|
||||
glm::vec3(25.0f, -130.0f, -135.0f),
|
||||
glm::vec3(50.0f, -130.0f, -140.0f),
|
||||
glm::vec3(60.0f, -130.0f, -110.0f),
|
||||
glm::vec3(50.0f, -130.0f, -75.0f),
|
||||
glm::vec3(30.0f, -130.0f, -85.0f),
|
||||
glm::vec3(10.0f, -130.0f, -50.0f),
|
||||
glm::vec3(-40.0f, -130.0f, -65.0f),
|
||||
glm::vec3(-25.0f, -130.0f, -25.0f),
|
||||
glm::vec3(-15.0f, -130.0f, -10.0f),
|
||||
glm::vec3(0.0f, -130.0f, 0.0f),
|
||||
});
|
||||
std::vector<glm::quat> fishKeyRotationFirst;
|
||||
|
||||
std::vector<glm::vec3> fishKeyPointsSecond({
|
||||
glm::vec3(0.0f, 0.0f, 15.0f),
|
||||
glm::vec3(-20.0f, 10.0f, 10.0f),
|
||||
glm::vec3(-35.0f, 15.0f, 5.0f),
|
||||
glm::vec3(-55.0f, 0.0f, 5.0f),
|
||||
glm::vec3(-70.0f, 0.0f, 0.0f),
|
||||
glm::vec3(-70.0f, 0.0f, -10.0f),
|
||||
glm::vec3(-70.0f, 0.0f, -25.0f),
|
||||
glm::vec3(-85.0f, 0.0f, -35.0f),
|
||||
glm::vec3(-115.0f, 0.0f, -45.0f),
|
||||
glm::vec3(-135.0f, 0.0f, -25.0f),
|
||||
glm::vec3(-155.0f, 0.0f, -5.0f),
|
||||
glm::vec3(-175.0f, 0.0f, 0.0f)
|
||||
});
|
||||
std::vector<glm::quat> fishKeyRotationSecond;
|
||||
|
||||
std::vector<glm::vec3> sharkKeyPoints({
|
||||
glm::vec3(-300.0f, 100.0f, -300.0f),
|
||||
glm::vec3(-200.0f, 100.0f, -200.0f),
|
||||
glm::vec3(-100.0f, 100.0f, -100.0f),
|
||||
glm::vec3(0.0f, 100.0f, 0.0f),
|
||||
glm::vec3(100.0f, 100.0f, 100.0f),
|
||||
glm::vec3(200.0f, 100.0f, 200.0f),
|
||||
glm::vec3(300.0f, 100.0f, 300.0f),
|
||||
});
|
||||
std::vector<glm::quat> sharkKeyRotation;
|
||||
|
||||
|
||||
std::vector<glm::vec3> generatedFishKeyPoints[30];
|
||||
std::vector<glm::quat> generatedFishKeyRotation;
|
||||
|
||||
std::vector<glm::quat> keyRotation;
|
||||
|
||||
std::vector<Core::Node> fish;
|
||||
|
||||
@ -176,12 +223,16 @@ bool isInBoundaries(glm::vec3 nextPosition) {
|
||||
nextPosition.y < skyboxBoundary&& nextPosition.x < skyboxBoundary&& nextPosition.x > -skyboxBoundary;
|
||||
}
|
||||
|
||||
|
||||
//First gen
|
||||
std::random_device rd; // obtain a random number from hardware
|
||||
std::mt19937 gen(rd()); // seed the generator
|
||||
std::uniform_int_distribution<> distr(-skyboxVerticeParameter, skyboxVerticeParameter); // define the range
|
||||
|
||||
//Second gen
|
||||
std::uniform_int_distribution<> distribution(10, 10); // define the range
|
||||
|
||||
std::vector<glm::vec3> genBubbleKeyPoints() {
|
||||
|
||||
float random1 = distr(gen);
|
||||
float random2 = distr(gen);
|
||||
std::vector<glm::vec3> bubbleKeyPoints({
|
||||
@ -199,10 +250,34 @@ void generateBubbleArray() {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<glm::vec3> genFishKeyPoints() {
|
||||
std::vector<glm::vec3> fishKeyPoints2;
|
||||
for (int i = 0; i < fishKeyPointsFirst.size(); i++) {
|
||||
float random1 = distribution(gen);
|
||||
float random2 = distribution(gen);
|
||||
|
||||
glm::vec3 oldKeyPoint = fishKeyPointsFirst[i];
|
||||
fishKeyPoints2.push_back(glm::vec3(oldKeyPoint.x + random1, -100.f, oldKeyPoint.z + random2));
|
||||
}
|
||||
//while (fishKeyPoints2.size() <= 30) {
|
||||
// float random1 = distribution(gen);
|
||||
// float random2 = distribution(gen);
|
||||
// fishKeyPoints2.push_back(glm::vec3(random1, -100.0f, random2));
|
||||
// }
|
||||
return fishKeyPoints2;
|
||||
};
|
||||
|
||||
void generateFishArray() {
|
||||
|
||||
for (int i = 0; i < 30; i++) {
|
||||
generatedFishKeyPoints[i] = genFishKeyPoints();
|
||||
}
|
||||
}
|
||||
|
||||
void keyboard(unsigned char key, int x, int y)
|
||||
{
|
||||
float angleSpeed = 10.f;
|
||||
float moveSpeed = 1.0f;
|
||||
float moveSpeed = 10.0f;
|
||||
glm::vec3 nextPosition;
|
||||
switch (key)
|
||||
{
|
||||
@ -289,7 +364,7 @@ std::vector<glm::vec3> changeKeyPoints(std::vector<glm::vec3> keyPoints, glm::ve
|
||||
return result;
|
||||
}
|
||||
|
||||
glm::mat4 animationMatrix(float time, glm::vec3 change, std::vector<glm::vec3> keyPoints, glm::vec3 scaleValue, float speed) {
|
||||
glm::mat4 animationMatrix(float time, glm::vec3 change, std::vector<glm::vec3> keyPoints, std::vector<glm::quat> keyRotation, glm::vec3 scaleValue, float speed) {
|
||||
|
||||
time = time * speed;
|
||||
std::vector<float> distances;
|
||||
@ -372,28 +447,42 @@ void renderScene()
|
||||
glm::mat4 submarineModelMatrix = glm::translate(cameraPos + cameraDir) * glm::mat4_cast(glm::inverse(rotation)) * submarineInitialTransformation;
|
||||
|
||||
|
||||
glm::vec3 change1 = glm::vec3(0, 3, 0);
|
||||
glm::vec3 change2 = glm::vec3(0, 0, 0);
|
||||
glm::vec3 change3 = glm::vec3(3, 0, 0);
|
||||
glm::vec3 change4 = glm::vec3(0, 2, 1);
|
||||
glm::vec3 change1 = glm::vec3(0, 4, 0);
|
||||
glm::vec3 change2 = glm::vec3(-3, 0, 4);
|
||||
glm::vec3 change3 = glm::vec3(6, 0, 3);
|
||||
glm::vec3 change4 = glm::vec3(0, 2, -5);
|
||||
|
||||
glm::vec3 change0 = glm::vec3(0, 0, 0);
|
||||
|
||||
for (int j = 0; j < 100; j++) {
|
||||
drawObjectTexture(bubbleContext, animationMatrix(time + j, change0, bubbleArray[j], glm::vec3(0.04f), 0.1f), cubemapTexture, bubbleProgram);
|
||||
}
|
||||
//for (int j = 0; j < 100; j++) {
|
||||
// drawObjectTexture(bubbleContext, animationMatrix(time + j, change0, bubbleArray[j], glm::vec3(0.04f), 0.1f), cubemapTexture, bubbleProgram);
|
||||
//}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (time > -10) {
|
||||
drawObjectTexture(fishContext, animationMatrix(time + 15, change1, fishKeyPoints, glm::vec3(0.25f), 1.f), textureFish, programTexture);
|
||||
drawObjectTexture(fishContext, animationMatrix(time + 15, change2, fishKeyPoints, glm::vec3(0.25f), 1.f), textureFish, programTexture);
|
||||
drawObjectTexture(fishContext, animationMatrix(time + 15, change3, fishKeyPoints, glm::vec3(0.25f), 1.f), textureFish, programTexture);
|
||||
drawObjectTexture(fishContext, animationMatrix(time + 15, change4, fishKeyPoints, glm::vec3(0.25f), 1.f), textureFish, programTexture);
|
||||
|
||||
time -= 6;
|
||||
drawObjectTexture(fishContext, animationMatrix(time + 15, change1, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 1.f), textureFish, programTexture);
|
||||
drawObjectTexture(fishContext, animationMatrix(time + 15, change2, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 1.f), textureFish, programTexture);
|
||||
drawObjectTexture(fishContext, animationMatrix(time + 15, change3, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 1.f), textureFish, programTexture);
|
||||
drawObjectTexture(fishContext, animationMatrix(time + 15, change4, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 1.f), textureFish, programTexture);
|
||||
drawObjectTexture(fangtoothContext, animationMatrix(time + 15, change1, fishKeyPointsSecond, fishKeyRotationSecond, glm::vec3(0.25f), 1.f), textureFangtooth, programTexture);
|
||||
drawObjectTexture(sharkContext, animationMatrix(time + 15, change1, sharkKeyPoints, sharkKeyRotation, glm::vec3(10.8f), 1.f), textureShark, programTexture);
|
||||
time -= 5;
|
||||
}
|
||||
}
|
||||
//drawObjectTexture(bubbleContext, submarineInitialTransformation, cubemapTexture, bubbleProgram);
|
||||
|
||||
//for (int i = 0; i < 3; i++) {
|
||||
// if (time > -10) {
|
||||
//
|
||||
// time -= 9;
|
||||
// }
|
||||
//}
|
||||
if (time > -10) {
|
||||
|
||||
time -= 5;
|
||||
}
|
||||
|
||||
|
||||
//drawObjectTexture(bubbleContext, submarineInitialTransformation, textureBubble, bubbleProgram);
|
||||
drawObjectTexture(submarineContext, submarineModelMatrix, textureSubmarine, programTexture);
|
||||
drawObjectTexture(floorContext, floorTransformation, textureFloor, programTexture);
|
||||
glutSwapBuffers();
|
||||
@ -462,14 +551,14 @@ void initSkybox()
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
|
||||
}
|
||||
|
||||
void initKeyRotation() {
|
||||
void initKeyRotation(std::vector<glm::vec3>& keyPoints, std::vector<glm::quat>& keyRotation) {
|
||||
glm::vec3 oldDirection = glm::vec3(0, 0, 1);
|
||||
glm::quat oldRotationCamera = glm::quat(1, 0, 0, 0);
|
||||
glm::vec3 direction;
|
||||
glm::quat rotation;
|
||||
for (int i = 0; i < fishKeyPoints.size() - 1; i++) {
|
||||
for (int i = 0; i < keyPoints.size() - 1; i++) {
|
||||
//3.1
|
||||
direction = glm::normalize(fishKeyPoints[i + 1] - fishKeyPoints[i]);
|
||||
direction = glm::normalize(keyPoints[i + 1] - keyPoints[i]);
|
||||
//3.2
|
||||
rotation = glm::normalize(glm::rotationCamera(oldDirection, direction) * oldRotationCamera);
|
||||
//3.3
|
||||
@ -509,16 +598,29 @@ void init()
|
||||
loadModelToContext("models/fish.obj", fishContext);
|
||||
textureFish = Core::LoadTexture("textures/fish.png");
|
||||
|
||||
initKeyRotation();
|
||||
loadModelToContext("models/fangtooth.obj", fangtoothContext);
|
||||
textureFangtooth = Core::LoadTexture("textures/fangtooth.png");
|
||||
|
||||
loadModelToContext("models/shark.obj", sharkContext);
|
||||
textureShark = Core::LoadTexture("textures/shark.png");
|
||||
|
||||
loadModelToContext("models/submarine.obj", submarineContext);
|
||||
textureSubmarine = Core::LoadTexture("textures/submarine.png");
|
||||
|
||||
loadModelToContext("models/sphere.obj", bubbleContext);
|
||||
textureBubble = Core::LoadTexture("textures/bubble.png");
|
||||
|
||||
loadModelToContext("models/terrain.obj", floorContext);
|
||||
textureFloor = Core::LoadTexture("textures/sand.png");
|
||||
|
||||
|
||||
generateFishArray();
|
||||
generateBubbleArray();
|
||||
|
||||
initKeyRotation(fishKeyPointsFirst, fishKeyRotationFirst);
|
||||
initKeyRotation(fishKeyPointsSecond, fishKeyRotationSecond);
|
||||
initKeyRotation(sharkKeyPoints, sharkKeyRotation);
|
||||
|
||||
initCube();
|
||||
initSkybox();
|
||||
|
||||
|
BIN
grafika_projekt/textures/fangtooth.png
Normal file
BIN
grafika_projekt/textures/fangtooth.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 MiB |
BIN
grafika_projekt/textures/shark.png
Normal file
BIN
grafika_projekt/textures/shark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 611 KiB |
Loading…
Reference in New Issue
Block a user