From 068348b3e3e56efb13c94a2e2d09239ec8a3b63c Mon Sep 17 00:00:00 2001 From: Ilya Shurupov <163508118+elushaX@users.noreply.github.com> Date: Sun, 24 Nov 2024 01:45:50 +0300 Subject: [PATCH 1/5] add setBuff method to Buffer2D --- Containers/public/Buffer2D.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Containers/public/Buffer2D.hpp b/Containers/public/Buffer2D.hpp index 9fda2a8..b28fb6d 100644 --- a/Containers/public/Buffer2D.hpp +++ b/Containers/public/Buffer2D.hpp @@ -58,6 +58,7 @@ namespace tp { [[nodiscard]] Index2D size() const { return { mSize.x, mSize.y }; } tType* getBuff() const { return mBuff; } + void setBuff(tType* data, Index2D size) { mBuff = data; mSize = size; } void flipY() { for (Index i = 0; i < mSize.x; i++) { From 1508d115736172b75c7ebeb7ce08e6318f3a2e72 Mon Sep 17 00:00:00 2001 From: Ilya Shurupov <163508118+elushaX@users.noreply.github.com> Date: Sun, 24 Nov 2024 10:50:08 -0800 Subject: [PATCH 2/5] Update LICENSE --- LICENSE | 350 ++++---------------------------------------------------- 1 file changed, 24 insertions(+), 326 deletions(-) diff --git a/LICENSE b/LICENSE index d159169..74b5cc8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,339 +1,37 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 +SOFTWARE LICENSE AGREEMENT +This Software License Agreement ("Agreement") is made and entered into as of 2024-11-24 ("Effective Date") by Ilya Shurupov. - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +WHEREAS, Licensor owns certain software that it desires to license to Licensee; - Preamble +WHEREAS, Licensee desires to use such software under the terms and conditions set forth herein. - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. +NOW, THEREFORE, in consideration of the mutual promises contained herein and for other good and valuable consideration, the receipt and sufficiency of which are hereby acknowledged, the parties agree as follows: - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +1. Definition of Software: +The term "Software" refers to the Modules, including any updates, modifications, or associated documentation provided by Licensor. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. +2. Grant of License: +Subject to the terms and conditions of this Agreement, Licensor hereby grants to Licensee a no license to use the Software. - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. +3. Derivative Works: +No modifications or derivative works are allowed. - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. +4. Commercial Use: +Commercial use is not allowed. - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. +5. Attribution: +No attribution is required. - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. +6. Intellectual Property Rights: +All intellectual property rights in the Software shall remain the property of Licensor. The Licensee does not acquire any rights to the Software except for the limited use rights specified in this Agreement. - The precise terms and conditions for copying, distribution and -modification follow. +7. Warranty and Liability: +The Software is provided "as is" without warranty of any kind. Licensor shall not be liable for any damages arising out of or related to the use or inability to use the Software. - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +8. Termination: +This Agreement shall terminate automatically if Licensee breaches any of its terms and conditions. Upon termination, Licensee must cease all use of the Software and destroy all copies. - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". +9. Governing Law: +This Agreement shall be governed by and construed in accordance with the laws of . -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. +https://www.binpress.com/license-generator/ From 8fc76a81f3f37250bace062bc8e773fe529554a1 Mon Sep 17 00:00:00 2001 From: IlyaShurupov Date: Mon, 4 Nov 2024 21:54:18 +0300 Subject: [PATCH 3/5] Tunes --- Math/public/Mat.hpp | 2 +- Sketch3D/applications/Entry.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Math/public/Mat.hpp b/Math/public/Mat.hpp index 4c51bcd..d773169 100644 --- a/Math/public/Mat.hpp +++ b/Math/public/Mat.hpp @@ -465,7 +465,7 @@ namespace tp { } // Matrix Properties - MVec transform(const MVec& in) const { return MVec(i.x * in.x + i.y * in.y, j.x * in.y + j.y * in.x); } + MVec transform(const MVec& in) const { return MVec(i.x * in.x + i.y * in.y, j.x * in.x + j.y * in.y); } Mat transform(const Mat& in) const { Mat out; diff --git a/Sketch3D/applications/Entry.cpp b/Sketch3D/applications/Entry.cpp index 8574a62..ef799c8 100644 --- a/Sketch3D/applications/Entry.cpp +++ b/Sketch3D/applications/Entry.cpp @@ -11,7 +11,7 @@ public: Sketch3DApplication() { setRoot(&mGui); - mGui.createRenderWidget(mGraphics->getCanvas(), { 1920, 1080 }); + mGui.createRenderWidget(mGraphics->getCanvas(), { 2560, 1440 }); mGui.setProject(&mSketch); } @@ -25,4 +25,4 @@ void runApp() { app.run(); } -int main() { runApp(); } \ No newline at end of file +int main() { runApp(); } From 8d167b960ad10b1302742100fa4ef5df09daaa52 Mon Sep 17 00:00:00 2001 From: IlyaShurupov Date: Mon, 4 Nov 2024 22:54:10 +0300 Subject: [PATCH 4/5] Raster render updates --- 3DEditor/rsc/shaders/default.vert | 3 +- 3DEditor/rsc/shaders/solid.frag | 7 +++ Math/private/Camera.cpp | 8 ++- Math/public/Camera.hpp | 1 + Math/public/Mat.hpp | 26 ++++++--- Math/public/Topology.hpp | 2 +- Math/public/Vec.hpp | 17 ++++++ RasterRender/private/FrameBuffer.cpp | 2 +- RasterRender/private/Render.cpp | 85 +++++++++++++++++++--------- RasterRender/public/RasterRender.hpp | 9 +++ 10 files changed, 121 insertions(+), 39 deletions(-) create mode 100644 3DEditor/rsc/shaders/solid.frag diff --git a/3DEditor/rsc/shaders/default.vert b/3DEditor/rsc/shaders/default.vert index 7d1fd94..6a740e3 100644 --- a/3DEditor/rsc/shaders/default.vert +++ b/3DEditor/rsc/shaders/default.vert @@ -7,5 +7,6 @@ uniform mat4 Basis; uniform mat4 Camera; void main() { - gl_Position = Camera * vec4(Point.xyz, 1.0); + vec4 transformed = (Basis * vec4(Point.xyz, 1.0)) + Origin; + gl_Position = Camera * transformed; } \ No newline at end of file diff --git a/3DEditor/rsc/shaders/solid.frag b/3DEditor/rsc/shaders/solid.frag new file mode 100644 index 0000000..31e99ca --- /dev/null +++ b/3DEditor/rsc/shaders/solid.frag @@ -0,0 +1,7 @@ +#version 330 core + +out vec4 FragColor; + +void main() { + FragColor = vec4(1, 0, 0, 1.f); +} \ No newline at end of file diff --git a/Math/private/Camera.cpp b/Math/private/Camera.cpp index fffc32e..017b467 100644 --- a/Math/private/Camera.cpp +++ b/Math/private/Camera.cpp @@ -117,16 +117,20 @@ void Camera::rotate(halnf angleX, halnf angleY) { Vec3F wup(0, 0, 1); mPos -= mTarget; - mat3f rotZ = mat3f::rotatorDir(wup, angleX); + Mat3F rotZ = Mat3F::rotatorDir(wup, angleX); mPos = rotZ * mPos; mUp = rotZ * mUp; Vec3F f = mPos.unitV(); Vec3F s = mUp * f; - mPos = mat3f::rotatorDir(s, -angleY) * mPos; + mPos = Mat3F::rotatorDir(s, -angleY) * mPos; mPos += mTarget; lookAtPoint(mTarget, mPos, mUp); } + +void Camera::setPos(Vec3F pos) { + mPos = pos; +} diff --git a/Math/public/Camera.hpp b/Math/public/Camera.hpp index 2b2ba45..6ebc5b3 100644 --- a/Math/public/Camera.hpp +++ b/Math/public/Camera.hpp @@ -18,6 +18,7 @@ namespace tp { void setRatio(halnf ratio); void setFOV(halnf fov); void setFar(halnf far); + void setPos(Vec3F pos); [[nodiscard]] const Vec3F& getPos() const; [[nodiscard]] const Vec3F& getTarget() const; diff --git a/Math/public/Mat.hpp b/Math/public/Mat.hpp index d773169..0c0344a 100644 --- a/Math/public/Mat.hpp +++ b/Math/public/Mat.hpp @@ -495,8 +495,8 @@ namespace tp { }; template - using mat3 = Mat; - using mat3f = mat3; + using Mat3 = Mat; + using Mat3F = Mat3; template class Mat { @@ -647,22 +647,22 @@ namespace tp { Mat inv() { return cofactors() /= det(); } - Mat rotatorX(alnf angle) { + Mat rotatorX(alnf angle) const { alnf cosA = (alnf) cos(angle); alnf sinA = (alnf) sin(angle); return { { 1, 0, 0 }, { 0, cosA, -sinA }, { 0, sinA, cosA } }; } - Mat rotatorY(alnf angle) { + Mat rotatorY(alnf angle) const { alnf cosA = (alnf) cos(angle); alnf sinA = (alnf) sin(angle); return { { cosA, 0, sinA }, { 0, 1, 0 }, { -sinA, 0, cosA } }; } - Mat rotatorZ(alnf angle) { - alnf cosA = (alnf) cos(angle); - alnf sinA = (alnf) sin(angle); - return { { cosA, -sinA, 0 }, { sinA, cosA, 0 }, { 0, 0, 1 } }; + static Mat rotatorZ(alnf angle) { + Type cosA = (Type) cos(angle); + Type sinA = (Type) sin(angle); + return { vec{ cosA, -sinA, 0 }, vec{ sinA, cosA, 0 }, vec{ 0, 0, 1 } }; } static Mat rotatorDir(vec dir, alnf angle) { @@ -707,4 +707,14 @@ namespace tp { Type det() { return Type(); } }; + + template + Mat toMat4(const Mat& in) { + Mat out; + out[0] = { in[0][0], in[0][1], in[0][2], 0 }; + out[1] = { in[1][0], in[1][1], in[1][2], 0 }; + out[2] = { in[2][0], in[2][1], in[2][2], 0 }; + out[3] = Type(1); + return out; + } } diff --git a/Math/public/Topology.hpp b/Math/public/Topology.hpp index 92cb1a0..31efc10 100644 --- a/Math/public/Topology.hpp +++ b/Math/public/Topology.hpp @@ -30,7 +30,7 @@ namespace tp { struct Topology { Vec3F Origin = { 0, 0, 0 }; - mat3f Basis = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; + Mat3F Basis = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; Buffer Points; Buffer Normals; diff --git a/Math/public/Vec.hpp b/Math/public/Vec.hpp index 0441fa8..0729046 100644 --- a/Math/public/Vec.hpp +++ b/Math/public/Vec.hpp @@ -110,6 +110,13 @@ namespace tp { return *this; } + Vec& operator=(Type val) { + for (ualni i = 0; i < tSize; i++) { + get(i) = val; + } + return *this; + } + void assign(Type val) { for (ualni i = 0; i < tSize; i++) { get(i) = val; @@ -576,4 +583,14 @@ namespace tp { using Vec4F = Vec4; using Vec4I = Vec4; + + template + Vec toVec4(const Vec& in) { + Vec out; + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; + out[3] = 0; + return out; + } } \ No newline at end of file diff --git a/RasterRender/private/FrameBuffer.cpp b/RasterRender/private/FrameBuffer.cpp index fd61110..0520051 100644 --- a/RasterRender/private/FrameBuffer.cpp +++ b/RasterRender/private/FrameBuffer.cpp @@ -102,7 +102,7 @@ void RenderBuffer::setViewport(const RectF& viewport) { void RenderBuffer::clear() { AssertGL(glClearColor(mClearCol.r, mClearCol.g, mClearCol.b, mClearCol.a)); - AssertGL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); + AssertGL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)); } void RenderBuffer::endDraw() { diff --git a/RasterRender/private/Render.cpp b/RasterRender/private/Render.cpp index 25cea38..af05b72 100644 --- a/RasterRender/private/Render.cpp +++ b/RasterRender/private/Render.cpp @@ -7,6 +7,7 @@ RasterRender::RasterRender() : mRenderBuffer({ 100, 100 }) { mDefaultShader.load("rsc/shaders/default.vert", nullptr, "rsc/shaders/default.frag", true); + mSolidShader.load("rsc/shaders/default.vert", nullptr, "rsc/shaders/solid.frag", true); } RasterRender::~RasterRender() {} @@ -15,6 +16,62 @@ uint4 RasterRender::getRenderBufferID() { return mRenderBuffer.texId(); } Vec2F RasterRender::getBufferSize() { return mRenderBuffer.getSize(); } +void RasterRender::bindCameraShaderAttributes(Mat4F cameraMat) { + static auto camera = (GLint) mDefaultShader.getu("Camera"); + glUniformMatrix4fv(camera, 1, true, &cameraMat[0][0]); +} + +void RasterRender::bindObjectShaderAttributes(const Object& object) { + static auto origin = (GLint) mDefaultShader.getu("Origin"); + static auto basis = (GLint) mDefaultShader.getu("Basis"); + + Mat4F basisMat = toMat4(object.mTopology.Basis); + Vec4F originPoint = toVec4(object.mTopology.Origin); + + glUniform4fv(origin, 1, &originPoint[0]); + glUniformMatrix4fv(basis, 1, false, &basisMat[0][0]); +} + +void RasterRender::renderDefault(const Scene& geometry) { + mDefaultShader.bind(); + + Mat4F cameraMat = geometry.mCamera.calculateTransformationMatrix(); + + glEnable(GL_DEPTH_TEST); + + // glPolygonMode(GL_FRONT, GL_LINE); + // glPolygonMode(GL_BACK, GL_LINE); + + // auto rotator = Mat3F::rotatorZ(alnf(0.001)); + + bindCameraShaderAttributes(cameraMat); + + for (auto object : geometry.mObjects) { + // object->mTopology.Origin += 0.01; + // object->mTopology.Basis = rotator * object->mTopology.Basis; + + bindObjectShaderAttributes(object.data()); + object->mGUPBuffers->drawCall(); + } + + mDefaultShader.unbind(); +} + +void RasterRender::renderOutline(const Camera& camera, const Object& object) { + glEnable(GL_STENCIL_TEST); + + mSolidShader.bind(); + + bindCameraShaderAttributes(camera.calculateTransformationMatrix()); + bindObjectShaderAttributes(object); + + object.mGUPBuffers->drawCall(); + + mSolidShader.unbind(); + + glDisable(GL_STENCIL_TEST); +} + void RasterRender::render(const Scene& geometry, const Vec2& size) { for (auto object : geometry.mObjects) { @@ -28,33 +85,9 @@ void RasterRender::render(const Scene& geometry, const Vec2& size) { mRenderBuffer.beginDraw(); mRenderBuffer.clear(); - mDefaultShader.bind(); - - Mat4F cameraMat = geometry.mCamera.calculateTransformationMatrix(); - - glEnable(GL_DEPTH_TEST); - - // glPolygonMode(GL_FRONT, GL_LINE); - // glPolygonMode(GL_BACK, GL_LINE); - - for (auto object : geometry.mObjects) { - - static auto origin = (GLint) mDefaultShader.getu("Origin"); - static auto basis = (GLint) mDefaultShader.getu("Basis"); - static auto camera = (GLint) mDefaultShader.getu("Camera"); - - Mat4F basisMat; - Vec4F originPoint; - - glUniform4fv(origin, 1, &originPoint[0]); - glUniformMatrix4fv(basis, 1, false, &basisMat[0][0]); - glUniformMatrix4fv(camera, 1, true, &cameraMat[0][0]); - - object->mGUPBuffers->drawCall(); - } - - mDefaultShader.unbind(); + renderDefault(geometry); + // if (geometry.mObjects.size()) renderOutline(geometry.mCamera, geometry.mObjects.first()); // glPolygonMode(GL_FRONT, GL_FILL); // glPolygonMode(GL_BACK, GL_FILL); diff --git a/RasterRender/public/RasterRender.hpp b/RasterRender/public/RasterRender.hpp index 229029d..12b4744 100644 --- a/RasterRender/public/RasterRender.hpp +++ b/RasterRender/public/RasterRender.hpp @@ -17,8 +17,17 @@ namespace tp { RenderBuffer* getRenderBuffer(); Vec2F getBufferSize(); + private: + void renderDefault(const Scene& geometry); + void renderOutline(const Camera& camera, const Object& object); + + void bindObjectShaderAttributes(const Object& object); + void bindCameraShaderAttributes(Mat4F cameraMat); + private: RenderBuffer mRenderBuffer; + RenderShader mDefaultShader; + RenderShader mSolidShader; }; } \ No newline at end of file From 573541ba2df51bbb9f09cda11cf42896b9b7bf5f Mon Sep 17 00:00:00 2001 From: IlyaShurupov Date: Tue, 5 Nov 2024 12:26:48 +0300 Subject: [PATCH 5/5] 3D Editor treaks --- 3DEditor/CMakeLists.txt | 5 +- 3DEditor/private/Denoise.cpp | 2 +- 3DEditor/private/Editor.cpp | 26 +++- 3DEditor/public/Editor.hpp | 8 + 3DEditor/public/EditorWidget.hpp | 20 ++- 3DScene/private/LuaFormat.cpp | 145 +++++++++--------- 3DScene/private/OBJFormat.cpp | 35 +++++ 3DScene/private/Scene.cpp | 10 +- 3DScene/public/Scene.hpp | 29 ++++ {3DEditor => 3DScene}/rsc/scene/meshes.mtl | 0 {3DEditor => 3DScene}/rsc/scene/meshes.obj | 0 {3DEditor => 3DScene}/rsc/scene/script.lua | 7 +- Graphics/CMakeLists.txt | 2 +- Graphics/examples/Font.ttf | Bin 42624 -> 0 bytes Graphics/private/Canvas.cpp | 2 +- Graphics/private/DebugGUI.cpp | 2 +- {3DEditor => Graphics}/rsc/Font.ttf | Bin Math/private/Camera.cpp | 2 +- Math/public/Mat.hpp | 2 +- RasterRender/private/Render.cpp | 53 ++++--- RasterRender/public/FrameBuffer.hpp | 2 +- RasterRender/public/RasterRender.hpp | 15 +- .../rsc/shaders/default.frag | 0 .../rsc/shaders/default.vert | 1 + .../rsc/shaders/solid.frag | 0 RayTracer/private/RayTracer.cpp | 2 + RayTracer/public/RayTracer.hpp | 8 - 27 files changed, 254 insertions(+), 124 deletions(-) rename {3DEditor => 3DScene}/rsc/scene/meshes.mtl (100%) rename {3DEditor => 3DScene}/rsc/scene/meshes.obj (100%) rename {3DEditor => 3DScene}/rsc/scene/script.lua (75%) delete mode 100644 Graphics/examples/Font.ttf rename {3DEditor => Graphics}/rsc/Font.ttf (100%) rename {3DEditor => RasterRender}/rsc/shaders/default.frag (100%) rename {3DEditor => RasterRender}/rsc/shaders/default.vert (83%) rename {3DEditor => RasterRender}/rsc/shaders/solid.frag (100%) diff --git a/3DEditor/CMakeLists.txt b/3DEditor/CMakeLists.txt index 4e22009..1a410b4 100644 --- a/3DEditor/CMakeLists.txt +++ b/3DEditor/CMakeLists.txt @@ -19,5 +19,6 @@ file(GLOB APP_SOURCES "./applications/*.cpp") add_executable(3DEditorApp ${APP_SOURCES}) target_link_libraries(3DEditorApp ${PROJECT_NAME}) -file(COPY "rsc" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") -file(COPY "rsc/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") +file(COPY "../RasterRender/rsc" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") +file(COPY "../Graphics/rsc" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") +file(COPY "../3DScene/rsc" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") diff --git a/3DEditor/private/Denoise.cpp b/3DEditor/private/Denoise.cpp index 7c4955a..a20672a 100644 --- a/3DEditor/private/Denoise.cpp +++ b/3DEditor/private/Denoise.cpp @@ -37,4 +37,4 @@ void Editor::denoise() { if (device.getError(errorMessage) != oidn::Error::None) { std::cerr << "Error: " << errorMessage << std::endl; } -} \ No newline at end of file +} diff --git a/3DEditor/private/Editor.cpp b/3DEditor/private/Editor.cpp index 59facdf..9641bf8 100644 --- a/3DEditor/private/Editor.cpp +++ b/3DEditor/private/Editor.cpp @@ -24,7 +24,10 @@ Editor::Editor() { void Editor::renderViewport() { switch (mRenderType) { case RenderType::RASTER: - mRasterRenderer.render(mScene, mScene.mRenderSettings.size); + mRasterRenderer.beginRender(mScene, mScene.mRenderSettings.size); + mRasterRenderer.renderDefault(mScene); + if (mActive) mRasterRenderer.renderOutline(mScene.mCamera, *mActive); + mRasterRenderer.endRender(); break; case RenderType::PATH_TRACER: @@ -54,6 +57,7 @@ uint4 Editor::getViewportTexID() { void Editor::loadDefaults() { mScene.load("rsc/scene/script.lua"); + mResetCamera = mScene.mCamera; } void Editor::setViewportSize(const Vec2F& size) { @@ -73,6 +77,7 @@ Editor::~Editor() { } void Editor::renderPathFrame() { + mScene.updateCache(); mPathRenderer.render(mScene, mPathTracerBuffers, mScene.mRenderSettings); sendBuffersToGPU(); } @@ -116,5 +121,20 @@ void Editor::navigationZoom(halnf factor) { } void Editor::navigationReset() { - mScene.mCamera.lookAtPoint({ 0, 0, 0 }, { 1, 5, 1 }, { 0, 0, 1 }); -} \ No newline at end of file + mScene.mCamera = mResetCamera; + // mScene.mCamera.lookAtPoint({ 0, 0, 0 }, { 1, 5, 1 }, { 0, 0, 1 }); +} + +void Editor::selectObject(const Vec2F& screenPos) { + mScene.updateCache(); + + auto dir = (mScene.mCamera.project(screenPos) - mScene.mCamera.getPos()).normalize(); + Ray ray = Ray( dir, mScene.mCamera.getPos() ); + + auto rayCastData = mScene.castRay(ray, 1000); + mActive = rayCastData.obj; +} + +Object* Editor::getActiveObject() { return mActive; } + +Scene* Editor::getScene() { return &mScene; } \ No newline at end of file diff --git a/3DEditor/public/Editor.hpp b/3DEditor/public/Editor.hpp index ee16122..a4c3b0f 100644 --- a/3DEditor/public/Editor.hpp +++ b/3DEditor/public/Editor.hpp @@ -28,6 +28,10 @@ namespace tp { void navigationZoom(halnf factor); void navigationReset(); + void selectObject(const Vec2F& screenPos); + Object* getActiveObject(); + + Scene* getScene(); private: void sendBuffersToGPU(); @@ -36,6 +40,8 @@ namespace tp { private: Scene mScene; + Camera mResetCamera; + RenderType mRenderType = RenderType::RASTER; RasterRender mRasterRenderer; @@ -43,5 +49,7 @@ namespace tp { RayTracer::OutputBuffers mPathTracerBuffers; uint4 mPathRenderTexture = 0; + + Object* mActive = nullptr; }; } \ No newline at end of file diff --git a/3DEditor/public/EditorWidget.hpp b/3DEditor/public/EditorWidget.hpp index 0914937..7b4e748 100644 --- a/3DEditor/public/EditorWidget.hpp +++ b/3DEditor/public/EditorWidget.hpp @@ -66,11 +66,13 @@ namespace tp { mNavigationOrbit.setText("Orbit"); mNavigationZoom.setText("Zoom"); mNavigationReset.setText("Reset"); + mNavigationSelect.setText("Select"); mNavigationMenu.addToMenu(&mNavigationPan); mNavigationMenu.addToMenu(&mNavigationOrbit); mNavigationMenu.addToMenu(&mNavigationZoom); mNavigationMenu.addToMenu(&mNavigationReset); + mNavigationMenu.addToMenu(&mNavigationSelect); mNavigationMenu.setText("Navigation"); } @@ -85,30 +87,39 @@ namespace tp { mNavigationOrbit.setAction( [this]() { mNavigationType = ORBIT; }); mNavigationPan.setAction( [this]() { mNavigationType = PAN; }); mNavigationZoom.setAction( [this](){ mNavigationType = ZOOM; }); + mNavigationSelect.setAction( [this](){ mNavigationType = SELECT; }); mNavigationReset.setAction( [this]() { mEditor->navigationReset(); }); } void process(const EventHandler& events) override { DockWidget::process(events); - auto pointer = events.getPointer(); - auto pointerPrev = events.getPointerPrev(); + if (auto obj = mEditor->getActiveObject()) { // dummy rotate active object + auto rotator = obj->mTopology.Basis.rotatorDir({1, 1, 1}, 0.1); + obj->mTopology.Basis = rotator * obj->mTopology.Basis; + } + + mEditor->getScene()->updateCache(); const auto& activeArea = mViewport.getArea(); + auto pointer = events.getPointer(); + auto pointerPrev = events.getPointerPrev(); + auto pointerRelative = (((pointer - activeArea.pos) / activeArea.size) - 0.5f) * 2; + if (activeArea.isInside(pointer) && events.isDown(InputID::MOUSE1)) { switch (mNavigationType) { case ORBIT: mEditor->navigationOrbit(events.getPointerDelta() / activeArea.size * 3); break; case PAN: { - auto pointerRelative = (((pointer - activeArea.pos) / activeArea.size) - 0.5f) * 2; auto prevPointerRelative = (((pointerPrev - activeArea.pos) / activeArea.size) - 0.5f) * 2; mEditor->navigationPan(prevPointerRelative, pointerRelative); } break; case ZOOM: mEditor->navigationZoom(1 + (events.getPointerDelta().y / activeArea.size.y)); break; + case SELECT: mEditor->selectObject(pointerRelative * -1); break; } } } @@ -129,13 +140,14 @@ namespace tp { ButtonWidget mRenderDeNoise; // Navigation - enum NavigationType { ORBIT, PAN, ZOOM } mNavigationType = ORBIT; + enum NavigationType { SELECT, ORBIT, PAN, ZOOM } mNavigationType = ORBIT; FloatingMenu mNavigationMenu; ButtonWidget mNavigationPan; ButtonWidget mNavigationOrbit; ButtonWidget mNavigationZoom; ButtonWidget mNavigationReset; + ButtonWidget mNavigationSelect; RGBA mBaseColor; }; diff --git a/3DScene/private/LuaFormat.cpp b/3DScene/private/LuaFormat.cpp index 3d61aad..acf4c9a 100644 --- a/3DScene/private/LuaFormat.cpp +++ b/3DScene/private/LuaFormat.cpp @@ -7,6 +7,61 @@ extern "C" { } #include +#include + +tp::Vec3F tp::Scene::getVec3(lua_State* state, const char* name) { + int stackSize = lua_gettop(state); + + // Access the "pos" field and validate it + lua_getfield(state, -1, name); + if (!lua_istable(state, -1) || lua_rawlen(state, -1) != 3) { + throw IOError(std::string("Invalid vec3 named ") + name); + } + + // Read the values from the table + float pos[3]; + for (int i = 0; i < 3; i++) { + lua_rawgeti(state, -1, i + 1); + if (lua_isnumber(state, -1)) { + pos[i] = lua_tonumber(state, -1); + } else { + throw IOError("vec3 values must be numbers"); + } + lua_pop(state, 1); // pop number + } + lua_pop(state, 1); // pop vec3 + + ASSERT(stackSize == lua_gettop(state)) + + return { pos[0], pos[1], pos[2] }; +} + +tp::Vec2F tp::Scene::getVec2(lua_State* state, const char* name) { + int stackSize = lua_gettop(state); + + // Access the "pos" field and validate it + lua_getfield(state, -1, name); + if (!lua_istable(state, -1) || lua_rawlen(state, -1) != 2) { + throw IOError(std::string("Invalid vec2 named ") + name); + } + + // Read the values from the table + float pos[2]; + for (int i = 0; i < 2; i++) { + lua_rawgeti(state, -1, i + 1); + if (lua_isnumber(state, -1)) { + pos[i] = lua_tonumber(state, -1); + } else { + throw IOError("vec3 values must be numbers"); + } + lua_pop(state, 1); // pop number + } + lua_pop(state, 1); // pop vec3 + + ASSERT(stackSize == lua_gettop(state)) + + return { pos[0], pos[1] }; +} // Function to read a Lua table representing RenderSettings int readRenderSettings(lua_State* L, tp::RenderSettings& settings) { @@ -53,23 +108,8 @@ int readRenderSettings(lua_State* L, tp::RenderSettings& settings) { } // Function to read a Lua table representing a light -int readLight(lua_State* L, tp::PointLight* light) { - lua_getfield(L, -1, "pos"); // Get the "pos" field from the light table - if (!lua_istable(L, -1)) { - printf("Light is missing the 'pos' table.\n"); - return 0; // Error - } - for (int i = 0; i < 3; i++) { - lua_rawgeti(L, -1, i + 1); // Index is 1-based in Lua - if (!lua_isnumber(L, -1)) { - printf("Light 'pos' field is not a number at index %d.\n", i); - lua_pop(L, 2); // Pop both the number and the 'pos' table - return 0; // Error - } - light->pos[i] = lua_tonumber(L, -1); - lua_pop(L, 1); // Pop the number - } - lua_pop(L, 1); // Pop the 'pos' table +int tp::Scene::readLight(lua_State* L, tp::PointLight* light) { + light->pos = getVec3(L, "pos"); lua_getfield(L, -1, "intensity"); // Get the "intensity" field from the light table if (!lua_isnumber(L, -1)) { @@ -121,66 +161,29 @@ bool tp::Scene::loadLuaFormat(const std::string& scenePath) { } // --- camera - - // Access Camera table - lua_getglobal(L, "Camera"); - if (!lua_istable(L, -1)) { - printf("Camera is not a table.\n"); - lua_close(L); - return false; - } - - // Verify you are inside the "Camera" table - int cameraTableIndex = lua_gettop(L); // Get the index of the "Camera" table - - // Access the "pos" field and validate it - lua_getfield(L, cameraTableIndex, "pos"); - if (!lua_istable(L, -1) || lua_rawlen(L, -1) != 3) { - printf("Invalid 'pos' field in Camera table.\n"); - lua_close(L); - return false; - } - - // Read the values from the table - float pos[3]; - for (int i = 0; i < 3; i++) { - lua_rawgeti(L, -1, i + 1); - if (lua_isnumber(L, -1)) { - pos[i] = lua_tonumber(L, -1); - } else { - printf("Invalid 'pos' field value at index %d.\n", i + 1); + { + lua_getglobal(L, "Camera"); + if (!lua_istable(L, -1)) { + printf("Camera is not a table.\n"); lua_close(L); return false; } + + Vec3F camPos = getVec3(L, "pos"); + Vec3F camTarget = getVec3(L, "target"); + Vec3F camUp = getVec3(L, "up"); + Vec2F camSize = getVec2(L, "size"); + + mRenderSettings.size = camSize; + + mCamera.lookAtPoint(camTarget, camPos, camUp); + mCamera.setFOV(3.14 / 4); + mCamera.setFar(100); + mCamera.setRatio((tp::halnf) camSize.y / (tp::halnf) camSize.x); + lua_pop(L, 1); } - // Access the "size_x" field and validate it - lua_getfield(L, cameraTableIndex, "size_x"); - if (!lua_isnumber(L, -1)) { - printf("Invalid or missing 'size_x' field in Camera table.\n"); - lua_close(L); - return false; - } - int size_x = lua_tointeger(L, -1); - lua_pop(L, 1); // Pop the 'size_x' value from the stack - - // Access the "size_y" field and validate it - lua_getfield(L, cameraTableIndex, "size_y"); - if (!lua_isnumber(L, -1)) { - printf("Invalid or missing 'size_y' field in Camera table.\n"); - lua_close(L); - return false; - } - int size_y = lua_tointeger(L, -1); - - mRenderSettings.size = { (tp::halnf) size_x, (tp::halnf) size_y }; - - mCamera.lookAtPoint({ 0, 0, 0 }, { pos[0], pos[1], pos[2] }, { 0, 0, 1 }); - mCamera.setFOV(3.14 / 4); - mCamera.setFar(100); - mCamera.setRatio((tp::halnf) size_y / (tp::halnf) size_x); - // ---------- LIGHTS { lua_getglobal(L, "Lights"); diff --git a/3DScene/private/OBJFormat.cpp b/3DScene/private/OBJFormat.cpp index 3fcf8ad..b97b87f 100644 --- a/3DScene/private/OBJFormat.cpp +++ b/3DScene/private/OBJFormat.cpp @@ -48,4 +48,39 @@ bool tp::Scene::loadOBJFormat(const std::string& objetsPath) { } return mObjects.size(); +} + +const tp::RayCastData& tp::Scene::castRay(const Ray& ray, alnf farVal) { + auto& out = mRayCastData; + + out.hit = false; + out.obj = nullptr; + + farVal *= farVal; + + for (auto obj : mObjects) { + for (auto trig : obj->mCache.TrigCaches) { + if (trig->castRay(ray)) { + + auto dist = (TrigCache::getHitPos() - ray.pos).length2(); + + if (farVal > dist && dist > EPSILON) { + out.trig = &trig.data(); + out.hitPos = TrigCache::getHitPos(); + out.obj = &obj.data(); + out.hit = true; + + farVal = dist; + } + } + } + } + + return mRayCastData; +} + +void tp::Scene::updateCache() { + for (auto obj : mObjects) { + obj->mCache.updateCache(); + } } \ No newline at end of file diff --git a/3DScene/private/Scene.cpp b/3DScene/private/Scene.cpp index f1927b2..6ef0399 100644 --- a/3DScene/private/Scene.cpp +++ b/3DScene/private/Scene.cpp @@ -2,5 +2,13 @@ #include "Scene.hpp" bool tp::Scene::load(const std::string& scenePath) { - return loadLuaFormat(scenePath); + try { + auto res = loadLuaFormat(scenePath); + if (!res) throw IOError("Failed loading lua script"); + } catch (const IOError& err) { + printf("Failed loading scene : %s\n", err.description.c_str()); + return false; + } + + return true; } \ No newline at end of file diff --git a/3DScene/public/Scene.hpp b/3DScene/public/Scene.hpp index f7aa56f..ac872f5 100644 --- a/3DScene/public/Scene.hpp +++ b/3DScene/public/Scene.hpp @@ -6,6 +6,8 @@ #include +struct lua_State; + namespace tp { struct RenderSettings { uhalni depth = 2; @@ -42,7 +44,22 @@ namespace tp { halnf intensity = 1.f; }; + struct RayCastData { + Object* obj = nullptr; + TrigCache* trig = nullptr; + Vec3F hitPos = { 0, 0, 0 }; + bool hit = false; + bool inv = false; + }; + class Scene { + struct IOError : public std::exception { + explicit IOError(std::string in) : + description(std::move(in)) {} + + std::string description; + }; + public: Scene() = default; @@ -51,11 +68,23 @@ namespace tp { bool loadLuaFormat(const std::string& scenePath); bool loadOBJFormat(const std::string& objectsPath); + const RayCastData& castRay(const Ray& ray, alnf farVal); + + void updateCache(); + + private: + Vec3F getVec3(lua_State* state, const char* name); + Vec2F getVec2(lua_State* state, const char* name); + + int readLight(lua_State* L, tp::PointLight* light); + public: Buffer mObjects; Buffer mLights; Camera mCamera; RenderSettings mRenderSettings; + + RayCastData mRayCastData; }; } diff --git a/3DEditor/rsc/scene/meshes.mtl b/3DScene/rsc/scene/meshes.mtl similarity index 100% rename from 3DEditor/rsc/scene/meshes.mtl rename to 3DScene/rsc/scene/meshes.mtl diff --git a/3DEditor/rsc/scene/meshes.obj b/3DScene/rsc/scene/meshes.obj similarity index 100% rename from 3DEditor/rsc/scene/meshes.obj rename to 3DScene/rsc/scene/meshes.obj diff --git a/3DEditor/rsc/scene/script.lua b/3DScene/rsc/scene/script.lua similarity index 75% rename from 3DEditor/rsc/scene/script.lua rename to 3DScene/rsc/scene/script.lua index ef6d484..42ea4c7 100644 --- a/3DEditor/rsc/scene/script.lua +++ b/3DScene/rsc/scene/script.lua @@ -2,9 +2,10 @@ Meshes = "meshes.obj" Camera = { - pos = { 0.5, 4.5, 0.2 }, - size_x = 600, - size_y = 800, + pos = { 0, 5, 0 }, + target = { 0, 0, 0 }, + up = { 0, 0, 1 }, + size = { 600, 800 }, } Lights = { diff --git a/Graphics/CMakeLists.txt b/Graphics/CMakeLists.txt index 1159d2a..3d4118b 100644 --- a/Graphics/CMakeLists.txt +++ b/Graphics/CMakeLists.txt @@ -19,5 +19,5 @@ target_link_libraries(Example${PROJECT_NAME} ${PROJECT_NAME} ${BINDINGS_LIBS}) target_include_directories(Example${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE}) -file(COPY "examples/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") +file(COPY "../Graphics/rsc" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/") diff --git a/Graphics/examples/Font.ttf b/Graphics/examples/Font.ttf deleted file mode 100644 index 8a630544c99ec9956153ebd9509abeac421c6d75..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 42624 zcmbS!2S8NE*6_?NyL4Ep^rbE!9d?)AK@^bQ1*rl`lcIthyMiqSd!h-NNQx#gCe|cs z5|d~05|g}?XYyj|OD``~*~@=s?k+4?zhAuEyL<1QIp@roGiOc%VT6z=T7g)Ulbs(F zT3Zx92O-=H-xk%jRJTueuK5){UxdS{c0rdMrSLMicNGq7l=AJp{ z)?9EvXi5x1o0A&rtLscIb-xJjhQobTBYa`8Qt}miChvGQwsb9WIQiG32pJwgNaEDo zR$KkMg`I#9^C?2CMN9RfcKkki2cG>I4tZ;JOMO}05?h3L_{<(_Z|m&hWt-a(GCu>| zFK_RtZ*P?JuYqUbeIzBYK95J&9ODL{ON2*9kvW_ZUWaPoZXDte1JA)7_?>_Pfd=&2 z;6)AKZ?JE4&1jK9B)tm{=>Eamb5(KuFzMerc+T2maznZpFAI3x!wUC=VT3~y%w7&Y@M^D*-y%eb&E z#xAZdi7v%1)h_c~*0}snZXd&`66N_mt#R-PiykU#F`euD$5A!y|Q-p2UD`>!w` z(DxY^BNrE!1eYS0Dwnw~D_nk+Tgj);_e158@|dyr(dg*t=cDIGkB!=mnh7g}cA-kh z`h4c+>7T1UxBZ;??D}WFe)h>{9oO=&#+mHurIZ_sP-oWbjc z$k5s_+%Vs8uHj0<9fl7XK5O`@;k$-k71Dl2UEPJ3{Cmf-pan-{$cx1 z9pnyG4l5j9ab9}<_Z>I%L7o1(3mpFgu;^b24^03P{E~BnCt^uxTu3KEck-N$Z zfU@XGL^@IRFC${or-R4u9#YGd_u^-lE(^)>ZqL_ow)BpaC=*&KN)^5>|Os1;HF zh!UbRqjyDLjQ%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Ox{YxIBb2yun@8M9 zrqY>OzgN|f*M5^0ZzpbHm1@;%)1ap1nl_o5aGjgT`TM6WIgJ4bb* z)ZQ%lp7a%@L8)1xcYZ|$;zpTdQ<4I;qwY*YLb=>pJ(D`5_Y@WPBJwl~A*abmq$o|y ziDP^3-{0HQ^PZ|kuZ#ZnTl{(a1U=Q!8_Vy89c{iFPkl;m>`os_wCm&gQmRh}j=bgb$tB|BqUH<+J5ufj$^6bZ#VL$~8x>#$Hf(CSEM z$a?tH&;=1A&ablr;vRN}?gMg>Iz?Tm-v?bV?xd|1N~62YPl%`Bhr`UNHR^S`s=BI- zIR${;B_)MSV$Yd+`=e=9d}_)A|hzw$GzGm79YGvmF{8}I*E@m zX~hVdiP#52E_#X4_ucO95#W#C%D=k1vDqurH2#J5V+B*z+K!-wc;%2LIVsW>M>T}z z6vqK`3CA(V%}TqwH&nf`Wr@3B=HkUO3l1I}TAovynKF9Dn|1GezjzM{J`!IzXX}Fb zZ@o0HrgnX$+^KyMT|8!LadlQs&CLA5EtS+Fti1|yj%XxE50x6?PoV)P-A79oDwC(3AR;#VPzxx*v5s>XcuICl%C!DK4K$Z{rwc+F}hE|v2 zTTl5zFr5SIBTV6Bd?Bt+z^X_r_RrUp=>44@R`&Io&ce>O-n~18b!myiRdzvZDt>Z) zS9{^5&mL%>u>X386%C&|-FxF-;D0!|%j=nwpW*%aAEy4Gp25WmEmF>^4IeMyxnaK_vpvB5wV}T|z7Y3=B}vg = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES); - if (nvgCreateFont(mContext->vg, "default", "Font.ttf") == -1) { + if (nvgCreateFont(mContext->vg, "default", "rsc/Font.ttf") == -1) { ASSERT(!"Cant create NVG font") } } diff --git a/Graphics/private/DebugGUI.cpp b/Graphics/private/DebugGUI.cpp index 03f6b1f..5880db1 100644 --- a/Graphics/private/DebugGUI.cpp +++ b/Graphics/private/DebugGUI.cpp @@ -36,7 +36,7 @@ DebugGUI::DebugGUI(Window* window) { ImGui_ImplOpenGL3_Init("#version 330"); ImGuiIO& io = ImGui::GetIO(); - io.Fonts->AddFontFromFileTTF("Font.ttf", 20.f); + io.Fonts->AddFontFromFileTTF("rsc/Font.ttf", 20.f); io.ConfigInputTrickleEventQueue = false; diff --git a/3DEditor/rsc/Font.ttf b/Graphics/rsc/Font.ttf similarity index 100% rename from 3DEditor/rsc/Font.ttf rename to Graphics/rsc/Font.ttf diff --git a/Math/private/Camera.cpp b/Math/private/Camera.cpp index 017b467..621297e 100644 --- a/Math/private/Camera.cpp +++ b/Math/private/Camera.cpp @@ -88,7 +88,7 @@ void Camera::lookAtPoint(const Vec3F& aTarget, const Vec3F& aPos, Vec3F aUp) { } mPos = aPos; mTarget = aTarget; - Vec3F f = (mPos - mTarget).normalize(); + Vec3F f = (mTarget - mPos).normalize(); mUp = f * (aUp.normalize() * f); } diff --git a/Math/public/Mat.hpp b/Math/public/Mat.hpp index 0c0344a..2483284 100644 --- a/Math/public/Mat.hpp +++ b/Math/public/Mat.hpp @@ -714,7 +714,7 @@ namespace tp { out[0] = { in[0][0], in[0][1], in[0][2], 0 }; out[1] = { in[1][0], in[1][1], in[1][2], 0 }; out[2] = { in[2][0], in[2][1], in[2][2], 0 }; - out[3] = Type(1); + out[3] = { Type(0), Type(0), Type(0), Type(1) }; return out; } } diff --git a/RasterRender/private/Render.cpp b/RasterRender/private/Render.cpp index af05b72..9b6da2c 100644 --- a/RasterRender/private/Render.cpp +++ b/RasterRender/private/Render.cpp @@ -3,20 +3,24 @@ using namespace tp; -RasterRender::RasterRender() : - mRenderBuffer({ 100, 100 }) -{ +RasterRender::RasterRender() { mDefaultShader.load("rsc/shaders/default.vert", nullptr, "rsc/shaders/default.frag", true); mSolidShader.load("rsc/shaders/default.vert", nullptr, "rsc/shaders/solid.frag", true); } RasterRender::~RasterRender() {} +void RasterRender::resize(const Vec2& size) { + auto sizeF = Vec2F(size.x, size.y); + mRenderBuffer.resize(sizeF); + mTempBuffer.resize(sizeF); +} + uint4 RasterRender::getRenderBufferID() { return mRenderBuffer.texId(); } Vec2F RasterRender::getBufferSize() { return mRenderBuffer.getSize(); } -void RasterRender::bindCameraShaderAttributes(Mat4F cameraMat) { +void RasterRender::bindCameraShaderAttributes(const Mat4F& cameraMat) { static auto camera = (GLint) mDefaultShader.getu("Camera"); glUniformMatrix4fv(camera, 1, true, &cameraMat[0][0]); } @@ -28,11 +32,18 @@ void RasterRender::bindObjectShaderAttributes(const Object& object) { Mat4F basisMat = toMat4(object.mTopology.Basis); Vec4F originPoint = toVec4(object.mTopology.Origin); + basisMat = basisMat.transpose(); + glUniform4fv(origin, 1, &originPoint[0]); glUniformMatrix4fv(basis, 1, false, &basisMat[0][0]); } void RasterRender::renderDefault(const Scene& geometry) { + mRenderBuffer.mClearCol = { 0.0f, 0.0f, 0.0f, 0.f }; + + mRenderBuffer.beginDraw(); + mRenderBuffer.clear(); + mDefaultShader.bind(); Mat4F cameraMat = geometry.mCamera.calculateTransformationMatrix(); @@ -55,10 +66,19 @@ void RasterRender::renderDefault(const Scene& geometry) { } mDefaultShader.unbind(); + + glDisable(GL_DEPTH_TEST); + + // glPolygonMode(GL_FRONT, GL_FILL); + // glPolygonMode(GL_BACK, GL_FILL); + + mRenderBuffer.endDraw(); } void RasterRender::renderOutline(const Camera& camera, const Object& object) { - glEnable(GL_STENCIL_TEST); + mRenderBuffer.beginDraw(); + + // glEnable(GL_STENCIL_TEST); mSolidShader.bind(); @@ -69,30 +89,23 @@ void RasterRender::renderOutline(const Camera& camera, const Object& object) { mSolidShader.unbind(); - glDisable(GL_STENCIL_TEST); + // glDisable(GL_STENCIL_TEST); + + mRenderBuffer.endDraw(); } -void RasterRender::render(const Scene& geometry, const Vec2& size) { +void RasterRender::beginRender(const Scene& geometry, const Vec2& size) { + resize(size); for (auto object : geometry.mObjects) { if (!object->mGUPBuffers) { object->mGUPBuffers = new ObjectBuffers(&object.data()); } } +} - mRenderBuffer.mClearCol = { 0.0f, 0.0f, 0.0f, 0.f }; - - mRenderBuffer.beginDraw(); - mRenderBuffer.clear(); - - renderDefault(geometry); - - // if (geometry.mObjects.size()) renderOutline(geometry.mCamera, geometry.mObjects.first()); - - // glPolygonMode(GL_FRONT, GL_FILL); - // glPolygonMode(GL_BACK, GL_FILL); - - mRenderBuffer.endDraw(); +void RasterRender::endRender() { + // pass } RenderBuffer* RasterRender::getRenderBuffer() { return &mRenderBuffer; } diff --git a/RasterRender/public/FrameBuffer.hpp b/RasterRender/public/FrameBuffer.hpp index 09dc82a..8c20aeb 100644 --- a/RasterRender/public/FrameBuffer.hpp +++ b/RasterRender/public/FrameBuffer.hpp @@ -7,7 +7,7 @@ namespace tp { class RenderBuffer { public: - explicit RenderBuffer(const Vec2F& size); + explicit RenderBuffer(const Vec2F& size = { 10, 10 }); RenderBuffer(const Vec2F& size, tp::uint1 samples); ~RenderBuffer(); diff --git a/RasterRender/public/RasterRender.hpp b/RasterRender/public/RasterRender.hpp index 12b4744..4824c93 100644 --- a/RasterRender/public/RasterRender.hpp +++ b/RasterRender/public/RasterRender.hpp @@ -12,20 +12,25 @@ namespace tp { RasterRender(); ~RasterRender(); - void render(const Scene& geometry, const Vec2& size); + void beginRender(const Scene& geometry, const Vec2& size); + void endRender(); + + void renderDefault(const Scene& geometry); + void renderOutline(const Camera& camera, const Object& object); + + void resize(const Vec2& size); + uint4 getRenderBufferID(); RenderBuffer* getRenderBuffer(); Vec2F getBufferSize(); private: - void renderDefault(const Scene& geometry); - void renderOutline(const Camera& camera, const Object& object); - void bindObjectShaderAttributes(const Object& object); - void bindCameraShaderAttributes(Mat4F cameraMat); + void bindCameraShaderAttributes(const Mat4F& cameraMat); private: RenderBuffer mRenderBuffer; + RenderBuffer mTempBuffer; RenderShader mDefaultShader; RenderShader mSolidShader; diff --git a/3DEditor/rsc/shaders/default.frag b/RasterRender/rsc/shaders/default.frag similarity index 100% rename from 3DEditor/rsc/shaders/default.frag rename to RasterRender/rsc/shaders/default.frag diff --git a/3DEditor/rsc/shaders/default.vert b/RasterRender/rsc/shaders/default.vert similarity index 83% rename from 3DEditor/rsc/shaders/default.vert rename to RasterRender/rsc/shaders/default.vert index 6a740e3..1d325ed 100644 --- a/3DEditor/rsc/shaders/default.vert +++ b/RasterRender/rsc/shaders/default.vert @@ -7,6 +7,7 @@ uniform mat4 Basis; uniform mat4 Camera; void main() { + // vec4 transformed = vec4(Point.xyz, 1.0); vec4 transformed = (Basis * vec4(Point.xyz, 1.0)) + Origin; gl_Position = Camera * transformed; } \ No newline at end of file diff --git a/3DEditor/rsc/shaders/solid.frag b/RasterRender/rsc/shaders/solid.frag similarity index 100% rename from 3DEditor/rsc/shaders/solid.frag rename to RasterRender/rsc/shaders/solid.frag diff --git a/RayTracer/private/RayTracer.cpp b/RayTracer/private/RayTracer.cpp index e8355e7..b7b85f0 100644 --- a/RayTracer/private/RayTracer.cpp +++ b/RayTracer/private/RayTracer.cpp @@ -43,6 +43,8 @@ normal = n1 * barycentric.x + n2 * barycentric.y + n3 * barycentric.z; using namespace tp; + +// TODO : de-duplicate in Scene? void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf farVal) { out.hit = false; out.obj = nullptr; diff --git a/RayTracer/public/RayTracer.hpp b/RayTracer/public/RayTracer.hpp index 4067247..a21964a 100644 --- a/RayTracer/public/RayTracer.hpp +++ b/RayTracer/public/RayTracer.hpp @@ -30,14 +30,6 @@ namespace tp { void render(const Scene& scene, OutputBuffers& out, const RenderSettings& settings); private: - struct RayCastData { - const Object* obj = nullptr; - TrigCache* trig = nullptr; - Vec3F hitPos = { 0, 0, 0 }; - bool hit = false; - bool inv = false; - }; - struct LightData { halnf intensity = 0; };