procedural
This commit is contained in:
parent
ac7077596e
commit
ac8089fff2
.vs/grk-cw/v17
.suoBrowse.VC.db
ipch/AutoPCH
2b33fed261f86991
3656a2292527ba01
4028e47cf6717348
63b3e7b650ed6b52
9030eb371a83063a
c50b74404c0f13
cfade4832bf6ae6c
Debug
Release
cw 2
Debug
Release
Camera.objParticleEmitter.objPhysics.objRender_Utils.objSOIL.objShader_Loader.objTexture.objgrk-cw2.exe.recipegrk-cw2.iobjgrk-cw2.ipdbgrk-cw2.log
grk-cw2.tlog
CL.command.1.tlogCL.read.1.tlogCL.write.1.tloggrk-cw2.lastbuildstatelink.command.1.tloglink.read.1.tloglink.write.1.tlog
image_DXT.objimage_helper.objmain_2_1a.objstb_image_aug.objvc143.pdbmodels
editObj.pygenerateTerrain.pygeneratedTerrain.objground2.objground2E.objgroundTest.objnoise.pngterrain.objtestingIn.obj
src
textures
Binary file not shown.
Binary file not shown.
BIN
.vs/grk-cw/v17/ipch/AutoPCH/2b33fed261f86991/RENDER_UTILS.ipch
Normal file
BIN
.vs/grk-cw/v17/ipch/AutoPCH/2b33fed261f86991/RENDER_UTILS.ipch
Normal file
Binary file not shown.
BIN
.vs/grk-cw/v17/ipch/AutoPCH/3656a2292527ba01/PHYSICS.ipch
Normal file
BIN
.vs/grk-cw/v17/ipch/AutoPCH/3656a2292527ba01/PHYSICS.ipch
Normal file
Binary file not shown.
BIN
.vs/grk-cw/v17/ipch/AutoPCH/4028e47cf6717348/IMAGE_HELPER.ipch
Normal file
BIN
.vs/grk-cw/v17/ipch/AutoPCH/4028e47cf6717348/IMAGE_HELPER.ipch
Normal file
Binary file not shown.
BIN
.vs/grk-cw/v17/ipch/AutoPCH/63b3e7b650ed6b52/IMAGE_DXT.ipch
Normal file
BIN
.vs/grk-cw/v17/ipch/AutoPCH/63b3e7b650ed6b52/IMAGE_DXT.ipch
Normal file
Binary file not shown.
Binary file not shown.
BIN
.vs/grk-cw/v17/ipch/AutoPCH/c50b74404c0f13/PARTICLEEMITTER.ipch
Normal file
BIN
.vs/grk-cw/v17/ipch/AutoPCH/c50b74404c0f13/PARTICLEEMITTER.ipch
Normal file
Binary file not shown.
BIN
.vs/grk-cw/v17/ipch/AutoPCH/cfade4832bf6ae6c/MAIN_2_1A.ipch
Normal file
BIN
.vs/grk-cw/v17/ipch/AutoPCH/cfade4832bf6ae6c/MAIN_2_1A.ipch
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Release/grk-cw2.exe
Normal file
BIN
Release/grk-cw2.exe
Normal file
Binary file not shown.
BIN
Release/grk-cw2.pdb
Normal file
BIN
Release/grk-cw2.pdb
Normal file
Binary file not shown.
@ -1 +1,12 @@
|
||||
grk-cw2.vcxproj -> G:\studia\grafika komputerowa\ggit\Debug\grk-cw2.exe
|
||||
main_2_1a.cpp
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(113,23): warning C4305: 'initializing': truncation from 'double' to 'float'
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(170,23): warning C4018: '<': signed/unsigned mismatch
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(252,22): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(253,22): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(545,69): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(669,15): warning C4244: 'argument': conversion from 'time_t' to 'unsigned int', possible loss of data
|
||||
Camera.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
|
||||
PhysXExtensions_static_32.lib(ExtCpuWorkerThread.obj) : warning LNK4099: PDB 'PhysXExtensions_static_32.pdb' was not found with 'PhysXExtensions_static_32.lib(ExtCpuWorkerThread.obj)' or at 'G:\studia\grafika komputerowa\ggit\Debug\PhysXExtensions_static_32.pdb'; linking object as if no debug info
|
||||
PhysXExtensions_static_32.lib(ExtDefaultCpuDispatcher.obj) : warning LNK4099: PDB 'PhysXExtensions_static_32.pdb' was not found with 'PhysXExtensions_static_32.lib(ExtDefaultCpuDispatcher.obj)' or at 'G:\studia\grafika komputerowa\ggit\Debug\PhysXExtensions_static_32.pdb'; linking object as if no debug info
|
||||
PhysXExtensions_static_32.lib(ExtDefaultErrorCallback.obj) : warning LNK4099: PDB 'PhysXExtensions_static_32.pdb' was not found with 'PhysXExtensions_static_32.lib(ExtDefaultErrorCallback.obj)' or at 'G:\studia\grafika komputerowa\ggit\Debug\PhysXExtensions_static_32.pdb'; linking object as if no debug info
|
||||
grk-cw2.vcxproj -> G:\studia\grafika komputerowa\ggit\Debug\grk-cw2.exe
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
cw 2/Release/Camera.obj
Normal file
BIN
cw 2/Release/Camera.obj
Normal file
Binary file not shown.
BIN
cw 2/Release/ParticleEmitter.obj
Normal file
BIN
cw 2/Release/ParticleEmitter.obj
Normal file
Binary file not shown.
BIN
cw 2/Release/Physics.obj
Normal file
BIN
cw 2/Release/Physics.obj
Normal file
Binary file not shown.
BIN
cw 2/Release/Render_Utils.obj
Normal file
BIN
cw 2/Release/Render_Utils.obj
Normal file
Binary file not shown.
BIN
cw 2/Release/SOIL.obj
Normal file
BIN
cw 2/Release/SOIL.obj
Normal file
Binary file not shown.
BIN
cw 2/Release/Shader_Loader.obj
Normal file
BIN
cw 2/Release/Shader_Loader.obj
Normal file
Binary file not shown.
BIN
cw 2/Release/Texture.obj
Normal file
BIN
cw 2/Release/Texture.obj
Normal file
Binary file not shown.
11
cw 2/Release/grk-cw2.exe.recipe
Normal file
11
cw 2/Release/grk-cw2.exe.recipe
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>G:\studia\grafika komputerowa\ggit\Release\grk-cw2.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
<SatelliteDlls />
|
||||
<NonRecipeFileRefs />
|
||||
</Project>
|
BIN
cw 2/Release/grk-cw2.iobj
Normal file
BIN
cw 2/Release/grk-cw2.iobj
Normal file
Binary file not shown.
BIN
cw 2/Release/grk-cw2.ipdb
Normal file
BIN
cw 2/Release/grk-cw2.ipdb
Normal file
Binary file not shown.
20
cw 2/Release/grk-cw2.log
Normal file
20
cw 2/Release/grk-cw2.log
Normal file
@ -0,0 +1,20 @@
|
||||
main_2_1a.cpp
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(88,19): warning C4244: 'initializing': conversion from 'double' to 'int', possible loss of data
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(90,19): warning C4244: 'initializing': conversion from 'double' to 'int', possible loss of data
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(191,23): warning C4305: 'initializing': truncation from 'double' to 'float'
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(246,23): warning C4018: '<': signed/unsigned mismatch
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(328,22): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(329,22): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(449,34): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(490,58): warning C4305: 'initializing': truncation from 'double' to 'float'
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(707,69): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
G:\studia\grafika komputerowa\ggit\cw 2\src\main_2_1a.cpp(831,15): warning C4244: 'argument': conversion from 'time_t' to 'unsigned int', possible loss of data
|
||||
Generating code
|
||||
1 of 1874 functions (<0.1%) were compiled, the rest were copied from previous compilation.
|
||||
0 functions were new in current compilation
|
||||
6 functions had inline decision re-evaluated but remain unchanged
|
||||
Finished generating code
|
||||
PhysXExtensions_static_32.lib(ExtCpuWorkerThread.obj) : warning LNK4099: PDB '' was not found with 'PhysXExtensions_static_32.lib(ExtCpuWorkerThread.obj)' or at ''; linking object as if no debug info
|
||||
PhysXExtensions_static_32.lib(ExtDefaultCpuDispatcher.obj) : warning LNK4099: PDB 'PhysXExtensions_static_32.pdb' was not found with 'PhysXExtensions_static_32.lib(ExtDefaultCpuDispatcher.obj)' or at 'G:\studia\grafika komputerowa\ggit\Release\PhysXExtensions_static_32.pdb'; linking object as if no debug info
|
||||
PhysXExtensions_static_32.lib(ExtDefaultErrorCallback.obj) : warning LNK4099: PDB 'PhysXExtensions_static_32.pdb' was not found with 'PhysXExtensions_static_32.lib(ExtDefaultErrorCallback.obj)' or at 'G:\studia\grafika komputerowa\ggit\Release\PhysXExtensions_static_32.pdb'; linking object as if no debug info
|
||||
grk-cw2.vcxproj -> G:\studia\grafika komputerowa\ggit\Release\grk-cw2.exe
|
BIN
cw 2/Release/grk-cw2.tlog/CL.command.1.tlog
Normal file
BIN
cw 2/Release/grk-cw2.tlog/CL.command.1.tlog
Normal file
Binary file not shown.
BIN
cw 2/Release/grk-cw2.tlog/CL.read.1.tlog
Normal file
BIN
cw 2/Release/grk-cw2.tlog/CL.read.1.tlog
Normal file
Binary file not shown.
BIN
cw 2/Release/grk-cw2.tlog/CL.write.1.tlog
Normal file
BIN
cw 2/Release/grk-cw2.tlog/CL.write.1.tlog
Normal file
Binary file not shown.
2
cw 2/Release/grk-cw2.tlog/grk-cw2.lastbuildstate
Normal file
2
cw 2/Release/grk-cw2.tlog/grk-cw2.lastbuildstate
Normal file
@ -0,0 +1,2 @@
|
||||
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.31.31103:TargetPlatformVersion=10.0.19041.0:
|
||||
Release|Win32|G:\studia\grafika komputerowa\ggit\|
|
BIN
cw 2/Release/grk-cw2.tlog/link.command.1.tlog
Normal file
BIN
cw 2/Release/grk-cw2.tlog/link.command.1.tlog
Normal file
Binary file not shown.
BIN
cw 2/Release/grk-cw2.tlog/link.read.1.tlog
Normal file
BIN
cw 2/Release/grk-cw2.tlog/link.read.1.tlog
Normal file
Binary file not shown.
BIN
cw 2/Release/grk-cw2.tlog/link.write.1.tlog
Normal file
BIN
cw 2/Release/grk-cw2.tlog/link.write.1.tlog
Normal file
Binary file not shown.
BIN
cw 2/Release/image_DXT.obj
Normal file
BIN
cw 2/Release/image_DXT.obj
Normal file
Binary file not shown.
BIN
cw 2/Release/image_helper.obj
Normal file
BIN
cw 2/Release/image_helper.obj
Normal file
Binary file not shown.
BIN
cw 2/Release/main_2_1a.obj
Normal file
BIN
cw 2/Release/main_2_1a.obj
Normal file
Binary file not shown.
BIN
cw 2/Release/stb_image_aug.obj
Normal file
BIN
cw 2/Release/stb_image_aug.obj
Normal file
Binary file not shown.
BIN
cw 2/Release/vc143.pdb
Normal file
BIN
cw 2/Release/vc143.pdb
Normal file
Binary file not shown.
22
cw 2/models/editObj.py
Normal file
22
cw 2/models/editObj.py
Normal file
@ -0,0 +1,22 @@
|
||||
with open("ground2.obj", 'r') as f:
|
||||
with open("ground2E.obj", 'w') as f2:
|
||||
c1 = 0
|
||||
c2 = 0
|
||||
c3 = 0
|
||||
for line in f.readlines():
|
||||
l = line.split()
|
||||
if l[0] == 'v':
|
||||
c1 += 1
|
||||
l[2] = "0.0"
|
||||
if l[0] == 'vt':
|
||||
c2 += 1
|
||||
l[1] = '1.00000'
|
||||
l[2] = '0.50000'
|
||||
if l[0] == "vn":
|
||||
c3 +=1
|
||||
l[1] = "1.0"
|
||||
l[2] = "1.0"
|
||||
l[3] = "1.0"
|
||||
l = " ".join(l)
|
||||
f2.write(l + "\n")
|
||||
print(c1, c2, c3)
|
44
cw 2/models/generateTerrain.py
Normal file
44
cw 2/models/generateTerrain.py
Normal file
@ -0,0 +1,44 @@
|
||||
import random
|
||||
import numpy
|
||||
import cv2
|
||||
|
||||
img_path = "noise.png"
|
||||
img = cv2.imread(img_path, 0)
|
||||
|
||||
|
||||
with open("generatedTerrain.obj", 'w') as f:
|
||||
increment = 450/110
|
||||
for i in range(111):
|
||||
for j in range(111):
|
||||
height = (img[i][j] - 50)/3
|
||||
line = "v " + str(-250 + i * increment) + " " + str(height) + " " + str(-250 + j * increment)
|
||||
f.write(line + "\n")
|
||||
incrementTx = 1/110
|
||||
for i in range(111):
|
||||
for j in range(111):
|
||||
line = "vt " + str(0 + i * incrementTx) + " " + str(0 + j * incrementTx) + "\n"
|
||||
f.write(line)
|
||||
#f.write("vt 0.0 0.0\nvt 1.0 1.0\nvt 0.0 1.0\nvt 1.0 1.0\n")
|
||||
f.write("s off\n")
|
||||
f.write("vn 1.0 1.0 1.0\nvn 1.0 1.0 0.0\n\
|
||||
vn 1.0 1.0 -1.0\nvn 0.0 1.0 1.0\nvn 0.0 1.0 0.0\nvn 0.0 1.0 -1.0\n")
|
||||
textureIdx = 0
|
||||
normalIdx = 0
|
||||
for i in range(111*110):
|
||||
j = i + 1
|
||||
if (j) % 111 == 0:
|
||||
pass
|
||||
else:
|
||||
lineA = "f " + str(j) + "/" + str(j) + "/" + str((normalIdx % 6) + 1) + " "
|
||||
textureIdx += 1
|
||||
lineB = str(j + 1) + "/" + str(j + 1) + "/" + str((normalIdx % 6) + 1) + " "
|
||||
textureIdx += 1
|
||||
lineC = str(j + 1 + 111) + "/" + str(j + 1 + 111) + "/" + str((normalIdx % 6) + 1) + " "
|
||||
textureIdx += 1
|
||||
lineD = str(j + 111) + "/" + str(j + 111) + "/" + str((normalIdx % 6) + 1) + "\n"
|
||||
textureIdx += 2
|
||||
normalIdx += 1
|
||||
line = lineA + lineB + lineC + lineD
|
||||
# print(line)
|
||||
f.write(line)
|
||||
# print(lineA, lineB, lineC, lineD)
|
36749
cw 2/models/generatedTerrain.obj
Normal file
36749
cw 2/models/generatedTerrain.obj
Normal file
File diff suppressed because it is too large
Load Diff
7858
cw 2/models/ground2.obj
Normal file
7858
cw 2/models/ground2.obj
Normal file
File diff suppressed because it is too large
Load Diff
7858
cw 2/models/ground2E.obj
Normal file
7858
cw 2/models/ground2E.obj
Normal file
File diff suppressed because it is too large
Load Diff
27
cw 2/models/groundTest.obj
Normal file
27
cw 2/models/groundTest.obj
Normal file
@ -0,0 +1,27 @@
|
||||
# Blender v3.0.0 OBJ File: 'untitled.blend'
|
||||
# www.blender.org
|
||||
o Plane_Plane.001
|
||||
v -180.0 50.0 -180.0
|
||||
v -180.0 0.0 0.0
|
||||
v -180.0 0.0 180.0
|
||||
v 0.0 0.0 -180.0
|
||||
v 0.0 00.0 0.0
|
||||
v 0.0 0.0 180.0
|
||||
v 180.0 0.0 -180.0
|
||||
v 180.0 0.0 0.0
|
||||
v 180.0 0.0 180.0
|
||||
vt 0.0 0.0
|
||||
vt 1.0 0.0
|
||||
vt 0.0 1.0
|
||||
vt 1.0 1.0
|
||||
vn 1.0 1.0 1.0
|
||||
vn 1.0 1.0 0.0
|
||||
vn 1.0 1.0 -1.0
|
||||
vn 0.0 1.0 1.0
|
||||
vn 0.0 1.0 0.0
|
||||
vn 0.0 1.0 -1.0
|
||||
s off
|
||||
f 1/1/1 2/2/1 5/3/1 4/4/1
|
||||
f 2/2/2 3/3/2 6/4/2 5/1/2
|
||||
f 4/3/3 5/4/3 8/1/3 7/2/3
|
||||
f 5/4/4 6/1/4 9/2/4 8/3/4
|
BIN
cw 2/models/noise.png
Normal file
BIN
cw 2/models/noise.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 47 KiB |
984320
cw 2/models/terrain.obj
Normal file
984320
cw 2/models/terrain.obj
Normal file
File diff suppressed because it is too large
Load Diff
49064
cw 2/models/testingIn.obj
Normal file
49064
cw 2/models/testingIn.obj
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,9 @@
|
||||
#include <cstdlib>
|
||||
#include <chrono>
|
||||
#include <time.h>
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Shader_Loader.h"
|
||||
#include "Render_Utils.h"
|
||||
@ -15,6 +18,10 @@
|
||||
#include "Texture.h"
|
||||
#include "SOIL/stb_image_aug.h"
|
||||
#include "ParticleEmitter.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
#define SIZE 1.0f
|
||||
@ -24,16 +31,87 @@
|
||||
#define PLANT1_NUM 100
|
||||
#define FISH_NUM 100
|
||||
#define PARTICLE_NUM 300
|
||||
#define GROUND_XY 168
|
||||
#define GROUND_XY 250
|
||||
#define GROUND_SQUARESXY 111
|
||||
#define GEYSER_NUM 3
|
||||
#define numOctaves 5
|
||||
#define maxPrimeIndex 10
|
||||
|
||||
double persistence = 1.0;
|
||||
auto radians = 0.01f;
|
||||
|
||||
|
||||
Core::Shader_Loader shaderLoader;
|
||||
GLuint programColor;
|
||||
GLuint programTexture;
|
||||
GLuint programSkyBox;
|
||||
|
||||
int primeIndex = 0;
|
||||
|
||||
int primes[maxPrimeIndex][3] = {
|
||||
{ 995615039, 600173719, 701464987 },
|
||||
{ 831731269, 162318869, 136250887 },
|
||||
{ 174329291, 946737083, 245679977 },
|
||||
{ 362489573, 795918041, 350777237 },
|
||||
{ 457025711, 880830799, 909678923 },
|
||||
{ 787070341, 177340217, 593320781 },
|
||||
{ 405493717, 291031019, 391950901 },
|
||||
{ 458904767, 676625681, 424452397 },
|
||||
{ 531736441, 939683957, 810651871 },
|
||||
{ 997169939, 842027887, 423882827 }
|
||||
};
|
||||
|
||||
double Noise(int i, int x, int y) {
|
||||
int n = x + y * 57;
|
||||
n = (n << 13) ^ n;
|
||||
int a = primes[i][0], b = primes[i][1], c = primes[i][2];
|
||||
int t = (n * (n * n * a + b) + c) & 0x7fffffff;
|
||||
return 1.0 - (double)(t) / 1073741824.0;
|
||||
}
|
||||
|
||||
double SmoothedNoise(int i, int x, int y) {
|
||||
double corners = (Noise(i, x - 1, y - 1) + Noise(i, x + 1, y - 1) +
|
||||
Noise(i, x - 1, y + 1) + Noise(i, x + 1, y + 1)) / 16,
|
||||
sides = (Noise(i, x - 1, y) + Noise(i, x + 1, y) + Noise(i, x, y - 1) +
|
||||
Noise(i, x, y + 1)) / 8,
|
||||
center = Noise(i, x, y) / 4;
|
||||
return corners + sides + center;
|
||||
}
|
||||
|
||||
double Interpolate(double a, double b, double x) { // cosine interpolation
|
||||
double ft = x * 3.1415927,
|
||||
f = (1 - cos(ft)) * 0.5;
|
||||
return a * (1 - f) + b * f;
|
||||
}
|
||||
|
||||
double InterpolatedNoise(int i, double x, double y) {
|
||||
int integer_X = x;
|
||||
double fractional_X = x - integer_X;
|
||||
int integer_Y = y;
|
||||
double fractional_Y = y - integer_Y;
|
||||
|
||||
double v1 = SmoothedNoise(i, integer_X, integer_Y),
|
||||
v2 = SmoothedNoise(i, integer_X + 1, integer_Y),
|
||||
v3 = SmoothedNoise(i, integer_X, integer_Y + 1),
|
||||
v4 = SmoothedNoise(i, integer_X + 1, integer_Y + 1),
|
||||
i1 = Interpolate(v1, v2, fractional_X),
|
||||
i2 = Interpolate(v3, v4, fractional_X);
|
||||
return Interpolate(i1, i2, fractional_Y);
|
||||
}
|
||||
|
||||
double ValueNoise_2D(double x, double y) {
|
||||
double total = 0,
|
||||
frequency = pow(2, numOctaves),
|
||||
amplitude = 1;
|
||||
for (int i = 0; i < numOctaves; ++i) {
|
||||
frequency /= 2;
|
||||
amplitude *= persistence;
|
||||
total += InterpolatedNoise((primeIndex + i) % maxPrimeIndex,
|
||||
x / frequency, y / frequency) * amplitude;
|
||||
}
|
||||
return total / frequency;
|
||||
}
|
||||
|
||||
auto radians = 0.01f;
|
||||
|
||||
struct fish
|
||||
{
|
||||
@ -129,6 +207,8 @@ std::vector<std::vector<particle>> particleList;
|
||||
std::vector<glm::vec3> geyserList;
|
||||
ParticleEmitter* ParticlesEmitter;
|
||||
|
||||
|
||||
|
||||
void setUpUniformsParticles(glm::mat4 transformation)
|
||||
{
|
||||
GLuint program = programParticle;
|
||||
@ -155,10 +235,6 @@ void drawParticle(glm::mat4 transformation)
|
||||
}
|
||||
|
||||
|
||||
void initGround() {
|
||||
|
||||
}
|
||||
|
||||
glm::vec3 search_for_y(float objX, float objZ, obj::Model model)
|
||||
{
|
||||
float y = 0;
|
||||
@ -359,6 +435,92 @@ void initSeaweed() {
|
||||
}
|
||||
|
||||
}
|
||||
void initGround() {
|
||||
ofstream groundFile("models/testingIn.obj");
|
||||
|
||||
float positionsX[GROUND_SQUARESXY][GROUND_SQUARESXY];
|
||||
float positionsY[GROUND_SQUARESXY][GROUND_SQUARESXY];
|
||||
float height[GROUND_SQUARESXY][GROUND_SQUARESXY];
|
||||
float normals[GROUND_SQUARESXY][GROUND_SQUARESXY][3];
|
||||
|
||||
for (int y = 0; y < GROUND_SQUARESXY; ++y) {
|
||||
for (int x = 0; x < GROUND_SQUARESXY; ++x) {
|
||||
double noise = ValueNoise_2D(x, y);
|
||||
height[y][x] = noise * 10;
|
||||
}
|
||||
}
|
||||
|
||||
float off[3] = { 1.0, 1.0, 0.0 };
|
||||
float hL, hR, hD, hU;
|
||||
glm::vec3 N;
|
||||
|
||||
for (int y = 0; y < GROUND_SQUARESXY; ++y) {
|
||||
for (int x = 0; x < GROUND_SQUARESXY; ++x) {
|
||||
if (y == 0 || y == GROUND_SQUARESXY - 1 || x == 0 || x == GROUND_SQUARESXY - 1)
|
||||
{
|
||||
normals[y][x][0] = 0.0;
|
||||
normals[y][x][1] = 0.0;
|
||||
normals[y][x][2] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
hL = height[y][x - 1];
|
||||
hR = height[y][x + 1];
|
||||
hD = height[y - 1][x];
|
||||
hU = height[y + 1][x];
|
||||
N.x = hL - hR;
|
||||
N.y = hD - hU;
|
||||
N.z = 2.0;
|
||||
N = glm::normalize(N);
|
||||
normals[y][x][0] = N.x;
|
||||
normals[y][x][1] = N.y;
|
||||
normals[y][x][2] = N.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float increment = float(2 * GROUND_XY) / GROUND_SQUARESXY;
|
||||
for (int i = 0; i < GROUND_SQUARESXY; i++) {
|
||||
for (int j = 0; j < GROUND_SQUARESXY; j++) {
|
||||
groundFile << "v " + to_string(float(-GROUND_XY) + float(i) * increment) + " " + to_string(height[i][j]) + " " + to_string(float(-GROUND_XY) + float(j) * increment) + "\n";
|
||||
positionsX[i][j] = float(-GROUND_XY) + float(i) * increment;
|
||||
positionsY[i][j] = float(-GROUND_XY) + float(j) * increment;
|
||||
}
|
||||
}
|
||||
float incrementTexture = 1.0 / (GROUND_SQUARESXY - 1);
|
||||
for (int i = 0; i < GROUND_SQUARESXY; i++) {
|
||||
for (int j = 0; j < GROUND_SQUARESXY; j++) {
|
||||
groundFile << "vt " + to_string(0 + float(i) * incrementTexture) + " " + to_string(0 + float(j) * incrementTexture) + "\n";
|
||||
}
|
||||
}
|
||||
groundFile << "s off\n";
|
||||
for (int i = 0; i < GROUND_SQUARESXY; i++) {
|
||||
for (int j = 0; j < GROUND_SQUARESXY; j++) {
|
||||
groundFile << "vn " + to_string(normals[i][j][0]) + " " + to_string(normals[i][j][1]) + " " + to_string(normals[i][j][2]) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
int textureIdx = 0;
|
||||
int normalIdx = 0;
|
||||
for (int i = 0; i < GROUND_SQUARESXY * (GROUND_SQUARESXY - 1); i++) {
|
||||
int j = i + 1;
|
||||
if (j % GROUND_SQUARESXY == 0) {
|
||||
|
||||
}
|
||||
else {
|
||||
groundFile << "f " + to_string(j) + "/" + to_string(j) + "/" + to_string(j) + " ";
|
||||
textureIdx++;
|
||||
groundFile << to_string(j + 1) + "/" + to_string(j + 1) + "/" + to_string(j + 1) + " ";
|
||||
textureIdx++;
|
||||
groundFile << to_string(j + 1 + GROUND_SQUARESXY) + "/" + to_string(j + 1 + GROUND_SQUARESXY) + "/" + to_string(j + 1 + GROUND_SQUARESXY) + " ";
|
||||
textureIdx++;
|
||||
groundFile << to_string(j + GROUND_SQUARESXY) + "/" + to_string(j + GROUND_SQUARESXY) + "/" + to_string(j + GROUND_SQUARESXY) + "\n";
|
||||
textureIdx = textureIdx + 2;
|
||||
normalIdx++;
|
||||
}
|
||||
}
|
||||
groundFile.close();
|
||||
}
|
||||
void initFish() {
|
||||
|
||||
for (int i = 0; i < FISH_NUM; i++) {
|
||||
@ -612,13 +774,14 @@ void renderScene()
|
||||
void init()
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
initGround();
|
||||
ParticlesEmitter = new ParticleEmitter();
|
||||
programColor = shaderLoader.CreateProgram("shaders/shader_color.vert", "shaders/shader_color.frag");
|
||||
programTexture = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
|
||||
programSkyBox = shaderLoader.CreateProgram("shaders/shader_box.vert", "shaders/shader_box.frag");
|
||||
programParticle = shaderLoader.CreateProgram("shaders/shader_particle.vert", "shaders/shader_particle.frag");
|
||||
|
||||
groundModel = obj::loadModelFromFile("models/ground.obj");
|
||||
groundModel = obj::loadModelFromFile("models/testingIn.obj");
|
||||
seaweedModel = obj::loadModelFromFile("models/seaweed.obj");
|
||||
fishModel1 = obj::loadModelFromFile("models/fish1.obj");
|
||||
fishModel2 = obj::loadModelFromFile("models/fish2.obj");
|
||||
@ -650,7 +813,6 @@ void init()
|
||||
initSkybox();
|
||||
initGeyser();
|
||||
initBubbles();
|
||||
initGround();
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
|
BIN
cw 2/textures/cow.jpg
Normal file
BIN
cw 2/textures/cow.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 47 KiB |
Loading…
Reference in New Issue
Block a user