diff --git a/assets/clean-fabric-texture-4-780x585.jpg b/assets/clean-fabric-texture-4-780x585.jpg new file mode 100755 index 0000000..58ba024 Binary files /dev/null and b/assets/clean-fabric-texture-4-780x585.jpg differ diff --git a/game/main_code.cpp b/game/main_code.cpp old mode 100644 new mode 100755 index a486391..8c1dbd2 --- a/game/main_code.cpp +++ b/game/main_code.cpp @@ -54,7 +54,8 @@ void TMyApplication::InnerInit() #ifdef TARGET_WIN32 #ifdef NDEBUG - ST::PathToResources = "resources/"; + //ST::PathToResources = "resources/"; + ST::PathToResources = "../../../assets/"; #else ST::PathToResources = "../../../assets/"; #endif @@ -83,6 +84,9 @@ void TMyApplication::InnerInit() ResourceManager->TexList.AddTexture("HeightMap.png"); ResourceManager->TexList.AddTexture("NormalMap.png"); ResourceManager->TexList.AddTexture("linesAll.png"); + ResourceManager->TexList.AddTexture("clean-fabric-texture-4-780x585.jpg"); + + ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 512, 512); @@ -137,49 +141,97 @@ void TMyApplication::InnerInit() float const step = 12; float const thick = 10; - auto f = [this, texW, texH, thick, W, H] (const Vector3f &p1, const Vector3f &p2) { - auto pv = p2 - p1; - Vector3f ortho(pv[2], 0, pv[0]); - ortho.normalize(); - auto p3 = p2 + ortho * thick; - auto p4 = p1 + ortho * thick; - fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(p1); - fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(p2); - fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(p3); - - fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(p3); - fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(p4); - fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(p1); + float const R = 5; + float const r = 6; + size_t const threadsCount = 3; + size_t const verticesCount = 6; + float const angle = pi / 18; + size_t const iterationsCount = 50; + auto g = [this, R, r, threadsCount, verticesCount, angle, iterationsCount, texW, texH, thick, H, W] (const Vector3f &start, const Vector3f &end) { + Vector3f direction = end - start; + Vector3f translate = direction / iterationsCount; + direction.normalize(); - auto texThick = thick / texW; - auto m = (p1[0] + p2[0]) / 2 / texW; - auto y = H / texH; + auto e0 = Vector3f(1, 0, -direction.x() / direction.z()); + auto e1 = Vector3f(0, 1, -direction.y() / direction.z()); + e1 = e1 - (e1.dot(e0) / e0.dot(e0)) * e0; + + e0.normalize(); + e1.normalize(); - fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(m, 0)); - fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(m, y)); - fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(m + texThick, y)); - - fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(m + texThick, y)); - fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(m + texThick, 0)); - fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(m, 0)); + std::vector> threads; + for(auto i = 0; i < threadsCount; i++) { + std::vector vertices; + Vector3f threadCenter = R * (e0 * cosf(i * 2 * pi / threadsCount) + e1 * sinf(i * 2 * pi / threadsCount)); + for(auto j = 0; j < verticesCount; j++) { + auto verticeCenter = threadCenter + r * (e0 * cosf(j * 2 * pi / verticesCount) + e1 * sinf(j * 2 * pi / verticesCount)); + vertices.push_back(Vector4f(verticeCenter.x(), verticeCenter.y(), verticeCenter.z(), 1)); + } + threads.push_back(vertices); + } + + auto transform = Translation3f(translate) * AngleAxis(angle, direction); + auto matrix = transform.matrix(); + + for(auto i = 0; i < iterationsCount; i++) { + std::vector> newThreads; + + for(auto j = 0; j < threadsCount; j++) { + auto vertices = threads[j]; + std::vector newVertices; + + for(auto k = 0; k < verticesCount; k++) { + newVertices.push_back(matrix * vertices[k]); + } + + newThreads.push_back(newVertices); + + for(auto k = 0; k < verticesCount; k++) { + auto vk = vertices[k]; + auto vk1 = vertices[(k + 1) % verticesCount]; + auto nvk = newVertices[k]; + auto nvk1 = newVertices[(k + 1) % verticesCount]; + + fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + vk.head(3)); + fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + vk1.head(3)); + fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + nvk.head(3)); + + fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + vk1.head(3)); + fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + nvk1.head(3)); + fabricRender.second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(start + nvk.head(3)); + + auto texThick = thick / texW; + auto m = (start[0] + end[0]) / 2 / texW; + auto y = H / texH; + + auto texPiece = texH / iterationsCount; + + fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(0, 0)); + fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(0.01, 0)); + fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(0, 0.01)); + + fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(0.01, 0)); + fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(0.01, 0.01)); + fabricRender.second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(Vector2f(0, 0.01)); + } + } + + threads = newThreads; + } }; - Vector3f const stepDirection(1, 0, 0); + Vector3f const stepDirection(18, 0, 0); Vector3f p1(bottomLeft[0], 0, -bottomLeft[1]); + Vector3f p2 = p1 - Vector3f(0, 0, W); - while (p1[0] < bottomLeft[0] + W) { - - auto p2 = p1 - Vector3f(0, 0, W); - f(p1, p2); - - auto p3 = p1 + step * stepDirection; - f(p3, p2); - - p1 = p3; + while(p1[0] < bottomLeft[0] + W) + { + g(p1, p2); + p1 += stepDirection; + p2 += stepDirection; } - } background.first.ShaderName ="DefaultShader"; @@ -194,10 +246,12 @@ void TMyApplication::InnerInit() fabricRender.first.SamplerMap[CONST_STRING_NORMALMAP_UNIFORM] = "NormalMap.png"; fabricRender.first.SamplerMap[CONST_STRING_HEIGHTMAP_UNIFORM] = "HeightMap.png"; - fabricRender.first.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = "linesAll.png"; + fabricRender.first.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = "clean-fabric-texture-4-780x585.jpg"; background.second.RefreshBuffer(); fabricRender.second.RefreshBuffer(); + + glEnable(GL_DEPTH_TEST); Inited = true; } @@ -286,8 +340,7 @@ void TMyApplication::InnerDraw() glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - glDisable(GL_DEPTH_TEST); - + CheckGlError(""); auto mat1 = quatToMatrix(quat1); @@ -312,6 +365,8 @@ void TMyApplication::InnerDraw() Renderer->DrawTriangleList(background.second); } + + //glEnable(GL_CULL_FACE); { TRenderParamsSetter params(fabricRender.first); diff --git a/windows/DoubleHitBalls-win/DoubleHitBalls-win/DoubleHitBalls-win.vcxproj b/windows/DoubleHitBalls-win/DoubleHitBalls-win/DoubleHitBalls-win.vcxproj index 4af150b..4cc9999 100755 --- a/windows/DoubleHitBalls-win/DoubleHitBalls-win/DoubleHitBalls-win.vcxproj +++ b/windows/DoubleHitBalls-win/DoubleHitBalls-win/DoubleHitBalls-win.vcxproj @@ -22,6 +22,7 @@ {1CC98EEE-BBCB-4D79-B6D7-8511789172C5} Win32Proj DoubleHitBallswin + 8.1 @@ -48,7 +49,7 @@ false true NotSet - v140 + v141 @@ -150,7 +151,7 @@ true true WIN32;NDEBUG;_WINDOWS;TARGET_WIN32;_WIN32_WINNT=0x0501;WIN32_LEAN_AND_MEAN;EIGEN_DONT_ALIGN_STATICALLY;%(PreprocessorDefinitions) - ../../../game;../../../../tes-engine;../../../../eigen;../../../../boost_1_63_0/;../../../../boost_1_63_0/bin.v2/libs/system/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/date_time/build/msvc-14.0/release/address-model-64/link-static/threading-multi/;../../../../boost_1_63_0/bin.v2/libs/regex/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/thread/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/chrono/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/signals/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../libs/boost-gil-extension;../../../../libs/jpeg-9;../../../../libs/jpeg-9/vc10;../../../../libs/lpng1510 + ../../../game;../../../../tes-engine;../../../../eigen;../../../../boost_1_67_0/;../../../../libs/boost-gil-extension;../../../../libs/jpeg-9;../../../../libs/jpeg-9/vc10;../../../../libs/lpng1510 4503 @@ -158,7 +159,7 @@ true true true - ../../../game;../../../../tes-engine;../../../../eigen;../../../../boost_1_63_0/stage/x64/lib;../../../../boost_1_63_0/bin.v2/libs/system/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/date_time/build/msvc-14.0/release/address-model-64/link-static/threading-multi/;../../../../boost_1_63_0/bin.v2/libs/regex/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/thread/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/chrono/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/signals/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../libs/boost-gil-extension;../../../../libs/jpeg-9;../../../../libs/jpeg-9/vc10;../../../../libs/lpng1510;../x64/Release + ../../../game;../../../../tes-engine;../../../../eigen;../../../../boost_1_67_0/stage/lib;../../../../libs/boost-gil-extension;../../../../libs/jpeg-9;../../../../libs/jpeg-9/vc10;../../../../libs/lpng1510;../x64/Release libjpeg.lib;libpng.lib;Engine.lib;opengl32.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) diff --git a/windows/DoubleHitBalls-win/DoubleHitBalls-win/DoubleHitBalls-win.vcxproj.user b/windows/DoubleHitBalls-win/DoubleHitBalls-win/DoubleHitBalls-win.vcxproj.user new file mode 100755 index 0000000..6e2aec7 --- /dev/null +++ b/windows/DoubleHitBalls-win/DoubleHitBalls-win/DoubleHitBalls-win.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/windows/DoubleHitBalls-win/DoubleHitBalls-win/main.cpp b/windows/DoubleHitBalls-win/DoubleHitBalls-win/main.cpp index 6000e5a..0a08c6a 100755 --- a/windows/DoubleHitBalls-win/DoubleHitBalls-win/main.cpp +++ b/windows/DoubleHitBalls-win/DoubleHitBalls-win/main.cpp @@ -8,8 +8,8 @@ int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, LPSTR lpszCmdLine, int nCmdShow) { - int width = 512; - int height = 512; + int width = 1024; + int height = 1024; if (CreateEngine(width, height))