├── .gitignore
├── LICENSE
├── README.md
├── addon_config.mk
├── example-labels
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ └── Champagne & Limousines.ttf
├── config.make
├── example.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ │ └── xcschemes
│ │ ├── example-labels Debug.xcscheme
│ │ └── example-labels Release.xcscheme
├── openFrameworks-Info.plist
└── src
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
├── example-shader
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ ├── Champagne & Limousines.ttf
│ │ └── shader.frag
├── config.make
├── example.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ │ └── xcschemes
│ │ ├── example-labels Debug.xcscheme
│ │ └── example-labels Release.xcscheme
├── openFrameworks-Info.plist
└── src
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
├── example-simple
├── Makefile
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ └── .gitkeep
├── config.make
├── example.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ │ └── xcschemes
│ │ ├── example-labels Debug.xcscheme
│ │ └── example-labels Release.xcscheme
├── openFrameworks-Info.plist
└── src
│ ├── main.cpp
│ ├── ofApp.cpp
│ └── ofApp.h
├── images
├── 01.gif
├── 02.gif
├── 03.gif
├── 04.gif
├── 05.gif
├── 06.gif
├── 07.gif
├── hud.jpg
└── projection.png
├── libs
├── glmFontstash
│ ├── fontstash
│ │ ├── fontstash.h
│ │ ├── glfontstash.h
│ │ ├── sdf.h
│ │ └── stb_truetype.h
│ ├── glmFont.cpp
│ └── glmFont.h
└── glmTile
│ ├── Labels
│ ├── glmAnchorLine.cpp
│ ├── glmAnchorLine.h
│ ├── glmFeatureLabel.cpp
│ ├── glmFeatureLabel.h
│ ├── glmFeatureLabelLine.cpp
│ ├── glmFeatureLabelLine.h
│ ├── glmFeatureLabelPoint.cpp
│ ├── glmFeatureLabelPoint.h
│ ├── glmLabelManager.cpp
│ └── glmLabelManager.h
│ ├── glmFeature.h
│ ├── glmGeometryBuilder.cpp
│ ├── glmGeometryBuilder.h
│ ├── glmTile.cpp
│ └── glmTile.h
├── ofxaddons_thumbnail.png
└── src
├── ofxVectorBuilder.cpp
├── ofxVectorBuilder.h
├── ofxVectorLabels.cpp
├── ofxVectorLabels.h
├── ofxVectorTile.cpp
└── ofxVectorTile.h
/.gitignore:
--------------------------------------------------------------------------------
1 | # Some general ignore patterns
2 | build/
3 | obj/
4 | *.o
5 | Debug*/
6 | Release*/
7 | *.mode*
8 | *.app/
9 | *.pyc
10 | .svn/
11 |
12 |
13 | #XCode
14 | *.pbxuser
15 | *.perspective
16 | *.perspectivev3
17 | *.mode1v3
18 | *.mode2v3
19 | #XCode 4
20 | xcuserdata
21 | *.xcworkspace
22 |
23 | #Code::Blocks
24 | *.depend
25 | *.layout
26 |
27 | #Visual Studio
28 | *.sdf
29 | *.opensdf
30 | *.suo
31 | ipch/
32 |
33 | #Eclipse
34 | .metadata
35 | local.properties
36 | .externalToolBuilders
37 |
38 |
39 | # OS-specific ignore patterns
40 |
41 | #Linux
42 | *~
43 | # KDE
44 | .directory
45 |
46 | #OSX
47 | .DS_Store
48 | *.swp
49 | *~.nib
50 | # Thumbnails
51 | ._*
52 |
53 | #Windows
54 | # Windows image file caches
55 | Thumbs.db
56 | # Folder config file
57 | Desktop.ini
58 |
59 | #Android
60 | .csettings
61 | /libs/openFrameworksCompiled/project/android/paths.make
62 |
63 | # Miscellaneous
64 | .mailmap
65 |
66 | /week1-movingRec/bin/data/park6/
67 | /week1-movingRec/bin/data/park5/
68 | /week1-movingRec/bin/data/park4/
69 | /week1-movingRec/bin/data/park3/
70 | /week1-movingRec/bin/data/park2/
71 | /week1-movingRec/bin/data/park1/
72 | /week1-movingRec/bin/data/Archive.zip
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Mapzen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | 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, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | [](http://unmaintained.tech/)
3 |
4 | ## VectorTile
5 |
6 | This addon is a wrapper from a [Mapzen](mapzen.com) [Tangram](https://github.com/tangrams) experiment on 3D Labels
7 |
8 | ## Install
9 |
10 | Install addons dependences:
11 |
12 | ```
13 | cd openFrameworks/addons
14 | git clone --depth 1 http://github.com/patriciogonzalezvivo/ofxGlmTools.git
15 | git clone --depth 1 http://github.com/jefftimesten/ofxJSON.git
16 | ```
17 |
18 | ## Add to project
19 |
20 | Install ```ofxVectorTile``` to your project using the ProjectGenerator, dragging folder or Adam’s [OFPlugin](https://github.com/admsyn/OFPlugin).
21 |
22 | On the project Properties (the blue icons with the name of your project) go to `Building Settings` > `Linking` > `Other Linker Flags` and add `-lcurl`
23 |
24 | ## Dependences
25 |
26 | - [ofxGlmTools](https://github.com/patriciogonzalezvivo/ofxGlmTools)
27 | - [ofxJSON](https://github.com/jefftimesten/ofxJSON)
28 |
29 | ## Sources
30 |
31 | - [glmTile](https://github.com/tangrams/glmTile)
32 |
33 | * [cURL](http://curl.haxx.se/libcurl/)
34 | * [JsonCpp](https://github.com/open-source-parsers/jsoncpp)
35 | * [Fontstash](https://github.com/memononen/fontstash)
36 |
37 |
38 | ## The Problem
39 | Labels in maps are a huge headache, and have been for a long time. There are lots of solutions for 2D mapping, but not so many when you work in 3D, and especially not when your map shifts between 2D and 3D.
40 |
41 | ## The Experiments
42 |
43 | The main trick is a 2D projection of the geometry to place the text, within the canvas. Like a heads-up display layer between the 3D geometry and the camera.
44 |
45 | In the canvas:
46 | 
47 |
48 | Pros:
49 |
50 | * Fonts don’t need to be resized on zoom
51 |
52 | * No off-screen computations
53 |
54 | * We know exactly what the user sees
55 |
56 | Cons:
57 |
58 | * Occlusion becomes a problem: Should labels be visible through buildings? Which labels to prioritize, how to prioritize them? For now, these have no occlusion.
59 |
60 | ### Line Labels
61 |
62 | * Fit and repeat
63 |
64 | ```
65 | float lastSeed = 0.0;
66 | for (int i = 0; i < _anchorLine.size()-1; i++) {
67 | float offset = _anchorLine.getDistances()[i];
68 | float segmentLength = _anchorLine.getDistances()[i+1]-_anchorLine.getDistances()[i];//_anchorLine.getPolars()[i].r;
69 |
70 | // Fits?
71 | //
72 | if( segmentLength >= (m_label.width+_maxDistance) ){
73 | // How many times?
74 | int nTimes = segmentLength/(m_label.width+_maxDistance);
75 |
76 | // At what distance between each other?
77 | float margin = (segmentLength-m_label.width*(float)nTimes)/((float)nTimes+1.0);
78 |
79 | // Add anchors points for seeds
80 | float seed = margin;
81 | for (int i = 0; i < nTimes; i++) {
82 | float potentialSeed = offset + seed ;
83 | if( potentialSeed-lastSeed > _minDistance ){
84 | lastSeed = potentialSeed;
85 | _anchorLine.marks.push_back(lastSeed);
86 | seed += m_label.width+margin;
87 | }
88 | }
89 | } else if ( segmentLength >= m_label.width+_minDistance){
90 | // Only one time
91 | //
92 | float margin = (segmentLength-m_label.width)*0.5;
93 | float potentialSeed = offset + margin ;
94 | if( potentialSeed-lastSeed > _minDistance){
95 | lastSeed = potentialSeed;
96 | _anchorLine.marks.push_back(lastSeed);
97 | }
98 | }
99 | }
100 | ```
101 |
102 | 
103 |
104 | * Fade according to tilt angle
105 |
106 | ```
107 | float angle = glm::dot(glm::normalize( *m_cameraPos - shapes[0].getCentroid()),glm::vec3(0.,0.,1.));
108 | m_alpha = lerpValue(m_alpha,powf( CLAMP(angle,0.01,1.0), 1.15 ),0.1);
109 | ```
110 |
111 | 
112 |
113 | * Curved path following
114 |
115 | ```
116 | float angle = PI;
117 | glm::vec3 diff = _anchorLine[0]-_anchorLine[_anchorLine.size()-1];
118 | angle = atan2f(-diff.y, diff.x);
119 |
120 | if(angle < PI*0.5 && angle > -PI*0.5){
121 | for (int i = m_text.length()-1; i >=0 ; i--) {
122 | glm::vec3 src = _anchorLine.getPositionAt(_offset);
123 | if(screen.inside(src)){
124 | double rot = _anchorLine.getAngleAt(_offset);
125 | glPushMatrix();
126 | glTranslated(src.x, src.y, src.z);
127 | glScalef(1,-1,1);
128 | glRotated(rot*RAD_TO_DEG, 0, 0, -1);
129 | glScaled(-1, -1, 1);
130 | glTranslated(-m_lettersWidth[i], 0, 0);
131 | glTranslatef(0., -m_label.height*0.5,0.);
132 | m_font->drawString( std::string(1,m_text[i]), m_alpha );
133 | glPopMatrix();
134 | _offset += m_lettersWidth[i];
135 | } else {
136 | break;
137 | }
138 | }
139 | } else {
140 | for (int i = 0; i < m_text.length(); i++) {
141 | glm::vec3 src = _anchorLine.getPositionAt(_offset);
142 | if(screen.inside(src)){
143 | double rot = _anchorLine.getAngleAt(_offset);
144 | glPushMatrix();
145 | glTranslated(src.x, src.y, src.z);
146 | glScalef(1,-1,1);
147 | glRotated(rot*RAD_TO_DEG, 0, 0, -1);
148 | glTranslatef(0., -m_label.height*0.5,0.);
149 | m_font->drawString( std::string(1,m_text[i]), m_alpha );
150 | glPopMatrix();
151 | _offset += m_lettersWidth[i];
152 | } else {
153 | break;
154 | }
155 | }
156 | }
157 | ```
158 |
159 | 
160 |
161 | ### Point Labels
162 |
163 | * Project top points
164 |
165 | ```
166 | glm::ivec4 viewport;
167 | glm::mat4x4 mvmatrix, projmatrix;
168 | glGetIntegerv(GL_VIEWPORT, &viewport[0]);
169 | glGetFloatv(GL_MODELVIEW_MATRIX, &mvmatrix[0][0]);
170 | glGetFloatv(GL_PROJECTION_MATRIX, &projmatrix[0][0]);
171 | m_anchorPoint = glm::project(m_centroid+m_offset, mvmatrix, projmatrix, viewport);
172 | ```
173 |
174 | 
175 |
176 | * Mutual occlusion using depth sort and bounding boxes
177 |
178 | ```
179 | bool depthSort(const glmFeatureLabelPointRef &_A, const glmFeatureLabelPointRef &_B){
180 | return _A->getAnchorPoint().z < _B->getAnchorPoint().z;
181 | }
182 |
183 | …
184 |
185 | std::sort(pointLabels.begin(),pointLabels.end(), depthSort);
186 | for (int i = 0; i < pointLabels.size(); i++) {
187 | if(pointLabels[i]->bVisible){
188 | for (int j = i-1; j >= 0 ; j--) {
189 | if (pointLabels[i]->isOver( pointLabels[j].get() ) ){
190 | pointLabels[i]->bVisible = false;
191 | break;
192 | }
193 | }
194 | }
195 | }
196 | ```
197 |
198 |
199 | 
200 |
201 | * Occlude line labels with bounding box
202 |
203 | ```
204 | double rot = _anchorLine.getAngleAt(_offset);
205 | glmRectangle boundingBox = glmPolyline(m_label,angle).getBoundingBox();
206 | boundingBox.translate(_anchorLine.getPositionAt(_offset+m_label.width*0.5));
207 |
208 | bool bOver = false;
209 | for (int i = 0; i < pointLabels->size(); i++ ){
210 | if(pointLabels->at(i)->bVisible){
211 | if( boundingBox.intersects(pointLabels->at(i)->getLabel(0) ) ){
212 | bOver = true;
213 | break;
214 | }
215 | }
216 | }
217 | ```
218 |
219 | 
220 |
221 | * Street level point of view
222 | 
223 |
224 |
225 |
--------------------------------------------------------------------------------
/addon_config.mk:
--------------------------------------------------------------------------------
1 | meta:
2 | ADDON_NAME = ofxVectorTile
3 | ADDON_DESCRIPTION = 3D Vector Map Tile builder with Labels
4 | ADDON_AUTHOR = Patricio Gonzalez Vivo
5 | ADDON_TAGS = map geo 3D shaders
6 | ADDON_URL = http://github.com/tangrams/ofxVectorTile
7 |
8 | common:
9 | # dependencies with other addons, a list of them separated by spaces
10 | # or use += in several lines
11 | ADDON_DEPENDENCIES = ofxJSON
12 | ADDON_DEPENDENCIES += ofxGlmTools
13 |
14 | # include search paths, this will be usually parsed from the file system
15 | # but if the addon or addon libraries need special search paths they can be
16 | # specified here separated by spaces or one per line using +=
17 | ADDON_INCLUDES =
18 |
19 | # any special flag that should be passed to the compiler when using this
20 | # addon
21 | ADDON_CFLAGS =
22 |
23 | # any special flag that should be passed to the linker when using this
24 | # addon, also used for system libraries with -lname
25 | ADDON_LDFLAGS = -lcurl
26 |
27 | # linux only, any library that should be included in the project using
28 | # pkg-config
29 | ADDON_PKG_CONFIG_LIBRARIES =
30 |
31 | # osx/iOS only, any framework that should be included in the project
32 | ADDON_FRAMEWORKS =
33 |
34 | # source files, these will be usually parsed from the file system looking
35 | # in the src folders in libs and the root of the addon. if your addon needs
36 | # to include files in different places or a different set of files per platform
37 | # they can be specified here
38 | ADDON_SOURCES =
39 |
40 | # binary libraries, these will be usually parsed from the file system but some
41 | # libraries need to passed to the linker in a specific order
42 | ADDON_LIBS =
43 |
44 | # some addons need resources to be copied to the bin/data folder of the project
45 | # specify here any files that need to be copied, you can use wildcards like * and ?
46 | ADDON_DATA = copy_to_data_GUI/*
47 |
48 | linux64:
49 | # when parsing the file system looking for libraries exclude this for all or
50 | # a specific platform
51 | ADDON_LIBS_EXCLUDE = libs/kiss
52 |
53 | linux:
54 | ADDON_LIBS_EXCLUDE = libs/kiss
55 |
56 | linuxarmv6l:
57 | ADDON_LIBS_EXCLUDE = libs/kiss
58 |
59 | linuxarmv7l:
60 | ADDON_LIBS_EXCLUDE = libs/kiss
61 |
62 | osx:
63 | win_cb:
64 | vs2010:
65 | iphone:
66 | android:
67 |
--------------------------------------------------------------------------------
/example-labels/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=../../..
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/example-labels/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)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/example-labels/addons.make:
--------------------------------------------------------------------------------
1 | ofxGlmTools
2 | ofxJSON
3 | ofxVectorTile
4 |
--------------------------------------------------------------------------------
/example-labels/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/example-labels/bin/data/.gitkeep
--------------------------------------------------------------------------------
/example-labels/bin/data/Champagne & Limousines.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/example-labels/bin/data/Champagne & Limousines.ttf
--------------------------------------------------------------------------------
/example-labels/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-labels/example.xcodeproj/xcshareddata/xcschemes/example-labels 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-labels/example.xcodeproj/xcshareddata/xcschemes/example-labels 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-labels/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-labels/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-labels/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 | ofSetVerticalSync(true);
6 | ofEnableAlphaBlending();
7 |
8 | light.setDiffuseColor(ofFloatColor(0.9));
9 | light.setPosition(ofPoint(0,0,100));
10 |
11 | // Load Label Fonts
12 | //
13 | labels.loadFont("Champagne & Limousines.ttf", 10);
14 | labels.setFontColor(ofFloatColor(1.0), ofFloatColor(0.0));
15 |
16 | // Link the label manager with the builder
17 | //
18 | builder.setLabelManager(&labels);
19 |
20 | // Request a new tile to the builder
21 | //
22 | tile = builder.getFromWeb(19299,24631,16);
23 |
24 | // Make a VBO from the tile (FASTER)
25 | //
26 | tileMesh = tile.getMesh();
27 |
28 | fbo.allocate(ofGetWidth(),ofGetHeight());
29 | }
30 |
31 | //--------------------------------------------------------------
32 | void ofApp::update(){
33 | labels.updateCameraPosition(cam.getPosition());
34 |
35 | // Update the scene
36 | //
37 | fbo.begin();
38 | ofClear(0,0,0,0);
39 | cam.begin();
40 | ofEnableDepthTest();
41 |
42 | ofEnableLighting();
43 | light.enable();
44 |
45 | // tile.draw();
46 | tileMesh.draw();
47 |
48 | light.disable();
49 | ofDisableLighting();
50 |
51 | labels.draw3D();
52 | labels.updateProjection();
53 |
54 | ofDisableDepthTest();
55 | cam.end();
56 | fbo.end();
57 | }
58 |
59 | //--------------------------------------------------------------
60 | void ofApp::draw(){
61 | ofBackgroundGradient(ofColor::gray,ofColor::black);
62 |
63 | ofSetColor(255);
64 | fbo.draw(0,0);
65 |
66 | labels.draw2D();
67 |
68 | ofDrawBitmapString(" 'p' : toogle point labels debug", 10,15);
69 | ofDrawBitmapString(" 'l' : toogle line labels debug", 10,35);
70 | }
71 |
72 | //--------------------------------------------------------------
73 | void ofApp::keyPressed(int key){
74 |
75 | if(key == 'f'){
76 | ofToggleFullscreen();
77 | } else if (key == 'p'){
78 | labels.bDebugPoints = !labels.bDebugPoints;
79 | } else if (key == 'l'){
80 | labels.bDebugLines = !labels.bDebugLines;
81 | }
82 |
83 | }
84 |
85 | //--------------------------------------------------------------
86 | void ofApp::keyReleased(int key){
87 |
88 | }
89 |
90 | //--------------------------------------------------------------
91 | void ofApp::mouseMoved(int x, int y ){
92 |
93 | }
94 |
95 | //--------------------------------------------------------------
96 | void ofApp::mouseDragged(int x, int y, int button){
97 |
98 | }
99 |
100 | //--------------------------------------------------------------
101 | void ofApp::mousePressed(int x, int y, int button){
102 |
103 | }
104 |
105 | //--------------------------------------------------------------
106 | void ofApp::mouseReleased(int x, int y, int button){
107 |
108 | }
109 |
110 | //--------------------------------------------------------------
111 | void ofApp::windowResized(int w, int h){
112 | fbo.allocate(w,h);
113 | }
114 |
115 | //--------------------------------------------------------------
116 | void ofApp::gotMessage(ofMessage msg){
117 |
118 | }
119 |
120 | //--------------------------------------------------------------
121 | void ofApp::dragEvent(ofDragInfo dragInfo){
122 |
123 | }
124 |
--------------------------------------------------------------------------------
/example-labels/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "ofxVectorTile.h"
5 | #include "ofxVectorBuilder.h"
6 | #include "ofxVectorLabels.h"
7 |
8 | class ofApp : public ofBaseApp{
9 | public:
10 | void setup();
11 | void update();
12 | void draw();
13 |
14 | void keyPressed(int key);
15 | void keyReleased(int key);
16 | void mouseMoved(int x, int y );
17 | void mouseDragged(int x, int y, int button);
18 | void mousePressed(int x, int y, int button);
19 | void mouseReleased(int x, int y, int button);
20 | void windowResized(int w, int h);
21 | void dragEvent(ofDragInfo dragInfo);
22 | void gotMessage(ofMessage msg);
23 |
24 | ofEasyCam cam;
25 | ofLight light;
26 | ofFbo fbo;
27 |
28 | ofxVectorTile tile;
29 | ofxVectorBuilder builder;
30 | ofxVectorLabels labels;
31 | ofVboMesh tileMesh;
32 | };
33 |
--------------------------------------------------------------------------------
/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=../../..
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)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/example-shader/addons.make:
--------------------------------------------------------------------------------
1 | ofxGlmTools
2 | ofxJSON
3 | ofxVectorTile
4 |
--------------------------------------------------------------------------------
/example-shader/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/example-shader/bin/data/.gitkeep
--------------------------------------------------------------------------------
/example-shader/bin/data/Champagne & Limousines.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/example-shader/bin/data/Champagne & Limousines.ttf
--------------------------------------------------------------------------------
/example-shader/bin/data/shader.frag:
--------------------------------------------------------------------------------
1 | // Created by Patricio Gonzalez Vivo on 10/10/14.
2 | //
3 | //
4 |
5 | uniform sampler2DRect colorTex; // Color Buffer
6 | uniform sampler2DRect depthTex; // Depth Buffer
7 |
8 | float offset = 0.59;
9 | float flatPct = 0.87;
10 | float pct = 1.0;
11 |
12 | float focalDistance = 0.15;
13 | float focalRange = 0.14;
14 |
15 | float getIntensity(vec2 u){
16 | vec3 a = texture2DRect(colorTex,u).xyz;
17 | return (a.x+a.y+a.z)/3.0;
18 | }
19 |
20 | float LinearizeDepth(float zoverw){
21 | float n = 1.0;
22 | float f = 20000.0;
23 | return (2.0 * n) / (f + n - zoverw * (f - n));
24 | }
25 |
26 | float FocalValue(vec2 pos){
27 | float depth = LinearizeDepth( texture2DRect(depthTex, pos).r ) * 20000.;
28 | float value = abs(depth - (focalDistance*10000.) ) / (focalRange*20000.);
29 | return min( value , 1.0);
30 | }
31 |
32 | void main(){
33 | vec2 uv = gl_TexCoord[0].st;
34 | vec2 p = vec2(offset);
35 |
36 | float rangeTexel = FocalValue(gl_TexCoord[0].st);
37 |
38 | float avg = 0.0;
39 | avg += FocalValue(uv+vec2(p.x,0.0));
40 | avg += FocalValue(uv+vec2(-p.x,0.0));
41 | avg += FocalValue(uv+vec2(0.0,p.y));
42 | avg += FocalValue(uv+vec2(0.0,-p.y));
43 | avg += FocalValue(uv+vec2(p.x,p.y));
44 | avg += FocalValue(uv+vec2(-p.x,-p.y));
45 | avg += FocalValue(uv+vec2(p.x,-p.y));
46 | avg += FocalValue(uv+vec2(-p.x,p.y));
47 | avg /= 8.0;
48 |
49 | float focalPoint = 1.0-FocalValue(uv);
50 | float result = (focalPoint) + avg;
51 | result = (1.0-result)*(1000.0*pct);
52 |
53 | gl_FragColor.rgb = vec3(1.-result)-vec3((getIntensity(uv))*flatPct);
54 | gl_FragColor.a = 1.0;
55 | }
--------------------------------------------------------------------------------
/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.xcodeproj/xcshareddata/xcschemes/example-labels 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-shader/example.xcodeproj/xcshareddata/xcschemes/example-labels 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-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 | 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-shader/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // ofxVectorTile
3 | //
4 | // Created by Patricio Gonzalez Vivo on 10/10/14.
5 | //
6 | //
7 |
8 | #include "ofApp.h"
9 |
10 | //--------------------------------------------------------------
11 | void ofApp::setup(){
12 | ofSetVerticalSync(true);
13 | ofEnableAlphaBlending();
14 |
15 | light.setDiffuseColor(ofFloatColor(0.9));
16 | light.setPosition(ofPoint(0,0,1000));
17 |
18 | // Load Label Fonts
19 | //
20 | labels.loadFont("Champagne & Limousines.ttf", 10);
21 | labels.setFontColor(ofColor::black, ofColor::white);
22 |
23 | // Link the label manager with the builder
24 | //
25 | builder.setLabelManager(&labels);
26 |
27 | // Request a new tile to the builder
28 | //
29 | tile = builder.getFromWeb(19299,24631,16);
30 |
31 | // Make a VBO from the tile (FASTER)
32 | //
33 | tileMesh = tile.getMesh();
34 |
35 | ofFbo::Settings settings;
36 | settings.width = ofGetWidth();
37 | settings.height = ofGetHeight();
38 | settings.internalformat = GL_RGB;
39 | settings.numSamples = 0;
40 | settings.useDepth = true;
41 | settings.useStencil = true;
42 | settings.depthStencilAsTexture = true;
43 | #ifdef TARGET_OPENGLES
44 | settings.textureTarget = GL_TEXTURE_2D;
45 | #else
46 | settings.textureTarget = ofGetUsingArbTex() ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D;
47 | #endif
48 | fbo.allocate(settings);
49 | shader.load("", "shader.frag");
50 |
51 | bShader = true;
52 | }
53 |
54 | //--------------------------------------------------------------
55 | void ofApp::update(){
56 | labels.updateCameraPosition(cam.getPosition());
57 |
58 | // Update the scene
59 | //
60 | fbo.begin();
61 | ofClear(0,0,0,0);
62 | cam.begin();
63 | ofEnableDepthTest();
64 |
65 | ofEnableLighting();
66 | light.enable();
67 |
68 | // tile.draw();
69 | tileMesh.draw();
70 |
71 | light.disable();
72 | ofDisableLighting();
73 |
74 | labels.draw3D();
75 | labels.updateProjection();
76 |
77 | ofDisableDepthTest();
78 | cam.end();
79 | fbo.end();
80 | }
81 |
82 | //--------------------------------------------------------------
83 | void ofApp::draw(){
84 | ofBackground(ofColor::black);
85 |
86 | ofSetColor(255);
87 |
88 | if(bShader){
89 | shader.begin();
90 | shader.setUniformTexture("colorTex", fbo, 0);
91 | shader.setUniformTexture("depthTex", fbo.getDepthTexture(), 1);
92 | fbo.draw(0,0);
93 | shader.end();
94 | } else {
95 | fbo.draw(0,0);
96 | }
97 |
98 |
99 | labels.draw2D();
100 |
101 | if(bShader){
102 | ofSetColor(0);
103 | } else {
104 | ofSetColor(255);
105 | }
106 |
107 | ofDrawBitmapString(" 'p' : toogle point labels debug", 10,15);
108 | ofDrawBitmapString(" 'l' : toogle line labels debug", 10,35);
109 | ofDrawBitmapString(" 's' : toogle shader", 10,55);
110 | }
111 |
112 | //--------------------------------------------------------------
113 | void ofApp::keyPressed(int key){
114 |
115 | if(key == 'f'){
116 | ofToggleFullscreen();
117 | } else if (key == 'p'){
118 | labels.bDebugPoints = !labels.bDebugPoints;
119 | } else if (key == 'l'){
120 | labels.bDebugLines = !labels.bDebugLines;
121 | } else if (key == 's'){
122 | bShader = !bShader;
123 |
124 | if(bShader){
125 | labels.setFontColor(ofColor::black, ofColor::white);
126 | } else {
127 | labels.setFontColor(ofColor::white, ofColor::black);
128 | }
129 | }
130 |
131 | }
132 |
133 | //--------------------------------------------------------------
134 | void ofApp::keyReleased(int key){
135 |
136 | }
137 |
138 | //--------------------------------------------------------------
139 | void ofApp::mouseMoved(int x, int y ){
140 |
141 | }
142 |
143 | //--------------------------------------------------------------
144 | void ofApp::mouseDragged(int x, int y, int button){
145 |
146 | }
147 |
148 | //--------------------------------------------------------------
149 | void ofApp::mousePressed(int x, int y, int button){
150 |
151 | }
152 |
153 | //--------------------------------------------------------------
154 | void ofApp::mouseReleased(int x, int y, int button){
155 |
156 | }
157 |
158 | //--------------------------------------------------------------
159 | void ofApp::windowResized(int w, int h){
160 | fbo.allocate(w,h);
161 | }
162 |
163 | //--------------------------------------------------------------
164 | void ofApp::gotMessage(ofMessage msg){
165 |
166 | }
167 |
168 | //--------------------------------------------------------------
169 | void ofApp::dragEvent(ofDragInfo dragInfo){
170 |
171 | }
172 |
--------------------------------------------------------------------------------
/example-shader/src/ofApp.h:
--------------------------------------------------------------------------------
1 | //
2 | // ofxVectorTile
3 | //
4 | // Created by Patricio Gonzalez Vivo on 10/10/14.
5 | //
6 | //
7 |
8 | #pragma once
9 |
10 | #include "ofMain.h"
11 | #include "ofxVectorTile.h"
12 | #include "ofxVectorLabels.h"
13 | #include "ofxVectorBuilder.h"
14 |
15 | class ofApp : public ofBaseApp{
16 | public:
17 | void setup();
18 | void update();
19 | void draw();
20 |
21 | void keyPressed(int key);
22 | void keyReleased(int key);
23 | void mouseMoved(int x, int y );
24 | void mouseDragged(int x, int y, int button);
25 | void mousePressed(int x, int y, int button);
26 | void mouseReleased(int x, int y, int button);
27 | void windowResized(int w, int h);
28 | void dragEvent(ofDragInfo dragInfo);
29 | void gotMessage(ofMessage msg);
30 |
31 | ofEasyCam cam;
32 | ofLight light;
33 | ofFbo fbo;
34 | ofShader shader;
35 |
36 | ofxVectorTile tile;
37 | ofxVectorBuilder builder;
38 | ofxVectorLabels labels;
39 | ofVboMesh tileMesh;
40 |
41 | bool bShader;
42 | };
43 |
--------------------------------------------------------------------------------
/example-simple/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=../../..
10 | endif
11 |
12 | # call the project makefile!
13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
14 |
--------------------------------------------------------------------------------
/example-simple/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)
17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
18 |
--------------------------------------------------------------------------------
/example-simple/addons.make:
--------------------------------------------------------------------------------
1 | ofxGlmTools
2 | ofxJSON
3 | ofxVectorTile
4 |
--------------------------------------------------------------------------------
/example-simple/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/example-simple/bin/data/.gitkeep
--------------------------------------------------------------------------------
/example-simple/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-simple/example.xcodeproj/xcshareddata/xcschemes/example-labels 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-simple/example.xcodeproj/xcshareddata/xcschemes/example-labels 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-simple/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-simple/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-simple/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup(){
5 | ofSetVerticalSync(true);
6 | ofEnableDepthTest();
7 |
8 | light.setDiffuseColor(ofFloatColor(0.9));
9 | light.setPosition(ofPoint(0,0,100));
10 |
11 | ofxVectorBuilder builder;
12 | tile = builder.getMesh(19299,24631,16);
13 | }
14 |
15 | //--------------------------------------------------------------
16 | void ofApp::update(){
17 |
18 | }
19 |
20 | //--------------------------------------------------------------
21 | void ofApp::draw(){
22 | ofBackground(0);
23 |
24 | cam.begin();
25 | light.enable();
26 | ofEnableLighting();
27 |
28 | tile.draw();
29 |
30 | ofDisableLighting();
31 | light.disable();
32 | cam.end();
33 |
34 | }
35 |
36 | //--------------------------------------------------------------
37 | void ofApp::keyPressed(int key){
38 |
39 | }
40 |
41 | //--------------------------------------------------------------
42 | void ofApp::keyReleased(int key){
43 |
44 | }
45 |
46 | //--------------------------------------------------------------
47 | void ofApp::mouseMoved(int x, int y ){
48 |
49 | }
50 |
51 | //--------------------------------------------------------------
52 | void ofApp::mouseDragged(int x, int y, int button){
53 |
54 | }
55 |
56 | //--------------------------------------------------------------
57 | void ofApp::mousePressed(int x, int y, int button){
58 |
59 | }
60 |
61 | //--------------------------------------------------------------
62 | void ofApp::mouseReleased(int x, int y, int button){
63 |
64 | }
65 |
66 | //--------------------------------------------------------------
67 | void ofApp::windowResized(int w, int h){
68 |
69 | }
70 |
71 | //--------------------------------------------------------------
72 | void ofApp::gotMessage(ofMessage msg){
73 |
74 | }
75 |
76 | //--------------------------------------------------------------
77 | void ofApp::dragEvent(ofDragInfo dragInfo){
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/example-simple/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 |
5 | #include "ofxVectorBuilder.h"
6 |
7 | class ofApp : public ofBaseApp{
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 windowResized(int w, int h);
20 | void dragEvent(ofDragInfo dragInfo);
21 | void gotMessage(ofMessage msg);
22 |
23 | ofEasyCam cam;
24 | ofLight light;
25 |
26 | ofVboMesh tile;
27 | };
28 |
--------------------------------------------------------------------------------
/images/01.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/images/01.gif
--------------------------------------------------------------------------------
/images/02.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/images/02.gif
--------------------------------------------------------------------------------
/images/03.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/images/03.gif
--------------------------------------------------------------------------------
/images/04.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/images/04.gif
--------------------------------------------------------------------------------
/images/05.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/images/05.gif
--------------------------------------------------------------------------------
/images/06.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/images/06.gif
--------------------------------------------------------------------------------
/images/07.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/images/07.gif
--------------------------------------------------------------------------------
/images/hud.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/images/hud.jpg
--------------------------------------------------------------------------------
/images/projection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tangrams/ofxVectorTile/5b38fc6660d932856b30056a5d3960a8464bf005/images/projection.png
--------------------------------------------------------------------------------
/libs/glmFontstash/fontstash/glfontstash.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2009-2013 Mikko Mononen memon@inside.org
3 | //
4 | // This software is provided 'as-is', without any express or implied
5 | // warranty. In no event will the authors be held liable for any damages
6 | // arising from the use of this software.
7 | // Permission is granted to anyone to use this software for any purpose,
8 | // including commercial applications, and to alter it and redistribute it
9 | // freely, subject to the following restrictions:
10 | // 1. The origin of this software must not be misrepresented; you must not
11 | // claim that you wrote the original software. If you use this software
12 | // in a product, an acknowledgment in the product documentation would be
13 | // appreciated but is not required.
14 | // 2. Altered source versions must be plainly marked as such, and must not be
15 | // misrepresented as being the original software.
16 | // 3. This notice may not be removed or altered from any source distribution.
17 | //
18 | #ifndef GLFONTSTASH_H
19 | #define GLFONTSTASH_H
20 |
21 | #include "glmGL.h"
22 | #include "type_ptr.hpp"
23 | #include "matrix_transform.hpp"
24 |
25 | #include
26 | #include "fontstash.h"
27 |
28 | #include