add more plants
This commit is contained in:
parent
73db74da7a
commit
d8c487d3dd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\Users\Tomek\source\repos\Grafika\GrafikaProjekt\Debug\grk-cw6.exe</FullPath>
|
||||
<FullPath>C:\Users\luksli\Desktop\GrafikaProjekt\GrafikaProjekt\Debug\grk-cw6.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +1,2 @@
|
||||
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.30.30705:TargetPlatformVersion=10.0.19041.0:
|
||||
Debug|Win32|C:\Users\Tomek\source\repos\Grafika\GrafikaProjekt\|
|
||||
Debug|Win32|C:\Users\luksli\Desktop\GrafikaProjekt\GrafikaProjekt\|
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
main.cpp
|
||||
C:\Users\Tomek\source\repos\Grafika\GrafikaProjekt\pliki\src\main.cpp(302,12): warning C4244: "argument": konwersja z "time_t" do "unsigned int", możliwa utrata danych
|
||||
C:\Users\luksli\Desktop\GrafikaProjekt\GrafikaProjekt\pliki\src\main.cpp(329,12): warning C4244: "argument": konwersja z "time_t" do "unsigned int", możliwa utrata danych
|
||||
Camera.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”
|
||||
projekt.vcxproj -> C:\Users\Tomek\source\repos\Grafika\GrafikaProjekt\Debug\grk-cw6.exe
|
||||
projekt.vcxproj -> C:\Users\luksli\Desktop\GrafikaProjekt\GrafikaProjekt\Debug\grk-cw6.exe
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -19,6 +19,7 @@ GLuint programTexture;
|
||||
Core::Shader_Loader shaderLoader;
|
||||
int random[320];
|
||||
int random2[320];
|
||||
int randomRock[65];
|
||||
|
||||
Core::RenderContext shipContext;
|
||||
Core::RenderContext sphereContext;
|
||||
@ -113,7 +114,7 @@ void keyboard(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
float angleSpeed = 0.1f;
|
||||
float moveSpeed = 0.1f;
|
||||
float moveSpeed = 0.4f;
|
||||
switch(key)
|
||||
{
|
||||
case 'z': cameraAngle -= angleSpeed; break;
|
||||
@ -135,7 +136,7 @@ void mouse(int x, int y)
|
||||
|
||||
glm::mat4 createCameraMatrix()
|
||||
{
|
||||
rotation = glm::normalize(rotation * glm::angleAxis((float)(mouseX * 0.01), cameraUp) * glm::angleAxis((float)(mouseY * 0.01), cameraSide));
|
||||
rotation = glm::normalize(rotation * glm::angleAxis((float)(mouseX * 0.05), cameraUp) * glm::angleAxis((float)(mouseY * 0.05), cameraSide));
|
||||
mouseX = mouseY = 0;
|
||||
cameraDir = glm::inverse(rotation) * glm::vec3(0, 0, -1);
|
||||
cameraSide = glm::inverse(rotation) * glm::vec3(-1, 0, 0);
|
||||
@ -237,6 +238,50 @@ size_t split(const std::string& txt, std::vector<std::string>& strs, char ch)
|
||||
return strs.size();
|
||||
}
|
||||
|
||||
void createFlora()
|
||||
{
|
||||
std::ifstream MyReadFile("models/teren1.obj");
|
||||
std::string myText;
|
||||
std::vector<std::string> v;
|
||||
for (int i = 1; i < 320; i++)
|
||||
{
|
||||
for (int j = 0; j < random[i]; j++)
|
||||
{
|
||||
std::getline(MyReadFile, myText);
|
||||
if (j == 25)
|
||||
{
|
||||
split(myText, v, ' ');
|
||||
if (random[i] > 50)
|
||||
drawObjectTexture(plant1, glm::translate(glm::vec3(std::stof(v[1]), std::stof(v[2]) - 1.2, std::stof(v[3]))) * glm::rotate(glm::degrees((float)random2[i]), glm::vec3(0, 1, 0)), texturePlant1);
|
||||
else
|
||||
drawObjectTexture(grass, glm::translate(glm::vec3(std::stof(v[1]), std::stof(v[2]) - 1.15, std::stof(v[3]))) * glm::rotate(glm::degrees((float)random2[i]), glm::vec3(0, 1, 0)), texturePlant3);
|
||||
}
|
||||
}
|
||||
split(myText, v, ' ');
|
||||
if (random[i] > 50)
|
||||
drawObjectTexture(plant3, glm::translate(glm::vec3(std::stof(v[1]), std::stof(v[2]) - 0.9, std::stof(v[3]))) * glm::rotate(glm::degrees((float)random2[i]), glm::vec3(0, 1, 0)), texturePlant3);
|
||||
else
|
||||
drawObjectTexture(plant4, glm::translate(glm::vec3(std::stof(v[1]), std::stof(v[2]) - 1.2, std::stof(v[3]))) * glm::rotate(glm::degrees((float)random2[i]), glm::vec3(0, 1, 0)), texturePlant4);
|
||||
}
|
||||
}
|
||||
|
||||
void createRockFlora()
|
||||
{
|
||||
std::ifstream MyReadFile("models/cave.obj");
|
||||
std::string myText;
|
||||
std::vector<std::string> v;
|
||||
for (int i = 0; i < 65; i++)
|
||||
{
|
||||
for (int i = 0; i < randomRock[i]; i++)
|
||||
std::getline(MyReadFile, myText);
|
||||
split(myText, v, ' ');
|
||||
if (randomRock[i] > 34)
|
||||
drawObjectTexture(plant5, glm::translate(glm::vec3(std::stof(v[1]), std::stof(v[2]) - 0.6, std::stof(v[3]))) * glm::rotate(glm::degrees((float)random2[i * 3]), glm::vec3(0, 1, 0)), texturePlant5);
|
||||
else
|
||||
drawObjectTexture(plant4, glm::translate(glm::vec3(std::stof(v[1]), std::stof(v[2]) - 0.6, std::stof(v[3]))) * glm::rotate(glm::degrees((float)random2[i*3]), glm::vec3(0, 1, 0)), texturePlant4);
|
||||
}
|
||||
}
|
||||
|
||||
void renderScene()
|
||||
{
|
||||
// Aktualizacja macierzy widoku i rzutowania
|
||||
@ -256,30 +301,12 @@ void renderScene()
|
||||
drawObjectTexture(sphereContext, glm::translate(glm::vec3(0, -1.2, 0)), textureAsteroid);
|
||||
drawObjectTexture(fish1Context, glm::translate(glm::vec3(0, 0, 0)), textureFish1);
|
||||
rypa = (rypa + 1) % 360;
|
||||
drawObjectTexture(fish2Context, glm::translate(glm::vec3(0.25f, 0, (float)rypa/(float)360)) * glm::rotate(glm::degrees((float)rypa / (float)360), glm::vec3(0, 1, 0)), textureFish2);
|
||||
drawObjectTexture(fish2Context, glm::rotate(glm::degrees((float)rypa / (float)360), glm::vec3(0, -1, 0)) * glm::translate(glm::vec3(0.5, 0, (float)rypa/(float)360)), textureFish2);
|
||||
drawObjectTexture(smiglo, shipModelMatrix * glm::translate(glm::vec3(0, -0.3, -1)) * glm::rotate(glm::degrees((float)rypa), glm::vec3(0, 0, 1)), textureSmiglo);
|
||||
drawObjectTexture(grass, glm::translate(glm::vec3(0, 1, 0)), texturePlant3);
|
||||
drawObjectTexture(plant4, glm::translate(glm::vec3(0, 1, 0)), texturePlant4);
|
||||
drawObjectTexture(plant5, glm::translate(glm::vec3(0, 1, 0)), texturePlant5);
|
||||
drawObjectTexture(cave, glm::translate(glm::vec3(0, -0.4, 0)), textureAsteroid);
|
||||
drawObjectTexture(cave, glm::translate(glm::vec3(0, -0.6, 0)), textureAsteroid);
|
||||
|
||||
std::ifstream MyReadFile("models/teren1.obj");
|
||||
std::string myText;
|
||||
std::vector<std::string> v;
|
||||
for (int i = 1; i < 320; i++)
|
||||
{
|
||||
for (int j = 0; j < random[i]; j++)
|
||||
{
|
||||
std::getline(MyReadFile, myText);
|
||||
if (j == 25)
|
||||
{
|
||||
split(myText, v, ' ');
|
||||
drawObjectTexture(plant1, glm::translate(glm::vec3(std::stof(v[1]), std::stof(v[2]) - 1.25, std::stof(v[3]))) * glm::rotate(glm::degrees((float)random2[i]), glm::vec3(0, 1, 0)), texturePlant1);
|
||||
}
|
||||
}
|
||||
split(myText, v, ' ');
|
||||
drawObjectTexture(plant3, glm::translate(glm::vec3(std::stof(v[1]), std::stof(v[2]) - 0.9, std::stof(v[3]))), texturePlant3);
|
||||
}
|
||||
createFlora();
|
||||
createRockFlora();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
@ -305,6 +332,10 @@ void init()
|
||||
random[i] = rand() % 50 + 25;
|
||||
random2[i] = rand() % 361 + 1;
|
||||
}
|
||||
for (int i = 0; i < 65; i++)
|
||||
{
|
||||
randomRock[i] = rand() % 20 + 30;
|
||||
}
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
programCubemap = shaderLoader.CreateProgram("shaders/shader_cubemap.vert", "shaders/shader_cubemap.frag");
|
||||
programTexture = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
|
||||
@ -355,7 +386,7 @@ int main(int argc, char ** argv)
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
|
||||
glutInitWindowPosition(200, 200);
|
||||
glutInitWindowPosition(200, 0);
|
||||
glutInitWindowSize(600, 600);
|
||||
glutCreateWindow("OpenGL Pierwszy Program");
|
||||
glewInit();
|
||||
|
Loading…
Reference in New Issue
Block a user