├── .codeclimate.yml ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md └── workflows │ └── deploy.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CMakeModules ├── FindOGRE.cmake ├── FindPkgMacros.cmake ├── FindZLIB.cmake └── PreprocessorUtils.cmake ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── DEBIAN-control.in ├── License ├── README.md ├── SECURITY.md ├── cfg ├── CMakeLists.txt ├── plugins.cfg.in ├── plugins_d.cfg.in ├── resources.cfg.in ├── resources_d.cfg.in └── version.txt.in ├── docs └── index.html ├── media ├── CMakeLists.txt ├── materials │ ├── programs │ │ ├── AmbientOneTexture.glsl │ │ ├── Example_Basic.cg │ │ ├── GLSL │ │ │ ├── DiffuseOneTexture.glsl │ │ │ ├── PassthroughFP.glsl │ │ │ └── skinningTwoWeightsShadowCasterVp.glsl │ │ ├── GLSL150 │ │ │ ├── ASCIIFP.glsl │ │ │ ├── AmbientOneTexture.glsl │ │ │ ├── AmbientOneTextureWithUV.glsl │ │ │ ├── Bloom2_ps20.glsl │ │ │ ├── Blur0_vs.glsl │ │ │ ├── Blur1_vs.glsl │ │ │ ├── BlurH_ps20.glsl │ │ │ ├── BlurV_ps20.glsl │ │ │ ├── Blur_ps.glsl │ │ │ ├── Blur_vs.glsl │ │ │ ├── BrightBloom2_ps20.glsl │ │ │ ├── BumpMapVPTangentParity.glsl │ │ │ ├── ColdCasterFp.glsl │ │ │ ├── ColdCasterVp.glsl │ │ │ ├── Combine_fp.glsl │ │ │ ├── DepthShadowObjectFp.glsl │ │ │ ├── DepthShadowObjectVp.glsl │ │ │ ├── DepthShadowmapCasterFp.glsl │ │ │ ├── DepthShadowmapCasterVp.glsl │ │ │ ├── DepthShadowmapNormalMapReceiverFp.glsl │ │ │ ├── DepthShadowmapNormalMapReceiverVp.glsl │ │ │ ├── DepthShadowmapReceiverFp.glsl │ │ │ ├── DepthShadowmapReceiverVp.glsl │ │ │ ├── DiffuseOneTexture.glsl │ │ │ ├── DitherFP.glsl │ │ │ ├── DualQuaternion.glsl │ │ │ ├── DualQuaternion_Common.glsl │ │ │ ├── DualQuaternion_ShadowCaster.glsl │ │ │ ├── DualQuaternion_TwoPhase.glsl │ │ │ ├── DualQuaternion_TwoPhaseShadowCaster.glsl │ │ │ ├── Dyn-TextFP.glsl │ │ │ ├── Dyn-TextVP.glsl │ │ │ ├── EmbossedFp.glsl │ │ │ ├── Example_BumpMappingFp.glsl │ │ │ ├── Example_BumpMappingShadowRcvFp.glsl │ │ │ ├── Example_BumpMappingShadowRcvVp.glsl │ │ │ ├── Example_BumpMappingSpecularFp.glsl │ │ │ ├── Example_BumpMappingSpecularVp.glsl │ │ │ ├── Example_BumpMappingVp.glsl │ │ │ ├── Example_CelShadingFp.glsl │ │ │ ├── Example_CelShadingVp.glsl │ │ │ ├── Example_FresnelFp.glsl │ │ │ ├── Example_FresnelVp.glsl │ │ │ ├── Example_TextureArrayPS.glsl │ │ │ ├── Example_TextureArrayVS.glsl │ │ │ ├── GlassFP.glsl │ │ │ ├── GrassAmbientFp.glsl │ │ │ ├── GrassAmbientVp.glsl │ │ │ ├── GrassCasterFp.glsl │ │ │ ├── GrassCasterVp.glsl │ │ │ ├── GrassFp.glsl │ │ │ ├── GrassReceiverFp.glsl │ │ │ ├── GrassReceiverVp.glsl │ │ │ ├── GrassTexVp.glsl │ │ │ ├── GrassVp.glsl │ │ │ ├── GrayScale.glsl │ │ │ ├── HWBasicInstancing.vert │ │ │ ├── HW_VTFInstancing.vert │ │ │ ├── HalftoneFP.glsl │ │ │ ├── HardwareMorphAnimationVp.glsl │ │ │ ├── HardwareMorphAnimationWithNormalsVp.glsl │ │ │ ├── HardwarePoseAnimationVp.glsl │ │ │ ├── HardwarePoseAnimationWithNormalsVp.glsl │ │ │ ├── HeatBlurFp.glsl │ │ │ ├── HeatBlurVp.glsl │ │ │ ├── HeatCasterFp.glsl │ │ │ ├── HeatCasterVp.glsl │ │ │ ├── Instancing.frag │ │ │ ├── InstancingMisc.vert │ │ │ ├── InvertFP.glsl │ │ │ ├── LaplaceFP.glsl │ │ │ ├── LightToHeatFp.glsl │ │ │ ├── LightToHeatVp.glsl │ │ │ ├── MetaballFP.glsl │ │ │ ├── NightVisionFP.glsl │ │ │ ├── Ocean2GLSL.frag │ │ │ ├── Ocean2GLSL.vert │ │ │ ├── OffsetMappingFp.glsl │ │ │ ├── OffsetMappingShadowsFp.glsl │ │ │ ├── OffsetMappingShadowsVp.glsl │ │ │ ├── OffsetMappingVp.glsl │ │ │ ├── OffsetMapping_specular.glsl │ │ │ ├── OldMovieFP.glsl │ │ │ ├── OldTV.glsl │ │ │ ├── ParticleGS_DisplayGS.glsl │ │ │ ├── ParticleGS_DisplayPS.glsl │ │ │ ├── ParticleGS_DisplayVS.glsl │ │ │ ├── ParticleGS_GenerateGS.glsl │ │ │ ├── ParticleGS_GenerateVS.glsl │ │ │ ├── PassthroughFP.glsl │ │ │ ├── PassthroughVP.glsl │ │ │ ├── PosterizeFP.glsl │ │ │ ├── Radial_Blur_FP.glsl │ │ │ ├── SampleFieldVS.glsl │ │ │ ├── ShaderInstancing.vert │ │ │ ├── SharpenEdgesFP.glsl │ │ │ ├── ShowNormals.glsl │ │ │ ├── ShowTangents.glsl │ │ │ ├── ShowUV.glsl │ │ │ ├── ShowUVdir3D.glsl │ │ │ ├── StdQuad_Tex2_vp.glsl │ │ │ ├── StdQuad_Tex2a_vp.glsl │ │ │ ├── StdQuad_Tex3_vp.glsl │ │ │ ├── StdQuad_Tex4_vp.glsl │ │ │ ├── StdQuad_vp.glsl │ │ │ ├── SwizzleGP.glsl │ │ │ ├── TessellateTetrahedraGS.glsl │ │ │ ├── TilingFP.glsl │ │ │ ├── VTFInstancing.vert │ │ │ ├── crowdVp.glsl │ │ │ ├── hdr_bloom.glsl │ │ │ ├── hdr_downscale2x2luminence.glsl │ │ │ ├── hdr_downscale3x3.glsl │ │ │ ├── hdr_downscale3x3brightpass.glsl │ │ │ ├── hdr_finalToneMapping.glsl │ │ │ ├── hdr_tonemap_util.glsl │ │ │ ├── instancingVp.glsl │ │ │ ├── mrttestfp_quad.glsl │ │ │ ├── mrttestfp_scene.glsl │ │ │ ├── oceanGLSL.frag │ │ │ ├── oceanGLSL.vert │ │ │ ├── pssmCasterFp.glsl │ │ │ ├── pssmCasterVp.glsl │ │ │ ├── pssmReceiverFp.glsl │ │ │ ├── pssmReceiverVp.glsl │ │ │ ├── shadows.glsl │ │ │ ├── skinningTwoWeightsShadowCasterVp.glsl │ │ │ └── skinningTwoWeightsVp.glsl │ │ └── skinningTwoWeightsVp.glsl │ ├── scripts │ │ └── QBuild.material │ └── textures │ │ └── grass_1024.jpg ├── models │ ├── Rumba Dancing.fbx │ ├── Twist Dance.fbx │ ├── ninja.mesh │ ├── ninja.skeleton │ ├── robot.mesh │ └── robot.skeleton └── packs │ ├── OgreCore.zip │ └── SdkTrays.zip ├── pull_request_template.md ├── resources ├── addVertice.png ├── capsule.png ├── cone.png ├── cube.png ├── cylinder.png ├── icon.icns ├── icone.ico ├── icone.rc ├── move.png ├── pause.png ├── play.png ├── remove.png ├── resource.qrc ├── rotacionar.png ├── roundedbox.png ├── selecionar.png ├── sphere.png ├── spring.png ├── square.png └── torus.png ├── sonar-project.properties ├── src ├── AnimationWidget.cpp ├── AnimationWidget.h ├── Assimp │ ├── AnimationProcessor.cpp │ ├── AnimationProcessor.h │ ├── AnimationProcessor_test.cpp │ ├── BoneProcessor.cpp │ ├── BoneProcessor.h │ ├── BoneProcessor_test.cpp │ ├── CMakeLists.txt │ ├── Importer.cpp │ ├── Importer.h │ ├── MaterialProcessor.cpp │ ├── MaterialProcessor.h │ ├── MaterialProcessor_test.cpp │ ├── MeshProcessor.cpp │ ├── MeshProcessor.h │ └── MeshProcessor_test.cpp ├── CMakeLists.txt ├── EditorViewport.cpp ├── EditorViewport.h ├── Euler.h ├── GlobalDefinitions.h ├── Info.plist.in ├── Manager.cpp ├── Manager.h ├── Manager_test.cpp ├── MaterialComboDelegate.cpp ├── MaterialComboDelegate.h ├── MaterialHighlighter.cpp ├── MaterialHighlighter.h ├── MaterialHighlighter_test.cpp ├── MaterialWidget.cpp ├── MaterialWidget.h ├── MaterialWidget_test.cpp ├── MeshImporterExporter.cpp ├── MeshImporterExporter.h ├── MeshImporterExporter_test.cpp ├── MeshTransform.cpp ├── MeshTransform.h ├── ObjectItemModel.cpp ├── ObjectItemModel.h ├── OgreWidget.cpp ├── OgreWidget.h ├── OgreXML │ ├── CMakeLists.txt │ ├── OgreXMLMeshSerializer.cpp │ ├── OgreXMLMeshSerializer.h │ ├── OgreXMLPrerequisites.h │ ├── OgreXMLSkeletonSerializer.cpp │ ├── OgreXMLSkeletonSerializer.h │ ├── pugiconfig.hpp │ ├── pugixml.cpp │ ├── pugixml.hpp │ ├── tinystr.cpp │ ├── tinystr.h │ ├── tinyxml.cpp │ ├── tinyxml.h │ ├── tinyxmlerror.cpp │ └── tinyxmlparser.cpp ├── PrimitiveObject.cpp ├── PrimitiveObject.h ├── PrimitiveObject_test.cpp ├── PrimitivesWidget.cpp ├── PrimitivesWidget.h ├── PrimitivesWidget_test.cpp ├── QtInputManager.cpp ├── QtInputManager.h ├── QtKeyListener.h ├── QtMouseListener.h ├── RotationGizmo.cpp ├── RotationGizmo.h ├── RotationGizmo_test.cpp ├── SelectionBoxObject.cpp ├── SelectionBoxObject.h ├── SelectionSet.cpp ├── SelectionSet.h ├── SelectionSet_test.cpp ├── SkeletonDebug.cpp ├── SkeletonDebug.h ├── SkeletonDebug_test.cpp ├── SkeletonTransform.cpp ├── SkeletonTransform.h ├── SpaceCamera.cpp ├── SpaceCamera.h ├── SpaceCamera_test.cpp ├── TransformOperator.cpp ├── TransformOperator.h ├── TransformOperator_test.cpp ├── TransformWidget.cpp ├── TransformWidget.h ├── TransformWidget_test.cpp ├── TranslationGizmo.cpp ├── TranslationGizmo.h ├── TranslationGizmo_test.cpp ├── ViewportGrid.cpp ├── ViewportGrid.h ├── about.cpp ├── about.h ├── about_test.cpp ├── animationcontrolslider.cpp ├── animationcontrolslider.h ├── animationcontrolwidget.cpp ├── animationcontrolwidget.h ├── dependencies │ └── zlib1.dll ├── main.cpp ├── main_test.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow_test.cpp ├── material.cpp ├── material.h ├── materialeditor.cpp ├── materialeditor.h └── materialeditor_test.cpp └── ui_files ├── CMakeLists.txt ├── PrimitivesWidget.ui ├── TransformWidget.ui ├── about.ui ├── animationcontrolwidget.ui ├── animationwidget.ui ├── mainwindow.ui ├── material.ui └── materialeditor.ui /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | checks: 3 | argument-count: 4 | enabled: true 5 | config: 6 | threshold: 4 7 | complex-logic: 8 | enabled: true 9 | config: 10 | threshold: 4 11 | file-lines: 12 | enabled: true 13 | config: 14 | threshold: 250 15 | method-complexity: 16 | enabled: true 17 | config: 18 | threshold: 5 19 | method-count: 20 | enabled: true 21 | config: 22 | threshold: 20 23 | method-lines: 24 | enabled: true 25 | config: 26 | threshold: 25 27 | nested-control-flow: 28 | enabled: true 29 | config: 30 | threshold: 4 31 | return-statements: 32 | enabled: true 33 | config: 34 | threshold: 4 35 | similar-code: 36 | enabled: true 37 | config: 38 | threshold: 10 39 | identical-code: 40 | enabled: true 41 | config: 42 | threshold: 10 43 | plugins: 44 | standard: 45 | enabled: true 46 | structure: 47 | enabled: true 48 | duplication: 49 | enabled: true 50 | fixme: 51 | enabled: true 52 | cppcheck: 53 | enabled: true 54 | config: 55 | check: all 56 | standard: "cpp17" 57 | library: googletest 58 | exclude_patterns: 59 | - "src/OgreXML/*.*" 60 | - "src/dependencies/ogre-procedural/library/src/*.*" 61 | - "src/UnitTests_autogen/**/*.cpp" 62 | - "*_autogen*" 63 | - "src/dependencies/**/*.*" 64 | - "**/CMakeFiles/*" 65 | - "_deps/**/*.*" 66 | - "ui_files/" 67 | - "moc_*" 68 | - "media/" 69 | - "lib/" 70 | - "bin/" 71 | - "cfg/" 72 | - "*.cc" 73 | - "*.md" 74 | - "*.in" 75 | - "*.yml" 76 | - "*.cmake" 77 | - "*.txt" 78 | - "makefile" 79 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | 12 | 13 | **To Reproduce** 14 | 19 | 20 | **Expected behavior** 21 | 22 | 23 | **Screenshots** 24 | 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | 29 | **Additional context** 30 | 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | 12 | 13 | **Describe the solution you'd like** 14 | 15 | 16 | **Describe alternatives you've considered** 17 | 18 | 19 | **Additional context** 20 | 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.dll 2 | *.obj 3 | *.exe 4 | *.cfg 5 | *.pro 6 | *.pro.* 7 | *.docx 8 | *Makefile 9 | Dependencies/* 10 | release/* 11 | bin/* 12 | lib/* 13 | debug/* 14 | src/ogre-assimp/CMakeFiles/ 15 | src\moc_* 16 | CMakeCache.txt* 17 | CMakeFiles/ 18 | moc_* 19 | ui_files/ 20 | ui_* 21 | *.log 22 | *.cmake 23 | *.user 24 | *.qtc_clangd* 25 | _CPack_Packages/* 26 | _deps/* 27 | *_autogen/* 28 | .vscode/* 29 | src/QtMeshEditor_autogen/* 30 | src/UnitTests_autogen/* 31 | src/__/* 32 | src/qrc_resource.cpp 33 | **/.cache/* 34 | compile_commands.json 35 | install_manifest.txt 36 | .ninja_deps 37 | .ninja_log 38 | build.ninja 39 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/dependencies/ogre-procedural"] 2 | path = src/dependencies/ogre-procedural 3 | url = https://github.com/fernandotonon/ogre-procedural.git 4 | -------------------------------------------------------------------------------- /CMakeModules/FindZLIB.cmake: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------- 2 | # This file is part of the CMake build system for OGRE 3 | # (Object-oriented Graphics Rendering Engine) 4 | # For the latest info, see http://www.ogre3d.org/ 5 | # 6 | # The contents of this file are placed in the public domain. Feel 7 | # free to make use of it in any way you like. 8 | #------------------------------------------------------------------- 9 | 10 | # - Try to find ZLIB 11 | # Once done, this will define 12 | # 13 | # ZLIB_FOUND - system has ZLIB 14 | # ZLIB_INCLUDE_DIRS - the ZLIB include directories 15 | # ZLIB_LIBRARIES - link these to use ZLIB 16 | 17 | include(FindPkgMacros) 18 | findpkg_begin(ZLIB) 19 | 20 | # Get path, convert backslashes as ${ENV_${var}} 21 | getenv_path(ZLIB_HOME) 22 | 23 | # construct search paths 24 | set(ZLIB_PREFIX_PATH ${ZLIB_HOME} ${ENV_ZLIB_HOME}) 25 | create_search_paths(ZLIB) 26 | # redo search if prefix path changed 27 | clear_if_changed(ZLIB_PREFIX_PATH 28 | ZLIB_LIBRARY_FWK 29 | ZLIB_LIBRARY_REL 30 | ZLIB_LIBRARY_DBG 31 | ZLIB_INCLUDE_DIR 32 | ) 33 | 34 | set(ZLIB_LIBRARY_NAMES z zlib zdll) 35 | get_debug_names(ZLIB_LIBRARY_NAMES) 36 | 37 | use_pkgconfig(ZLIB_PKGC zzip-zlib-config) 38 | 39 | findpkg_framework(ZLIB) 40 | 41 | find_path(ZLIB_INCLUDE_DIR NAMES zlib.h HINTS ${ZLIB_INC_SEARCH_PATH} ${ZLIB_PKGC_INCLUDE_DIRS}) 42 | find_library(ZLIB_LIBRARY_REL NAMES ${ZLIB_LIBRARY_NAMES} HINTS ${ZLIB_LIB_SEARCH_PATH} ${ZLIB_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel) 43 | find_library(ZLIB_LIBRARY_DBG NAMES ${ZLIB_LIBRARY_NAMES_DBG} HINTS ${ZLIB_LIB_SEARCH_PATH} ${ZLIB_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug) 44 | 45 | make_library_set(ZLIB_LIBRARY) 46 | 47 | findpkg_finish(ZLIB) 48 | 49 | -------------------------------------------------------------------------------- /CMakeModules/PreprocessorUtils.cmake: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------- 2 | # This file is part of the CMake build system for OGRE 3 | # (Object-oriented Graphics Rendering Engine) 4 | # For the latest info, see http://www.ogre3d.org/ 5 | # 6 | # The contents of this file are placed in the public domain. Feel 7 | # free to make use of it in any way you like. 8 | #------------------------------------------------------------------- 9 | 10 | macro(get_preprocessor_entry CONTENTS KEYWORD VARIABLE) 11 | string(REGEX MATCH 12 | "# *define +${KEYWORD} +((\"([^\n]*)\")|([^ \n]*))" 13 | PREPROC_TEMP_VAR 14 | ${${CONTENTS}} 15 | ) 16 | if (CMAKE_MATCH_3) 17 | set(${VARIABLE} ${CMAKE_MATCH_3}) 18 | else () 19 | set(${VARIABLE} ${CMAKE_MATCH_4}) 20 | endif () 21 | endmacro() 22 | 23 | macro(has_preprocessor_entry CONTENTS KEYWORD VARIABLE) 24 | string(REGEX MATCH 25 | "\n *# *define +(${KEYWORD})" 26 | PREPROC_TEMP_VAR 27 | ${${CONTENTS}} 28 | ) 29 | if (CMAKE_MATCH_1) 30 | set(${VARIABLE} TRUE) 31 | else () 32 | set(${VARIABLE} FALSE) 33 | endif () 34 | endmacro() 35 | 36 | macro(replace_preprocessor_entry VARIABLE KEYWORD NEW_VALUE) 37 | string(REGEX REPLACE 38 | "(// *)?# *define +${KEYWORD} +[^ \n]*" 39 | "#define ${KEYWORD} ${NEW_VALUE}" 40 | ${VARIABLE}_TEMP 41 | ${${VARIABLE}} 42 | ) 43 | set(${VARIABLE} ${${VARIABLE}_TEMP}) 44 | endmacro() 45 | 46 | macro(set_preprocessor_entry VARIABLE KEYWORD ENABLE) 47 | if (${ENABLE}) 48 | set(TMP_REPLACE_STR "#define ${KEYWORD}") 49 | else () 50 | set(TMP_REPLACE_STR "// #define ${KEYWORD}") 51 | endif () 52 | string(REGEX REPLACE 53 | "(// *)?# *define +${KEYWORD} *\n" 54 | ${TMP_REPLACE_STR} 55 | ${VARIABLE}_TEMP 56 | ${${VARIABLE}} 57 | ) 58 | set(${VARIABLE} ${${VARIABLE}_TEMP}) 59 | endmacro() 60 | 61 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | Feel free to contribute ;) 3 | -------------------------------------------------------------------------------- /DEBIAN-control.in: -------------------------------------------------------------------------------- 1 | Package: qtmesheditor 2 | Version: @PROJECT_VERSION@ 3 | Section: editors 4 | Priority: extra 5 | Installed-Size: 757000 6 | Architecture: amd64 7 | Origin: ubuntu 8 | Bugs: https://github.com/fernandotonon/QtMeshEditor/issues 9 | Homepage: https://github.com/fernandotonon/QtMeshEditor 10 | Depends: libxcb-cursor0 11 | Maintainer: Fernando Tonon de Rossi 12 | Description: It is a graphical editor for Ogre3D mesh and material 13 | I have made this editor to make it easier to change the meshes instead of using the meshmagick and meshupgrader, it is not finished yet, but the main operations are implemented, I hope it helps someone... :) 14 | -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | MIT License. 2 | 3 | Copyright (c) 2012-2023 QtMeshEditor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Currently we only support the latest version, please, keep your software up to date. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | To report a vulnerability, please add an Issue on the project GitHub page. 10 | -------------------------------------------------------------------------------- /cfg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #Copy required file in the exe directory 2 | set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL}) 3 | 4 | IF(WIN32) 5 | set(PLUGIN_DEBUG_POSTFIX "_d") 6 | ELSE() 7 | set(PLUGIN_DEBUG_POSTFIX "") 8 | 9 | ENDIF(WIN32) 10 | 11 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 12 | IF(WIN32) 13 | set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) 14 | ENDIF(WIN32) 15 | 16 | configure_file ( 17 | "${CMAKE_CURRENT_SOURCE_DIR}/plugins_d.cfg.in" 18 | "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cfg/plugins_d.cfg" 19 | @ONLY) 20 | 21 | configure_file ( 22 | "${CMAKE_CURRENT_SOURCE_DIR}/resources_d.cfg.in" 23 | "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cfg/resources_d.cfg" 24 | @ONLY) 25 | else() 26 | configure_file ( 27 | "${CMAKE_CURRENT_SOURCE_DIR}/plugins.cfg.in" 28 | "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cfg/plugins.cfg" 29 | @ONLY) 30 | 31 | configure_file ( 32 | "${CMAKE_CURRENT_SOURCE_DIR}/resources.cfg.in" 33 | "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cfg/resources.cfg" 34 | @ONLY) 35 | 36 | 37 | endif() 38 | configure_file ( 39 | "${CMAKE_CURRENT_SOURCE_DIR}/version.txt.in" 40 | "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cfg/version.txt" 41 | @ONLY) 42 | 43 | FILE(GLOB CFG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*) 44 | 45 | #Copy all file/tree in the exe directory 46 | #file(COPY ${CMAKE_CURRENT_SOURCE_DIR} 47 | # DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) 48 | 49 | add_custom_target(_cfg SOURCES ${CFG_FILES}) 50 | 51 | 52 | -------------------------------------------------------------------------------- /cfg/plugins.cfg.in: -------------------------------------------------------------------------------- 1 | # Defines plugins to load 2 | 3 | # Define plugin folder 4 | PluginFolder=@PLUGIN_DIR@ 5 | # PluginFolder=../ 6 | 7 | # Define plugins 8 | Plugin=RenderSystem_GL 9 | #Plugin=RenderSystem_GL3Plus 10 | Plugin=Plugin_OctreeSceneManager 11 | Plugin=Codec_STBI 12 | #Plugin=Plugin_CgProgramManager 13 | -------------------------------------------------------------------------------- /cfg/plugins_d.cfg.in: -------------------------------------------------------------------------------- 1 | # Defines plugins to load 2 | 3 | # Define plugin folder 4 | PluginFolder=@PLUGIN_DIR@ 5 | 6 | # Define plugins 7 | Plugin=RenderSystem_GL@PLUGIN_DEBUG_POSTFIX@ 8 | Plugin=Plugin_OctreeSceneManager@PLUGIN_DEBUG_POSTFIX@ 9 | #Plugin=Plugin_CgProgramManager 10 | -------------------------------------------------------------------------------- /cfg/resources.cfg.in: -------------------------------------------------------------------------------- 1 | # Resource locations to be added to the 'boostrap' path 2 | # This also contains the minimum you need to use the Ogre example framework 3 | #[Essential] 4 | #Zip=OgreCore.zip 5 | #Zip=SdkTrays.zip 6 | 7 | 8 | # Resource locations to be added to the default path 9 | [General] 10 | #FileSystem=media/models 11 | #FileSystem=media/materials/programs 12 | #FileSystem=media/materials/programs/GLSL 13 | FileSystem=media/materials/scripts 14 | FileSystem=media/materials/textures 15 | -------------------------------------------------------------------------------- /cfg/resources_d.cfg.in: -------------------------------------------------------------------------------- 1 | # Resource locations to be added to the 'boostrap' path 2 | # This also contains the minimum you need to use the Ogre example framework 3 | #[Essential] 4 | #Zip=./../media/OgreCore.zip 5 | #Zip=./../media/SdkTrays.zip 6 | 7 | 8 | # Resource locations to be added to the default path 9 | [General] 10 | #FileSystem=media/models 11 | #FileSystem=media/materials/programs 12 | #FileSystem=media/materials/programs/GLSL 13 | FileSystem=media/materials/scripts 14 | FileSystem=media/materials/textures 15 | -------------------------------------------------------------------------------- /cfg/version.txt.in: -------------------------------------------------------------------------------- 1 | @QTMESHEDITOR_VERSION_STRING@ 2 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | Hello QtMeshEditor! 2 | 3 | ✨ Features 4 | * Mesh 5 | Translation, Scale, and Rotation (Easier than OgreMeshMagick) 6 | Change the material of the mesh 7 | - Allows the change of the mesh material 8 | Primitives creation, using ogre-procedural 9 | -Easy tool to create Box, Sphere, and Plane 10 | * Material 11 | Shows in real time the material changes on the model 12 | Material can be edited using GUI or code editor 13 | * Skeleton 14 | View the bones 15 | Animation Preview 16 | - Shows a list of animations and allows the animation preview. 17 | Renaming Animation 18 | View keyframes positions and values 19 | * Import/Export 20 | Export mesh in older versions 21 | Other 3D Format Importer - Can be used to convert any 3D format provided by ASSIMP to Ogre Mesh, Material and Skeleton 22 | -------------------------------------------------------------------------------- /media/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB_RECURSE MEDIA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*) 2 | 3 | #Copy all file/tree in the exe directory 4 | #file(COPY ${CMAKE_CURRENT_SOURCE_DIR} 5 | # DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) 6 | 7 | add_custom_target(media SOURCES ${MEDIA_FILES}) 8 | 9 | 10 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 11 | DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) 12 | -------------------------------------------------------------------------------- /media/materials/programs/AmbientOneTexture.glsl: -------------------------------------------------------------------------------- 1 | uniform vec4 ambient; 2 | 3 | /* 4 | Basic ambient lighting vertex program 5 | */ 6 | void main() 7 | { 8 | gl_Position = ftransform(); 9 | gl_TexCoord[0] = gl_MultiTexCoord0; 10 | gl_FrontColor = ambient; 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL/DiffuseOneTexture.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D texMap; 4 | 5 | in vec4 colour; 6 | in vec4 uv; 7 | 8 | out vec4 fragColour; 9 | 10 | /* 11 | Basic fragment program using texture and diffuse colour. 12 | */ 13 | void main() 14 | { 15 | fragColour = texture(texMap, uv.xy) * colour; 16 | } 17 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL/PassthroughFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 colour; 4 | out vec4 fragColour; 5 | 6 | /* 7 | Basic ambient lighting fragment program for GLSL ES 8 | */ 9 | void main() 10 | { 11 | fragColour = colour; 12 | } 13 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL/skinningTwoWeightsShadowCasterVp.glsl: -------------------------------------------------------------------------------- 1 | // Example GLSL program for skinning with two bone weights per vertex 2 | 3 | attribute vec4 vertex; 4 | attribute vec4 uv0; 5 | attribute vec4 blendIndices; 6 | attribute vec4 blendWeights; 7 | 8 | // 3x4 matrix, passed as vec4's for compatibility with GL 2.0 9 | // GL 2.0 supports 3x4 matrices 10 | // Support 24 bones ie 24*3, but use 72 since our parser can pick that out for sizing 11 | uniform vec4 worldMatrix3x4Array[72]; 12 | uniform mat4 viewProjectionMatrix; 13 | uniform vec4 ambient; 14 | 15 | void main() 16 | { 17 | vec3 blendPos = vec3(0,0,0); 18 | 19 | for (int bone = 0; bone < 2; ++bone) 20 | { 21 | // perform matrix multiplication manually since no 3x4 matrices 22 | // ATI GLSL compiler can't handle indexing an array within an array so calculate the inner index first 23 | int idx = int(blendIndices[bone]) * 3; 24 | // ATI GLSL compiler can't handle unrolling the loop so do it manually 25 | // ATI GLSL has better performance when mat4 is used rather than using individual dot product 26 | // There is a bug in ATI mat4 constructor (Cat 7.2) when indexed uniform array elements are used as vec4 parameter so manually assign 27 | mat4 worldMatrix; 28 | worldMatrix[0] = worldMatrix3x4Array[idx]; 29 | worldMatrix[1] = worldMatrix3x4Array[idx + 1]; 30 | worldMatrix[2] = worldMatrix3x4Array[idx + 2]; 31 | worldMatrix[3] = vec4(0); 32 | // now weight this into final 33 | blendPos += (vertex * worldMatrix).xyz * blendWeights[bone]; 34 | } 35 | 36 | // apply view / projection to position 37 | gl_Position = viewProjectionMatrix * vec4(blendPos, 1); 38 | 39 | gl_FrontSecondaryColor = vec4(0,0,0,0); 40 | gl_FrontColor = ambient; 41 | gl_TexCoord[0] = uv0; 42 | } 43 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ASCIIFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 pos; 4 | in vec2 oUv0; 5 | out vec4 fragColour; 6 | 7 | uniform sampler2D RT; 8 | uniform sampler3D chars; 9 | uniform vec2 numTiles; 10 | uniform vec2 iNumTiles; 11 | uniform vec2 iNumTiles2; 12 | uniform vec4 lum; 13 | uniform float charBias; 14 | 15 | void main() 16 | { 17 | vec3 local; 18 | 19 | //sample RT 20 | local.xy = mod(oUv0, iNumTiles); 21 | vec2 middle = oUv0 - local.xy; 22 | local.xy = local.xy * numTiles; 23 | 24 | //iNumTiles2 = iNumTiles / 2 25 | middle = middle + iNumTiles2; 26 | vec4 c = texture(RT, middle); 27 | 28 | //multiply luminance by charbias , beacause not all slices of the ascii 29 | //volume texture are used 30 | local.z = dot(c , lum)*charBias; 31 | 32 | //fix to brighten the dark pixels with small characters 33 | //c *= lerp(2.0,1.0, local.z); 34 | 35 | c *= texture(chars, local); 36 | fragColour = c; 37 | } 38 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/AmbientOneTexture.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 ambient; 4 | uniform mat4 worldViewProj; 5 | 6 | in vec4 position; 7 | 8 | out vec4 colour; 9 | 10 | /* 11 | Basic ambient lighting vertex program for GLSL 12 | */ 13 | void main() 14 | { 15 | gl_Position = worldViewProj * position; 16 | colour = ambient; 17 | } 18 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/AmbientOneTextureWithUV.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 ambient; 4 | uniform mat4 worldViewProj; 5 | 6 | in vec4 position; 7 | in vec4 uv0; 8 | 9 | out vec4 ambColour; 10 | out vec4 ambientUV; 11 | 12 | /* 13 | Basic ambient lighting vertex program for GLSL 14 | */ 15 | void main() 16 | { 17 | gl_Position = worldViewProj * position; 18 | ambColour = ambient; 19 | ambientUV = uv0; 20 | } 21 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Bloom2_ps20.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | //------------------------------- 4 | //Bloom_ps20.glsl 5 | // Blends using weights the blurred image with the sharp one 6 | // Params: 7 | // OriginalImageWeight 8 | // BlurWeight 9 | //------------------------------- 10 | 11 | uniform sampler2D RT; 12 | uniform sampler2D Blur1; 13 | 14 | uniform float OriginalImageWeight; 15 | uniform float BlurWeight; 16 | 17 | out vec4 fragColour; 18 | in vec2 texCoord[5]; 19 | 20 | void main() 21 | { 22 | vec4 sharp; 23 | vec4 blur; 24 | 25 | 26 | sharp = texture(RT, texCoord[0]); 27 | blur = texture(Blur1, texCoord[0]); 28 | 29 | fragColour = ( (blur * BlurWeight) + (sharp * OriginalImageWeight) ); 30 | //fragColour = vec4(0); 31 | } 32 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Blur0_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | out vec2 texCoord[5]; 4 | in vec4 vertex; 5 | 6 | uniform mat4 worldViewProj; 7 | in vec2 uv0; 8 | 9 | void main() 10 | { 11 | gl_Position = worldViewProj * vertex; 12 | 13 | texCoord[0] = uv0; 14 | 15 | const float size = 0.01; 16 | texCoord[1] = texCoord[0] + vec2(1.0, 0.0)*size; 17 | texCoord[2] = texCoord[0] + vec2(2.0, 0.0)*size; 18 | texCoord[3] = texCoord[0] + vec2(-1.0, 0.0)*size; 19 | texCoord[4] = texCoord[0] + vec2(-2.0, 0.0)*size; 20 | } 21 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Blur1_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 worldViewProj; 4 | 5 | out vec2 texCoord[5]; 6 | in vec4 vertex; 7 | in vec2 uv0; 8 | 9 | void main() 10 | { 11 | gl_Position = worldViewProj * vertex; 12 | 13 | texCoord[0] = uv0; 14 | 15 | const float size = 0.01; 16 | texCoord[1] = texCoord[0] + vec2(0.0, 1.0)*size; 17 | texCoord[2] = texCoord[0] + vec2(0.0, 2.0)*size; 18 | texCoord[3] = texCoord[0] + vec2(0.0, -1.0)*size; 19 | texCoord[4] = texCoord[0] + vec2(0.0, -2.0)*size; 20 | } 21 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/BlurH_ps20.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | //------------------------------- 4 | //BlurH_ps20.glsl 5 | // Horizontal Gaussian-Blur pass 6 | //------------------------------- 7 | 8 | uniform sampler2D Blur0; 9 | out vec4 fragColour; 10 | in vec2 texCoord[5]; 11 | 12 | vec2 pos[11] = vec2[11] 13 | ( 14 | vec2( -5, 0), 15 | vec2( -4, 0), 16 | vec2( -3, 0), 17 | vec2( -2, 0), 18 | vec2( -1, 0), 19 | vec2( 0, 0), 20 | vec2( 1, 0), 21 | vec2( 2, 0), 22 | vec2( 3, 0), 23 | vec2( 4, 0), 24 | vec2( 5, 0) 25 | ); 26 | 27 | //We use the Normal-gauss distribution formula 28 | //f(x) being the formula, we used f(0.5)-f(-0.5); f(1.5)-f(0.5)... 29 | float samples[11] = float[11] 30 | (//stddev=2.0 31 | 0.01222447, 32 | 0.02783468, 33 | 0.06559061, 34 | 0.12097757, 35 | 0.17466632, 36 | 37 | 0.19741265, 38 | 39 | 0.17466632, 40 | 0.12097757, 41 | 0.06559061, 42 | 0.02783468, 43 | 0.01222447 44 | ); 45 | 46 | void main() 47 | { 48 | vec4 retVal; 49 | 50 | vec4 sum = vec4( 0 ); 51 | 52 | for( int i=0;i < 11; i++ ) 53 | { 54 | sum += texture( Blur0, texCoord[0] + (pos[i] * 0.0100000) ) * samples[i]; 55 | } 56 | 57 | fragColour = sum; 58 | } 59 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/BlurV_ps20.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // Note, this won't work on ATI which is why it's not used 4 | // the issue is with the array initializers 5 | // no card supports GL_3DL_array_objects but it does work on nvidia, not on ATI 6 | //#extension GL_3DL_array_objects : enable 7 | 8 | //------------------------------- 9 | //BlurV_ps20.glsl 10 | // Vertical Gaussian-Blur pass 11 | //------------------------------- 12 | 13 | uniform sampler2D Blur0; 14 | out vec4 fragColour; 15 | in vec2 texCoord[5]; 16 | 17 | vec2 pos[11] = vec2[11]( 18 | vec2(0.0, -5.0), 19 | vec2(0.0, -4.0), 20 | vec2(0.0, -3.0), 21 | vec2(0.0, -2.0), 22 | vec2(0.0, -1.0), 23 | vec2(0.0, 0.0), 24 | vec2(0.0, 1.0), 25 | vec2(0.0, 2.0), 26 | vec2(0.0, 3.0), 27 | vec2(0.0, 4.0), 28 | vec2(0.0, 5.0) 29 | ); 30 | 31 | //We use the Normal-gauss distribution formula 32 | //f(x) being the formula, we used f(0.5)-f(-0.5); f(1.5)-f(0.5)... 33 | float samples[11] = float[11] 34 | (//stddev=2.0 35 | 0.01222447, 36 | 0.02783468, 37 | 0.06559061, 38 | 0.12097757, 39 | 0.17466632, 40 | 41 | 0.19741265, 42 | 43 | 0.17466632, 44 | 0.12097757, 45 | 0.06559061, 46 | 0.02783468, 47 | 0.01222447 48 | ); 49 | 50 | void main() 51 | { 52 | vec4 retVal; 53 | 54 | vec4 sum; 55 | int i = 0; 56 | 57 | sum = vec4( 0 ); 58 | for( ;i < 11; i++ ) 59 | { 60 | sum += texture( Blur0, texCoord[0] + (pos[i] * 0.0100000) ) * samples[i]; 61 | } 62 | 63 | fragColour = sum; 64 | } 65 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Blur_ps.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D tex0; 4 | 5 | in vec2 texCoord[5]; 6 | 7 | out vec4 fragColour; 8 | 9 | void main() 10 | { 11 | vec4 sum = texture(tex0, texCoord[0]) + 12 | texture(tex0, texCoord[1]) + 13 | texture(tex0, texCoord[2]) + 14 | texture(tex0, texCoord[3]) + 15 | texture(tex0, texCoord[4]); 16 | fragColour = sum / 5.0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Blur_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 vertex; 4 | out vec2 texCoord[5]; 5 | 6 | uniform mat4 worldViewProj; 7 | in vec2 uv0; 8 | 9 | void main() 10 | { 11 | gl_Position = worldViewProj * vertex; 12 | 13 | texCoord[0] = uv0; 14 | 15 | const float size = 0.01; 16 | texCoord[1] = uv0 + vec2(0.0, 1.0)*size; 17 | texCoord[2] = uv0 + vec2(0.0, 2.0)*size; 18 | texCoord[3] = uv0 + vec2(0.0, -1.0)*size; 19 | texCoord[4] = uv0 + vec2(0.0, -2.0)*size; 20 | } 21 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/BrightBloom2_ps20.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | //------------------------------- 4 | //BrightBloom_ps20.glsl 5 | // High-pass filter for obtaining lumminance 6 | // We use an aproximation formula that is pretty fast: 7 | // f(x) = ( -3 * ( x - 1 )^2 + 1 ) * 2 8 | // Color += Grayscale( f(Color) ) + 0.6 9 | // 10 | // Special thanks to ATI for their great HLSL2GLSL utility 11 | // http://sourceforge.net/projects/hlsl2glsl 12 | //------------------------------- 13 | 14 | uniform sampler2D RT; 15 | out vec4 fragColour; 16 | in vec2 oUv0; 17 | 18 | void main() 19 | { 20 | vec4 tex; 21 | vec4 bright4; 22 | float bright; 23 | 24 | vec2 texCoord = oUv0.xy; 25 | 26 | tex = texture( RT, texCoord); 27 | tex -= 1.00000; 28 | bright4 = -6.00000 * tex * tex + 2.00000; 29 | bright = dot( bright4, vec4( 0.333333, 0.333333, 0.333333, 0.000000) ); 30 | tex += (bright + 0.600000); 31 | 32 | fragColour = tex; 33 | } 34 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/BumpMapVPTangentParity.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | /* Bump mapping vertex program 4 | In this program, we want to calculate the tangent space light vector 5 | on a per-vertex level which will get passed to the fragment program, 6 | or to the fixed function dot3 operation, to produce the per-pixel 7 | lighting effect. 8 | */ 9 | // parameters 10 | uniform vec4 lightPosition; // object space 11 | uniform mat4 worldViewProj; 12 | uniform vec4 lightDiffuse; 13 | 14 | in vec4 vertex; 15 | in vec3 normal; 16 | in vec4 tangent; 17 | in vec2 uv0; 18 | 19 | out vec2 oUv0; 20 | out vec3 oTSLightDir; 21 | out vec4 colour; 22 | 23 | void main() 24 | { 25 | // Calculate output position 26 | gl_Position = worldViewProj * vertex; 27 | 28 | // Pass the main uvs straight through unchanged 29 | oUv0 = uv0; 30 | 31 | // Calculate tangent space light vector 32 | // Get object space light direction 33 | // Non-normalised since we'll do that in the fragment program anyway 34 | vec3 lightDir = lightPosition.xyz - (vertex * lightPosition.w).xyz; 35 | 36 | // Calculate the binormal (NB we assume both normal and tangent are 37 | // already normalised) 38 | 39 | // Fixed handedness 40 | vec3 binormal = cross(normal, tangent.xyz) * tangent.www; 41 | 42 | // Form a rotation matrix out of the vectors, column major for glsl es 43 | mat3 rotation = mat3(tangent.xyz,binormal,normal); 44 | // mat3 rotation = mat3(vec3(tangent[0], binormal[0], normal[0]), 45 | // vec3(tangent[1], binormal[1], normal[1]), 46 | // vec3(tangent[2], binormal[2], normal[2])); 47 | 48 | // Transform the light vector according to this matrix 49 | oTSLightDir = rotation * lightDir; 50 | colour = lightDiffuse; 51 | } 52 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ColdCasterFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec2 NDotV; 4 | out vec4 fragColour; 5 | 6 | void main() 7 | { 8 | fragColour = vec4(NDotV.x / 2.0); 9 | } 10 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ColdCasterVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 worldViewProj; 4 | uniform vec3 eyePosition; 5 | in vec4 position; 6 | in vec4 normal; 7 | out vec2 NDotV; 8 | 9 | void main() 10 | { 11 | vec4 eyeDir = vec4(eyePosition - position.xyz, 0.0); 12 | eyeDir = normalize(eyeDir); 13 | gl_Position = worldViewProj * position; 14 | NDotV = vec2(clamp( dot( normal, eyeDir ), 0.0, 1.0 )); 15 | } 16 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Combine_fp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D RT; 4 | uniform sampler2D Sum; 5 | uniform float blur; 6 | 7 | in vec2 oUv0; 8 | out vec4 fragColour; 9 | 10 | void main() 11 | { 12 | vec4 render = texture(RT, oUv0); 13 | vec4 sum = texture(Sum, oUv0); 14 | 15 | fragColour = mix(render, sum, blur); 16 | } 17 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/DepthShadowmapCasterFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec2 depth; 4 | //out vec4 fragColour; 5 | 6 | void main() 7 | { 8 | #if LINEAR_RANGE 9 | float finalDepth = depth.x; 10 | #else 11 | float finalDepth = depth.x;// / depth.y; 12 | #endif 13 | // just smear across all components 14 | // therefore this one needs high individual channel precision 15 | // fragColour = vec4(finalDepth, finalDepth, finalDepth, 1); 16 | gl_FragDepth = finalDepth; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/DepthShadowmapCasterVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 worldViewProj; 4 | uniform vec4 texelOffsets; 5 | uniform vec4 depthRange; 6 | 7 | in vec4 vertex; 8 | out vec2 depth; 9 | 10 | void main() 11 | { 12 | gl_Position = worldViewProj * vertex; 13 | 14 | // fix pixel / texel alignment 15 | gl_Position.xy += texelOffsets.zw * gl_Position.w; 16 | // linear depth storage 17 | // offset / scale range output 18 | #if LINEAR_RANGE 19 | depth.x = (gl_Position.z - depthRange.x) * depthRange.w; 20 | #else 21 | depth.x = gl_Position.z; 22 | #endif 23 | depth.y = gl_Position.w; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/DepthShadowmapNormalMapReceiverVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec3 tangent; 4 | in vec3 normal; 5 | in vec4 vertex; 6 | in vec4 uv1; 7 | 8 | uniform mat4 world; 9 | uniform mat4 worldViewProj; 10 | uniform mat4 texViewProj; 11 | uniform vec4 lightPosition; // object space 12 | uniform vec4 shadowDepthRange; 13 | 14 | out vec3 tangentLightDir; 15 | out vec4 oUv0; 16 | out vec4 oUv1; 17 | 18 | void main() 19 | { 20 | gl_Position = worldViewProj * vertex; 21 | 22 | vec4 worldPos = world * vertex; 23 | 24 | // Get object space light direction 25 | vec3 lightDir = normalize(lightPosition.xyz - (vertex.xyz * lightPosition.w)); 26 | 27 | // calculate shadow map coords 28 | oUv0 = texViewProj * worldPos; 29 | #if LINEAR_RANGE 30 | // adjust by fixed depth bias, rescale into range 31 | oUv0.z = (oUv0.z - shadowDepthRange.x) * shadowDepthRange.w; 32 | #endif 33 | 34 | // pass the main uvs straight through unchanged 35 | oUv1 = uv1; 36 | 37 | // Calculate the binormal (NB we assume both normal and tangent are 38 | // already normalised) 39 | vec3 binormal = cross(normal, tangent); 40 | 41 | // Form a rotation matrix out of the vectors 42 | mat3 rotation = mat3(tangent, binormal, normal); 43 | // mat3 rotation = mat3(vec3(tangent[0], binormal[0], normal[0]), 44 | // vec3(tangent[1], binormal[1], normal[1]), 45 | // vec3(tangent[2], binormal[2], normal[2])); 46 | 47 | // Transform the light vector according to this matrix 48 | tangentLightDir = normalize(rotation * lightDir); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/DepthShadowmapReceiverFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform float inverseShadowmapSize; 4 | uniform float fixedDepthBias; 5 | uniform float gradientClamp; 6 | uniform float gradientScaleBias; 7 | uniform float shadowFuzzyWidth; 8 | 9 | uniform sampler2D shadowMap; 10 | out vec4 fragColour; 11 | in vec4 shadowUV; 12 | in vec4 oColour; 13 | 14 | void main() 15 | { 16 | float centerdepth = texture(shadowMap, shadowUV.xy).x; 17 | 18 | // gradient calculation 19 | float pixeloffset = inverseShadowmapSize; 20 | vec4 depths = vec4( 21 | texture(shadowMap, shadowUV.xy + vec2(-pixeloffset, 0)).x, 22 | texture(shadowMap, shadowUV.xy + vec2(+pixeloffset, 0)).x, 23 | texture(shadowMap, shadowUV.xy + vec2(0, -pixeloffset)).x, 24 | texture(shadowMap, shadowUV.xy + vec2(0, +pixeloffset)).x); 25 | 26 | vec2 differences = abs( depths.yw - depths.xz ); 27 | float gradient = min(gradientClamp, max(differences.x, differences.y)); 28 | float gradientFactor = gradient * gradientScaleBias; 29 | 30 | // visibility function 31 | float depthAdjust = gradientFactor + (fixedDepthBias * centerdepth); 32 | float finalCenterDepth = centerdepth + depthAdjust; 33 | 34 | // shadowUV.z contains lightspace position of current object 35 | 36 | #if FUZZY_TEST 37 | // fuzzy test - introduces some ghosting in result and doesn't appear to be needed? 38 | //float visibility = saturate(1 + delta_z / (gradient * shadowFuzzyWidth)); 39 | float visibility = saturate(1 + (finalCenterDepth - shadowUV.z) * shadowFuzzyWidth * shadowUV.w); 40 | 41 | fragColour = vertexColour * visibility; 42 | #else 43 | // hard test 44 | #if PCF 45 | // use depths from prev, calculate diff 46 | depths += depthAdjust; 47 | float final = (finalCenterDepth > shadowUV.z) ? 1.0 : 0.0; 48 | final += (depths.x > shadowUV.z) ? 1.0 : 0.0; 49 | final += (depths.y > shadowUV.z) ? 1.0 : 0.0; 50 | final += (depths.z > shadowUV.z) ? 1.0 : 0.0; 51 | final += (depths.w > shadowUV.z) ? 1.0 : 0.0; 52 | 53 | final *= 0.2; 54 | 55 | fragColour = vec4(oColour.xyz * final, 1); 56 | 57 | #else 58 | fragColour = (finalCenterDepth > shadowUV.z) ? oColour : vec4(0.5,0,0,1); 59 | #endif 60 | 61 | #endif 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/DepthShadowmapReceiverVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 world; 4 | uniform mat4 worldIT; 5 | uniform mat4 worldViewProj; 6 | uniform mat4 texViewProj; 7 | uniform vec4 lightPosition; 8 | uniform vec4 lightColour; 9 | uniform vec4 shadowDepthRange; 10 | 11 | in vec4 position; 12 | in vec3 normal; 13 | in vec4 ambient; 14 | 15 | out vec4 shadowUV; 16 | out vec4 oColour; 17 | 18 | void main() 19 | { 20 | gl_Position = worldViewProj * position; 21 | vec4 worldPos = world * position; 22 | vec3 worldNorm = (worldIT * vec4(normal, 1)).xyz; 23 | 24 | // calculate lighting (simple vertex lighting) 25 | vec3 lightDir = normalize( 26 | lightPosition.xyz - (worldPos.xyz * lightPosition.w)); 27 | 28 | oColour = lightColour * max(dot(lightDir, worldNorm), 0.0); 29 | 30 | // calculate shadow map coords 31 | shadowUV = texViewProj * worldPos; 32 | #if LINEAR_RANGE 33 | // adjust by fixed depth bias, rescale into range 34 | // shadowUV.z = (shadowUV.z - shadowDepthRange.x) * shadowDepthRange.w; 35 | shadowUV.xy = shadowUV.xy / shadowUV.w; 36 | #else 37 | shadowUV = shadowUV / shadowUV.w; 38 | #endif 39 | } 40 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/DiffuseOneTexture.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D texMap; 4 | 5 | in vec4 colour; 6 | in vec4 uv; 7 | 8 | out vec4 fragColour; 9 | 10 | /* 11 | Basic fragment program using texture and diffuse colour. 12 | */ 13 | void main() 14 | { 15 | fragColour = texture(texMap, uv.xy) * colour; 16 | } 17 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/DitherFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D RT; 4 | uniform sampler2D noise; 5 | in vec2 oUv0; 6 | 7 | out vec4 fragColour; 8 | 9 | void main() 10 | { 11 | float c = dot(texture(RT, oUv0), vec4(0.30, 0.11, 0.59, 0.00)); 12 | float n = texture(noise, oUv0).r * 2.0 - 1.0; 13 | c += n; 14 | 15 | c = step(c, 0.5); 16 | 17 | fragColour = vec4(c,c,c,1.0); 18 | } 19 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/DualQuaternion.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, vec4 dualQuaternions[24]); 4 | vec3 calculateBlendPosition(vec3 position, mat2x4 blendDQ); 5 | vec3 calculateBlendNormal(vec3 normal, mat2x4 blendDQ); 6 | 7 | uniform vec4 worldDualQuaternion2x4Array[24]; 8 | uniform mat4 viewProjectionMatrix; 9 | uniform vec4 lightPos[2]; 10 | uniform vec4 lightDiffuseColour[2]; 11 | uniform vec4 ambient; 12 | 13 | in vec4 vertex; 14 | in vec3 normal; 15 | in vec4 blendIndices; 16 | in vec4 blendWeights; 17 | in vec4 uv0; 18 | 19 | out vec4 oUv0; 20 | out vec4 ambientColour; 21 | 22 | void main() 23 | { 24 | mat2x4 blendDQ = blendTwoWeightsAntipod(blendWeights, blendIndices, worldDualQuaternion2x4Array); 25 | 26 | float len = length(blendDQ[0]); 27 | blendDQ /= len; 28 | 29 | vec3 blendPosition = calculateBlendPosition(vertex.xyz, blendDQ); 30 | 31 | //No need to normalize, the magnitude of the normal is preserved because only rotation is performed 32 | vec3 blendNormal = calculateBlendNormal(normal, blendDQ); 33 | 34 | gl_Position = viewProjectionMatrix * vec4(blendPosition, 1.0); 35 | 36 | // Lighting - support point and directional 37 | vec3 lightDir0 = normalize(lightPos[0].xyz - (blendPosition * lightPos[0].w)); 38 | vec3 lightDir1 = normalize(lightPos[1].xyz - (blendPosition * lightPos[1].w)); 39 | 40 | oUv0 = uv0; 41 | 42 | ambientColour = /*gl_FrontMaterial.diffuse **/ (ambient + (clamp(dot(lightDir0, blendNormal), 0.0, 1.0) * lightDiffuseColour[0]) + 43 | (clamp(dot(lightDir1, blendNormal), 0.0, 1.0) * lightDiffuseColour[1])); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/DualQuaternion_ShadowCaster.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, vec4 dualQuaternions[24]); 4 | vec3 calculateBlendPosition(vec3 position, mat2x4 blendDQ); 5 | 6 | uniform vec4 worldDualQuaternion2x4Array[24]; 7 | uniform mat4x4 viewProjectionMatrix; 8 | uniform vec4 ambient; 9 | 10 | in vec4 vertex; 11 | in vec4 blendIndices; 12 | in vec4 blendWeights; 13 | 14 | out vec4 ambientColour; 15 | 16 | //Shadow caster pass 17 | void main() 18 | { 19 | mat2x4 blendDQ = blendTwoWeightsAntipod(blendWeights, blendIndices, worldDualQuaternion2x4Array); 20 | 21 | float len = length(blendDQ[0]); 22 | blendDQ /= len; 23 | 24 | vec3 blendPosition = calculateBlendPosition(vertex.xyz, blendDQ); 25 | 26 | // view / projection 27 | gl_Position = viewProjectionMatrix * vec4(blendPosition, 1.0); 28 | 29 | ambientColour = ambient; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/DualQuaternion_TwoPhaseShadowCaster.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, vec4 dualQuaternions[24]); 4 | vec3 calculateBlendPosition(vec3 position, mat2x4 blendDQ); 5 | 6 | uniform vec4 worldDualQuaternion2x4Array[24]; 7 | uniform vec4 scaleM[72]; 8 | uniform mat4 viewProjectionMatrix; 9 | uniform vec4 ambient; 10 | 11 | in vec4 vertex; 12 | in vec4 blendIndices; 13 | in vec4 blendWeights; 14 | 15 | out vec4 ambientColour; 16 | 17 | void main() 18 | { 19 | //First phase - applies scaling and shearing: 20 | int blendIndicesX = int(blendIndices.x) * 3; 21 | int blendIndicesY = int(blendIndices.y) * 3; 22 | 23 | mat3x4 blendS = blendWeights.x*mat3x4(scaleM[blendIndicesX], 24 | scaleM[blendIndicesX + 1], scaleM[blendIndicesX + 2]); 25 | 26 | blendS += blendWeights.y*mat3x4(scaleM[blendIndicesY], 27 | scaleM[blendIndicesY + 1], scaleM[blendIndicesY + 2]); 28 | 29 | mat4x3 blendF = transpose(blendS); 30 | 31 | vec3 pass1_position = blendF * vertex; 32 | 33 | //Second phase 34 | mat2x4 blendDQ = blendTwoWeightsAntipod(blendWeights, blendIndices, worldDualQuaternion2x4Array); 35 | 36 | blendDQ /= length(blendDQ[0]); 37 | 38 | vec3 blendPosition = calculateBlendPosition(pass1_position, blendDQ); 39 | 40 | gl_Position = viewProjectionMatrix * vec4(blendPosition, 1.0); 41 | 42 | ambientColour = ambient; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Dyn-TextFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D Image; 4 | uniform sampler2D Thaw; 5 | in vec4 oUv; 6 | out vec4 fragColour; 7 | 8 | void main(void) 9 | { 10 | vec4 c0 = texture(Image, oUv.xy); 11 | vec4 c1 = texture(Thaw, oUv.xy); 12 | 13 | fragColour = c0 * c1; 14 | } 15 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Dyn-TextVP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 uv0; 4 | in vec4 vertex; 5 | out vec4 oUv; 6 | 7 | uniform mat4 worldViewProj; 8 | 9 | void main(void) 10 | { 11 | gl_Position = worldViewProj * vertex; 12 | oUv = uv0; 13 | } -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/EmbossedFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D RT; 4 | in vec2 oUv0; 5 | out vec4 fragColour; 6 | 7 | void main() 8 | { 9 | vec4 Color; 10 | Color.a = 1.0; 11 | Color.rgb = vec3(0.5); 12 | Color -= texture( RT, oUv0 - 0.001)*2.0; 13 | Color += texture( RT, oUv0 + 0.001)*2.0; 14 | Color.rgb = vec3((Color.r+Color.g+Color.b)/3.0); 15 | fragColour = Color; 16 | } 17 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_BumpMappingFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 lightDiffuse; 4 | uniform sampler2D normalMap; 5 | 6 | in vec4 oUv0; 7 | in vec3 oTSLightDir; 8 | 9 | out vec4 fragColour; 10 | 11 | // General functions 12 | 13 | // Expand a range-compressed vector 14 | vec3 expand(vec3 v) 15 | { 16 | return (v - 0.5) * 2.0; 17 | } 18 | 19 | void main() 20 | { 21 | // Retrieve normalised light vector, expand from range-compressed 22 | vec3 lightVec = normalize(oTSLightDir).xyz; 23 | 24 | // Get bump map vector, again expand from range-compressed 25 | vec3 bumpVec = expand(texture(normalMap, oUv0.xy).xyz); 26 | 27 | // Calculate dot product 28 | fragColour = lightDiffuse * dot(bumpVec, lightVec); 29 | } 30 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_BumpMappingShadowRcvFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // General functions 4 | 5 | // Expand a range-compressed vector 6 | vec3 expand(vec3 v) 7 | { 8 | return (v - 0.5) * 2.0; 9 | } 10 | 11 | uniform sampler2D shadowMap; 12 | uniform sampler2D normalMap; 13 | uniform vec4 lightDiffuse; 14 | 15 | in vec4 uvproj; 16 | in vec4 oUv0; 17 | in vec3 oTSLightDir; 18 | 19 | out vec4 fragColour; 20 | 21 | void main() 22 | { 23 | // retrieve normalised light vector, expand from range-compressed 24 | vec3 lightVec = expand(normalize(oTSLightDir).xyz); 25 | 26 | // get bump map vector, again expand from range-compressed 27 | vec3 bumpVec = expand(texture(normalMap, oUv0.xy).xyz); 28 | 29 | // get shadow value 30 | vec3 shadow = textureProj(shadowMap, uvproj).xyz; 31 | 32 | // Calculate dot product 33 | fragColour = vec4(shadow * lightDiffuse.xyz * dot(bumpVec, lightVec), 1.0); 34 | } 35 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_BumpMappingShadowRcvVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | /* Bump mapping vertex program for shadow receiving 4 | In this program, we want to calculate the tangent space light vector 5 | on a per-vertex level which will get passed to the fragment program, 6 | or to the fixed function dot3 operation, to produce the per-pixel 7 | lighting effect. 8 | */ 9 | 10 | // parameters 11 | uniform vec4 lightPosition; // object space 12 | uniform mat4 worldViewProj; 13 | uniform mat4 worldMatrix; 14 | uniform mat4 texViewProj; 15 | 16 | in vec4 vertex; 17 | in vec3 normal; 18 | in vec3 tangent; 19 | in vec4 uv0; 20 | 21 | out vec4 uvproj; 22 | out vec4 oUv0; 23 | out vec3 oTSLightDir; 24 | 25 | void main() 26 | { 27 | // Calculate output position 28 | gl_Position = worldViewProj * vertex; 29 | 30 | // Pass the main uvs straight through unchanged 31 | oUv0 = uv0; 32 | 33 | // Calculate tangent space light vector 34 | // Get object space light direction 35 | // Non-normalised since we'll do that in the fragment program anyway 36 | vec3 lightDir = lightPosition.xyz - (vertex * lightPosition.w).xyz; 37 | 38 | // Calculate the binormal (NB we assume both normal and tangent are 39 | // already normalised) 40 | vec3 binormal = cross(normal, tangent); 41 | 42 | // Form a rotation matrix out of the vectors, column major for glsl es 43 | mat3 rotation = mat3(vec3(tangent[0], binormal[0], normal[0]), 44 | vec3(tangent[1], binormal[1], normal[1]), 45 | vec3(tangent[2], binormal[2], normal[2])); 46 | 47 | // Transform the light vector according to this matrix 48 | oTSLightDir = rotation * lightDir; 49 | 50 | // Projection 51 | uvproj = texViewProj * (worldMatrix * vertex); 52 | } 53 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_BumpMappingSpecularFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // General functions 4 | 5 | // Expand a range-compressed vector 6 | vec3 expand(vec3 v) 7 | { 8 | return (v - 0.5) * 2.0; 9 | } 10 | 11 | uniform vec4 lightDiffuse; 12 | uniform vec4 lightSpecular; 13 | uniform sampler2D normalMap; 14 | 15 | in vec4 oUv0; 16 | in vec3 oTSLightDir; 17 | in vec3 oTSHalfAngle; 18 | 19 | out vec4 fragColour; 20 | 21 | // NOTE: GLSL does not have the saturate function. But it is equivalent to clamp(val, 0.0, 1.0) 22 | 23 | /* Fragment program which supports specular component */ 24 | void main() 25 | { 26 | // retrieve normalised light vector 27 | vec3 lightVec = normalize(oTSLightDir); 28 | 29 | // retrieve half angle and normalise 30 | vec3 halfAngle = normalize(oTSHalfAngle); 31 | 32 | // get bump map vector, again expand from range-compressed 33 | vec3 bumpVec = expand(texture(normalMap, oUv0.xy).xyz); 34 | 35 | // Pre-raise the specular exponent to the eight power 36 | float specFactor = pow(clamp(dot(bumpVec, halfAngle), 0.0, 1.0), 4.0); 37 | 38 | // Calculate dot product for diffuse 39 | fragColour = (lightDiffuse * clamp(dot(bumpVec, lightVec), 0.0, 1.0)) + 40 | (lightSpecular * specFactor); 41 | } 42 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_BumpMappingSpecularVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // General functions 4 | // parameters 5 | uniform vec4 lightPosition; // object space 6 | uniform vec3 eyePosition; // object space 7 | uniform mat4 worldViewProj; 8 | 9 | in vec4 vertex; 10 | in vec3 normal; 11 | in vec3 tangent; 12 | in vec4 uv0; 13 | 14 | out vec4 oUv0; 15 | out vec3 oTSLightDir; 16 | out vec3 oTSHalfAngle; 17 | 18 | /* Vertex program which includes specular component */ 19 | void main() 20 | { 21 | // calculate output position 22 | gl_Position = worldViewProj * vertex; 23 | 24 | // pass the main uvs straight through unchanged 25 | oUv0 = uv0; 26 | 27 | // calculate tangent space light vector 28 | // Get object space light direction 29 | vec3 lightDir = normalize(lightPosition.xyz - (vertex * lightPosition.w).xyz); 30 | 31 | // Calculate the binormal (NB we assume both normal and tangent are 32 | // already normalised) 33 | vec3 binormal = cross(normal, tangent); 34 | 35 | // Form a rotation matrix out of the vectors 36 | mat3 rotation = mat3(vec3(tangent[0], binormal[0], normal[0]), 37 | vec3(tangent[1], binormal[1], normal[1]), 38 | vec3(tangent[2], binormal[2], normal[2])); 39 | 40 | // Transform the light vector according to this matrix 41 | oTSLightDir = rotation * lightDir; 42 | 43 | // Calculate half-angle in tangent space 44 | vec3 eyeDir = normalize(eyePosition - vertex.xyz); 45 | vec3 halfAngle = normalize(eyeDir + lightDir); 46 | oTSHalfAngle = rotation * halfAngle; 47 | } 48 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_BumpMappingVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | /* Bump mapping vertex program 4 | In this program, we want to calculate the tangent space light vector 5 | on a per-vertex level which will get passed to the fragment program, 6 | or to the fixed function dot3 operation, to produce the per-pixel 7 | lighting effect. 8 | */ 9 | // parameters 10 | uniform vec4 lightPosition; // object space 11 | uniform mat4 worldViewProj; 12 | 13 | in vec4 vertex; 14 | in vec3 normal; 15 | in vec3 tangent; 16 | in vec4 uv0; 17 | 18 | out vec4 oUv0; 19 | out vec3 oTSLightDir; 20 | 21 | void main() 22 | { 23 | // Calculate output position 24 | gl_Position = worldViewProj * vertex; 25 | 26 | // Pass the main uvs straight through unchanged 27 | oUv0 = uv0; 28 | 29 | // Calculate tangent space light vector 30 | // Get object space light direction 31 | // Non-normalised since we'll do that in the fragment program anyway 32 | vec3 lightDir = lightPosition.xyz - (vertex * lightPosition.w).xyz; 33 | 34 | // Calculate the binormal (NB we assume both normal and tangent are 35 | // already normalised) 36 | 37 | // Fixed handedness 38 | vec3 binormal = cross(normal, tangent); 39 | 40 | // Form a rotation matrix out of the vectors, column major for glsl es 41 | mat3 rotation = mat3(vec3(tangent[0], binormal[0], normal[0]), 42 | vec3(tangent[1], binormal[1], normal[1]), 43 | vec3(tangent[2], binormal[2], normal[2])); 44 | 45 | // Transform the light vector according to this matrix 46 | oTSLightDir = rotation * lightDir; 47 | } 48 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_CelShadingFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | /* Cel shading fragment program for single-pass rendering */ 4 | uniform vec4 diffuse; 5 | uniform vec4 specular; 6 | uniform sampler1D diffuseRamp; 7 | uniform sampler1D specularRamp; 8 | uniform sampler1D edgeRamp; 9 | 10 | in float diffuseIn; 11 | in float specularIn; 12 | in float edge; 13 | 14 | out vec4 fragColour; 15 | 16 | /*uniform lighting 17 | { 18 | vec4 diffuse; 19 | vec4 specular; 20 | } LightingParams;*/ 21 | 22 | void main() 23 | { 24 | // Step functions from textures 25 | float diffuseStep = texture(diffuseRamp, diffuseIn).x; 26 | float specularStep = texture(specularRamp, specularIn).x; 27 | float edgeStep = texture(edgeRamp, edge).x; 28 | 29 | fragColour = edgeStep * ((diffuse * diffuseStep) + 30 | (specular * specularStep)); 31 | // fragColour = edgeStep * ((LightingParams.diffuse * diffuseStep) + 32 | // (LightingParams.specular * specularStep)); 33 | } 34 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_CelShadingVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | /* Cel shading vertex program for single-pass rendering 4 | In this program, we want to calculate the diffuse and specular 5 | ramp components, and the edge factor (for doing simple outlining) 6 | For the outlining to look good, we need a pretty well curved model. 7 | */ 8 | // Parameters 9 | in vec4 vertex; 10 | in vec3 normal; 11 | 12 | uniform vec3 lightPosition; // object space 13 | uniform vec3 eyePosition; // object space 14 | uniform vec4 shininess; 15 | uniform mat4 worldViewProj; 16 | 17 | //uniform transform 18 | //{ 19 | // vec4 shininess; 20 | //} MaterialShininess; 21 | 22 | out float diffuseIn; 23 | out float specularIn; 24 | out float edge; 25 | 26 | void main() 27 | { 28 | // calculate output position 29 | gl_Position = worldViewProj * vertex; 30 | 31 | // calculate light vector 32 | vec3 N = normalize(normal); 33 | vec3 L = normalize(lightPosition - vertex.xyz); 34 | 35 | // Calculate diffuse component 36 | diffuseIn = max(dot(N, L) , 0.0); 37 | 38 | // Mask off specular if diffuse is 0 39 | if (diffuseIn == 0.0) 40 | specularIn = 0.0; 41 | 42 | // Calculate specular component 43 | vec3 E = normalize(eyePosition - vertex.xyz); 44 | vec3 H = normalize(L + E); 45 | specularIn = pow(max(dot(N, H), 0.0), shininess.x); 46 | // specularIn = pow(max(dot(N, H), 0.0), MaterialShininess.shininess.x); 47 | 48 | // Edge detection, dot eye and normal vectors 49 | edge = max(dot(N, E), 0.0); 50 | } 51 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_FresnelFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 tintColour; 4 | uniform float noiseScale; 5 | uniform float fresnelBias; 6 | uniform float fresnelScale; 7 | uniform float fresnelPower; 8 | uniform sampler2D noiseMap; 9 | uniform sampler2D reflectMap; 10 | uniform sampler2D refractMap; 11 | 12 | in vec3 noiseCoord; 13 | in vec4 projectionCoord; 14 | in vec3 eyeDir; 15 | in vec3 oNormal; 16 | 17 | out vec4 fragColour; 18 | 19 | // Fragment program for distorting a texture using a 3D noise texture 20 | void main() 21 | { 22 | // Do the tex projection manually so we can distort _after_ 23 | vec2 final = projectionCoord.xy / projectionCoord.w; 24 | 25 | // Noise 26 | vec3 noiseNormal = (texture(noiseMap, (noiseCoord.xy / 5.0)).rgb - 0.5).rbg * noiseScale; 27 | final += noiseNormal.xz; 28 | 29 | // Fresnel 30 | //normal = normalize(normal + noiseNormal.xz); 31 | float fresnel = fresnelBias + fresnelScale * pow(1.0 + dot(eyeDir, oNormal), fresnelPower); 32 | 33 | // Reflection / refraction 34 | vec4 reflectionColour = texture(reflectMap, final); 35 | vec4 refractionColour = texture(refractMap, final) + tintColour; 36 | 37 | // Final colour 38 | fragColour = mix(refractionColour, reflectionColour, fresnel); 39 | } 40 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_FresnelVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 uv0; 4 | in vec4 position; 5 | in vec3 normal; 6 | 7 | uniform mat4 worldViewProjMatrix; 8 | uniform vec3 eyePosition; // object space 9 | uniform float timeVal; 10 | uniform float scale; // the amount to scale the noise texture by 11 | uniform float scroll; // the amount by which to scroll the noise 12 | uniform float noise; // the noise perturb as a factor of the time 13 | 14 | out vec3 noiseCoord; 15 | out vec4 projectionCoord; 16 | out vec3 eyeDir; 17 | out vec3 oNormal; 18 | 19 | // Vertex program for fresnel reflections / refractions 20 | void main() 21 | { 22 | gl_Position = worldViewProjMatrix * position; 23 | // Projective texture coordinates, adjust for mapping 24 | mat4 scalemat = mat4(0.5, 0.0, 0.0, 0.0, 25 | 0.0, -0.5, 0.0, 0.0, 26 | 0.0, 0.0, 0.5, 0.0, 27 | 0.5, 0.5, 0.5, 1.0); 28 | projectionCoord = scalemat * gl_Position; 29 | 30 | // Noise map coords 31 | noiseCoord.xy = (uv0.xy + (timeVal * scroll)) * scale; 32 | noiseCoord.z = noise * timeVal; 33 | 34 | eyeDir = normalize(position.xyz - eyePosition); 35 | oNormal = normal.rgb; 36 | } 37 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_TextureArrayPS.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2DArray TextureArrayTex; 4 | in vec4 oUv; 5 | out vec4 fragColour; 6 | 7 | void main(void) 8 | { 9 | vec4 texcoord; 10 | texcoord = oUv; 11 | texcoord.z = floor(texcoord.z); 12 | vec4 c0 = texture(TextureArrayTex, texcoord.xyz); 13 | texcoord.z += 1.0; 14 | vec4 c1 = texture(TextureArrayTex, texcoord.xyz); 15 | 16 | fragColour = mix(c0, c1, fract(oUv.z)); 17 | } 18 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Example_TextureArrayVS.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 uv0; 4 | in vec4 vertex; 5 | out vec4 oUv; 6 | 7 | uniform mat4 worldViewProj; 8 | 9 | void main(void) 10 | { 11 | gl_Position = worldViewProj * vertex; 12 | oUv = uv0; 13 | } 14 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GlassFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D RT; 4 | uniform sampler2D NormalMap; 5 | 6 | in vec2 oUv0; 7 | out vec4 fragColour; 8 | 9 | void main() 10 | { 11 | vec4 normal = 2.0 * (texture(NormalMap, oUv0 * 2.5) - 0.5); 12 | 13 | fragColour = texture(RT, oUv0 + normal.xy * 0.05); 14 | } 15 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GrassAmbientFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D diffuseMap; 4 | 5 | in vec4 oUv0; 6 | in vec4 oColour; 7 | 8 | out vec4 fragColour; 9 | 10 | /// grass_vp ambient 11 | void main() 12 | { 13 | vec4 texColor = texture(diffuseMap, oUv0.xy); 14 | fragColour = vec4(oColour.rgb, texColor.a); 15 | } 16 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GrassAmbientVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | 4 | uniform mat4 worldViewProj; 5 | uniform vec4 ambient; 6 | uniform vec4 offset; 7 | 8 | in vec4 position; 9 | in vec4 normal; 10 | in vec4 uv0; 11 | 12 | out vec4 oUv0; 13 | out vec4 oColour; 14 | 15 | /// grass_vp ambient 16 | void main() 17 | { 18 | // Position 19 | vec4 mypos = position; 20 | vec4 factor = vec4(1.0, 1.0, 1.0, 1.0) - uv0.yyyy; 21 | mypos = mypos + offset * factor; 22 | gl_Position = worldViewProj * mypos; 23 | // Texture Coord 24 | oUv0.xy = uv0.xy; 25 | /* 26 | // Normal 27 | // Make vec from vertex to camera 28 | vec4 EyeVec = camObjPos - mypos; 29 | // Dot the v to eye and the normal to see if they point 30 | // in the same direction or opposite 31 | float aligned = dot(normal, EyeVec); // -1..1 32 | // If aligned is negative, we need to flip the normal 33 | if (aligned < 0) 34 | normal = -normal; 35 | //oNormal = normal; 36 | */ 37 | // Color 38 | oColour = ambient; 39 | } 40 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GrassCasterFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D diffuseMap; 4 | 5 | in vec4 oUv0; 6 | in vec2 oDepth; 7 | 8 | out vec4 fragColour; 9 | 10 | //////////////////////// GRASS SHADOW CASTER 11 | void main() 12 | { 13 | float alpha = texture(diffuseMap, oUv0.xy).a; 14 | if (alpha > 0.001) 15 | { 16 | fragColour = vec4(1.0, 1.0, 1.0, 0.0); 17 | } 18 | else 19 | { 20 | float finalDepth = oDepth.x / oDepth.y; 21 | // just smear across all components 22 | // therefore this one needs high individual channel precision 23 | fragColour = vec4(vec3(finalDepth), 1.0); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GrassCasterVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 worldViewProj; 4 | uniform vec4 offset; 5 | uniform vec4 texelOffsets; 6 | 7 | in vec4 position; 8 | in vec4 uv0; 9 | 10 | out vec4 oUv0; 11 | out vec2 oDepth; 12 | 13 | //////////////////////// GRASS SHADOW CASTER 14 | // Shadow caster vertex program. 15 | void main() 16 | { 17 | vec4 mypos = position; 18 | vec4 factor = vec4(1.0, 1.0, 1.0, 1.0) - uv0.yyyy; 19 | mypos = mypos + offset * factor; 20 | gl_Position = worldViewProj * mypos; 21 | 22 | // fix pixel / texel alignment 23 | gl_Position.xy += texelOffsets.zw * gl_Position.w; 24 | 25 | oDepth.x = gl_Position.z; 26 | oDepth.y = gl_Position.w; 27 | 28 | oUv0 = uv0; 29 | } 30 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GrassFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | ////////////////////////////// MOVING GRASS 4 | // Vertex program to wave some grass about 5 | // Assumes UV texture coords of v==0 indicates the top of the grass 6 | uniform sampler2D diffuseMap; 7 | 8 | in vec4 oUv0; 9 | in vec4 oColour; 10 | 11 | out vec4 fragColour; 12 | 13 | void main() 14 | { 15 | vec4 texColor = texture(diffuseMap, oUv0.xy); 16 | fragColour = vec4(texColor.rgb * oColour.rgb, texColor.a); 17 | 18 | // Do manual alpha rejection 19 | if (texColor.a < 0.58) 20 | { 21 | discard; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GrassReceiverFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform float fixedDepthBias; 4 | uniform float gradientClamp; 5 | uniform float gradientScaleBias; 6 | uniform sampler2D shadowMap; 7 | uniform sampler2D diffuseMap; 8 | uniform vec4 vertexLight; 9 | 10 | in vec4 oUv0; 11 | in vec4 oShadowUV; 12 | 13 | out vec4 fragColour; 14 | 15 | //////////////////////// GRASS SHADOW RECEIVER 16 | void main() 17 | { 18 | if (oShadowUV.z > 0.0) 19 | { 20 | vec4 diffuse = texture(diffuseMap, oUv0.xy); 21 | if (diffuse.a > 0.001) 22 | { 23 | fragColour = vec4(0.0); 24 | } 25 | else 26 | { 27 | vec4 normShadowUV = oShadowUV / oShadowUV.w; 28 | vec4 shadowDepths = texture(shadowMap, normShadowUV.xy); 29 | 30 | float gradientFactor = gradientClamp * gradientScaleBias; 31 | float depthAdjust = gradientFactor + fixedDepthBias * shadowDepths.x; 32 | float centerdepth = shadowDepths.x + depthAdjust; 33 | 34 | fragColour = (centerdepth > normShadowUV.z) ? vec4(vertexLight.rgb, diffuse.a) : vec4(0.0, 0.0, 0.0, diffuse.a); 35 | } 36 | } 37 | else 38 | { 39 | fragColour = vec4(0.0); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GrassReceiverVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 world; 4 | uniform mat4 worldViewProj; 5 | uniform mat4 texViewProj; 6 | uniform vec4 camObjPos; 7 | uniform vec4 objSpaceLight; 8 | uniform vec4 lightColour; 9 | uniform vec4 offset; 10 | 11 | in vec4 position; 12 | in vec4 normal; 13 | in vec4 uv0; 14 | 15 | out vec4 oShadowUV; 16 | out vec3 oUv0; 17 | out vec4 oColour; 18 | 19 | //////////////////////// GRASS SHADOW RECEIVER 20 | void main() 21 | { 22 | vec4 mypos = position; 23 | vec4 factor = vec4(1.0, 1.0, 1.0, 1.0) - uv0.yyyy; 24 | mypos = mypos + offset * factor; 25 | gl_Position = worldViewProj * mypos; 26 | oUv0.xy = uv0.xy; 27 | // Transform position to world space 28 | vec4 worldPos = world * mypos; 29 | // calculate shadow map coords 30 | oShadowUV = texViewProj * worldPos; 31 | 32 | // Make vec from vertex to camera 33 | vec4 EyeVec = camObjPos - mypos; 34 | // Dot the v to eye and the normal to see if they point 35 | // in the same direction or opposite 36 | float alignedEye = dot(normal, EyeVec); // -1..1 37 | // If aligned is negative, we need to flip the normal 38 | vec4 myNormal = normal; 39 | if (alignedEye < 0.0) 40 | myNormal = -normal; 41 | //oNormal = normal; 42 | 43 | // get vertex light direction (support directional and point) 44 | vec3 lightVec = normalize(objSpaceLight.xyz - (mypos.xyz * objSpaceLight.w).xyz); 45 | // Dot the v to light and the normal to see if they point 46 | // in the same direction or opposite 47 | float alignedLight = dot(myNormal.xyz, lightVec); // -1..1 48 | // If aligned is negative, shadowing/lighting is not possible. 49 | oUv0.z = (alignedLight < 0.0) ? 0.0 : 1.0 ; 50 | 51 | float diffuseFactor = max(alignedLight, 0.0); 52 | //oColour = diffuseFactor * lightColour; 53 | oColour = lightColour; 54 | } 55 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GrassTexVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | out vec4 oUv0; 4 | 5 | in vec4 position; 6 | in vec4 uv0; 7 | 8 | uniform mat4 worldViewProj; 9 | uniform vec4 ambient; 10 | uniform vec4 objSpaceLight; 11 | uniform vec4 lightColour; 12 | uniform vec4 offset; 13 | 14 | void main() 15 | { 16 | // Position 17 | vec4 mypos = position; 18 | vec4 factor = vec4(1.0, 1.0, 1.0, 1.0) - uv0.yyyy; 19 | mypos = mypos + offset * factor; 20 | gl_Position = worldViewProj * mypos; 21 | // Texture Coord 22 | oUv0.xy = uv0.xy; 23 | } 24 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GrassVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | ////////////////////////////// MOVING GRASS 4 | // Vertex program to wave some grass about 5 | // Assumes UV texture coords of v==0 indicates the top of the grass 6 | uniform mat4 worldViewProj; 7 | uniform vec4 camObjPos; 8 | uniform vec4 ambient; 9 | uniform vec4 objSpaceLight; 10 | uniform vec4 lightColour; 11 | uniform vec4 offset; 12 | 13 | in vec4 position; 14 | in vec4 normal; 15 | in vec4 uv0; 16 | 17 | out vec4 oUv0; 18 | out vec4 oColour; 19 | 20 | void main() 21 | { 22 | vec4 mypos = position; 23 | vec4 factor = vec4(1.0, 1.0, 1.0, 1.0) - uv0.yyyy; 24 | mypos = mypos + offset * factor; 25 | gl_Position = worldViewProj * mypos; 26 | 27 | oUv0 = uv0; 28 | // Color 29 | // get vertex light direction (support directional and point) 30 | vec3 light = normalize(objSpaceLight.xyz - (mypos.xyz * objSpaceLight.w).xyz); 31 | // grass is just 2D quads, so if light passes underneath we need to invert the normal 32 | // abs() will have the same effect 33 | float diffuseFactor = abs(dot(normal.xyz, light)); 34 | oColour = ambient + diffuseFactor * lightColour; 35 | } 36 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/GrayScale.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D RT; 4 | in vec2 oUv0; 5 | out vec4 fragColour; 6 | 7 | void main() 8 | { 9 | vec3 greyscale = vec3(dot(texture(RT, oUv0).rgb, vec3(0.3, 0.59, 0.11))); 10 | fragColour = vec4(greyscale, 1.0); 11 | } 12 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/HWBasicInstancing.vert: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | //These materials/shaders are part of the NEW InstanceManager implementation 3 | //Written by Matias N. Goldberg ("dark_sylinc") 4 | //--------------------------------------------------------------------------- 5 | #version 150 6 | 7 | //Vertex input 8 | in vec4 vertex; 9 | in vec3 normal; 10 | in vec4 uv0; 11 | in vec4 uv1; 12 | in vec4 uv2; 13 | in vec4 uv3; 14 | in vec3 tangent; 15 | 16 | //Parameters 17 | uniform mat4 viewProjMatrix; 18 | 19 | #if (DEPTH_SHADOWCASTER || DEPTH_SHADOWRECEIVER) 20 | uniform vec4 depthRange; 21 | #endif 22 | 23 | #if DEPTH_SHADOWRECEIVER 24 | uniform mat4 texViewProjMatrix; 25 | #endif 26 | 27 | //Output 28 | #if DEPTH_SHADOWCASTER 29 | out vec2 depth; 30 | #else 31 | out vec2 _uv0; 32 | out vec3 oNormal; 33 | out vec3 oVPos; 34 | #if DEPTH_SHADOWRECEIVER 35 | out vec4 oLightSpacePos; 36 | #endif 37 | #endif 38 | 39 | //--------------------------------------------- 40 | //Main Vertex Shader 41 | //--------------------------------------------- 42 | void main(void) 43 | { 44 | mat4 worldMatrix; 45 | worldMatrix[0] = uv1; 46 | worldMatrix[1] = uv2; 47 | worldMatrix[2] = uv3; 48 | worldMatrix[3] = vec4( 0, 0, 0, 1 ); 49 | 50 | vec4 worldPos = vertex * worldMatrix; 51 | vec3 worldNorm = normal * mat3(worldMatrix); 52 | 53 | //Transform the position 54 | gl_Position = viewProjMatrix * worldPos; 55 | 56 | #if DEPTH_SHADOWCASTER 57 | depth.x = (gl_Position.z - depthRange.x) * depthRange.w; 58 | depth.y = depthRange.w; 59 | #else 60 | _uv0 = uv0.xy; 61 | oNormal = worldNorm; 62 | oVPos = worldPos.xyz; 63 | 64 | #if DEPTH_SHADOWRECEIVER 65 | oLightSpacePos = texViewProjMatrix * worldPos; 66 | oLightSpacePos.z = (oLightSpacePos.z - depthRange.x) * depthRange.w; 67 | #endif 68 | #endif 69 | } 70 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/HalftoneFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 pos; 4 | in vec2 oUv0; 5 | 6 | uniform vec2 numTiles; 7 | uniform vec2 iNumTiles; 8 | uniform vec2 iNumTiles2; 9 | uniform vec4 lum; 10 | uniform sampler2D RT; 11 | uniform sampler3D noise; 12 | 13 | out vec4 fragColour; 14 | 15 | void main() 16 | { 17 | vec3 local; 18 | local.xy = mod(oUv0, iNumTiles); 19 | vec2 middle = oUv0 - local.xy; 20 | local.xy = local.xy * numTiles; 21 | middle += iNumTiles2; 22 | local.z = dot(texture(RT, middle), lum); 23 | vec4 c = vec4(texture(noise,local).r); 24 | fragColour = c; 25 | } 26 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/HardwareMorphAnimationVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 vertex; 4 | in vec4 normal; 5 | in vec4 uv0; 6 | in vec4 uv1; // pos2 7 | 8 | out vec2 oUv; 9 | out vec4 colour; 10 | 11 | uniform mat4 worldViewProj; 12 | uniform vec4 anim_t; 13 | 14 | // hardware morph animation (no normals) 15 | void main() 16 | { 17 | // interpolate 18 | vec4 interp = vec4(vertex.xyz + anim_t.x*(uv1.xyz - vertex.xyz), 1.0); 19 | 20 | gl_Position = worldViewProj * interp; 21 | oUv = uv0.xy; 22 | colour = vec4(1.0,0.0,0.0,1.0); 23 | } 24 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/HardwareMorphAnimationWithNormalsVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 vertex; 4 | in vec3 normal; 5 | in vec4 uv0; 6 | in vec4 uv1; // pos2 7 | in vec4 uv2; // normal2 8 | 9 | out vec2 oUv; 10 | out vec4 colour; 11 | 12 | uniform mat4 worldViewProj; 13 | uniform vec4 anim_t; 14 | uniform vec4 objSpaceLightPos; 15 | uniform vec4 ambient; 16 | 17 | // hardware morph animation (with normals) 18 | void main() 19 | { 20 | // interpolate position 21 | vec4 posinterp = vec4(vertex.xyz + anim_t.x*(uv1.xyz - vertex.xyz), 1.0); 22 | 23 | // nlerp normal 24 | vec3 ninterp = normal + anim_t.x*(uv2.xyz - normal); 25 | ninterp = normalize(ninterp); 26 | 27 | gl_Position = worldViewProj * posinterp; 28 | oUv = uv0.xy; 29 | 30 | vec3 lightDir = normalize( 31 | objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w)); 32 | 33 | // Colour it red to make it easy to identify 34 | float lit = clamp(dot(lightDir, ninterp), 0.0, 1.0); 35 | colour = vec4((ambient.rgb + vec3(lit,lit,lit)) * vec3(1.0,0.0,0.0), 1.0); 36 | } 37 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/HardwarePoseAnimationVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 vertex; 4 | in vec4 normal; 5 | in vec4 uv0; 6 | in vec4 uv1; // pose1 7 | in vec4 uv2; // pose2 8 | 9 | out vec2 oUv; 10 | out vec4 colour; 11 | 12 | uniform mat4 worldViewProj; 13 | uniform vec4 anim_t; 14 | 15 | // hardware pose animation (no normals) 16 | void main() 17 | { 18 | // interpolate 19 | vec4 interp = vec4(vertex + anim_t.x*uv1.xyz + anim_t.y*uv2.xyz, 1.0); 20 | 21 | gl_Position = worldViewProj * interp; 22 | oUv = uv0.xy; 23 | colour = vec4(1.0,0.0,0.0,1.0); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/HardwarePoseAnimationWithNormalsVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 vertex; 4 | in vec4 normal; 5 | in vec4 uv0; 6 | in vec4 uv1; // pose1pos 7 | in vec4 uv2; // pose1norm 8 | in vec4 uv3; // pose2pos 9 | in vec4 uv4; // pose2norm 10 | 11 | out vec2 oUv; 12 | out vec4 colour; 13 | 14 | uniform mat4 worldViewProj; 15 | uniform vec4 anim_t; 16 | uniform vec4 objSpaceLightPos; 17 | uniform vec4 ambient; 18 | 19 | // hardware pose animation (with normals) 20 | void main() 21 | { 22 | // interpolate position 23 | vec4 posinterp = vec4(pos + anim_t.x*uv1.xyz + anim_t.y*uv3.xyz, 1.0); 24 | 25 | // nlerp normal 26 | // nlerp normal 27 | // First apply the pose normals (these are actual normals, not offsets) 28 | vec3 ninterp = anim_t.x*uv2.xyz + anim_t.y*uv4.xyz; 29 | 30 | // Now add back any influence of the original normal 31 | // This depends on what the cumulative weighting left the normal at, if it's lacking or cancelled out 32 | //float remainder = 1.0 - min(anim_t.x + anim_t.y, 1.0); 33 | float remainder = 1.0 - min(length(ninterp), 1.0); 34 | ninterp = ninterp + (normal * remainder); 35 | ninterp = normalize(ninterp); 36 | 37 | gl_Position = worldViewProj * posinterp; 38 | oUv = uv0.xy; 39 | 40 | vec3 lightDir = normalize( 41 | objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w)); 42 | 43 | // Colour it red to make it easy to identify 44 | float lit = clamp(dot(lightDir, ninterp), 0.0, 1.0); 45 | colour = vec4((ambient.rgb + vec3(lit,lit,lit)) * vec3(1.0,0.0,0.0), 1.0); 46 | } 47 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/HeatBlurFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D Input; 4 | uniform vec4 blurAmount; 5 | 6 | in vec2 uv; 7 | out vec4 fragColour; 8 | 9 | void main() 10 | { 11 | int i; 12 | vec4 tmpOutColor; 13 | float diffuseGlowFactor; 14 | vec2 offsets[4]; 15 | /* 16 | // hazy blur 17 | -1.8, -1.8, 18 | -1.8, 1.8, 19 | 1.8, -1.8, 20 | 1.8, 1.8 21 | */ 22 | /* 23 | // less-hazy blur 24 | -1.0, 2.0, 25 | -1.0, -1.0, 26 | 1.0, -1.0, 27 | 1.0, 1.0 28 | */ 29 | /* 30 | -0.326212, -0.405805, 31 | -0.840144, -0.073580, 32 | -0.695914, 0.457137, 33 | -0.203345, 0.620716 34 | */ 35 | 36 | offsets[0] = vec2(-0.3, 0.4); 37 | offsets[1] = vec2(-0.3, -0.4); 38 | offsets[2] = vec2(0.3, -0.4); 39 | offsets[3] = vec2(0.3, 0.4); 40 | 41 | tmpOutColor = texture( Input, uv ); // UV coords are in image space 42 | 43 | // calculate glow amount 44 | diffuseGlowFactor = 0.0113 * (2.0 - max( tmpOutColor.r, tmpOutColor.g )); 45 | 46 | // basic blur filter 47 | for (i = 0; i < 4; i++) { 48 | tmpOutColor += texture( Input, uv + blurAmount.x * diffuseGlowFactor * offsets[i] ); 49 | } 50 | 51 | tmpOutColor *= 0.25; 52 | 53 | // TIPS (old-skool strikes again!) 54 | // Pay attention here! If you use the "out float4 outColor" directly 55 | // in your steps while creating the output color (like you remove 56 | // the "tmpOutColor" var and just use the "outColor" directly) 57 | // your pixel-color output IS CHANGING EACH TIME YOU DO AN ASSIGNMENT TOO! 58 | // A temporary variable, instead, acts like a per-pixel double buffer, and 59 | // best of all, lead to better performance. 60 | fragColour = tmpOutColor; 61 | } 62 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/HeatBlurVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 position; 4 | out vec2 uv; 5 | 6 | uniform mat4 worldViewProj; 7 | in vec4 vertex; 8 | in vec2 uv0; 9 | 10 | void main() 11 | { 12 | gl_Position = worldViewProj * vertex; 13 | uv = uv0; 14 | } 15 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/HeatCasterFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec2 NDotV; 4 | out vec4 fragColour; 5 | 6 | void main() 7 | { 8 | fragColour = vec4(NDotV.x); 9 | } 10 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/HeatCasterVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 worldViewProj; 4 | uniform vec3 eyePosition; 5 | in vec4 position; 6 | in vec4 normal; 7 | out vec2 NDotV; 8 | 9 | void main() 10 | { 11 | vec4 eyeDir = vec4(eyePosition - position.xyz, 0.0); 12 | eyeDir = normalize(eyeDir); 13 | gl_Position = worldViewProj * position; 14 | NDotV = vec2(clamp( dot( normal, eyeDir ), 0.0, 1.0 )); 15 | } 16 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Instancing.frag: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | //These materials/shaders are part of the NEW InstanceManager implementation 3 | //Written by Matias N. Goldberg ("dark_sylinc") 4 | //--------------------------------------------------------------------------- 5 | 6 | #version 150 7 | 8 | uniform sampler2D diffuseMap; 9 | 10 | uniform vec4 lightPosition; 11 | uniform vec3 cameraPosition; 12 | uniform vec3 lightAmbient; 13 | uniform vec3 lightDiffuse; 14 | uniform vec3 lightSpecular; 15 | uniform vec4 lightAttenuation; 16 | uniform float lightGloss; 17 | 18 | #if DEPTH_SHADOWRECEIVER 19 | uniform float invShadowMapSize; 20 | uniform sampler2DShadow shadowMap; 21 | 22 | //declare external function 23 | //vec4 calcDepthShadow(in vec4 inColour, in float lum); 24 | float calcDepthShadow(sampler2DShadow shadowMap, vec4 uv, float invShadowMapSize); 25 | #endif 26 | 27 | in vec2 _uv0; 28 | in vec3 oNormal; 29 | in vec3 oVPos; 30 | #if DEPTH_SHADOWRECEIVER 31 | in vec4 oLightSpacePos; 32 | #endif 33 | out vec4 fragColour; 34 | 35 | //--------------------------------------------- 36 | //Main Pixel Shader 37 | //--------------------------------------------- 38 | void main(void) 39 | { 40 | vec4 color = texture( diffuseMap, _uv0 ); 41 | 42 | float fShadow = 1.0; 43 | #if DEPTH_SHADOWRECEIVER 44 | fShadow = calcDepthShadow( shadowMap, oLightSpacePos, invShadowMapSize ); 45 | #endif 46 | 47 | vec4 baseColour = texture( diffuseMap, _uv0 ); 48 | 49 | //Blinn-Phong lighting 50 | vec3 normal = normalize( oNormal ); 51 | vec3 lightDir = lightPosition.xyz - oVPos * lightPosition.w; 52 | vec3 eyeDir = normalize( cameraPosition - oVPos ); 53 | 54 | float fLength = length( lightDir ); 55 | lightDir = normalize( lightDir ); 56 | 57 | float NdotL = max( 0.0, dot( normal, lightDir ) ); 58 | vec3 halfVector = normalize(lightDir + eyeDir); 59 | float HdotN = max( 0.0, dot( halfVector, normal ) ); 60 | 61 | vec3 ambient = lightAmbient * baseColour.xyz; 62 | vec3 diffuse = lightDiffuse * NdotL * baseColour.xyz; 63 | vec3 specular = lightSpecular * pow( HdotN, lightGloss ); 64 | 65 | vec3 directLighting = (diffuse + specular) * fShadow; 66 | 67 | fragColour = vec4( directLighting + ambient, baseColour.a ); 68 | //fragColour = baseColour; 69 | } 70 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/InstancingMisc.vert: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | //These materials/shaders are part of the NEW InstanceManager implementation 3 | //Written by Matias N. Goldberg ("dark_sylinc") 4 | //--------------------------------------------------------------------------- 5 | #version 150 6 | 7 | //Vertex input 8 | in vec4 vertex; 9 | in vec3 normal; 10 | in vec3 tangent; 11 | in vec4 uv0; 12 | in vec4 blendIndices; 13 | in vec4 blendWeights; 14 | 15 | //Parameters 16 | uniform mat4 viewProjMatrix; 17 | uniform mat4 worldMatrix; 18 | 19 | #if (DEPTH_SHADOWCASTER || DEPTH_SHADOWRECEIVER) 20 | uniform vec4 depthRange; 21 | #endif 22 | 23 | #if DEPTH_SHADOWRECEIVER 24 | uniform mat4 texViewProjMatrix; 25 | #endif 26 | 27 | //Output 28 | #if DEPTH_SHADOWCASTER 29 | out vec2 depth; 30 | #else 31 | out vec2 _uv0; 32 | out vec3 oNormal; 33 | out vec3 oVPos; 34 | #if DEPTH_SHADOWRECEIVER 35 | out vec4 oLightSpacePos; 36 | #endif 37 | #endif 38 | //--------------------------------------------- 39 | //Main Vertex Shader 40 | //--------------------------------------------- 41 | void main(void) 42 | { 43 | vec4 worldPos = vertex * worldMatrix; 44 | vec3 worldNorm = normal * mat3(worldMatrix); 45 | 46 | //Transform the position 47 | gl_Position = viewProjMatrix * worldPos; 48 | 49 | #if DEPTH_SHADOWCASTER 50 | depth.x = (gl_Position.z - depthRange.x) * depthRange.w; 51 | depth.y = depthRange.w; 52 | #else 53 | _uv0 = uv0.xy; 54 | oNormal = worldNorm; 55 | oVPos = worldPos.xyz; 56 | 57 | #if DEPTH_SHADOWRECEIVER 58 | oLightSpacePos = texViewProjMatrix * worldPos; 59 | oLightSpacePos.z = (oLightSpacePos.z - depthRange.x) * depthRange.w; 60 | #endif 61 | #endif 62 | } 63 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/InvertFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D RT; 4 | in vec2 oUv0; 5 | in vec2 oUv1; 6 | out vec4 fragColour; 7 | 8 | void main() 9 | { 10 | fragColour = 1.0 - texture(RT, oUv0); 11 | } 12 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/LaplaceFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D Image; 4 | uniform float scale; 5 | uniform float pixelSize; 6 | in vec2 oUv0; 7 | out vec4 fragColour; 8 | 9 | // The Laplace filter approximates the second order derivate, 10 | // that is, the rate of change of slope in the image. It can be 11 | // used for edge detection. The Laplace filter gives negative 12 | // response on the higher side of the edge and positive response 13 | // on the lower side. 14 | 15 | // This is the filter kernel: 16 | // 0 1 0 17 | // 1 -4 1 18 | // 0 1 0 19 | 20 | void main() 21 | { 22 | vec2 samples[4]; 23 | samples[0] = vec2(0, -1); 24 | samples[1] = vec2(-1, 0); 25 | samples[2] = vec2(1, 0); 26 | samples[3] = vec2(0, 1); 27 | 28 | mediump vec4 tc = texture(Image, oUv0); 29 | vec4 laplace = -4.0 * tc; 30 | 31 | // Sample the neighbor pixels 32 | for (int i = 0; i < 4; i++){ 33 | laplace += texture(Image, oUv0 + pixelSize * samples[i]); 34 | } 35 | 36 | fragColour = (0.5 + scale * laplace); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/LightToHeatFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 random_fractions; 4 | uniform vec4 heatBiasScale; 5 | uniform vec4 depth_modulator; 6 | 7 | uniform sampler2D Input; // output of HeatVisionCaster_fp (NdotV) 8 | uniform sampler2D NoiseMap; 9 | uniform sampler2D HeatLookup; 10 | 11 | in vec4 diffuse; 12 | in vec2 uv; 13 | out vec4 fragColour; 14 | 15 | void main() 16 | { 17 | float depth, heat, interference; 18 | 19 | // Output constant color: 20 | depth = texture( Input, uv ).x; 21 | depth *= (depth * depth_modulator).x; 22 | 23 | heat = (depth * heatBiasScale.y); 24 | 25 | // if (depth > 0) 26 | { 27 | interference = -0.5 + texture( NoiseMap, uv + vec2( random_fractions.x, random_fractions.y ) ).x; 28 | interference *= interference; 29 | interference *= 1.0 - heat; 30 | heat += interference;//+ heatBiasScale.x; 31 | } 32 | 33 | // Clamp UVs 34 | heat = max( 0.005, min( 0.995, heat ) ); 35 | fragColour = texture( HeatLookup, vec2( heat, 0.0 ) ); 36 | } 37 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/LightToHeatVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 vertex; 4 | out vec2 uv; 5 | 6 | uniform mat4 worldViewProj; 7 | in vec2 uv0; 8 | 9 | void main() 10 | { 11 | gl_Position = worldViewProj * vertex; 12 | uv = uv0; 13 | } 14 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/MetaballFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // Ogre port of Nvidia's IsoSurf.cg file 4 | // Modified code follows. See http://developer.download.nvidia.com/SDK/10/opengl/samples.html for original 5 | // 6 | // Cg port of Yury Uralsky's metaball FX shader 7 | // 8 | // Authors: Simon Green and Yury Urlasky 9 | // Email: sdkfeedback@nvidia.com 10 | // 11 | // Copyright (c) NVIDIA Corporation. All rights reserved. 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// 13 | 14 | out vec4 fragColour; 15 | in vec3 oNormal; 16 | 17 | // Pixel shader 18 | void main() 19 | { 20 | // Sanitize input 21 | vec3 N = normalize(oNormal); 22 | vec3 L = vec3(0, 0, 1); 23 | float nDotL = dot(N, L); 24 | 25 | vec3 materials[2] = vec3[](vec3(1, 1, 1), vec3(0, 0, 0.5)); 26 | 27 | fragColour = vec4(abs(nDotL) * materials[int(nDotL < 0.0)], 0.1); 28 | } 29 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/NightVisionFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | out vec4 fragColour; 4 | 5 | uniform sampler2D RT; 6 | uniform sampler3D noiseVol; 7 | 8 | in vec2 oUv0; 9 | uniform vec4 lum; 10 | uniform float time; 11 | 12 | void main() 13 | { 14 | vec4 oC; 15 | oC = texture(RT, oUv0); 16 | 17 | //obtain luminence value 18 | oC = vec4(dot(oC,lum)); 19 | 20 | //add some random noise 21 | oC += 0.2 *(texture(noiseVol, vec3(oUv0*5,time)))- 0.05; 22 | 23 | //add lens circle effect 24 | //(could be optimised by using texture) 25 | float dist = distance(oUv0, vec2(0.5,0.5)); 26 | oC *= smoothstep(0.5,0.45,dist); 27 | 28 | //add rb to the brightest pixels 29 | oC.rb = vec2(max(oC.r - 0.75, 0)*4); 30 | 31 | fragColour = oC; 32 | } 33 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/OffsetMappingFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec3 lightDiffuse; 4 | uniform vec3 lightSpecular; 5 | uniform vec4 scaleBias; 6 | 7 | uniform sampler2D normalHeightMap; 8 | uniform sampler2D diffuseMap; 9 | 10 | in vec3 oEyeDir; 11 | in vec3 oLightDir; 12 | in vec3 oHalfAngle; 13 | in vec4 oUv0; 14 | 15 | out vec4 fragColour; 16 | 17 | // Expand a range-compressed vector 18 | vec3 expand(vec3 v) 19 | { 20 | return (v - 0.5) * 2.0; 21 | } 22 | 23 | void main() 24 | { 25 | // Get the height using the tex coords 26 | float height = texture(normalHeightMap, oUv0.xy).a; 27 | 28 | // Calculate displacement 29 | float displacement = (height * scaleBias.x) + scaleBias.y; 30 | 31 | vec3 uv2 = vec3(oUv0.xy, 1.0); 32 | 33 | // calculate the new tex coord to use for normal and diffuse 34 | vec2 newTexCoord = ((oEyeDir * displacement) + uv2).xy; 35 | 36 | // get the new normal and diffuse values 37 | vec3 normal = expand(texture(normalHeightMap, newTexCoord).xyz); 38 | vec3 diffuse = texture(diffuseMap, newTexCoord).xyz; 39 | vec3 specular = pow(clamp(dot(normal, oHalfAngle), 0.0, 1.0), 32.0) * lightSpecular; 40 | 41 | vec3 col = diffuse * (clamp(dot(normal, oLightDir), 0.0, 1.0) * lightDiffuse) + specular; 42 | fragColour = vec4(col, 1.0); 43 | } 44 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/OffsetMappingShadowsFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 lightDiffuse; 4 | uniform vec4 scaleBias; 5 | uniform vec4 spotParams; 6 | uniform vec4 lightDiffuse1; 7 | uniform vec4 spotParams1; 8 | 9 | uniform sampler2D normalHeightMap; 10 | uniform sampler2D diffuseMap; 11 | uniform sampler2D shadowMap1; 12 | uniform sampler2D shadowMap2; 13 | 14 | in vec3 tangentEyeDir; 15 | in vec3 tangentLightDir[2]; 16 | in vec3 tangentSpotDir[2]; 17 | in vec4 shadowUV[2]; 18 | in vec4 oUv0; 19 | 20 | out vec4 fragColour; 21 | 22 | // Expand a range-compressed vector 23 | vec3 expand(vec3 v) 24 | { 25 | return (v - 0.5) * 2.0; 26 | } 27 | 28 | void main() 29 | { 30 | // get the height using the tex coords 31 | float height = texture(normalHeightMap, oUv0.xy).a; 32 | // scale and bias factors 33 | float scale = scaleBias.x; 34 | float bias = scaleBias.y; 35 | 36 | // calculate displacement 37 | float displacement = (height * scale) + bias; 38 | //float displacement = (height * 0.04) - 0.02; 39 | 40 | vec3 scaledEyeDir = tangentEyeDir * displacement; 41 | 42 | // calculate the new tex coord to use for normal and diffuse 43 | vec2 newTexCoord = (scaledEyeDir + oUv0.xyz).xy; 44 | 45 | // get the new normal and diffuse values 46 | vec3 normal = expand(texture(normalHeightMap, newTexCoord).xyz); 47 | vec4 diffuse = texture(diffuseMap, newTexCoord); 48 | 49 | vec4 col1 = diffuse * clamp(dot(normal, tangentLightDir[0]),0.0,1.0) * lightDiffuse; 50 | // factor in spotlight angle 51 | float rho = clamp(dot(tangentSpotDir[0], tangentLightDir[0]),0.0,1.0); 52 | // factor = (rho - cos(outer/2) / cos(inner/2) - cos(outer/2)) ^ falloff 53 | float spotFactor = pow( 54 | clamp(rho - spotParams.y,0.0,1.0) / (spotParams.x - spotParams.y), spotParams.z); 55 | col1 = col1 * spotFactor; 56 | vec4 col2 = diffuse * clamp(dot(normal, tangentLightDir[1]),0.0,1.0) * lightDiffuse1; 57 | // factor in spotlight angle 58 | rho = clamp(dot(tangentSpotDir[1], tangentLightDir[1]),0.0,1.0); 59 | // factor = (rho - cos(outer/2) / cos(inner/2) - cos(outer/2)) ^ falloff 60 | spotFactor = pow( 61 | clamp(rho - spotParams1.y,0.0,1.0) / (spotParams1.x - spotParams1.y), spotParams1.z); 62 | col2 = col2 * spotFactor; 63 | 64 | // shadow textures 65 | col1 = col1 * textureProj(shadowMap1, shadowUV[0]); 66 | col2 = col2 * textureProj(shadowMap2, shadowUV[1]); 67 | 68 | fragColour = col1 + col2; 69 | } 70 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/OffsetMappingShadowsVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 lightPosition; // object space 4 | uniform vec4 lightPosition1; // object space 5 | uniform vec4 eyePosition; // object space 6 | uniform vec4 spotDirection; // object space 7 | uniform vec4 spotDirection1; // object space 8 | uniform mat4 worldViewProj; // not actually used but here for compat with HLSL 9 | uniform mat4 worldMatrix; 10 | uniform mat4 texViewProj1; 11 | uniform mat4 texViewProj2; 12 | 13 | out vec3 tangentEyeDir; 14 | out vec3 tangentLightDir[2]; 15 | out vec3 tangentSpotDir[2]; 16 | out vec4 shadowUV[2]; 17 | out vec4 oUv0; 18 | 19 | in vec3 tangent; 20 | in vec4 position; 21 | in vec3 normal; 22 | in vec4 uv0; 23 | 24 | void main() 25 | { 26 | gl_Position = worldViewProj * position; 27 | 28 | vec4 worldPos = worldMatrix * position; 29 | 30 | oUv0 = uv0; 31 | 32 | shadowUV[0] = texViewProj1 * worldPos; 33 | shadowUV[1] = texViewProj2 * worldPos; 34 | 35 | // calculate tangent space light vector 36 | // Get object space light direction 37 | vec3 lightDir = normalize(lightPosition.xyz - (position.xyz * lightPosition.w)); 38 | vec3 lightDir1 = normalize(lightPosition1.xyz - (position.xyz * lightPosition1.w)); 39 | 40 | vec3 eyeDir = (eyePosition - position).xyz; 41 | 42 | // Calculate the binormal (NB we assume both normal and tangent are 43 | // already normalised) 44 | vec3 binormal = cross(normal, tangent); 45 | 46 | // Form a rotation matrix out of the vectors, column major for glsl es 47 | mat3 rotation = mat3(tangent, binormal, normal); 48 | 49 | // Transform the light vector according to this matrix 50 | tangentLightDir[0] = normalize(rotation * lightDir); 51 | tangentLightDir[1] = normalize(rotation * lightDir1); 52 | // Invert the Y on the eye dir since we'll be using this to alter UVs and 53 | // GL has Y inverted 54 | tangentEyeDir = normalize(rotation * eyeDir) * vec3(1.0, -1.0, 1.0); 55 | 56 | tangentSpotDir[0] = normalize(rotation * -spotDirection.xyz); 57 | tangentSpotDir[1] = normalize(rotation * -spotDirection1.xyz); 58 | } 59 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/OffsetMappingVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 lightPosition; // object space 4 | uniform vec3 eyePosition; // object space 5 | uniform mat4 worldViewProj; // not actually used but here for compat with HLSL 6 | 7 | out vec3 oEyeDir; 8 | out vec3 oLightDir; 9 | out vec3 oHalfAngle; 10 | out vec4 oUv0; 11 | 12 | in vec3 normal; 13 | in vec3 tangent; 14 | in vec4 uv0; 15 | in vec4 position; 16 | 17 | /* Vertex program that moves light and eye vectors into texture tangent space at vertex */ 18 | 19 | void main() 20 | { 21 | // Calculate output position 22 | gl_Position = worldViewProj * position; 23 | 24 | // Pass the main uvs straight through unchanged 25 | oUv0 = uv0; 26 | 27 | vec3 lightDir = lightPosition.xyz - (position.xyz * lightPosition.w); 28 | 29 | vec3 eyeDir = eyePosition - position.xyz; 30 | 31 | // Calculate the binormal (NB we assume both normal and tangent are 32 | // already normalised) 33 | // NB looks like nvidia cross params are BACKWARDS to what you'd expect 34 | // this equates to NxT, not TxN 35 | vec3 localbinormal = cross(tangent, normal); 36 | 37 | // Form a rotation matrix out of the vectors, column major for glsl es 38 | mat3 TBN = mat3(tangent, localbinormal, normal); 39 | 40 | // Transform the light vector according to this matrix 41 | oLightDir = normalize(TBN * lightDir); 42 | oEyeDir = normalize(TBN * eyeDir); 43 | oHalfAngle = normalize(oEyeDir + oLightDir); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/OffsetMapping_specular.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 lightDiffuse; 4 | uniform vec4 lightSpecular; 5 | uniform vec4 scaleBias; 6 | uniform float exponent; 7 | uniform sampler2D normalHeightMap; 8 | 9 | in vec3 tangentEyeDir; 10 | in vec3 tangentLightDir[2]; 11 | in vec4 shadowUV[2]; 12 | in vec4 oUv0; 13 | 14 | out vec4 fragColour; 15 | 16 | vec4 lit(float NdotL, float NdotH, float m) { 17 | 18 | float ambient = 1.0; 19 | float diffuse = max(NdotL, 0.0); 20 | float specular = step(0.0, NdotL) * max(NdotH * m, 0.0); 21 | 22 | return vec4(ambient, diffuse, specular, 1.0); 23 | } 24 | 25 | vec3 expand(vec3 v) 26 | { 27 | return (v - 0.5) * 2.0; 28 | } 29 | 30 | /* 31 | Pixel Shader for doing bump mapping with parallax plus diffuse and specular lighting by masterfalcon 32 | */ 33 | void main() 34 | { 35 | float height = texture(normalHeightMap, oUv0.xy).a; 36 | float displacement = (height * scaleBias.x) + scaleBias.y; 37 | vec2 newTexCoord = ((tangentEyeDir * displacement) + oUv0.xyz).xy; 38 | vec3 bumpVec = expand(texture(normalHeightMap, newTexCoord).xyz); 39 | vec3 N = normalize(bumpVec); 40 | 41 | vec3 halfAngle = normalize(tangentEyeDir + tangentLightDir[0]); 42 | float NdotL = dot(normalize(tangentLightDir[0]), N); 43 | float NdotH = dot(normalize(halfAngle), N); 44 | 45 | vec4 Lit = lit(NdotL, NdotH, exponent); 46 | 47 | fragColour = lightDiffuse * Lit.y + lightSpecular * Lit.z; 48 | } 49 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/OldMovieFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec2 oUv0; 4 | out vec4 fragColour; 5 | 6 | uniform sampler2D RT; 7 | uniform sampler2D SplotchesTx; 8 | uniform sampler1D Texture2; 9 | uniform sampler1D SepiaTx; 10 | uniform float time_cycle_period; 11 | uniform float flicker; 12 | uniform float DirtFrequency; 13 | uniform vec3 luminance; 14 | uniform float frameJitter; 15 | uniform float lumiShift; 16 | 17 | vec2 calcSpriteAddr(vec2 texCoord, float DirtFrequency1, float period) 18 | { 19 | return texCoord + texture(Texture2, period * DirtFrequency1).xy; 20 | } 21 | 22 | vec4 getSplotches(vec2 spriteAddr) 23 | { 24 | // get sprite address into paged texture coords space 25 | spriteAddr = spriteAddr / 6.3; 26 | spriteAddr = spriteAddr - (spriteAddr / 33.3); 27 | 28 | // return texture(SplotchesTx, spriteAddr); 29 | return vec4(1.0) * texture(SplotchesTx, spriteAddr).r; 30 | } 31 | 32 | void main() 33 | { 34 | // get sprite address 35 | vec2 spriteAddr = calcSpriteAddr(oUv0, DirtFrequency, time_cycle_period); 36 | 37 | // add some dark and light splotches to the film 38 | vec4 splotches = getSplotches(spriteAddr); 39 | vec4 specs = 1.0 - getSplotches(spriteAddr / 3.0); 40 | 41 | // convert color to base luminance 42 | vec4 base = texture(RT, oUv0 + vec2(0.0, spriteAddr.y * frameJitter)); 43 | float lumi = dot(base.rgb, luminance); 44 | // randomly shift luminance 45 | lumi -= spriteAddr.x * lumiShift; 46 | // tone map luminance 47 | base.rgb = texture(SepiaTx, lumi).rgb; 48 | 49 | // calc flicker speed 50 | float darken = fract(flicker * time_cycle_period); 51 | 52 | // we want darken to cycle between 0.6 and 1.0 53 | darken = abs(darken - 0.5) * 0.4 + 0.6; 54 | // composite dirt onto film 55 | fragColour = base * splotches * darken + specs; 56 | } 57 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/OldTV.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 pos; 4 | in vec2 oUv0; 5 | out vec4 fragColour; 6 | 7 | uniform sampler2D Image; 8 | uniform sampler3D Rand; 9 | uniform sampler3D Noise; 10 | uniform float distortionFreq; 11 | uniform float distortionScale; 12 | uniform float distortionRoll; 13 | uniform float interference; 14 | uniform float frameLimit; 15 | uniform float frameShape; 16 | uniform float frameSharpness; 17 | uniform float time_0_X; 18 | uniform float sin_time_0_X; 19 | 20 | void main() 21 | { 22 | // Define a frame shape 23 | float f = (1 - pos.x * pos.x) * (1 - pos.y * pos.y); 24 | float frame = clamp(frameSharpness * (pow(f, frameShape) - frameLimit), 0.0, 1.0); 25 | 26 | // Interference ... just a texture filled with rand() 27 | float rand = texture(Rand, vec3(1.5 * pos.x, 1.5 * pos.y, time_0_X)).x - 0.2; 28 | 29 | // Some signed noise for the distortion effect 30 | float noisy = texture(Noise, vec3(0, 0.5 * pos.y, 0.1 * time_0_X)).x - 0.5; 31 | 32 | // Repeat a 1 - x^2 (0 < x < 1) curve and roll it with sinus. 33 | float dst = fract(pos.y * distortionFreq + distortionRoll * sin_time_0_X); 34 | dst *= (1 - dst); 35 | // Make sure distortion is highest in the center of the image 36 | dst /= 1 + distortionScale * abs(pos.y); 37 | 38 | // ... and finally distort 39 | vec2 inUv = oUv0; 40 | inUv.x += distortionScale * noisy * dst; 41 | vec4 image = texture(Image, inUv); 42 | 43 | // Combine frame, distorted image and interference 44 | fragColour = frame * (interference * rand + image); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ParticleGS_DisplayGS.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in block { 4 | vec3 pos; 5 | vec4 color; 6 | float radius; 7 | } ColoredFirework[]; 8 | 9 | out block { 10 | vec4 pos; 11 | vec4 color; 12 | vec2 texcoord; 13 | } Firework; 14 | 15 | uniform mat4 inverseView; 16 | uniform mat4 worldViewProj; 17 | 18 | layout(points) in; 19 | layout(triangle_strip, max_vertices = 4) out; 20 | 21 | //The geometry shader that prepares the fireworks for display 22 | void main() 23 | { 24 | vec3 g_positions[4] = vec3[4](vec3(-1, 1, 0), vec3(-1, -1, 0), vec3(1, 1, 0), vec3(1, -1, 0)); 25 | vec2 g_texcoords[4] = vec2[4](vec2(0, 1), vec2(1, 1), vec2(0, 0), vec2(1, 0)); 26 | 27 | // 28 | // Emit two new triangles 29 | // 30 | for(int i=0; i<4; i++) 31 | { 32 | vec3 position = -g_positions[i] * ColoredFirework[0].radius; 33 | position = mat3(inverseView) * position + ColoredFirework[0].pos; 34 | gl_Position = worldViewProj * vec4(position, 1.0); 35 | 36 | Firework.pos = gl_Position; 37 | Firework.color = ColoredFirework[0].color; 38 | Firework.texcoord = g_texcoords[i]; 39 | EmitVertex(); 40 | } 41 | EndPrimitive(); 42 | } 43 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ParticleGS_DisplayPS.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in block { 4 | vec4 pos; 5 | vec4 color; 6 | vec2 texcoord; 7 | } Firework; 8 | 9 | out vec4 fragColour; 10 | 11 | uniform sampler2D diffuseTex; 12 | 13 | //The pixels shaders that colors the fireworks 14 | void main() 15 | { 16 | fragColour = texture(diffuseTex, Firework.texcoord) * Firework.color; 17 | } 18 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ParticleGS_DisplayVS.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // 4 | // Explanation of different particle types 5 | // 6 | #define PT_LAUNCHER 0 //Firework Launcher - launches a PT_SHELL every so many seconds 7 | #define PT_SHELL 1 //Unexploded shell - flies from the origin and explodes into many PT_EMBERXs 8 | #define PT_EMBER1 2 //basic particle - after it's emitted from the shell, it dies 9 | #define PT_EMBER2 3 //after it's emitted, it explodes again into many PT_EMBER1s 10 | #define PT_EMBER3 4 //just a differently colored ember1 11 | #define P_SHELLLIFE 3.0 12 | #define P_EMBER1LIFE 2.5 13 | #define P_EMBER2LIFE 1.5 14 | #define P_EMBER3LIFE 2.0 15 | 16 | in vec4 position; 17 | uniform float inTimer; 18 | uniform float inType; 19 | uniform vec3 inVelocity; 20 | 21 | out block { 22 | vec3 pos; 23 | vec4 color; 24 | float radius; 25 | } ColoredFirework; 26 | 27 | uniform mat4 worldViewProj; 28 | 29 | //The vertex shader that prepares the fireworks for display 30 | void main() 31 | { 32 | // 33 | // Pass the point through 34 | // 35 | ColoredFirework.pos = position.xyz; //Multiply by world matrix? 36 | ColoredFirework.radius = 1.5; 37 | 38 | // 39 | // calculate the color 40 | // 41 | if( inType == PT_LAUNCHER ) 42 | { 43 | ColoredFirework.color = vec4(1,0.1,0.1,1); 44 | ColoredFirework.radius = 1.0; 45 | } 46 | else if( inType == PT_SHELL ) 47 | { 48 | ColoredFirework.color = vec4(0.1,1,1,1); 49 | ColoredFirework.radius = 1.0; 50 | } 51 | else if( inType == PT_EMBER1 ) 52 | { 53 | ColoredFirework.color = vec4(1,1,0.1,1); 54 | ColoredFirework.color *= (inTimer / P_EMBER1LIFE ); 55 | } 56 | else if( inType == PT_EMBER2 ) 57 | { 58 | ColoredFirework.color = vec4(1,0.1,1,1); 59 | } 60 | else if( inType == PT_EMBER3 ) 61 | { 62 | ColoredFirework.color = vec4(1,0.1,0.1,1); 63 | ColoredFirework.color *= (inTimer / P_EMBER3LIFE ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ParticleGS_GenerateVS.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 vertex; 4 | uniform float inTimer; 5 | uniform float inType; 6 | uniform vec3 inVelocity; 7 | 8 | out block { 9 | vec4 Pos; 10 | float Timer; 11 | float Type; 12 | vec3 Vel; 13 | } FireworkData; 14 | 15 | //The vertex shader that prepares the fireworks for display 16 | void main() 17 | { 18 | FireworkData.Pos = vertex; 19 | FireworkData.Timer = inTimer; 20 | FireworkData.Type = inType; 21 | FireworkData.Vel = inVelocity; 22 | } 23 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/PassthroughFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 colour; 4 | out vec4 fragColour; 5 | 6 | /* 7 | Basic ambient lighting fragment program for GLSL ES 8 | */ 9 | void main() 10 | { 11 | fragColour = colour; 12 | } 13 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/PassthroughVP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | void main() 4 | { 5 | //Transform the vertex (ModelViewProj matrix) 6 | gl_Position = ftransform(); 7 | } 8 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/PosterizeFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D RT; 4 | in vec2 oUv0; 5 | out vec4 fragColour; 6 | 7 | void main() 8 | { 9 | float nColors = 8.0; 10 | float gamma = 0.6; 11 | 12 | vec4 texCol = vec4(texture(RT, oUv0)); 13 | vec3 tc = texCol.xyz; 14 | tc = pow(tc, vec3(gamma)); 15 | tc = tc * nColors; 16 | tc = floor(tc); 17 | tc = tc / nColors; 18 | tc = pow(tc, vec3(1.0/gamma)); 19 | fragColour = vec4(tc, texCol.w); 20 | } 21 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/Radial_Blur_FP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | //------------------------------------------------------ 4 | //Radial_Blur_FP.glsl 5 | // Implements radial blur to be used with the compositor 6 | // It's very dependent on screen resolution 7 | //------------------------------------------------------ 8 | 9 | uniform sampler2D tex; 10 | uniform float sampleDist; 11 | uniform float sampleStrength; 12 | 13 | in vec2 oUv0; 14 | out vec4 fragColour; 15 | 16 | void main() 17 | { 18 | float samples[10]; 19 | 20 | samples[0] = -0.08; 21 | samples[1] = -0.05; 22 | samples[2] = -0.03; 23 | samples[3] = -0.02; 24 | samples[4] = -0.01; 25 | samples[5] = 0.01; 26 | samples[6] = 0.02; 27 | samples[7] = 0.03; 28 | samples[8] = 0.05; 29 | samples[9] = 0.08; 30 | 31 | //Vector from pixel to the center of the screen 32 | vec2 dir = 0.5 - oUv0; 33 | 34 | //Distance from pixel to the center (distant pixels have stronger effect) 35 | //float dist = distance( vec2( 0.5, 0.5 ), texCoord ); 36 | float dist = sqrt( dir.x*dir.x + dir.y*dir.y ); 37 | 38 | 39 | //Now that we have dist, we can normlize vector 40 | dir = normalize( dir ); 41 | 42 | //Save the color to be used later 43 | vec4 color = texture( tex, oUv0 ); 44 | //Average the pixels going along the vector 45 | vec4 sum = color; 46 | for (int i = 0; i < 10; i++) 47 | { 48 | vec4 res=texture( tex, oUv0 + dir * samples[i] * sampleDist ); 49 | sum += res; 50 | } 51 | sum /= 11.0; 52 | 53 | //Calculate amount of blur based on 54 | //distance and a strength parameter 55 | float t = dist * sampleStrength; 56 | t = clamp( t, 0.0, 1.0 );//We need 0 <= t <= 1 57 | 58 | //Blend the original color with the averaged pixels 59 | fragColour = mix( color, sum, t ); 60 | } 61 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/SharpenEdgesFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D RT; 4 | uniform vec2 vTexelSize; 5 | 6 | in vec2 oUv0; 7 | in vec2 oUv1; 8 | out vec4 fragColour; 9 | 10 | void main() 11 | { 12 | vec2 usedTexelED[8]; 13 | usedTexelED[0] = vec2(-1, -1); 14 | usedTexelED[1] = vec2(0, -1); 15 | usedTexelED[2] = vec2(1, -1); 16 | usedTexelED[3] = vec2(-1, 0); 17 | usedTexelED[4] = vec2(1, 0); 18 | usedTexelED[5] = vec2(-1, 1); 19 | usedTexelED[6] = vec2(0, 1); 20 | usedTexelED[7] = vec2(1, 1); 21 | 22 | vec4 tc = texture(RT, oUv0); 23 | vec4 cAvgColor = vec4(9.0 * tc); 24 | 25 | for(int t=0; t<8; t++) 26 | cAvgColor -= texture(RT, oUv0 + vTexelSize * usedTexelED[t]); 27 | 28 | fragColour = cAvgColor; 29 | } 30 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ShowNormals.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 position; 4 | in vec3 normal; 5 | 6 | out vec4 oUv0; 7 | 8 | uniform mat4 worldViewProj; 9 | 10 | void main() 11 | { 12 | gl_Position = worldViewProj * position; 13 | oUv0 = vec4(normal, 1.0); 14 | } 15 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ShowTangents.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 position; 4 | in vec3 tangent; 5 | 6 | out vec4 oUv0; 7 | 8 | uniform mat4 worldViewProj; 9 | 10 | void main() 11 | { 12 | gl_Position = worldViewProj * position; 13 | oUv0 = vec4(tangent, 1.0); 14 | } 15 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ShowUV.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 ambientUV; 4 | in vec4 ambColour; 5 | 6 | out vec4 fragColour; 7 | 8 | // Basic fragment program to display UV 9 | void main() 10 | { 11 | // wrap values using fract 12 | fragColour = vec4(fract(ambientUV.x), fract(ambientUV.y), 0.0, 1.0); 13 | } 14 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/ShowUVdir3D.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 oUv0; 4 | 5 | out vec4 fragColour; 6 | 7 | // Basic fragment program to display 3d uv 8 | void main() 9 | { 10 | vec3 n = normalize(oUv0.xyz); 11 | fragColour = vec4(n.x, n.y, n.z, 1.0); 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/StdQuad_Tex2_vp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 worldViewProj; 4 | in vec4 vertex; 5 | in vec2 uv0; 6 | out vec2 oUv0; 7 | out vec2 oUv1; 8 | 9 | void main() 10 | { 11 | // Use standardise transform, so work accord with render system specific (RS depth, requires texture flipping, etc) 12 | gl_Position = worldViewProj * vertex; 13 | 14 | // Convert to image-space 15 | oUv0 = uv0; 16 | oUv1 = oUv0; 17 | } 18 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/StdQuad_Tex2a_vp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 worldViewProj; 4 | in vec4 vertex; 5 | in vec2 uv0; 6 | out vec2 oUv0; 7 | out vec2 oUv1; 8 | out vec4 pos; 9 | 10 | void main() 11 | { 12 | // Use standardise transform, so work accord with render system specific (RS depth, requires texture flipping, etc) 13 | gl_Position = worldViewProj * vertex; 14 | 15 | oUv0 = uv0; 16 | oUv1 = -vertex.xy; 17 | pos = gl_Position; 18 | } 19 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/StdQuad_Tex3_vp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 worldViewProj; 4 | in vec4 vertex; 5 | in vec2 uv0; 6 | out vec2 oUv0; 7 | out vec2 oUv1; 8 | out vec2 oUv2; 9 | out vec4 pos; 10 | 11 | void main() 12 | { 13 | // Use standardise transform, so work accord with render system specific (RS depth, requires texture flipping, etc) 14 | gl_Position = worldViewProj * vertex; 15 | 16 | 17 | // Convert to image-space 18 | oUv0 = uv0; 19 | oUv1 = oUv0; 20 | oUv2 = oUv0; 21 | pos = gl_Position; 22 | } 23 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/StdQuad_Tex4_vp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 worldViewProj; 4 | in vec4 vertex; 5 | in vec2 uv0; 6 | out vec2 oUv0; 7 | out vec2 oUv1; 8 | out vec2 oUv2; 9 | out vec2 oUv3; 10 | out vec4 pos; 11 | 12 | void main() 13 | { 14 | // Use standardise transform, so work accord with render system specific (RS depth, requires texture flipping, etc) 15 | gl_Position = worldViewProj * vertex; 16 | 17 | oUv0 = uv0; 18 | oUv1 = oUv0; 19 | oUv2 = oUv0; 20 | oUv3 = oUv0; 21 | pos = gl_Position; 22 | } 23 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/StdQuad_vp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 vertex; 4 | in vec2 uv0; 5 | uniform mat4 worldViewProj; 6 | 7 | out vec2 oUv0; 8 | 9 | void main() 10 | { 11 | gl_Position = worldViewProj * vertex; 12 | 13 | oUv0 = uv0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/SwizzleGP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #extension GL_EXT_geometry_shader4 : enable 4 | 5 | uniform vec4 origColor; 6 | uniform vec4 cloneColor; 7 | 8 | void main(void) 9 | { 10 | 11 | //increment variable 12 | int i; 13 | 14 | ///////////////////////////////////////////////////////////// 15 | //This example has two parts 16 | // step a) draw the primitive pushed down the pipeline 17 | // there are gl_Vertices # of vertices 18 | // put the vertex value into gl_Position 19 | // use EmitVertex => 'create' a new vertex 20 | // use EndPrimitive to signal that you are done creating a primitive! 21 | // step b) create a new piece of geometry (I.E. WHY WE ARE USING A GEOMETRY SHADER!) 22 | // I just do the same loop, but swizzle the x and y values 23 | // result => the line we want to draw, and the same line, but along the other axis 24 | 25 | //Pass-thru! 26 | for(i=0; i< gl_VerticesIn; i++){ 27 | gl_Position = gl_PositionIn[i]; 28 | gl_FrontColor = origColor; 29 | EmitVertex(); 30 | } 31 | EndPrimitive(); 32 | //New piece of geometry! We just swizzle the x and y terms 33 | for(i=0; i< gl_VerticesIn; i++){ 34 | gl_Position = gl_PositionIn[i]; 35 | gl_Position.xy = gl_Position.yx; 36 | gl_FrontColor = cloneColor; 37 | EmitVertex(); 38 | } 39 | EndPrimitive(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/TilingFP.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D RT; 4 | uniform float NumTiles; 5 | uniform float Threshold; 6 | in vec2 oUv0; 7 | out vec4 fragColour; 8 | 9 | void main() 10 | { 11 | vec3 EdgeColor = vec3(0.7, 0.7, 0.7); 12 | 13 | float size = 1.0/NumTiles; 14 | vec2 Pbase = oUv0 - mod(oUv0, vec2(size)); 15 | vec2 PCenter = vec2(Pbase + (size/2.0)); 16 | vec2 st = (oUv0 - Pbase)/size; 17 | vec4 c1 = vec4(0.0); 18 | vec4 c2 = vec4(0.0); 19 | vec4 invOff = vec4((1.0-EdgeColor),1.0); 20 | if (st.x > st.y) { c1 = invOff; } 21 | float threshholdB = 1.0 - Threshold; 22 | if (st.x > threshholdB) { c2 = c1; } 23 | if (st.y > threshholdB) { c2 = c1; } 24 | vec4 cBottom = c2; 25 | c1 = vec4(0.0); 26 | c2 = vec4(0.0); 27 | if (st.x > st.y) { c1 = invOff; } 28 | if (st.x < Threshold) { c2 = c1; } 29 | if (st.y < Threshold) { c2 = c1; } 30 | vec4 cTop = c2; 31 | vec4 tileColor = vec4(texture(RT, PCenter)); 32 | vec4 result = tileColor + cTop - cBottom; 33 | fragColour = result; 34 | } 35 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/crowdVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 viewProjectionMatrix; 4 | uniform float numBones; 5 | uniform vec4 worldMatrix3x4Array[240]; 6 | uniform vec4 lightDiffuseColour; 7 | uniform vec4 ambient; 8 | uniform vec4 lightPos; 9 | 10 | in vec4 blendIndices; 11 | in vec4 blendWeights; 12 | 13 | in vec4 vertex; 14 | in vec3 normal; 15 | in vec4 uv0; 16 | in vec4 uv1; 17 | out vec4 colour; 18 | out vec4 oUv0; 19 | out vec4 oUv1; 20 | 21 | void main() 22 | { 23 | vec3 blendPos = vec3(0); 24 | vec3 blendNorm = vec3(0); 25 | vec3 tmpPos = vec3(0); 26 | vec3 tmpNorm = vec3(0); 27 | 28 | int instanceOffset = int(uv1.x) * 3 * int(numBones); 29 | for (int bone = 0; bone < 2; ++bone) 30 | { 31 | // perform matrix multiplication manually since no 3x4 matrices 32 | for (int row = 0; row < 3; ++row) 33 | { 34 | int idx = instanceOffset + int(blendIndices[bone]) * 3 + row; 35 | vec4 blendMatrixRow = worldMatrix3x4Array[idx]; 36 | tmpPos[row] = dot(blendMatrixRow, gl_Vertex); 37 | #if SHADOW_CASTER 38 | #else 39 | tmpNorm[row] = dot(blendMatrixRow.xyz, gl_Normal); 40 | #endif 41 | } 42 | // now weight this into final 43 | blendPos += tmpPos * blendWeights[bone]; 44 | #if SHADOW_CASTER 45 | #else 46 | blendNorm += tmpNorm * blendWeights[bone]; 47 | #endif 48 | } 49 | 50 | // apply view / projection to position 51 | gl_Position = viewProjectionMatrix * vec4(blendPos, 1); 52 | 53 | #if SHADOW_CASTER 54 | colour = ambient; 55 | #else 56 | // simple lighting model 57 | vec3 lightDir = normalize( 58 | lightPos.xyz - (blendPos.xyz * lightPos.w)); 59 | colour = ambient 60 | + clamp(dot(lightDir, blendNorm), 0.0, 1.0) * lightDiffuseColour; 61 | #endif 62 | colour = vec4(0); 63 | oUv0 = uv0; 64 | } 65 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/hdr_bloom.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D inRTT; 4 | 5 | uniform vec4 sampleOffsets[15]; 6 | uniform vec4 sampleWeights[15]; 7 | 8 | in vec2 oUv0; 9 | out vec4 fragColour; 10 | 11 | void main(void) 12 | { 13 | vec4 accum = vec4(0.0, 0.0, 0.0, 1.0); 14 | vec2 sampleUV; 15 | 16 | for( int i = 0; i < 15; i++ ) 17 | { 18 | // Sample from adjacent points, 7 each side and central 19 | sampleUV = oUv0 + sampleOffsets[i].xy; 20 | accum += sampleWeights[i] * texture(inRTT, sampleUV); 21 | } 22 | 23 | fragColour = accum; 24 | } 25 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/hdr_downscale2x2luminence.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D inRTT; 4 | uniform vec2 texelSize; 5 | 6 | in vec2 oUv0; 7 | out vec4 fragColour; 8 | 9 | void main(void) 10 | { 11 | 12 | vec4 accum = vec4(0.0); 13 | vec4 LUMINENCE_FACTOR = vec4(0.27, 0.67, 0.06, 0.0); 14 | 15 | // Get colour from source 16 | accum += texture(inRTT, oUv0 + texelSize * vec2(-0.5, -0.5)); 17 | accum += texture(inRTT, oUv0 + texelSize * vec2(-0.5, 0.5)); 18 | accum += texture(inRTT, oUv0 + texelSize * vec2(0.5, 0.5)); 19 | accum += texture(inRTT, oUv0 + texelSize * vec2(0.5, -0.5)); 20 | 21 | // Adjust the accumulated amount by lum factor 22 | float lum = dot(accum, LUMINENCE_FACTOR); 23 | 24 | // Take average of 4 samples 25 | lum *= 0.25; 26 | fragColour = vec4(lum, lum, lum, 1.0); 27 | } 28 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/hdr_downscale3x3.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D inRTT; 4 | uniform vec2 texelSize; 5 | 6 | in vec2 oUv0; 7 | out vec4 fragColour; 8 | 9 | void main(void) 10 | { 11 | vec4 accum = vec4(0.0); 12 | 13 | // Get colour from source 14 | accum += texture(inRTT, oUv0 + texelSize * vec2(-1.0, -1.0)); 15 | accum += texture(inRTT, oUv0 + texelSize * vec2( 0.0, -1.0)); 16 | accum += texture(inRTT, oUv0 + texelSize * vec2( 1.0, -1.0)); 17 | accum += texture(inRTT, oUv0 + texelSize * vec2(-1.0, 0.0)); 18 | accum += texture(inRTT, oUv0 + texelSize * vec2( 0.0, 0.0)); 19 | accum += texture(inRTT, oUv0 + texelSize * vec2( 1.0, 0.0)); 20 | accum += texture(inRTT, oUv0 + texelSize * vec2(-1.0, 1.0)); 21 | accum += texture(inRTT, oUv0 + texelSize * vec2( 0.0, 1.0)); 22 | accum += texture(inRTT, oUv0 + texelSize * vec2( 1.0, 1.0)); 23 | 24 | // take average of 9 samples 25 | accum *= 0.1111111111111111; 26 | 27 | fragColour = accum; 28 | } 29 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/hdr_downscale3x3brightpass.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D inRTT; 4 | uniform sampler2D inLum; 5 | uniform vec2 texelSize; 6 | 7 | in vec2 oUv0; 8 | out vec4 fragColour; 9 | const vec4 BRIGHT_LIMITER = vec4(0.6, 0.6, 0.6, 0.0); 10 | 11 | // declare external function 12 | vec4 toneMap(in vec4 inColour, in float lum); 13 | 14 | void main(void) 15 | { 16 | vec4 accum = vec4(0.0); 17 | 18 | accum += texture(inRTT, oUv0 + texelSize * vec2(-1.0, -1.0)); 19 | accum += texture(inRTT, oUv0 + texelSize * vec2( 0.0, -1.0)); 20 | accum += texture(inRTT, oUv0 + texelSize * vec2( 1.0, -1.0)); 21 | accum += texture(inRTT, oUv0 + texelSize * vec2(-1.0, 0.0)); 22 | accum += texture(inRTT, oUv0 + texelSize * vec2( 0.0, 0.0)); 23 | accum += texture(inRTT, oUv0 + texelSize * vec2( 1.0, 0.0)); 24 | accum += texture(inRTT, oUv0 + texelSize * vec2(-1.0, 1.0)); 25 | accum += texture(inRTT, oUv0 + texelSize * vec2( 0.0, 1.0)); 26 | accum += texture(inRTT, oUv0 + texelSize * vec2( 1.0, 1.0)); 27 | 28 | // take average of 9 samples 29 | accum *= 0.1111111111111111; 30 | 31 | // Reduce bright and clamp 32 | accum = max(vec4(0.0, 0.0, 0.0, 1.0), accum - BRIGHT_LIMITER); 33 | 34 | // Sample the luminence texture 35 | vec4 lum = texture(inLum, vec2(0.5)); 36 | 37 | // Tone map result 38 | fragColour = toneMap(accum, lum.r); 39 | } 40 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/hdr_finalToneMapping.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D inRTT; 4 | uniform sampler2D inBloom; 5 | uniform sampler2D inLum; 6 | 7 | in vec2 oUv0; 8 | out vec4 fragColour; 9 | 10 | // declare external function 11 | vec4 toneMap(in vec4 inColour, in float lum); 12 | 13 | void main(void) 14 | { 15 | // Get main scene colour 16 | vec4 sceneCol = texture(inRTT, oUv0); 17 | 18 | // Get luminence value 19 | vec4 lum = texture(inLum, vec2(0.5)); 20 | 21 | // tone map this 22 | vec4 toneMappedSceneCol = toneMap(sceneCol, lum.r); 23 | 24 | // Get bloom colour 25 | vec4 bloom = texture(inBloom, oUv0); 26 | 27 | // Add scene & bloom 28 | fragColour = vec4(toneMappedSceneCol.rgb + bloom.rgb, 1.0); 29 | } 30 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/hdr_tonemap_util.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | const float MIDDLE_GREY = 0.72; 4 | const float FUDGE = 0.001; 5 | const float L_WHITE = 1.5; 6 | 7 | /** Tone mapping function 8 | @note Only affects rgb, not a 9 | @param inColour The HDR colour 10 | @param lum The scene lumninence 11 | @returns Tone mapped colour 12 | */ 13 | vec4 toneMap(in vec4 inColour, in float lum) 14 | { 15 | // From Reinhard et al 16 | // "Photographic Tone Reproduction for Digital Images" 17 | 18 | // Initial luminence scaling (equation 2) 19 | inColour.rgb *= MIDDLE_GREY / (FUDGE + lum); 20 | 21 | // Control white out (equation 4 nom) 22 | inColour.rgb *= (1.0 + inColour.rgb / L_WHITE); 23 | 24 | // Final mapping (equation 4 denom) 25 | inColour.rgb /= (1.0 + inColour.rgb); 26 | 27 | return inColour; 28 | } 29 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/instancingVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 position; 4 | in vec3 normal; 5 | in vec4 uv0; 6 | in float uv1; 7 | 8 | out vec4 oColor_0; 9 | #if SHADOW_CASTER 10 | #else 11 | out vec2 oTexcoord2_0; 12 | #endif 13 | 14 | uniform mat4x3 worldMatrix3x4Array[80]; 15 | uniform mat4 viewProjectionMatrix; 16 | uniform vec4 lightPos; 17 | uniform vec4 ambient; 18 | uniform vec4 lightDiffuseColour; 19 | 20 | void main() 21 | { 22 | #if SHADOW_CASTER 23 | // transform by indexed matrix 24 | vec4 transformedPos = vec4((worldMatrix3x4Array[int(uv1)] * position).xyz, 1.0); 25 | 26 | // view / projection 27 | gl_Position = viewProjectionMatrix * transformedPos; 28 | 29 | oColor_0 = ambient; 30 | #else 31 | // transform by indexed matrix 32 | vec4 transformedPos = vec4((worldMatrix3x4Array[int(uv1)] * position).xyz, 1.0); 33 | 34 | // view / projection 35 | gl_Position = viewProjectionMatrix * transformedPos; 36 | oTexcoord2_0 = uv0.xy; 37 | 38 | vec3 norm = mat3(worldMatrix3x4Array[int(uv1)]) * normal; 39 | 40 | vec3 lightDir = normalize( 41 | lightPos.xyz - (transformedPos.xyz * lightPos.w)); 42 | 43 | oColor_0 = ambient + clamp(dot(lightDir, norm), 0.0, 1.0) * lightDiffuseColour; 44 | #endif 45 | } 46 | 47 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/mrttestfp_quad.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D rt0; 4 | uniform sampler2D rt1; 5 | uniform sampler2D rt2; 6 | uniform sampler2D rt3; 7 | 8 | in vec2 uv; 9 | out vec4 fragColour; 10 | 11 | void main(void) 12 | { 13 | 14 | //fragColour = texture(rt0, uv); 15 | fragColour = texture(rt1, uv); 16 | //fragColour = texture(rt2, uv); 17 | //fragColour = texture(rt3, uv); 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/mrttestfp_scene.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // Need to enable the draw buffers extension 4 | #extension GL_ARB_draw_buffers : enable 5 | 6 | uniform sampler2D tex0; 7 | 8 | void main() 9 | { 10 | vec4 baseColour = texture(tex0, gl_TexCoord[0].xy); 11 | 12 | gl_FragData[0] = baseColour; 13 | 14 | gl_FragData[1] = baseColour * vec4(1, 0, 0, 1); 15 | 16 | float abs = (baseColour.r + baseColour.g + baseColour.b) * 0.333; 17 | gl_FragData[2] = vec4(abs, abs, abs, 1); 18 | 19 | float invabs = 1.0 - abs; 20 | gl_FragData[3] = vec4(invabs, invabs, invabs, 1); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/oceanGLSL.frag: -------------------------------------------------------------------------------- 1 | // oceanGLSL.frag 2 | // fragment program for Ocean water simulation 3 | // 05 Aug 2005 4 | // adapted for Ogre by nfz 5 | // converted from HLSL to GLSL 6 | // original shader source from Render Monkey 1.6 Reflections Refractions.rfx 7 | 8 | // 06 Aug 2005: moved uvw calculation from fragment program into vertex program 9 | 10 | #version 150 11 | 12 | uniform float fadeBias; 13 | uniform float fadeExp; 14 | uniform vec4 waterColor; 15 | uniform sampler3D Noise; 16 | uniform samplerCube skyBox; 17 | 18 | in vec3 uvw; 19 | in vec4 oNormal; 20 | in vec3 vVec; 21 | out vec4 fragColour; 22 | 23 | void main(void) 24 | { 25 | vec3 noisy = texture(Noise, uvw).xyz; 26 | 27 | // convert to signed noise 28 | vec3 bump = 2.0 * noisy - 1.0; 29 | bump.xz *= 0.15; 30 | // Make sure the normal always points upwards 31 | // note that Ogres y axis is vertical (RM Z axis is vertical) 32 | bump.y = 0.8 * abs(bump.y) + 0.2; 33 | // Offset the surface normal with the bump 34 | bump = normalize(oNormal.xyz + bump); 35 | 36 | // Find the reflection vector 37 | vec3 normView = normalize(vVec); 38 | vec3 reflVec = reflect(normView, bump); 39 | // Ogre has z flipped for cubemaps 40 | reflVec.z = -reflVec.z; 41 | vec4 refl = texture(skyBox, reflVec); 42 | 43 | // set up for fresnel calc 44 | float lrp = 1.0 - dot(-normView, bump); 45 | 46 | // Interpolate between the water color and reflection for fresnel effect 47 | fragColour = mix(waterColor, refl, clamp(fadeBias + pow(lrp, fadeExp), 0.0, 1.0) ); 48 | } 49 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/oceanGLSL.vert: -------------------------------------------------------------------------------- 1 | // oceanGLSL.vert 2 | // vertex program for Ocean water simulation 3 | // 05 Aug 2005 4 | // adapted for Ogre by nfz 5 | // converted from HLSL to GLSL 6 | // original shader source from Render Monkey 1.6 Reflections Refractions.rfx 7 | 8 | // 06 Aug 2005: moved uvw calculation from fragment program into vertex program 9 | 10 | #version 150 11 | 12 | uniform vec3 scale; 13 | uniform vec3 eyePosition; 14 | uniform vec2 waveSpeed; 15 | uniform float noiseSpeed; 16 | uniform float time_0_X; 17 | uniform mat4 worldViewProj; 18 | 19 | in vec4 vertex; 20 | in vec4 normal; 21 | 22 | out vec3 uvw; 23 | out vec4 oNormal; 24 | out vec3 vVec; 25 | 26 | void main(void) 27 | { 28 | gl_Position = worldViewProj * vertex; 29 | 30 | // the view vector needs to be in vertex space 31 | vVec = vertex.xyz - eyePosition; 32 | oNormal = normal; 33 | // uvw is the calculated uvw coordinates based on vertex position 34 | uvw = vertex.xyz * scale.xyz; 35 | uvw.xz += waveSpeed * time_0_X; 36 | uvw.y += uvw.z + noiseSpeed * time_0_X; 37 | } 38 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/pssmCasterFp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec2 oDepth; 4 | out vec4 fragColour; 5 | uniform vec4 pssmSplitPoints; 6 | 7 | void main() 8 | { 9 | float finalDepth = oDepth.x / oDepth.y; 10 | fragColour = vec4(finalDepth, finalDepth, finalDepth, 1.0); 11 | } 12 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/pssmCasterVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | out vec2 oDepth; 4 | uniform mat4 worldViewProjMatrix; 5 | in vec4 vertex; 6 | 7 | void main() 8 | { 9 | // This is the view space position 10 | gl_Position = worldViewProjMatrix * vertex; 11 | 12 | // Depth info for the fragment. 13 | oDepth.x = gl_Position.z; 14 | oDepth.y = gl_Position.w; 15 | 16 | // Clamp z to zero. seem to do the trick. :-/ 17 | //oPosition.z = max(oPosition.z, 0); 18 | } 19 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/pssmReceiverVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform vec4 lightPosition; // object space 4 | uniform vec3 eyePosition; // object space 5 | uniform mat4 worldViewProjMatrix; 6 | uniform mat4 texWorldViewProjMatrix0; 7 | uniform mat4 texWorldViewProjMatrix1; 8 | uniform mat4 texWorldViewProjMatrix2; 9 | 10 | out vec4 oUv0; 11 | out vec3 oLightDir; 12 | out vec3 oHalfAngle; 13 | out vec4 oLightPosition0; 14 | out vec4 oLightPosition1; 15 | out vec4 oLightPosition2; 16 | out vec3 oNormal; 17 | 18 | in vec4 position; 19 | in vec3 normal; 20 | in vec4 uv0; 21 | 22 | void main() 23 | { 24 | // Calculate output position 25 | gl_Position = worldViewProjMatrix * position; 26 | 27 | // Pass the main uvs straight through unchanged 28 | oUv0.xy = uv0.xy; 29 | oUv0.z = gl_Position.z; 30 | 31 | // Calculate tangent space light vector 32 | // Get object space light direction 33 | oLightDir = normalize(lightPosition.xyz - (position * lightPosition.w).xyz); 34 | 35 | // Calculate half-angle in tangent space 36 | vec3 eyeDir = normalize(eyePosition - position.xyz); 37 | oHalfAngle = normalize(eyeDir + oLightDir); 38 | 39 | // Calculate the position of vertex in light space 40 | oLightPosition0 = texWorldViewProjMatrix0 * position; 41 | oLightPosition1 = texWorldViewProjMatrix1 * position; 42 | oLightPosition2 = texWorldViewProjMatrix2 * position; 43 | 44 | oNormal = normal; 45 | } 46 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/skinningTwoWeightsShadowCasterVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // Example GLSL program for skinning with two bone weights per vertex 4 | 5 | in vec4 vertex; 6 | in vec4 uv0; 7 | in vec4 blendIndices; 8 | in vec4 blendWeights; 9 | 10 | // 3x4 matrix, passed as vec4's for compatibility with GL 2.0 11 | // GL 2.0 supports 3x4 matrices 12 | // Support 24 bones ie 24*3, but use 72 since our parser can pick that out for sizing 13 | uniform vec4 worldMatrix3x4Array[72]; 14 | uniform mat4 viewProjectionMatrix; 15 | uniform vec4 ambient; 16 | 17 | void main() 18 | { 19 | vec3 blendPos = vec3(0,0,0); 20 | 21 | for (int bone = 0; bone < 2; ++bone) 22 | { 23 | // perform matrix multiplication manually since no 3x4 matrices 24 | // ATI GLSL compiler can't handle indexing an array within an array so calculate the inner index first 25 | int idx = int(blendIndices[bone]) * 3; 26 | // ATI GLSL compiler can't handle unrolling the loop so do it manually 27 | // ATI GLSL has better performance when mat4 is used rather than using individual dot product 28 | // There is a bug in ATI mat4 constructor (Cat 7.2) when indexed uniform array elements are used as vec4 parameter so manually assign 29 | mat4 worldMatrix; 30 | worldMatrix[0] = worldMatrix3x4Array[idx]; 31 | worldMatrix[1] = worldMatrix3x4Array[idx + 1]; 32 | worldMatrix[2] = worldMatrix3x4Array[idx + 2]; 33 | worldMatrix[3] = vec4(0); 34 | // now weight this into final 35 | blendPos += (vertex * worldMatrix).xyz * blendWeights[bone]; 36 | } 37 | 38 | // apply view / projection to position 39 | gl_Position = viewProjectionMatrix * vec4(blendPos, 1); 40 | 41 | gl_FrontSecondaryColor = vec4(0,0,0,0); 42 | gl_FrontColor = ambient; 43 | gl_TexCoord[0] = uv0; 44 | } 45 | -------------------------------------------------------------------------------- /media/materials/programs/GLSL150/skinningTwoWeightsVp.glsl: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // Example GLSL program for skinning with two bone weights per vertex 4 | 5 | in vec4 vertex; 6 | in vec3 normal; 7 | in vec4 uv0; 8 | in vec4 blendIndices; 9 | in vec4 blendWeights; 10 | 11 | // 3x4 matrix, passed as vec4's for compatibility with GL 2.0 12 | // GL 2.0 supports 3x4 matrices 13 | // Support 24 bones ie 24*3, but use 72 since our parser can pick that out for sizing 14 | uniform vec4 worldMatrix3x4Array[72]; 15 | uniform mat4 viewProjectionMatrix; 16 | uniform vec4 lightPos[2]; 17 | uniform vec4 lightDiffuseColour[2]; 18 | uniform vec4 ambient; 19 | uniform vec4 diffuse; 20 | 21 | out vec4 colour; 22 | out vec4 uv; 23 | 24 | void main() 25 | { 26 | vec3 blendPos = vec3(0.0, 0.0, 0.0); 27 | vec3 blendNorm = vec3(0.0, 0.0, 0.0); 28 | 29 | for (int bone = 0; bone < 2; ++bone) 30 | { 31 | // perform matrix multiplication manually since no 3x4 matrices 32 | // ATI GLSL compiler can't handle indexing an array within an array so calculate the inner index first 33 | int idx = int(blendIndices[bone]) * 3; 34 | // ATI GLSL compiler can't handle unrolling the loop so do it manually 35 | // ATI GLSL has better performance when mat4 is used rather than using individual dot product 36 | // There is a bug in ATI mat4 constructor (Cat 7.2) when indexed uniform array elements are used as vec4 parameter so manually assign 37 | mat4 worldMatrix; 38 | worldMatrix[0] = worldMatrix3x4Array[idx]; 39 | worldMatrix[1] = worldMatrix3x4Array[idx + 1]; 40 | worldMatrix[2] = worldMatrix3x4Array[idx + 2]; 41 | worldMatrix[3] = vec4(0); 42 | // now weight this into final 43 | float weight = blendWeights[bone]; 44 | blendPos += (vertex * worldMatrix).xyz * weight; 45 | 46 | mat3 worldRotMatrix = mat3(worldMatrix[0].xyz, worldMatrix[1].xyz, worldMatrix[2].xyz); 47 | blendNorm += (normal * worldRotMatrix) * weight; 48 | } 49 | 50 | blendNorm = normalize(blendNorm); 51 | 52 | // apply view / projection to position 53 | gl_Position = viewProjectionMatrix * vec4(blendPos, 1.0); 54 | 55 | // simple vertex lighting model 56 | vec3 lightDir0 = normalize( 57 | lightPos[0].xyz - (blendPos * lightPos[0].w)); 58 | vec3 lightDir1 = normalize( 59 | lightPos[1].xyz - (blendPos * lightPos[1].w)); 60 | 61 | colour = diffuse * (ambient + (clamp(dot(lightDir0, blendNorm), 0.0, 1.0) * lightDiffuseColour[0]) + 62 | (clamp(dot(lightDir1, blendNorm), 0.0, 1.0) * lightDiffuseColour[1])); 63 | 64 | uv = uv0; 65 | } 66 | -------------------------------------------------------------------------------- /media/materials/programs/skinningTwoWeightsVp.glsl: -------------------------------------------------------------------------------- 1 | // Example GLSL program for skinning with two bone weights per vertex 2 | 3 | attribute vec4 vertex; 4 | attribute vec3 normal; 5 | attribute vec4 uv0; 6 | attribute vec4 blendIndices; 7 | attribute vec4 blendWeights; 8 | 9 | // 3x4 matrix, passed as vec4's for compatibility with GL 2.0 10 | // GL 2.0 supports 3x4 matrices 11 | // Support 24 bones ie 24*3, but use 72 since our parser can pick that out for sizing 12 | uniform vec4 worldMatrix3x4Array[72]; 13 | uniform mat4 viewProjectionMatrix; 14 | uniform vec4 lightPos[2]; 15 | uniform vec4 lightDiffuseColour[2]; 16 | 17 | void main() 18 | { 19 | vec3 blendPos = vec3(0,0,0); 20 | vec3 blendNorm = vec3(0,0,0); 21 | 22 | for (int bone = 0; bone < 2; ++bone) 23 | { 24 | // perform matrix multiplication manually since no 3x4 matrices 25 | // ATI GLSL compiler can't handle indexing an array within an array so calculate the inner index first 26 | int idx = int(blendIndices[bone]) * 3; 27 | // ATI GLSL compiler can't handle unrolling the loop so do it manually 28 | // ATI GLSL has better performance when mat4 is used rather than using individual dot product 29 | // There is a bug in ATI mat4 constructor (Cat 7.2) when indexed uniform array elements are used as vec4 parameter so manually assign 30 | mat4 worldMatrix; 31 | worldMatrix[0] = worldMatrix3x4Array[idx]; 32 | worldMatrix[1] = worldMatrix3x4Array[idx + 1]; 33 | worldMatrix[2] = worldMatrix3x4Array[idx + 2]; 34 | worldMatrix[3] = vec4(0); 35 | // now weight this into final 36 | float weight = blendWeights[bone]; 37 | blendPos += (vertex * worldMatrix).xyz * weight; 38 | 39 | mat3 worldRotMatrix = mat3(worldMatrix[0].xyz, worldMatrix[1].xyz, worldMatrix[2].xyz); 40 | blendNorm += (normal * worldRotMatrix) * weight; 41 | 42 | } 43 | 44 | // apply view / projection to position 45 | gl_Position = viewProjectionMatrix * vec4(blendPos, 1); 46 | 47 | // simple vertex lighting model 48 | vec3 lightDir0 = normalize( 49 | lightPos[0].xyz - (blendPos.xyz * lightPos[0].w)); 50 | vec3 lightDir1 = normalize( 51 | lightPos[1].xyz - (blendPos.xyz * lightPos[1].w)); 52 | 53 | gl_FrontSecondaryColor = vec4(0); 54 | gl_FrontColor = vec4(0.5, 0.5, 0.5, 1.0) 55 | + clamp(dot(lightDir0, blendNorm), 0.0, 1.0) * lightDiffuseColour[0] 56 | + clamp(dot(lightDir1, blendNorm), 0.0, 1.0) * lightDiffuseColour[1]; 57 | 58 | gl_TexCoord[0] = uv0; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /media/materials/scripts/QBuild.material: -------------------------------------------------------------------------------- 1 | material BaseFlatOutlined 2 | { 3 | technique 4 | { 5 | pass 6 | { 7 | ambient 0.5 0.5 0.5 1.0 8 | diffuse 0.6 0.6 0.6 1.0 9 | emissive 0.25 0.25 0.25 1.0 10 | shading flat 11 | } 12 | 13 | pass 14 | { 15 | ambient 0.2 0.2 0.2 16 | diffuse 0.2 0.2 0.2 17 | emissive 0.4 0.4 0.4 18 | polygon_mode wireframe 19 | depth_bias 10 20 | } 21 | } 22 | } 23 | 24 | material BaseOutlined 25 | { 26 | technique 27 | { 28 | pass 29 | { 30 | ambient 0.5 0.5 0.5 1.0 31 | diffuse 0.6 0.6 0.6 1.0 32 | emissive 0.25 0.25 0.25 1.0 33 | } 34 | 35 | pass 36 | { 37 | ambient 0.2 0.2 0.2 38 | diffuse 0.2 0.2 0.2 39 | emissive 0.4 0.4 0.4 40 | polygon_mode wireframe 41 | depth_bias 10 42 | } 43 | } 44 | } 45 | 46 | material BaseMaterial 47 | { 48 | technique 49 | { 50 | pass 51 | { 52 | lighting on 53 | ambient 0.5 0.5 0.5 1.0 54 | diffuse 0.6 0.6 0.6 1.0 55 | emissive 0.25 0.25 0.25 1.0 56 | } 57 | } 58 | } 59 | 60 | 61 | material Examples/GrassFloor 62 | { 63 | technique 64 | { 65 | pass 66 | { 67 | texture_unit 68 | { 69 | texture grass_1024.jpg 70 | } 71 | } 72 | } 73 | } 74 | 75 | 76 | material Red 77 | { 78 | technique 79 | { 80 | pass 81 | { 82 | lighting on 83 | 84 | ambient 0.3 0.1 0.1 1.0 85 | diffuse 0.8 0.05 0.05 1.0 86 | emissive 0.0 0.0 0.0 1.0 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /media/materials/textures/grass_1024.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/media/materials/textures/grass_1024.jpg -------------------------------------------------------------------------------- /media/models/Rumba Dancing.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/media/models/Rumba Dancing.fbx -------------------------------------------------------------------------------- /media/models/Twist Dance.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/media/models/Twist Dance.fbx -------------------------------------------------------------------------------- /media/models/ninja.mesh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/media/models/ninja.mesh -------------------------------------------------------------------------------- /media/models/ninja.skeleton: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/media/models/ninja.skeleton -------------------------------------------------------------------------------- /media/models/robot.mesh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/media/models/robot.mesh -------------------------------------------------------------------------------- /media/models/robot.skeleton: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/media/models/robot.skeleton -------------------------------------------------------------------------------- /media/packs/OgreCore.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/media/packs/OgreCore.zip -------------------------------------------------------------------------------- /media/packs/SdkTrays.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/media/packs/SdkTrays.zip -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | 4 | # Technical Details 5 | 6 | 7 | 8 | ### :sparkles: Features 9 | 10 | 11 | ### :bug: Bugfixes 12 | 13 | -------------------------------------------------------------------------------- /resources/addVertice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/addVertice.png -------------------------------------------------------------------------------- /resources/capsule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/capsule.png -------------------------------------------------------------------------------- /resources/cone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/cone.png -------------------------------------------------------------------------------- /resources/cube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/cube.png -------------------------------------------------------------------------------- /resources/cylinder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/cylinder.png -------------------------------------------------------------------------------- /resources/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/icon.icns -------------------------------------------------------------------------------- /resources/icone.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/icone.ico -------------------------------------------------------------------------------- /resources/icone.rc: -------------------------------------------------------------------------------- 1 | QtMeshEditor.exe ICON icone.ico 2 | 3 | -------------------------------------------------------------------------------- /resources/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/move.png -------------------------------------------------------------------------------- /resources/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/pause.png -------------------------------------------------------------------------------- /resources/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/play.png -------------------------------------------------------------------------------- /resources/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/remove.png -------------------------------------------------------------------------------- /resources/resource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | cube.png 4 | sphere.png 5 | square.png 6 | move.png 7 | selecionar.png 8 | rotacionar.png 9 | icone.ico 10 | pause.png 11 | play.png 12 | remove.png 13 | cylinder.png 14 | cone.png 15 | torus.png 16 | capsule.png 17 | roundedbox.png 18 | addVertice.png 19 | spring.png 20 | 21 | 22 | -------------------------------------------------------------------------------- /resources/rotacionar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/rotacionar.png -------------------------------------------------------------------------------- /resources/roundedbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/roundedbox.png -------------------------------------------------------------------------------- /resources/selecionar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/selecionar.png -------------------------------------------------------------------------------- /resources/sphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/sphere.png -------------------------------------------------------------------------------- /resources/spring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/spring.png -------------------------------------------------------------------------------- /resources/square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/square.png -------------------------------------------------------------------------------- /resources/torus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/resources/torus.png -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.projectKey=fernandotonon_QtMeshEditor 2 | sonar.organization=fernandotonon 3 | sonar.cfamily.gcov.reportsPath=./ 4 | 5 | # This is the name and version displayed in the SonarCloud UI. 6 | sonar.projectName=QtMeshEditor 7 | #sonar.projectVersion=1.0 8 | 9 | 10 | # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. 11 | #sonar.sources=. 12 | 13 | # Encoding of the source code. Default is default system encoding 14 | #sonar.sourceEncoding=UTF-8 15 | 16 | # Exclude directories 17 | sonar.exclusions=**/OgreXML/**,**/dependencies/** 18 | sonar.coverage.exclusions=**/*_test.cpp 19 | -------------------------------------------------------------------------------- /src/AnimationWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATIONWIDGET_H 2 | #define ANIMATIONWIDGET_H 3 | 4 | #include 5 | #include 6 | #include "SkeletonDebug.h" 7 | 8 | namespace Ui { 9 | class AnimationWidget; 10 | } 11 | namespace Ogre{ 12 | class AnimationState; 13 | } 14 | 15 | class AnimationWidget : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit AnimationWidget(QWidget *parent = nullptr); 21 | ~AnimationWidget() override; 22 | bool isSkeletonShown(Ogre::Entity*entity) const; 23 | 24 | private: 25 | void setAnimationState(bool playing); 26 | void disableAllSelectedAnimations(); 27 | void disableAllSkeletonDebug(); 28 | void disableEntityAnimations(Ogre::Entity* entity); 29 | 30 | private slots: 31 | void updateAnimationTable(); 32 | void updateSkeletonTable(); 33 | void on_PlayPauseButton_toggled(bool checked); 34 | void on_animTable_cellDoubleClicked(int row, int column); 35 | void on_animTable_clicked(const QModelIndex &index); 36 | void on_skeletonTable_clicked(const QModelIndex &index); 37 | 38 | void on_mergeButton_clicked(); 39 | 40 | signals: 41 | void changeAnimationState(bool playing); 42 | void changeAnimationName(const std::string &newName); 43 | 44 | private: 45 | Ui::AnimationWidget* ui; 46 | QMap mShowSkeleton; 47 | }; 48 | 49 | #endif // ANIMATIONWIDGET_H 50 | -------------------------------------------------------------------------------- /src/Assimp/AnimationProcessor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class AnimationProcessor 7 | { 8 | public: 9 | AnimationProcessor(Ogre::SkeletonPtr skeleton); 10 | void processAnimations(const aiScene* scene); 11 | 12 | private: 13 | void processAnimation(aiAnimation* animation, const aiScene* scene); 14 | void processAnimationChannel(aiNodeAnim* nodeAnim, Ogre::Animation* animation, const aiScene* scene, unsigned int channelIndex, Ogre::Real mTicksPerSecond); 15 | Ogre::SkeletonPtr skeleton; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /src/Assimp/AnimationProcessor_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "AnimationProcessor.h" 4 | 5 | // Test if processAnimations processes all animations 6 | TEST(AnimationProcessorTest, ProcessAllAnimations) { 7 | auto ogreRoot = std::make_unique(); 8 | auto mockSkeleton= Ogre::SkeletonManager::getSingleton().create("MockSkeleton",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true); 9 | AnimationProcessor processor(mockSkeleton); 10 | 11 | aiScene scene; 12 | scene.mNumAnimations = 2; 13 | scene.mAnimations = new aiAnimation*[2]; 14 | scene.mAnimations[0] = new aiAnimation; 15 | scene.mAnimations[1] = new aiAnimation; 16 | scene.mAnimations[0]->mName = aiString( std::string( "Animation1")); 17 | scene.mAnimations[1]->mName = aiString( std::string( "Animation2")); 18 | scene.mAnimations[0]->mNumChannels=0; 19 | scene.mAnimations[1]->mNumChannels=0; 20 | 21 | processor.processAnimations(&scene); 22 | 23 | EXPECT_EQ(mockSkeleton->getNumAnimations(), 2); 24 | EXPECT_EQ(mockSkeleton->getAnimation(0)->getName(), "Animation1"); 25 | EXPECT_EQ(mockSkeleton->getAnimation(1)->getName(), "Animation2"); 26 | } 27 | -------------------------------------------------------------------------------- /src/Assimp/BoneProcessor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class BoneProcessor { 7 | public: 8 | void processBones(Ogre::SkeletonPtr skeleton, const aiScene* scene); 9 | 10 | private: 11 | void createBone(const std::string& boneName); 12 | void processBoneHierarchy(aiNode* node); 13 | void processBoneNode(aiBone *bone); 14 | Ogre::Matrix4 convertToOgreMatrix4(const aiMatrix4x4& aiMat); 15 | void applyTransformation(const std::string& boneName, const Ogre::Matrix4 &transform); 16 | 17 | Ogre::SkeletonPtr skeleton; 18 | std::map aiBonesMap; 19 | }; 20 | -------------------------------------------------------------------------------- /src/Assimp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | # adding the files 3 | ############################################################## 4 | 5 | set(SRC_FILES 6 | ${SRC_FILES} 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Importer.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/MaterialProcessor.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/AnimationProcessor.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/BoneProcessor.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/MeshProcessor.cpp 12 | PARENT_SCOPE 13 | ) 14 | 15 | set(HEADER_FILES 16 | ${HEADER_FILES} 17 | ${CMAKE_CURRENT_SOURCE_DIR}/Importer.h 18 | ${CMAKE_CURRENT_SOURCE_DIR}/MaterialProcessor.h 19 | ${CMAKE_CURRENT_SOURCE_DIR}/AnimationProcessor.h 20 | ${CMAKE_CURRENT_SOURCE_DIR}/BoneProcessor.h 21 | ${CMAKE_CURRENT_SOURCE_DIR}/MeshProcessor.h 22 | PARENT_SCOPE 23 | ) 24 | 25 | set(TEST_SOURCES 26 | ${TEST_SOURCES} 27 | ${CMAKE_CURRENT_SOURCE_DIR}/MaterialProcessor_test.cpp 28 | ${CMAKE_CURRENT_SOURCE_DIR}/AnimationProcessor_test.cpp 29 | ${CMAKE_CURRENT_SOURCE_DIR}/BoneProcessor_test.cpp 30 | ${CMAKE_CURRENT_SOURCE_DIR}/MeshProcessor_test.cpp 31 | PARENT_SCOPE 32 | ) 33 | -------------------------------------------------------------------------------- /src/Assimp/Importer.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) HogPog Team (www.hogpog.com.br) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | 34 | #include "MaterialProcessor.h" 35 | 36 | class AssimpToOgreImporter { 37 | public: 38 | AssimpToOgreImporter() : importer() {} 39 | 40 | Ogre::MeshPtr loadModel(const std::string& path); 41 | 42 | private: 43 | Assimp::Importer importer; 44 | Ogre::SkeletonPtr skeleton; 45 | std::string modelName; 46 | 47 | MaterialProcessor materialProcessor; 48 | }; 49 | -------------------------------------------------------------------------------- /src/Assimp/MaterialProcessor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class MaterialProcessor 7 | { 8 | public: 9 | void loadScene(const aiScene* scene); 10 | Ogre::MaterialPtr operator[](unsigned int index); 11 | unsigned long size() const; 12 | 13 | private: 14 | Ogre::MaterialPtr processMaterial(const aiMaterial* material, const aiScene* scene); 15 | Ogre::TexturePtr loadTexture(const Ogre::String& filename, const aiString& path, const aiScene* scene) const; 16 | 17 | std::vector materials; 18 | }; 19 | -------------------------------------------------------------------------------- /src/Assimp/MaterialProcessor_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "MaterialProcessor.h" 4 | 5 | TEST(MaterialProcessorTest, LoadSceneProcessesAllMaterials) { 6 | auto ogreRoot = std::make_unique(); 7 | MaterialProcessor processor; 8 | aiScene scene; 9 | 10 | scene.mNumMaterials = 2; 11 | scene.mMaterials = new aiMaterial*[2]; 12 | scene.mMaterials[0] = new aiMaterial; 13 | scene.mMaterials[1] = new aiMaterial; 14 | aiString matName1( std::string( "testMaterial1")); 15 | aiString matName2( std::string( "testMaterial2")); 16 | scene.mMaterials[0]->AddProperty(&matName1, AI_MATKEY_NAME); 17 | scene.mMaterials[1]->AddProperty(&matName2, AI_MATKEY_NAME); 18 | 19 | processor.loadScene(&scene); 20 | 21 | EXPECT_EQ(processor.size(), 2); 22 | } 23 | 24 | TEST(MaterialProcessorTest, MaterialIndexing) { 25 | auto ogreRoot = std::make_unique(); 26 | MaterialProcessor processor; 27 | aiScene scene; 28 | 29 | scene.mNumMaterials = 2; 30 | scene.mMaterials = new aiMaterial*[2]; 31 | scene.mMaterials[0] = new aiMaterial; 32 | scene.mMaterials[1] = new aiMaterial; 33 | aiString matName1( std::string( "testMaterial1")); 34 | aiString matName2( std::string( "testMaterial2")); 35 | scene.mMaterials[0]->AddProperty(&matName1, AI_MATKEY_NAME); 36 | scene.mMaterials[1]->AddProperty(&matName2, AI_MATKEY_NAME); 37 | 38 | processor.loadScene(&scene); 39 | 40 | EXPECT_EQ(processor[0].get()->getName(), "testMaterial1"); 41 | EXPECT_EQ(processor[1].get()->getName(), "testMaterial2"); 42 | } 43 | 44 | TEST(MaterialProcessorTest, MaterialSize) { 45 | auto ogreRoot = std::make_unique(); 46 | MaterialProcessor processor; 47 | aiScene scene; 48 | 49 | scene.mNumMaterials = 3; 50 | scene.mMaterials = new aiMaterial*[3]; 51 | scene.mMaterials[0] = new aiMaterial; 52 | scene.mMaterials[1] = new aiMaterial; 53 | scene.mMaterials[2] = new aiMaterial; 54 | aiString matName1( std::string( "testMaterial1")); 55 | aiString matName2( std::string( "testMaterial2")); 56 | aiString matName3( std::string( "testMaterial3")); 57 | scene.mMaterials[0]->AddProperty(&matName1, AI_MATKEY_NAME); 58 | scene.mMaterials[1]->AddProperty(&matName2, AI_MATKEY_NAME); 59 | scene.mMaterials[2]->AddProperty(&matName3, AI_MATKEY_NAME); 60 | 61 | processor.loadScene(&scene); 62 | 63 | EXPECT_EQ(processor.size(), 3); 64 | } 65 | -------------------------------------------------------------------------------- /src/Assimp/MeshProcessor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "MaterialProcessor.h" 6 | 7 | struct SubMeshData { 8 | std::vector vertices; 9 | std::vector normals; 10 | std::vector texCoords; 11 | std::vector tangents; 12 | std::vector bitangents; 13 | std::vector colors; 14 | std::vector indices; 15 | std::vector boneAssignments; 16 | unsigned int materialIndex; 17 | }; 18 | 19 | class MeshProcessor { 20 | public: 21 | MeshProcessor(Ogre::SkeletonPtr skeleton); 22 | void processNode(aiNode* node, const aiScene* scene); 23 | Ogre::MeshPtr createMesh(const Ogre::String& name, const Ogre::String& group, MaterialProcessor &materialProcessor); 24 | 25 | protected: 26 | // Protected for testing purposes 27 | SubMeshData* processMesh(aiMesh* mesh, const aiScene* scene); 28 | 29 | private: 30 | std::vector subMeshesData; 31 | std::vector boneAssignments; 32 | Ogre::SkeletonPtr skeleton; 33 | }; 34 | -------------------------------------------------------------------------------- /src/EditorViewport.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) Fernando Tonon (https://github.com/fernandotonon) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef EDITOR_VIEWPORT_H 30 | #define EDITOR_VIEWPORT_H 31 | 32 | #include 33 | 34 | class OgreWidget; 35 | class MainWindow; 36 | 37 | class EditorViewport : public QDockWidget 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | EditorViewport(MainWindow* parent, int index = 0); 43 | ~EditorViewport(); 44 | 45 | int getIndex() const; 46 | OgreWidget* getOgreWidget() const; 47 | MainWindow* getMainWindow() const; 48 | 49 | signals: 50 | void widgetAboutToClose(EditorViewport* const& widget); 51 | 52 | //TODO add another function to do the job and put the events protected 53 | public: 54 | 55 | protected: 56 | virtual void closeEvent(QCloseEvent *e); 57 | virtual void paintEvent(QPaintEvent *e); 58 | 59 | private: 60 | int mIndex; 61 | OgreWidget* m_pOgreWidget; 62 | MainWindow* m_pMainWindow; 63 | 64 | }; 65 | 66 | 67 | #endif //EDITOR_VIEWPORT_H 68 | 69 | -------------------------------------------------------------------------------- /src/GlobalDefinitions.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) Fernando Tonon (https://github.com/fernandotonon) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef GLOBAL_DEFINITIONS_H 30 | #define GLOBAL_DEFINITIONS_H 31 | 32 | #define ZORDER_OVERLAY Ogre::RENDER_QUEUE_OVERLAY 33 | 34 | #define GUI_MATERIAL_NAME "GUI_Material" 35 | 36 | #define GIZMO_QUERY_FLAGS 0x01 37 | #define SCENE_QUERY_FLAGS 0xFE 38 | 39 | #define GUI_VISIBILITY_FLAGS 0x01 40 | #define SCENE_VISIBILITY_FLAGS 0xFE 41 | 42 | #define TRANSFORM_OBJECT_NAME "Transform" 43 | #define SELECTIONBOX_OBJECT_NAME "SelectionBox" 44 | 45 | #define NODE_DATA Qt::UserRole+1 46 | #define ENTITY_DATA Qt::UserRole+2 47 | #define SUBENTITY_DATA Qt::UserRole+3 48 | 49 | #endif //GLOBAL_DEFINITIONS_H 50 | -------------------------------------------------------------------------------- /src/Info.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleInfoDictionaryVersion 6 | 6.0 7 | CFBundlePackageType 8 | APPL 9 | 10 | CFBundleName 11 | QtMeshEditor 12 | CFBundleDisplayName 13 | QtMeshEditor 14 | CFBundleSignature 15 | QtMeshEditor 16 | CFBundleIdentifier 17 | QtMeshEditor 18 | CFBundleExecutable 19 | QtMeshEditor 20 | 21 | CFBundleVersion 22 | @PROJECT_VERSION@ 23 | CFBundleShortVersionString 24 | @PROJECT_VERSION@ 25 | 26 | LSMinimumSystemVersion 27 | 13 28 | 29 | NSHumanReadableCopyright 30 | MIT License, since 2012 31 | 32 | CFBundleIconFile 33 | icon.icns 34 | 35 | CFBundleDevelopmentRegion 36 | en 37 | CFBundleAllowMixedLocalizations 38 | 39 | 40 | NSPrincipalClass 41 | NSApplication 42 | 43 | NSSupportsAutomaticGraphicsSwitching 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/Manager_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Manager.h" 4 | #include "GlobalDefinitions.h" 5 | #include 6 | #include "mainwindow.h" 7 | 8 | using ::testing::Mock; 9 | 10 | // Mock class for QApplication 11 | class MockQApplication : public QApplication 12 | { 13 | public: 14 | MockQApplication(int& argc, char** argv) : QApplication(argc, argv) {} 15 | 16 | MOCK_METHOD(int, exec, ()); 17 | }; 18 | 19 | 20 | TEST(ManagerTest, Forbidden_Name) 21 | { 22 | // Create mock objects 23 | int argc = 0; 24 | char* argv[] = { nullptr }; 25 | MockQApplication mockQApplication(argc, argv); 26 | 27 | Manager *manager = Manager::getSingleton(nullptr); 28 | EXPECT_EQ(manager->isForbiddenNodeName("Cube"), false); 29 | EXPECT_EQ(manager->isForbiddenNodeName("Cube_0"), false); 30 | EXPECT_EQ(manager->isForbiddenNodeName("Cube_1"), false); 31 | EXPECT_EQ(manager->isForbiddenNodeName("TPCameraChildSceneNode"), true); 32 | EXPECT_EQ(manager->isForbiddenNodeName("TPCameraChildSceneNode_0"), false); 33 | EXPECT_EQ(manager->isForbiddenNodeName("GridLine_node"), true); 34 | EXPECT_EQ(manager->isForbiddenNodeName("Unnamed_"), true); 35 | EXPECT_EQ(manager->isForbiddenNodeName(TRANSFORM_OBJECT_NAME), true); 36 | EXPECT_EQ(manager->isForbiddenNodeName(SELECTIONBOX_OBJECT_NAME), true); 37 | 38 | // Clear the mock object 39 | Mock::VerifyAndClear(&mockQApplication); 40 | } 41 | 42 | TEST(ManagerTest, CreateEmptyScene) 43 | { 44 | // Create mock objects 45 | int argc = 0; 46 | char* argv[] = { nullptr }; 47 | MockQApplication mockQApplication(argc, argv); 48 | MainWindow* mainWindow = new MainWindow(); // TODO: currently it is not possible to mock it twice, so we need to refactory it to be able to do it to test the other functions 49 | 50 | Manager *manager = Manager::getSingleton(mainWindow); 51 | manager->CreateEmptyScene(); 52 | EXPECT_EQ(manager->getSceneNodes().size(), 3); // Root and the light 53 | EXPECT_EQ(manager->getEntities().size(), 2); 54 | 55 | // Clear the mock object 56 | Mock::VerifyAndClear(&mockQApplication); 57 | delete mainWindow; 58 | } 59 | -------------------------------------------------------------------------------- /src/MaterialComboDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) Fernando Tonon (https://github.com/fernandotonon) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef MATERIAL_COMBO_DELEGATE_H 30 | #define MATERIAL_COMBO_DELEGATE_H 31 | 32 | #include 33 | namespace Ogre{ 34 | class SubEntity; 35 | } 36 | class MaterialComboDelegate : public QStyledItemDelegate 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | MaterialComboDelegate(QObject *parent = nullptr); 42 | 43 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, 44 | const QModelIndex &index) const; 45 | 46 | void setEditorData(QWidget *editor, const QModelIndex &index) const; 47 | void setModelData(QWidget *editor, QAbstractItemModel *model, 48 | const QModelIndex &index) const; 49 | 50 | void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem& option, const QModelIndex& index) const; 51 | void initStyleOption(QStyleOptionViewItem* option, const QModelIndex& index) const; 52 | 53 | private: 54 | QString materialNameFromIndex(const QModelIndex& index) const; 55 | private slots: 56 | void commitAndCloseEditor(); 57 | 58 | }; 59 | 60 | 61 | #endif //MATERIAL_COMBO_DELEGATE_H 62 | -------------------------------------------------------------------------------- /src/MaterialHighlighter.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) Fernando Tonon (https://github.com/fernandotonon) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef MATERIALHIGHLIGHTER_H 30 | #define MATERIALHIGHLIGHTER_H 31 | 32 | #include 33 | 34 | class MaterialHighlighter : public QSyntaxHighlighter 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit MaterialHighlighter(QObject *parent = nullptr); 40 | ~MaterialHighlighter() = default; 41 | 42 | void highlightBlock(const QString &text); 43 | 44 | protected: 45 | virtual void applyHighlight(const QTextCharFormat &format, const QString &pattern, const QString &text); 46 | 47 | private: 48 | QObject *mParent; 49 | }; 50 | 51 | #endif // MATERIALHIGHLIGHTER_H 52 | -------------------------------------------------------------------------------- /src/MaterialHighlighter_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "MaterialHighlighter.h" 7 | 8 | using ::testing::Mock; 9 | 10 | class MockMaterialHighlighter : public MaterialHighlighter 11 | { 12 | public: 13 | explicit MockMaterialHighlighter(QTextEdit *editor=nullptr){} 14 | 15 | MOCK_METHOD(void, applyHighlight, (const QTextCharFormat &format, const QString &pattern, const QString &text), (override)); 16 | 17 | bool containsExpectedFormat(const std::vector& capturedFormats, 18 | const QTextCharFormat& expectedFormat) { 19 | return std::any_of(capturedFormats.begin(), capturedFormats.end(), 20 | [&expectedFormat](const QTextCharFormat& format) { 21 | return format.fontWeight() == expectedFormat.fontWeight() && 22 | format.foreground().color() == expectedFormat.foreground().color(); 23 | }); 24 | } 25 | }; 26 | 27 | TEST(MaterialHighlighterTest, HighlightKeywordsDarkModeTest) { 28 | MockMaterialHighlighter highlighter{}; 29 | 30 | QString testText = "material MyMaterial { technique MyTechnique { pass MyPass { } } }"; 31 | 32 | QTextCharFormat expectedFormat; 33 | expectedFormat.setFontWeight(QFont::Bold); 34 | expectedFormat.setForeground(Qt::darkBlue); 35 | 36 | std::vector capturedFormats; 37 | 38 | EXPECT_CALL(highlighter, applyHighlight(::testing::_, ::testing::_, testText)) 39 | .Times(5) 40 | .WillRepeatedly(::testing::Invoke( 41 | [&capturedFormats](const QTextCharFormat &format, const QString &, const QString &) { 42 | capturedFormats.push_back(format); 43 | } 44 | )); 45 | 46 | highlighter.highlightBlock(testText); 47 | 48 | ASSERT_TRUE(highlighter.containsExpectedFormat(capturedFormats, expectedFormat)); 49 | } 50 | -------------------------------------------------------------------------------- /src/MaterialWidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) Fernando Tonon (https://github.com/fernandotonon) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef MATERIAL_WIDGET_H 30 | #define MATERIAL_WIDGET_H 31 | 32 | #include 33 | 34 | namespace Ogre { 35 | class Entity; 36 | class SubEntity; 37 | } 38 | 39 | 40 | class MaterialWidget : public QTableWidget 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | explicit MaterialWidget(QWidget *parent = nullptr); 46 | virtual ~MaterialWidget() = default; 47 | 48 | private: 49 | void populateTableWithEntities(const QList& entities); 50 | void populateTableWithSubEntities(const QList& subEntities); 51 | 52 | private slots: 53 | void onNodeSelected(); 54 | void onEntitySelected(); 55 | void onSubEntitySelected(); 56 | void onMaterialChanged(int row, int column); 57 | 58 | }; 59 | 60 | #endif // MATERIAL_WIDGET_H 61 | -------------------------------------------------------------------------------- /src/MaterialWidget_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "MaterialWidget.h" 6 | 7 | // Test case for MaterialWidget 8 | class MaterialWidgetTest : public ::testing::Test 9 | { 10 | protected: 11 | void SetUp() override 12 | { 13 | // Create a QApplication instance for testing 14 | int argc = 0; 15 | char* argv[] = { nullptr }; 16 | app = new QApplication(argc, argv); 17 | } 18 | 19 | void TearDown() override 20 | { 21 | // Clean up the QApplication instance 22 | delete app; 23 | } 24 | 25 | QApplication* app; 26 | 27 | }; 28 | 29 | // Test the constructor of MaterialWidget 30 | TEST_F(MaterialWidgetTest, Constructor) 31 | { 32 | // Create a MaterialWidget instance 33 | MaterialWidget materialWidget; 34 | 35 | // Check the initial state of the MaterialWidget 36 | EXPECT_EQ(materialWidget.columnCount(), 3); 37 | EXPECT_EQ(materialWidget.horizontalHeader()->sectionResizeMode(QHeaderView::Stretch), QHeaderView::Stretch); 38 | EXPECT_TRUE(materialWidget.verticalHeader()->isHidden()); 39 | } 40 | -------------------------------------------------------------------------------- /src/MeshImporterExporter.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) Fernando Tonon (https://github.com/fernandotonon) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef MESHIMPORTEREXPORTER_H 30 | #define MESHIMPORTEREXPORTER_H 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include "mainwindow.h" 37 | 38 | class MeshImporterExporter 39 | { 40 | private: 41 | static void configureCamera(const Ogre::Entity *en); 42 | static void exportMaterial(const Ogre::Entity *e, const QFileInfo &file); 43 | static void exportTextures(const Ogre::MaterialPtr &material, const QFileInfo &file); 44 | static const QMap exportFormats; 45 | 46 | public: 47 | static void importer(const QStringList &_uriList); 48 | static int exporter(const Ogre::SceneNode *_sn); 49 | static int exporter(const Ogre::SceneNode *_sn, const QString &_uri, const QString &_format); 50 | static QString formatFileURI(const QString &_uri, const QString &_format); 51 | static QString exportFileDialogFilter(); 52 | }; 53 | 54 | #endif // MESHIMPORTEREXPORTER_H 55 | -------------------------------------------------------------------------------- /src/MeshTransform.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) Fernando Tonon (https://github.com/fernandotonon) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef MESHTRANSFORM_H 30 | #define MESHTRANSFORM_H 31 | 32 | #include 33 | 34 | class MeshTransform 35 | { 36 | public: 37 | MeshTransform() = delete; 38 | static void scaleMesh(const Ogre::Entity *_ent, const Ogre::Vector3 &_scale); 39 | static void scaleMesh(Ogre::Mesh *_mesh, const Ogre::Vector3 &_scale); 40 | static void translateMesh(const Ogre::Entity *_ent, const Ogre::Vector3 &_translate); 41 | static void rotateMesh(const Ogre::Entity *_ent, const Ogre::Vector3 &_rotate); 42 | }; 43 | 44 | #endif // MESHTRANSFORM_H 45 | -------------------------------------------------------------------------------- /src/ObjectItemModel.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) Fernando Tonon (https://github.com/fernandotonon) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef OBJECT_ITEM_MODEL_H 30 | #define OBJECT_ITEM_MODEL_H 31 | 32 | #include 33 | 34 | #include 35 | 36 | namespace Ogre{ 37 | class SceneNode; 38 | class Entity; 39 | } 40 | 41 | class ObjectItemModel : public QStandardItemModel 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | explicit ObjectItemModel(QObject *parent = nullptr); 47 | ~ObjectItemModel(); 48 | 49 | 50 | const QModelIndex getRootIndex() const; 51 | void setHeaderText(const QString& text); 52 | private: 53 | void appendAllChildFromParent(Ogre::SceneNode* const& parentNode, QStandardItem* const& parentItem); 54 | void appendEntitiesFromNode(Ogre::SceneNode* const& parentNode, QStandardItem* const& parentItem); 55 | void appendSubEntitiesFromEntity(Ogre::Entity* const& parentEntity, QStandardItem* const& parentItem); 56 | 57 | private slots: 58 | void newObjectNode(Ogre::SceneNode* const& newNode); 59 | void objectNodeRemoved(Ogre::SceneNode* const& node); 60 | void reloadSceneNode(); 61 | 62 | private: 63 | Ogre::SceneNode* m_pRootNode; 64 | QStandardItem* mRootItem; 65 | Ogre::Entity* mOgreEntity; 66 | 67 | }; 68 | 69 | #endif // OBJECT_ITEM_MODEL_H 70 | -------------------------------------------------------------------------------- /src/OgreXML/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | # adding the files 3 | ############################################################## 4 | 5 | set(SRC_FILES 6 | ${SRC_FILES} 7 | ${CMAKE_CURRENT_SOURCE_DIR}/pugixml.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/tinystr.cpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/tinyxml.cpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/tinyxmlerror.cpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/tinyxmlparser.cpp 12 | ${CMAKE_CURRENT_SOURCE_DIR}/OgreXMLMeshSerializer.cpp 13 | ${CMAKE_CURRENT_SOURCE_DIR}/OgreXMLSkeletonSerializer.cpp 14 | PARENT_SCOPE 15 | ) 16 | 17 | set(HEADER_FILES 18 | ${HEADER_FILES} 19 | ${CMAKE_CURRENT_SOURCE_DIR}/pugiconfig.hpp 20 | ${CMAKE_CURRENT_SOURCE_DIR}/pugixml.hpp 21 | ${CMAKE_CURRENT_SOURCE_DIR}/tinystr.h 22 | ${CMAKE_CURRENT_SOURCE_DIR}/tinyxml.h 23 | ${CMAKE_CURRENT_SOURCE_DIR}/OgreXMLMeshSerializer.h 24 | ${CMAKE_CURRENT_SOURCE_DIR}/OgreXMLPrerequisites.h 25 | ${CMAKE_CURRENT_SOURCE_DIR}/OgreXMLSkeletonSerializer.h 26 | PARENT_SCOPE 27 | ) 28 | -------------------------------------------------------------------------------- /src/OgreXML/OgreXMLPrerequisites.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------- 3 | This source file is part of OGRE 4 | (Object-oriented Graphics Rendering Engine) 5 | For the latest info, see http://www.ogre3d.org/ 6 | 7 | Copyright (c) 2000-2014 Torus Knot Software Ltd 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef __XMLPrerequisites_H__ 30 | #define __XMLPrerequisites_H__ 31 | 32 | #include "OgrePrerequisites.h" 33 | 34 | // Include tinyxml headers 35 | #include "pugixml.hpp" 36 | 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/OgreXML/tinystr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/src/OgreXML/tinystr.cpp -------------------------------------------------------------------------------- /src/OgreXML/tinyxmlerror.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | www.sourceforge.net/projects/tinyxml 3 | Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any 7 | damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any 10 | purpose, including commercial applications, and to alter it and 11 | redistribute it freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must 14 | not claim that you wrote the original software. If you use this 15 | software in a product, an acknowledgment in the product documentation 16 | would be appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and 19 | must not be misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source 22 | distribution. 23 | */ 24 | 25 | #include "tinyxml.h" 26 | 27 | // The goal of the seperate error file is to make the first 28 | // step towards localization. tinyxml (currently) only supports 29 | // english error messages, but the could now be translated. 30 | // 31 | // It also cleans up the code a bit. 32 | // 33 | 34 | const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = 35 | { 36 | "No error", 37 | "Error", 38 | "Failed to open file", 39 | "Memory allocation failed.", 40 | "Error parsing Element.", 41 | "Failed to read Element name", 42 | "Error reading Element value.", 43 | "Error reading Attributes.", 44 | "Error: empty tag.", 45 | "Error reading end tag.", 46 | "Error parsing Unknown.", 47 | "Error parsing Comment.", 48 | "Error parsing Declaration.", 49 | "Error document empty.", 50 | "Error null (0) or unexpected EOF found in input stream.", 51 | "Error parsing CDATA.", 52 | "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", 53 | }; 54 | -------------------------------------------------------------------------------- /src/PrimitiveObject_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "PrimitiveObject.h" 3 | 4 | TEST(PrimitivesTest, CreateDefaultPrimitive) 5 | { 6 | PrimitiveObject primitive(""); 7 | ASSERT_EQ(primitive.getName(), ""); 8 | ASSERT_EQ(primitive.getType(), PrimitiveObject::PrimitiveType::AP_NONE); 9 | ASSERT_EQ(primitive.getSceneNode(), nullptr); 10 | ASSERT_EQ(primitive.getNumIterations(), 1); 11 | ASSERT_EQ(primitive.getNumSegBase(), 1); 12 | ASSERT_EQ(primitive.getNumSegCircle(), 1); 13 | ASSERT_EQ(primitive.getNumSegX(), 1); 14 | ASSERT_EQ(primitive.getNumSegY(), 1); 15 | ASSERT_EQ(primitive.getNumSegZ(), 1); 16 | ASSERT_EQ(primitive.getInnerRadius(), 0.5f); 17 | ASSERT_EQ(primitive.getSectionRadius(), 0.5f); 18 | ASSERT_EQ(primitive.getChamferRadius(), 1.0f); 19 | ASSERT_EQ(primitive.getOuterRadius(), 1.0f); 20 | ASSERT_EQ(primitive.getRadius(), 1.0f); 21 | ASSERT_EQ(primitive.getHeight(), 1.0f); 22 | ASSERT_EQ(primitive.getSizeZ(), 1.0f); 23 | ASSERT_EQ(primitive.getSizeY(), 1.0f); 24 | ASSERT_EQ(primitive.getSizeX(), 1.0f); 25 | } 26 | 27 | TEST(PrimitivesTest, isPrimitiveWithNullptr) 28 | { 29 | ASSERT_FALSE(PrimitiveObject::isPrimitive(nullptr)); 30 | } 31 | -------------------------------------------------------------------------------- /src/PrimitivesWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef PRIMITIVES_WIDGET_H 2 | #define PRIMITIVES_WIDGET_H 3 | 4 | #include 5 | #include 6 | #include "PrimitiveObject.h" 7 | 8 | #include "ui_PrimitivesWidget.h" 9 | 10 | class PrimitivesWidget : public QWidget,private Ui::PrimitivesWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit PrimitivesWidget(QWidget *parent = nullptr); 16 | ~PrimitivesWidget() override = default; 17 | void updateUiFromParams(); 18 | const QList& getSelectedPrimitiveList(); 19 | 20 | public slots: 21 | void onSelectionChanged(); 22 | void createCube(); 23 | void createSphere(); 24 | void createPlane(); 25 | void createCylinder(); 26 | void createCone(); 27 | void createTorus(); 28 | void createTube(); 29 | void createCapsule(); 30 | void createIcoSphere(); 31 | void createRoundedBox(); 32 | void createSpring(); 33 | 34 | protected: 35 | void setUiEmpty(); 36 | void setUiMesh(); 37 | void setUiCube(); 38 | void setUiSphere(); 39 | void setUiPlane(); 40 | void setUiCylinder(); 41 | void setUiCone(); 42 | void setUiTorus(); 43 | void setUiTube(); 44 | void setUiCapsule(); 45 | void setUiIcoSphere(); 46 | void setUiRoundedBox(); 47 | void setUiSpring(); 48 | void createPrimitive(PrimitiveObject::PrimitiveType newPrimitive, const QString& name); 49 | PrimitiveObject::PrimitiveType getSelectedPrimitive(); 50 | void blockEditSignals(bool block); 51 | void setUVTileVisible(bool visible = true); 52 | 53 | private slots: 54 | 55 | void onEditSizeX(); 56 | void onEditSizeY(); 57 | void onEditSizeZ(); 58 | 59 | void onEditRadius(); 60 | void onEditRadius2(); 61 | void onEditHeight(); 62 | 63 | void onEditNumSegX(); 64 | void onEditNumSegY(); 65 | void onEditNumSegZ(); 66 | 67 | void onEditUTile(); 68 | void onEditVTile(); 69 | void onToggleSwitchUV(); 70 | 71 | private: 72 | QList mSelectedPrimitive; 73 | }; 74 | 75 | #endif // PRIMITIVES_WIDGET_H 76 | -------------------------------------------------------------------------------- /src/QtInputManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) Fernando Tonon (https://github.com/fernandotonon) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef QTINPUTMANAGER_H 30 | #define QTINPUTMANAGER_H 31 | 32 | #include "QtKeyListener.h" 33 | #include "QtMouseListener.h" 34 | 35 | class QtInputManager 36 | { 37 | public: 38 | static QtInputManager& getInstance(){return mInstance;} 39 | static QtInputManager* getInstancePtr(){return &mInstance;} 40 | 41 | void AddKeyListener(QtKeyListener* listener); 42 | void AddMouseListener(QtMouseListener* listener); 43 | void RemoveKeyListener(QtKeyListener* listener); 44 | void RemoveMouseListener(QtMouseListener* listener); 45 | 46 | void keyPressEvent(QKeyEvent *event); 47 | void keyReleaseEvent(QKeyEvent *event); 48 | 49 | void mousePressEvent(QMouseEvent *event); 50 | void mouseReleaseEvent(QMouseEvent *event); 51 | void mouseMoveEvent(QMouseEvent *event); 52 | void wheelEvent(QWheelEvent *event); 53 | private: 54 | QtInputManager() = default; 55 | static QtInputManager mInstance; 56 | QList mKeyListeners; 57 | QList mMouseListeners; 58 | 59 | QList mRemovedKeyListeners; 60 | QList mRemovedMouseListeners; 61 | }; 62 | 63 | #endif // QTINPUTMANAGER_H 64 | -------------------------------------------------------------------------------- /src/QtKeyListener.h: -------------------------------------------------------------------------------- 1 | #ifndef QTKEYLISTENER_H 2 | #define QTKEYLISTENER_H 3 | 4 | #include 5 | 6 | class QtKeyListener 7 | { 8 | public: 9 | virtual void keyPressEvent(QKeyEvent *event) = 0; 10 | virtual void keyReleaseEvent(QKeyEvent *event) = 0; 11 | }; 12 | 13 | #endif // QTKEYLISTENER_H 14 | -------------------------------------------------------------------------------- /src/QtMouseListener.h: -------------------------------------------------------------------------------- 1 | #ifndef QTMOUSELISTENER_H 2 | #define QTMOUSELISTENER_H 3 | 4 | #include 5 | #include 6 | 7 | class QtMouseListener 8 | { 9 | public: 10 | virtual void mousePressEvent(QMouseEvent *event) = 0; 11 | virtual void mouseReleaseEvent(QMouseEvent *event) = 0; 12 | virtual void mouseMoveEvent(QMouseEvent *event) = 0; 13 | virtual void wheelEvent(QWheelEvent *event) = 0; 14 | virtual ~QtMouseListener() = default; 15 | }; 16 | 17 | #endif // QTMOUSELISTENER_H 18 | -------------------------------------------------------------------------------- /src/SelectionBoxObject.cpp: -------------------------------------------------------------------------------- 1 | #include "SelectionBoxObject.h" 2 | 3 | #include "GlobalDefinitions.h" 4 | #include "Manager.h" 5 | 6 | #include 7 | 8 | SelectionBoxObject::SelectionBoxObject(const Ogre::String& name) 9 | : Ogre::ManualObject(name) 10 | { 11 | setRenderQueueGroup(ZORDER_OVERLAY); // when using this, ensure Depth Check is Off in the material 12 | setUseIdentityProjection(true); 13 | setUseIdentityView(true); 14 | setQueryFlags(0); 15 | } 16 | 17 | const Ogre::ColourValue& SelectionBoxObject::getBoxColour() const 18 | { return mBoxColour; } 19 | 20 | void SelectionBoxObject::setBoxColour(const Ogre::ColourValue &colour) 21 | { mBoxColour = colour; } 22 | 23 | void SelectionBoxObject::drawBox(float left, float top, float right, float bottom) 24 | { 25 | //upper left corner (-1,1) - bottom right corner (1,-1) 26 | clear(); 27 | begin(GUI_MATERIAL_NAME, Ogre::RenderOperation::OT_LINE_STRIP); 28 | colour(mBoxColour); 29 | position(left, top, -1); 30 | position(right, top, -1); 31 | position(right, bottom, -1); 32 | position(left, bottom, -1); 33 | position(left, top, -1); 34 | end(); 35 | 36 | setBoundingBox(Ogre::AxisAlignedBox::BOX_INFINITE); 37 | } 38 | 39 | void SelectionBoxObject::drawBox(const Ogre::Vector2& topLeft, const Ogre::Vector2& bottomRight) 40 | { 41 | drawBox(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); 42 | } 43 | -------------------------------------------------------------------------------- /src/SelectionBoxObject.h: -------------------------------------------------------------------------------- 1 | #ifndef SELECTION_BOX_OBJECT_H 2 | #define SELECTION_BOX_OBJECT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class SelectionBoxObject : public Ogre::ManualObject 10 | { 11 | public : 12 | explicit SelectionBoxObject(const Ogre::String& name); 13 | ~SelectionBoxObject() override = default ; 14 | 15 | const Ogre::ColourValue& getBoxColour() const; 16 | 17 | void setBoxColour(const Ogre::ColourValue& colour); 18 | 19 | void drawBox(float left, float top, float right, float bottom); 20 | void drawBox(const Ogre::Vector2& topLeft, const Ogre::Vector2& bottomRight); 21 | 22 | private : 23 | Ogre::ColourValue mBoxColour = Ogre::ColourValue(0.8f,0.8f,0.8f,0.8f); 24 | }; 25 | 26 | #endif //SELECTION_BOX_OBJECT_H 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/SkeletonDebug.h: -------------------------------------------------------------------------------- 1 | #ifndef SKELETONDEBUG_H_INCLUDED 2 | #define SKELETONDEBUG_H_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | //#include "ObjectTextDisplay.h" 9 | 10 | class QTimer; 11 | 12 | class SkeletonDebug: public QObject 13 | { 14 | Q_OBJECT 15 | public: 16 | SkeletonDebug(Ogre::Entity *entity, Ogre::SceneManager *man,/* Ogre::Camera *cam,*/ float boneSize = 0.1f, float scaleAxes =0.1f); 17 | ~SkeletonDebug(); 18 | 19 | void setAxesScale(Ogre::Real scale){mScaleAxes = scale;} 20 | Ogre::Real getAxesScale(){return mScaleAxes;} 21 | 22 | void showAxes(bool show); 23 | void showNames(bool show); 24 | void showBones(bool show); 25 | bool axesShown(){return mShowAxes;} 26 | bool namesShown(){return mShowNames;} 27 | bool bonesShown(){return mShowBones;} 28 | 29 | void update(); 30 | 31 | private: 32 | std::vector mAxisEntities; 33 | std::vector mBoneEntities; 34 | //std::vector mTextOverlays; 35 | 36 | float mBoneSize; 37 | 38 | Ogre::Entity *mEntity; 39 | Ogre::MaterialPtr mAxisMatPtr; 40 | Ogre::MaterialPtr mBoneMatPtr; 41 | Ogre::MaterialPtr mBoneMatSelectedPtr; 42 | Ogre::MeshPtr mBoneMeshPtr; 43 | Ogre::MeshPtr mAxesMeshPtr; 44 | Ogre::SceneManager *mSceneMan; 45 | //Ogre::Camera *mCamera; 46 | 47 | Ogre::Real mScaleAxes; 48 | 49 | bool mShowAxes; 50 | bool mShowBones; 51 | bool mShowNames; 52 | 53 | void createAxesMaterial(); 54 | void createBoneMaterial(); 55 | void createAxesMesh(); 56 | void createBoneMesh(); 57 | 58 | QTimer *mTimer; 59 | }; 60 | 61 | #endif // SKELETONDEBUG_H_INCLUDED 62 | -------------------------------------------------------------------------------- /src/SkeletonDebug_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Manager.h" 3 | #include "mainwindow.h" 4 | #include "SkeletonDebug.h" 5 | 6 | class SkeletonDebugTests : public ::testing::Test { 7 | protected: 8 | std::unique_ptr skeletonDebug; 9 | 10 | void SetUp() override { 11 | QStringList validUri{"./media/models/robot.mesh"}; 12 | Manager::getSingleton()->getMainWindow()->importMeshs(validUri); 13 | Ogre::Entity* entity = Manager::getSingleton()->getEntities().last(); 14 | Ogre::SceneManager* sceneManager = Manager::getSingleton()->getSceneMgr(); 15 | skeletonDebug = std::make_unique(entity,sceneManager); 16 | } 17 | 18 | }; 19 | 20 | TEST_F(SkeletonDebugTests, ShowAxesTest) 21 | { 22 | // Initially, axes should not be shown 23 | EXPECT_FALSE(skeletonDebug->axesShown()); 24 | 25 | // Show axes 26 | skeletonDebug->showAxes(true); 27 | EXPECT_TRUE(skeletonDebug->axesShown()); 28 | 29 | // Hide axes 30 | skeletonDebug->showAxes(false); 31 | EXPECT_FALSE(skeletonDebug->axesShown()); 32 | } 33 | 34 | TEST_F(SkeletonDebugTests, ShowNamesTest) 35 | { 36 | // Initially, names should not be shown 37 | EXPECT_FALSE(skeletonDebug->namesShown()); 38 | 39 | // Show names 40 | skeletonDebug->showNames(true); 41 | EXPECT_TRUE(skeletonDebug->namesShown()); 42 | 43 | // Hide names 44 | skeletonDebug->showNames(false); 45 | EXPECT_FALSE(skeletonDebug->namesShown()); 46 | } 47 | 48 | TEST_F(SkeletonDebugTests, ShowBonesTest) 49 | { 50 | // Initially, bones should not be shown 51 | EXPECT_FALSE(skeletonDebug->bonesShown()); 52 | 53 | // Show bones 54 | skeletonDebug->showBones(true); 55 | EXPECT_TRUE(skeletonDebug->bonesShown()); 56 | 57 | // Hide bones 58 | skeletonDebug->showBones(false); 59 | EXPECT_FALSE(skeletonDebug->bonesShown()); 60 | } 61 | 62 | TEST_F(SkeletonDebugTests, SetAndGetAxesScaleTest) 63 | { 64 | // Set axes scale 65 | skeletonDebug->setAxesScale(0.5f); 66 | EXPECT_FLOAT_EQ(skeletonDebug->getAxesScale(), 0.5f); 67 | 68 | // Set axes scale to a different value 69 | skeletonDebug->setAxesScale(1.0f); 70 | EXPECT_FLOAT_EQ(skeletonDebug->getAxesScale(), 1.0f); 71 | } 72 | -------------------------------------------------------------------------------- /src/SkeletonTransform.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------------- 3 | A QtMeshEditor file 4 | 5 | Copyright (c) Fernando Tonon (https://github.com/fernandotonon) 6 | 7 | The MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ----------------------------------------------------------------------------------- 27 | */ 28 | 29 | #ifndef SKELETONTRANSFORM_H 30 | #define SKELETONTRANSFORM_H 31 | 32 | #include 33 | #include 34 | 35 | class SkeletonTransform 36 | { 37 | public: 38 | SkeletonTransform() = delete; 39 | static void scaleSkeleton(const Ogre::Entity *_ent, const Ogre::Vector3 &_scale); 40 | static void translateSkeleton(const Ogre::Entity *_ent, const Ogre::Vector3 &_translate); 41 | static void rotateSkeleton(const Ogre::Entity *_ent, const Ogre::Vector3 &_rotate); 42 | static bool renameAnimation(Ogre::Entity *_ent, const QString &_oldName, const QString &_newName); 43 | }; 44 | 45 | #endif // SKELETONTRANSFORM_H 46 | -------------------------------------------------------------------------------- /src/SpaceCamera_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "SpaceCamera.h" 4 | 5 | #include 6 | 7 | using ::testing::Mock; 8 | 9 | // Mock class for SpaceCamera 10 | class MockSpaceCamera : public SpaceCamera 11 | { 12 | public: 13 | // Mock constructor 14 | MockSpaceCamera():SpaceCamera(){} 15 | virtual ~MockSpaceCamera() = default; 16 | }; 17 | 18 | TEST(SpaceCamera, InitialSpeed) 19 | { 20 | MockSpaceCamera spaceCamera; 21 | EXPECT_EQ(spaceCamera.getCameraSpeed(), 0.0f); 22 | spaceCamera.setCameraSpeed(0.5f); 23 | EXPECT_EQ(spaceCamera.getCameraSpeed(), 0.5f); 24 | } 25 | 26 | TEST(SpaceCamera, FrameStartedAndEnded) 27 | { 28 | MockSpaceCamera spaceCamera; 29 | Ogre::FrameEvent frameEvent; 30 | EXPECT_TRUE(spaceCamera.frameStarted(frameEvent)); 31 | EXPECT_TRUE(spaceCamera.frameEnded(frameEvent)); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/TransformOperator_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "TransformOperator.h" 5 | 6 | // Test if getSingleton returns a valid pointer 7 | TEST(TransformOperatorTest, GetSingleton) { 8 | TransformOperator* instance = TransformOperator::getSingleton(); 9 | EXPECT_NE(instance, nullptr); 10 | } 11 | 12 | // Test if getSingleton always returns the same instance 13 | TEST(TransformOperatorTest, SingletonInstance) { 14 | TransformOperator* instance1 = TransformOperator::getSingleton(); 15 | TransformOperator* instance2 = TransformOperator::getSingleton(); 16 | EXPECT_EQ(instance1, instance2); 17 | } 18 | 19 | // Test if setTransformState sets the state correctly 20 | TEST(TransformOperatorTest, SetSelectionBoxColour) { 21 | TransformOperator* instance = TransformOperator::getSingleton(); 22 | instance->setSelectionBoxColour(Ogre::ColourValue(0.5, 0.5, 0.5, 1.0)); 23 | EXPECT_EQ(instance->getSelectionBoxColour(), Ogre::ColourValue(0.5, 0.5, 0.5, 1.0)); 24 | } 25 | 26 | TEST(TransformOperatorTest, Swap) { 27 | int x = 1; 28 | int y = 2; 29 | TransformOperator::swap(x, y); 30 | EXPECT_EQ(x, 2); 31 | EXPECT_EQ(y, 1); 32 | } 33 | 34 | TEST(TransformOperatorTest, RayFromScreenPoint) { 35 | TransformOperator* instance = TransformOperator::getSingleton(); 36 | Ogre::Ray ray = instance->rayFromScreenPoint(QPoint(0, 0)); 37 | EXPECT_EQ(ray.getOrigin(), Ogre::Vector3::ZERO); 38 | EXPECT_EQ(ray.getDirection(), Ogre::Vector3::UNIT_Z); 39 | } 40 | -------------------------------------------------------------------------------- /src/TransformWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSFORM_WIDGET_H 2 | #define TRANSFORM_WIDGET_H 3 | 4 | #include 5 | #include 6 | #include "ui_TransformWidget.h" 7 | 8 | class QItemSelection; 9 | class ObjectItemModel; 10 | 11 | class TransformWidget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit TransformWidget(QWidget *parent = nullptr); 17 | ~TransformWidget(); 18 | 19 | private slots: 20 | void updateTreeViewFromSelection(); 21 | void treeWidgetSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); 22 | 23 | void updatePosition(const Ogre::Vector3& newPosition); 24 | void updateNodeScale(const Ogre::Vector3& newScale); 25 | void updateNodeOrientation(const Ogre::Vector3& newOrientation); 26 | 27 | void onPositionEdited(); 28 | void onNodeScaleEdited(); 29 | void onNodeOrientationEdited(); 30 | 31 | signals: 32 | void selectionChanged(const QString& newSelection); 33 | void selectionChanged(Ogre::SceneNode* newNode); 34 | 35 | private: 36 | Ui::TransformWidget* ui = new Ui::TransformWidget; 37 | ObjectItemModel* m_pObjectTreeModel; 38 | }; 39 | 40 | #endif // TRANSFORM_WIDGET_H 41 | -------------------------------------------------------------------------------- /src/about.cpp: -------------------------------------------------------------------------------- 1 | #include "about.h" 2 | #include "ui_about.h" 3 | 4 | About::About(QWidget *parent) : 5 | QDialog(parent), 6 | ui(new Ui::About) 7 | { 8 | ui->setupUi(this); 9 | ui->versionText->setText(QString("Version: ")+QTMESHEDITOR_VERSION); 10 | } 11 | 12 | About::~About() 13 | { 14 | delete ui; 15 | } 16 | 17 | QString About::getVersionText() const { 18 | return ui->versionText->text(); 19 | } 20 | -------------------------------------------------------------------------------- /src/about.h: -------------------------------------------------------------------------------- 1 | #ifndef ABOUT_H 2 | #define ABOUT_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class About; 8 | } 9 | 10 | class About : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit About(QWidget *parent = nullptr); 16 | ~About() override; 17 | 18 | QString getVersionText() const; 19 | 20 | private: 21 | Ui::About *ui; 22 | }; 23 | 24 | #endif // ABOUT_H 25 | -------------------------------------------------------------------------------- /src/about_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "about.h" 3 | #include 4 | 5 | class AboutTest : public ::testing::Test { 6 | protected: 7 | void SetUp() override { 8 | // Setup code if needed 9 | } 10 | 11 | void TearDown() override { 12 | // Cleanup code if needed 13 | } 14 | }; 15 | 16 | TEST_F(AboutTest, VersionTextIsCorrect) { 17 | int argc = 0; 18 | QApplication app(argc, nullptr); 19 | 20 | About aboutDialog; 21 | About aboutDialog2(&aboutDialog); // Also test with a parent widget. 22 | QString expectedVersionText = QString("Version: ") + QTMESHEDITOR_VERSION; 23 | EXPECT_EQ(aboutDialog.getVersionText(), expectedVersionText); 24 | EXPECT_EQ(aboutDialog2.getVersionText(), expectedVersionText); 25 | } 26 | -------------------------------------------------------------------------------- /src/animationcontrolslider.cpp: -------------------------------------------------------------------------------- 1 | #include "animationcontrolslider.h" 2 | 3 | AnimationControlSlider::AnimationControlSlider(QWidget *parent) 4 | : QSlider(parent) {} 5 | 6 | void AnimationControlSlider::addTick(int value, QColor color) 7 | { 8 | m_ticks.push_back(std::make_pair(value, color)); 9 | } 10 | 11 | void AnimationControlSlider::paintEvent(QPaintEvent *event) 12 | { 13 | QSlider::paintEvent(event); 14 | 15 | for(const auto &[first, second] : m_ticks) 16 | { 17 | int x = QStyle::sliderPositionFromValue(minimum(), maximum(), first, width()); 18 | QPainter painter(this); 19 | painter.setPen(QPen(second, 2)); 20 | painter.drawLine(x, 15, x, height()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/animationcontrolslider.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATIONCONTROLSLIDER_H 2 | #define ANIMATIONCONTROLSLIDER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class AnimationControlSlider : public QSlider 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | explicit AnimationControlSlider(QWidget *parent = nullptr); 14 | void addTick(int value, QColor color); 15 | 16 | protected: 17 | void paintEvent(QPaintEvent *event) override; 18 | 19 | private: 20 | std::vector> m_ticks; 21 | }; 22 | 23 | #endif // ANIMATIONCONTROLSLIDER_H 24 | -------------------------------------------------------------------------------- /src/animationcontrolwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATIONCONTROLWIDGET_H 2 | #define ANIMATIONCONTROLWIDGET_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class AnimationControlWidget; 8 | } 9 | 10 | namespace Ogre { 11 | class Entity; 12 | class NodeAnimationTrack; 13 | class SkeletonInstance; 14 | } 15 | 16 | class AnimationControlWidget : public QDockWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit AnimationControlWidget(QWidget *parent = nullptr); 22 | ~AnimationControlWidget(); 23 | 24 | public slots: 25 | void updateAnimationTree(); 26 | 27 | private slots: 28 | void setAnimationFrame(int time); 29 | 30 | private: 31 | Ui::AnimationControlWidget *ui; 32 | std::string m_selectedAnimation=""; 33 | Ogre::NodeAnimationTrack* m_selectedTrack=nullptr; 34 | Ogre::SkeletonInstance* m_selectedSkeleton=nullptr; 35 | Ogre::Entity* m_selectedEntity=nullptr; 36 | float m_time = 0.0f; 37 | }; 38 | 39 | #endif // ANIMATIONCONTROLWIDGET_H 40 | -------------------------------------------------------------------------------- /src/dependencies/zlib1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fernandotonon/QtMeshEditor/0ff73b461f62611adff20173f276a1253840da9e/src/dependencies/zlib1.dll -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "mainwindow.h" 8 | 9 | int main(int argc, char *argv[]) 10 | { 11 | QApplication a(argc, argv); 12 | 13 | QCoreApplication::setOrganizationName("QtMeshEditor"); 14 | QCoreApplication::setOrganizationDomain("none"); 15 | QCoreApplication::setApplicationName("QtMeshEditor"); 16 | QCoreApplication::setApplicationVersion(QTMESHEDITOR_VERSION); 17 | 18 | a.setStyle(QStyleFactory::create("Fusion")); 19 | 20 | MainWindow w; 21 | w.show(); 22 | 23 | return a.exec(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "mainwindow.h" 10 | #include "Manager.h" 11 | 12 | using ::testing::Mock; 13 | 14 | // Mock class for MainWindow 15 | class MockMainWindow : public MainWindow 16 | { 17 | public: 18 | MOCK_METHOD(void, show, ()); 19 | }; 20 | 21 | // Mock class for QApplication 22 | class MockQApplication : public QApplication 23 | { 24 | public: 25 | MockQApplication(int& argc, char** argv) : QApplication(argc, argv) {} 26 | 27 | MOCK_METHOD(int, exec, ()); 28 | }; 29 | 30 | // Test case using the mocked MainWindow and QApplication 31 | TEST(MainTest, QApplicationAndMainWindowMock) 32 | { 33 | int argc = 0; 34 | char* argv[] = { nullptr }; 35 | 36 | // Create mock objects 37 | MockQApplication mockQApplication(argc, argv); 38 | // MockMainWindow mockMainWindow; 39 | 40 | // Set expectations 41 | // EXPECT_CALL(mockMainWindow, show()).Times(0); 42 | EXPECT_CALL(mockQApplication, exec()).Times(1); 43 | 44 | // Run the code under test 45 | int result = mockQApplication.exec(); 46 | 47 | // Assertions on the result if needed 48 | EXPECT_EQ(result, 0); 49 | 50 | // Clear the mock object 51 | Mock::VerifyAndClear(&mockQApplication); 52 | } 53 | 54 | //Test creating mainwindow passing a list of URIs to import as startup arguments 55 | TEST(MainTest, ImportMeshs) { 56 | auto before = Manager::getSingleton()->getEntities().count(); 57 | int argc = 2; 58 | char* argv[] = { "./media/models/ninja.mesh", "./media/models/robot.mesh" }; 59 | QApplication app(argc, argv); 60 | MainWindow mainWindow; 61 | Manager::getSingleton()->getRoot()->renderOneFrame(); 62 | auto after = Manager::getSingleton()->getEntities().count(); 63 | ASSERT_EQ(after, before+3); 64 | } 65 | -------------------------------------------------------------------------------- /src/material.h: -------------------------------------------------------------------------------- 1 | #ifndef MATERIAL_H 2 | #define MATERIAL_H 3 | 4 | #include "QtWidgets/qlistwidget.h" 5 | #include 6 | 7 | namespace Ui { 8 | class Material; 9 | } 10 | 11 | class Material : public QMainWindow 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Material(QWidget *parent = nullptr); 17 | virtual ~Material(); 18 | void SetMaterialList(const QStringList &_list); 19 | 20 | private slots: 21 | void on_listMaterial_itemSelectionChanged(); 22 | 23 | void on_buttonEdit_clicked(); 24 | 25 | void on_buttonExport_clicked(); 26 | 27 | void on_buttonNew_clicked(); 28 | 29 | void on_pushButton_clicked(); 30 | 31 | void on_listMaterial_itemDoubleClicked(QListWidgetItem *item); 32 | 33 | private: 34 | Ui::Material *ui; 35 | 36 | void UpdateMaterialList(); 37 | }; 38 | 39 | #endif // MATERIAL_H 40 | -------------------------------------------------------------------------------- /ui_files/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB BUILD_UIS "${CMAKE_CURRENT_SOURCE_DIR}/*.ui") 2 | 3 | QT_WRAP_UI(BUILD_UIS_H ${BUILD_UIS}) 4 | 5 | SET(BUILD_UIH_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) 6 | 7 | ADD_CUSTOM_TARGET(ui ALL DEPENDS ${BUILD_UIS_H}) 8 | 9 | MESSAGE(STATUS "Ui wrapped and added") 10 | --------------------------------------------------------------------------------