add random values for rotation/size objects
This commit is contained in:
parent
03d3efd52e
commit
a0ac366237
@ -29,7 +29,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -107,6 +107,22 @@ void Core::Engine::generateObjectArray() {
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Engine::generateObjectSize() {
|
||||
std::uniform_real_distribution<> distr(0.1f, 0.25f);
|
||||
for (int i = 0; i < 200; i++) {
|
||||
float random = distr(this->gen);
|
||||
objectSize.push_back(random);
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Engine::generateObjectRotation() {
|
||||
std::uniform_real_distribution<> distr(0.0f, 360.0f);
|
||||
for (int i = 0; i < 200; i++) {
|
||||
float random = distr(this->gen);
|
||||
objectRotation.push_back(random);
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Engine::initBubbles() {
|
||||
this->generateBubbleArray();
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ namespace Core {
|
||||
GLuint skyboxVAO;
|
||||
Core::RenderContext submarineContext, fishContext, bubbleContext, terrainContext, plant1Context, plant2Context, plant3Context, coral1Context, rocktower1Context, archContext;
|
||||
std::vector<glm::vec3> bubbleArray[300];
|
||||
std::vector<float> objectSize;
|
||||
std::vector<float> objectRotation;
|
||||
glm::vec3 objectArray[200];
|
||||
void initShaderPrograms();
|
||||
void shutdownShaderPrograms();
|
||||
@ -27,6 +29,8 @@ namespace Core {
|
||||
void initSkybox();
|
||||
void initBubbles();
|
||||
void generateObjectArray();
|
||||
void generateObjectSize();
|
||||
void generateObjectRotation();
|
||||
Terrain terrain;
|
||||
void initRandomGenerator(std::default_random_engine gen, std::uniform_int_distribution<> distr);
|
||||
static const float skyboxVerticeParameter;
|
||||
|
@ -30,7 +30,7 @@ obj::Model Terrain::generateTerrain() {
|
||||
textureCoords[vertexPointer * 2 + 1] = float(i) / float(VERTEX_COUNT - 1) * 40;
|
||||
vertexPointer++;
|
||||
heightTable[j][i] = height;
|
||||
std::cout << heightTable[j][i] << std::endl;
|
||||
//std::cout << heightTable[j][i] << std::endl;
|
||||
}
|
||||
}
|
||||
int pointer = 0;
|
||||
|
@ -240,22 +240,27 @@ void renderScene()
|
||||
|
||||
|
||||
|
||||
for (int j = 0; j < 25; j++) {
|
||||
glm::mat4 objectTransformation = glm::translate(engine.objectArray[j]) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.3f));
|
||||
|
||||
drawObjectTexture(engine.plant1Context, objectTransformation, engine.plant1Texture, engine.textureShader, lightDir, cameraMatrix, perspectiveMatrix);
|
||||
|
||||
objectTransformation = glm::translate(engine.objectArray[25+j]) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.3f));
|
||||
drawObjectTexture(engine.plant2Context, objectTransformation, engine.plant2Texture, engine.textureShader, lightDir, cameraMatrix, perspectiveMatrix);
|
||||
|
||||
objectTransformation = glm::translate(engine.objectArray[50+j]) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.3f));
|
||||
drawObjectTexture(engine.plant3Context, objectTransformation, engine.plant3Texture, engine.textureShader, lightDir, cameraMatrix, perspectiveMatrix);
|
||||
|
||||
objectTransformation = glm::translate(engine.objectArray[75+j]) * glm::rotate(glm::radians(0.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.3f));
|
||||
drawObjectTexture(engine.coral1Context, objectTransformation, engine.coral1Texture, engine.textureShader, lightDir, cameraMatrix, perspectiveMatrix);
|
||||
|
||||
objectTransformation = glm::translate(engine.objectArray[100+j]) * glm::rotate(glm::radians(90.f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.3f));
|
||||
drawObjectTexture(engine.archContext, objectTransformation, engine.archTexture, engine.textureShader, lightDir, cameraMatrix, perspectiveMatrix);
|
||||
for (int j = 0; j < 100; j++) {
|
||||
glm::mat4 objectTransformation;
|
||||
if (j % 5 == 0) {
|
||||
objectTransformation = glm::translate(engine.objectArray[j]) * glm::rotate(glm::radians(engine.objectRotation[j]), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(engine.objectSize[j]));
|
||||
drawObjectTexture(engine.plant1Context, objectTransformation, engine.plant1Texture, engine.textureShader, lightDir, cameraMatrix, perspectiveMatrix);
|
||||
} else if (j % 5 == 1) {
|
||||
objectTransformation = glm::translate(engine.objectArray[25 + j]) * glm::rotate(glm::radians(engine.objectRotation[j]), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(engine.objectSize[j]));
|
||||
drawObjectTexture(engine.plant2Context, objectTransformation, engine.plant2Texture, engine.textureShader, lightDir, cameraMatrix, perspectiveMatrix);
|
||||
}
|
||||
else if (j % 5 == 2) {
|
||||
objectTransformation = glm::translate(engine.objectArray[50 + j]) * glm::rotate(glm::radians(engine.objectRotation[j]), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(engine.objectSize[j]));
|
||||
drawObjectTexture(engine.plant3Context, objectTransformation, engine.plant3Texture, engine.textureShader, lightDir, cameraMatrix, perspectiveMatrix);
|
||||
}
|
||||
else if (j % 5 == 3) {
|
||||
objectTransformation = glm::translate(engine.objectArray[75 + j]) * glm::rotate(glm::radians(engine.objectRotation[j]), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(engine.objectSize[j]));
|
||||
drawObjectTexture(engine.coral1Context, objectTransformation, engine.coral1Texture, engine.textureShader, lightDir, cameraMatrix, perspectiveMatrix);
|
||||
}
|
||||
else if (j % 5 == 4) {
|
||||
objectTransformation = glm::translate(engine.objectArray[100 + j]) * glm::rotate(glm::radians(engine.objectRotation[j]), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(engine.objectSize[j]));
|
||||
drawObjectTexture(engine.archContext, objectTransformation, engine.archTexture, engine.textureShader, lightDir, cameraMatrix, perspectiveMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@ -301,6 +306,8 @@ void init()
|
||||
engine.initSkybox();
|
||||
engine.initBubbles();
|
||||
engine.generateObjectArray();
|
||||
engine.generateObjectSize();
|
||||
engine.generateObjectRotation();
|
||||
initKeyRotation();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user