├── .appveyor.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── example-forest ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ └── .gitkeep ├── config.make ├── example-forest.qbs ├── example-forest.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── example-forest.xcscmblueprint │ │ └── xcuserdata │ │ │ └── da1.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── xcshareddata │ │ └── xcschemes │ │ │ ├── example-forest Debug.xcscheme │ │ │ └── example-forest Release.xcscheme │ └── xcuserdata │ │ └── da1.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example-gui ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ └── trees │ │ ├── bush-1.xml │ │ ├── carpet.xml │ │ ├── doube-rule.xml │ │ ├── koch.xml │ │ ├── node-rewriting-1.xml │ │ ├── node-rewriting-2.xml │ │ ├── node-rewriting-3.xml │ │ ├── parametric-test.xml │ │ ├── parametric-without-condition.xml │ │ ├── sierpinski-gasket.xml │ │ ├── stochastic-test.xml │ │ ├── tree-3.xml │ │ ├── twig.xml │ │ └── weed-1.xml ├── config.make ├── example-gui.qbs ├── example-gui.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── example-gui.xcscmblueprint │ │ └── xcuserdata │ │ │ └── da1.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── xcshareddata │ │ └── xcschemes │ │ │ ├── example-gui Debug.xcscheme │ │ │ └── example-gui Release.xcscheme │ └── xcuserdata │ │ └── da1.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── guiExample.qbs ├── guiExample.qbs.user ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example-shader ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ └── shaders_gl3 │ │ ├── 2dmatrices.frag │ │ ├── 2dmatrices.vert │ │ ├── basic.frag │ │ ├── basic.vert │ │ ├── colors.frag │ │ ├── colors.vert │ │ ├── generative.frag │ │ ├── generative.vert │ │ ├── noise.frag │ │ ├── noise.vert │ │ ├── patterns.frag │ │ ├── patterns.vert │ │ ├── ring.frag │ │ ├── ring.vert │ │ ├── shapes.frag │ │ └── shapes.vert ├── config.make ├── example-shader.qbs ├── example-shader.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── example-shader.xcscmblueprint │ │ └── xcuserdata │ │ │ └── da1.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── xcshareddata │ │ └── xcschemes │ │ │ ├── shadersTree Debug.xcscheme │ │ │ └── shadersTree Release.xcscheme │ └── xcuserdata │ │ └── da1.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example-texture ├── Makefile ├── Project.xcconfig ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ ├── bark.jpg │ │ └── texture.png ├── config.make ├── example-texture.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── example-texture.xcscmblueprint │ │ └── xcuserdata │ │ │ └── da1.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── xcshareddata │ │ └── xcschemes │ │ │ ├── example-texture Debug.xcscheme │ │ │ └── example-texture Release.xcscheme │ └── xcuserdata │ │ └── da1.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── img ├── azul.png ├── forest.png ├── green.png ├── rings.gif ├── scaleWidth.png └── violet.png ├── ofxaddons_thumbnail.png └── src ├── ofxLSBoundingBox.h ├── ofxLSBranch.h ├── ofxLSGeometry.cpp ├── ofxLSGeometry.h ├── ofxLSGeometryAvailable.h ├── ofxLSInputError.h ├── ofxLSInstruction.cpp ├── ofxLSInstruction.h ├── ofxLSLine.cpp ├── ofxLSLine.h ├── ofxLSOption.h ├── ofxLSTriangle.cpp ├── ofxLSTriangle.h ├── ofxLSTube.cpp ├── ofxLSTube.h ├── ofxLSTubeDeformed.cpp ├── ofxLSTubeDeformed.h ├── ofxLSTurtle.cpp ├── ofxLSTurtle.h ├── ofxLSUtils.h ├── ofxLSystem.cpp └── ofxLSystem.h /.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | 3 | environment: 4 | global: 5 | APPVEYOR_OS_NAME: windows 6 | matrix: 7 | #MSYS2 Building 8 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 9 | platform: x86 10 | BUILDER: MSYS2 11 | 12 | #VisualStudio Building 13 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 14 | platform: x86 15 | BUILDER : VS 16 | BITS: 32 17 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 18 | platform: x64 19 | BUILDER : VS 20 | BITS: 64 21 | 22 | configuration: Debug 23 | shallow_clone: true 24 | clone_depth: 10 25 | 26 | init: 27 | - set MSYS2_PATH=c:\msys64 28 | - set CHERE_INVOKING=1 29 | - if "%BUILDER%_%PLATFORM%"=="MSYS2_x86" set MSYSTEM=MINGW32 30 | - if "%BUILDER%_%PLATFORM%"=="MSYS2_x64" set MSYSTEM=MINGW64 31 | - '%MSYS2_PATH%\usr\bin\bash -lc "pacman --noconfirm -S --needed unzip rsync"' 32 | - if "%BUILDER%"=="VS" set PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin;%PATH% 33 | 34 | install: 35 | - cd .. 36 | - git clone --depth=1 --branch=master https://github.com/openframeworks/openFrameworks 37 | - git clone --depth=1 --branch=master https://github.com/edap/ofxLSystemGrammar openframeworks/addons/ofxLSystemGrammar 38 | - call openFrameworks\scripts\ci\addons\install.cmd 39 | 40 | build_script: 41 | - cd %OF_PATH% 42 | - scripts\ci\addons\build.cmd 43 | 44 | 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | example-forest/bin/forestExampleDebug.app 2 | example-forest/bin/example-forestDebug 3 | example-forest/bin/example-forestDebug.app 4 | build-forestExample-Desktop-Debug/ 5 | build-example-forest-Desktop-Debug/ 6 | example-forest/bin/example-forest_debug 7 | 8 | example-gui/bin/example-guiDebug 9 | example-gui/bin/example-guiDebug.app 10 | example-gui/bin/guiExampleDebug.app 11 | build-guiExample-Desktop-Debug/ 12 | build-example-gui-Desktop-Debug/ 13 | example-gui/bin/example-gui_debug 14 | 15 | example-texture/bin/textureExampleDebug.app 16 | example-texture/bin/example-textureDebug 17 | example-texture/bin/example-textureDebug.app 18 | build-textureExample-Desktop-Debug/ 19 | build-example-texture-Desktop-Debug/ 20 | example-texture/bin/example-texture_debug 21 | 22 | example-shader/bin/shaderExampleDebug.app 23 | example-shader/bin/example-shaderDebug 24 | example-shader/bin/example-shaderDebug.app 25 | build-shaderExample-Desktop-Debug/ 26 | build-example-shader-Desktop-Debug/ 27 | example-shader/bin/example-shader_debug 28 | 29 | example-rings/bin/ringsExampleDebug.app 30 | example-rings/bin/example-ringsDebug 31 | example-rings/bin/example-ringsDebug.app 32 | build-ringsExample-Desktop-Debug/ 33 | build-example-rings-Desktop-Debug/ 34 | example-rings/bin/example-rings_debug 35 | example-rings/bin/data/*.ply 36 | 37 | *qbs.user 38 | 39 | 40 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # This file allows testing your addon using travis CI servers to use it you'll need to 2 | # create an account in travis.org and enable your addon there. 3 | # 4 | # By default it will test linux 64bit and osx against the master and stable OF branches. 5 | # Other platforms can be enabled by uncommenting the corresponding sections. 6 | # 7 | # If any extra install is needed to use the addon it can be included in the corresponding 8 | # install script in: 9 | # 10 | # scripts/ci/$TARGET/install.sh 11 | # 12 | 13 | 14 | language: c++ 15 | compiler: gcc 16 | sudo: true 17 | matrix: 18 | include: 19 | # fully specify builds, include can't dynamically expand matrix entries 20 | # relative order of sudo and env is important so that addons: is recognized 21 | 22 | # Linux 64bit, OF master 23 | - os: linux 24 | dist: trusty 25 | sudo: required 26 | env: TARGET="linux64" OF_BRANCH="master" 27 | addons: 28 | apt: 29 | sources: 30 | - ubuntu-toolchain-r-test 31 | packages: 32 | - gcc-5 33 | - g++-5 34 | - gdb 35 | 36 | # Linux 64bit, OF stable: Not supported yet 37 | # - os: linux 38 | # dist: trusty 39 | # sudo: required 40 | # env: TARGET="linux64" OF_BRANCH="stable" 41 | # addons: 42 | # apt: 43 | # sources: 44 | # - ubuntu-toolchain-r-test 45 | # packages: 46 | # - gcc-4.9 47 | # - g++-4.9 48 | # - gdb 49 | 50 | # OSX, OF master 51 | - os: osx 52 | osx_image: xcode9.4 53 | compiler: clang 54 | env: TARGET="osx" OF_BRANCH="master" 55 | 56 | # OSX, OF stable: Not supported yet 57 | # - os: osx 58 | # osx_image: xcode9.4 59 | # compiler: clang 60 | # env: TARGET="osx" OF_BRANCH="stable" 61 | 62 | # Linux ARM6, OF master: Uncomment following lines to enable 63 | # - os: linux 64 | # sudo: required 65 | # dist: trusty 66 | # env: TARGET="linuxarmv6l" OF_BRANCH="master" 67 | 68 | 69 | # Linux ARM6, OF stable: Not supported yet 70 | # - os: linux 71 | # sudo: required 72 | # dist: trusty 73 | # env: TARGET="linuxarmv6l" OF_BRANCH="stable" 74 | 75 | # Linux ARM7, OF master: Uncomment following lines to enable 76 | # - os: linux 77 | # sudo: false 78 | # env: TARGET="linuxarmv7l" OF_BRANCH="master" 79 | # cache: 80 | # directories: 81 | # - ~/rpi2_toolchain 82 | # - ~/firmware-master 83 | # - ~/archlinux 84 | 85 | # Linux ARM7, OF stable: Not supported yet 86 | # - os: linux 87 | # sudo: false 88 | # env: TARGET="linuxarmv7l" OF_BRANCH="stable" 89 | # cache: 90 | # directories: 91 | # - ~/rpi2_toolchain 92 | # - ~/firmware-master 93 | # - ~/archlinux 94 | 95 | 96 | # Emscripten, OF master: Uncomment following lines to enable 97 | # - os: linux 98 | # sudo: false 99 | # env: TARGET="emscripten" OF_BRANCH="master" 100 | # addons: 101 | # apt: 102 | # sources: 103 | # - ubuntu-toolchain-r-test 104 | # packages: 105 | # - libstdc++6 106 | 107 | 108 | # Emscripten, OF stable: Not supported yet 109 | # - os: linux 110 | # sudo: false 111 | # env: TARGET="emscripten" OF_BRANCH="stable" 112 | # addons: 113 | # apt: 114 | # sources: 115 | # - ubuntu-toolchain-r-test 116 | # packages: 117 | # - libstdc++6 118 | 119 | 120 | # iOS, OF master: Not supported yet 121 | # - os: osx 122 | # osx_image: xcode8 123 | # compiler: clang 124 | # env: TARGET="ios" OF_BRANCH="master" 125 | 126 | 127 | # iOS, OF stable: Not supported yet 128 | # - os: osx 129 | # osx_image: xcode8 130 | # compiler: clang 131 | # env: TARGET="ios" OF_BRANCH="stable" 132 | 133 | 134 | # tvOS, OF master: Not supported yet 135 | # - os: osx 136 | # osx_image: xcode8 137 | # compiler: clang 138 | # env: TARGET="tvos" OF_BRANCH="master" 139 | 140 | 141 | # tvOS, OF stable: Not supported yet 142 | # - os: osx 143 | # osx_image: xcode8 144 | # compiler: clang 145 | # env: TARGET="tvos" OF_BRANCH="stable" 146 | 147 | 148 | # Android armv7, OF master: Uncomment following lines to enable 149 | # - os: linux 150 | # sudo: false 151 | # env: TARGET="android" OPT="armv7" OF_BRANCH="master" 152 | # cache: 153 | # directories: 154 | # - ~/android-ndk-r12b 155 | 156 | 157 | # Android armv7, OF stable: Not supported yet 158 | # - os: linux 159 | # sudo: false 160 | # env: TARGET="android" OPT="armv7" OF_BRANCH="stable" 161 | # cache: 162 | # directories: 163 | # - ~/android-ndk-r12b 164 | 165 | 166 | # Android x86, OF master: Uncomment following lines to enable 167 | # - os: linux 168 | # sudo: false 169 | # env: TARGET="android" OPT="x86" OF_BRANCH="master" 170 | # cache: 171 | # directories: 172 | # - ~/android-ndk-r12b 173 | 174 | 175 | # Android x86, OF stable: Not supported yet 176 | # - os: linux 177 | # sudo: false 178 | # env: TARGET="android" OPT="x86" OF_BRANCH="stable" 179 | # cache: 180 | # directories: 181 | # - ~/android-ndk-r12b 182 | 183 | 184 | # Exclude the default build that would otherwise be generated 185 | # see https://github.com/travis-ci/travis-ci/issues/1228 186 | exclude: 187 | - compiler: gcc 188 | 189 | install: 190 | - cd ~ 191 | - git clone --depth=1 --branch=$OF_BRANCH https://github.com/openframeworks/openFrameworks 192 | - cd openFrameworks 193 | - scripts/ci/addons/install.sh 194 | - git clone --depth=1 --branch=master https://github.com/edap/ofxLSystemGrammar addons/ofxLSystemGrammar 195 | 196 | script: 197 | - scripts/ci/addons/build.sh 198 | 199 | git: 200 | depth: 10 201 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2016 Davide Prati 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ofxLSystem 2 | 3 | [![Build status](https://travis-ci.org/edap/ofxLSystem.svg?branch=master)](https://travis-ci.org/edap/ofxLSystem) 4 | [![Build status](https://ci.appveyor.com/api/projects/status/etxh1ocwr7nbcf84?svg=true)](https://ci.appveyor.com/project/edap/ofxlsystem) 5 | 6 | 7 | This addon has a dependency on [ofxLSystemGrammar](https://github.com/edap/ofxLSystemGrammar). Download it and add it to your addon folder 8 | 9 | ofxLSystem is a 3D graphic turtle graphic interpretation of L-Syestems. In the readme of ofxLSystemGrammar you can find some information about L-System. 10 | This addon can be used to generate meshes as the following ones: 11 | 12 | ![example](img/violet.png) 13 | ![example](img/green.png) 14 | ![example](img/azul.png) 15 | ![example](img/forest.png) 16 | ![example](img/rings.gif) 17 | 18 | ## Supported platforms 19 | 20 | It is currently tested on mac, linux and windows and the current version of openFrameworks in master 21 | 22 | On linux, you need g++ > 4.9 and the `-std=gnu++14` flag. Otherwise you will have an error about `std::regex_iterator`. This flag is the default since OF 0.9.3, just in case you set it to `std=c++11` as described in this [post]( https://forum.openframeworks.cc/t/openframeworks-0-9-qtcreator/21312/7). 23 | 24 | ## Usage 25 | 26 | In your header file include `ofxLSystem` and declare an instance of it. Declare also a material, it will be applied to the tree's mesh. 27 | 28 | ```cpp 29 | #include "ofxLSystem.h" 30 | // ... 31 | ofxLSystem tree 32 | ofMaterial treeMaterial 33 | ``` 34 | 35 | In your `ofApp.cpp` 36 | 37 | ```cpp 38 | void ofApp::setup(){ 39 | treeMaterial.setDiffuseColor(ofFloatColor::blueSteel) 40 | tree.setStep(4); 41 | tree.build(); 42 | } 43 | 44 | 45 | void ofApp::draw(){ 46 | treeMaterial.begin(); 47 | tree.draw(); 48 | treeMaterial.end(); 49 | } 50 | ``` 51 | 52 | `tree.setAxiom("F")` tells to ofxLSystem to use `F` as axiom, `tree.setRules({"F -> FF[+F][-F]"})` to use `F -> FF[+F][-F]` as reproduction rule and `tree.setStep(4)` to iterate 4 times. Have a look into ofxLSystemGrammar or in the 2 examples in this project for more L-System examples. 53 | 54 | By default, each L-System is initialized with this parameters: 55 | 56 | ```cpp 57 | typedef map Constants; 58 | 59 | vector rulesContainer = {"F -> F[+F][-F]"}; 60 | string axiom = "F"; 61 | bool randomYRotation = false; 62 | int depth = 1; 63 | float theta = 25.00; 64 | float stepWidth = 10.00; 65 | bool scaleWidth = false; 66 | float stepLength = 100.00; 67 | map constants = Constants(); 68 | ``` 69 | 70 | you can overwrite the default parameters using these methods: 71 | 72 | ```cpp 73 | void setAxiom(string _axiom); 74 | void setRules(vector _rulesContainer); 75 | void setTheta(float _theta); 76 | void setRandomZRotation(bool _randomYRotation); 77 | void setStep(int _depth); 78 | void setScaleWidth(bool _scaleWidht); 79 | void setStepWidth(float _stepWidth); 80 | void setStepLength(float _stepLength); 81 | void setConstants(map _Constants); 82 | ``` 83 | 84 | For example, the following snippet: 85 | 86 | ```cpp 87 | ofxLSystem tree; 88 | map constants; 89 | constants.insert(make_pair("R", 1.456)); 90 | 91 | tree.setAxiom("A(100)"); 92 | tree.setRules({"A(s) -> F(s)[+A(s/R)][-A(s/R)]"}); 93 | tree.setRandomYRotation(true); 94 | tree.setConstants(constants); 95 | tree.setStep(4); 96 | tree.setScaleWidth(true); 97 | tree.setStepLength(90); 98 | ``` 99 | 100 | Generates a tree like this: 101 | 102 | ![example](img/scaleWidth.png) 103 | 104 | 105 | 106 | ## Examples 107 | 108 | - *example-gui* contains ~10 differents L-Systems, with a GUI to change colors, rotation angle, n steps ecc. It saves the settings for each tree on a separate xml file 109 | - *example-forest* An example on how you can build a forest merging the meshes of 60 trees in one 110 | - *example-shader* I've added some simple shaders following "the book of shader" of Patricio Gonzalo Vivo. 111 | -------------------------------------------------------------------------------- /example-forest/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example-forest/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | //ICONS - NEW IN 0072 9 | ICON_NAME_DEBUG = icon-debug.icns 10 | ICON_NAME_RELEASE = icon.icns 11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ 12 | 13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: 14 | //ICON_FILE_PATH = bin/data/ 15 | 16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS) 17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 18 | -------------------------------------------------------------------------------- /example-forest/addons.make: -------------------------------------------------------------------------------- 1 | ofxLSystem 2 | ofxLSystemGrammar 3 | -------------------------------------------------------------------------------- /example-forest/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-forest/bin/data/.gitkeep -------------------------------------------------------------------------------- /example-forest/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example-forest/example-forest.qbs: -------------------------------------------------------------------------------- 1 | import qbs 2 | import qbs.Process 3 | import qbs.File 4 | import qbs.FileInfo 5 | import qbs.TextFile 6 | import "../../../libs/openFrameworksCompiled/project/qtcreator/ofApp.qbs" as ofApp 7 | 8 | Project{ 9 | property string of_root: '../../..' 10 | 11 | ofApp { 12 | name: { return FileInfo.baseName(sourceDirectory) } 13 | 14 | files: [ 15 | 'src/main.cpp', 16 | 'src/ofApp.cpp', 17 | 'src/ofApp.h', 18 | ] 19 | 20 | // This project is using addons.make to include the addons 21 | // since it was imported from old code. To change it to include 22 | // the addons from the qbs file change the following lines to 23 | // the list of used addons in array format. eg: 24 | // 25 | // of.addons: [ 26 | // 'ofxGui', 27 | // 'ofxOpenCv', 28 | // ] 29 | 30 | // additional flags for the project. the of module sets some 31 | // flags by default to add the core libraries, search paths... 32 | // this flags can be augmented through the following properties: 33 | of.pkgConfigs: [] // list of additional system pkgs to include 34 | of.includePaths: [] // include search paths 35 | of.cFlags: [] // flags passed to the c compiler 36 | of.cxxFlags: [] // flags passed to the c++ compiler 37 | of.linkerFlags: [] // flags passed to the linker 38 | of.defines: [] // defines are passed as -D to the compiler 39 | // and can be checked with #ifdef or #if in the code 40 | of.frameworks: [] // osx only, additional frameworks to link with the project 41 | of.staticLibraries: [] // static libraries 42 | of.dynamicLibraries: [] // dynamic libraries 43 | 44 | // other flags can be set through the cpp module: http://doc.qt.io/qbs/cpp-module.html 45 | // eg: this will enable ccache when compiling 46 | // 47 | // cpp.compilerWrapper: 'ccache' 48 | 49 | Depends{ 50 | name: "cpp" 51 | } 52 | 53 | // common rules that parse the include search paths, core libraries... 54 | Depends{ 55 | name: "of" 56 | } 57 | 58 | // dependency with the OF library 59 | Depends{ 60 | name: "openFrameworks" 61 | } 62 | } 63 | 64 | property bool makeOF: true // use makfiles to compile the OF library 65 | // will compile OF only once for all your projects 66 | // otherwise compiled per project with qbs 67 | 68 | references: [FileInfo.joinPaths(of_root, "/libs/openFrameworksCompiled/project/qtcreator/openFrameworks.qbs")] 69 | } 70 | -------------------------------------------------------------------------------- /example-forest/example-forest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example-forest/example-forest.xcodeproj/project.xcworkspace/xcshareddata/example-forest.xcscmblueprint: -------------------------------------------------------------------------------- 1 | { 2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2", 3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { 4 | 5 | }, 6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { 7 | "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" : 9223372036854775807, 8 | "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" : 9223372036854775807 9 | }, 10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "255E18EA-DAAB-4670-AFBE-4C16260AF19D", 11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { 12 | "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" : "ofxLSystem\/", 13 | "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" : "ofxLSystemGrammar\/" 14 | }, 15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "example-forest", 16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204, 17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "example-forest\/example-forest.xcodeproj", 18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ 19 | { 20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:edap\/ofxLSystem.git", 21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" 23 | }, 24 | { 25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:edap\/ofxLSystemGrammar.git", 26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /example-forest/example-forest.xcodeproj/project.xcworkspace/xcuserdata/da1.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-forest/example-forest.xcodeproj/project.xcworkspace/xcuserdata/da1.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /example-forest/example-forest.xcodeproj/xcshareddata/xcschemes/example-forest Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /example-forest/example-forest.xcodeproj/xcshareddata/xcschemes/example-forest Release.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /example-forest/example-forest.xcodeproj/xcuserdata/da1.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SuppressBuildableAutocreation 6 | 7 | E4B69B5A0A3A1756003C02F2 8 | 9 | primary 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-forest/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | cc.openFrameworks.ofapp 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | CFBundleIconFile 20 | ${ICON} 21 | NSHighResolutionCapable 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /example-forest/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /example-forest/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | float halfScreen = ofGetWidth()/2; 6 | //light 7 | light.setPosition(500, 1000, 1600); 8 | light.enable(); 9 | 10 | //camera 11 | cam.setPosition(0, 100, 600); 12 | cam.lookAt(ofVec3f(0, 0, 0)); 13 | //cam.setNearClip(0.01f); 14 | //cam.setMovementMaxSpeed( 25.f ); 15 | 16 | //plane 17 | plane.setPosition(100, 0, 0); 18 | plane.set(20000, 20000); 19 | plane.setResolution(20, 20); 20 | plane.rotate(270, 1, 0 , 0); 21 | 22 | roadMaterial.setDiffuseColor(ofFloatColor::moccasin); 23 | roadMaterial.setShininess(0.01); 24 | treeMaterial.setAmbientColor(ofFloatColor::hotPink); 25 | treeMaterial.setSpecularColor(ofFloatColor::blueSteel); 26 | treeMaterial.setDiffuseColor(ofFloatColor::yellowGreen); 27 | treeMaterial.setShininess(0.04); 28 | map constants; 29 | constants.insert(make_pair("R", 1.356)); 30 | 31 | for(int i = 0; i F(s)[+A(s/R)][-A(s/R)]"}); 35 | tree.setRandomYRotation(true); 36 | tree.setConstants(constants); 37 | tree.setStep(abs(ofRandom(6, 9))); 38 | tree.setScaleWidth(true); 39 | tree.setResolution(20); 40 | tree.setStep(abs(ofRandom(5, 7))); 41 | tree.setStepWidth(abs(ofRandom(30.5, 40.5))); 42 | tree.setStepLength(abs(ofRandom(150,300))); 43 | tree.build(); 44 | auto pos = ofVec2f(ofRandom(-halfScreen, halfScreen), 45 | ofRandom(-halfScreen, halfScreen)); 46 | for (int i=0; i 2 | 3 | F -> FF+[+F-F-F]-[-F+F+F] 4 | F 5 | 2 6 | 25 7 | 140, 68, 45, 255 8 | 255, 188, 55, 255 9 | 0 10 | 11 | 2 12 | 10, 93, 252, 255 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/carpet.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | F -> F[F] -F +F [--F] +F -F 4 | F-F-F-F 5 | 4 6 | 90 7 | 100, 162, 5, 255 8 | 37, 255, 255, 255 9 | 10 | 11 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/doube-rule.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | B ->F[-B]+B;F->FF 4 | B 5 | 2 6 | 25 7 | 100, 100, 140, 255 8 | 255, 0, 0, 255 9 | 10 | 11 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/koch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | F -> F - F ++F -F 4 | F++F++F 5 | 3 6 | 60 7 | 100, 162, 5, 255 8 | 37, 255, 255, 255 9 | 10 | 11 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/node-rewriting-1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | X -> F[+X]F[-X]+X; 5 | F -> FF; 6 | 7 | X 8 | 7 9 | 20 10 | 39, 128, 123, 255 11 | 150, 180, 0, 255 12 | 4 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/node-rewriting-2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | X -> F[+X][-X]FX; 5 | F -> FF; 6 | 7 | X 8 | 7 9 | 25.7 10 | 39, 128, 123, 255 11 | 150, 180, 0, 255 12 | 4 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/node-rewriting-3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | X -> F-[[X]+X]+F[+FX]-X; 5 | F -> FF; 6 | 7 | X 8 | 7 9 | 22.5 10 | 39, 128, 123, 255 11 | 150, 180, 0, 255 12 | 4 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/parametric-test.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | A(x,y): y<=3 -> A(x*2,x+y); 5 | A(x,y): y>3 -> B(x)A(x/y,0); 6 | B(x) :x<1 -> C; 7 | B(x) : x>=1 -> B(x-1); 8 | 9 | B(2)A(4,4) 10 | 2 11 | 25 12 | 100, 100, 140, 255 13 | 255, 0, 0, 255 14 | 15 | 16 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/parametric-without-condition.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | A(s) -> F(s)[+A(s/R)][-A(s/R)]; 5 | 6 | A(100) 7 | R=1.456 8 | 2 9 | 85 10 | 40, 31, 228, 255 11 | 104, 173, 0, 255 12 | 0 13 | 3 14 | 255, 45, 0, 255 15 | 16 | 17 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/sierpinski-gasket.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | F -> F--F--F--GG; G -> GG 4 | F--F--F 5 | 3 6 | 60 7 | 100, 162, 5, 255 8 | 37, 255, 255, 255 9 | 10 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/stochastic-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 0.50 -> B -> F[-B]+B; 5 | 0.50 -> F -> FF 6 | 7 | 8 | B 9 | 2 10 | 25 11 | 100, 100, 140, 255 12 | 255, 0, 0, 255 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/tree-3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | A(s) -> F(s)[--A(s/R)][+A(s/R)]-A(s/R); 5 | 6 | A(100) 7 | 3 8 | 24.3 9 | 29, 244, 206, 255 10 | 39, 202, 227, 255 11 | R=1.456 12 | 1 13 | 0 14 | 0 15 | 0 16 | 5 17 | 1 18 | 0.01 19 | 255, 0, 0, 255 20 | 195, 63, 134, 255 21 | 22 | 23 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/twig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | A(s) -> F(s)[+A(s/R)][-A(s/R)]; 5 | 6 | A(100) 7 | 3 8 | 24.3 9 | 61, 175, 255, 255 10 | 255, 84, 0, 255 11 | R=1.456 12 | 0 13 | 0 14 | 0 15 | 0 16 | 7 17 | 1 18 | 0.01 19 | 255, 0, 0, 255 20 | 223, 191, 0, 255 21 | 22 | 23 | -------------------------------------------------------------------------------- /example-gui/bin/data/trees/weed-1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | F -> F[-F]F[+F]F 4 | F 5 | 3 6 | 24.3 7 | 217, 163, 11, 255 8 | 255, 31, 0, 255 9 | 10 | 11 | -------------------------------------------------------------------------------- /example-gui/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example-gui/example-gui.qbs: -------------------------------------------------------------------------------- 1 | import qbs 2 | import qbs.Process 3 | import qbs.File 4 | import qbs.FileInfo 5 | import qbs.TextFile 6 | import "../../../libs/openFrameworksCompiled/project/qtcreator/ofApp.qbs" as ofApp 7 | 8 | Project{ 9 | property string of_root: '../../..' 10 | 11 | ofApp { 12 | name: { return FileInfo.baseName(sourceDirectory) } 13 | 14 | files: [ 15 | 'src/main.cpp', 16 | 'src/ofApp.cpp', 17 | 'src/ofApp.h', 18 | ] 19 | 20 | // This project is using addons.make to include the addons 21 | // since it was imported from old code. To change it to include 22 | // the addons from the qbs file change the following lines to 23 | // the list of used addons in array format. eg: 24 | // 25 | // of.addons: [ 26 | // 'ofxGui', 27 | // 'ofxOpenCv', 28 | // ] 29 | 30 | // additional flags for the project. the of module sets some 31 | // flags by default to add the core libraries, search paths... 32 | // this flags can be augmented through the following properties: 33 | of.pkgConfigs: [] // list of additional system pkgs to include 34 | of.includePaths: [] // include search paths 35 | of.cFlags: [] // flags passed to the c compiler 36 | of.cxxFlags: [] // flags passed to the c++ compiler 37 | of.linkerFlags: [] // flags passed to the linker 38 | of.defines: [] // defines are passed as -D to the compiler 39 | // and can be checked with #ifdef or #if in the code 40 | of.frameworks: [] // osx only, additional frameworks to link with the project 41 | of.staticLibraries: [] // static libraries 42 | of.dynamicLibraries: [] // dynamic libraries 43 | 44 | // other flags can be set through the cpp module: http://doc.qt.io/qbs/cpp-module.html 45 | // eg: this will enable ccache when compiling 46 | // 47 | // cpp.compilerWrapper: 'ccache' 48 | 49 | Depends{ 50 | name: "cpp" 51 | } 52 | 53 | // common rules that parse the include search paths, core libraries... 54 | Depends{ 55 | name: "of" 56 | } 57 | 58 | // dependency with the OF library 59 | Depends{ 60 | name: "openFrameworks" 61 | } 62 | } 63 | 64 | property bool makeOF: true // use makfiles to compile the OF library 65 | // will compile OF only once for all your projects 66 | // otherwise compiled per project with qbs 67 | 68 | references: [FileInfo.joinPaths(of_root, "/libs/openFrameworksCompiled/project/qtcreator/openFrameworks.qbs")] 69 | } 70 | -------------------------------------------------------------------------------- /example-gui/example-gui.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example-gui/example-gui.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example-gui/example-gui.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildSystemType 6 | Original 7 | 8 | 9 | -------------------------------------------------------------------------------- /example-gui/example-gui.xcodeproj/project.xcworkspace/xcshareddata/example-gui.xcscmblueprint: -------------------------------------------------------------------------------- 1 | { 2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2", 3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { 4 | 5 | }, 6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { 7 | "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" : 9223372036854775807, 8 | "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" : 9223372036854775807 9 | }, 10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "4FD03FC4-B95B-4988-8F97-43FA3DD81230", 11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { 12 | "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" : "ofxLSystem\/", 13 | "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" : "ofxLSystemGrammar\/" 14 | }, 15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "example-gui", 16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204, 17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "example-gui\/example-gui.xcodeproj", 18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ 19 | { 20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:edap\/ofxLSystem.git", 21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" 23 | }, 24 | { 25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:edap\/ofxLSystemGrammar.git", 26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /example-gui/example-gui.xcodeproj/project.xcworkspace/xcuserdata/da1.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-gui/example-gui.xcodeproj/project.xcworkspace/xcuserdata/da1.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /example-gui/example-gui.xcodeproj/xcshareddata/xcschemes/example-gui Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /example-gui/example-gui.xcodeproj/xcshareddata/xcschemes/example-gui Release.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /example-gui/example-gui.xcodeproj/xcuserdata/da1.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SuppressBuildableAutocreation 6 | 7 | E4B69B5A0A3A1756003C02F2 8 | 9 | primary 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-gui/guiExample.qbs: -------------------------------------------------------------------------------- 1 | import qbs 2 | import qbs.Process 3 | import qbs.File 4 | import qbs.FileInfo 5 | import qbs.TextFile 6 | import "../../../libs/openFrameworksCompiled/project/qtcreator/ofApp.qbs" as ofApp 7 | 8 | Project{ 9 | property string of_root: '../../..' 10 | 11 | ofApp { 12 | name: { return FileInfo.baseName(path) } 13 | 14 | files: [ 15 | 'src/main.cpp', 16 | 'src/ofApp.cpp', 17 | 'src/ofApp.h', 18 | ] 19 | 20 | // This project is using addons.make to include the addons 21 | // since it was imported from old code. To change it to include 22 | // the addons from the qbs file change the following lines to 23 | // the list of used addons in array format. eg: 24 | // 25 | // of.addons: [ 26 | // 'ofxGui', 27 | // 'ofxOpenCv', 28 | // ] 29 | 30 | // additional flags for the project. the of module sets some 31 | // flags by default to add the core libraries, search paths... 32 | // this flags can be augmented through the following properties: 33 | of.pkgConfigs: [] // list of additional system pkgs to include 34 | of.includePaths: [] // include search paths 35 | of.cFlags: [] // flags passed to the c compiler 36 | of.cxxFlags: [] // flags passed to the c++ compiler 37 | of.linkerFlags: [] // flags passed to the linker 38 | of.defines: [] // defines are passed as -D to the compiler 39 | // and can be checked with #ifdef or #if in the code 40 | of.frameworks: [] // osx only, additional frameworks to link with the project 41 | 42 | // other flags can be set through the cpp module: http://doc.qt.io/qbs/cpp-module.html 43 | // eg: this will enable ccache when compiling 44 | // 45 | // cpp.compilerWrapper: 'ccache' 46 | 47 | Depends{ 48 | name: "cpp" 49 | } 50 | 51 | // common rules that parse the include search paths, core libraries... 52 | Depends{ 53 | name: "of" 54 | } 55 | 56 | // dependency with the OF library 57 | Depends{ 58 | name: "openFrameworks" 59 | } 60 | } 61 | 62 | references: [FileInfo.joinPaths(of_root, "/libs/openFrameworksCompiled/project/qtcreator/openFrameworks.qbs")] 63 | } 64 | -------------------------------------------------------------------------------- /example-gui/guiExample.qbs.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {b94fec22-5fc5-4e3d-8bb9-126327a1fdf3} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | true 41 | false 42 | 0 43 | true 44 | 0 45 | 8 46 | true 47 | 1 48 | true 49 | true 50 | true 51 | false 52 | 53 | 54 | 55 | ProjectExplorer.Project.PluginSettings 56 | 57 | 58 | 59 | ProjectExplorer.Project.Target.0 60 | 61 | Desktop 62 | Desktop 63 | {7730fced-ecc8-4368-8182-9141ee6536c0} 64 | 0 65 | 0 66 | 0 67 | 68 | /home/da/Sources/OF/of_v0.9.3_linux64_release/addons/ofxLSystem/build-guiExample-Desktop-Debug 69 | 70 | 71 | true 72 | 73 | Qbs Build 74 | Qbs.BuildStep 75 | false 76 | 77 | debug 78 | qtc_Desktop_7d084846 79 | 80 | false 81 | false 82 | true 83 | 4 84 | false 85 | 86 | 1 87 | Build 88 | 89 | ProjectExplorer.BuildSteps.Build 90 | 91 | 92 | 93 | true 94 | 95 | Qbs Clean 96 | Qbs.CleanStep 97 | true 98 | false 99 | false 100 | 101 | 1 102 | Clean 103 | 104 | ProjectExplorer.BuildSteps.Clean 105 | 106 | 2 107 | false 108 | 109 | Debug 110 | 111 | Qbs.QbsBuildConfiguration 112 | 113 | 114 | /home/da/Sources/OF/of_v0.9.3_linux64_release/addons/ofxLSystem/build-guiExample-Desktop-Release 115 | 116 | 117 | true 118 | 119 | Qbs Build 120 | Qbs.BuildStep 121 | false 122 | 123 | release 124 | qtc_Desktop_7d084846 125 | 126 | false 127 | false 128 | true 129 | 0 130 | false 131 | 132 | 1 133 | Build 134 | 135 | ProjectExplorer.BuildSteps.Build 136 | 137 | 138 | 139 | true 140 | 141 | Qbs Clean 142 | Qbs.CleanStep 143 | true 144 | false 145 | false 146 | 147 | 1 148 | Clean 149 | 150 | ProjectExplorer.BuildSteps.Clean 151 | 152 | 2 153 | false 154 | 155 | Release 156 | 157 | Qbs.QbsBuildConfiguration 158 | 159 | 2 160 | 161 | 162 | 0 163 | Deploy 164 | 165 | ProjectExplorer.BuildSteps.Deploy 166 | 167 | 1 168 | Deploy locally 169 | Qbs Install 170 | Qbs.Deploy 171 | 172 | 1 173 | 174 | 175 | false 176 | 1000 177 | 178 | true 179 | 180 | false 181 | false 182 | false 183 | false 184 | true 185 | 0.01 186 | 10 187 | true 188 | 1 189 | 25 190 | 191 | 1 192 | true 193 | false 194 | true 195 | valgrind 196 | 197 | 0 198 | 1 199 | 2 200 | 3 201 | 4 202 | 5 203 | 6 204 | 7 205 | 8 206 | 9 207 | 10 208 | 11 209 | 12 210 | 13 211 | 14 212 | 213 | 2 214 | 215 | guiExample 216 | 217 | Qbs.RunConfiguration:guiExample.qtc_Desktop_7d084846---Qbs.RC.NameSeparator---guiExample 218 | 219 | 220 | /home/da/Sources/OF/of_v0.9.3_linux64_release/addons/ofxLSystem/guiExample/bin 221 | 3768 222 | false 223 | true 224 | false 225 | false 226 | true 227 | 228 | 1 229 | 230 | 231 | 232 | ProjectExplorer.Project.TargetCount 233 | 1 234 | 235 | 236 | ProjectExplorer.Project.Updater.FileVersion 237 | 18 238 | 239 | 240 | Version 241 | 18 242 | 243 | 244 | -------------------------------------------------------------------------------- /example-gui/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | cc.openFrameworks.ofapp 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | CFBundleIconFile 20 | ${ICON} 21 | NSCameraUsageDescription 22 | This app needs to access the camera 23 | NSMicrophoneUsageDescription 24 | This app needs to access the microphone 25 | 26 | 27 | -------------------------------------------------------------------------------- /example-gui/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /example-gui/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | readFilesDirectory(); 6 | selectedTheta.addListener(this, &ofApp::selectedThetaChanghed); 7 | selectedDepth.addListener(this, &ofApp::selectedDepthChanghed); 8 | saveMesh.addListener(this, &ofApp::saveMeshPressed); 9 | // on writing xml files, take care of this 10 | // https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references 11 | gui.loadFromFile("trees/bush-1.xml"); 12 | gui.setup(); 13 | gui.setPosition(ofPoint(5, 50)); 14 | gui.setName("treed"); 15 | gui.add(selectedRule.set("rule","F->F[-F][+F]")); 16 | axiom.setName("axiom"); 17 | gui.add(axiom); 18 | gui.add(randomYRotation.set("Random Y Rotation", false)); 19 | gui.add(definedConstant.set("constants", "")); 20 | gui.add(selectedDepth.set("depth", 2, 1, 9)); 21 | gui.add(selectedTheta.set("theta", 25.00, 0.00, 45.00)); 22 | gui.add(bgColor.set("bg color", ofColor(100, 100, 140), ofColor(0, 0), ofColor(255, 255))); 23 | gui.add(treeColor.set("tree color", ofColor(255, 0, 0), ofColor(0, 0), ofColor(255, 255))); 24 | gui.add(specularColor.set("specular color", ofColor(255, 255, 0), ofColor(0, 0), ofColor(255, 255))); 25 | gui.add(saveMesh.setup("save mesh")); 26 | ofSetVerticalSync(true); 27 | oldDepth = selectedDepth; 28 | 29 | //light 30 | light.setPosition(500, 1000, 1600); 31 | light.enable(); 32 | 33 | //camera 34 | cam.setPosition(0, 100, 200); 35 | cam.lookAt(ofVec3f(0, -20, 0)); 36 | 37 | startLSystem(axiom, 38 | selectedRule, 39 | selectedTheta, 40 | selectedDepth, 41 | definedConstant, 42 | randomYRotation 43 | ); 44 | } 45 | 46 | //-------------------------------------------------------------- 47 | void ofApp::update(){ 48 | material.setDiffuseColor(ofColor(treeColor)); 49 | material.setSpecularColor(ofColor(specularColor)); 50 | lsystem.pan(0.4); 51 | } 52 | 53 | void ofApp::startLSystem(string axiom, 54 | string rulesString, 55 | float theta, 56 | int depth, 57 | string _constants, 58 | bool randomZRotation){ 59 | auto constants = getConstants(_constants); 60 | auto rules = getRules(rulesString); 61 | lsystem.setAxiom(axiom); 62 | lsystem.setRules(rules); 63 | lsystem.setTheta(theta); 64 | lsystem.setStep(depth); 65 | lsystem.setScaleWidth(true); 66 | lsystem.setGeometry(TRIANGLES); 67 | lsystem.setConstants(constants); 68 | lsystem.setRandomYRotation(randomYRotation); 69 | lsystem.build(); 70 | } 71 | 72 | //-------------------------------------------------------------- 73 | void ofApp::draw(){ 74 | ofBackground(bgColor); 75 | 76 | maybeDrawGui(); 77 | ofEnableDepthTest(); 78 | // scene 79 | cam.begin(); 80 | //ofDrawAxis(100); 81 | material.begin(); 82 | lsystem.draw(); 83 | //lsystem.drawWireframe(); 84 | //lsystem.drawNormals(20); 85 | material.end(); 86 | cam.end(); 87 | ofDisableDepthTest(); 88 | } 89 | 90 | void ofApp::readFilesDirectory(){ 91 | selected = 0; 92 | dir.listDir("trees"); 93 | dir.sort(); 94 | for(auto file:dir){ 95 | fileNames.push_back(file.path()); 96 | } 97 | } 98 | 99 | void ofApp::loadSettings(string filename){ 100 | gui.clear(); 101 | gui.setName("treed"); 102 | readFilesDirectory(); 103 | } 104 | 105 | void ofApp::selectedThetaChanghed(float & aselectedTheta){ 106 | startLSystem(axiom, 107 | selectedRule, 108 | selectedTheta, 109 | selectedDepth, 110 | definedConstant, 111 | randomYRotation); 112 | } 113 | 114 | void ofApp::selectedDepthChanghed(int & aselectedDepth){ 115 | if(oldDepth!= aselectedDepth){ 116 | oldDepth = aselectedDepth; 117 | startLSystem(axiom, 118 | selectedRule, 119 | selectedTheta, 120 | selectedDepth, 121 | definedConstant, 122 | randomYRotation); 123 | } 124 | } 125 | 126 | //-------------------------------------------------------------- 127 | void ofApp::keyPressed(int key){ 128 | switch (key) 129 | { 130 | case OF_KEY_RETURN: 131 | gui.loadFromFile(fileNames[selected]); 132 | break; 133 | 134 | case OF_KEY_UP: 135 | selected = (selected - 1); 136 | if (selected < 0) selected = fileNames.size() - 1; 137 | break; 138 | 139 | case OF_KEY_DOWN: 140 | selected = (selected + 1) % fileNames.size(); 141 | break; 142 | case 's': 143 | gui.saveToFile(fileNames[selected]); 144 | break; 145 | 146 | case 'g': 147 | drawGui = !drawGui; 148 | break; 149 | 150 | default: 151 | break; 152 | } 153 | } 154 | //it expects a single string like "y=0.54353;t=1" 155 | mapofApp::getConstants(string _constant) const{ 156 | map result; 157 | auto parts = ofSplitString(_constant, ";"); 158 | for (auto con : parts){ 159 | auto def = ofSplitString(con, "="); 160 | if(def.size() == 2){ 161 | result.insert(make_pair(def[0], ofToFloat(def[1]))); 162 | } 163 | } 164 | return result; 165 | } 166 | 167 | vectorofApp::getRules(string rules) const{ 168 | vector stringRules; 169 | if(rules.find(";") != std::string::npos){ 170 | //multiple rules 171 | auto rule_container = ofSplitString(rules, ";"); 172 | for(auto r:rule_container){ 173 | stringRules.push_back(r); 174 | } 175 | }else{ 176 | //single rule 177 | stringRules.push_back(rules); 178 | } 179 | return stringRules; 180 | } 181 | 182 | //-------------------------------------------------------------- 183 | void ofApp::keyReleased(int key){ 184 | 185 | } 186 | 187 | //-------------------------------------------------------------- 188 | void ofApp::mouseMoved(int x, int y ){ 189 | 190 | } 191 | 192 | //-------------------------------------------------------------- 193 | void ofApp::mouseDragged(int x, int y, int button){ 194 | 195 | } 196 | 197 | //-------------------------------------------------------------- 198 | void ofApp::mousePressed(int x, int y, int button){ 199 | 200 | } 201 | 202 | void ofApp::maybeDrawGui(){ 203 | if (drawGui) { 204 | //fps 205 | string msg = "\n\nfps: " + ofToString(ofGetFrameRate(), 2); 206 | ofDrawBitmapStringHighlight(msg, 10, 10); 207 | //gui 208 | gui.draw(); 209 | // file selection 210 | ofPushStyle(); 211 | ofDisableLighting(); 212 | for (unsigned i = 0; i < fileNames.size(); ++i){ 213 | if (i == selected) ofSetColor(0, 255, 0); 214 | else ofSetColor(255, 0, 0); 215 | ofDrawBitmapString(fileNames[i], 10, 500 +(20 * (i + 1))); 216 | } 217 | ofEnableLighting(); 218 | ofPopStyle(); 219 | } 220 | } 221 | 222 | //-------------------------------------------------------------- 223 | void ofApp::mouseReleased(int x, int y, int button){ 224 | 225 | } 226 | 227 | //-------------------------------------------------------------- 228 | void ofApp::mouseEntered(int x, int y){ 229 | 230 | } 231 | 232 | //-------------------------------------------------------------- 233 | void ofApp::mouseExited(int x, int y){ 234 | 235 | } 236 | 237 | //-------------------------------------------------------------- 238 | void ofApp::windowResized(int w, int h){ 239 | 240 | } 241 | 242 | //-------------------------------------------------------------- 243 | void ofApp::gotMessage(ofMessage msg){ 244 | 245 | } 246 | 247 | //-------------------------------------------------------------- 248 | void ofApp::dragEvent(ofDragInfo dragInfo){ 249 | 250 | } 251 | 252 | void ofApp::saveMeshPressed(){ 253 | string randomFilename = ofGetTimestampString() + ".ply"; 254 | lsystem.save(randomFilename); 255 | } 256 | -------------------------------------------------------------------------------- /example-gui/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxLSystem.h" 5 | #include "ofParameter.h" 6 | #include "ofxGui.h" 7 | 8 | class ofApp : public ofBaseApp{ 9 | 10 | public: 11 | void setup(); 12 | void update(); 13 | void draw(); 14 | 15 | void keyPressed(int key); 16 | void keyReleased(int key); 17 | void mouseMoved(int x, int y ); 18 | void mouseDragged(int x, int y, int button); 19 | void mousePressed(int x, int y, int button); 20 | void mouseReleased(int x, int y, int button); 21 | void mouseEntered(int x, int y); 22 | void mouseExited(int x, int y); 23 | void saveMeshPressed(); 24 | void windowResized(int w, int h); 25 | void dragEvent(ofDragInfo dragInfo); 26 | void gotMessage(ofMessage msg); 27 | void selectedThetaChanghed(float & selectedTheta); 28 | void selectedDepthChanghed(int & selectedDepth); 29 | void fileSaved(int & file); 30 | 31 | private: 32 | void loadSettings(string filename = "bush-1.xml"); 33 | void readFilesDirectory(); 34 | map getConstants(string _constants) const; 35 | vector getRules(string rules) const; 36 | void startLSystem( 37 | string axiom, 38 | string selectedRule, 39 | float theta, 40 | int depth, 41 | string constants, 42 | bool randomZRotation); 43 | void maybeDrawGui(); 44 | string trim(string str); 45 | bool drawGui = true; 46 | int selected; 47 | 48 | ofxPanel gui; 49 | ofParameter vSync; 50 | 51 | //LSystem parameters 52 | ofParameter selectedRule; 53 | ofParameter definedConstant; 54 | ofParameter axiom; 55 | ofParameter selectedDepth; 56 | ofParameter randomYRotation; 57 | unsigned int oldDepth = 1; 58 | ofParameter selectedTheta; 59 | ofParameter bgColor; 60 | ofParameter treeColor; 61 | ofParameter specularColor; 62 | ofxButton saveMesh; 63 | 64 | vector fileNames; 65 | ofDirectory dir; 66 | 67 | ofEasyCam cam; 68 | ofLight light; 69 | ofxLSystem lsystem; 70 | ofMaterial material; 71 | ofTrueTypeFont font; 72 | }; 73 | -------------------------------------------------------------------------------- /example-shader/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example-shader/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | //ICONS - NEW IN 0072 9 | ICON_NAME_DEBUG = icon-debug.icns 10 | ICON_NAME_RELEASE = icon.icns 11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ 12 | 13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: 14 | //ICON_FILE_PATH = bin/data/ 15 | 16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS) 17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 18 | -------------------------------------------------------------------------------- /example-shader/addons.make: -------------------------------------------------------------------------------- 1 | ofxGui 2 | ofxLSystem 3 | ofxLSystemGrammar 4 | -------------------------------------------------------------------------------- /example-shader/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-shader/bin/data/.gitkeep -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/2dmatrices.frag: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-shader/bin/data/shaders_gl3/2dmatrices.frag -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/2dmatrices.vert: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-shader/bin/data/shaders_gl3/2dmatrices.vert -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/basic.frag: -------------------------------------------------------------------------------- 1 | #version 150 2 | in vec3 vecNormal; 3 | in vec4 vecPosition; 4 | 5 | out vec4 fragColor; 6 | 7 | // this are set in the OF app 8 | uniform vec3 uLightPosition; 9 | uniform vec4 uMaterialColor; 10 | 11 | void main(){ 12 | // basic lambertian lighting 13 | vec3 lightDirection = normalize(vecPosition.xyz - uLightPosition); 14 | float dProd = max(0.0, dot(vecNormal, lightDirection)); 15 | 16 | //color 17 | vec4 color = uMaterialColor; 18 | vec4 col = vec4( vec3( dProd ) * vec3( color ), 1.0 ); 19 | fragColor = col; 20 | } -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/basic.vert: -------------------------------------------------------------------------------- 1 | #version 150 2 | out vec3 vecNormal; 3 | out vec4 vecPosition; 4 | 5 | in vec4 position; 6 | in vec4 normal; 7 | 8 | // these are passed in from OF programmable renderer 9 | uniform mat4 modelViewProjectionMatrix; 10 | 11 | void main(){ 12 | // Since the light is in world coordinates, i need the vertex position in world 13 | // coordinates too. 14 | vecPosition = modelViewProjectionMatrix * position; 15 | 16 | vecNormal = normal.xzy; 17 | gl_Position = vecPosition; 18 | } -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/colors.frag: -------------------------------------------------------------------------------- 1 | #version 150 2 | //Modes: uncomment to active one modes 3 | //#define SIMPLE_MIX 4 | //#define PLOT 5 | #define COLOR_DEPENDING_ON_MESH_HEIGHT 6 | 7 | 8 | in vec3 vecNormal; 9 | in vec4 vecPosition; 10 | in float height; 11 | 12 | out vec4 fragColor; 13 | 14 | // this are set in the OF app 15 | uniform vec3 uLightPosition; 16 | uniform vec4 uMaterialColor; 17 | uniform float uTime; 18 | uniform vec2 uResolution; 19 | 20 | // Only used when PLOT 21 | float plot (vec2 st, float pct){ 22 | return smoothstep( pct-0.01, pct, st.y) - 23 | smoothstep( pct, pct+0.01, st.y); 24 | } 25 | 26 | void main(){ 27 | // basic lambertian lighting 28 | vec3 lightDirection = normalize(vecPosition.xyz - uLightPosition); 29 | float dProd = max(0.0, dot(vecNormal, lightDirection)); 30 | 31 | //color 32 | // the default is the material color 33 | vec4 color = uMaterialColor; 34 | vec4 colorA = vec4(0.149,0.141,0.912,1.0); 35 | vec4 colorB = vec4(1.000,0.833,0.224,1.0); 36 | 37 | #ifdef SIMPLE_MIX 38 | float pct = abs(sin(uTime)); 39 | color = mix(colorA, colorB, pct); 40 | #endif 41 | 42 | #ifdef PLOT 43 | vec2 st = gl_FragCoord.xy/uResolution.xy; 44 | vec4 black = vec4(vec3(0.0),1.0); 45 | vec4 pct = vec4(st.x); 46 | color = mix(colorA, colorB, pct); 47 | color = mix(color,vec4(1.0,0.0,0.0,1.0),plot(st,pct.r)); 48 | color = mix(color,vec4(0.0,1.0,0.0,1.0),plot(st,pct.g)); 49 | color = mix(color,vec4(0.0,0.0,1.0,1.o),plot(st,pct.b)); 50 | #endif 51 | 52 | #ifdef COLOR_DEPENDING_ON_MESH_HEIGHT 53 | //just to see how the fragCoord can be used to change the color 54 | //color.r = gl_FragCoord.y / uResolution.y; 55 | color = mix(colorA, colorB, height); 56 | #endif 57 | 58 | vec4 col = vec4( vec3( dProd ) * vec3( color ), 1.0 ); 59 | fragColor = col; 60 | } -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/colors.vert: -------------------------------------------------------------------------------- 1 | #version 150 2 | // https://thebookofshaders.com/06/ 3 | 4 | out vec3 vecNormal; 5 | out vec4 vecPosition; 6 | out float height; 7 | 8 | in vec4 position; 9 | in vec4 normal; 10 | 11 | // these are passed in from OF programmable renderer 12 | uniform mat4 modelViewProjectionMatrix; 13 | 14 | //these are set in the app 15 | uniform vec2 uTreeResolution; 16 | 17 | void main(){ 18 | // Since the light is in world coordinates, i need the vertex position in world 19 | // coordinates too. 20 | vecPosition = modelViewProjectionMatrix * position; 21 | height = position.y / uTreeResolution.y; 22 | 23 | vecNormal = normal.xzy; 24 | gl_Position = vecPosition; 25 | } -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/generative.frag: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-shader/bin/data/shaders_gl3/generative.frag -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/generative.vert: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-shader/bin/data/shaders_gl3/generative.vert -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/noise.frag: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D src_tex_unit0; 4 | uniform vec4 globalColor; 5 | 6 | in vec2 texCoordVarying; 7 | 8 | out vec4 fragColor; 9 | 10 | void main(){ 11 | //this is the fragment shader 12 | //this is where the pixel level drawing happens 13 | //gl_FragCoord gives us the x and y of the current pixel its drawing 14 | 15 | //we grab the x and y and store them in an int 16 | float xVal = gl_FragCoord.x; 17 | float yVal = gl_FragCoord.y; 18 | 19 | //we use the mod function to only draw pixels if they are every 2 in x or every 4 in y 20 | if( mod(xVal, 2.0) == 0.5 && mod(yVal, 4.0) == 0.5 ){ 21 | fragColor = globalColor; 22 | }else{ 23 | discard; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/noise.vert: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec4 position; 4 | in vec2 texcoord; 5 | 6 | uniform mat4 modelViewProjectionMatrix; 7 | 8 | 9 | uniform float timeValX; 10 | uniform float timeValY; 11 | uniform vec2 mouse; 12 | 13 | //generate a random value from four points 14 | vec4 rand(vec2 A,vec2 B,vec2 C,vec2 D){ 15 | 16 | vec2 s=vec2(12.9898,78.233); 17 | vec4 tmp=vec4(dot(A,s),dot(B,s),dot(C,s),dot(D,s)); 18 | 19 | return fract(sin(tmp) * 43758.5453)* 2.0 - 1.0; 20 | } 21 | 22 | //this is similar to a perlin noise function 23 | float noise(vec2 coord,float d){ 24 | 25 | vec2 C[4]; 26 | 27 | float d1 = 1.0/d; 28 | 29 | C[0]=floor(coord*d)*d1; 30 | 31 | C[1]=C[0]+vec2(d1,0.0); 32 | 33 | C[2]=C[0]+vec2(d1,d1); 34 | 35 | C[3]=C[0]+vec2(0.0,d1); 36 | 37 | 38 | vec2 p=fract(coord*d); 39 | 40 | vec2 q=1.0-p; 41 | 42 | vec4 w=vec4(q.x*q.y,p.x*q.y,p.x*p.y,q.x*p.y); 43 | 44 | return dot(vec4(rand(C[0],C[1],C[2],C[3])),w); 45 | } 46 | 47 | 48 | void main(){ 49 | 50 | //get our current vertex position so we can modify it 51 | vec4 pos = modelViewProjectionMatrix * position; 52 | 53 | //generate some noise values based on vertex position and the time value which comes in from our OF app 54 | float noiseAmntX = noise( vec2(-timeValX + pos.x / 1000.0, 100.0), 20.0 ); 55 | float noiseAmntY = noise( vec2(timeValY + pos.y / 1000.0, pos.x / 2000.0), 20.0 ); 56 | 57 | //generate noise for our blue pixel value 58 | float noiseB = noise( vec2(timeValY * 0.25, pos.y / 2000.0), 20.0 ); 59 | 60 | //lets also figure out the distance between the mouse and the vertex and apply a repelling force away from the mouse 61 | vec2 d = vec2(pos.x, pos.y) - mouse; 62 | float len = sqrt(d.x*d.x + d.y*d.y); 63 | if( len < 300.0 && len > 0.0 ){ 64 | 65 | //lets get the distance into 0-1 ranges 66 | float pct = len / 300.0; 67 | 68 | //this turns our linear 0-1 value into a curved 0-1 value 69 | pct *= pct; 70 | 71 | //flip it so the closer we are the greater the repulsion 72 | pct = 1.0 - pct; 73 | 74 | //normalize our repulsion vector 75 | d /= len; 76 | 77 | //apply the repulsion to our position 78 | pos.x += d.x * pct * 90.0; 79 | pos.y += d.y * pct * 90.0; 80 | } 81 | 82 | //modify our position with the smooth noise 83 | pos.x += noiseAmntX * 20.0; 84 | pos.y += noiseAmntY * 10.0; 85 | 86 | //finally set the pos to be that actual position rendered 87 | gl_Position = pos; 88 | } 89 | -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/patterns.frag: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-shader/bin/data/shaders_gl3/patterns.frag -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/patterns.vert: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-shader/bin/data/shaders_gl3/patterns.vert -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/ring.frag: -------------------------------------------------------------------------------- 1 | #version 150 2 | #define RING_PROGRESSIVE 3 | //#define RING_MODULO 4 | //#define RING_SINE 5 | //#define RING_FRACT 6 | 7 | in vec3 vecNormal; 8 | in vec4 vecPosition; 9 | in vec2 st; 10 | 11 | out vec4 fragColor; 12 | 13 | // this are set in the OF app 14 | uniform vec3 uLightPosition; 15 | uniform vec4 uMaterialColor; 16 | uniform float uTime; 17 | uniform float uThickness; 18 | uniform float uScale; 19 | 20 | // http://www.iquilezles.org/www/articles/functions/functions.htm 21 | float cubicPulse( float c, float w, float x ){ 22 | x = abs(x - c); 23 | if( x>w ) return 0.0; 24 | x /= w; 25 | return 1.0 - x*x*(3.0-2.0*x); 26 | } 27 | 28 | float plot(vec2 st, float pct){ 29 | return smoothstep( pct-0.052, pct, st.y) - 30 | smoothstep( pct, pct+0.02, st.y); 31 | } 32 | 33 | float nRing = 6.0; 34 | 35 | void main(){ 36 | // basic lambertian lighting 37 | // not used in this shaders 38 | vec3 lightDirection = normalize(vecPosition.xyz - uLightPosition); 39 | float dProd = max(0.3, dot(vecNormal, lightDirection)); 40 | 41 | //color 42 | vec4 color = uMaterialColor; 43 | #ifdef RING_PROGRESSIVE 44 | for(int i = 1; i<= nRing; i++){ 45 | color += vec4(vec3( 46 | cubicPulse(abs(sin(uTime)),uThickness,st.y/i) 47 | ), 1.0); 48 | } 49 | #endif 50 | 51 | #ifdef RING_MODULO 52 | //programmatically 53 | // float inc = 1.0/nRing; 54 | // float padding = 0.0; 55 | // for(int i = 1; i<= nRing; i++){ 56 | // color += vec4(vec3( 57 | // cubicPulse(mod(uTime*uScale, 1.0),uThickness,(st.y+padding)) 58 | // ), 1.0); 59 | // padding+=inc; 60 | // } 61 | float y = cubicPulse(mod(uTime*uScale, 1.0),uThickness,st.y); 62 | float y1 = cubicPulse(mod(uTime*uScale, 1.0),uThickness,st.y+0.2); 63 | float y2 = cubicPulse(mod(uTime*uScale, 1.0),uThickness,st.y-0.2); 64 | float y3 = cubicPulse(mod(uTime*uScale, 1.0),uThickness,st.y+0.4); 65 | float y4 = cubicPulse(mod(uTime*uScale, 1.0),uThickness,st.y-0.4); 66 | float y5 = cubicPulse(mod(uTime*uScale, 1.0),uThickness,st.y+0.6); 67 | float y6 = cubicPulse(mod(uTime*uScale, 1.0),uThickness,st.y-0.6); 68 | float y7 = cubicPulse(mod(uTime*uScale, 1.0),uThickness,st.y+0.8); 69 | float y8 = cubicPulse(mod(uTime*uScale, 1.0),uThickness,st.y-0.8); 70 | color += vec4(vec3(y), 1.0); 71 | color += vec4(vec3(y1), 1.0); 72 | color += vec4(vec3(y2), 1.0); 73 | color += vec4(vec3(y3), 1.0); 74 | color += vec4(vec3(y4), 1.0); 75 | color += vec4(vec3(y5), 1.0); 76 | color += vec4(vec3(y6), 1.0); 77 | color += vec4(vec3(y7), 1.0); 78 | color += vec4(vec3(y8), 1.0); 79 | #endif 80 | 81 | #ifdef RING_SINE 82 | float y = cubicPulse(abs(sin(uTime*uScale)),uThickness,st.y); 83 | float y1 = cubicPulse(abs(sin(uTime*uScale)),uThickness,st.y+0.2); 84 | float y2 = cubicPulse(abs(sin(uTime*uScale)),uThickness,st.y+0.4); 85 | float y3 = cubicPulse(abs(sin(uTime*uScale)),uThickness,st.y+0.6); 86 | float y4 = cubicPulse(abs(sin(uTime*uScale)),uThickness,st.y+0.8); 87 | color += vec4(vec3(y), 1.0); 88 | color += vec4(vec3(y1), 1.0); 89 | color += vec4(vec3(y2), 1.0); 90 | color += vec4(vec3(y3), 1.0); 91 | color += vec4(vec3(y4), 1.0); 92 | #endif 93 | 94 | vec4 col = vec4( vec3( dProd ) * vec3( color ), 1.0 ); 95 | //vec4 col = vec4( vec3( color ), 1.0 ); 96 | fragColor = col; 97 | } -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/ring.vert: -------------------------------------------------------------------------------- 1 | #version 150 2 | //https://thebookofshaders.com/07/ 3 | 4 | out vec3 vecNormal; 5 | out vec4 vecPosition; 6 | out vec2 st; 7 | 8 | in vec4 position; 9 | in vec4 normal; 10 | 11 | // these are passed in from OF programmable renderer 12 | uniform mat4 modelViewProjectionMatrix; 13 | uniform vec2 uTreeResolution; 14 | uniform vec2 uMinTree; 15 | uniform vec2 uMaxTree; 16 | 17 | 18 | float map(float x, float in_min, float in_max, float out_min, float out_max){ 19 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 20 | } 21 | 22 | void main(){ 23 | // Since the light is in world coordinates, i need the vertex position in world 24 | // coordinates too. 25 | vecPosition = modelViewProjectionMatrix * position; 26 | float x = map(position.x,uMinTree.x, uMaxTree.x, 0, uTreeResolution.x); 27 | float y = map(position.y,uMinTree.y, uMaxTree.y, 0, uTreeResolution.y); 28 | // this variable st is like gl_FragCoord.xy/screenResolution, but it 29 | // consider each pixel relative to the dimension of the mesh instead that the 30 | // dimension of the screen. This calculation screw up as soon as we move the mesh, 31 | // because, we should recalculate the bounding box too. 32 | st = vec2(x/uTreeResolution.x, y/uTreeResolution.y); 33 | 34 | vecNormal = normal.xzy; 35 | gl_Position = vecPosition; 36 | } -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/shapes.frag: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | //#define BORDERS 4 | //#define CIRCLE_DISTANCE 5 | #define CIRCLE_SMALL 6 | 7 | in vec3 vecNormal; 8 | in vec4 vecPosition; 9 | in vec2 st; 10 | 11 | out vec4 fragColor; 12 | 13 | // this are set in the OF app 14 | uniform vec3 uLightPosition; 15 | uniform vec4 uMaterialColor; 16 | uniform vec2 uResolution; 17 | uniform float uTime; 18 | 19 | void main(){ 20 | // basic lambertian lighting 21 | vec3 lightDirection = normalize(vecPosition.xyz - uLightPosition); 22 | float dProd = max(0.3, dot(vecNormal, lightDirection)); 23 | 24 | //color 25 | vec4 color = uMaterialColor; 26 | #ifdef BORDERS 27 | //values under 1.0 returns 0.0, more than 0.1 returns 1 28 | vec2 bordersBottomLeft = step(vec2(0.1),st); 29 | // this is like and AND condition 1.0 * 1.0 returns 1.0 (black) 30 | // 0.0 * 0.0 return 0.0 (white) 31 | float pct = bordersBottomLeft.x * bordersBottomLeft.y; 32 | 33 | // top-right 34 | vec2 bordersTopRight = step(vec2(0.1),1.0-st); 35 | pct *= bordersTopRight.x * bordersTopRight.y; 36 | 37 | color = vec4(vec3(pct), 1.0); 38 | #endif 39 | 40 | #ifdef CIRCLE_DISTANCE 41 | //to draw a circle you need to compare each point with the center. 42 | // you can use the function distance, length or sqrt. 43 | // this time we use screen cordinates 44 | float pct = 0.0; 45 | vec2 stscreen = gl_FragCoord.xy/uResolution; 46 | //The closer a pixel is to the center, the lower (darker) value it has 47 | pct = distance(stscreen,vec2(0.5)); 48 | color = vec4(pct); 49 | #endif 50 | 51 | 52 | #ifdef CIRCLE_SMALL 53 | float pct = 0.0; 54 | vec2 stscreen = gl_FragCoord.xy/uResolution; 55 | pct = distance(stscreen,vec2(0.5, 0.7)); 56 | color = vec4(step(pct, abs(sin(uTime)*0.1))); 57 | #endif 58 | 59 | 60 | 61 | // The multiplication of left*bottom will be similar to the logical AND. 62 | //vec4 color = vec4( left * bottom ); 63 | vec4 col = vec4( vec3( dProd ) * vec3( color ), 1.0 ); 64 | fragColor = col; 65 | } -------------------------------------------------------------------------------- /example-shader/bin/data/shaders_gl3/shapes.vert: -------------------------------------------------------------------------------- 1 | #version 150 2 | //https://thebookofshaders.com/07/ 3 | 4 | out vec3 vecNormal; 5 | out vec4 vecPosition; 6 | out vec2 st; 7 | 8 | in vec4 position; 9 | in vec4 normal; 10 | 11 | // these are passed in from OF programmable renderer 12 | uniform mat4 modelViewProjectionMatrix; 13 | uniform vec2 uTreeResolution; 14 | uniform vec2 uMinTree; 15 | uniform vec2 uMaxTree; 16 | 17 | 18 | float map(float x, float in_min, float in_max, float out_min, float out_max){ 19 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 20 | } 21 | 22 | void main(){ 23 | // Since the light is in world coordinates, i need the vertex position in world 24 | // coordinates too. 25 | vecPosition = modelViewProjectionMatrix * position; 26 | float x = map(position.x,uMinTree.x, uMaxTree.x, 0, uTreeResolution.x); 27 | float y = map(position.y,uMinTree.y, uMaxTree.y, 0, uTreeResolution.y); 28 | // this variable st is like gl_FragCoord.xy/screenResolution, but it 29 | // consider each pixel relative to the dimension of the mesh instead that the 30 | // dimension of the screen. This calculation screw up as soon as we move the mesh, 31 | // because, we should recalculate the bounding box too. 32 | st = vec2(x/uTreeResolution.x, y/uTreeResolution.y); 33 | 34 | vecNormal = normal.xzy; 35 | gl_Position = vecPosition; 36 | } -------------------------------------------------------------------------------- /example-shader/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example-shader/example-shader.qbs: -------------------------------------------------------------------------------- 1 | import qbs 2 | import qbs.Process 3 | import qbs.File 4 | import qbs.FileInfo 5 | import qbs.TextFile 6 | import "../../../libs/openFrameworksCompiled/project/qtcreator/ofApp.qbs" as ofApp 7 | 8 | Project{ 9 | property string of_root: '../../..' 10 | 11 | ofApp { 12 | name: { return FileInfo.baseName(sourceDirectory) } 13 | 14 | files: [ 15 | 'src/main.cpp', 16 | 'src/ofApp.cpp', 17 | 'src/ofApp.h', 18 | ] 19 | 20 | // This project is using addons.make to include the addons 21 | // since it was imported from old code. To change it to include 22 | // the addons from the qbs file change the following lines to 23 | // the list of used addons in array format. eg: 24 | // 25 | of.addons: ['ofxLSystem','ofxLSystemGrammar','ofxGui'] 26 | 27 | // additional flags for the project. the of module sets some 28 | // flags by default to add the core libraries, search paths... 29 | // this flags can be augmented through the following properties: 30 | of.pkgConfigs: [] // list of additional system pkgs to include 31 | of.includePaths: [] // include search paths 32 | of.cFlags: [] // flags passed to the c compiler 33 | of.cxxFlags: [] // flags passed to the c++ compiler 34 | of.linkerFlags: [] // flags passed to the linker 35 | of.defines: [] // defines are passed as -D to the compiler 36 | // and can be checked with #ifdef or #if in the code 37 | of.frameworks: [] // osx only, additional frameworks to link with the project 38 | of.staticLibraries: [] // static libraries 39 | of.dynamicLibraries: [] // dynamic libraries 40 | 41 | // other flags can be set through the cpp module: http://doc.qt.io/qbs/cpp-module.html 42 | // eg: this will enable ccache when compiling 43 | // 44 | // cpp.compilerWrapper: 'ccache' 45 | 46 | Depends{ 47 | name: "cpp" 48 | } 49 | 50 | // common rules that parse the include search paths, core libraries... 51 | Depends{ 52 | name: "of" 53 | } 54 | 55 | // dependency with the OF library 56 | Depends{ 57 | name: "openFrameworks" 58 | } 59 | } 60 | 61 | property bool makeOF: true // use makfiles to compile the OF library 62 | // will compile OF only once for all your projects 63 | // otherwise compiled per project with qbs 64 | 65 | references: [FileInfo.joinPaths(of_root, "/libs/openFrameworksCompiled/project/qtcreator/openFrameworks.qbs")] 66 | } 67 | -------------------------------------------------------------------------------- /example-shader/example-shader.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example-shader/example-shader.xcodeproj/project.xcworkspace/xcshareddata/example-shader.xcscmblueprint: -------------------------------------------------------------------------------- 1 | { 2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2", 3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { 4 | 5 | }, 6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { 7 | "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" : 0, 8 | "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" : 0 9 | }, 10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "0130AEEF-9FCA-4178-B8F8-8CA48F91DD4A", 11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { 12 | "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" : "ofxLSystem\/", 13 | "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" : "ofxLSystemGrammar\/" 14 | }, 15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "example-shader", 16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204, 17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "example-shader\/example-shader.xcodeproj", 18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ 19 | { 20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:edap\/ofxLSystem.git", 21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" 23 | }, 24 | { 25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:edap\/ofxLSystemGrammar.git", 26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /example-shader/example-shader.xcodeproj/project.xcworkspace/xcuserdata/da1.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-shader/example-shader.xcodeproj/project.xcworkspace/xcuserdata/da1.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /example-shader/example-shader.xcodeproj/xcshareddata/xcschemes/shadersTree Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example-shader/example-shader.xcodeproj/xcshareddata/xcschemes/shadersTree Release.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example-shader/example-shader.xcodeproj/xcuserdata/da1.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /example-shader/example-shader.xcodeproj/xcuserdata/da1.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SuppressBuildableAutocreation 6 | 7 | E4B69B5A0A3A1756003C02F2 8 | 9 | primary 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-shader/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | cc.openFrameworks.ofapp 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | CFBundleIconFile 20 | ${ICON} 21 | 22 | 23 | -------------------------------------------------------------------------------- /example-shader/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | 5 | //======================================================================== 6 | int main( ){ 7 | ofGLFWWindowSettings settings; 8 | settings.setGLVersion(3, 2); 9 | ofCreateWindow(settings); 10 | ofRunApp(new ofApp()); 11 | } 12 | -------------------------------------------------------------------------------- /example-shader/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | ofDisableAlphaBlending(); 6 | ofEnableDepthTest(); 7 | 8 | light.setup(); 9 | light.enable(); 10 | light.setPosition(ofVec3f(400,300,200)); 11 | light.lookAt(ofVec3f(0,0,0)); 12 | 13 | map constants; 14 | constants.insert(make_pair("R", 1.356)); 15 | 16 | // tree on which it will be applied a texture 17 | tree.setAxiom("A(100)"); 18 | tree.setRules({"A(s) -> F(s)[+A(s/R)][-A(s/R)]"}); 19 | tree.setRandomYRotation(true); 20 | tree.setConstants(constants); 21 | tree.setStep(9); 22 | tree.setScaleWidth(true); 23 | tree.setStepWidth(40.5); 24 | tree.setStepLength(250); 25 | tree.build(); 26 | tree.boom(-200); 27 | uResolution = ofVec2f(ofGetWidth(), ofGetHeight()); 28 | 29 | if(ofIsGLProgrammableRenderer()){ 30 | //I'm using opengl 4.1 that support the programmable pipeline 31 | //shader.load("shaders_gl3/noise.vert", "shaders_gl3/noise.frag"); 32 | shader.load("shaders_gl3/ring.vert", "shaders_gl3/ring.frag"); 33 | } 34 | 35 | gui.setup(); 36 | gui.add(scale.set("scale", 1.0, 0.06, 2.0)); 37 | gui.add(thickness.set("thickness", 0.06, 0.01, 0.2)); 38 | gui.add(lightPos.set("lightPosition", 39 | ofVec3f(400,300,200), ofVec3f(-800,-800,-800), ofVec3f(800,800,800))); 40 | gui.add(materialColor.setup("material color", 41 | ofColor(0, 255, 0), ofColor(0, 0), ofColor(255, 255))); 42 | ofSetVerticalSync(true); 43 | tree.computeBoundingBox(); 44 | cout << abs(tree.getBoundingBox().min.x) << endl; 45 | cout << abs(tree.getBoundingBox().max.x) << endl; 46 | uMinTree = tree.getBoundingBox().min; 47 | uMaxTree = tree.getBoundingBox().max; 48 | 49 | float treeWidth = abs(uMinTree.x) + uMaxTree.x; 50 | float treeHeight = abs(uMinTree.y) + uMaxTree.y; 51 | uTreeResolution = ofVec2f(treeWidth, treeHeight); 52 | 53 | for(auto v:tree.getMesh().getVertices()){ 54 | //cout << v.x<< endl; 55 | 56 | } 57 | } 58 | 59 | //-------------------------------------------------------------- 60 | void ofApp::update(){ 61 | 62 | } 63 | 64 | //-------------------------------------------------------------- 65 | void ofApp::draw(){ 66 | ofBackground(0, 0, 0); 67 | cam.begin(); 68 | 69 | shader.begin(); 70 | shader.setUniform1f("uTime", ofGetElapsedTimef()); 71 | shader.setUniform1f("uThickness", thickness); 72 | shader.setUniform1f("uScale", scale); 73 | shader.setUniform2f("mouse", mouseX - ofGetWidth()/2, ofGetHeight()/2-mouseY ); 74 | shader.setUniform3f("uLightPosition", lightPos.get()); 75 | shader.setUniform4f("uMaterialColor", ofColor(materialColor)); 76 | shader.setUniform2f("uResolution", uResolution ); 77 | shader.setUniform2f("uTreeResolution", uTreeResolution ); 78 | shader.setUniform2f("uMinTree", uMinTree); 79 | shader.setUniform2f("uMaxTree", uMaxTree); 80 | 81 | tree.draw(); 82 | 83 | shader.end(); 84 | cam.end(); 85 | 86 | maybeDrawGui(); 87 | } 88 | 89 | void ofApp::maybeDrawGui(){ 90 | if(drawGui){ 91 | ofDisableDepthTest(); 92 | gui.draw(); 93 | ofEnableDepthTest(); 94 | } 95 | } 96 | 97 | //-------------------------------------------------------------- 98 | void ofApp::keyPressed(int key){ 99 | if(key == 'g'){ 100 | drawGui = !drawGui; 101 | } 102 | } 103 | 104 | //-------------------------------------------------------------- 105 | void ofApp::keyReleased(int key){ 106 | 107 | } 108 | 109 | //-------------------------------------------------------------- 110 | void ofApp::mouseMoved(int x, int y ){ 111 | 112 | } 113 | 114 | //-------------------------------------------------------------- 115 | void ofApp::mouseDragged(int x, int y, int button){ 116 | 117 | } 118 | 119 | //-------------------------------------------------------------- 120 | void ofApp::mousePressed(int x, int y, int button){ 121 | 122 | } 123 | 124 | //-------------------------------------------------------------- 125 | void ofApp::mouseReleased(int x, int y, int button){ 126 | 127 | } 128 | 129 | //-------------------------------------------------------------- 130 | void ofApp::mouseEntered(int x, int y){ 131 | 132 | } 133 | 134 | //-------------------------------------------------------------- 135 | void ofApp::mouseExited(int x, int y){ 136 | 137 | } 138 | 139 | //-------------------------------------------------------------- 140 | void ofApp::windowResized(int w, int h){ 141 | 142 | } 143 | 144 | //-------------------------------------------------------------- 145 | void ofApp::gotMessage(ofMessage msg){ 146 | 147 | } 148 | 149 | //-------------------------------------------------------------- 150 | void ofApp::dragEvent(ofDragInfo dragInfo){ 151 | 152 | } 153 | -------------------------------------------------------------------------------- /example-shader/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "ofxLSystem.h" 4 | #include "ofxGui.h" 5 | 6 | class ofApp : public ofBaseApp{ 7 | 8 | public: 9 | void setup(); 10 | void update(); 11 | void draw(); 12 | 13 | void keyPressed(int key); 14 | void keyReleased(int key); 15 | void mouseMoved(int x, int y ); 16 | void mouseDragged(int x, int y, int button); 17 | void mousePressed(int x, int y, int button); 18 | void mouseReleased(int x, int y, int button); 19 | void mouseEntered(int x, int y); 20 | void mouseExited(int x, int y); 21 | void windowResized(int w, int h); 22 | void dragEvent(ofDragInfo dragInfo); 23 | void gotMessage(ofMessage msg); 24 | void maybeDrawGui(); 25 | 26 | ofxLSystem tree; 27 | ofxPanel gui; 28 | ofParameter lightPos; 29 | ofxColorSlider materialColor; 30 | ofParameter scale; 31 | ofParameter thickness; 32 | bool drawGui = true; 33 | ofLight light; 34 | ofEasyCam cam; 35 | ofShader shader; 36 | ofVec2f uResolution; 37 | ofVec2f uTreeResolution; 38 | 39 | ofVec2f uMinTree; 40 | ofVec2f uMaxTree; 41 | float maxHeight; 42 | 43 | 44 | }; 45 | -------------------------------------------------------------------------------- /example-texture/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example-texture/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | //ICONS - NEW IN 0072 9 | ICON_NAME_DEBUG = icon-debug.icns 10 | ICON_NAME_RELEASE = icon.icns 11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ 12 | 13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: 14 | //ICON_FILE_PATH = bin/data/ 15 | 16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS) 17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 18 | -------------------------------------------------------------------------------- /example-texture/addons.make: -------------------------------------------------------------------------------- 1 | ofxLSystem 2 | ofxLSystemGrammar 3 | -------------------------------------------------------------------------------- /example-texture/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-texture/bin/data/.gitkeep -------------------------------------------------------------------------------- /example-texture/bin/data/bark.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-texture/bin/data/bark.jpg -------------------------------------------------------------------------------- /example-texture/bin/data/texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-texture/bin/data/texture.png -------------------------------------------------------------------------------- /example-texture/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example-texture/example-texture.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example-texture/example-texture.xcodeproj/project.xcworkspace/xcshareddata/example-texture.xcscmblueprint: -------------------------------------------------------------------------------- 1 | { 2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2", 3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { 4 | 5 | }, 6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { 7 | "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" : 0, 8 | "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" : 0 9 | }, 10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "72084782-B89A-4AEF-ACBC-5A1A49A24C07", 11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { 12 | "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" : "ofxLSystem\/", 13 | "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" : "ofxLSystemGrammar\/" 14 | }, 15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "example-texture", 16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204, 17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "example-texture\/example-texture.xcodeproj", 18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ 19 | { 20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:edap\/ofxLSystem.git", 21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3998ED1A39B3A3908ED7716C4F9FB3DEAA7F29C2" 23 | }, 24 | { 25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:edap\/ofxLSystemGrammar.git", 26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "727ED838D711BA8796C3B24BEA5DBFF3FD89F4A5" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /example-texture/example-texture.xcodeproj/project.xcworkspace/xcuserdata/da1.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/example-texture/example-texture.xcodeproj/project.xcworkspace/xcuserdata/da1.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /example-texture/example-texture.xcodeproj/xcshareddata/xcschemes/example-texture Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /example-texture/example-texture.xcodeproj/xcshareddata/xcschemes/example-texture Release.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /example-texture/example-texture.xcodeproj/xcuserdata/da1.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SuppressBuildableAutocreation 6 | 7 | E4B69B5A0A3A1756003C02F2 8 | 9 | primary 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example-texture/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | cc.openFrameworks.ofapp 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | CFBundleIconFile 20 | ${ICON} 21 | 22 | 23 | -------------------------------------------------------------------------------- /example-texture/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /example-texture/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | ofDisableAlphaBlending(); 6 | ofEnableDepthTest(); 7 | light.enable(); 8 | light.setPosition(ofVec3f(400,300,200)); 9 | light.lookAt(ofVec3f(0,0,0)); 10 | //important, ofDisableArbText has to be called before the image is loaded 11 | ofDisableArbTex(); 12 | string textureName = "texture.png"; 13 | //string textureName = "bark.jpg"; 14 | 15 | // first texture 16 | ofLoadImage(bark, textureName); 17 | 18 | // second texture 19 | ofLoadImage(bark2, textureName); 20 | bark2.setTextureWrap(GL_REPEAT, GL_REPEAT); 21 | bark2.setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); 22 | 23 | // third texture 24 | ofLoadImage(bark3,textureName); 25 | bark3.setTextureWrap(GL_REPEAT, GL_REPEAT); 26 | bark3.generateMipmap(); // it creates a mipmap out of that image 27 | bark3.setTextureMinMagFilter(GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST); //activate mipmap filtering once texture has been loaded 28 | 29 | map constants; 30 | constants.insert(make_pair("R", 1.456)); 31 | 32 | // tree on which it will be applied a texture 33 | tree.setAxiom("A(100)"); 34 | tree.setRules({"A(s) -> F(s)[+A(s/R)][-A(s/R)]"}); 35 | tree.setRandomYRotation(true); 36 | tree.setConstants(constants); 37 | tree.setStep(8); 38 | tree.setScaleWidth(true); 39 | tree.setStepWidth(21.5); 40 | tree.setStepLength(100); 41 | tree.build(); 42 | tree.truck(-300); 43 | 44 | // tree on which a texture will be repeated N times 45 | tree2.setAxiom("A(100)"); 46 | tree2.setRules({"A(s) -> F(s)[+A(s/R)][-A(s/R)]"}); 47 | tree2.setRandomYRotation(true); 48 | tree2.setConstants(constants); 49 | // here is is defined how many times is the texture repeated 50 | tree2.setTextureRepeat(6); 51 | tree2.setStep(8); 52 | tree2.setScaleWidth(true); 53 | tree2.setStepWidth(21.5); 54 | tree2.setStepLength(100); 55 | tree2.build(); 56 | 57 | // tree on which a texture will be repeated N times using a mipmap 58 | // note how the border of the black circles are antialiased 59 | // try to change GL_LINEAR_MIPMAP_LINEAR to GL_NEAREST 60 | // and see how it changes 61 | tree3.setAxiom("A(100)"); 62 | tree3.setRules({"A(s) -> F(s)[+A(s/R)][-A(s/R)]"}); 63 | tree3.setRandomYRotation(true); 64 | tree3.setConstants(constants); 65 | tree3.setStep(8); 66 | tree3.setTextureRepeat(6); 67 | tree3.setScaleWidth(true); 68 | tree3.setStepWidth(21.5); 69 | tree3.setStepLength(100); 70 | tree3.build(); 71 | tree3.truck(300); 72 | } 73 | 74 | //-------------------------------------------------------------- 75 | void ofApp::update(){ 76 | 77 | } 78 | 79 | //-------------------------------------------------------------- 80 | void ofApp::draw(){ 81 | cam.begin(); 82 | 83 | bark.bind(); 84 | tree.draw(); 85 | bark.unbind(); 86 | 87 | bark2.bind(); 88 | tree2.draw(); 89 | bark2.unbind(); 90 | 91 | bark3.bind(); 92 | tree3.draw(); 93 | bark3.unbind(); 94 | 95 | cam.end(); 96 | } 97 | 98 | //-------------------------------------------------------------- 99 | void ofApp::keyPressed(int key){ 100 | 101 | } 102 | 103 | //-------------------------------------------------------------- 104 | void ofApp::keyReleased(int key){ 105 | 106 | } 107 | 108 | //-------------------------------------------------------------- 109 | void ofApp::mouseMoved(int x, int y ){ 110 | 111 | } 112 | 113 | //-------------------------------------------------------------- 114 | void ofApp::mouseDragged(int x, int y, int button){ 115 | 116 | } 117 | 118 | //-------------------------------------------------------------- 119 | void ofApp::mousePressed(int x, int y, int button){ 120 | 121 | } 122 | 123 | //-------------------------------------------------------------- 124 | void ofApp::mouseReleased(int x, int y, int button){ 125 | 126 | } 127 | 128 | //-------------------------------------------------------------- 129 | void ofApp::mouseEntered(int x, int y){ 130 | 131 | } 132 | 133 | //-------------------------------------------------------------- 134 | void ofApp::mouseExited(int x, int y){ 135 | 136 | } 137 | 138 | //-------------------------------------------------------------- 139 | void ofApp::windowResized(int w, int h){ 140 | 141 | } 142 | 143 | //-------------------------------------------------------------- 144 | void ofApp::gotMessage(ofMessage msg){ 145 | 146 | } 147 | 148 | //-------------------------------------------------------------- 149 | void ofApp::dragEvent(ofDragInfo dragInfo){ 150 | 151 | } 152 | -------------------------------------------------------------------------------- /example-texture/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "ofxLSystem.h" 4 | 5 | class ofApp : public ofBaseApp{ 6 | 7 | public: 8 | void setup(); 9 | void update(); 10 | void draw(); 11 | 12 | void keyPressed(int key); 13 | void keyReleased(int key); 14 | void mouseMoved(int x, int y ); 15 | void mouseDragged(int x, int y, int button); 16 | void mousePressed(int x, int y, int button); 17 | void mouseReleased(int x, int y, int button); 18 | void mouseEntered(int x, int y); 19 | void mouseExited(int x, int y); 20 | void windowResized(int w, int h); 21 | void dragEvent(ofDragInfo dragInfo); 22 | void gotMessage(ofMessage msg); 23 | 24 | ofxLSystem tree; 25 | ofxLSystem tree2; 26 | ofxLSystem tree3; 27 | ofLight light; 28 | ofTexture bark; 29 | ofTexture bark2; 30 | ofTexture bark3; 31 | ofEasyCam cam; 32 | 33 | 34 | }; -------------------------------------------------------------------------------- /img/azul.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/img/azul.png -------------------------------------------------------------------------------- /img/forest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/img/forest.png -------------------------------------------------------------------------------- /img/green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/img/green.png -------------------------------------------------------------------------------- /img/rings.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/img/rings.gif -------------------------------------------------------------------------------- /img/scaleWidth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/img/scaleWidth.png -------------------------------------------------------------------------------- /img/violet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/img/violet.png -------------------------------------------------------------------------------- /ofxaddons_thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edap/ofxLSystem/13e9f466ab435321dda0ca7591b43b611b0e64a1/ofxaddons_thumbnail.png -------------------------------------------------------------------------------- /src/ofxLSBoundingBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | 4 | typedef struct{ 5 | ofVec3f min = ofVec3f(0,0,0); 6 | ofVec3f max = ofVec3f(0,0,0); 7 | }BoundingBox; 8 | -------------------------------------------------------------------------------- /src/ofxLSBranch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | 4 | class ofxLSBranch { 5 | public: 6 | ofxLSBranch(const ofNode _begin, const ofNode _end, pair _capSizes){ 7 | //Imagine a cylinder 8 | begin = _begin; // it is where the cylinder starts 9 | end = _end; // it is where the cylinder ends 10 | capSizes = _capSizes; // the length of the ray of the 2 caps of the cylinder 11 | // the first one defines the bottom cap, the second one defines top cap 12 | }; 13 | ofNode begin; 14 | ofNode end; 15 | pair capSizes; 16 | }; 17 | -------------------------------------------------------------------------------- /src/ofxLSGeometry.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxLSGeometry.h" 2 | 3 | void ofxLSGeometry::putIntoMesh(const ofxLSBranch branch, ofVboMesh& mesh,ofxLSGeometryAvailable _geometryType, int resolution, float length, int textureRepeat){ 4 | //Branch deve contenere solo 2 ofNode, uno per l'inizio del segmento e 5 | // uno per la fine. Tutto il resto viene implementato dalla geometria 6 | switch (_geometryType) { 7 | case TUBES: 8 | tube.setTextureRepeat(textureRepeat); 9 | tube.setResolution(resolution); 10 | tube.generate(mesh, branch, length); 11 | break; 12 | // case TUBES_DEFORMED: 13 | // tubeDeformed.generate(mesh, branch, width); 14 | // break; 15 | case LINES: 16 | line.generate(mesh, branch); 17 | break; 18 | case TRIANGLES: 19 | triangle.setResolution(resolution); 20 | triangle.generate(mesh, branch, length); 21 | break; 22 | default: 23 | line.generate(mesh, branch); 24 | break; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/ofxLSGeometry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "ofxLSBranch.h" 4 | #include "ofxLSTube.h" 5 | #include "ofxLSTubeDeformed.h" 6 | #include "ofxLSLine.h" 7 | #include "ofxLSTriangle.h" 8 | #include "ofxLSGeometryAvailable.h" 9 | 10 | class ofxLSGeometry{ 11 | public: 12 | void putIntoMesh(const ofxLSBranch branch, ofVboMesh& mesh, ofxLSGeometryAvailable _geometryType, int resolution, float length, int textureRepeat); 13 | 14 | private: 15 | //avoid to save values in instance vars in these classes, they should simply 16 | // add stuff into the mesh 17 | ofxLSGeometryAvailable geometry; 18 | ofxLSTube tube; 19 | ofxLSTubeDeformed tubeDeformed; 20 | ofxLSLine line; 21 | ofxLSTriangle triangle; 22 | }; 23 | -------------------------------------------------------------------------------- /src/ofxLSGeometryAvailable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum ofxLSGeometryAvailable{ 4 | TUBES = 0, 5 | TUBES_DEFORMED, 6 | LINES, 7 | TRIANGLES 8 | }; 9 | -------------------------------------------------------------------------------- /src/ofxLSInputError.h: -------------------------------------------------------------------------------- 1 | class ofxLSInputError : public exception{ 2 | public: 3 | ofxLSInputError(string m="exception!") : msg(m) {} 4 | ofxLSInputError() throw() {} 5 | const char* what() const throw() { return msg.c_str(); } 6 | 7 | private: 8 | string msg; 9 | }; 10 | -------------------------------------------------------------------------------- /src/ofxLSInstruction.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxLSInstruction.h" 2 | 3 | ofxLSInstruction::ofxLSInstruction(string _text){ 4 | //order is important, setHead needs to be called before setValue 5 | setHead(_text); // ex: 'A', '[' 6 | setValues(_text);// ex: 0.9 7 | }; 8 | 9 | 10 | string ofxLSInstruction::getHead() const { 11 | return head; 12 | } 13 | 14 | float ofxLSInstruction::getAngle(float defaultValue) const { 15 | if (angleIsProvided) { 16 | return angle; 17 | }else{ 18 | return defaultValue; 19 | } 20 | } 21 | 22 | float ofxLSInstruction::getLength(float defaultValue) const { 23 | if (lengthIsProvided) { 24 | return length; 25 | }else{ 26 | return defaultValue; 27 | } 28 | } 29 | 30 | void ofxLSInstruction::setValues(string text){ 31 | auto numberInRoundBrackets = ofxLSUtils::grepStringInRegex(text, "(\\([0-9\\.,]+\\)*)"); 32 | if (numberInRoundBrackets.length()>2) { 33 | // TODO, acctually we handle only single number, like (0.9). not multiple numbers like 34 | // (0.2, 1.4). In this last case, we take only 0.2 35 | auto stringValue = ofxLSUtils::grepStringInRegex(text, "([0-9\\.]+)"); 36 | if(head == "\\" || head == "/" || head == "&" || head == "^" || head == "+" || head == "-" || head == "|" ){ 37 | angleIsProvided = true; 38 | angle = ofToFloat(stringValue); 39 | }else{ 40 | lengthIsProvided = true; 41 | length = ofToFloat(stringValue); 42 | } 43 | }else{ 44 | lengthIsProvided = false; 45 | angleIsProvided = false; 46 | } 47 | } 48 | 49 | void ofxLSInstruction::setHead(string _text){ 50 | head = ofxLSUtils::validTurtleInstruction(_text); 51 | } 52 | -------------------------------------------------------------------------------- /src/ofxLSInstruction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "ofxLSUtils.h" 4 | 5 | class ofxLSInstruction{ 6 | public: 7 | ofxLSInstruction(string str); 8 | string getHead() const; 9 | float getAngle(float defaultValue) const; 10 | float getLength(float defaultValue) const; 11 | private: 12 | string text; 13 | string head; 14 | bool angleIsProvided = false; 15 | bool lengthIsProvided = false; 16 | float angle = 0.0; 17 | float length = 0.0; 18 | void setValues(string text); 19 | void setHead(string text); 20 | }; 21 | -------------------------------------------------------------------------------- /src/ofxLSLine.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxLSLine.h" 2 | 3 | ofxLSLine::ofxLSLine(){ 4 | 5 | } 6 | 7 | void ofxLSLine::generate(ofMesh& mesh, ofxLSBranch branch){ 8 | auto start = branch.begin.getGlobalPosition(); 9 | auto end = branch.end.getGlobalPosition(); 10 | auto numberCurrentVertices = mesh.getNumVertices(); 11 | 12 | // int index = numberCurrentVertices/2; 13 | // mesh.addIndex(index); 14 | // mesh.addIndex(index+1); 15 | 16 | mesh.addVertex(start); 17 | mesh.addVertex(end); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/ofxLSLine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "ofxLSBranch.h" 4 | 5 | class ofxLSLine { 6 | public: 7 | ofxLSLine(); 8 | void generate(ofMesh& mesh, ofxLSBranch branch); 9 | 10 | }; 11 | -------------------------------------------------------------------------------- /src/ofxLSOption.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | 4 | class ofxLSOption { 5 | public: 6 | ofxLSOption(); 7 | }; 8 | -------------------------------------------------------------------------------- /src/ofxLSTriangle.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxLSTriangle.h" 2 | 3 | ofxLSTriangle::ofxLSTriangle(){ 4 | 5 | } 6 | 7 | void ofxLSTriangle::generate(ofMesh& mesh, const ofxLSBranch branch, const float length){ 8 | //if you set offsetBetweenBranches to 0, all the triangles composing 9 | // the branch will start exactly where the previous one finish, 10 | // to make them look a bit more intricates, I've overlapped them a bit 11 | const int offsetBetweenBranches = 10; 12 | const int radius = branch.capSizes.first; 13 | const int scaledRadius = branch.capSizes.second; 14 | const float stepLenght = length; 15 | ofMatrix4x4 beginMatrix = branch.begin.getGlobalTransformMatrix(); 16 | ofMatrix4x4 endMatrix = branch.end.getGlobalTransformMatrix(); 17 | 18 | vector topValues; 19 | vector bottomValues; 20 | 21 | // create top and bottom points 22 | for (int i = 0; i < resolution; i++){ 23 | float theta = 2.0f * 3.1415926f * float(i) / float(resolution); 24 | float x = radius * cosf(theta); 25 | float z = radius * sinf(theta); 26 | float y = 0; 27 | ofVec3f circleBottom = ofVec3f(x, y-offsetBetweenBranches, z); 28 | bottomValues.push_back(circleBottom); 29 | 30 | float topX = scaledRadius * cosf(theta); 31 | float topZ = scaledRadius * sinf(theta); 32 | float topY = 0; 33 | ofVec3f circleTop = ofVec3f(topX, topY+offsetBetweenBranches, topZ); 34 | topValues.push_back(circleTop); 35 | } 36 | 37 | //random shuffle them 38 | random_shuffle(topValues.begin(), topValues.end()); 39 | random_shuffle(bottomValues.begin(), bottomValues.end()); 40 | 41 | int n_triangles = resolution; 42 | int firstIndex = mesh.getNumVertices(); 43 | float middleLength = stepLenght /2; 44 | 45 | for (unsigned int i = 0; i< (n_triangles*3); i += 3) { 46 | ofVec3f firstV = topValues.at(i/3); 47 | ofVec3f thirdV = bottomValues.at(i/3); 48 | ofVec3f secondV = bottomValues.at(i/3); 49 | //secondV.z = ofRandom(-scaledRadius, radius); 50 | secondV.y = ofRandom(middleLength -radius*2, middleLength + radius*2); 51 | 52 | mesh.addIndex(firstIndex +i); 53 | mesh.addIndex(firstIndex +i+1); 54 | mesh.addIndex(firstIndex +i+2); 55 | 56 | //find position AND direction of 2 vertices of the triangle; 57 | ofVec3f e1 = firstV - secondV; 58 | ofVec3f e2 = thirdV - secondV; 59 | //Use these 2 vertices to find the normal 60 | ofVec3f no = e2.cross( e1 ).normalize(); 61 | 62 | mesh.addVertex(firstV * endMatrix); 63 | mesh.addNormal(no); 64 | mesh.addVertex(secondV * (beginMatrix)); 65 | mesh.addNormal(no); 66 | mesh.addVertex(thirdV * beginMatrix); 67 | mesh.addNormal(no); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/ofxLSTriangle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "ofxLSBranch.h" 4 | 5 | class ofxLSTriangle { 6 | public: 7 | ofxLSTriangle(); 8 | void generate(ofMesh& mesh, const ofxLSBranch branch, const float length); 9 | void setResolution(int _resolution){resolution = _resolution;}; 10 | private: 11 | int resolution = 7; 12 | }; 13 | -------------------------------------------------------------------------------- /src/ofxLSTube.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxLSTube.h" 2 | 3 | ofxLSTube::ofxLSTube(){ 4 | 5 | } 6 | 7 | void ofxLSTube::setResolution(const int _res){ 8 | if(_res < 3){ 9 | resolution = 3; 10 | } else { 11 | resolution = _res; 12 | } 13 | } 14 | 15 | void ofxLSTube::generate(ofMesh& mesh, const ofxLSBranch branch, const float length){ 16 | bool cap = true; 17 | const int radius = branch.capSizes.first; 18 | const int scaledRadius = branch.capSizes.second; 19 | 20 | // these variables are used to do not stretch the texture 21 | float circumferenceBottom = radius * 3.1415926f; 22 | float ratio = circumferenceBottom/length; 23 | float ratioCap = scaledRadius/length; 24 | float xWrapLimit = circumferenceBottom/(length/textureRepeat); 25 | float wrapLimitCap = ratioCap * textureRepeat; 26 | 27 | ofMatrix4x4 beginMatrix = branch.begin.getGlobalTransformMatrix(); 28 | ofMatrix4x4 endMatrix = branch.end.getGlobalTransformMatrix(); 29 | 30 | // Cylinder body 31 | int first = mesh.getNumVertices(); 32 | for (int i = 0; i <= resolution; i++) { 33 | // if it is the last face, close it where the first face 34 | // was started 35 | if (i == resolution) { 36 | mesh.addIndex(first+(i*2)); 37 | mesh.addIndex(first); 38 | mesh.addIndex(first+1); 39 | 40 | mesh.addIndex(first+1); 41 | mesh.addIndex(first+(i*2)+1); 42 | mesh.addIndex(first+(i*2)); 43 | } else { 44 | mesh.addIndex(first+(i*2)); 45 | mesh.addIndex(first+(i*2)+2); 46 | mesh.addIndex(first+(i*2)+3); 47 | 48 | mesh.addIndex(first+(i*2)+3); 49 | mesh.addIndex(first+(i*2)+1); 50 | mesh.addIndex(first+(i*2)); 51 | } 52 | } 53 | 54 | for (int i = 0; i <= resolution; i++) { 55 | //calculate x and y component 56 | float theta = 2.0f * 3.1415926f * float(i) / float(resolution); 57 | float x = radius * cosf(theta); 58 | float z = radius * sinf(theta); 59 | ofVec3f circleBottom = ofVec3f(x, 0.0, z); 60 | ofVec3f direction = (ofVec3f() + circleBottom).getNormalized(); 61 | 62 | float xTop = scaledRadius * cosf(theta); 63 | float zTop = scaledRadius * sinf(theta); 64 | ofVec3f circleTop = ofVec3f(xTop, 0.0, zTop); 65 | ofVec2f tcoord; 66 | tcoord.x = ofMap(i, 0.f, resolution, 0.f, xWrapLimit); 67 | 68 | // bottom 69 | tcoord.y = 0; 70 | mesh.addVertex(circleBottom * beginMatrix); 71 | mesh.addNormal(direction * beginMatrix.getRotate()); 72 | mesh.addTexCoord(tcoord); 73 | 74 | //top 75 | tcoord.y = textureRepeat; 76 | mesh.addVertex(circleTop * endMatrix); 77 | mesh.addNormal(direction * endMatrix.getRotate()); 78 | mesh.addTexCoord(tcoord); 79 | } 80 | 81 | // Cylinder cap 82 | if (cap) { 83 | int topMiddlePoint = mesh.getNumVertices(); 84 | ofVec3f topDir = glm::normalize(branch.end.getPosition()); 85 | mesh.addVertex(branch.end.getGlobalPosition()); 86 | mesh.addNormal(topDir * endMatrix.getRotate()); 87 | mesh.addTexCoord(ofVec2f(wrapLimitCap/2,wrapLimitCap/2)); 88 | 89 | for (int i = 0; i <= resolution; i++) { 90 | if (i == resolution) { 91 | //closing triangle 92 | mesh.addIndex(topMiddlePoint); 93 | mesh.addIndex(topMiddlePoint+ i + 1); 94 | mesh.addIndex(topMiddlePoint+1); 95 | } else { 96 | //indices 97 | mesh.addIndex(topMiddlePoint); 98 | mesh.addIndex(topMiddlePoint+ i + 1); 99 | mesh.addIndex(topMiddlePoint+ i + 2); 100 | } 101 | //add vertex 102 | float theta = 2.0f * 3.1415926f * float(i) / float(resolution); 103 | float x = scaledRadius * cosf(theta); 104 | float z = scaledRadius * sinf(theta); 105 | ofVec3f circleTemp = ofVec3f(x, 0.0, z); 106 | 107 | ofVec2f capTcoord; 108 | capTcoord.x = ofMap(x, -scaledRadius, scaledRadius, 0.f, wrapLimitCap); 109 | capTcoord.y = ofMap(z, -scaledRadius, scaledRadius, 0.f, wrapLimitCap); 110 | mesh.addVertex(circleTemp * branch.end.getGlobalTransformMatrix()); 111 | mesh.addNormal(topDir * endMatrix.getRotate()); 112 | mesh.addTexCoord(capTcoord); 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/ofxLSTube.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "ofxLSBranch.h" 4 | 5 | class ofxLSTube { 6 | public: 7 | ofxLSTube(); 8 | void generate(ofMesh& mesh, const ofxLSBranch branch, const float length); 9 | void setResolution(int _resolution); 10 | void setTextureRepeat(int _n){textureRepeat = _n;}; 11 | private: 12 | int resolution = 32; 13 | int textureRepeat = 1; 14 | }; 15 | -------------------------------------------------------------------------------- /src/ofxLSTubeDeformed.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxLSTubeDeformed.h" 2 | 3 | ofxLSTubeDeformed::ofxLSTubeDeformed(){ 4 | ring.clear(); 5 | middleRing.clear(); 6 | randomNumbers.clear(); 7 | buildRing(resolution); 8 | calcSide(); 9 | generateSetRandomNumbers(resolution); 10 | } 11 | 12 | void ofxLSTubeDeformed::generate(ofMesh& mesh, const ofxLSBranch branch, const int radius){ 13 | ofMatrix4x4 beginMatrix = branch.begin.getGlobalTransformMatrix(); 14 | ofMatrix4x4 endMatrix = branch.end.getGlobalTransformMatrix(); 15 | middleRing.clear(); 16 | // first part 17 | addRoundIndices(resolution,mesh.getNumVertices(), mesh); 18 | std::random_shuffle (randomNumbers.begin(), randomNumbers.end() ); 19 | unsigned int index_random_vector = 0; 20 | for(auto circleTemp : ring){ 21 | // bottom 22 | mesh.addVertex(circleTemp * beginMatrix); 23 | ofVec3f direction = (ofVec3f() + circleTemp).getNormalized(); 24 | //middle 25 | ofVec3f medTemp = circleTemp; 26 | int middle = (branch.end.getPosition().z - branch.begin.getPosition()).z/2; 27 | medTemp.z = middle+ ofRandom(-middle/2, +middle/2); 28 | medTemp.x = medTemp.x + randomNumbers.at(index_random_vector); 29 | medTemp.y = medTemp.y + randomNumbers.at(index_random_vector); 30 | middleRing.push_back(medTemp); 31 | mesh.addVertex(medTemp * beginMatrix); 32 | index_random_vector ++; 33 | } 34 | // second part 35 | addRoundIndices(resolution,mesh.getNumVertices(), mesh); 36 | int i = 0; 37 | for(auto circleTemp : ring){ 38 | mesh.addVertex(middleRing.at(i) * beginMatrix); 39 | //top 40 | mesh.addVertex(circleTemp * endMatrix); 41 | i ++; 42 | } 43 | calcNormals(mesh); 44 | } 45 | 46 | void ofxLSTubeDeformed::buildRing(const int _resolution){ 47 | for (int i = 0; i < _resolution; i++){ 48 | //calculate x and y component 49 | float theta = 2.0f * 3.1415926f * float(i) / float(_resolution); 50 | float x = radius * cosf(theta); 51 | float y = radius * sinf(theta); 52 | ofVec3f circleTemp = ofVec3f(x, y, 0.0); 53 | ring.push_back(circleTemp); 54 | } 55 | } 56 | 57 | void ofxLSTubeDeformed::calcSide(){ 58 | side = ring.at(0).distance(ring.at(1)); 59 | variation = side/2; 60 | } 61 | 62 | void ofxLSTubeDeformed::addRoundIndices(const int _resolution,const int _totalVertices, ofMesh& mesh){ 63 | for (int i = 0; i < _resolution; i++){ 64 | // if it is the last face, close it where the first face 65 | // was started 66 | if(i == _resolution -1){ 67 | mesh.addIndex(_totalVertices+(i*2)); 68 | mesh.addIndex(_totalVertices); 69 | mesh.addIndex(_totalVertices+1); 70 | 71 | mesh.addIndex(_totalVertices+1); 72 | mesh.addIndex(_totalVertices+(i*2)+1); 73 | mesh.addIndex(_totalVertices+(i*2)); 74 | }else{ 75 | mesh.addIndex(_totalVertices+(i*2)); 76 | mesh.addIndex(_totalVertices+(i*2)+2); 77 | mesh.addIndex(_totalVertices+(i*2)+3); 78 | 79 | mesh.addIndex(_totalVertices+(i*2)+3); 80 | mesh.addIndex(_totalVertices+(i*2)+1); 81 | mesh.addIndex(_totalVertices+(i*2)); 82 | } 83 | } 84 | } 85 | 86 | void ofxLSTubeDeformed::calcNormals(ofMesh& mesh){ 87 | mesh.clearNormals(); 88 | // https://forum.openframeworks.cc/t/mesh-lighting-normal-issues/18127/11 89 | // via https://github.com/ofZach/ofxMeshUtils/blob/master/src/ofxMeshUtils.cpp 90 | // inspired by http://www.iquilezles.org/www/articles/normals/normals.htm 91 | for( int i=0; i < mesh.getVertices().size(); i++ ) mesh.addNormal(ofPoint(0,0,0)); 92 | 93 | //itero un triangolo alla volta 94 | for( int i=0; i < mesh.getIndices().size(); i+=3 ){ 95 | const int ia = mesh.getIndices()[i]; 96 | const int ib = mesh.getIndices()[i+1]; 97 | const int ic = mesh.getIndices()[i+2]; 98 | 99 | //calcolo la posizione e la direzione di due vertici di un triangolo 100 | ofVec3f e1 = mesh.getVertices()[ia] - mesh.getVertices()[ib]; 101 | ofVec3f e2 = mesh.getVertices()[ic] - mesh.getVertices()[ib]; 102 | //uso i due vertici per trovare il normal 103 | ofVec3f no = e2.cross( e1 ); 104 | 105 | // depending on your clockwise / winding order, you might want to reverse the e2 / e1 above if your normals are flipped. 106 | 107 | mesh.getNormals()[ia] += no; 108 | mesh.getNormals()[ib] += no; 109 | mesh.getNormals()[ic] += no; 110 | } 111 | //normalizzo tutti i vettori che definiscono i normals 112 | for(int i=0; i < mesh.getNormals().size(); i++ ) { 113 | mesh.getNormals()[i] = glm::normalize(mesh.getNormals()[i]); 114 | } 115 | } 116 | 117 | void ofxLSTubeDeformed::generateSetRandomNumbers(const unsigned int resolution){ 118 | for(unsigned int i = 0; i < resolution; i++){ 119 | randomNumbers.push_back(ofRandom(-variation, +variation)); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/ofxLSTubeDeformed.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "ofxLSBranch.h" 4 | 5 | class ofxLSTubeDeformed { 6 | public: 7 | ofxLSTubeDeformed(); 8 | void generate(ofMesh& mesh, const ofxLSBranch branch, const int radius); 9 | private: 10 | int resolution = 4; 11 | float radius = 20.00; 12 | float side = 1.0; 13 | float variation = side /2; 14 | void build(const int resolution); 15 | void buildRing(const int resolution); 16 | void calcSide(); 17 | void calcNormals(ofMesh& mesh); 18 | void generateSetRandomNumbers(const unsigned int resolution); 19 | void addRoundIndices(const int resolution, const int totVertices, ofMesh& mesh); 20 | 21 | vector ring; 22 | vector randomNumbers; 23 | vector middleRing; 24 | }; 25 | -------------------------------------------------------------------------------- /src/ofxLSTurtle.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxLSTurtle.h" 2 | 3 | void ofxLSTurtle::setup( float _moveLength, float _width, float _turnAngle, ofxLSGeometryAvailable _geometry, bool _randomYRotation, bool _scaleWidth, int _resolution, int _textureRepeat) { 4 | defaultLength = _moveLength; 5 | width = _width; 6 | theta = _turnAngle; 7 | resolution = _resolution; 8 | textureRepeat = _textureRepeat; 9 | geometry = _geometry; 10 | randomYRotation = _randomYRotation; 11 | scaleWidth = _scaleWidth; 12 | bookmarks.clear(); 13 | nodesContainer.clear(); 14 | historySizes.clear(); 15 | shared_ptr root(new ofNode); 16 | root->setPosition(origin); 17 | nodesContainer.push_back(root); 18 | } 19 | 20 | void ofxLSTurtle::generate(ofVboMesh& mesh, const string _instruction, const int _depth) { 21 | resetBoundingBox(); 22 | bool branching = false; 23 | auto instructions = getInstructionsFromString(_instruction); 24 | 25 | for (auto stringInstruction : instructions) { 26 | auto inst = ofxLSInstruction(stringInstruction); 27 | auto head = inst.getHead(); 28 | if (head == "F") { 29 | branching = true; 30 | }else if( head == "G") { 31 | shared_ptr newJoin(new ofNode); 32 | newJoin->setParent(*nodesContainer.back()); 33 | newJoin->boom(inst.getLength(defaultLength)); 34 | nodesContainer.push_back(newJoin); 35 | }else if (head == "+") { 36 | shared_ptr newJoin(new ofNode); 37 | newJoin->setParent(*nodesContainer.back()); 38 | newJoin->rollDeg(+inst.getAngle(theta)); 39 | if(randomYRotation){ 40 | newJoin->panDeg(ofRandom(30.00, 330.00)); 41 | } 42 | nodesContainer.push_back(newJoin); 43 | }else if (head == "-") { 44 | shared_ptr newJoin(new ofNode); 45 | newJoin->setParent(*nodesContainer.back()); 46 | newJoin->rollDeg(-inst.getAngle(theta)); 47 | if(randomYRotation){ 48 | newJoin->panDeg(ofRandom(30.00, 330.00)); 49 | } 50 | nodesContainer.push_back(newJoin); 51 | }else if (head == "|") { 52 | shared_ptr newJoin(new ofNode); 53 | newJoin->setParent(*nodesContainer.back()); 54 | newJoin->panDeg(+inst.getAngle(180.00)); 55 | nodesContainer.push_back(newJoin); 56 | }else if (head == "&") { 57 | shared_ptr newJoin(new ofNode); 58 | newJoin->setParent(*nodesContainer.back()); 59 | newJoin->tiltDeg(+inst.getAngle(theta)); 60 | nodesContainer.push_back(newJoin); 61 | } 62 | else if (head == "^") { 63 | shared_ptr newJoin(new ofNode); 64 | newJoin->setParent(*nodesContainer.back()); 65 | newJoin->tiltDeg(-inst.getAngle(theta)); 66 | nodesContainer.push_back(newJoin); 67 | } 68 | else if (head == "\\") { 69 | shared_ptr newJoin(new ofNode); 70 | newJoin->setParent(*nodesContainer.back()); 71 | newJoin->panDeg(+inst.getAngle(theta)); 72 | nodesContainer.push_back(newJoin); 73 | } 74 | else if (head == "/") { 75 | shared_ptr newJoin(new ofNode); 76 | newJoin->setParent(*nodesContainer.back()); 77 | newJoin->panDeg(-inst.getAngle(180.00)); 78 | nodesContainer.push_back(newJoin); 79 | } 80 | else if (head == "[") { 81 | bookmarks.push_back(nodesContainer.back()); 82 | } 83 | else if (head == "]") { 84 | nodesContainer.push_back(bookmarks.back()); 85 | bookmarks.pop_back(); 86 | } 87 | 88 | if (branching) { 89 | float length = inst.getLength(defaultLength); 90 | auto beginBranch = nodesContainer.back(); 91 | shared_ptr endBranch(new ofNode); 92 | endBranch->setParent(*nodesContainer.back()); 93 | endBranch->move(ofVec3f(0, length, 0)); 94 | 95 | maybeVectorExpandsBoundingBox(endBranch->getGlobalPosition()); 96 | 97 | auto widths = getPrevAndCurrentWidth(length); 98 | auto newBranch = ofxLSBranch(*beginBranch, *endBranch, widths); 99 | nodesContainer.push_back(endBranch); 100 | 101 | // L-Systems are recursive, to avoid to insert the same mesh multiple 102 | // times, we check if a branch is not already in 103 | if (!branchAlreadySaved(newBranch)) { 104 | geometryBuilder.putIntoMesh(newBranch, mesh, geometry, resolution, length, textureRepeat); 105 | branchContainer.push_back(newBranch); 106 | } 107 | 108 | branching = false; 109 | } 110 | } 111 | 112 | //TODO, separate the generation of the node skeleton to mesh construction 113 | // float distance; 114 | // for(auto b : branchContainer){ 115 | // if(b->getParent() != nullptr){ 116 | // cout << "Start"<< endl; 117 | // cout << b->getParent()->getGlobalPosition().x; 118 | // cout << b->getParent()->getGlobalPosition().y; 119 | // cout << b->getParent()->getGlobalPosition().x; 120 | // cout << "End" << endl; 121 | // cout << b->getGlobalPosition().x; 122 | // cout << b->getGlobalPosition().y; 123 | // cout << b->getGlobalPosition().x; 124 | // }else{ 125 | // //root point 126 | // } 127 | // 128 | // } 129 | 130 | nodesContainer.clear(); 131 | bookmarks.clear(); 132 | historySizes.clear(); 133 | branchContainer.clear(); 134 | } 135 | 136 | bool ofxLSTurtle::branchAlreadySaved(ofxLSBranch newBranch){ 137 | for (auto savedBranch:branchContainer) { 138 | if(newBranch.begin.getGlobalPosition() == savedBranch.begin.getGlobalPosition() && 139 | newBranch.end.getGlobalPosition() == savedBranch.end.getGlobalPosition()){ 140 | return true; 141 | } 142 | } 143 | return false; 144 | }; 145 | 146 | // In case there is the need to keep track of the differents branches width and lenght, 147 | // as in the case when scaleWidth is set to true, this method does 2 things: 148 | // 1) it stores all the sizes in the container historySizes, for each pair, the first calue is the lenght 149 | // the second the width. 150 | // 2) It returns the current width and the previous one, as the method name says. 151 | // If there is no need to keep track of the branch width, just returns a pair containing 152 | // the default width, both for the prev and current width. 153 | pair ofxLSTurtle::getPrevAndCurrentWidth(float currentLength){ 154 | if(!scaleWidth){ 155 | return make_pair(width, width); 156 | } 157 | 158 | 159 | float currentWidth = (scaleWidth) ? getScaledWidth(currentLength) : width; 160 | if (historySizes.empty()) { 161 | historySizes.insert(make_pair(currentLength, currentWidth)); 162 | return (make_pair(currentWidth, currentWidth)); 163 | } else { 164 | map::iterator current; 165 | if (historySizes.find(currentLength) == historySizes.end()) { 166 | historySizes.insert(make_pair(currentLength, currentWidth)); 167 | current = historySizes.begin(); 168 | } else { 169 | current = historySizes.find(currentLength); 170 | } 171 | auto prev = current; 172 | ++prev; 173 | return make_pair(prev->second, current->second); 174 | } 175 | } 176 | 177 | //it scales the with proportionally to the scaled length 178 | // 179 | float ofxLSTurtle::getScaledWidth(float currentLength){ 180 | auto ratio = (defaultLength / currentLength ); 181 | float currentWidth = width / ratio; 182 | return currentWidth; 183 | if (currentWidth < 0.2) { 184 | return 0.2; 185 | } else { 186 | return currentWidth; 187 | } 188 | } 189 | 190 | vector ofxLSTurtle::getInstructionsFromString(string _str){ 191 | // This regex deserves an explanation. Taking a string like: 192 | // "F[+F-F(1.0,3.2)^F&F\\F/F?|]YU(2.0)A(2.232)?\\/" 193 | // it returns a vector containing 194 | // F 195 | // + 196 | // F 197 | // - 198 | // F(1.0,3.2) 199 | // ^ 200 | // F 201 | // & 202 | // F 203 | // \ 204 | // F 205 | // / 206 | // F 207 | // ? 208 | // | 209 | // Y 210 | // U(2.0) 211 | // A(2.232) 212 | // ? 213 | // \ 214 | // / 215 | 216 | // Explanation: 217 | // "([A-Z\\^&\\+-\\?\\|/\\]\\[\\\\](\\([0-9\\.,]+\\))*)" this means take any string that start with a capital letter, 218 | // a ^, a & a +, -, a | a '/', a'\' a'[', a ']'and, if there are, take any number or point '.' enclosed between () 219 | return ofxLSUtils::matchesInRegex(_str,"([A-Z\\^&\\+\\-\\?\\|/\\]\\[\\\\](\\([0-9\\.,]+\\))*)"); 220 | } 221 | 222 | // keep in mind that this method does not consider the thikness of a branch, but just the position of the vertices 223 | // that will be used later to generate the cylinder. Therefore, it is not accurate, but is is usefull to get the UV 224 | // if you want higher precision, call ofxLSystem.computeBoundingBox(), that iterates on all the vertices composing the 225 | // mesh 226 | void ofxLSTurtle::maybeVectorExpandsBoundingBox(ofVec3f v){ 227 | if (v.x < buildedBoundingBox.min.x) buildedBoundingBox.min.x = v.x; 228 | if (v.y < buildedBoundingBox.min.y) buildedBoundingBox.min.y = v.y; 229 | if (v.z < buildedBoundingBox.min.z) buildedBoundingBox.min.z = v.z; 230 | 231 | if (v.x > buildedBoundingBox.max.x) buildedBoundingBox.max.x = v.x; 232 | if (v.y > buildedBoundingBox.max.y) buildedBoundingBox.max.y = v.y; 233 | if (v.z > buildedBoundingBox.max.z) buildedBoundingBox.max.z = v.z; 234 | }; 235 | 236 | void ofxLSTurtle::resetBoundingBox(){ 237 | buildedBoundingBox.min = ofVec3f(0,0,0); 238 | buildedBoundingBox.max = ofVec3f(0,0,0); 239 | } 240 | -------------------------------------------------------------------------------- /src/ofxLSTurtle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxLSBranch.h" 5 | #include "ofxLSGeometry.h" 6 | #include "ofxLSInstruction.h" 7 | #include "ofxLSUtils.h" 8 | #include "ofxLSGeometryAvailable.h" 9 | #include "ofxLSBoundingBox.h" 10 | 11 | class ofxLSTurtle { 12 | public: 13 | void setup( float moveLength, float width, float turnAngle, ofxLSGeometryAvailable geometry, 14 | bool randomYRotation, bool scaleWidth, int resolution, int textureRepeat); 15 | void generate(ofVboMesh& mesh, const string ruleStr, const int depth); 16 | BoundingBox getBuildedBoundingBox() const { return buildedBoundingBox; }; 17 | 18 | private: 19 | const glm::vec3 origin = glm::vec3(0.,0.,0.); 20 | float defaultLength = 100; 21 | float width; 22 | float theta; 23 | ofxLSGeometryAvailable geometry; 24 | bool debug = false; 25 | bool randomYRotation = false; 26 | bool scaleWidth = false; 27 | int resolution = 4; 28 | int textureRepeat; 29 | vector getInstructionsFromString(string sentence); 30 | void maybeVectorExpandsBoundingBox(ofVec3f v); 31 | 32 | ofxLSGeometry geometryBuilder; 33 | std::vector > bookmarks; 34 | std::vector > nodesContainer; 35 | std::vector branchContainer; 36 | 37 | map historySizes; 38 | pair getPrevAndCurrentWidth(float currentLength); 39 | float getScaledWidth(float currentLength); 40 | 41 | void resetBoundingBox(); 42 | bool branchAlreadySaved(ofxLSBranch branch); 43 | BoundingBox buildedBoundingBox; 44 | }; 45 | -------------------------------------------------------------------------------- /src/ofxLSUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include 4 | 5 | class ofxLSUtils{ 6 | public: 7 | static string grepStringInRegex(string _str, string _reg){ 8 | smatch match; 9 | regex regEx(_reg); 10 | stringstream buffer; 11 | 12 | auto wordsBegin = sregex_iterator(_str.begin(), _str.end(), regEx); 13 | auto wordsEnd = sregex_iterator(); 14 | for(sregex_iterator i = wordsBegin; i != wordsEnd; ++i){ 15 | smatch m = *i; 16 | buffer << m.str(); 17 | } 18 | return buffer.str(); 19 | } 20 | 21 | static int countSubstring(const std::string& str, const std::string& sub){ 22 | if (sub.length() == 0) return 0; 23 | int count = 0; 24 | for (size_t offset = str.find(sub); offset != std::string::npos; 25 | offset = str.find(sub, offset + sub.length())){ 26 | ++count; 27 | } 28 | return count; 29 | } 30 | 31 | static vector matchesInRegex(string subject, string reg){ 32 | vector results; 33 | try { 34 | smatch match; 35 | regex regEx(reg); 36 | auto wordsBegin = sregex_iterator(subject.begin(), subject.end(), regEx); 37 | auto wordsEnd = sregex_iterator(); 38 | for(sregex_iterator i = wordsBegin; i != wordsEnd; ++i){ 39 | smatch m = *i; 40 | results.push_back(m.str()); 41 | } 42 | } catch (regex_error& e) { 43 | // Syntax error in the regular expression 44 | ofLogError("Error in regular expression"); 45 | } 46 | return results; 47 | } 48 | 49 | static string validTurtleInstruction(string str){ 50 | return grepStringInRegex(str, "[F-G]|-|\\+|\\]|\\[|\\||\\^|&|/|\\\\"); 51 | } 52 | }; 53 | 54 | -------------------------------------------------------------------------------- /src/ofxLSystem.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxLSystem.h" 2 | 3 | ofxLSystem::ofxLSystem(){ 4 | 5 | } 6 | 7 | void ofxLSystem::setAxiom(string _axiom){ 8 | axiom = _axiom; 9 | }; 10 | 11 | void ofxLSystem::setRules(vector _rulesContainer){ 12 | rulesContainer = _rulesContainer; 13 | }; 14 | 15 | void ofxLSystem::setTheta(float _theta){ theta = _theta; 16 | theta = _theta; 17 | }; 18 | 19 | void ofxLSystem::build(){ 20 | //check if axiom, rules and theta are ok, 21 | // if not, define some default 22 | try { 23 | validateInput(axiom, rulesContainer, theta); 24 | } catch (ofxLSInputError& e) { 25 | ofLogError(e.what()); 26 | theta = 25.00; 27 | axiom = "F"; 28 | rulesContainer = {"F -> F[+F][-F]"}; 29 | } 30 | //clear the mesh 31 | mesh.clear(); 32 | 33 | // setup the turtle, the sentences and the geometry 34 | setMeshMode(geometry); 35 | turtle.setup(stepLength, stepWidth, theta, geometry, randomYRotation, scaleWidth, resolution, textureRepeat); 36 | const vector sentences = 37 | ofxLSystemGrammar::buildSentences(rulesContainer, depth, axiom, constants); 38 | 39 | // populate the mesh 40 | turtle.generate(mesh, sentences.back(), depth); 41 | getMesh().clear(); 42 | getMesh().append(mesh); 43 | setBoundingBox(turtle.getBuildedBoundingBox()); 44 | getMesh().enableNormals(); 45 | } 46 | 47 | void ofxLSystem::save(string filename){ 48 | mesh.save(filename); 49 | } 50 | 51 | void ofxLSystem::setMeshMode(ofxLSGeometryAvailable _geometry){ 52 | switch (_geometry) { 53 | case LINES: 54 | mesh.setMode(OF_PRIMITIVE_LINES); 55 | getMesh().setMode(OF_PRIMITIVE_LINES); 56 | break; 57 | case TUBES: 58 | mesh.setMode(OF_PRIMITIVE_TRIANGLES); 59 | getMesh().setMode(OF_PRIMITIVE_TRIANGLES); 60 | break; 61 | case TUBES_DEFORMED: 62 | mesh.setMode(OF_PRIMITIVE_TRIANGLES); 63 | getMesh().setMode(OF_PRIMITIVE_TRIANGLES); 64 | break; 65 | case TRIANGLES: 66 | mesh.setMode(OF_PRIMITIVE_TRIANGLES); 67 | getMesh().setMode(OF_PRIMITIVE_TRIANGLES); 68 | break; 69 | default: 70 | mesh.setMode(OF_PRIMITIVE_TRIANGLES); 71 | getMesh().setMode(OF_PRIMITIVE_TRIANGLES); 72 | break; 73 | } 74 | } 75 | 76 | bool ofxLSystem::isAxiomInRules(string _axiom, vector _rulesContainer){ 77 | auto lettersInAxiom = ofxLSUtils::matchesInRegex(_axiom, "[a-zA-Z]"); 78 | for(auto letter : lettersInAxiom){ 79 | for(string rule : _rulesContainer){ 80 | if(ofxLSUtils::countSubstring(rule, letter) > 0){ 81 | return true; 82 | } 83 | } 84 | } 85 | 86 | return false; 87 | } 88 | 89 | bool ofxLSystem::thetaValueIsinRange(float theta){ 90 | return (theta >= -360.00 && theta <= 360.00) ? true : false; 91 | } 92 | 93 | void ofxLSystem::validateInput(string _axiom, vector _strRules, float theta){ 94 | if(!isAxiomInRules(_axiom, _strRules)){ 95 | throw ofxLSInputError("axiom is not in rules container"); 96 | } 97 | if(!thetaValueIsinRange(theta)){ 98 | throw ofxLSInputError("theta has to be between -360.00 and 360.00"); 99 | } 100 | } 101 | 102 | void ofxLSystem::setScaleWidth(bool _setScaleWidth){ 103 | if( 104 | ofxLSystemGrammar::detectGrammarType(rulesContainer) != "parametric" && 105 | _setScaleWidth == true 106 | ){ 107 | ofLogError("only parametric grammar supports setScale=true"); 108 | scaleWidth = false; 109 | }else{ 110 | scaleWidth = _setScaleWidth; 111 | } 112 | } 113 | 114 | void ofxLSystem::computeBoundingBox(){ 115 | for(auto v : mesh.getVertices()){ 116 | if (v.x < boundingBox.min.x) boundingBox.min.x = v.x; 117 | if (v.y < boundingBox.min.y) boundingBox.min.y = v.y; 118 | if (v.z < boundingBox.min.z) boundingBox.min.z = v.z; 119 | 120 | if (v.x > boundingBox.max.x) boundingBox.max.x = v.x; 121 | if (v.y > boundingBox.max.y) boundingBox.max.y = v.y; 122 | if (v.z > boundingBox.max.z) boundingBox.max.z = v.z; 123 | } 124 | } 125 | 126 | BoundingBox ofxLSystem::getBoundingBox() const { 127 | return boundingBox; 128 | }; 129 | 130 | void ofxLSystem::setBoundingBox(BoundingBox _boundingBox) { 131 | boundingBox = _boundingBox; 132 | }; 133 | -------------------------------------------------------------------------------- /src/ofxLSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxLSTurtle.h" 5 | #include "ofxLSystemGrammar.h" 6 | #include "ofxLSGeometryAvailable.h" 7 | #include "ofxLSInputError.h" 8 | #include "of3dPrimitives.h" 9 | #include "ofxLSBoundingBox.h" 10 | 11 | typedef map Constants; 12 | 13 | class ofxLSystem : public of3dPrimitive{ 14 | public: 15 | ofxLSystem(); 16 | 17 | void setAxiom(string _axiom); 18 | void setRules(vector _rulesContainer); 19 | void setTheta(float _theta); 20 | 21 | void setResolution(int _resolution) { resolution = _resolution; }; 22 | void setTextureRepeat(int _n) { textureRepeat = _n; }; 23 | void setRandomYRotation(bool _randomYRotation) { randomYRotation = _randomYRotation; }; 24 | void setGeometry(ofxLSGeometryAvailable _geometry){ geometry = _geometry; }; 25 | void setStep(int _depth) { depth = _depth; }; 26 | void setScaleWidth(bool _scaleWidht); 27 | void setStepWidth(float _stepWidth) { stepWidth = _stepWidth; }; 28 | void setStepLength(float _stepLength) { stepLength = _stepLength; }; 29 | void setConstants(map _Constants) { constants = _Constants; }; 30 | void computeBoundingBox(); 31 | BoundingBox getBoundingBox() const; 32 | void setBoundingBox(BoundingBox); 33 | 34 | void build(); 35 | void save(string filename); 36 | 37 | private: 38 | 39 | vector rulesContainer = {"F -> F[+F][-F]"}; 40 | string axiom = "F"; 41 | bool randomYRotation = false; 42 | ofxLSGeometryAvailable geometry = TUBES; 43 | int resolution = 10; 44 | int depth = 1; 45 | float theta = 25.00; 46 | float stepWidth = 10.00; 47 | bool scaleWidth = false; 48 | float stepLength = 100.00; 49 | int textureRepeat = 1; 50 | map constants = Constants(); 51 | ofxLSTurtle turtle; 52 | ofVboMesh mesh; 53 | BoundingBox boundingBox; 54 | 55 | void setMeshMode(ofxLSGeometryAvailable geometry); 56 | 57 | //validations 58 | bool thetaValueIsinRange(float theta); 59 | bool isAxiomInRules(string _axiom, vector _strRules); 60 | void validateInput(string _axiom, vector _strRules, float theta); 61 | }; 62 | --------------------------------------------------------------------------------