├── src ├── rvtgen3d │ ├── clipper │ │ ├── README │ │ ├── clipper.cpp │ │ └── LICENSE.clipper.txt │ ├── rs │ │ ├── rsboost.h │ │ ├── rsnoise.h │ │ ├── rsdebug.h │ │ ├── rsthread.h │ │ ├── rsmem.h │ │ ├── rsmx.h │ │ ├── rsnoise.c │ │ ├── rsgeom.h │ │ └── rsboost.cpp │ ├── loader.h │ ├── CMakeLists.txt │ ├── earcut │ │ └── LICENSE.mapbox_earcut │ ├── rvtloader.h │ ├── rvtexport.h │ ├── rvtapp.h │ ├── rvtutil.h │ ├── tileloader.h │ ├── rvtgen.h │ ├── rvtapp.c │ ├── main.h │ ├── tileloader.c │ └── loader.c ├── conv │ └── CMakeLists.txt ├── o5m_get_outlines │ └── CMakeLists.txt ├── tiff2hmdata │ ├── CMakeLists.txt │ └── tiff2hmdata.cpp ├── tiffcompose │ ├── CMakeLists.txt │ └── tiffcompose.cpp ├── tilepacker │ └── CMakeLists.txt └── csv2rvtdata │ ├── CMakeLists.txt │ ├── LICENSE.csv.txt │ ├── csv.h │ ├── postgres_parser.hpp │ ├── LICENSE.hstore_parser.md │ └── csv.c ├── CMakeLists.txt ├── scripts ├── rsgeotools-process-hm-full.sh ├── rsgeotools-process-subdiv-shapefile.sh ├── rsgeotools-subdiv-shapefile.sh ├── rsgeotools-process-mass-subdiv-shapefile.sh ├── rsgeotools-subdiv-o5m.sh ├── rsgeotools-planet-init.sh ├── rsgeotools-process-tiles-mass.sh ├── rsgeotools-planet-process-full.sh ├── rsgeotools-process-tile.sh └── rsgeotools-process-hm.sh ├── LICENSE ├── rvtgen3d-data ├── models │ ├── bush1.ply │ ├── road-sign-give-way.ply │ ├── tree1.ply │ ├── road-sign-stop.ply │ ├── treepack1.ply │ ├── roof-shape-dome.ply │ ├── building-roof-part2.ply │ ├── building-roof-part1.ply │ ├── roof-rural-01.ply │ ├── building-entrance-1.ply │ ├── building-construction-part.ply │ ├── bridge-base.ply │ └── street-lamp-footway.ply └── color_codes.txt ├── Makefile ├── conf └── osm-conf.ini └── README.md /src/rvtgen3d/clipper/README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/romanshuvalov/rsgeotools/HEAD/src/rvtgen3d/clipper/README -------------------------------------------------------------------------------- /src/rvtgen3d/clipper/clipper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/romanshuvalov/rsgeotools/HEAD/src/rvtgen3d/clipper/clipper.cpp -------------------------------------------------------------------------------- /src/conv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(rsgeotools-conv) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(${PROJECT_NAME} conv.cpp) 7 | -------------------------------------------------------------------------------- /src/o5m_get_outlines/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(rsgeotools-o5m_get_outlines) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(${PROJECT_NAME} o5m_get_outlines.c) 7 | -------------------------------------------------------------------------------- /src/tiff2hmdata/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(rsgeotools-tiff2hmdata) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(${PROJECT_NAME} tiff2hmdata.cpp) 7 | target_link_libraries(${PROJECT_NAME} PRIVATE tiff) #TODO add package search before 8 | -------------------------------------------------------------------------------- /src/tiffcompose/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(rsgeotools-tiffcompose) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(${PROJECT_NAME} tiffcompose.cpp) 7 | target_link_libraries(${PROJECT_NAME} PRIVATE tiff) #TODO add package search before 8 | -------------------------------------------------------------------------------- /src/tilepacker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(rsgeotools-tilepacker) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(${PROJECT_NAME} tilepacker.cpp) 7 | target_link_libraries(${PROJECT_NAME} PRIVATE z bz2) #TODO add package search before 8 | -------------------------------------------------------------------------------- /src/csv2rvtdata/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(rsgeotools-csv2rvtdata) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(${PROJECT_NAME} csv.c csv2rvtdata.cpp) 7 | target_link_libraries(${PROJECT_NAME} PRIVATE geos_c) #TODO add package search before 8 | -------------------------------------------------------------------------------- /src/rvtgen3d/rs/rsboost.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | 5 | #include "rsgeom.h" 6 | 7 | rs_shape_t *rs_boost_shape_create_simplified(rs_shape_t *src, float tolerance); 8 | 9 | rs_shape_t *rs_boost_shape_create_convex_hull(rs_shape_t *src); 10 | 11 | #ifdef __cplusplus 12 | } // extern "C" 13 | #endif 14 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(rsgeotools) 3 | 4 | add_subdirectory(src/conv) 5 | add_subdirectory(src/csv2rvtdata) 6 | add_subdirectory(src/o5m_get_outlines) 7 | add_subdirectory(src/rvtgen3d) 8 | add_subdirectory(src/tiff2hmdata) 9 | add_subdirectory(src/tiffcompose) 10 | add_subdirectory(src/tilepacker) 11 | -------------------------------------------------------------------------------- /src/rvtgen3d/loader.h: -------------------------------------------------------------------------------- 1 | #ifndef RS_GLOADER_H 2 | #define RS_GLOADER_H 3 | 4 | #define RVT_APP_LOADER_FORMAT_PLY 1 5 | 6 | 7 | void loader_load_all_vbodata(); 8 | 9 | void loader_create_vbodata(int vbodata_index, char* filename, int format_type); 10 | 11 | void loader_create_vbodata_ply(int vbodata_index, char* filename); 12 | 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /src/rvtgen3d/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(rsgeotools-rvtgen3d) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(${PROJECT_NAME} 7 | clipper/clipper.cpp 8 | loader.c 9 | main.c 10 | rs/rsboost.cpp 11 | rs/rsgeom.cpp 12 | rs/rsmem.c 13 | rs/rsmx.c 14 | rs/rsnoise.c 15 | rvt.c 16 | rvtapp.c 17 | rvtexport.c 18 | rvtgen.c 19 | rvtloader.c 20 | rvtutil.c 21 | tileloader.c 22 | ) 23 | 24 | target_link_libraries(${PROJECT_NAME} PRIVATE bz2 z pthread) #TODO add package search before 25 | target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) 26 | -------------------------------------------------------------------------------- /src/rvtgen3d/rs/rsnoise.h: -------------------------------------------------------------------------------- 1 | #ifndef RS_NOISE_H 2 | #define RS_NOISE_H 3 | 4 | float rs_perlin(float i, float j); 5 | float rs_quad_noise(float i, float j); 6 | 7 | float rs_noise(int x, int y); 8 | float rs_noise_for_perlin(int x, int y); 9 | 10 | float rs_new_perlin_noise(float x, float y); 11 | 12 | void rs_perlin_configure(float freq, int octaves, float persistence, float seed, int tex_size, int shift_y); 13 | 14 | typedef struct rs_perlin_conf_t { 15 | float freq; 16 | int octaves; 17 | float persistence; 18 | float seed; 19 | int period; 20 | int tex_size; 21 | int shift_y; 22 | } rs_perlin_conf_t; 23 | 24 | extern rs_perlin_conf_t rs_perlin_conf; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/rvtgen3d/earcut/LICENSE.mapbox_earcut: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2016, Mapbox 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any purpose 6 | with or without fee is hereby granted, provided that the above copyright notice 7 | and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 10 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 11 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 12 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 13 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 14 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 15 | THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /src/rvtgen3d/rvtloader.h: -------------------------------------------------------------------------------- 1 | #ifndef RVTLOADER_H 2 | #define RVTLOADER_H 3 | 4 | #include "rvt.h" 5 | 6 | void rvt_load_tile(int tile_z, int tile_x, int tile_y, int subpak_z, int part_i, int tile_ix, int tile_iy, int tile_px, int tile_py, float tile_side_units); 7 | 8 | void heightmap_load_tile_to_data(unsigned char **output_super_tile_data, unsigned int *output_super_tile_data_len, int tile_z, int tile_world_ix, int tile_world_iy, int subpak_z, int vbo_index, int tile_ix, int tile_iy, int tile_x, int tile_y); 9 | void heightmap_load_tile_from_data(unsigned char *super_tile_data, unsigned int super_tile_data_len, int tile_z, int tile_world_ix, int tile_world_iy, int subpak_z, int vbo_index, int tile_ix, int tile_iy, int tile_x, int tile_y); 10 | 11 | void rvt_process_file(unsigned char **pdata, unsigned int *pdata_len, int tile_z, int tile_world_ix, int tile_world_iy, int subpak_z, int data_type, int part_i); 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/rvtgen3d/rvtexport.h: -------------------------------------------------------------------------------- 1 | #ifndef RS_RVTEXPORT_H 2 | #define RS_RVTEXPORT_H 3 | 4 | #include 5 | #include 6 | 7 | #include "rvttypes.h" 8 | 9 | void rvt_export_file_init(rvt_export_file_t *rvtfile, int file_format, int z_up, int vertex_type, int z, int x, int y, int layer_i); 10 | void rvt_export_file_term(rvt_export_file_t *rvtfile); 11 | 12 | void rvt_export_file_start_new_tile(rvt_export_file_t *rvtfile, int z, int x, int y, int layer_index); 13 | 14 | #define RVT_EXPORT_V_TYPE_12 0 15 | #define RVT_EXPORT_V_TYPE_16 1 16 | #define RVT_EXPORT_V_TYPE_BUILDING 2 17 | 18 | void rvt_export_file_write_vertices(rvt_export_file_t *rvtfile, float *p_vertices, int v_count ); 19 | void rvt_export_file_write_indices(rvt_export_file_t *rvtfile, uint32_t *p_indices, int i_count, int v_start_shift ); 20 | 21 | void rvt_export_file_write( rvt_export_file_t *rvtfile, float *p_vertices, int v_count, uint32_t *p_indices, int i_count ); 22 | 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /scripts/rsgeotools-process-hm-full.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test -z "$RVT_GPAK_DIR" 4 | then 5 | echo "RVT_GPAK_DIR is not set. " 6 | exit 7 | fi 8 | 9 | if test -z "$RVT_TEMP_DIR" 10 | then 11 | echo "RVT_TEMP_DIR is not set. " 12 | exit 13 | fi 14 | 15 | if test -z "$RVT_HGT_DIR_NASADEM" 16 | then 17 | echo "RVT_HGT_DIR_NASADEM is not set. " 18 | exit 19 | fi 20 | 21 | if test -z "$RVT_HGT_DIR_ASTERGDEMV3" 22 | then 23 | echo "RVT_HGT_DIR_ASTERGDEMV3 is not set. " 24 | exit 25 | fi 26 | 27 | 28 | if test -z "$6" 29 | then 30 | echo "Usage: rsgeotools-process-hm-full.sh TOP_Z TOP_X TOP_Y ARCHIVE_Z SUBPAK_Z DEST_Z (example: 5 20 10 6 11 11) " 31 | exit 32 | fi 33 | 34 | 35 | TOP_Z=$1 36 | TOP_X=$2 37 | TOP_Y=$3 38 | 39 | TILE_Z=$4 40 | 41 | SUBPAK_Z=$5 42 | 43 | DEST_Z=$6 44 | 45 | 46 | for tile_pair in `geoconv I $TOP_Z $TOP_X $TOP_Y $TILE_Z` 47 | do 48 | 49 | TP=$(echo $tile_pair | tr "_" " ") 50 | eval "rsgeotools-process-hm.sh $TILE_Z $TP $SUBPAK_Z $DEST_Z" 51 | 52 | done 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/rvtgen3d/rs/rsdebug.h: -------------------------------------------------------------------------------- 1 | #ifndef RSDEBUG_H_INCLUDED 2 | #define RSDEBUG_H_INCLUDED 3 | 4 | #ifndef STREETS_GAME 5 | 6 | #define DEBUG10(a) ((void)0) 7 | #define DEBUG10f(...) ((void)0) 8 | 9 | #define DEBUG20(a) ((void)0) 10 | #define DEBUG20f(...) ((void)0) 11 | 12 | #define DEBUG30(a) ((void)0) 13 | #define DEBUG30f(...) ((void)0) 14 | 15 | 16 | #define DEBUGR(a) 17 | #define DEBUGRf(...) 18 | 19 | 20 | #define CHECK_GL ((void)0) 21 | 22 | #define rs_app_assert_memory(...) ((void)0) 23 | #define rs_app_assert_memory_adv(...) ((void)0) 24 | 25 | #define RS_UNUSED_PARAM(...) ((void)0) 26 | 27 | #define rvt_app_increase_threads_count(...) ((void)0) 28 | 29 | #define rs_show_message(...) ((void)0) 30 | #define rs_show_message_sprintf(...) ((void)0) 31 | 32 | #define rs_critical_alert_and_halt(...) ((void)0) 33 | #define rs_critical_alert_and_halt_sprintf(...) ((void)0) 34 | 35 | #define rvt_app_exit(...) ((void)0) 36 | 37 | #endif 38 | 39 | #endif // RSDEBUG_H_INCLUDED 40 | -------------------------------------------------------------------------------- /src/csv2rvtdata/LICENSE.csv.txt: -------------------------------------------------------------------------------- 1 | * Copyright (c) 2003 Michael B. Allen 2 | * 3 | * The MIT License 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included 13 | * in 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 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 | * OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/rvtgen3d/rvtapp.h: -------------------------------------------------------------------------------- 1 | #ifndef RVTAPP_H 2 | #define RVTAPP_H 3 | 4 | #include 5 | 6 | #include "rvt.h" 7 | 8 | 9 | rvt_vbodata_t* rvt_app_get_vbodata_by_index(int index); 10 | 11 | float rvt_app_get_sc(); 12 | float rvt_app_get_sc_z(); 13 | 14 | int rvt_app_is_terrain_flat_by_default(); 15 | 16 | int rvt_app_get_stride_by_layer(int layer); 17 | 18 | int rvt_app_get_conf_index_by_layer(int vbo_layer_index); 19 | 20 | int rvt_app_is_exporting(); 21 | 22 | void rvt_app_exporting_total_bytes_append(uint64_t bytes); 23 | 24 | 25 | rvt_vbodata_t* rvt_app_get_vbodata_by_index(int index); 26 | 27 | int rvt_app_get_hexcode_by_color_string(char *s, int *p_output); 28 | 29 | 30 | int rvt_app_get_rvt_style(); 31 | int rvt_app_get_visstyle_index(); 32 | 33 | rvt_geodata_struct_t* rvt_app_get_geodata(); 34 | 35 | void rvt_app_update_history_game_bases(); 36 | 37 | rvt_gnote_t *rvt_get_gnote_by_point(rvt_gpoint_t *gp); 38 | 39 | void rvt_app_create_subtile_raw_vbo(int i); 40 | 41 | int rvt_app_are_vertices_per_frame_unlimited(); 42 | 43 | char *rvt_app_get_lang(); 44 | char *rvt_app_get_alt_lang(); 45 | 46 | void rvt_app_create_terrain_vbo( int vbo_index, unsigned char *data, int data_count, int stride ); 47 | 48 | rvt_cache_settings_t *rvt_app_get_cache_settings(); 49 | 50 | rvt_exporting_struct_t* rvt_app_get_exporting_struct(); 51 | 52 | void rvt_app_sleep_msec(int msec); 53 | 54 | void rvt_app_get_date(int *y, int *m, int *d, int *h, int *i, int *s); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/rvtgen3d/clipper/LICENSE.clipper.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | http://www.boost.org/LICENSE_1_0.txt 3 | 4 | Permission is hereby granted, free of charge, to any person or organization 5 | obtaining a copy of the software and accompanying documentation covered by 6 | this license (the "Software") to use, reproduce, display, distribute, 7 | execute, and transmit the Software, and to prepare derivative works of the 8 | Software, and to permit third-parties to whom the Software is furnished to 9 | do so, all subject to the following: 10 | 11 | The copyright notices in the Software and this entire statement, including 12 | the above license grant, this restriction and the following disclaimer, 13 | must be included in all copies of the Software, in whole or in part, and 14 | all derivative works of the Software, unless such copies or derivative 15 | works are solely in the form of machine-executable object code generated by 16 | a source language processor. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 21 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 22 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/csv2rvtdata/csv.h: -------------------------------------------------------------------------------- 1 | #ifndef MBA_CSV_H 2 | #define MBA_CSV_H 3 | 4 | /* 5 | 6 | From here: http://www.ioplex.com/~miallen/libmba/dl/src/mba/csv.h 7 | (c) 2003 Michael B. Allen 8 | MIT License 9 | 10 | */ 11 | 12 | /* csv - read write comma separated value format 13 | */ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #ifndef LIBMBA_API 20 | #ifdef WIN32 21 | # ifdef LIBMBA_EXPORTS 22 | # define LIBMBA_API __declspec(dllexport) 23 | # else /* LIBMBA_EXPORTS */ 24 | # define LIBMBA_API __declspec(dllimport) 25 | # endif /* LIBMBA_EXPORTS */ 26 | #else /* WIN32 */ 27 | # define LIBMBA_API extern 28 | #endif /* WIN32 */ 29 | #endif /* LIBMBA_API */ 30 | 31 | #include 32 | ////#include 33 | 34 | #if USE_WCHAR 35 | #define csv_row_parse csv_row_parse_wcs 36 | #else 37 | #define csv_row_parse csv_row_parse_str 38 | #endif 39 | 40 | #define CSV_TRIM 0x01 41 | #define CSV_QUOTES 0x02 42 | 43 | LIBMBA_API int csv_row_parse_str(const unsigned char *src, size_t sn, 44 | unsigned char *buf, size_t bn, 45 | unsigned char *row[], int rn, 46 | int sep, int flags); 47 | LIBMBA_API int csv_row_parse_wcs(const wchar_t *src, size_t sn, 48 | wchar_t *buf, size_t bn, 49 | wchar_t *row[], int rn, 50 | int sep, int flags); 51 | LIBMBA_API int csv_row_fread(FILE *in, 52 | unsigned char *buf, size_t bn, 53 | unsigned char *row[], int numcols, 54 | int sep, int flags); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* MBA_CSV_H */ 61 | 62 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Roman Shuvalov, www.romanshuvalov.com 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /src/csv2rvtdata/postgres_parser.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * postgres_parser.hpp 3 | * 4 | * Created on: 21.11.2016 5 | * Author: Michael Reichert 6 | */ 7 | 8 | #ifndef SRC_POSTGRES_PARSER_HPP_ 9 | #define SRC_POSTGRES_PARSER_HPP_ 10 | 11 | namespace pg_array_hstore_parser { 12 | template 13 | class PostgresParser { 14 | protected: 15 | /** 16 | * string representation we got from the database 17 | */ 18 | std::string& m_string_repr; 19 | 20 | /** 21 | * current position inside #m_string_repr 22 | */ 23 | size_t m_current_position = 0; 24 | 25 | /** 26 | * \brief Throw std::runtime_error due to invalid syntax 27 | * 28 | * \param error error type to be included into the message 29 | * 30 | * \throws std::runtime_error 31 | */ 32 | virtual void invalid_syntax(std::string error) = 0; 33 | 34 | public: 35 | PostgresParser(std::string& string_representation) : 36 | m_string_repr(string_representation) {}; 37 | 38 | virtual ~PostgresParser() {} 39 | 40 | /** 41 | * Has the parser reached the end of the structure to be parsed? 42 | * 43 | * \returns True if we are at the end. 44 | */ 45 | virtual bool has_next() = 0; 46 | 47 | /** 48 | * returns the next key value pair as a pair of strings 49 | * 50 | * Call #has_next() first! 51 | */ 52 | virtual TSingleElementType get_next() = 0; 53 | }; 54 | } // namespace pg_array_hstore_parser 55 | 56 | 57 | #endif /* SRC_POSTGRES_PARSER_HPP_ */ 58 | -------------------------------------------------------------------------------- /src/csv2rvtdata/LICENSE.hstore_parser.md: -------------------------------------------------------------------------------- 1 | pg-array-hstore-parser 2 | ====================== 3 | 4 | Copyright (c) 2015, Michael Reichert 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | Catch Testing Framework 28 | ======================= 29 | 30 | Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. 31 | 32 | Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt) 33 | -------------------------------------------------------------------------------- /scripts/rsgeotools-process-subdiv-shapefile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test -z "$RVT_SHP_ARCHIVE_DIR" 4 | then 5 | echo "RVT_SHP_ARCHIVE_DIR is not set. " 6 | exit 7 | fi 8 | 9 | if test -z "$RVT_SHP_DIR" 10 | then 11 | echo "RVT_SHP_DIR is not set. " 12 | exit 13 | fi 14 | 15 | if test -z "$RVT_TEMP_DIR" 16 | then 17 | echo "RVT_TEMP_DIR is not set. " 18 | exit 19 | fi 20 | 21 | 22 | if test -z "$4" 23 | then 24 | echo "Usage: rsgeotools-process-subdiv-shapefile.sh TOP_Z TOP_X TOP_Y PREFIX" 25 | exit 26 | fi 27 | 28 | TOP_Z=$1 29 | TOP_X=$2 30 | TOP_Y=$3 31 | 32 | SHAPEFILE_PREFIX=$4 33 | 34 | 35 | DEFAULT_DIR=`pwd` 36 | 37 | # SHP_DIR=$DEFAULT_DIR 38 | 39 | mkdir -p $RVT_TEMP_DIR 40 | 41 | TEMP_DIR="$RVT_TEMP_DIR/shp_temp_${SHAPEFILE_PREFIX}${TOP_Z}_${TOP_X}_${TOP_Y}" 42 | 43 | rm -rf $TEMP_DIR 44 | mkdir -p $TEMP_DIR 45 | 46 | mkdir -p $RVT_SHP_ARCHIVE_DIR 47 | mkdir -p $RVT_SHP_ARCHIVE_DIR/$SHAPEFILE_PREFIX 48 | 49 | cp $RVT_SHP_DIR/${SHAPEFILE_PREFIX}${TOP_Z}_${TOP_X}_${TOP_Y}* $TEMP_DIR/ 50 | 51 | cd $TEMP_DIR 52 | 53 | rsgeotools-subdiv-shapefile.sh $TOP_Z $TOP_X $TOP_Y 8 $SHAPEFILE_PREFIX 54 | 55 | rsgeotools-subdiv-shapefile.sh $TOP_Z $TOP_X $TOP_Y 9 $SHAPEFILE_PREFIX 56 | rm -r ${SHAPEFILE_PREFIX}8* 57 | 58 | rsgeotools-subdiv-shapefile.sh $TOP_Z $TOP_X $TOP_Y 10 $SHAPEFILE_PREFIX 59 | rm -r ${SHAPEFILE_PREFIX}9* 60 | 61 | rsgeotools-subdiv-shapefile.sh $TOP_Z $TOP_X $TOP_Y 11 $SHAPEFILE_PREFIX 62 | rm -r ${SHAPEFILE_PREFIX}10* 63 | 64 | TAR_FILENAME="${SHAPEFILE_PREFIX}${TOP_Z}_${TOP_X}_${TOP_Y}.tar.gz" 65 | 66 | tar -cf $TAR_FILENAME -z ${SHAPEFILE_PREFIX}11* 67 | 68 | cp $TAR_FILENAME $RVT_SHP_ARCHIVE_DIR/$SHAPEFILE_PREFIX/ 69 | 70 | echo "Process subdiv shapefile done." 71 | 72 | cd $DEFAULT_DIR 73 | 74 | if test -z "$SHAPEFILE_KEEP_TEMP_DATA" 75 | then 76 | rm -r $TEMP_DIR 77 | fi 78 | 79 | 80 | -------------------------------------------------------------------------------- /scripts/rsgeotools-subdiv-shapefile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | IFS=$'\n' 5 | 6 | TOP_Z=$1 7 | TOP_X=$2 8 | TOP_Y=$3 9 | 10 | TILE_Z=$4 11 | TILE_Z_PARENT=$(expr $TILE_Z - 1) 12 | 13 | TILE_PREFIX=$5 14 | 15 | OUTPUT_DIR="." 16 | 17 | 18 | if test -z "$5" 19 | then 20 | echo "Usage: rsgeotools-subdiv-shapefile.sh TOP_Z TOP_X TOP_Y DEST_Z TILE_PREFIX " 21 | exit 22 | fi 23 | 24 | 25 | current_number=0 26 | 27 | 28 | 29 | for tile_pair in `rsgeotools-conv I $TOP_Z $TOP_X $TOP_Y $TILE_Z_PARENT` 30 | do 31 | 32 | 33 | current_number=$(expr $current_number + 1) 34 | 35 | TP=$(echo $tile_pair | tr "_" "\n") 36 | 37 | 38 | echo "------- #$current_number (zoom $TILE_Z_PARENT) ($tile_pair) -------" 39 | 40 | 41 | subtile_pairs=(`rsgeotools-conv i $TILE_Z_PARENT $TP $TILE_Z`) 42 | 43 | t0_tp=$(echo ${subtile_pairs[0]} | tr "_" "\n") 44 | t1_tp=$(echo ${subtile_pairs[1]} | tr "_" "\n") 45 | t2_tp=$(echo ${subtile_pairs[2]} | tr "_" "\n") 46 | t3_tp=$(echo ${subtile_pairs[3]} | tr "_" "\n") 47 | 48 | 49 | t0_cmd="ogr2ogr -skipfailures -clipsrc `rsgeotools-conv c $TILE_Z $t0_tp` ${TILE_PREFIX}${TILE_Z}_${subtile_pairs[0]}.shp ${TILE_PREFIX}${TILE_Z_PARENT}_${tile_pair}.shp" 50 | t1_cmd="ogr2ogr -skipfailures -clipsrc `rsgeotools-conv c $TILE_Z $t1_tp` ${TILE_PREFIX}${TILE_Z}_${subtile_pairs[1]}.shp ${TILE_PREFIX}${TILE_Z_PARENT}_${tile_pair}.shp" 51 | t2_cmd="ogr2ogr -skipfailures -clipsrc `rsgeotools-conv c $TILE_Z $t2_tp` ${TILE_PREFIX}${TILE_Z}_${subtile_pairs[2]}.shp ${TILE_PREFIX}${TILE_Z_PARENT}_${tile_pair}.shp" 52 | t3_cmd="ogr2ogr -skipfailures -clipsrc `rsgeotools-conv c $TILE_Z $t3_tp` ${TILE_PREFIX}${TILE_Z}_${subtile_pairs[3]}.shp ${TILE_PREFIX}${TILE_Z_PARENT}_${tile_pair}.shp" 53 | 54 | 55 | eval $t0_cmd & 56 | eval $t1_cmd & 57 | eval $t2_cmd & 58 | eval $t3_cmd & 59 | wait 60 | 61 | done 62 | 63 | 64 | echo "Done." 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/rvtgen3d/rs/rsthread.h: -------------------------------------------------------------------------------- 1 | #ifndef RSTHREAD_H_INCLUDED 2 | #define RSTHREAD_H_INCLUDED 3 | 4 | 5 | #ifdef RS_WIN 6 | 7 | // WIN32 THREADS 8 | 9 | #include "rsplatform.h" 10 | 11 | #include 12 | #include 13 | 14 | #define RS_MUTEX_T CRITICAL_SECTION 15 | 16 | #define RS_MUTEX_LOCK(x) EnterCriticalSection(x) 17 | #define RS_MUTEX_UNLOCK(x) LeaveCriticalSection(x) 18 | #define RS_MUTEX_INIT(x) InitializeCriticalSection(x) 19 | 20 | #define RS_THREAD_CREATE(thread,func,arg) thread = _beginthread(func,0,arg) 21 | #define RS_THREAD_RETURN(retval) return 22 | #define RS_THREAD_JOIN(thread) WaitForSingleObject(thread,INFINITE) 23 | 24 | #define RS_THREAD_T uintptr_t 25 | 26 | #define RS_THREAD_FUNC_T void 27 | 28 | #define RS_SET_THREAD_PRIORITY(thread,priority) SetThreadPriority(thread, priority) 29 | #define RS_GET_THREAD_PRIORITY(thread) GetThreadPriority(HANDLE hThread) 30 | #define RS_THREAD_PRIORITY_NORMAL THREAD_PRIORITY_NORMAL 31 | #define RS_THREAD_PRIORITY_HIGHER THREAD_PRIORITY_ABOVE_NORMAL 32 | 33 | #else 34 | 35 | // POSIX THREADS 36 | 37 | #include 38 | 39 | #define RS_MUTEX_T pthread_mutex_t 40 | 41 | #define RS_MUTEX_LOCK(x) pthread_mutex_lock(x) 42 | #define RS_MUTEX_UNLOCK(x) pthread_mutex_unlock(x) 43 | 44 | 45 | #define RS_MUTEX_INIT(x) pthread_mutex_init(x,NULL) 46 | 47 | #define RS_THREAD_CREATE(thread,func,arg) pthread_create(&thread, NULL, func, (void*)arg) 48 | #define RS_THREAD_RETURN(retval) pthread_exit(retval) 49 | #define RS_THREAD_JOIN(thread) pthread_join(thread,NULL) 50 | 51 | #define RS_THREAD_KILL(thread) pthread_kill(thread,0) 52 | 53 | #define RS_THREAD_T pthread_t 54 | 55 | #define RS_THREAD_FUNC_T void* 56 | 57 | #endif 58 | 59 | #endif // RSTHREAD_H_INCLUDED 60 | -------------------------------------------------------------------------------- /scripts/rsgeotools-process-mass-subdiv-shapefile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if test -z "$RVT_SHP_ARCHIVE_DIR" 4 | then 5 | echo "RVT_SHP_ARCHIVE_DIR is not set. " 6 | exit 7 | fi 8 | 9 | if test -z "$RVT_SHP_DIR" 10 | then 11 | echo "RVT_SHP_DIR is not set. " 12 | exit 13 | fi 14 | 15 | if test -z "$RVT_TEMP_DIR" 16 | then 17 | echo "RVT_TEMP_DIR is not set. " 18 | exit 19 | fi 20 | 21 | 22 | IFS=$'\n' 23 | 24 | if test -z "$5" 25 | then 26 | echo "Usage: cmd TOP_Z TOP_X TOP_Y TILE_Z SHAPEFILE_PREFIX" 27 | exit 28 | fi 29 | 30 | TOP_Z=$1 31 | TOP_X=$2 32 | TOP_Y=$3 33 | 34 | TILE_Z=$4 35 | TILE_Z_PARENT=$(expr $TILE_Z - 1) 36 | 37 | SHAPEFILE_PREFIX=$5 38 | 39 | LOG_FILE="$RVT_SHP_ARCHIVE_DIR/${SHAPEFILE_PREFIX}_log_file.txt" 40 | 41 | rm -f $LOG_FILE 42 | 43 | DEFAULT_DIR=`pwd` 44 | 45 | 46 | for tile_pair in `geoconv I $TOP_Z $TOP_X $TOP_Y $TILE_Z_PARENT` 47 | do 48 | 49 | 50 | current_number=$(expr $current_number + 1) 51 | 52 | TP=$(echo $tile_pair | tr "_" "\n") 53 | 54 | echo "------- #$current_number (zoom $TILE_Z_PARENT) ($tile_pair) -------" 55 | 56 | subtile_pairs=(`geoconv i $TILE_Z_PARENT $TP $TILE_Z`) 57 | 58 | t0_tp=$(echo ${subtile_pairs[0]} | tr "_" " ") 59 | t1_tp=$(echo ${subtile_pairs[1]} | tr "_" " ") 60 | t2_tp=$(echo ${subtile_pairs[2]} | tr "_" " ") 61 | t3_tp=$(echo ${subtile_pairs[3]} | tr "_" " ") 62 | 63 | t0_cmd="rsgeotools-process-subdiv-shapefile.sh $TILE_Z ${t0_tp} $PROCESS_Z $SHAPEFILE_PREFIX" 64 | t1_cmd="rsgeotools-process-subdiv-shapefile.sh $TILE_Z ${t1_tp} $PROCESS_Z $SHAPEFILE_PREFIX" 65 | t2_cmd="rsgeotools-process-subdiv-shapefile.sh $TILE_Z ${t2_tp} $PROCESS_Z $SHAPEFILE_PREFIX" 66 | t3_cmd="rsgeotools-process-subdiv-shapefile.sh $TILE_Z ${t3_tp} $PROCESS_Z $SHAPEFILE_PREFIX" 67 | 68 | eval $t0_cmd >> $LOG_FILE 69 | eval $t1_cmd >> $LOG_FILE 70 | eval $t2_cmd >> $LOG_FILE 71 | eval $t3_cmd >> $LOG_FILE 72 | 73 | 74 | done 75 | 76 | cd $DEFAULT_DIR 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/bush1.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'tree1_v2.blend' 4 | element vertex 16 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 8 17 | property list uchar uint vertex_indices 18 | end_header 19 | 2.000000 0.000000 -0.000000 0.000000 -0.000000 1.000000 0.000050 0.999900 18 166 41 20 | -2.000000 4.000000 0.000000 0.000000 -0.000000 1.000000 0.499950 0.000100 18 166 41 21 | -2.000000 0.000000 -0.000000 0.000000 -0.000000 1.000000 0.499950 0.999900 18 166 41 22 | -0.000000 0.000000 -2.000000 1.000000 -0.000000 -0.000000 0.000050 0.999900 18 166 41 23 | 0.000000 4.000000 2.000000 1.000000 -0.000000 -0.000000 0.499950 0.000100 18 166 41 24 | -0.000000 0.000000 2.000000 1.000000 -0.000000 -0.000000 0.499950 0.999900 18 166 41 25 | 1.414213 2.000000 1.414214 0.000000 1.000000 0.000000 0.499950 0.500000 18 166 41 26 | -2.828427 2.000000 0.000000 0.000000 1.000000 0.000000 0.000050 0.000100 18 166 41 27 | -0.000000 2.000000 2.828427 0.000000 1.000000 0.000000 0.499950 0.000100 18 166 41 28 | -1.414213 2.000000 -1.414213 -0.000000 1.000000 0.000000 0.499950 0.500000 18 166 41 29 | 2.828427 2.000000 0.000000 -0.000000 1.000000 0.000000 0.000050 0.000100 18 166 41 30 | 0.000000 2.000000 -2.828427 -0.000000 1.000000 0.000000 0.499950 0.000100 18 166 41 31 | 2.000000 4.000000 0.000000 0.000000 -0.000000 1.000000 0.000050 0.000100 18 166 41 32 | 0.000000 4.000000 -2.000000 1.000000 -0.000000 -0.000000 0.000050 0.000100 18 166 41 33 | -1.414213 2.000000 -1.414213 0.000000 1.000000 0.000000 0.000050 0.500000 18 166 41 34 | 1.414214 2.000000 1.414214 -0.000000 1.000000 0.000000 0.000050 0.500000 18 166 41 35 | 3 0 1 2 36 | 3 3 4 5 37 | 3 6 7 8 38 | 3 9 10 11 39 | 3 0 12 1 40 | 3 3 13 4 41 | 3 6 14 7 42 | 3 9 15 10 43 | -------------------------------------------------------------------------------- /src/rvtgen3d/rvtutil.h: -------------------------------------------------------------------------------- 1 | #ifndef RVTUTIL_H 2 | #define RVTUTIL_H 3 | 4 | #include 5 | 6 | #include "rvt.h" 7 | #include "rvttypes.h" 8 | 9 | int rvt_point_is_in_area(rs_vec2_t p, int layer_i, int required_flags, int exclude_flags, rvt_gtriangle_t **gtriangle_result_p); 10 | 11 | 12 | void rvt_gp_add(int layer_i, int dest_tile_i, rs_point_t pos, float azimuth, void *pdata, int flags, float radius); 13 | 14 | void rvt_gline_add(int layer_i, int dest_tile_i, rs_point_t p1, rs_point_t p2, gd_lines_data_t *pdata, int flags, float thickness); 15 | void rvt_gline_add_shape(int layer_i, int dest_tile_i, float shift_x, float shift_y, rs_shape_t *src_sh, gd_lines_data_t *pdata, int flags, float thickness, int is_already_segmentized); 16 | 17 | void rvt_gtriangle_add(int layer_i, int dest_tile_i, int flags, float shift_x, float shift_y, rs_triangle_t *src_triangle); 18 | void rvt_gtriangle_add_triangle_set(int layer_i, int dest_tile_i, int flags, float shift_x, float shift_y, rs_triangle_set_t *src_tset); 19 | 20 | 21 | int rvt_get_tile_i_by_subtile_i(int subtile_i); 22 | 23 | int rvt_get_subtile_i_limited_by_tile_i(float x, float z, int dest_tile_i); 24 | 25 | int rvt_get_tile_i(float x, float z); 26 | int rvt_get_subtile_i(float x, float z); 27 | 28 | 29 | rvt_gpoint_t* rvt_gp_find_nearest(rs_vec2_t p, int layer_i, int required_flags, int exclude_flags); 30 | float rvt_gp_distance_to_nearest(rs_vec2_t p, int layer_i, int required_flags, int exclude_flags); 31 | 32 | float rvt_gline_find_nearest(rs_vec2_t p, int layer_i, int required_flags, int exclude_flags, rvt_gline_t **gline_result_p); 33 | float rvt_near_glines_length(rs_vec2_t p, int layer_i, int required_flags, int exclude_flags, float radius); 34 | 35 | float rvt_hm_get_height(float x, float y); 36 | float rvt_hm_get_height_adv(float fpx, float fpy, int tile_x, int tile_y); 37 | 38 | void rvt_create_wire_vbodata(int vbodata_index, rs_vec3_t p0, rs_vec3_t p1, rs_vec3_t p2, float halfwidth, int segments_count); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/rvtgen3d/tileloader.h: -------------------------------------------------------------------------------- 1 | #ifndef TILELOADER_H 2 | #define TILELOADER_H 3 | 4 | 5 | #include "rvtapp.h" 6 | #include "rvttypes.h" 7 | 8 | typedef struct rvt_tile_loader_st_rec_t { 9 | 10 | float *st_data; 11 | int st_total_vertices; 12 | int st_stride; 13 | int *st_ind_data; 14 | int st_total_indices; 15 | #ifdef STREETS_GAME 16 | int st_ind_type; 17 | int st_geom_type; 18 | #endif 19 | int st_vbo_conf_index; 20 | 21 | int st_subtile_i; 22 | int st_layer_i; 23 | 24 | int st_igroup_start[RVT_IGROUPS_COUNT]; 25 | int st_igroup_indices_count[RVT_IGROUPS_COUNT]; 26 | 27 | } rvt_tile_loader_st_rec_t; 28 | 29 | #define RVT_TILE_LOADER_MAX_ST_RECS_COUNT 32 30 | 31 | typedef struct rvt_tile_loader_struct_t { 32 | 33 | int status; 34 | int progress; 35 | 36 | int hm_ready; 37 | unsigned char *super_tile_data; 38 | int super_tile_data_len; 39 | 40 | int st_ready_count; 41 | rvt_tile_loader_st_rec_t st_rec[RVT_TILE_LOADER_MAX_ST_RECS_COUNT]; 42 | 43 | int tile_i; 44 | int tile_ix; 45 | int tile_iy; 46 | 47 | int tile_z; 48 | int tile_x; 49 | int tile_y; 50 | 51 | int tile_world_ix; 52 | int tile_world_iy; 53 | 54 | int tile_px; 55 | int tile_py; 56 | 57 | int current_layer; 58 | int custom_subtile_i; 59 | 60 | RS_MUTEX_T mutex; 61 | 62 | 63 | } rvt_tile_loader_struct_t; 64 | 65 | extern rvt_tile_loader_struct_t rvt_tile_loader_reg; 66 | 67 | 68 | #define RVT_TILE_LOADER_STATUS_OFF 0 69 | #define RVT_TILE_LOADER_STATUS_LOADING 1 70 | 71 | #define RVT_TILE_LOADER_STATUS_ERROR_CORRUPTED_FILE 8 72 | 73 | 74 | RS_THREAD_FUNC_T rvt_tile_loader_thread_func(); 75 | 76 | void rvt_tile_loader_load_tile(int tile_z, int tile_world_ix, int tile_world_iy, int tile_i, int tile_px, int tile_py); 77 | void rvt_tile_loader_init(); 78 | 79 | void rvt_tile_loader_halt(); 80 | 81 | 82 | void rvt_tile_loader_check_mainthread(); 83 | 84 | 85 | #endif // TILELOADER_H 86 | -------------------------------------------------------------------------------- /scripts/rsgeotools-subdiv-o5m.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | if test -z "$RVT_O5M_DIR" 5 | then 6 | echo "RVT_O5M_DIR is not set. " 7 | exit 8 | fi 9 | 10 | 11 | IFS=$'\n' 12 | 13 | TOP_Z=$1 14 | TOP_X=$2 15 | TOP_Y=$3 16 | 17 | TILE_Z=$4 18 | TILE_Z_PARENT=$(expr $TILE_Z - 1) 19 | 20 | OUTPUT_DIR="." 21 | 22 | 23 | if test -z "$4" 24 | then 25 | echo "Usage: rsgeotools-subdiv-o5m.sh TOP_Z TOP_X TOP_Y DEST_Z " 26 | exit 27 | fi 28 | 29 | 30 | current_number=0 31 | 32 | for tile_pair in `rsgeotools-conv I $TOP_Z $TOP_X $TOP_Y $TILE_Z_PARENT` 33 | do 34 | 35 | 36 | current_number=$(expr $current_number + 1) 37 | 38 | TP=$(echo $tile_pair | tr "_" "\n") 39 | 40 | 41 | echo "---- #$current_number (zoom $TILE_Z_PARENT) ($tile_pair) ----" 42 | 43 | subtile_pairs=(`rsgeotools-conv i $TILE_Z_PARENT $TP $TILE_Z`) 44 | 45 | t0_tp=$(echo ${subtile_pairs[0]} | tr "_" "\n") 46 | t1_tp=$(echo ${subtile_pairs[1]} | tr "_" "\n") 47 | t2_tp=$(echo ${subtile_pairs[2]} | tr "_" "\n") 48 | t3_tp=$(echo ${subtile_pairs[3]} | tr "_" "\n") 49 | 50 | t0_cmd="osmconvert t${TILE_Z_PARENT}_${tile_pair}.o5m -b=`rsgeotools-conv D $TILE_Z $t0_tp` -o=t${TILE_Z}_${subtile_pairs[0]}.o5m --complex-ways" 51 | t1_cmd="osmconvert t${TILE_Z_PARENT}_${tile_pair}.o5m -b=`rsgeotools-conv D $TILE_Z $t1_tp` -o=t${TILE_Z}_${subtile_pairs[1]}.o5m --complex-ways" 52 | t2_cmd="osmconvert t${TILE_Z_PARENT}_${tile_pair}.o5m -b=`rsgeotools-conv D $TILE_Z $t2_tp` -o=t${TILE_Z}_${subtile_pairs[2]}.o5m --complex-ways" 53 | t3_cmd="osmconvert t${TILE_Z_PARENT}_${tile_pair}.o5m -b=`rsgeotools-conv D $TILE_Z $t3_tp` -o=t${TILE_Z}_${subtile_pairs[3]}.o5m --complex-ways" 54 | 55 | if test -z "$RVT_SINGLE_THREAD" 56 | then 57 | eval $t0_cmd & 58 | eval $t1_cmd & 59 | eval $t2_cmd & 60 | eval $t3_cmd & 61 | wait 62 | else 63 | #echo "Executing [$t0_cmd]..." 64 | eval $t0_cmd 65 | #echo "Executing [$t1_cmd]..." 66 | eval $t1_cmd 67 | #echo "Executing [$t2_cmd]..." 68 | eval $t2_cmd 69 | #echo "Executing [$t3_cmd]..." 70 | eval $t3_cmd 71 | fi 72 | 73 | 74 | done 75 | 76 | 77 | 78 | echo "Done." 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/rvtgen3d/rs/rsmem.h: -------------------------------------------------------------------------------- 1 | #ifndef RSMEM_H_INCLUDED 2 | #define RSMEM_H_INCLUDED 3 | 4 | #include 5 | 6 | #include "rsthread.h" 7 | 8 | 9 | typedef struct rs_mem_chunk_t { 10 | 11 | int32_t pool_index; 12 | int32_t chunk_index; 13 | 14 | 15 | } rs_mem_chunk_t; 16 | 17 | #define RS_MEM_CHUNK_HDR_LEN (sizeof(rs_mem_chunk_t)) 18 | 19 | typedef struct rs_mem_pool_t { 20 | 21 | uint32_t status; 22 | uint32_t chunk_len; 23 | int32_t chunks_per_chunkset_count; 24 | 25 | int32_t max_chunksets_count; 26 | 27 | int32_t max_chunks_count; 28 | 29 | int32_t allocated_chunks_count; 30 | int32_t max_allocated_chunks_count; 31 | 32 | uint32_t *chunk_index_numpool; 33 | uint32_t chunk_index_numpool_pos; 34 | 35 | uint32_t *chunk_statuses; 36 | unsigned char **chunksets; 37 | 38 | } rs_mem_pool_t; 39 | 40 | void rs_mem_pool_init( int pool_index, int chunk_len, int chunks_per_chunkset_count, int max_chunks_count ); 41 | void rs_mem_pool_term( int pool_index ); 42 | void* rs_mem_pool_get_chunk( int pool_index ); 43 | void rs_mem_pool_release_chunk( int pool_index, int chunk_index ); 44 | 45 | #define RS_MEM_MAX_POOLS 24 46 | 47 | #define RS_MEM_RESERVED_POOLS 9 48 | 49 | typedef struct rs_mem_reg_t { 50 | 51 | rs_mem_pool_t pools[RS_MEM_MAX_POOLS]; 52 | 53 | int counter; 54 | 55 | RS_MUTEX_T mutex; 56 | 57 | int total_allocations; 58 | int max_total_allocations; 59 | 60 | uint64_t max_total_bytes_allocated; 61 | 62 | int total_reallocations; 63 | 64 | } rs_mem_reg_t; 65 | 66 | 67 | #define RS_MEM_POOL_AUTO (-1) 68 | 69 | extern rs_mem_reg_t rs_mem_reg; 70 | 71 | void rs_mem_init(); 72 | void rs_mem_term(); 73 | 74 | void rs_mem_print_statistics(); 75 | 76 | unsigned char* rs_mem_alloc(uint32_t bytes, int pool_index); 77 | unsigned char* rs_mem_alloc_adv(uint32_t bytes, const char *filename, int line, int index); 78 | unsigned char* rs_mem_realloc( void *pointer, uint32_t bytes); 79 | void rs_mem_free(void *pointer); 80 | 81 | 82 | #endif // RSMEM_H_INCLUDED 83 | -------------------------------------------------------------------------------- /scripts/rsgeotools-planet-init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | START_DATE=`date` 4 | 5 | IFS=$'\n' 6 | 7 | DEFAULT_DIR=`pwd` 8 | 9 | if test -z "$RVT_O5M_DIR" 10 | then 11 | echo "RVT_O5M_DIR is not set. " 12 | exit 13 | fi 14 | 15 | if test -z "$1" 16 | then 17 | echo "Usage: rsgeotools-planet-init.sh " 18 | exit 19 | fi 20 | 21 | 22 | PBF_FILENAME=$1 23 | 24 | 25 | echo "PBF to O5M..." 26 | date 27 | osmconvert --drop-author --drop-version $PBF_FILENAME -o=$RVT_O5M_DIR/planet.o5m 28 | 29 | 30 | echo "Filtering O5M..." 31 | date 32 | 33 | osmfilter $RVT_O5M_DIR/planet.o5m --drop-tags="created_by= converted_by= source*= lacounty*= gnis*= tiger*= NHD*= nhd*= time= ele= note= openGeoDB*= fixme= FIXME= is_in= is_in*= wikipedia*= wikidata*= website*= media*= description*= addr:street*= addr:city*= addr:postcode*= addr:country*= addr:place*= addr:suburb*= addr:state*= addr:province*= addr:cons*= addr:muni*= addr:interp*= addr:distric*= addr:sub*=" -o=$RVT_O5M_DIR/t0_0_0.o5m 34 | 35 | rm $RVT_O5M_DIR/planet.o5m 36 | 37 | cd $RVT_O5M_DIR 38 | 39 | echo "-----------------" 40 | echo "z1..." 41 | date 42 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh 0 0 0 1 43 | rm t0_0_0.o5m 44 | 45 | echo "-----------------" 46 | echo "z2..." 47 | date 48 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh 1 0 0 2 49 | rm t1_0_0.o5m 50 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh 1 0 1 2 51 | rm t1_0_1.o5m 52 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh 1 1 0 2 53 | rm t1_1_0.o5m 54 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh 1 1 1 2 55 | rm t1_1_1.o5m 56 | 57 | echo "-----------------" 58 | echo "z3..." 59 | date 60 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh 0 0 0 3 61 | rm t2_* 62 | 63 | echo "-----------------" 64 | echo "z4..." 65 | date 66 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh 0 0 0 4 67 | rm t3_* 68 | 69 | echo "-----------------" 70 | echo "z5..." 71 | date 72 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh 0 0 0 5 73 | rm t4_* 74 | 75 | echo "-----------------" 76 | echo "z6..." 77 | date 78 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh 0 0 0 6 79 | rm t5_* 80 | 81 | echo "-----------------" 82 | echo "z7..." 83 | date 84 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh 0 0 0 7 85 | rm t6_* 86 | 87 | cd $DEFAULT_DIR 88 | 89 | echo "------" 90 | 91 | END_DATE=`date` 92 | echo "Start: $START_DATE" 93 | echo "End: $END_DATE" 94 | echo "Done." 95 | echo "" 96 | 97 | 98 | -------------------------------------------------------------------------------- /src/rvtgen3d/rvtgen.h: -------------------------------------------------------------------------------- 1 | #ifndef RVTGEN_H 2 | #define RVTGEN_H 3 | 4 | #include "rvt.h" 5 | 6 | 7 | void rvt_gen_init_default_stages(); 8 | 9 | void rvt_rural_write_stuff( rs_point_t p, float azimuth, float distance, float shift_forward, float last_shift_forward, float max_side_wall_len, int last, int rand_i ); 10 | void rvt_barrier_write_common( int flags, int barrier_osm_value, float y_start, int barrier_height, int wall_type_index, rs_shape_t *p ); 11 | 12 | 13 | void rvt_barrier_wall_area(rs_shape_t *p, int stage_i, gd_area_data_t *data); 14 | void rvt_barrier_wall_line(rs_shape_t *p, int stage_i, gd_lines_data_t *data); 15 | 16 | void rvt_road_rural_houses(rs_shape_t *p, int stage_i, gd_lines_data_t *sdata); 17 | 18 | void rvt_road_lamps(rs_shape_t *p, int stage_i, gd_lines_data_t *data); 19 | void rvt_road_footway_trees(rs_shape_t *p, int stage_i, gd_lines_data_t *data); 20 | 21 | 22 | void rvt_railway_towers(rs_shape_t *p, int stage_i, gd_lines_data_t *sdata); 23 | 24 | void rvt_railway(rs_shape_t *p, int stage_i, gd_lines_data_t *data); 25 | 26 | void rvt_road(rs_shape_t *p, int stage_i, gd_lines_data_t *data); 27 | void rvt_river(rs_shape_t *p, int stage_i, gd_lines_data_t *sdata); 28 | 29 | void rvt_area(rs_shape_t *p, int stage_i, gd_area_data_t *sdata); 30 | 31 | void rvt_bridge(rs_shape_t *p, int stage_i, gd_lines_data_t *sdata); 32 | void rvt_tunnel(rs_shape_t *p, int stage_i, gd_lines_data_t *sdata); 33 | 34 | void rvt_building_add_point(rs_shape_t *p, int stage_i, gd_building_data_t *data); 35 | 36 | 37 | void rvt_building(rs_shape_t *p, int stage_i, gd_building_data_t *sdata, rvt_gnote_t *gnote); 38 | 39 | void rvt_crossing(rs_vec2_t *v, int stage_i, gd_point_data_t *sdata); 40 | void rvt_level_crossing(rs_vec2_t *v, int stage_i, gd_point_data_t *data); 41 | 42 | void rvt_natural_tree(rs_vec2_t *v, int stage_i, gd_point_data_t *data); 43 | void rvt_building_entrance(rs_vec2_t *v, int stage_i, gd_point_data_t *sdata); 44 | void rvt_barrier_block(rs_vec2_t *v, int stage_i, gd_point_data_t *data); 45 | 46 | void rvt_powerline(rs_shape_t *p, int stage_i, gd_lines_data_t *sdata); 47 | 48 | void rvt_all_forest(rs_shape_t *unused_shape, int stage_i, gd_area_data_t *unused_data); 49 | void rvt_all_buildings(void *unused_geometry, int stage_i, gd_building_data_t *unused_data); 50 | 51 | void rvt_full_tile_naturals(void *geometry, int stage_i, void *data); 52 | 53 | void gd_gen_geom(int tile_i); 54 | 55 | #endif // RVTGEN_H 56 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/road-sign-give-way.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'street-lamp.blend' 4 | element vertex 23 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 11 17 | property list uchar uint vertex_indices 18 | end_header 19 | 0.000000 9.000000 -0.125000 0.707107 0.000000 -0.707107 0.200001 -5.149611 117 116 115 20 | 0.125000 0.000000 0.000000 0.707107 0.000000 -0.707107 0.400002 6.149608 117 116 115 21 | 0.000000 0.000000 -0.125000 0.707107 0.000000 -0.707107 0.200002 6.149608 117 116 115 22 | 0.125000 9.000000 0.000000 0.707107 0.000000 0.707107 0.600001 -5.149611 117 116 115 23 | -0.000000 0.000000 0.125000 0.707107 0.000000 0.707107 0.800001 6.149611 117 116 115 24 | 0.125000 0.000000 0.000000 0.707107 0.000000 0.707107 0.600001 6.149611 117 116 115 25 | 0.000000 9.000000 -0.125000 0.000000 1.000000 0.000000 0.800001 -5.149611 117 116 115 26 | -0.000000 9.000000 0.125000 0.000000 1.000000 0.000000 1.000000 -4.816704 117 116 115 27 | 0.125000 9.000000 0.000000 0.000000 1.000000 0.000000 0.800001 -4.816704 117 116 115 28 | -0.000000 9.000000 0.125000 -0.707107 0.000000 0.707107 0.600001 6.149608 117 116 115 29 | -0.125000 0.000000 -0.000000 -0.707107 0.000000 0.707107 0.400002 -5.149611 117 116 115 30 | -0.000000 0.000000 0.125000 -0.707107 0.000000 0.707107 0.600001 -5.149611 117 116 115 31 | -0.125000 9.000000 -0.000000 -0.707107 0.000000 -0.707107 0.000000 -5.149611 117 116 115 32 | 0.000000 0.000000 -0.125000 -0.707107 0.000000 -0.707107 0.200001 6.149609 117 116 115 33 | -0.125000 0.000000 -0.000000 -0.707107 0.000000 -0.707107 0.000002 6.149609 117 116 115 34 | 0.000000 7.334782 0.151149 -0.000000 0.000000 1.000000 0.000000 0.000000 199 196 194 35 | 1.200000 9.734781 0.151148 -0.000000 0.000000 1.000000 0.000000 0.000000 199 196 194 36 | -1.200000 9.734781 0.151148 -0.000000 0.000000 1.000000 0.000000 0.000000 199 196 194 37 | 0.125000 9.000000 0.000000 0.707107 0.000000 -0.707107 0.400001 -5.149611 117 116 115 38 | -0.000000 9.000000 0.125000 0.707107 -0.000000 0.707107 0.800001 -5.149610 117 116 115 39 | -0.125000 9.000000 -0.000000 0.000000 1.000000 0.000000 1.000000 -5.149611 117 116 115 40 | -0.125000 9.000000 -0.000000 -0.707107 0.000000 0.707107 0.400002 6.149608 117 116 115 41 | 0.000000 9.000000 -0.125000 -0.707107 0.000000 -0.707107 0.199999 -5.149611 117 116 115 42 | 3 0 1 2 43 | 3 3 4 5 44 | 3 6 7 8 45 | 3 9 10 11 46 | 3 12 13 14 47 | 3 15 16 17 48 | 3 0 18 1 49 | 3 3 19 4 50 | 3 6 20 7 51 | 3 9 21 10 52 | 3 12 22 13 53 | -------------------------------------------------------------------------------- /scripts/rsgeotools-process-tiles-mass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | if test -z "$RVT_O5M_DIR" 5 | then 6 | echo "RVT_O5M_DIR is not set. " 7 | exit 8 | fi 9 | 10 | if test -z "$RVT_SHP_ARCHIVE_DIR" 11 | then 12 | echo "RVT_SHP_ARCHIVE_DIR is not set. " 13 | exit 14 | fi 15 | 16 | if test -z "$RVT_GPAK_DIR" 17 | then 18 | echo "RVT_GPAK_DIR is not set. " 19 | exit 20 | fi 21 | 22 | 23 | if test -z "$RVT_CSV_CONF" 24 | then 25 | echo "RVT_CSV_CONF ini file is not set. " 26 | exit 27 | fi 28 | 29 | if test -z "$RVT_TEMP_DIR" 30 | then 31 | echo "RVT_TEMP_DIR is not set. " 32 | exit 33 | fi 34 | 35 | 36 | IFS=$'\n' 37 | 38 | if test -z "$8" 39 | then 40 | echo "Usage: cmd TOP_Z TOP_X TOP_Y TILE_Z PROCESS_Z SUBPAK_Z DEST_Z PLANET_TIMESTAMP" 41 | exit 42 | fi 43 | 44 | TOP_Z=$1 45 | TOP_X=$2 46 | TOP_Y=$3 47 | 48 | TILE_Z=$4 49 | TILE_Z_PARENT=$(expr $TILE_Z - 1) 50 | 51 | PROCESS_Z=$5 52 | 53 | SUBPAK_Z=$6 54 | 55 | DEST_Z=$7 56 | 57 | PLANET_TIMESTAMP=$8 58 | 59 | LOG_FILE="$RVT_O5M_DIR/log_file.txt" 60 | 61 | rm -f $LOG_FILE 62 | 63 | DEFAULT_DIR=`pwd` 64 | 65 | 66 | for tile_pair in `geoconv I $TOP_Z $TOP_X $TOP_Y $TILE_Z_PARENT` 67 | do 68 | 69 | current_number=$(expr $current_number + 1) 70 | 71 | TP=$(echo $tile_pair | tr "_" "\n") 72 | 73 | echo "--- #$current_number (z $TILE_Z_PARENT) ($tile_pair) (single thread = $RVT_SINGLE_THREAD) ---" 74 | 75 | subtile_pairs=(`geoconv i $TILE_Z_PARENT $TP $TILE_Z`) 76 | 77 | t0_tp=$(echo ${subtile_pairs[0]} | tr "_" " ") 78 | t1_tp=$(echo ${subtile_pairs[1]} | tr "_" " ") 79 | t2_tp=$(echo ${subtile_pairs[2]} | tr "_" " ") 80 | t3_tp=$(echo ${subtile_pairs[3]} | tr "_" " ") 81 | 82 | t0_cmd="rsgeotools-process-tile.sh $TILE_Z ${t0_tp} $PROCESS_Z $SUBPAK_Z $DEST_Z $PLANET_TIMESTAMP" 83 | t1_cmd="rsgeotools-process-tile.sh $TILE_Z ${t1_tp} $PROCESS_Z $SUBPAK_Z $DEST_Z $PLANET_TIMESTAMP" 84 | t2_cmd="rsgeotools-process-tile.sh $TILE_Z ${t2_tp} $PROCESS_Z $SUBPAK_Z $DEST_Z $PLANET_TIMESTAMP" 85 | t3_cmd="rsgeotools-process-tile.sh $TILE_Z ${t3_tp} $PROCESS_Z $SUBPAK_Z $DEST_Z $PLANET_TIMESTAMP" 86 | 87 | 88 | if test -z "$RVT_SINGLE_THREAD" 89 | then 90 | # Caution: t7_67_43, t7_65_42, t7_66_42 are too big, can cause 'out of memory' errors 91 | # That's why we use 2 threads instead of 4 92 | 93 | eval $t0_cmd >> $LOG_FILE & 94 | eval $t1_cmd >> $LOG_FILE & 95 | wait 96 | eval $t2_cmd >> $LOG_FILE & 97 | eval $t3_cmd >> $LOG_FILE & 98 | wait 99 | 100 | else 101 | eval $t0_cmd 102 | eval $t1_cmd 103 | eval $t2_cmd 104 | eval $t3_cmd 105 | fi 106 | 107 | 108 | done 109 | 110 | cd $DEFAULT_DIR 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/tree1.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'tree1_v2.blend' 4 | element vertex 24 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 12 17 | property list uchar uint vertex_indices 18 | end_header 19 | 2.000000 0.000000 -0.000000 0.000000 -0.000000 1.000000 0.000050 0.999900 18 166 41 20 | -2.000000 4.000000 0.000000 0.000000 -0.000000 1.000000 0.499950 0.000100 18 166 41 21 | -2.000000 0.000000 -0.000000 0.000000 -0.000000 1.000000 0.499950 0.999900 18 166 41 22 | -0.000000 0.000000 -2.000000 1.000000 -0.000000 -0.000000 0.000050 0.999900 18 166 41 23 | 0.000000 4.000000 2.000000 1.000000 -0.000000 -0.000000 0.499950 0.000100 18 166 41 24 | -0.000000 0.000000 2.000000 1.000000 -0.000000 -0.000000 0.499950 0.999900 18 166 41 25 | 1.000000 2.000000 0.000000 0.000000 0.866025 0.500000 0.000050 0.500000 18 166 41 26 | -1.000000 2.500000 -0.866025 0.000000 0.866025 0.500000 0.499950 0.000100 18 166 41 27 | -1.000000 2.000000 0.000000 0.000000 0.866025 0.500000 0.499950 0.500000 18 166 41 28 | 1.000000 2.000000 0.000000 0.000000 0.866025 0.500000 0.499950 0.500000 18 166 41 29 | -1.000000 1.500000 0.866026 0.000000 0.866025 0.500000 0.000050 0.000100 18 166 41 30 | 1.000000 1.500000 0.866026 0.000000 0.866025 0.500000 0.499950 0.000100 18 166 41 31 | 0.683012 2.816987 0.707107 0.258819 0.965926 0.000000 0.499950 0.500000 18 166 41 32 | -1.366025 3.366026 0.000000 0.258819 0.965926 0.000000 0.000050 0.000100 18 166 41 33 | -0.000000 3.000000 1.414213 0.258819 0.965926 0.000000 0.499950 0.000100 18 166 41 34 | -0.683012 3.183013 -0.707106 0.258819 0.965926 -0.000000 0.499950 0.500000 18 166 41 35 | 1.366025 2.633975 0.000000 0.258819 0.965926 -0.000000 0.000050 0.000100 18 166 41 36 | 0.000000 3.000000 -1.414213 0.258819 0.965926 -0.000000 0.499950 0.000100 18 166 41 37 | 2.000000 4.000000 0.000000 0.000000 -0.000000 1.000000 0.000050 0.000100 18 166 41 38 | 0.000000 4.000000 -2.000000 1.000000 -0.000000 -0.000000 0.000050 0.000100 18 166 41 39 | 1.000000 2.500000 -0.866025 -0.000000 0.866025 0.500000 0.000050 0.000100 18 166 41 40 | -1.000000 2.000000 0.000000 0.000000 0.866025 0.500000 0.000050 0.500000 18 166 41 41 | -0.683012 3.183013 -0.707106 0.258819 0.965926 0.000000 0.000050 0.500000 18 166 41 42 | 0.683013 2.816987 0.707107 0.258819 0.965926 0.000000 0.000050 0.500000 18 166 41 43 | 3 0 1 2 44 | 3 3 4 5 45 | 3 6 7 8 46 | 3 9 10 11 47 | 3 12 13 14 48 | 3 15 16 17 49 | 3 0 18 1 50 | 3 3 19 4 51 | 3 6 20 7 52 | 3 9 21 10 53 | 3 12 22 13 54 | 3 15 23 16 55 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/road-sign-stop.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'street-lamp.blend' 4 | element vertex 28 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 16 17 | property list uchar uint vertex_indices 18 | end_header 19 | 0.000000 9.000000 -0.125000 0.707107 0.000000 -0.707107 0.200001 -5.149611 117 116 115 20 | 0.125000 0.000000 0.000000 0.707107 0.000000 -0.707107 0.400002 6.149608 117 116 115 21 | 0.000000 0.000000 -0.125000 0.707107 0.000000 -0.707107 0.200002 6.149608 117 116 115 22 | 0.125000 9.000000 0.000000 0.707107 0.000000 0.707107 0.600001 -5.149611 117 116 115 23 | -0.000000 0.000000 0.125000 0.707107 0.000000 0.707107 0.800001 6.149611 117 116 115 24 | 0.125000 0.000000 0.000000 0.707107 0.000000 0.707107 0.600001 6.149611 117 116 115 25 | 0.000000 9.000000 -0.125000 0.000000 1.000000 0.000000 0.800001 -5.149611 117 116 115 26 | -0.000000 9.000000 0.125000 0.000000 1.000000 0.000000 1.000000 -4.816704 117 116 115 27 | 0.125000 9.000000 0.000000 0.000000 1.000000 0.000000 0.800001 -4.816704 117 116 115 28 | -0.000000 9.000000 0.125000 -0.707107 0.000000 0.707107 0.600001 6.149608 117 116 115 29 | -0.125000 0.000000 -0.000000 -0.707107 0.000000 0.707107 0.400002 -5.149611 117 116 115 30 | -0.000000 0.000000 0.125000 -0.707107 0.000000 0.707107 0.600001 -5.149611 117 116 115 31 | -0.125000 9.000000 -0.000000 -0.707107 0.000000 -0.707107 0.000000 -5.149611 117 116 115 32 | 0.000000 0.000000 -0.125000 -0.707107 0.000000 -0.707107 0.200001 6.149609 117 116 115 33 | -0.125000 0.000000 -0.000000 -0.707107 0.000000 -0.707107 0.000002 6.149609 117 116 115 34 | -1.246615 8.159251 0.151373 0.000000 -0.000000 1.000000 0.000000 0.000000 184 126 103 35 | -0.543061 7.455695 0.151373 0.000000 -0.000000 1.000000 0.000000 0.000000 184 126 103 36 | 1.155471 8.159251 0.151373 0.000000 -0.000000 1.000000 0.000000 0.000000 184 126 103 37 | 0.125000 9.000000 0.000000 0.707107 0.000000 -0.707107 0.400001 -5.149611 117 116 115 38 | -0.000000 9.000000 0.125000 0.707107 -0.000000 0.707107 0.800001 -5.149610 117 116 115 39 | -0.125000 9.000000 -0.000000 0.000000 1.000000 0.000000 1.000000 -5.149611 117 116 115 40 | -0.125000 9.000000 -0.000000 -0.707107 0.000000 0.707107 0.400002 6.149608 117 116 115 41 | 0.000000 9.000000 -0.125000 -0.707107 0.000000 -0.707107 0.199999 -5.149611 117 116 115 42 | 1.155471 9.154228 0.151373 0.000000 0.000000 1.000000 0.000000 0.000000 184 126 103 43 | -1.246615 9.154228 0.151373 0.000000 0.000000 1.000000 0.000000 0.000000 184 126 103 44 | 0.451917 9.857783 0.151373 -0.000000 0.000000 1.000000 0.000000 0.000000 184 126 103 45 | -0.543061 9.857783 0.151373 -0.000000 0.000000 1.000000 0.000000 0.000000 184 126 103 46 | 0.451916 7.455695 0.151373 0.000000 0.000000 1.000000 0.000000 0.000000 184 126 103 47 | 3 0 1 2 48 | 3 3 4 5 49 | 3 6 7 8 50 | 3 9 10 11 51 | 3 12 13 14 52 | 3 15 16 17 53 | 3 0 18 1 54 | 3 3 19 4 55 | 3 6 20 7 56 | 3 9 21 10 57 | 3 12 22 13 58 | 3 17 23 24 59 | 3 25 26 24 60 | 3 24 15 17 61 | 3 16 27 17 62 | 3 23 25 24 63 | -------------------------------------------------------------------------------- /rvtgen3d-data/color_codes.txt: -------------------------------------------------------------------------------- 1 | # String, space, 6-digit hex code 2 | # 1024 lines max 3 | 4 | black 000000 5 | gray 808080 6 | grey 808080 7 | maroon 800000 8 | olive 808000 9 | green 008000 10 | teal 008080 11 | navy 000080 12 | purple 800080 13 | 14 | white ffffff 15 | silver c0c0c0 16 | red ff0000 17 | yellow ffff00 18 | lime 00ff00 19 | aqua 00ffff 20 | cyan 00ffff 21 | blue 0000ff 22 | fuchsia ff00ff 23 | magenta ff00ff 24 | 25 | aliceblue f0f8ff 26 | antiquewhite faebd7 27 | aquamarine 7fffd4 28 | azure f0ffff 29 | beige f5f5dc 30 | bisque ffe4c4 31 | blanchedalmond ffebcd 32 | blueviolet 8a2be2 33 | brown a52a2a 34 | burlywood deb887 35 | cadetblue 5f9ea0 36 | chartreuse 7fff00 37 | chocolate d2691e 38 | coral ff7f50 39 | cornflowerblue 6495ed 40 | cornsilk fff8dc 41 | crimson dc143c 42 | darkblue 00008b 43 | darkcyan 008b8b 44 | darkgoldenrod b8860b 45 | darkgray a9a9a9 46 | darkgreen 006400 47 | darkgrey a9a9a9 48 | darkkhaki bdb76b 49 | darkmagenta 8b008b 50 | darkolivegreen 556b2f 51 | darkorange ff8c00 52 | darkorchid 9932cc 53 | darkred 8b0000 54 | darksalmon e9967a 55 | darkseagreen 8fbc8f 56 | darkslateblue 483d8b 57 | darkslategray 2f4f4f 58 | darkslategrey 2f4f4f 59 | darkturquoise 00ced1 60 | darkviolet 9400d3 61 | deeppink ff1493 62 | deepskyblue 00bfff 63 | dimgray 696969 64 | dimgrey 696969 65 | dodgerblue 1e90ff 66 | firebrick b22222 67 | floralwhite fffaf0 68 | forestgreen 228b22 69 | gainsboro dcdcdc 70 | ghostwhite f8f8ff 71 | gold ffd700 72 | goldenrod daa520 73 | greenyellow adff2f 74 | honeydew f0fff0 75 | hotpink ff69b4 76 | indianred cd5c5c 77 | indigo 4b0082 78 | ivory fffff0 79 | khaki f0e68c 80 | lavender e6e6fa 81 | lavenderblush fff0f5 82 | lawngreen 7cfc00 83 | lemonchiffon fffacd 84 | lightblue add8e6 85 | lightcoral f08080 86 | lightcyan e0ffff 87 | lightgoldenrodyellow fafad2 88 | lightgray d3d3d3 89 | lightgreen 90ee90 90 | lightgrey d3d3d3 91 | lightpink ffb6c1 92 | lightsalmon ffa07a 93 | lightseagreen 20b2aa 94 | lightskyblue 87cefa 95 | lightslategray 778899 96 | lightslategrey 778899 97 | lightsteelblue b0c4de 98 | lightyellow ffffe0 99 | limegreen 32cd32 100 | linen faf0e6 101 | mediumaquamarine 66cdaa 102 | mediumblue 0000cd 103 | mediumorchid ba55d3 104 | mediumpurple 9370db 105 | mediumseagreen 3cb371 106 | mediumslateblue 7b68ee 107 | mediumspringgreen 00fa9a 108 | mediumturquoise 48d1cc 109 | mediumvioletred c71585 110 | midnightblue 191970 111 | mintcream f5fffa 112 | mistyrose ffe4e1 113 | moccasin ffe4b5 114 | navajowhite ffdead 115 | oldlace fdf5e6 116 | olivedrab 6b8e23 117 | orange ffa500 118 | orangered ff4500 119 | orchid da70d6 120 | palegoldenrod eee8aa 121 | palegreen 98fb98 122 | paleturquoise afeeee 123 | palevioletred db7093 124 | papayawhip ffefd5 125 | peachpuff ffdab9 126 | peru cd853f 127 | pink ffc0cb 128 | plum dda0dd 129 | powderblue b0e0e6 130 | rosybrown bc8f8f 131 | royalblue 4169e1 132 | saddlebrown 8b4513 133 | salmon fa8072 134 | sandybrown f4a460 135 | seagreen 2e8b57 136 | seashell fff5ee 137 | sienna a0522d 138 | skyblue 87ceeb 139 | slateblue 6a5acd 140 | slategray 708090 141 | slategrey 708090 142 | snow fffafa 143 | springgreen 00ff7f 144 | steelblue 4682b4 145 | tan d2b48c 146 | thistle d8bfd8 147 | tomato ff6347 148 | turquoise 40e0d0 149 | violet ee82ee 150 | wheat f5deb3 151 | whitesmoke f5f5f5 152 | yellowgreen 9acd32 153 | 154 | -------------------------------------------------------------------------------- /src/rvtgen3d/rvtapp.c: -------------------------------------------------------------------------------- 1 | #include "rvtapp.h" 2 | 3 | #include "main.h" 4 | 5 | #include 6 | 7 | #include 8 | 9 | float rvt_app_get_sc() { 10 | return rvt_app->sc; 11 | }; 12 | 13 | float rvt_app_get_sc_z() { 14 | return rvt_app->sc_z; 15 | }; 16 | 17 | int rvt_app_is_terrain_flat_by_default() { 18 | return (rvt_app->flags & RVT_APP_FLAG_FLAT_TERRAIN) ? 1 : 0; 19 | }; 20 | 21 | int rvt_app_get_stride_by_layer(int layer) { 22 | return rvt_app->rvt_stride[layer]; 23 | }; 24 | 25 | int rvt_app_get_conf_index_by_layer(int vbo_layer_index) { 26 | return rvt_app->rvt_vbo_conf_index[vbo_layer_index]; 27 | }; 28 | 29 | int rvt_app_is_exporting() { 30 | return rvt_app_get_exporting_struct()->exporting; 31 | }; 32 | 33 | 34 | void rvt_app_exporting_total_bytes_append(uint64_t bytes) { 35 | rvt_app_get_exporting_struct()->exporting_total_bytes += bytes; 36 | }; 37 | 38 | rvt_vbodata_t* rvt_app_get_vbodata_by_index(int index) { 39 | return &rvt_app->vbodata[index]; 40 | }; 41 | 42 | int rvt_app_get_hexcode_by_color_string(char *s, int *p_output) { 43 | 44 | for (int i = 0; i < rvt_app->color_recs_count; i++) { 45 | if (!strcmp(s, rvt_app->color_recs[i].s)) { 46 | *p_output = rvt_app->color_recs[i].hexcode; 47 | return 1; 48 | }; 49 | }; 50 | 51 | return 0; 52 | }; 53 | 54 | int rvt_app_get_rvt_style() { 55 | return rvt_app->rvt_style; 56 | }; 57 | 58 | int rvt_app_get_visstyle_index() { 59 | return rvt_app->visstyle_index; 60 | }; 61 | 62 | rvt_geodata_struct_t* rvt_app_get_geodata() { 63 | return &rvt_app->geodata; 64 | }; 65 | 66 | void rvt_app_update_history_game_bases() { 67 | // Not used in this tool 68 | }; 69 | 70 | rvt_gnote_t *rvt_get_gnote_by_point(rvt_gpoint_t *gp) { 71 | // Not used in this tool 72 | return NULL; 73 | }; 74 | 75 | void rvt_app_create_subtile_raw_vbo(int stage_i) { 76 | // Not used in this tool 77 | }; 78 | 79 | int rvt_app_are_vertices_per_frame_unlimited() { 80 | 81 | return ( (!rvt_app->tiles_initial_loading_is_passed) || (rvt_app->termination_process) || (rvt_app_is_exporting()) ); 82 | 83 | }; 84 | 85 | char *rvt_app_get_lang() { 86 | return rvt_app->user_lang; 87 | }; 88 | 89 | char *rvt_app_get_alt_lang() { 90 | return rvt_app->user_alt_lang; 91 | }; 92 | 93 | void rvt_app_create_terrain_vbo( int vbo_index, unsigned char *data, int data_count, int stride ) { 94 | // Not used in this tool 95 | }; 96 | 97 | 98 | rvt_cache_settings_t *rvt_app_get_cache_settings() { 99 | 100 | return &rvt_app->rvt_cache_settings; 101 | 102 | }; 103 | 104 | rvt_exporting_struct_t* rvt_app_get_exporting_struct() { 105 | return &rvt_app->exporting_struct; 106 | }; 107 | 108 | void rvt_app_sleep_msec(int msec) { 109 | 110 | usleep(msec*1000); 111 | 112 | }; 113 | 114 | void rvt_app_get_date(int *y, int *m, int *d, int *h, int *i, int *s) { 115 | 116 | time_t theTime = time(NULL); 117 | struct tm *aTime = localtime(&theTime); 118 | 119 | *y = aTime->tm_year + 1900; // Year is # years since 1900 120 | *m = aTime->tm_mon + 1; // Month is 0 - 11, adding 1 to get a 1-12 121 | *d = aTime->tm_mday; 122 | 123 | *h = aTime->tm_hour; 124 | *i = aTime->tm_min; 125 | *s = aTime->tm_sec; 126 | 127 | }; 128 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/treepack1.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'tree1_v2.blend' 4 | element vertex 32 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 16 17 | property list uchar uint vertex_indices 18 | end_header 19 | -5.570250 0.000000 -0.320249 -0.005025 -0.000000 -0.999987 0.000100 0.999900 18 166 41 20 | 5.573750 3.333476 -0.376250 -0.005025 -0.000000 -0.999987 0.999900 0.000100 18 166 41 21 | 5.573750 0.000000 -0.376250 -0.005025 -0.000000 -0.999987 0.999900 0.999900 18 166 41 22 | -0.320250 0.000000 -5.570251 -0.999987 -0.000000 -0.005025 0.999900 0.999900 18 166 41 23 | -0.376250 2.840366 5.573750 -0.999987 -0.000000 -0.005025 0.000100 0.000100 18 166 41 24 | -0.320251 4.316123 -5.570250 -0.999987 -0.000000 -0.005025 0.999900 0.000100 18 166 41 25 | 5.558000 0.000000 2.757999 0.005025 -0.000000 0.999987 0.000100 0.999900 18 166 41 26 | -5.585999 3.277280 2.814000 0.005025 -0.000000 0.999987 0.999900 0.000100 18 166 41 27 | -5.585999 0.000000 2.814000 0.005025 -0.000000 0.999987 0.999900 0.999900 18 166 41 28 | 5.585999 -0.000000 -2.814000 0.005025 -0.000000 0.999987 0.000100 0.999900 18 166 41 29 | -5.558000 3.277280 -2.757999 0.005025 -0.000000 0.999987 0.999900 0.000100 18 166 41 30 | -5.558000 0.000000 -2.758000 0.005025 -0.000000 0.999987 0.999900 0.999900 18 166 41 31 | -2.758000 0.000000 -5.558000 0.999987 -0.000000 0.005025 0.000100 0.999900 18 166 41 32 | -2.814000 3.355412 5.585999 0.999987 -0.000000 0.005025 0.999900 0.000100 18 166 41 33 | -2.814000 0.000000 5.586000 0.999987 -0.000000 0.005025 0.999900 0.999900 18 166 41 34 | 2.814000 0.000000 -5.585999 0.999987 -0.000000 0.005025 0.000100 0.999900 18 166 41 35 | 2.758000 3.589808 5.558000 0.999987 -0.000000 0.005025 0.999900 0.000100 18 166 41 36 | 2.758000 0.000000 5.558000 0.999987 -0.000000 0.005025 0.999900 0.999900 18 166 41 37 | -0.028000 1.999905 5.572000 -0.000000 1.000000 -0.000000 0.999900 0.499950 18 166 41 38 | -4.809345 1.999905 -5.547691 -0.000000 1.000000 -0.000000 0.000100 0.000050 18 166 41 39 | -5.599999 1.999905 5.599999 -0.000000 1.000000 -0.000000 0.999900 0.000050 18 166 41 40 | 0.028000 1.999905 -5.572000 -0.000000 1.000000 -0.000000 0.999900 0.499950 18 166 41 41 | 4.809346 1.999905 5.547690 -0.000000 1.000000 -0.000000 0.000100 0.000050 18 166 41 42 | 5.599998 1.999905 -5.600000 -0.000000 1.000000 -0.000000 0.999900 0.000050 18 166 41 43 | -5.570250 3.367600 -0.320249 -0.005025 -0.000000 -0.999987 0.000100 0.000100 18 166 41 44 | -0.376249 0.000000 5.573750 -0.999987 -0.000000 -0.005025 0.000100 0.999900 18 166 41 45 | 5.558000 4.164032 2.758000 0.005025 -0.000000 0.999987 0.000100 0.000100 18 166 41 46 | 5.585999 4.064538 -2.813999 0.005025 -0.000000 0.999987 0.000100 0.000100 18 166 41 47 | -2.757999 3.570275 -5.558000 0.999987 -0.000000 0.005025 0.000100 0.000100 18 166 41 48 | 2.814000 4.541121 -5.586000 0.999987 -0.000000 0.005025 0.000100 0.000100 18 166 41 49 | 0.027999 1.999905 -5.571999 0.000000 1.000000 -0.000000 0.000100 0.499950 18 166 41 50 | -0.027999 1.999905 5.571999 -0.000000 1.000000 -0.000000 0.000100 0.499950 18 166 41 51 | 3 0 1 2 52 | 3 3 4 5 53 | 3 6 7 8 54 | 3 9 10 11 55 | 3 12 13 14 56 | 3 15 16 17 57 | 3 18 19 20 58 | 3 21 22 23 59 | 3 0 24 1 60 | 3 3 25 4 61 | 3 6 26 7 62 | 3 9 27 10 63 | 3 12 28 13 64 | 3 15 29 16 65 | 3 18 30 19 66 | 3 21 31 22 67 | -------------------------------------------------------------------------------- /scripts/rsgeotools-planet-process-full.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if test -z "$RVT_O5M_DIR" 4 | then 5 | echo "RVT_O5M_DIR is not set. " 6 | exit 7 | fi 8 | 9 | if test -z "$RVT_SHP_ARCHIVE_DIR" 10 | then 11 | echo "RVT_SHP_ARCHIVE_DIR is not set. " 12 | exit 13 | fi 14 | 15 | if test -z "$RVT_GPAK_DIR" 16 | then 17 | echo "RVT_GPAK_DIR is not set. " 18 | exit 19 | fi 20 | 21 | 22 | if test -z "$RVT_CSV_CONF" 23 | then 24 | echo "RVT_CSV_CONF ini file is not set. " 25 | exit 26 | fi 27 | 28 | if test -z "$RVT_TEMP_DIR" 29 | then 30 | echo "RVT_TEMP_DIR is not set. " 31 | exit 32 | fi 33 | 34 | 35 | if test -z "$2" 36 | then 37 | echo "Usage: cmd PLANET_TIMESTAMP START_STAGE_INDEX" 38 | exit 39 | fi 40 | 41 | PLANET_TIMESTAMP=$1 42 | START_STAGE_INDEX=$2 43 | 44 | LOG_FILE="$RVT_GPAK_DIR/planet_process_log_file.txt" 45 | 46 | TIME_START=`date +%s` 47 | 48 | echo "" >> $LOG_FILE 49 | echo "--------------------" >> $LOG_FILE 50 | echo "Processing planet with timestamp $PLANET_TIMESTAMP, starting from stage $START_STAGE_INDEX" >> $LOG_FILE 51 | 52 | if test "0" -ge "$START_STAGE_INDEX"; then 53 | echo "[ 0 of 12] [2/0/0] Started at `date`" >> $LOG_FILE 54 | rsgeotools-process-tiles-mass.sh 2 0 0 7 11 12 14 $PLANET_TIMESTAMP 55 | fi 56 | 57 | if test "1" -ge "$START_STAGE_INDEX"; then 58 | echo "[ 1 of 12] [2/1/0] Started at `date`" >> $LOG_FILE 59 | rsgeotools-process-tiles-mass.sh 2 1 0 7 11 12 14 $PLANET_TIMESTAMP 60 | fi 61 | 62 | if test "2" -ge "$START_STAGE_INDEX"; then 63 | echo "[ 2 of 12] [2/0/1] Started at `date`" >> $LOG_FILE 64 | rsgeotools-process-tiles-mass.sh 2 0 1 7 11 12 14 $PLANET_TIMESTAMP 65 | fi 66 | 67 | if test "3" -ge "$START_STAGE_INDEX"; then 68 | echo "[ 3 of 12] [2/1/1] Started at `date`" >> $LOG_FILE 69 | rsgeotools-process-tiles-mass.sh 2 1 1 7 11 12 14 $PLANET_TIMESTAMP 70 | fi 71 | 72 | 73 | 74 | 75 | if test "4" -ge "$START_STAGE_INDEX"; then 76 | echo "[ 4 of 12] [2/2/0] Started at `date`" >> $LOG_FILE 77 | rsgeotools-process-tiles-mass.sh 2 2 0 7 11 12 14 $PLANET_TIMESTAMP 78 | fi 79 | 80 | if test "5" -ge "$START_STAGE_INDEX"; then 81 | echo "[ 5 of 12] [2/3/0] Started at `date`" >> $LOG_FILE 82 | rsgeotools-process-tiles-mass.sh 2 3 0 7 11 12 14 $PLANET_TIMESTAMP 83 | fi 84 | 85 | if test "6" -ge "$START_STAGE_INDEX"; then 86 | echo "[ 6 of 12] [2/2/1] Started at `date`" >> $LOG_FILE 87 | rsgeotools-process-tiles-mass.sh 2 2 1 7 11 12 14 $PLANET_TIMESTAMP 88 | fi 89 | 90 | if test "7" -ge "$START_STAGE_INDEX"; then 91 | echo "[ 7 of 12] [2/3/1] Started at `date`" >> $LOG_FILE 92 | rsgeotools-process-tiles-mass.sh 2 3 1 7 11 12 14 $PLANET_TIMESTAMP 93 | fi 94 | 95 | 96 | 97 | 98 | if test "8" -ge "$START_STAGE_INDEX"; then 99 | echo "[ 8 of 12] [2/0/2] Started at `date`" >> $LOG_FILE 100 | rsgeotools-process-tiles-mass.sh 2 0 2 7 11 12 14 $PLANET_TIMESTAMP 101 | fi 102 | 103 | if test "9" -ge "$START_STAGE_INDEX"; then 104 | echo "[ 9 of 12] [2/1/2] Started at `date`" >> $LOG_FILE 105 | rsgeotools-process-tiles-mass.sh 2 1 2 7 11 12 14 $PLANET_TIMESTAMP 106 | fi 107 | 108 | if test "10" -ge "$START_STAGE_INDEX"; then 109 | echo "[10 of 12] [2/2/2] Started at `date`" >> $LOG_FILE 110 | rsgeotools-process-tiles-mass.sh 2 2 2 7 11 12 14 $PLANET_TIMESTAMP 111 | fi 112 | 113 | if test "11" -ge "$START_STAGE_INDEX"; then 114 | echo "[11 of 12] [2/3/2] Started at `date`" >> $LOG_FILE 115 | rsgeotools-process-tiles-mass.sh 2 3 2 7 11 12 14 $PLANET_TIMESTAMP 116 | fi 117 | 118 | echo "Done at `date`" >> $LOG_FILE 119 | 120 | TIME_END=`date +%s` 121 | TIME_DIFF_HOURS=$(( ($TIME_END - $TIME_START)/(60*60) )) 122 | TIME_DIFF_DAYS=$(( $TIME_DIFF_HOURS/(24) )) 123 | 124 | echo "Total $TIME_DIFF_HOURS hours ($TIME_DIFF_DAYS days). " >> $LOG_FILE 125 | 126 | echo "" >> $LOG_FILE 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | WORKDIR = `pwd` 2 | 3 | CC = gcc 4 | CXX = g++ 5 | LD = g++ 6 | 7 | INC = 8 | INC_RVTGEN3D = -I src/rvtgen3d 9 | CFLAGS = -g 10 | CXXFLAGS = -g -fpermissive 11 | OUTPUT_BIN_DIR = bin 12 | SRC_DIR = src 13 | OBJ_DIR = obj 14 | 15 | all: rsgeotools 16 | 17 | clean: 18 | rm -rf $(OUTPUT_BIN_DIR) 19 | rm -rf $(OBJ_DIR) 20 | 21 | before_rsgeotools: 22 | test -d $(OUTPUT_BIN_DIR) || mkdir -p $(OUTPUT_BIN_DIR) 23 | 24 | rsgeotools: before_rsgeotools rsgeotools-conv rsgeotools-csv2rvtdata rsgeotools-tiffcompose rsgeotools-tiff2hmdata rsgeotools-o5m-get-outlines rsgeotools-tilepacker rsgeotools-rvtgen3d 25 | 26 | rsgeotools-conv: before_rsgeotools 27 | $(CXX) $(CFLAGS) $(INC) $(SRC_DIR)/conv/conv.cpp -o $(OUTPUT_BIN_DIR)/rsgeotools-conv 28 | 29 | rsgeotools-csv2rvtdata: before_rsgeotools 30 | $(CXX) $(CFLAGS) $(INC) -I$(SRC_DIR)/csv2rvtdata/ -lgeos_c $(SRC_DIR)/csv2rvtdata/csv.c $(SRC_DIR)/csv2rvtdata/csv2rvtdata.cpp -o $(OUTPUT_BIN_DIR)/rsgeotools-csv2rvtdata 31 | 32 | rsgeotools-tiffcompose: before_rsgeotools 33 | $(CXX) $(CFLAGS) $(INC) $(SRC_DIR)/tiffcompose/tiffcompose.cpp -ltiff -o $(OUTPUT_BIN_DIR)/rsgeotools-tiffcompose 34 | 35 | rsgeotools-tiff2hmdata: before_rsgeotools 36 | $(CXX) $(CFLAGS) $(INC) $(SRC_DIR)/tiff2hmdata/tiff2hmdata.cpp -ltiff -o $(OUTPUT_BIN_DIR)/rsgeotools-tiff2hmdata 37 | 38 | rsgeotools-o5m-get-outlines: before_rsgeotools 39 | $(CC) $(CFLAGS) $(INC) $(SRC_DIR)/o5m_get_outlines/o5m_get_outlines.c -o $(OUTPUT_BIN_DIR)/rsgeotools-o5m-get-outlines 40 | 41 | rsgeotools-tilepacker: before_rsgeotools 42 | $(CXX) $(CFLAGS) $(INC) $(SRC_DIR)/tilepacker/tilepacker.cpp -lz -lbz2 -o $(OUTPUT_BIN_DIR)/rsgeotools-tilepacker 43 | 44 | rsgeotools-rvtgen3d: before_rsgeotools 45 | test -d $(OBJ_DIR) || mkdir -p $(OBJ_DIR) 46 | test -d $(OBJ_DIR)/rvtgen3d || mkdir -p $(OBJ_DIR)/rvtgen3d 47 | 48 | $(CXX) $(CXXFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/clipper/clipper.cpp -o $(OBJ_DIR)/rvtgen3d/clipper.o 49 | 50 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/loader.c -o $(OBJ_DIR)/rvtgen3d/loader.o 51 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/main.c -o $(OBJ_DIR)/rvtgen3d/main.o 52 | 53 | $(CXX) $(CXXFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rs/rsboost.cpp -o $(OBJ_DIR)/rvtgen3d/rsboost.o 54 | $(CXX) $(CXXFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rs/rsgeom.cpp -o $(OBJ_DIR)/rvtgen3d/rsgeom.o 55 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rs/rsmem.c -o $(OBJ_DIR)/rvtgen3d/rsmem.o 56 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rs/rsmx.c -o $(OBJ_DIR)/rvtgen3d/rsmx.o 57 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rs/rsnoise.c -o $(OBJ_DIR)/rvtgen3d/rsnoise.o 58 | 59 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rvt.c -o $(OBJ_DIR)/rvtgen3d/rvt.o 60 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rvtapp.c -o $(OBJ_DIR)/rvtgen3d/rvtapp.o 61 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rvtexport.c -o $(OBJ_DIR)/rvtgen3d/rvtexport.o 62 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rvtgen.c -o $(OBJ_DIR)/rvtgen3d/rvtgen.o 63 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rvtloader.c -o $(OBJ_DIR)/rvtgen3d/rvtloader.o 64 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/rvtutil.c -o $(OBJ_DIR)/rvtgen3d/rvtutil.o 65 | $(CC) $(CFLAGS) $(INC_RVTGEN3D) -c $(SRC_DIR)/rvtgen3d/tileloader.c -o $(OBJ_DIR)/rvtgen3d/tileloader.o 66 | 67 | $(CXX) -o $(OUTPUT_BIN_DIR)/rsgeotools-rvtgen3d $(OBJ_DIR)/rvtgen3d/clipper.o $(OBJ_DIR)/rvtgen3d/loader.o $(OBJ_DIR)/rvtgen3d/main.o $(OBJ_DIR)/rvtgen3d/rsboost.o $(OBJ_DIR)/rvtgen3d/rsgeom.o $(OBJ_DIR)/rvtgen3d/rsmem.o $(OBJ_DIR)/rvtgen3d/rsmx.o $(OBJ_DIR)/rvtgen3d/rsnoise.o $(OBJ_DIR)/rvtgen3d/rvt.o $(OBJ_DIR)/rvtgen3d/rvtapp.o $(OBJ_DIR)/rvtgen3d/rvtexport.o $(OBJ_DIR)/rvtgen3d/rvtgen.o $(OBJ_DIR)/rvtgen3d/rvtloader.o $(OBJ_DIR)/rvtgen3d/rvtutil.o $(OBJ_DIR)/rvtgen3d/tileloader.o -m64 -lbz2 -lz -lpthread 68 | 69 | .PHONY: before_rsgeotools clean_rsgeotools 70 | -------------------------------------------------------------------------------- /scripts/rsgeotools-process-tile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test -z "$RVT_O5M_DIR" 4 | then 5 | echo "RVT_O5M_DIR is not set. " 6 | exit 7 | fi 8 | 9 | if test -z "$RVT_SHP_ARCHIVE_DIR" 10 | then 11 | echo "RVT_SHP_ARCHIVE_DIR is not set. " 12 | exit 13 | fi 14 | 15 | if test -z "$RVT_GPAK_DIR" 16 | then 17 | echo "RVT_GPAK_DIR is not set. " 18 | exit 19 | fi 20 | 21 | 22 | if test -z "$RVT_CSV_CONF" 23 | then 24 | echo "RVT_CSV_CONF ini file is not set. " 25 | exit 26 | fi 27 | 28 | if test -z "$RVT_TEMP_DIR" 29 | then 30 | echo "RVT_TEMP_DIR is not set. " 31 | exit 32 | fi 33 | 34 | 35 | if test -z "$7" 36 | then 37 | echo "Usage: cmd TOP_Z TOP_X TOP_Y PROCESS_Z SUBPAK_Z DEST_Z PLANET_TIMESTAMP" 38 | exit 39 | fi 40 | 41 | TOP_Z=$1 42 | TOP_X=$2 43 | TOP_Y=$3 44 | 45 | PROCESS_Z=$4 46 | 47 | SUBPAK_Z=$5 48 | 49 | DEST_Z=$6 50 | 51 | PLANET_TIMESTAMP=$7 52 | 53 | 54 | # DEST_Z should be 14, PROCESS_Z 11, SUBPAK_Z 12, TOP_Z must be 7 55 | 56 | DEFAULT_DIR=`pwd` 57 | TEMP_DIR="$RVT_TEMP_DIR/rvt_temp_${TOP_Z}_${TOP_X}_${TOP_Y}" 58 | 59 | SRC_Z=7 60 | 61 | mkdir -p $RVT_GPAK_DIR 62 | 63 | rm -rf $TEMP_DIR 64 | mkdir -p $TEMP_DIR 65 | 66 | cp $RVT_O5M_DIR/t${TOP_Z}_${TOP_X}_${TOP_Y}.o5m $TEMP_DIR/ 67 | cp $RVT_CSV_CONF $TEMP_DIR/ 68 | 69 | cd $TEMP_DIR 70 | 71 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh $TOP_Z $TOP_X $TOP_Y 8 72 | rm -r t7_* 73 | 74 | RVT_SINGLE_THREAD=1 rsgeotools-subdiv-o5m.sh $TOP_Z $TOP_X $TOP_Y 9 75 | rm -r t8_* 76 | 77 | rsgeotools-subdiv-o5m.sh $TOP_Z $TOP_X $TOP_Y 10 78 | rm -r t9_* 79 | 80 | rsgeotools-subdiv-o5m.sh $TOP_Z $TOP_X $TOP_Y 11 81 | rm -r t10_* 82 | 83 | 84 | tar -x -f $RVT_SHP_ARCHIVE_DIR/ocean/ocean${TOP_Z}_${TOP_X}_${TOP_Y}.tar.gz 85 | 86 | 87 | for tile_pair in `geoconv I $TOP_Z $TOP_X $TOP_Y $PROCESS_Z` 88 | do 89 | 90 | TP=$(echo $tile_pair | tr "_" " "); 91 | 92 | FILENAME=t${PROCESS_Z}_${tile_pair} 93 | 94 | OCEAN_FILENAME=ocean${PROCESS_Z}_${tile_pair} 95 | 96 | # echo "osmconvert o5m -> pbf..." 97 | osmconvert $FILENAME.o5m -o=${FILENAME}.pbf 98 | 99 | # echo "o5m -> outlines..." 100 | cat ${FILENAME}.o5m | rsgeotools-o5m-get-outlines > ${FILENAME}_outlines.txt 101 | 102 | CSV_DIR=$TEMP_DIR/csv_out 103 | 104 | CSV_DIR_OCEAN=$TEMP_DIR/csv_out_ocean 105 | 106 | # echo "ogr2ogr -> WKT..." 107 | 108 | rm -rf $CSV_DIR 109 | ogr2ogr -f CSV -t_srs EPSG:4326 $CSV_DIR $TEMP_DIR/${FILENAME}.pbf -lco GEOMETRY=AS_WKT --config OSM_CONFIG_FILE $RVT_CSV_CONF 110 | 111 | rm -rf $CSV_DIR_OCEAN 112 | OCEAN_PARAM="" 113 | if test -f "$TEMP_DIR/${OCEAN_FILENAME}.shp" 114 | then 115 | ogr2ogr -f CSV $CSV_DIR_OCEAN $TEMP_DIR/${OCEAN_FILENAME}.shp -lco GEOMETRY=AS_WKT 116 | OCEAN_PARAM="${CSV_DIR_OCEAN}/${OCEAN_FILENAME}.csv" 117 | fi 118 | 119 | # echo "geocsv2db (b, a, l, p) $PROCESS_Z $TP $DEST_Z..." 120 | 121 | rsgeotools-csv2rvtdata b $PROCESS_Z $TP $DEST_Z ${CSV_DIR}/multipolygons.csv ${FILENAME}_outlines.txt 122 | rsgeotools-csv2rvtdata a $PROCESS_Z $TP $DEST_Z ${CSV_DIR}/multipolygons.csv $OCEAN_PARAM 123 | rsgeotools-csv2rvtdata l $PROCESS_Z $TP $DEST_Z ${CSV_DIR}/lines.csv 124 | rsgeotools-csv2rvtdata p $PROCESS_Z $TP $DEST_Z ${CSV_DIR}/points.csv 125 | 126 | rm ${FILENAME}.pbf 127 | 128 | if test -z "$RVT_KEEP_TEMP_DATA" 129 | then 130 | rm ${FILENAME}.o5m 131 | rm -f ${FILENAME}_outlines.txt 132 | rm -f ${OCEAN_FILENAME}* 133 | fi 134 | 135 | done 136 | 137 | echo "geotilepacker g $TOP_Z $TOP_X $TOP_Y $DEST_Z..." 138 | 139 | geotilepacker_cmd="rsgeotools-tilepacker g $TOP_Z $TOP_X $TOP_Y $SUBPAK_Z $DEST_Z 256 $PLANET_TIMESTAMP" 140 | echo "Executing: $geotilepacker_cmd" 141 | eval $geotilepacker_cmd 142 | 143 | cp ${TOP_Z}_${TOP_X}_${TOP_Y}_g.gpak $RVT_GPAK_DIR/ 144 | 145 | if test -z "$RVT_KEEP_TEMP_DATA" 146 | then 147 | rm *.data 148 | fi 149 | 150 | cd $DEFAULT_DIR 151 | 152 | if test -z "$RVT_KEEP_TEMP_DATA" 153 | then 154 | rm -r $TEMP_DIR 155 | fi 156 | 157 | 158 | -------------------------------------------------------------------------------- /src/tiff2hmdata/tiff2hmdata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2020, Roman Shuvalov, www.romanshuvalov.com 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | #include 40 | 41 | #include 42 | 43 | using namespace std; 44 | 45 | char *filename; 46 | char *out_filename; 47 | 48 | 49 | 50 | void DummyHandler(const char* module, const char* fmt, va_list ap) 51 | { 52 | // ignore errors and warnings (or handle them your own way) 53 | }; 54 | 55 | int main(int argc, char* argv[]) { 56 | 57 | TIFFSetWarningHandler(DummyHandler); 58 | 59 | if (argc != 3) { 60 | cerr << "Usage: " << argv[0] << " FILE.TIFF OUTPUT_FILENAME" << endl; 61 | return -1; 62 | } 63 | 64 | filename = argv[1]; 65 | out_filename = argv[2]; 66 | 67 | 68 | printf("Converting %s to %s: ", filename, out_filename); 69 | 70 | FILE *fp = fopen(filename, "rb"); 71 | if (!fp) { 72 | cout << "FP is null" << endl; 73 | return -1; 74 | }; 75 | fclose(fp); 76 | 77 | 78 | TIFF *tif=TIFFOpen(filename, "r"); 79 | fp = fopen(out_filename, "wb"); 80 | 81 | 82 | uint32_t width = 0, height = 0, bits_per_sample = 0, samples_per_pixel = 0, sample_format = 0; 83 | 84 | 85 | TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); // uint32 width; 86 | TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); // uint32 height; 87 | 88 | TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); 89 | TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel); 90 | TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &sample_format); 91 | 92 | 93 | printf("(%d x %d, %d bit) ", width, height, bits_per_sample); 94 | 95 | if ( (bits_per_sample != 16) || (sample_format != 2) || (samples_per_pixel != 1) ) { 96 | printf("ERROR: Bad format. Aborted. \n\n"); 97 | fclose(fp); 98 | TIFFClose(tif); 99 | return -1; 100 | } 101 | 102 | 103 | int16_t *buf; 104 | tsize_t scanline = TIFFScanlineSize(tif); 105 | 106 | 107 | buf = (int16_t*) _TIFFmalloc(scanline); 108 | for (uint32_t row = 0; row < height; row++) { 109 | TIFFReadScanline(tif, buf, row); 110 | 111 | 112 | for (int i = 0; i < width; i++) { 113 | buf[i] /= 2; 114 | } 115 | 116 | fwrite( buf, scanline, 1, fp ); 117 | 118 | }; 119 | _TIFFfree(buf); 120 | 121 | 122 | 123 | TIFFClose(tif); 124 | fclose(fp); 125 | 126 | printf("Done.\n"); 127 | 128 | return 0; 129 | } 130 | -------------------------------------------------------------------------------- /src/rvtgen3d/main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H_INCLUDED 2 | #define MAIN_H_INCLUDED 3 | 4 | 5 | #include "rs/rsdebug.h" 6 | 7 | #include "rs/rsthread.h" 8 | 9 | #include "rs/rsgeom.h" 10 | #include "rs/rsmx.h" 11 | 12 | #include "rs/rsmem.h" 13 | 14 | #include "rvtexport.h" 15 | #include "rvttypes.h" 16 | 17 | 18 | #ifndef RS_VBO_UNSIGNED_SHORT 19 | #define RS_VBO_UNSIGNED_SHORT 1 20 | #endif 21 | 22 | #ifndef RS_VBO_CONF_444C 23 | #define RS_VBO_CONF_444C 2 24 | #endif 25 | 26 | #ifndef RS_VBO_CONF_USER 27 | #define RS_VBO_CONF_USER 16 28 | #endif 29 | 30 | 31 | #define RVT_APP_VBO_CONF_20 0 32 | #define RVT_APP_VBO_CONF_16 1 33 | #define RVT_APP_VBO_CONF_BUILDING 2 34 | 35 | 36 | // ---------- 37 | 38 | 39 | enum { 40 | VBODATA_TEMP = 0, 41 | VBODATA_TEMP_WIRE, 42 | VBODATA_RESERVED1, 43 | VBODATA_RESERVED2, 44 | 45 | 46 | VBODATA_BUILDING_ROOF_PART_1, 47 | VBODATA_BUILDING_ROOF_PART_2, 48 | VBODATA_BUILDING_CONSTRUCTION_PART, 49 | 50 | VBODATA_BUILDING_ENTRANCE_1, 51 | 52 | VBODATA_ROOF_SHAPE_DOME, 53 | VBODATA_ROOF_SHAPE_ONION, 54 | 55 | VBODATA_ROOF_RURAL_01, 56 | VBODATA_ROOF_RURAL_02, 57 | 58 | VBODATA_POWER_TOWER, 59 | VBODATA_POWER_TOWER_METAL, 60 | VBODATA_MINOR_TOWER, 61 | 62 | VBODATA_TREE1, 63 | VBODATA_TREEPACK1, 64 | VBODATA_BUSH1, 65 | 66 | VBODATA_BRIDGE_END1, 67 | VBODATA_BRIDGE_GARBAGE1, 68 | VBODATA_BRIDGE_BASE1, 69 | 70 | VBODATA_STREET_LAMP2, 71 | VBODATA_STREET_LAMP1_FOOTWAY, 72 | VBODATA_RAILWAY_TOWER, 73 | 74 | VBODATA_TRAFFIC_LIGHT, 75 | 76 | VBODATA_ROAD_SIGN_GIVE_WAY, 77 | VBODATA_ROAD_SIGN_STOP, 78 | 79 | VBODATA_HOUSE01, 80 | VBODATA_HOUSE02, 81 | VBODATA_HOUSE03, 82 | VBODATA_HOUSE04, 83 | 84 | RVT_APP_VBODATA_COUNT 85 | 86 | }; 87 | 88 | 89 | // Colors 90 | 91 | #define RVT_APP_COLOR_REC_STRING_LEN 28 92 | 93 | typedef struct rs_color_rec_t { 94 | char s[RVT_APP_COLOR_REC_STRING_LEN]; 95 | uint32_t hexcode; 96 | } rs_color_rec_t; 97 | 98 | #define RVT_APP_MAX_COLOR_RECS 1024 99 | 100 | 101 | void gd_append(int tile_i, int layer_i, int hdr_len, unsigned char *content_header, int data_len, unsigned char *content_data); 102 | 103 | 104 | #define RVT_APP_FLAG_FLAT_TERRAIN 0x01 105 | #define RVT_APP_FLAG_DROP_NO_OUTER_RING 0x02 106 | #define RVT_APP_FLAG_DISABLE_TIMESTAMP_FOLDERS 0x04 107 | 108 | #define VISSTYLE_INDEX_DEFAULT (1) 109 | #define VISSTYLE_INDEX_WINTER (2) 110 | 111 | 112 | // Game Registry 113 | 114 | typedef struct rvt_app_t { 115 | 116 | int flags; 117 | 118 | int termination_process; 119 | 120 | struct rvt_exporting_struct_t exporting_struct; 121 | 122 | int current_tile_ix; 123 | int current_tile_iy; 124 | int current_tile_i; 125 | int current_subtile_i; 126 | 127 | char user_lang[3]; // e.g. 'ru\0' 128 | char user_alt_lang[3]; 129 | 130 | // RVT Constants 131 | int rvt_stride[RVT_SUBTILES_VBO_LAYERS_COUNT]; 132 | int rvt_vbo_conf_index[RVT_SUBTILES_VBO_LAYERS_COUNT]; 133 | 134 | // GeoData 135 | struct rvt_geodata_struct_t geodata; 136 | 137 | rvt_gpoint_t *highlighted_building_point; 138 | int highlighted_building_tile_i; 139 | 140 | rvt_gpoint_t *editor_building_point; 141 | int editor_building_tile_i; 142 | 143 | float sc; 144 | float sc_z; 145 | float sc_heightmap_z; 146 | 147 | 148 | // Color codes 149 | rs_color_rec_t color_recs[RVT_APP_MAX_COLOR_RECS]; 150 | int color_recs_count; 151 | 152 | int tiles_are_ready; // Everything is loaded. 153 | int tiles_initial_loading_is_passed; 154 | int tiles_loader_progress; 155 | 156 | 157 | rvt_vbodata_t vbodata[RVT_APP_VBODATA_COUNT]; 158 | 159 | int visstyle_index; 160 | 161 | rvt_cache_settings_t rvt_cache_settings; 162 | char output_dir[255]; 163 | 164 | int rvt_style; 165 | 166 | 167 | } rvt_app_t; 168 | 169 | 170 | extern rvt_app_t *rvt_app; 171 | 172 | 173 | void rvt_app_reg_init(); 174 | 175 | void GameProcess(); 176 | 177 | 178 | void rvtgen3d_init(int argc, char **argv); 179 | void rvtgen3d_generate(); 180 | void rvtgen3d_term(); 181 | 182 | void rvt_app_destroy_tile(int tile_i); 183 | 184 | void rvt_app_destroy_tile_geodata(int tile_i); 185 | void rvt_app_destroy_subtile_gstuff(int subtile_i); 186 | 187 | void rvt_app_clear_tile_cache(); 188 | 189 | void rvt_app_destroy_all_tiles(); 190 | 191 | void rvt_app_street_labels_update(int manually); 192 | 193 | 194 | void rvt_app_export_process(); 195 | 196 | 197 | void rvt_app_test_export(); 198 | 199 | #endif // MAIN_H_INCLUDED 200 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/roof-shape-dome.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.79 (sub 0) - www.blender.org, source file: 'building-roof-part1.blend' 4 | element vertex 41 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 40 17 | property list uchar uint vertex_indices 18 | end_header 19 | -0.850648 0.525736 0.000000 -0.850642 0.525712 0.000000 0.170958 0.110957 209 206 222 20 | -0.723607 0.447219 0.525725 -0.723594 0.447188 0.525712 0.205948 0.290487 209 206 222 21 | -0.425323 0.850654 0.309011 -0.425306 0.850642 0.309000 0.076223 0.290487 209 206 222 22 | -0.425323 0.850654 -0.309011 -0.425306 0.850642 -0.309000 0.049904 0.110958 209 206 222 23 | 0.000000 1.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.290488 209 206 222 24 | 0.688189 0.525736 -0.499997 0.688162 0.525712 -0.499985 0.529984 0.328130 209 206 222 25 | 0.276388 0.447220 -0.850649 0.276376 0.447218 -0.850642 0.591284 0.157995 209 206 222 26 | 0.162456 0.850654 -0.499995 0.162450 0.850642 -0.499985 0.670907 0.310518 209 206 222 27 | -0.262869 0.525738 -0.809012 -0.262856 0.525712 -0.808985 0.860111 0.678452 209 206 222 28 | -0.723607 0.447219 -0.525725 -0.723594 0.447188 -0.525712 0.867586 0.873657 209 206 222 29 | -0.425323 0.850654 -0.309011 -0.425306 0.850642 -0.309000 0.739342 0.805981 209 206 222 30 | 0.162456 0.850654 -0.499995 0.162450 0.850642 -0.499985 0.739342 0.587779 209 206 222 31 | 0.000000 1.000000 0.000000 0.000000 1.000000 0.000000 0.662122 0.719393 209 206 222 32 | 0.162456 0.850654 0.499995 0.162450 0.850642 0.499985 0.401464 0.696446 209 206 222 33 | 0.525730 0.850652 0.000000 0.525712 0.850642 0.000000 0.401465 0.914649 209 206 222 34 | 0.000000 1.000000 0.000000 0.000000 1.000000 0.000000 0.324244 0.783034 209 206 222 35 | 0.525730 0.850652 0.000000 0.525712 0.850642 0.000000 0.588540 0.502428 209 206 222 36 | 0.000000 1.000000 0.000000 0.000000 1.000000 0.000000 0.690904 0.454529 209 206 222 37 | -0.951058 0.000000 0.309013 -0.932035 0.221717 0.286569 0.324244 0.179530 209 206 222 38 | -0.587786 0.000000 0.809017 -0.560564 0.221717 0.797845 0.324244 0.401445 209 206 222 39 | 0.587786 0.000000 -0.809017 0.585559 0.221717 -0.779687 0.449006 0.136219 209 206 222 40 | -0.587786 0.000000 -0.809017 -0.560564 0.221717 -0.797845 1.000000 0.793651 209 206 222 41 | -0.951058 0.000000 -0.309013 -0.932035 0.221717 -0.286569 0.965684 0.992380 209 206 222 42 | 0.951058 0.000000 -0.309013 0.922483 0.221717 -0.315958 0.366639 0.328131 209 206 222 43 | 0.688189 0.525736 0.499997 0.688162 0.525712 0.499985 0.522234 0.823976 209 206 222 44 | 0.894426 0.447216 0.000000 0.894406 0.447188 0.000000 0.529709 1.000000 209 206 222 45 | 0.894426 0.447216 0.000000 0.894406 0.447188 0.000000 0.451152 0.484492 209 206 222 46 | -0.850648 0.525736 0.000000 -0.850642 0.525712 0.000000 0.804589 0.999998 209 206 222 47 | 0.000000 0.000000 -1.000000 -0.015442 0.221717 -0.974975 1.000000 0.575448 209 206 222 48 | 0.276388 0.447220 -0.850649 0.276376 0.447218 -0.850642 0.867586 0.502428 209 206 222 49 | 0.951058 0.000000 0.309013 0.922483 0.221717 0.315958 0.324244 0.502428 209 206 222 50 | 0.000000 0.000000 1.000000 -0.015442 0.221717 0.974975 0.627806 0.510047 209 206 222 51 | 0.587786 0.000000 0.809017 0.585559 0.221717 0.779687 0.662122 0.708775 209 206 222 52 | 0.276388 0.447220 0.850649 0.276376 0.447218 0.850642 0.529708 0.628770 209 206 222 53 | -0.951058 0.000000 -0.309013 -0.932035 0.221717 -0.286569 0.297925 0.000000 209 206 222 54 | 0.951058 0.000000 0.309013 0.922483 0.221717 0.315958 0.662122 0.926979 209 206 222 55 | -0.262869 0.525738 0.809012 -0.262856 0.525712 0.808985 0.466709 0.502428 209 206 222 56 | 0.000000 0.000000 1.000000 -0.015442 0.221717 0.974975 0.297924 0.580977 209 206 222 57 | -0.262869 0.525738 0.809012 -0.262856 0.525712 0.808985 0.170958 0.470018 209 206 222 58 | 0.000000 0.000000 -1.000000 -0.015442 0.221717 -0.974975 0.539882 0.000000 209 206 222 59 | 0.162456 0.850654 0.499995 0.162450 0.850642 0.499985 0.049904 0.470018 209 206 222 60 | 3 0 1 2 61 | 3 3 0 2 62 | 3 3 2 4 63 | 3 5 6 7 64 | 3 8 9 10 65 | 3 11 8 10 66 | 3 11 10 12 67 | 3 13 14 15 68 | 3 16 5 7 69 | 3 16 7 17 70 | 3 18 19 1 71 | 3 20 6 5 72 | 3 21 22 9 73 | 3 23 20 5 74 | 3 24 25 14 75 | 3 23 5 26 76 | 3 13 24 14 77 | 3 22 27 9 78 | 3 28 21 8 79 | 3 28 8 29 80 | 3 30 23 26 81 | 3 18 1 0 82 | 3 31 32 33 83 | 3 34 18 0 84 | 3 21 9 8 85 | 3 32 35 24 86 | 3 31 33 36 87 | 3 32 24 33 88 | 3 19 37 38 89 | 3 19 38 1 90 | 3 20 39 6 91 | 3 36 33 13 92 | 3 35 25 24 93 | 3 29 8 11 94 | 3 9 27 10 95 | 3 2 38 40 96 | 3 2 40 4 97 | 3 26 5 16 98 | 3 33 24 13 99 | 3 1 38 2 100 | -------------------------------------------------------------------------------- /conf/osm-conf.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for OSM import 3 | # 4 | 5 | # put here the name of keys for ways that are assumed to be polygons if they are closed 6 | # see http://wiki.openstreetmap.org/wiki/Map_Features 7 | closed_ways_are_polygons=aeroway,amenity,boundary,building,building:part,craft,geological,historic,landuse,leisure,military,natural,office,place,shop,sport,tourism,waterway 8 | 9 | # comment to avoid laundering of keys ( ':' turned into '_' ) 10 | attribute_name_laundering=yes 11 | 12 | # uncomment to report all nodes, including the ones without any (significant) tag 13 | #report_all_nodes=yes 14 | 15 | # uncomment to report all ways, including the ones without any (significant) tag 16 | #report_all_ways=yes 17 | 18 | [points] 19 | # common attributes 20 | osm_id=yes 21 | osm_version=no 22 | osm_timestamp=no 23 | osm_uid=no 24 | osm_user=no 25 | osm_changeset=no 26 | 27 | # keys to report as OGR fields 28 | attributes=name,type 29 | # keys that, alone, are not significant enough to report a node as a OGR point 30 | unsignificant=created_by,converted_by,source,time,ele,attribution 31 | # keys that should NOT be reported in the "other_tags" field 32 | ignore=created_by,converted_by,source,source:,source_ref,lacounty:,gnis:,tiger:,NHD:,nhd:,time,ele,note,openGeoDB:,fixme,FIXME,is_in,is_in:,wikipedia,wikipedia:,wikidata,wikidata:,website,website:,media,media:,description,description: 33 | # uncomment to avoid creation of "other_tags" field 34 | # other_tags=y 35 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 36 | all_tags=yes 37 | 38 | [lines] 39 | # common attributes 40 | osm_id=yes 41 | osm_version=no 42 | osm_timestamp=no 43 | osm_uid=no 44 | osm_user=no 45 | osm_changeset=no 46 | 47 | # keys to report as OGR fields 48 | attributes=name,type 49 | 50 | # type of attribute 'foo' can be changed with something like 51 | #foo_type=Integer/Real/String/DateTime 52 | 53 | # keys that should NOT be reported in the "other_tags" field 54 | ignore=created_by,converted_by,source,source:,source_ref,lacounty:,gnis:,tiger:,NHD:,nhd:,time,ele,note,openGeoDB:,fixme,FIXME,is_in,is_in:,wikipedia,wikipedia:,wikidata,wikidata:,website,website:,media,media:,description,description: 55 | # uncomment to avoid creation of "other_tags" field 56 | #other_tags=no 57 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 58 | all_tags=yes 59 | 60 | #computed_attributes must appear before the keywords _type and _sql 61 | computed_attributes=z_order 62 | z_order_type=Integer 63 | # Formula based on https://github.com/openstreetmap/osm2pgsql/blob/master/style.lua#L13 64 | # [foo] is substituted by value of tag foo. When substitution is not wished, the [ character can be escaped with \[ in literals 65 | z_order_sql="SELECT (CASE [highway] WHEN 'minor' THEN 3 WHEN 'road' THEN 3 WHEN 'unclassified' THEN 3 WHEN 'residential' THEN 3 WHEN 'tertiary_link' THEN 4 WHEN 'tertiary' THEN 4 WHEN 'secondary_link' THEN 6 WHEN 'secondary' THEN 6 WHEN 'primary_link' THEN 7 WHEN 'primary' THEN 7 WHEN 'trunk_link' THEN 8 WHEN 'trunk' THEN 8 WHEN 'motorway_link' THEN 9 WHEN 'motorway' THEN 9 ELSE 0 END) + (CASE WHEN [bridge] IN ('yes', 'true', '1') THEN 10 ELSE 0 END) + (CASE WHEN [tunnel] IN ('yes', 'true', '1') THEN -10 ELSE 0 END) + (CASE WHEN [railway] IS NOT NULL THEN 5 ELSE 0 END) + (CASE WHEN [layer] IS NOT NULL THEN 10 * CAST([layer] AS INTEGER) ELSE 0 END)" 66 | 67 | [multipolygons] 68 | # common attributes 69 | # note: for multipolygons, osm_id=yes instantiates a osm_id field for the id of relations 70 | # and a osm_way_id field for the id of closed ways. Both fields are exclusively set. 71 | osm_id=yes 72 | osm_version=no 73 | osm_timestamp=no 74 | osm_uid=no 75 | osm_user=no 76 | osm_changeset=no 77 | 78 | # keys to report as OGR fields 79 | attributes=name,type,building,building:part 80 | # keys that should NOT be reported in the "other_tags" field 81 | ignore=created_by,converted_by,source,source:,source_ref,lacounty:,gnis:,tiger:,NHD:,nhd:,time,ele,note,openGeoDB:,fixme,FIXME,is_in,is_in:,wikipedia,wikipedia:,wikidata,wikidata:,website,website:,media,media:,description,description: 82 | # uncomment to avoid creation of "other_tags" field 83 | #other_tags=no 84 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 85 | all_tags=yes 86 | 87 | [multilinestrings] 88 | # common attributes 89 | osm_id=yes 90 | osm_version=no 91 | osm_timestamp=no 92 | osm_uid=no 93 | osm_user=no 94 | osm_changeset=no 95 | 96 | # keys to report as OGR fields 97 | attributes=name,type 98 | # keys that should NOT be reported in the "other_tags" field 99 | ignore=created_by,converted_by,source,source:,source_ref,lacounty:,gnis:,tiger:,NHD:,nhd:,time,ele,note,openGeoDB:,fixme,FIXME,is_in,is_in:,wikipedia,wikipedia:,wikidata,wikidata:,website,website:,media,media:,description,description: 100 | # uncomment to avoid creation of "other_tags" field 101 | #other_tags=no 102 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 103 | #all_tags=yes 104 | 105 | [other_relations] 106 | # common attributes 107 | osm_id=yes 108 | osm_version=no 109 | osm_timestamp=no 110 | osm_uid=no 111 | osm_user=no 112 | osm_changeset=no 113 | 114 | # keys to report as OGR fields 115 | attributes=name,type 116 | # keys that should NOT be reported in the "other_tags" field 117 | ignore=created_by,converted_by,source,source:,source_ref,lacounty:,gnis:,tiger:,NHD:,nhd:,time,ele,note,openGeoDB:,fixme,FIXME,is_in,is_in:,wikipedia,wikipedia:,wikidata,wikidata:,website,website:,media,media:,description,description: 118 | # uncomment to avoid creation of "other_tags" field 119 | #other_tags=no 120 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 121 | #all_tags=yes 122 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/building-roof-part2.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'building-roof-part1.blend' 4 | element vertex 56 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 28 17 | property list uchar uint vertex_indices 18 | end_header 19 | -1.125000 1.260000 -1.125000 0.000000 0.000000 -1.000000 0.000000 1.000000 189 159 141 20 | 1.125000 0.840000 -1.125000 0.000000 0.000000 -1.000000 0.166667 0.500000 189 159 141 21 | -1.125000 0.840000 -1.125000 0.000000 0.000000 -1.000000 0.166667 1.000000 189 159 141 22 | -1.125000 1.260000 -1.125000 0.000000 1.000000 -0.000000 0.500000 0.500000 189 159 141 23 | 1.125000 1.260000 1.125000 0.000000 1.000000 -0.000000 0.000000 0.000000 189 159 141 24 | 1.125000 1.260000 -1.125000 0.000000 1.000000 -0.000000 0.500000 0.000000 189 159 141 25 | 1.125000 1.260000 1.125000 0.000000 -0.000000 1.000000 0.833333 0.000000 189 159 141 26 | -1.125000 0.840000 1.125000 0.000000 -0.000000 1.000000 0.666667 0.500000 189 159 141 27 | 1.125000 0.840000 1.125000 0.000000 -0.000000 1.000000 0.666667 0.000000 189 159 141 28 | -0.750000 0.840000 -0.750000 0.000000 0.000000 -1.000000 0.500000 0.500000 189 159 141 29 | 0.750000 0.000000 -0.750000 0.000000 0.000000 -1.000000 1.000000 0.000000 189 159 141 30 | -0.750000 0.000000 -0.750000 0.000000 0.000000 -1.000000 1.000000 0.500000 189 159 141 31 | -0.750000 0.840000 0.750000 -1.000000 0.000000 0.000000 0.000000 1.000000 189 159 141 32 | -0.750000 0.000000 -0.750000 -1.000000 0.000000 0.000000 0.500000 0.500000 189 159 141 33 | -0.750000 0.000000 0.750000 -1.000000 0.000000 0.000000 0.500000 1.000000 189 159 141 34 | 0.750000 0.840000 0.750000 0.000000 -0.000000 1.000000 0.500000 0.000000 189 159 141 35 | -0.750000 0.000000 0.750000 0.000000 -0.000000 1.000000 0.000000 0.500000 189 159 141 36 | 0.750000 0.000000 0.750000 0.000000 -0.000000 1.000000 0.000000 0.000000 189 159 141 37 | 0.750000 0.840000 -0.750000 1.000000 -0.000000 0.000000 0.500000 1.000000 189 159 141 38 | 0.750000 0.000000 0.750000 1.000000 -0.000000 0.000000 1.000000 0.500000 189 159 141 39 | 0.750000 0.000000 -0.750000 1.000000 -0.000000 0.000000 1.000000 1.000000 189 159 141 40 | -1.125000 1.260000 1.125000 -1.000000 0.000000 0.000000 0.833333 0.500000 189 159 141 41 | -1.125000 0.840000 -1.125000 -1.000000 0.000000 0.000000 1.000000 0.000000 189 159 141 42 | -1.125000 0.840000 1.125000 -1.000000 0.000000 0.000000 1.000000 0.500000 189 159 141 43 | 1.125000 1.260000 -1.125000 1.000000 -0.000000 0.000000 0.500000 0.500000 189 159 141 44 | 1.125000 0.840000 1.125000 1.000000 -0.000000 0.000000 0.666667 0.000000 189 159 141 45 | 1.125000 0.840000 -1.125000 1.000000 -0.000000 0.000000 0.666667 0.500000 189 159 141 46 | -0.589327 2.166026 0.711759 -1.000000 0.000000 0.000000 0.200000 1.000000 177 175 189 47 | -0.589327 1.004438 0.444738 -1.000000 0.000000 0.000000 0.000000 0.000000 177 175 189 48 | -0.589327 1.004438 0.711759 -1.000000 0.000000 0.000000 0.200000 0.000000 177 175 189 49 | -0.589327 2.166026 0.444738 0.000000 0.000000 -1.000000 0.400000 0.000000 177 175 189 50 | -0.322306 1.004438 0.444738 0.000000 0.000000 -1.000000 0.600000 1.000000 177 175 189 51 | -0.589327 1.004438 0.444738 0.000000 0.000000 -1.000000 0.400000 1.000000 177 175 189 52 | -0.322306 2.166026 0.444738 1.000000 -0.000000 0.000000 0.400000 1.000000 177 175 189 53 | -0.322306 1.004438 0.711759 1.000000 -0.000000 0.000000 0.200000 0.000000 177 175 189 54 | -0.322306 1.004438 0.444738 1.000000 -0.000000 0.000000 0.400000 0.000000 177 175 189 55 | -0.322306 2.166026 0.711759 0.000000 -0.000000 1.000000 0.600000 0.000000 177 175 189 56 | -0.589327 1.004438 0.711759 0.000000 -0.000000 1.000000 0.800000 1.000000 177 175 189 57 | -0.322306 1.004438 0.711759 0.000000 -0.000000 1.000000 0.600000 1.000000 177 175 189 58 | -0.589327 2.166026 0.444738 0.000000 1.000000 -0.000000 1.000000 0.229875 177 175 189 59 | -0.322306 2.166026 0.711759 0.000000 1.000000 -0.000000 0.800000 0.000000 177 175 189 60 | -0.322306 2.166026 0.444738 0.000000 1.000000 -0.000000 1.000000 0.000000 177 175 189 61 | 1.125000 1.260000 -1.125000 0.000000 0.000000 -1.000000 0.000000 0.500000 189 159 141 62 | -1.125000 1.260000 1.125000 0.000000 1.000000 0.000000 0.000000 0.500000 189 159 141 63 | -1.125000 1.260000 1.125000 0.000000 0.000000 1.000000 0.833333 0.500000 189 159 141 64 | 0.750000 0.840000 -0.750000 0.000000 0.000000 -1.000000 0.500000 0.000000 189 159 141 65 | -0.750000 0.840000 -0.750000 -1.000000 0.000000 0.000000 0.000000 0.500000 189 159 141 66 | -0.750000 0.840000 0.750000 0.000000 0.000000 1.000000 0.500000 0.500000 189 159 141 67 | 0.750000 0.840000 0.750000 1.000000 -0.000000 0.000000 0.500000 0.500000 189 159 141 68 | -1.125000 1.260000 -1.125000 -1.000000 0.000000 0.000000 0.833333 0.000000 189 159 141 69 | 1.125000 1.260000 1.125000 1.000000 -0.000000 0.000000 0.500000 0.000000 189 159 141 70 | -0.589327 2.166026 0.444738 -1.000000 0.000000 0.000000 0.000000 1.000000 177 175 189 71 | -0.322306 2.166026 0.444738 0.000000 0.000000 -1.000000 0.600000 0.000000 177 175 189 72 | -0.322306 2.166026 0.711759 1.000000 -0.000000 0.000000 0.200000 1.000000 177 175 189 73 | -0.589327 2.166026 0.711759 0.000000 0.000000 1.000000 0.800000 0.000000 177 175 189 74 | -0.589327 2.166026 0.711759 0.000000 1.000000 0.000000 0.800000 0.229876 177 175 189 75 | 3 0 1 2 76 | 3 3 4 5 77 | 3 6 7 8 78 | 3 9 10 11 79 | 3 12 13 14 80 | 3 15 16 17 81 | 3 18 19 20 82 | 3 21 22 23 83 | 3 24 25 26 84 | 3 27 28 29 85 | 3 30 31 32 86 | 3 33 34 35 87 | 3 36 37 38 88 | 3 39 40 41 89 | 3 0 42 1 90 | 3 3 43 4 91 | 3 6 44 7 92 | 3 9 45 10 93 | 3 12 46 13 94 | 3 15 47 16 95 | 3 18 48 19 96 | 3 21 49 22 97 | 3 24 50 25 98 | 3 27 51 28 99 | 3 30 52 31 100 | 3 33 53 34 101 | 3 36 54 37 102 | 3 39 55 40 103 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/building-roof-part1.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'building-roof-part1.blend' 4 | element vertex 58 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 26 17 | property list uchar uint vertex_indices 18 | end_header 19 | 1.000000 2.000000 -0.999999 1.000000 -0.000000 0.000000 0.498999 0.335335 0 255 0 20 | 1.000000 0.000000 1.000000 1.000000 -0.000000 0.000000 0.002002 0.665666 0 255 0 21 | 1.000000 0.000000 -1.000000 1.000000 -0.000000 0.000000 0.498999 0.665666 0 255 0 22 | -0.000001 2.500000 1.000000 -0.000000 -0.000000 1.000000 0.498999 0.002002 0 255 0 23 | -1.000000 0.000000 1.000000 -0.000000 -0.000000 1.000000 0.498999 0.332332 0 255 0 24 | 1.000000 0.000000 1.000000 -0.000000 -0.000000 1.000000 0.002002 0.332332 0 255 0 25 | -1.000000 0.000000 1.000000 -1.000000 -0.000000 -0.000000 0.998999 0.335335 0 255 0 26 | -1.000000 2.000000 -1.000000 -1.000000 -0.000000 -0.000000 0.502002 0.665666 0 255 0 27 | -1.000000 0.000000 -1.000000 -1.000000 -0.000000 -0.000000 0.998999 0.665666 0 255 0 28 | 0.000000 2.500000 -1.000000 0.000000 0.000000 -1.000000 0.002002 0.998999 0 255 0 29 | -1.000000 0.000000 -1.000000 0.000000 0.000000 -1.000000 0.498999 0.668669 0 255 0 30 | -1.000000 2.000000 -1.000000 0.000000 0.000000 -1.000000 0.498999 0.998999 0 255 0 31 | 1.000000 2.000000 -0.999999 0.000000 0.000000 -1.000000 0.001001 0.667668 0 255 0 32 | 1.000000 0.000000 -1.000000 0.000000 0.000000 -1.000000 0.001001 0.997998 0 255 0 33 | 0.000000 2.500000 -1.000000 0.000000 0.000000 -1.000000 0.497998 0.667668 0 255 0 34 | 1.000000 0.000000 1.000000 -0.000001 -0.000000 1.000000 0.998999 0.002002 0 255 0 35 | 0.999999 2.000000 1.000001 -0.000001 -0.000000 1.000000 0.998999 0.332332 0 255 0 36 | -0.000001 2.500000 1.000000 -0.000001 -0.000000 1.000000 0.502002 0.332332 0 255 0 37 | 1.000000 2.000000 -0.999999 1.000000 0.000000 0.000001 0.501001 0.664665 0 255 0 38 | 0.999999 2.000000 1.000001 1.000000 0.000000 0.000001 0.501001 0.334334 0 255 0 39 | 1.000000 0.000000 1.000000 1.000000 0.000000 0.000001 0.997998 0.334334 0 255 0 40 | -0.000001 2.500000 1.000000 -0.000001 0.000000 1.000000 0.997998 0.001001 0 255 0 41 | -1.000000 2.000000 1.000000 -0.000001 0.000000 1.000000 0.501001 0.001001 0 255 0 42 | -1.000000 0.000000 1.000000 -0.000001 0.000000 1.000000 0.501001 0.331331 0 255 0 43 | -1.000000 0.000000 1.000000 -1.000000 -0.000000 -0.000000 0.001001 0.664665 0 255 0 44 | -1.000000 2.000000 1.000000 -1.000000 -0.000000 -0.000000 0.001001 0.334334 0 255 0 45 | -1.000000 2.000000 -1.000000 -1.000000 -0.000000 -0.000000 0.497998 0.334334 0 255 0 46 | 0.000000 2.500000 -1.000000 0.000000 0.000000 -1.000000 0.001001 0.331331 0 255 0 47 | 1.000000 0.000000 -1.000000 0.000000 0.000000 -1.000000 0.497998 0.001001 0 255 0 48 | -1.000000 0.000000 -1.000000 0.000000 0.000000 -1.000000 0.001001 0.001001 0 255 0 49 | 0.000000 2.800000 -1.300000 -0.436659 0.899627 -0.000000 0.520000 0.336478 255 255 0 50 | -1.442177 2.100000 1.299999 -0.436659 0.899627 -0.000000 0.000000 0.519690 255 255 0 51 | -0.000001 2.800000 1.300000 -0.436659 0.899627 -0.000000 0.000000 0.336478 255 255 0 52 | 0.000000 2.800000 -1.300000 0.436659 0.899627 0.000000 0.520000 0.336478 255 255 0 53 | 1.442176 2.100000 1.300001 0.436659 0.899627 0.000000 0.000000 0.040333 255 255 0 54 | 1.442177 2.100000 -1.299999 0.436659 0.899627 0.000000 0.520000 0.040333 255 255 0 55 | -1.442177 2.100000 -1.300000 -0.436659 0.899627 -0.000000 0.520000 0.519690 255 255 0 56 | -0.000001 2.800000 1.300000 0.436659 0.899627 0.000000 0.000000 0.336478 255 255 0 57 | 1.442177 1.600000 -1.299999 1.000000 -0.000000 0.000001 0.520000 0.000000 255 255 0 58 | 1.442176 2.100000 1.300001 1.000000 -0.000000 0.000001 0.000000 0.040333 255 255 0 59 | 1.442176 1.600000 1.300001 1.000000 -0.000000 0.000001 0.000000 0.000000 255 255 0 60 | -0.000001 2.300000 1.300000 -0.000000 0.000000 1.000000 0.860000 0.266420 255 255 0 61 | 1.442176 2.100000 1.300001 -0.000000 0.000000 1.000000 0.900000 0.532840 255 255 0 62 | -0.000001 2.800000 1.300000 -0.000000 0.000000 1.000000 0.760000 0.266420 255 255 0 63 | -1.442177 1.600000 1.299999 -1.000000 0.000000 -0.000000 0.100000 1.000000 255 255 0 64 | -1.442177 2.100000 -1.300000 -1.000000 0.000000 -0.000000 0.000000 0.519690 255 255 0 65 | -1.442177 1.600000 -1.300000 -1.000000 0.000000 -0.000000 0.100000 0.519690 255 255 0 66 | 0.000000 2.300000 -1.300000 0.000000 0.000000 -1.000000 0.620000 0.266420 255 255 0 67 | -1.442177 2.100000 -1.300000 0.000000 0.000000 -1.000000 0.660000 0.532840 255 255 0 68 | 0.000000 2.800000 -1.300000 0.000000 0.000000 -1.000000 0.520000 0.266420 255 255 0 69 | 1.442177 2.100000 -1.299999 0.000000 0.000000 -1.000000 0.660000 0.000000 255 255 0 70 | 1.442177 1.600000 -1.299999 0.000000 0.000000 -1.000000 0.760000 0.000000 255 255 0 71 | -1.442177 2.100000 1.299999 -0.000000 0.000000 1.000000 0.900000 0.000000 255 255 0 72 | -1.442177 1.600000 1.299999 -0.000000 0.000000 1.000000 1.000000 0.000000 255 255 0 73 | 1.442177 2.100000 -1.299999 1.000000 0.000000 0.000001 0.520000 0.040333 255 255 0 74 | 1.442176 1.600000 1.300001 -0.000000 0.000000 1.000000 1.000000 0.532840 255 255 0 75 | -1.442177 2.100000 1.299999 -1.000000 -0.000000 -0.000000 0.000000 1.000000 255 255 0 76 | -1.442177 1.600000 -1.300000 0.000000 0.000000 -1.000000 0.760000 0.532840 255 255 0 77 | 3 0 1 2 78 | 3 3 4 5 79 | 3 6 7 8 80 | 3 9 10 11 81 | 3 12 13 14 82 | 3 15 16 17 83 | 3 18 19 20 84 | 3 21 22 23 85 | 3 24 25 26 86 | 3 27 28 29 87 | 3 30 31 32 88 | 3 33 34 35 89 | 3 30 36 31 90 | 3 33 37 34 91 | 3 38 39 40 92 | 3 41 42 43 93 | 3 44 45 46 94 | 3 47 48 49 95 | 3 47 50 51 96 | 3 41 52 53 97 | 3 38 54 39 98 | 3 41 55 42 99 | 3 44 56 45 100 | 3 47 57 48 101 | 3 47 49 50 102 | 3 41 43 52 103 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/roof-rural-01.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.79 (sub 0) - www.blender.org, source file: 'house.blend' 4 | element vertex 58 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 32 17 | property list uchar uint vertex_indices 18 | end_header 19 | 1.818220 0.778349 0.076653 1.000000 0.000000 -0.000000 0.499852 0.228345 0 0 0 20 | 1.818220 0.127949 1.849010 1.000000 0.000000 -0.000000 0.027861 0.055139 0 0 0 21 | 1.818220 0.000000 1.849010 1.000000 0.000000 -0.000000 0.027861 0.021065 0 0 0 22 | -1.858716 0.778349 0.076654 -1.000000 0.000000 0.000000 1.565080 0.228345 0 0 0 23 | -1.858716 0.127949 -1.695702 -1.000000 0.000000 0.000000 2.037071 0.055139 0 0 0 24 | -1.858716 0.000000 -1.695702 -1.000000 0.000000 0.000000 2.037071 0.021065 0 0 0 25 | 2.106836 0.697570 0.078447 1.000000 0.000000 -0.000000 2.354568 0.412798 255 255 255 26 | 2.106836 0.107537 -1.863209 1.000000 0.000000 -0.000000 2.451330 0.999115 255 255 255 27 | 2.106836 0.812545 0.078447 1.000000 0.000000 -0.000000 2.301472 0.412798 255 255 255 28 | 2.106837 -0.007438 2.020102 0.000000 -0.000000 1.000000 2.610616 1.114460 255 255 255 29 | -2.158450 0.107537 2.020103 0.000000 -0.000000 1.000000 2.557521 -0.173519 255 255 255 30 | -2.158450 -0.007438 2.020103 0.000000 -0.000000 1.000000 2.610616 -0.173519 255 255 255 31 | 2.106837 0.107537 2.020102 0.000000 0.939956 0.341295 1.322637 -0.173519 255 255 255 32 | -2.158450 0.812545 0.078447 0.000000 0.939956 0.341295 1.659432 1.114460 255 255 255 33 | -2.158450 0.107537 2.020103 0.000000 0.939956 0.341295 1.322637 1.114460 255 255 255 34 | -2.158450 0.107537 -1.863209 -1.000000 -0.000000 0.000000 2.248377 -0.173519 255 255 255 35 | -2.158450 0.697570 0.078447 -1.000000 -0.000000 0.000000 2.151614 0.412798 255 255 255 36 | -2.158450 0.812545 0.078447 -1.000000 -0.000000 0.000000 2.098519 0.412798 255 255 255 37 | 2.106836 0.812545 0.078447 -0.000000 0.939956 -0.341295 1.659432 -0.173519 255 255 255 38 | -2.158450 0.107537 -1.863209 -0.000000 0.939956 -0.341295 2.098519 1.114460 255 255 255 39 | -2.158450 0.812545 0.078447 -0.000000 0.939956 -0.341295 1.659432 1.114460 255 255 255 40 | 2.106837 0.107537 2.020102 1.000000 0.000000 -0.000000 2.451330 -0.173519 255 255 255 41 | -2.158450 0.107537 2.020103 -1.000000 0.000000 0.000000 2.248377 0.999116 255 255 255 42 | -2.158450 -0.007438 2.020103 -1.000000 0.000000 0.000000 2.301472 0.999116 255 255 255 43 | 2.106836 0.107537 -1.863209 -0.000000 -0.000000 -1.000000 2.504426 -0.173519 255 255 255 44 | -2.158450 -0.007438 -1.863209 -0.000000 -0.000000 -1.000000 2.557521 1.114460 255 255 255 45 | -2.158450 0.107537 -1.863209 -0.000000 -0.000000 -1.000000 2.504426 1.114460 255 255 255 46 | -0.873638 0.228605 0.924634 -0.000000 0.000000 1.000000 1.266618 1.268910 0 0 0 47 | -1.227138 1.314363 0.924634 -0.000000 0.000000 1.000000 1.220240 1.416176 0 0 0 48 | -1.227138 0.228605 0.924634 -0.000000 0.000000 1.000000 1.220240 1.268910 0 0 0 49 | -0.873638 0.228605 0.924634 1.000000 0.000000 0.000000 1.118033 1.268910 0 0 0 50 | -0.873638 1.314363 0.499107 1.000000 0.000000 0.000000 1.173861 1.416176 0 0 0 51 | -0.873638 1.314363 0.924634 1.000000 0.000000 0.000000 1.118033 1.416176 0 0 0 52 | -1.227138 1.314363 0.499107 -1.000000 -0.000000 -0.000000 1.118033 1.268910 0 0 0 53 | -1.227138 0.228605 0.924634 -1.000000 -0.000000 -0.000000 1.062205 1.416176 0 0 0 54 | -1.227138 1.314363 0.924634 -1.000000 -0.000000 -0.000000 1.062205 1.268910 0 0 0 55 | -1.227138 1.314363 0.924634 0.000000 1.000000 -0.000000 1.062205 1.416176 0 0 0 56 | -0.873638 1.314363 0.499107 0.000000 1.000000 -0.000000 1.108583 1.473324 0 0 0 57 | -1.227138 1.314363 0.499107 0.000000 1.000000 -0.000000 1.062205 1.473324 0 0 0 58 | -0.873638 1.314363 0.499107 0.000000 0.000000 -1.000000 1.173861 1.416176 0 0 0 59 | -1.227138 0.228605 0.499107 0.000000 0.000000 -1.000000 1.220240 1.268910 0 0 0 60 | -1.227138 1.314363 0.499107 0.000000 0.000000 -1.000000 1.220240 1.416176 0 0 0 61 | 1.818220 0.000000 -1.695702 1.000000 0.000000 -0.000000 0.971843 0.021065 0 0 0 62 | 1.818220 0.127949 -1.695702 1.000000 0.000000 0.000000 0.971843 0.055139 0 0 0 63 | -1.858716 0.000000 1.849010 -1.000000 0.000000 0.000000 1.093089 0.021065 0 0 0 64 | -1.858716 0.127949 1.849010 -1.000000 0.000000 0.000000 1.093089 0.055139 0 0 0 65 | 2.106836 -0.007438 -1.863209 1.000000 0.000000 -0.000000 2.504426 0.999115 255 255 255 66 | 2.106837 0.107537 2.020102 0.000000 0.000000 1.000000 2.557521 1.114460 255 255 255 67 | 2.106836 0.812545 0.078447 0.000000 0.939956 0.341295 1.659432 -0.173519 255 255 255 68 | -2.158450 -0.007438 -1.863209 -1.000000 0.000000 -0.000000 2.301472 -0.173519 255 255 255 69 | 2.106836 0.107537 -1.863209 -0.000000 0.939956 -0.341295 2.098519 -0.173519 255 255 255 70 | 2.106837 -0.007438 2.020102 1.000000 0.000000 -0.000000 2.504426 -0.173519 255 255 255 71 | 2.106836 -0.007438 -1.863209 -0.000000 0.000000 -1.000000 2.557521 -0.173519 255 255 255 72 | -0.873638 1.314363 0.924634 -0.000000 0.000000 1.000000 1.266618 1.416176 0 0 0 73 | -0.873638 0.228605 0.499107 1.000000 0.000000 -0.000000 1.173861 1.268910 0 0 0 74 | -1.227138 0.228605 0.499107 -1.000000 0.000000 0.000000 1.118033 1.416176 0 0 0 75 | -0.873638 1.314363 0.924634 0.000000 1.000000 -0.000000 1.108583 1.416176 0 0 0 76 | -0.873638 0.228605 0.499107 0.000000 0.000000 -1.000000 1.173861 1.268910 0 0 0 77 | 3 0 1 2 78 | 3 3 4 5 79 | 3 6 7 8 80 | 3 9 10 11 81 | 3 12 13 14 82 | 3 15 16 17 83 | 3 18 19 20 84 | 3 21 6 8 85 | 3 22 16 23 86 | 3 24 25 26 87 | 3 27 28 29 88 | 3 30 31 32 89 | 3 33 34 35 90 | 3 36 37 38 91 | 3 39 40 41 92 | 3 2 42 0 93 | 3 42 43 0 94 | 3 5 44 3 95 | 3 44 45 3 96 | 3 6 46 7 97 | 3 9 47 10 98 | 3 12 48 13 99 | 3 15 49 16 100 | 3 18 50 19 101 | 3 21 51 6 102 | 3 22 17 16 103 | 3 24 52 25 104 | 3 27 53 28 105 | 3 30 54 31 106 | 3 33 55 34 107 | 3 36 56 37 108 | 3 39 57 40 109 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/building-entrance-1.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'building-roof-part1.blend' 4 | element vertex 60 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 30 17 | property list uchar uint vertex_indices 18 | end_header 19 | -1.125000 1.656000 -0.846394 0.000000 1.000000 -0.000000 0.500000 0.500000 177 175 189 20 | 1.125000 1.656000 0.905565 0.000000 1.000000 -0.000000 0.000000 0.000000 177 175 189 21 | 1.125000 1.656000 -0.846394 0.000000 1.000000 -0.000000 0.500000 0.000000 177 175 189 22 | 1.125000 1.656000 0.905565 0.000000 -0.000000 1.000000 0.833333 0.000000 177 175 189 23 | -1.125000 1.416000 0.905565 0.000000 -0.000000 1.000000 0.666667 0.500000 177 175 189 24 | 1.125000 1.416000 0.905565 0.000000 -0.000000 1.000000 0.666667 0.000000 177 175 189 25 | -0.550000 1.420000 0.508333 -1.000000 0.000000 0.000000 0.000000 1.000000 177 175 189 26 | -0.550000 -0.020000 -0.841667 -1.000000 0.000000 0.000000 0.500000 0.500000 177 175 189 27 | -0.550000 -0.020000 0.508333 -1.000000 0.000000 0.000000 0.500000 1.000000 177 175 189 28 | -0.250000 1.420000 0.508333 0.000000 -0.000000 1.000000 0.500000 0.000000 177 175 189 29 | -0.550000 -0.020000 0.508333 0.000000 -0.000000 1.000000 0.000000 0.500000 177 175 189 30 | -0.250000 -0.020000 0.508333 0.000000 -0.000000 1.000000 0.000000 0.000000 177 175 189 31 | -0.250000 1.420000 -0.841667 1.000000 -0.000000 0.000000 0.500000 1.000000 177 175 189 32 | -0.250000 -0.020000 0.508333 1.000000 -0.000000 0.000000 1.000000 0.500000 177 175 189 33 | -0.250000 -0.020000 -0.841667 1.000000 -0.000000 0.000000 1.000000 1.000000 177 175 189 34 | -1.125000 1.656000 0.905565 -1.000000 0.000000 0.000000 0.833333 0.500000 177 175 189 35 | -1.125000 1.416000 -0.846394 -1.000000 0.000000 0.000000 1.000000 0.000000 177 175 189 36 | -1.125000 1.416000 0.905565 -1.000000 0.000000 0.000000 1.000000 0.500000 177 175 189 37 | 1.125000 1.656000 -0.846394 1.000000 -0.000000 0.000000 0.500000 0.500000 177 175 189 38 | 1.125000 1.416000 0.905565 1.000000 -0.000000 0.000000 0.666667 0.000000 177 175 189 39 | 1.125000 1.416000 -0.846394 1.000000 -0.000000 0.000000 0.666667 0.500000 177 175 189 40 | -0.238873 0.067495 0.577073 0.000000 1.000000 -0.000000 0.453753 1.000000 177 175 189 41 | 0.609403 0.067495 0.909343 0.000000 1.000000 -0.000000 0.000000 0.000000 177 175 189 42 | 0.609403 0.067495 0.577073 0.000000 1.000000 -0.000000 0.453753 0.000000 177 175 189 43 | 0.609403 0.067495 0.909343 0.000000 -0.000000 1.000000 0.726876 0.000000 177 175 189 44 | -0.238873 -0.132505 0.909343 0.000000 -0.000000 1.000000 0.453753 1.000000 177 175 189 45 | 0.609403 -0.132505 0.909343 0.000000 -0.000000 1.000000 0.453753 0.000000 177 175 189 46 | -1.000000 0.200000 0.633379 -1.000000 0.000000 0.000000 0.904371 0.745706 177 175 189 47 | -1.000000 0.000000 -0.858033 -1.000000 0.000000 0.000000 1.000000 0.000000 177 175 189 48 | -1.000000 0.000000 0.633379 -1.000000 0.000000 0.000000 1.000000 0.745706 177 175 189 49 | -0.238873 0.067495 0.909343 -1.000000 0.000000 0.000000 0.726877 0.391700 177 175 189 50 | -0.238873 -0.132505 0.577073 -1.000000 0.000000 0.000000 1.000000 0.000000 177 175 189 51 | -0.238873 -0.132505 0.909343 -1.000000 0.000000 0.000000 1.000000 0.391700 177 175 189 52 | 1.000000 0.200000 -0.858033 1.000000 -0.000000 0.000000 0.808742 0.745706 177 175 189 53 | 1.000000 0.000000 0.633379 1.000000 -0.000000 0.000000 0.904371 0.000000 177 175 189 54 | 1.000000 0.000000 -0.858033 1.000000 -0.000000 0.000000 0.904371 0.745706 177 175 189 55 | 1.000000 0.200000 0.633379 0.000000 -0.000000 1.000000 0.808741 0.000000 177 175 189 56 | -1.000000 0.000000 0.633379 0.000000 -0.000000 1.000000 0.713112 1.000000 177 175 189 57 | 1.000000 0.000000 0.633379 0.000000 -0.000000 1.000000 0.713112 0.000000 177 175 189 58 | 0.609403 0.067495 0.577073 1.000000 -0.000000 0.000000 0.726877 0.783400 177 175 189 59 | 0.609403 -0.132505 0.909343 1.000000 -0.000000 0.000000 1.000000 0.391700 177 175 189 60 | 0.609403 -0.132505 0.577073 1.000000 -0.000000 0.000000 1.000000 0.783400 177 175 189 61 | -1.000000 0.200000 -0.858033 0.000000 1.000000 -0.000000 0.713112 1.000000 177 175 189 62 | 1.000000 0.200000 0.633379 0.000000 1.000000 -0.000000 0.000000 0.000000 177 175 189 63 | 1.000000 0.200000 -0.858033 0.000000 1.000000 -0.000000 0.713112 0.000000 177 175 189 64 | -1.125000 1.656000 0.905565 0.000000 1.000000 0.000000 0.000000 0.500000 177 175 189 65 | -1.125000 1.656000 0.905565 0.000000 0.000000 1.000000 0.833333 0.500000 177 175 189 66 | -0.550000 1.420000 -0.841667 -1.000000 0.000000 0.000000 0.000000 0.500000 177 175 189 67 | -0.550000 1.420000 0.508333 0.000000 0.000000 1.000000 0.500000 0.500000 177 175 189 68 | -0.250000 1.420000 0.508333 1.000000 -0.000000 0.000000 0.500000 0.500000 177 175 189 69 | -1.125000 1.656000 -0.846394 -1.000000 0.000000 0.000000 0.833333 0.000000 177 175 189 70 | 1.125000 1.656000 0.905565 1.000000 -0.000000 0.000000 0.500000 0.000000 177 175 189 71 | -0.238873 0.067495 0.909343 0.000000 1.000000 0.000000 0.000000 1.000000 177 175 189 72 | -0.238873 0.067495 0.909343 0.000000 0.000000 1.000000 0.726877 1.000000 177 175 189 73 | -1.000000 0.200000 -0.858033 -1.000000 0.000000 0.000000 0.904371 0.000000 177 175 189 74 | -0.238873 0.067495 0.577073 -1.000000 0.000000 0.000000 0.726877 0.000000 177 175 189 75 | 1.000000 0.200000 0.633379 1.000000 -0.000000 0.000000 0.808742 0.000000 177 175 189 76 | -1.000000 0.200000 0.633379 0.000000 0.000000 1.000000 0.808742 1.000000 177 175 189 77 | 0.609403 0.067495 0.909343 1.000000 -0.000000 0.000000 0.726877 0.391700 177 175 189 78 | -1.000000 0.200000 0.633379 0.000000 1.000000 0.000000 0.000000 1.000000 177 175 189 79 | 3 0 1 2 80 | 3 3 4 5 81 | 3 6 7 8 82 | 3 9 10 11 83 | 3 12 13 14 84 | 3 15 16 17 85 | 3 18 19 20 86 | 3 21 22 23 87 | 3 24 25 26 88 | 3 27 28 29 89 | 3 30 31 32 90 | 3 33 34 35 91 | 3 36 37 38 92 | 3 39 40 41 93 | 3 42 43 44 94 | 3 0 45 1 95 | 3 3 46 4 96 | 3 6 47 7 97 | 3 9 48 10 98 | 3 12 49 13 99 | 3 15 50 16 100 | 3 18 51 19 101 | 3 21 52 22 102 | 3 24 53 25 103 | 3 27 54 28 104 | 3 30 55 31 105 | 3 33 56 34 106 | 3 36 57 37 107 | 3 39 58 40 108 | 3 42 59 43 109 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/building-construction-part.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'building-roof-part1.blend' 4 | element vertex 62 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 30 17 | property list uchar uint vertex_indices 18 | end_header 19 | 2.129763 3.155204 -5.282896 0.000000 0.000000 -1.000000 0.564162 0.549102 185 182 196 20 | 2.603043 0.000000 -5.282896 0.000000 0.000000 -1.000000 0.594619 0.750291 185 182 196 21 | 2.129763 0.000000 -5.282896 0.000000 0.000000 -1.000000 0.564162 0.750291 185 182 196 22 | 2.603043 3.155204 -5.282896 1.000000 0.000000 -0.000000 0.706296 0.549102 185 182 196 23 | 2.603044 0.000000 3.282896 1.000000 0.000000 -0.000000 0.908646 0.000000 185 182 196 24 | 2.603043 0.000000 -5.282896 1.000000 0.000000 -0.000000 0.908646 0.549102 185 182 196 25 | 2.603044 3.155204 3.282896 0.000000 -0.000000 1.000000 0.533704 0.549102 185 182 196 26 | 2.129764 0.000000 3.282896 0.000000 -0.000000 1.000000 0.564162 0.751363 185 182 196 27 | 2.603044 0.000000 3.282896 0.000000 -0.000000 1.000000 0.533704 0.751363 185 182 196 28 | 2.129764 3.155204 3.282896 -1.000000 0.000000 0.000000 0.503247 0.549102 185 182 196 29 | 2.129763 0.000000 -5.282896 -1.000000 0.000000 0.000000 0.706296 0.000000 185 182 196 30 | 2.129764 0.000000 3.282896 -1.000000 0.000000 0.000000 0.706296 0.549102 185 182 196 31 | 2.603043 3.155204 -5.282896 0.000000 1.000000 0.000000 0.939094 0.549102 185 182 196 32 | 2.129764 3.155204 3.282896 0.000000 1.000000 0.000000 0.908646 0.000000 185 182 196 33 | 2.603044 3.155204 3.282896 0.000000 1.000000 0.000000 0.939094 0.000001 185 182 196 34 | -1.025442 3.119668 -4.155204 0.000000 -0.305248 -0.952273 0.496766 0.736883 185 182 196 35 | -0.552161 0.000000 -3.155204 0.000000 -0.305248 -0.952273 0.466309 0.531368 185 182 196 36 | -1.025442 0.000000 -3.155204 0.000000 -0.305248 -0.952273 0.496766 0.531368 185 182 196 37 | -0.552161 0.000000 -3.155204 1.000000 0.000000 -0.000000 0.205014 0.594506 185 182 196 38 | -0.552161 3.155204 3.155205 1.000000 0.000000 -0.000000 0.405394 1.000000 185 182 196 39 | -0.552161 0.000000 3.155205 1.000000 0.000000 -0.000000 0.203047 0.999023 185 182 196 40 | -0.552161 3.155204 3.155205 0.000000 -0.000000 1.000000 0.503247 0.549102 185 182 196 41 | -1.025442 0.000000 3.155205 0.000000 -0.000000 1.000000 0.533704 0.751363 185 182 196 42 | -0.552161 0.000000 3.155205 0.000000 -0.000000 1.000000 0.503247 0.751363 185 182 196 43 | -1.025442 3.155204 3.155205 -1.000000 0.000000 0.000000 0.203047 0.531368 185 182 196 44 | -1.025442 0.000000 -3.155204 -1.000000 0.000000 0.000000 0.001974 0.936869 185 182 196 45 | -1.025442 0.000000 3.155205 -1.000000 0.000000 0.000000 0.000000 0.532351 185 182 196 46 | -0.552161 3.119668 -4.155204 0.000000 0.999988 -0.004861 0.969552 0.000002 185 182 196 47 | -1.025442 3.155204 3.155205 0.000000 0.999988 -0.004861 1.000000 0.468630 185 182 196 48 | -0.552161 3.155204 3.155205 0.000000 0.999988 -0.004861 0.969552 0.468632 185 182 196 49 | -3.368706 3.312964 -1.340960 -1.000000 0.000000 0.000000 0.435852 0.531368 185 182 196 50 | -3.368706 0.000000 -1.814241 -1.000000 0.000000 0.000000 0.466309 0.743742 185 182 196 51 | -3.368706 0.000000 -1.340960 -1.000000 0.000000 0.000000 0.435852 0.743742 185 182 196 52 | 3.920439 0.000000 -1.340961 0.968974 -0.247163 -0.000002 0.435852 0.787133 185 182 196 53 | 4.920439 3.920393 -1.814242 0.968974 -0.247163 -0.000002 0.405394 0.531368 185 182 196 54 | 4.920440 3.920393 -1.340961 0.968974 -0.247163 -0.000002 0.435852 0.531368 185 182 196 55 | 3.920439 0.000000 -1.340961 0.000000 -0.000000 1.000000 0.252292 0.467264 185 182 196 56 | -3.368706 3.312964 -1.340960 0.000000 -0.000000 1.000000 0.039090 0.000000 185 182 196 57 | -3.368706 0.000000 -1.340960 0.000000 -0.000000 1.000000 0.252292 0.000000 185 182 196 58 | 4.920439 3.920393 -1.814242 -0.073084 0.997326 0.000000 0.969552 0.000002 185 182 196 59 | -3.368706 3.312964 -1.340960 -0.073084 0.997326 0.000000 0.939094 0.532159 185 182 196 60 | 4.920440 3.920393 -1.340961 -0.073084 0.997326 0.000000 0.939094 0.000000 185 182 196 61 | -3.368706 3.312964 -1.814241 -0.000000 0.000000 -1.000000 0.291175 0.531368 185 182 196 62 | 3.920439 0.000000 -1.814242 -0.000000 0.000000 -1.000000 0.503247 0.064104 185 182 196 63 | -3.368706 0.000000 -1.814241 -0.000000 0.000000 -1.000000 0.503247 0.531368 185 182 196 64 | 2.603043 3.155204 -5.282896 0.000000 0.000000 -1.000000 0.594619 0.549102 185 182 196 65 | 2.603044 3.155204 3.282896 1.000000 0.000000 -0.000000 0.706296 0.000000 185 182 196 66 | 2.129764 3.155204 3.282896 0.000000 0.000000 1.000000 0.564162 0.549102 185 182 196 67 | 2.129763 3.155204 -5.282896 -1.000000 0.000000 0.000000 0.503247 0.000000 185 182 196 68 | 2.129763 3.155204 -5.282896 -0.000000 1.000000 0.000000 0.908646 0.549101 185 182 196 69 | -0.552161 3.119668 -4.155204 -0.000000 -0.305248 -0.952273 0.466309 0.736883 185 182 196 70 | -0.552161 3.119668 -4.155204 1.000000 -0.000000 -0.000000 0.405394 0.531368 185 182 196 71 | -1.025442 3.155204 3.155205 0.000000 0.000000 1.000000 0.533704 0.549102 185 182 196 72 | -1.025442 3.119668 -4.155204 -1.000000 0.000000 0.000000 0.203047 1.000000 185 182 196 73 | -1.025442 3.119668 -4.155204 0.000000 0.999988 -0.004861 1.000000 0.000000 185 182 196 74 | -3.368706 3.312964 -1.814241 -1.000000 0.000000 0.000000 0.466309 0.531368 185 182 196 75 | 3.920439 0.000000 -1.340961 0.968974 -0.247162 -0.000000 0.435852 0.787133 185 182 196 76 | 3.920439 0.000000 -1.814242 0.968974 -0.247162 -0.000000 0.405394 0.787133 185 182 196 77 | 4.920439 3.920393 -1.814242 0.968974 -0.247162 -0.000000 0.405394 0.531368 185 182 196 78 | 4.920440 3.920393 -1.340961 0.000000 -0.000000 1.000000 0.000000 0.531368 185 182 196 79 | -3.368706 3.312964 -1.814241 -0.073084 0.997326 0.000000 0.969552 0.532161 185 182 196 80 | 4.920439 3.920393 -1.814242 -0.000000 0.000000 -1.000000 0.252292 0.000000 185 182 196 81 | 3 0 1 2 82 | 3 3 4 5 83 | 3 6 7 8 84 | 3 9 10 11 85 | 3 12 13 14 86 | 3 15 16 17 87 | 3 18 19 20 88 | 3 21 22 23 89 | 3 24 25 26 90 | 3 27 28 29 91 | 3 30 31 32 92 | 3 33 34 35 93 | 3 36 37 38 94 | 3 39 40 41 95 | 3 42 43 44 96 | 3 0 45 1 97 | 3 3 46 4 98 | 3 6 47 7 99 | 3 9 48 10 100 | 3 12 49 13 101 | 3 15 50 16 102 | 3 18 51 19 103 | 3 21 52 22 104 | 3 24 53 25 105 | 3 27 54 28 106 | 3 30 55 31 107 | 3 56 57 58 108 | 3 36 59 37 109 | 3 39 60 40 110 | 3 42 61 43 111 | -------------------------------------------------------------------------------- /scripts/rsgeotools-process-hm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Create heightmap tiles from NASADEM and ASTER GDEM v3 4 | 5 | 6 | if test -z "$RVT_GPAK_DIR" 7 | then 8 | echo "RVT_GPAK_DIR is not set. " 9 | exit 10 | fi 11 | 12 | if test -z "$RVT_TEMP_DIR" 13 | then 14 | echo "RVT_TEMP_DIR is not set. " 15 | exit 16 | fi 17 | 18 | if test -z "$RVT_HGT_DIR_NASADEM" 19 | then 20 | echo "RVT_HGT_DIR_NASADEM is not set. " 21 | exit 22 | fi 23 | 24 | if test -z "$RVT_HGT_DIR_ASTERGDEMV3" 25 | then 26 | echo "RVT_HGT_DIR_ASTERGDEMV3 is not set. " 27 | exit 28 | fi 29 | 30 | 31 | if test -z "$5" 32 | then 33 | echo "usage: rsgeotools-process-hm.sh Z X Y SUBPAK_Z DEST_Z (example: 7 81 41 11 11)" 34 | exit 35 | fi 36 | 37 | IFS=$'\n' 38 | 39 | TILE_Z=$1 40 | TILE_X=$2 41 | TILE_Y=$3 42 | 43 | SUBPAK_Z=$4 44 | 45 | DEST_Z=$5 46 | DEST_Z_PARENT=$(expr $DEST_Z - 1) 47 | 48 | DEFAULT_DIR=`pwd` 49 | 50 | cd $HM_DATA_ROOT_DIR 51 | 52 | TEMP_DIR="$RVT_TEMP_DIR/heightmap_temp_${TILE_Z}_${TILE_X}_${TILE_Y}" 53 | 54 | OUTPUT_DIR="$RVT_TEMP_DIR/heightmap_data_out_${TILE_Z}_${TILE_X}_${TILE_Y}" 55 | 56 | 57 | if [ ! -d $RVT_HGT_DIR_NASADEM ]; then 58 | echo "$RVT_HGT_DIR_NASADEM is not a directory. Aborted." 59 | exit 60 | fi 61 | 62 | if [ ! -d $RVT_HGT_DIR_ASTERGDEMV3 ]; then 63 | echo "$RVT_HGT_DIR_ASTERGDEMV3 is not a directory. Aborted." 64 | exit 65 | fi 66 | 67 | 68 | # 32 for z14, 128 for z12, 256 for z11 69 | IMAGE_SIZE="256" 70 | 71 | LOG_FILE="log_hm.txt" 72 | 73 | echo "-----------------------------" >> $LOG_FILE 74 | date > $LOG_FILE 75 | 76 | 77 | current_number=0 78 | 79 | 80 | mkdir -p $OUTPUT_DIR 81 | mkdir -p $RVT_GPAK_DIR 82 | mkdir -p $TEMP_DIR 83 | 84 | cd $TEMP_DIR 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | echo "Checking/unzipping heightmaps..." 98 | 99 | 100 | HM_PRIMARY_PATH="$RVT_HGT_DIR_NASADEM" 101 | HM_PRIMARY_PREFIX="" 102 | HM_PRIMARY_SUFFIX=".hgt" 103 | HM_PRIMARY_PREFIX_ZIP="" 104 | HM_PRIMARY_SUFFIX_ZIP=".hgt.zip" 105 | HM_PRIMARY_LOWERCASE=1 106 | HM_PRIMARY_EXT="hgt" 107 | 108 | HM_SECONDARY_PATH="$RVT_HGT_DIR_ASTERGDEMV3" 109 | HM_SECONDARY_PREFIX="ASTGTMV003_" 110 | HM_SECONDARY_SUFFIX="_dem.tif" 111 | HM_SECONDARY_PREFIX_ZIP="" 112 | HM_SECONDARY_SUFFIX_ZIP=".zip" 113 | HM_SECONDARY_LOWERCASE=0 114 | HM_SECONDARY_EXT="tif" 115 | 116 | HGT_DIR="$TEMP_DIR" 117 | 118 | 119 | 120 | for f in `rsgeotools-conv f ${TILE_Z} ${TILE_X} ${TILE_Y}` 121 | do 122 | 123 | f1="$f" 124 | if [ "$HM_PRIMARY_LOWERCASE" -eq 1 ] 125 | then 126 | f1=`echo "$f" | awk '{print tolower($0)}'` 127 | fi 128 | 129 | f1_zip="${HM_PRIMARY_PATH}/${HM_PRIMARY_PREFIX_ZIP}${f1}${HM_PRIMARY_SUFFIX_ZIP}" 130 | 131 | if [ -f $f1_zip ]; then 132 | # echo "($f) Primary: $f1_zip" 133 | 134 | unzip -q -o -j $f1_zip -d $HGT_DIR 135 | 136 | mv ${HGT_DIR}/${HM_PRIMARY_PREFIX}${f1}${HM_PRIMARY_SUFFIX} ${HGT_DIR}/$f.${HM_PRIMARY_EXT} 137 | 138 | if [ "$HM_PRIMARY_EXT" != "tif" ] 139 | then 140 | gdalwarp ${HGT_DIR}/$f.${HM_PRIMARY_EXT} ${HGT_DIR}/$f.tif 141 | rm ${HGT_DIR}/$f.${HM_PRIMARY_EXT} 142 | fi 143 | 144 | else 145 | 146 | f2="$f" 147 | if [ "$HM_SECONDARY_LOWERCASE" -eq 1 ] 148 | then 149 | f2=`echo "$f" | awk '{print tolower($0)}'` 150 | fi 151 | 152 | f2_zip="${HM_SECONDARY_PATH}/${HM_SECONDARY_PREFIX_ZIP}${f2}${HM_SECONDARY_SUFFIX_ZIP}" 153 | 154 | if [ -f $f2_zip ]; then 155 | # echo "($f) Secondary: $f2_zip" 156 | 157 | unzip -q -o -j $f2_zip -d $HGT_DIR 158 | 159 | mv ${HGT_DIR}/${HM_SECONDARY_PREFIX}${f2}${HM_SECONDARY_SUFFIX} ${HGT_DIR}/$f.${HM_SECONDARY_EXT} 160 | 161 | if [ "$HM_SECONDARY_EXT" != "tif" ] 162 | then 163 | gdalwarp ${HGT_DIR}/$f.${HM_SECONDARY_EXT} ${HGT_DIR}/$f.tif 164 | rm ${HGT_DIR}/$f.${HM_SECONDARY_EXT} 165 | fi 166 | 167 | fi 168 | 169 | fi 170 | 171 | done 172 | 173 | 174 | 175 | 176 | 177 | HGT_PREFIX="./" 178 | HGT_SUFFIX=".tif" 179 | 180 | 181 | tile_pair_list=(`rsgeotools-conv i $TILE_Z $TILE_X $TILE_Y $DEST_Z_PARENT`) 182 | 183 | tile_pair_list_len=${#tile_pair_list[@]} 184 | 185 | echo "--- $TILE_Z/$TILE_X/$TILE_Y ($tile_pair_list_len total) ---" 186 | 187 | for tile_pair in `rsgeotools-conv i $TILE_Z $TILE_X $TILE_Y $DEST_Z_PARENT` 188 | do 189 | 190 | current_number=$(expr $current_number + 1) 191 | #echo "----- $current_number of $tile_pair_list_len -----" 192 | echo -n "." 193 | 194 | 195 | TP=$(echo $tile_pair | tr "_" "\n") 196 | 197 | 198 | subtile_pairs=(`rsgeotools-conv i $DEST_Z_PARENT $TP $DEST_Z`) 199 | 200 | 201 | t0_tp=$(echo ${subtile_pairs[0]} | tr "_" "\n") 202 | t1_tp=$(echo ${subtile_pairs[1]} | tr "_" "\n") 203 | t2_tp=$(echo ${subtile_pairs[2]} | tr "_" "\n") 204 | t3_tp=$(echo ${subtile_pairs[3]} | tr "_" "\n") 205 | 206 | t0_cmd="rsgeotools-conv h $DEST_Z ${t0_tp} $IMAGE_SIZE $HGT_PREFIX $HGT_SUFFIX" 207 | t1_cmd="rsgeotools-conv h $DEST_Z ${t1_tp} $IMAGE_SIZE $HGT_PREFIX $HGT_SUFFIX" 208 | t2_cmd="rsgeotools-conv h $DEST_Z ${t2_tp} $IMAGE_SIZE $HGT_PREFIX $HGT_SUFFIX" 209 | t3_cmd="rsgeotools-conv h $DEST_Z ${t3_tp} $IMAGE_SIZE $HGT_PREFIX $HGT_SUFFIX" 210 | 211 | 212 | eval $t0_cmd >> $LOG_FILE & 213 | eval $t1_cmd >> $LOG_FILE & 214 | eval $t2_cmd >> $LOG_FILE & 215 | eval $t3_cmd >> $LOG_FILE & 216 | wait 217 | 218 | t0_cmd="rsgeotools-tiff2hmdata tile_${DEST_Z}_${subtile_pairs[0]}_quad.tif $OUTPUT_DIR/${DEST_Z}_${subtile_pairs[0]}_q.data >> $LOG_FILE" 219 | t1_cmd="rsgeotools-tiff2hmdata tile_${DEST_Z}_${subtile_pairs[1]}_quad.tif $OUTPUT_DIR/${DEST_Z}_${subtile_pairs[1]}_q.data >> $LOG_FILE" 220 | t2_cmd="rsgeotools-tiff2hmdata tile_${DEST_Z}_${subtile_pairs[2]}_quad.tif $OUTPUT_DIR/${DEST_Z}_${subtile_pairs[2]}_q.data >> $LOG_FILE" 221 | t3_cmd="rsgeotools-tiff2hmdata tile_${DEST_Z}_${subtile_pairs[3]}_quad.tif $OUTPUT_DIR/${DEST_Z}_${subtile_pairs[3]}_q.data >> $LOG_FILE" 222 | 223 | eval $t0_cmd >> $LOG_FILE & 224 | eval $t1_cmd >> $LOG_FILE & 225 | eval $t2_cmd >> $LOG_FILE & 226 | eval $t3_cmd >> $LOG_FILE & 227 | wait 228 | 229 | 230 | rm -f ./*_quad.tif 231 | 232 | done 233 | 234 | 235 | cd $OUTPUT_DIR 236 | 237 | echo "" 238 | 239 | echo -n "Compressing and packing... " 240 | 241 | 242 | ARCHIVE_FILENAME="${TILE_Z}_${TILE_X}_${TILE_Y}_h.gpak" 243 | 244 | packer_cmd="rsgeotools-tilepacker h $TILE_Z $TILE_X $TILE_Y $SUBPAK_Z $DEST_Z $IMAGE_SIZE 0" 245 | 246 | 247 | eval $packer_cmd 248 | 249 | 250 | if [ -f $ARCHIVE_FILENAME ]; then 251 | cp_cmd="cp ${ARCHIVE_FILENAME} ${RVT_GPAK_DIR}/" 252 | eval $cp_cmd 253 | fi 254 | 255 | if test -z "$RVT_KEEP_TEMP_DATA" 256 | then 257 | rm -rf $OUTPUT_DIR 258 | rm -rf $TEMP_DIR 259 | fi 260 | 261 | 262 | 263 | cd $DEFAULT_DIR 264 | 265 | 266 | echo "Done." 267 | echo "" 268 | 269 | 270 | 271 | -------------------------------------------------------------------------------- /src/rvtgen3d/rs/rsmx.h: -------------------------------------------------------------------------------- 1 | #ifndef rs_mx_t_H_INCLUDED 2 | #define rs_mx_t_H_INCLUDED 3 | 4 | #include 5 | 6 | 7 | #define RS_SQR(x) ((x)*(x)) 8 | #define RS_CUBE(x) ((x)*(x)*(x)) 9 | 10 | 11 | // aligned(16) for Bullet physics 12 | typedef float __attribute__ ((aligned (16))) rs_mx_t[16]; 13 | 14 | typedef rs_mx_t __attribute__ ((aligned (16))) rs_mx4_t; 15 | //typedef float *rs_mx_t_p; 16 | 17 | typedef float rs_mx3_t[9]; 18 | 19 | 20 | typedef struct { 21 | float x; 22 | float y; 23 | } rs_vec2_t; 24 | 25 | typedef struct { 26 | int x; 27 | int y; 28 | } rs_vec2i_t; 29 | 30 | typedef struct { 31 | union { 32 | struct { 33 | float x; 34 | float y; 35 | float z; 36 | }; 37 | struct { 38 | float r; 39 | float g; 40 | float b; 41 | }; 42 | float v[3]; 43 | }; 44 | 45 | } rs_vec3_t; 46 | 47 | 48 | typedef struct { 49 | union { 50 | struct { 51 | float x; 52 | float y; 53 | float z; 54 | float w; 55 | }; 56 | struct { 57 | float r; 58 | float g; 59 | float b; 60 | float a; 61 | }; 62 | float v[4]; 63 | }; 64 | 65 | } rs_vec4_t; 66 | 67 | 68 | typedef struct { 69 | union { 70 | struct { 71 | uint32_t x; 72 | uint32_t y; 73 | uint32_t z; 74 | uint32_t w; 75 | }; 76 | uint32_t v[4]; 77 | }; 78 | 79 | } rs_vec4i_t; 80 | 81 | 82 | 83 | 84 | void rs_mx3_mult_vec3(rs_vec3_t dest, rs_mx3_t m, rs_vec3_t v); 85 | 86 | 87 | 88 | void rs_mx_identity(rs_mx_t mx); 89 | 90 | void rs_mx_ortho(rs_mx_t mx, float left, float right, float bottom, float top); 91 | void rs_mx_frustum(rs_mx_t mx, float left, float right, float bottom, float top, float near, float far); 92 | 93 | void rs_mx_mult_adv(rs_mx_t dest, rs_mx_t src1, rs_mx_t src2); 94 | void rs_mx_mult(rs_mx_t dest, rs_mx_t src); 95 | 96 | void rs_mx3_mult_adv(rs_mx3_t dest, rs_mx3_t src1, rs_mx3_t src2); 97 | void rs_mx3_mult(rs_mx3_t dest, rs_mx3_t src); 98 | 99 | void rs_mx_translate(rs_mx_t mx, float x, float y, float z); 100 | void rs_mx_rotate(rs_mx_t mx, float angle, float x, float y, float z); 101 | void rs_mx_scale(rs_mx_t mx, float s); 102 | void rs_mx_scale_adv(rs_mx_t mx, float x, float y, float z); 103 | 104 | void rs_mx_look_at(rs_mx_t mx, rs_vec3_t eye, rs_vec3_t center, rs_vec3_t up); 105 | 106 | 107 | void rs_mx_copy(rs_mx_t dest, rs_mx_t src); 108 | #define rs_mx4_copy(dest,src) rs_mx_copy(dest,src) 109 | void rs_mx3_copy(rs_mx3_t dest, rs_mx3_t src); 110 | 111 | void rs_mx_minor(rs_mx3_t dest, rs_mx4_t src); 112 | 113 | float rs_mx3_det(rs_mx3_t mx); 114 | float rs_mx4_det(rs_mx4_t mx); 115 | 116 | void rs_mx3_inv(rs_mx3_t dest, rs_mx3_t src); 117 | void rs_mx_inv(rs_mx_t inv, rs_mx_t m); 118 | 119 | void rs_mx3_cofactor(rs_mx3_t cof, rs_mx3_t mx); 120 | void rs_mx4_cofactor(rs_mx4_t cof, rs_mx4_t mx); 121 | 122 | void rs_mx3_transp(rs_mx3_t dest, rs_mx3_t src); 123 | void rs_mx4_transp(rs_mx4_t dest, rs_mx4_t src); 124 | 125 | void rs_mx3_normal_matrix_from_modelview(rs_mx3_t dest, rs_mx4_t modelview); 126 | 127 | 128 | 129 | rs_vec2_t rs_vec2(float x, float y); 130 | rs_vec2_t rs_vec2_add(rs_vec2_t v1, rs_vec2_t v2); 131 | rs_vec2_t rs_vec2_sub(rs_vec2_t v1, rs_vec2_t v2); 132 | rs_vec2_t rs_vec2_mult(rs_vec2_t v, float s); 133 | float rs_vec2_dot(rs_vec2_t v1, rs_vec2_t v2); 134 | float rs_vec2_length_sqr(rs_vec2_t src); 135 | float rs_vec2_length(rs_vec2_t v); 136 | float rs_vec2_azimuth( rs_vec2_t v_from, rs_vec2_t v_to ); 137 | 138 | rs_vec3_t rs_vec3(float x, float y, float z); 139 | rs_vec3_t rs_vec3_add(rs_vec3_t v1, rs_vec3_t v2); 140 | rs_vec3_t rs_vec3_sub(rs_vec3_t v1, rs_vec3_t v2); 141 | rs_vec3_t rs_vec3_mult(rs_vec3_t v, float s); 142 | float rs_vec3_dot(rs_vec3_t v1, rs_vec3_t v2); 143 | float rs_vec3_length_sqr(rs_vec3_t src); 144 | float rs_vec3_length(rs_vec3_t v); 145 | 146 | 147 | rs_vec4_t rs_vec4(float x, float y, float z, float w); 148 | rs_vec4_t rs_vec4_add(rs_vec4_t v1, rs_vec4_t v2); 149 | rs_vec4_t rs_vec4_sub(rs_vec4_t v1, rs_vec4_t v2); 150 | rs_vec4_t rs_vec4_mult(rs_vec4_t v, float s); 151 | float rs_vec4_dot(rs_vec4_t v1, rs_vec4_t v2); 152 | float rs_vec4_length_sqr(rs_vec4_t src); 153 | float rs_vec4_length(rs_vec4_t v); 154 | 155 | rs_vec4_t rs_vec4_quat(float angle, rs_vec3_t axis); 156 | 157 | rs_vec4_t rs_mx_mult_vec(rs_mx_t mx, rs_vec4_t v); 158 | 159 | rs_vec3_t rs_vec3_cross(rs_vec3_t u, rs_vec3_t v); 160 | 161 | rs_vec3_t rs_vec3_normalize(rs_vec3_t v); 162 | 163 | float rs_vec4_angle(rs_vec4_t u, rs_vec4_t v); 164 | 165 | float rs_vec3_cos_angle(rs_vec3_t u, rs_vec3_t v); 166 | 167 | 168 | rs_vec2_t rs_vec2_normalize(rs_vec2_t v); 169 | 170 | float rs_vec2_distance(rs_vec2_t u, rs_vec2_t v); 171 | float rs_vec2_distance_sqr(rs_vec2_t u, rs_vec2_t v); 172 | 173 | float rs_vec3_distance(rs_vec3_t u, rs_vec3_t v); 174 | float rs_vec3_axis_distance(rs_vec3_t u, rs_vec3_t v); 175 | float rs_vec3_distance_sqr(rs_vec3_t u, rs_vec3_t v); 176 | 177 | float rs_clamp(float x, float min1, float max1); 178 | int rs_clamp_i(int x, int min1, int max1); 179 | 180 | float rs_smoothstep(float min1, float max1, float val); 181 | 182 | 183 | float rs_periodical_clamp(float x, float min1, float max1); 184 | int rs_periodical_clamp_i(int x, int min1, int max1); 185 | 186 | float rs_max(float x, float y); 187 | float rs_min(float x, float y); 188 | 189 | int rs_max_i(int x, int y); 190 | int rs_min_i(int x, int y); 191 | 192 | float rs_sign(float f); 193 | float rs_pow(float f, float p); 194 | 195 | float rs_exp_interpolate(float v_from, float v_to, float dt); 196 | float rs_exp_interpolate_angle(float a_from, float a_to, float dt); 197 | rs_vec3_t rs_vec3_exp_interpolate(rs_vec3_t v_from, rs_vec3_t v_to, float dt); 198 | rs_vec3_t rs_vec3_exp_interpolate2(rs_vec3_t v_from, rs_vec3_t v_to, float dt); 199 | 200 | float rs_clamp_angle(float f); 201 | 202 | 203 | int rs_cyclic_mod_i(int value, int base); 204 | float rs_cyclic_mod_f(float value, float base); 205 | 206 | rs_vec3_t rs_vec3_bezier3( rs_vec3_t v0, rs_vec3_t v1, rs_vec3_t v2, rs_vec3_t v3, float pos ); 207 | rs_vec3_t rs_vec3_bezier2( rs_vec3_t v0, rs_vec3_t v1, rs_vec3_t v2, float pos ); 208 | 209 | rs_vec3_t rs_vec3_linear( rs_vec3_t v0, rs_vec3_t v1, float pos ); 210 | rs_vec2_t rs_vec2_linear( rs_vec2_t v0, rs_vec2_t v1, float pos ); 211 | 212 | void rs_mx_linear( rs_mx_t dest, rs_mx_t src1, rs_mx_t src2, float pos ); 213 | 214 | unsigned int rs_log2_i (unsigned int i); 215 | 216 | float rs_spline(float v0, float v1, float v2, float v3, float t); 217 | 218 | float rs_short_angle_dist(float a0, float a1); 219 | 220 | float rs_rand(); 221 | 222 | #endif // rs_mx_t_H_INCLUDED 223 | 224 | -------------------------------------------------------------------------------- /src/rvtgen3d/tileloader.c: -------------------------------------------------------------------------------- 1 | #include "tileloader.h" 2 | 3 | #include "rvtgen.h" 4 | #include "rvtloader.h" 5 | 6 | #ifdef STREETS_GAME 7 | #include "rsbullet.h" // for heightmap 8 | #endif 9 | 10 | #include 11 | 12 | #include "rs/rsdebug.h" 13 | 14 | rvt_tile_loader_struct_t rvt_tile_loader_reg; 15 | 16 | RS_THREAD_T rvt_tile_loader_thread; 17 | 18 | RS_THREAD_FUNC_T rvt_tile_loader_thread_func() { 19 | 20 | int subpak_z; 21 | 22 | // 1. heightmap 23 | 24 | subpak_z = 11; 25 | 26 | unsigned char *super_tile_data; 27 | unsigned int super_tile_data_len; 28 | 29 | heightmap_load_tile_to_data( &super_tile_data, &super_tile_data_len, 30 | rvt_tile_loader_reg.tile_z, rvt_tile_loader_reg.tile_world_ix, rvt_tile_loader_reg.tile_world_iy, 31 | subpak_z, 0 /* !! unused */, rvt_tile_loader_reg.tile_ix, rvt_tile_loader_reg.tile_iy, 32 | rvt_tile_loader_reg.tile_px, rvt_tile_loader_reg.tile_py); 33 | 34 | 35 | RS_MUTEX_LOCK(&rvt_tile_loader_reg.mutex); 36 | rvt_tile_loader_reg.super_tile_data = super_tile_data; 37 | rvt_tile_loader_reg.super_tile_data_len = super_tile_data_len; 38 | rvt_tile_loader_reg.hm_ready = 1; 39 | 40 | RS_MUTEX_UNLOCK(&rvt_tile_loader_reg.mutex); 41 | 42 | // wait until pending heightmap of current layer is created by main thread 43 | int loop = 1; 44 | while (loop) { 45 | rvt_app_sleep_msec(1); 46 | RS_MUTEX_LOCK(&rvt_tile_loader_reg.mutex); 47 | loop = (rvt_tile_loader_reg.hm_ready != 0); 48 | RS_MUTEX_UNLOCK(&rvt_tile_loader_reg.mutex); 49 | }; 50 | 51 | 52 | // 2. geodata 53 | 54 | subpak_z = 12; 55 | 56 | 57 | for (int i = 0; i < 4; i++) { 58 | 59 | rvt_load_tile(14, rvt_tile_loader_reg.tile_world_ix, rvt_tile_loader_reg.tile_world_iy, subpak_z, i, 60 | rvt_tile_loader_reg.tile_ix, rvt_tile_loader_reg.tile_iy, rvt_tile_loader_reg.tile_px, rvt_tile_loader_reg.tile_py, 61 | rvt_app_get_sc() ); 62 | 63 | }; 64 | gd_gen_geom(rvt_tile_loader_reg.tile_i); 65 | 66 | rvt_app_get_geodata()->tile[rvt_tile_loader_reg.tile_i].status = RVT_TILE_STATUS_LOADED; 67 | 68 | DEBUG20f("gd_gen_geom() done, tile loader done. tile_i %d status is LOADED.\n", rvt_tile_loader_reg.tile_i); 69 | 70 | rvt_tile_loader_reg.status = RVT_TILE_LOADER_STATUS_OFF; 71 | rvt_app_increase_threads_count(-1); // rs_app.child_threads_count--; 72 | RS_THREAD_RETURN(0); 73 | 74 | }; 75 | 76 | void rvt_tile_loader_load_tile(int tile_z, int tile_world_ix, int tile_world_iy, int tile_i, int tile_px, int tile_py) { 77 | 78 | RS_THREAD_FUNC_T* func = (RS_THREAD_FUNC_T*) &rvt_tile_loader_thread_func; 79 | 80 | rvt_tile_loader_reg.tile_z = tile_z; 81 | rvt_tile_loader_reg.tile_world_ix = tile_world_ix; 82 | rvt_tile_loader_reg.tile_world_iy = tile_world_iy; 83 | 84 | rvt_tile_loader_reg.tile_i = tile_i; 85 | rvt_tile_loader_reg.tile_ix = tile_i % RVT_TILES_SIDE_COUNT; 86 | rvt_tile_loader_reg.tile_iy = tile_i / RVT_TILES_SIDE_COUNT; 87 | 88 | rvt_tile_loader_reg.tile_px = tile_px; 89 | rvt_tile_loader_reg.tile_py = tile_py; 90 | 91 | rvt_tile_loader_reg.status = RVT_TILE_LOADER_STATUS_LOADING; 92 | 93 | 94 | RS_MUTEX_INIT(&rvt_tile_loader_reg.mutex); 95 | RS_THREAD_CREATE(rvt_tile_loader_thread, ( void*(*)(void*) ) func, 0); 96 | rvt_app_increase_threads_count(1); // rs_app.child_threads_count++; 97 | 98 | 99 | }; 100 | 101 | void rvt_tile_loader_init() { 102 | 103 | memset(&rvt_tile_loader_reg, 0, sizeof(rvt_tile_loader_struct_t) ); 104 | 105 | }; 106 | 107 | void rvt_tile_loader_halt() { 108 | 109 | return; // Not implemented in this version 110 | 111 | }; 112 | 113 | #ifndef VBO_TERRAIN 114 | #define VBO_TERRAIN 0 115 | #endif // VBO_TERRAIN 116 | 117 | void rvt_tile_loader_check_mainthread() { 118 | 119 | 120 | RS_MUTEX_LOCK(&rvt_tile_loader_reg.mutex); 121 | 122 | if (rvt_tile_loader_reg.status == RVT_TILE_LOADER_STATUS_ERROR_CORRUPTED_FILE) { 123 | 124 | rs_show_message("Corrupted file!"); 125 | rvt_tile_loader_reg.status = RVT_TILE_LOADER_STATUS_OFF; 126 | 127 | }; 128 | 129 | if (rvt_tile_loader_reg.hm_ready) { 130 | 131 | int subpak_z = 11; 132 | int vbo_index = VBO_TERRAIN + rvt_tile_loader_reg.tile_i; 133 | 134 | heightmap_load_tile_from_data( rvt_tile_loader_reg.super_tile_data, rvt_tile_loader_reg.super_tile_data_len, 135 | 14, rvt_tile_loader_reg.tile_world_ix, rvt_tile_loader_reg.tile_world_iy, subpak_z, 136 | vbo_index, rvt_tile_loader_reg.tile_ix, 137 | rvt_tile_loader_reg.tile_iy, 138 | rvt_tile_loader_reg.tile_px, rvt_tile_loader_reg.tile_py); 139 | 140 | rvt_app_get_geodata()->hm[rvt_tile_loader_reg.tile_i].status = 1; 141 | 142 | #ifdef STREETS_GAME 143 | int field_size = 33; // 129; 144 | rsph_add_heightmap(rvt_tile_loader_reg.tile_i, field_size, rvt_tile_loader_reg.tile_px, rvt_tile_loader_reg.tile_py); // 145 | #endif 146 | 147 | rvt_app_update_history_game_bases(); 148 | 149 | rvt_tile_loader_reg.hm_ready = 0; 150 | 151 | }; 152 | 153 | if (rvt_tile_loader_reg.st_ready_count > 0) { 154 | 155 | 156 | int max_vertices_per_frame = 15000; 157 | int max_stages_per_frame = 12; 158 | 159 | if ( rvt_app_are_vertices_per_frame_unlimited() ) { 160 | max_vertices_per_frame = 99000000; 161 | max_stages_per_frame = 99999; 162 | }; 163 | 164 | 165 | int total_vertices_written = 0; 166 | int total_indices_written = 0; 167 | int total_stages_passed = 0; 168 | 169 | for (int i = rvt_tile_loader_reg.st_ready_count-1; (i >= 0) && (i > rvt_tile_loader_reg.st_ready_count-1-max_stages_per_frame); i--) { 170 | 171 | if (!rvt_app_is_exporting()) { 172 | rvt_app_create_subtile_raw_vbo(i); 173 | }; 174 | 175 | total_stages_passed++; 176 | total_vertices_written += rvt_tile_loader_reg.st_rec[i].st_total_vertices; 177 | total_indices_written += rvt_tile_loader_reg.st_rec[i].st_total_indices; 178 | if (total_vertices_written > max_vertices_per_frame) { 179 | break; 180 | }; 181 | 182 | if (i > 0) { 183 | if ( (total_vertices_written + rvt_tile_loader_reg.st_rec[i].st_total_vertices) > max_vertices_per_frame ) { 184 | break; 185 | } 186 | }; 187 | 188 | 189 | }; 190 | 191 | rvt_tile_loader_reg.st_ready_count = rs_max_i(0, rvt_tile_loader_reg.st_ready_count - total_stages_passed); 192 | 193 | }; 194 | 195 | RS_MUTEX_UNLOCK(&rvt_tile_loader_reg.mutex); 196 | 197 | }; 198 | -------------------------------------------------------------------------------- /src/rvtgen3d/rs/rsnoise.c: -------------------------------------------------------------------------------- 1 | #include "rsnoise.h" 2 | 3 | #include 4 | 5 | rs_perlin_conf_t rs_perlin_conf; 6 | 7 | void rs_perlin_configure(float freq, int octaves, float persistence, float seed, int tex_size, int shift_y) { 8 | rs_perlin_conf.freq = freq; 9 | rs_perlin_conf.octaves = octaves; 10 | rs_perlin_conf.persistence = persistence; 11 | rs_perlin_conf.seed = seed; 12 | rs_perlin_conf.tex_size = tex_size; 13 | rs_perlin_conf.period = (int) (0.1 + roundf(freq) ); 14 | rs_perlin_conf.shift_y = shift_y; 15 | }; 16 | 17 | float rs_noise(int x, int y) { 18 | // from here, http://www.cplusplus.com/forum/general/85758/ 19 | // koef. changed 20 | int n = x + y * 57 * 5; 21 | n = (n << 13) ^ n; 22 | int t = (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff; 23 | float ret = 1.0 - ((float)t) * 0.931322574615478515625e-9; 24 | return ret; 25 | }; 26 | 27 | float rs_noise_for_perlin(int x, int y) { 28 | 29 | x %= rs_perlin_conf.period; 30 | y %= rs_perlin_conf.period; 31 | 32 | // from here, http://www.cplusplus.com/forum/general/85758/ 33 | // koef. changed 34 | int n = x + y * 57 * 5; 35 | n = (n << 13) ^ n; 36 | int t = (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff; 37 | return 1.0 - ((float)t) * 0.931322574615478515625e-9; 38 | }; 39 | 40 | 41 | double rs_interpolate(double x, double y, double a) { 42 | 43 | float c = 0.5 + 0.5*cos( a * M_PI ); 44 | 45 | return y*(1.0 - c) + x*c; 46 | 47 | } 48 | 49 | double rs_perlin_noise(double x, double y) { 50 | 51 | int Xint = (int)x; 52 | int Yint = (int)y; 53 | double Xfrac = x - Xint; 54 | double Yfrac = y - Yint; 55 | 56 | double n01= rs_noise_for_perlin(Xint-1, Yint-1); 57 | double n02= rs_noise_for_perlin(Xint+1, Yint-1); 58 | double n03= rs_noise_for_perlin(Xint-1, Yint+1); 59 | double n04= rs_noise_for_perlin(Xint+1, Yint+1); 60 | double n05= rs_noise_for_perlin(Xint-1, Yint); 61 | double n06= rs_noise_for_perlin(Xint+1, Yint); 62 | double n07= rs_noise_for_perlin(Xint, Yint-1); 63 | double n08= rs_noise_for_perlin(Xint, Yint+1); 64 | double n09= rs_noise_for_perlin(Xint, Yint); 65 | 66 | double n12= rs_noise_for_perlin(Xint+2, Yint-1); 67 | double n14= rs_noise_for_perlin(Xint+2, Yint+1); 68 | double n16= rs_noise_for_perlin(Xint+2, Yint); 69 | 70 | double n23= rs_noise_for_perlin(Xint-1, Yint+2); 71 | double n24= rs_noise_for_perlin(Xint+1, Yint+2); 72 | double n28= rs_noise_for_perlin(Xint, Yint+2); 73 | 74 | double n34= rs_noise_for_perlin(Xint+2, Yint+2); 75 | 76 | //find the noise values of the four corners 77 | double x0y0 = 0.0625*(n01+n02+n03+n04) + 0.125*(n05+n06+n07+n08) + 0.25*(n09); 78 | double x1y0 = 0.0625*(n07+n12+n08+n14) + 0.125*(n09+n16+n02+n04) + 0.25*(n06); 79 | double x0y1 = 0.0625*(n05+n06+n23+n24) + 0.125*(n03+n04+n09+n28) + 0.25*(n08); 80 | double x1y1 = 0.0625*(n09+n16+n28+n34) + 0.125*(n08+n14+n06+n24) + 0.25*(n04); 81 | 82 | //interpolate between those values according to the x and y fractions 83 | double v1 = rs_interpolate(x0y0, x1y0, Xfrac); //interpolate in x direction (y) 84 | double v2 = rs_interpolate(x0y1, x1y1, Xfrac); //interpolate in x direction (y+1) 85 | double fin = rs_interpolate(v1, v2, Yfrac); //interpolate in y direction 86 | 87 | return fin; 88 | } 89 | 90 | float rs_perlin(float i, float j) { 91 | 92 | double t = 0.0f; 93 | double _amplitude = 1.0; 94 | 95 | 96 | int k; 97 | 98 | float amplitude_divider = 0.0; 99 | for (k = 0; k < rs_perlin_conf.octaves; k++) { 100 | amplitude_divider += _amplitude; 101 | _amplitude *= rs_perlin_conf.persistence; 102 | }; 103 | 104 | _amplitude = 1.0; 105 | 106 | float freq = rs_perlin_conf.freq; 107 | 108 | for(k = 0; k < rs_perlin_conf.octaves; k++) 109 | { 110 | t += rs_perlin_noise(j * freq / rs_perlin_conf.tex_size + rs_perlin_conf.seed, i * freq / rs_perlin_conf.tex_size + rs_perlin_conf.seed) * _amplitude; 111 | _amplitude *= rs_perlin_conf.persistence; 112 | freq *= 2; 113 | } 114 | 115 | return t / amplitude_divider; 116 | }; 117 | 118 | float rs_quad_noise(float i, float j) { 119 | 120 | double t = 0.0f; 121 | double _amplitude = 1.0; 122 | 123 | 124 | int k; 125 | 126 | float amplitude_divider = 0.0; 127 | for (k = 0; k < rs_perlin_conf.octaves; k++) { 128 | amplitude_divider += _amplitude; 129 | _amplitude *= rs_perlin_conf.persistence; 130 | }; 131 | 132 | _amplitude = 1.0; 133 | 134 | float freq = rs_perlin_conf.freq; 135 | 136 | for(k = 0; k < rs_perlin_conf.octaves; k++) 137 | { 138 | t += rs_noise(j * freq / rs_perlin_conf.tex_size + rs_perlin_conf.seed, i * freq / rs_perlin_conf.tex_size + rs_perlin_conf.seed) * _amplitude; 139 | _amplitude *= rs_perlin_conf.persistence; 140 | freq *= 2; 141 | } 142 | 143 | return t / amplitude_divider; 144 | }; 145 | 146 | 147 | 148 | // ============================== NEW PERLIN ============================= 149 | // from here: http://freespace.virgin.net/hugo.elias/models/m_perlin.htm 150 | 151 | 152 | 153 | float rs_new_noise(int x, int y) { 154 | int n = x + (y) * 57 + rs_perlin_conf.seed; 155 | n = (n<<13) ^ n; 156 | return ( 1.0 - ( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); 157 | } 158 | 159 | float SmoothNoise_1(float x, float y) { 160 | float corners = ( rs_new_noise(x-1, y-1)+rs_new_noise(x+1, y-1)+rs_new_noise(x-1, y+1)+rs_new_noise(x+1, y+1) ) / 16; 161 | float sides = ( rs_new_noise(x-1, y) +rs_new_noise(x+1, y) +rs_new_noise(x, y-1) +rs_new_noise(x, y+1) ) / 8; 162 | float center = rs_new_noise(x, y) / 4; 163 | return corners + sides + center; 164 | } 165 | 166 | float InterpolatedNoise_1(float x, float y) { 167 | 168 | int integer_X = (int) (x); 169 | float fractional_X = x - integer_X; 170 | 171 | int integer_Y = (int) (y); 172 | float fractional_Y = y - integer_Y; 173 | 174 | float v1 = SmoothNoise_1(integer_X, integer_Y); 175 | float v2 = SmoothNoise_1(integer_X + 1, integer_Y); 176 | float v3 = SmoothNoise_1(integer_X, integer_Y + 1); 177 | float v4 = SmoothNoise_1(integer_X + 1, integer_Y + 1); 178 | 179 | float i1 = rs_interpolate(v1 , v2 , fractional_X); 180 | float i2 = rs_interpolate(v3 , v4 , fractional_X); 181 | 182 | return rs_interpolate(i1 , i2 , fractional_Y); 183 | 184 | }; 185 | 186 | 187 | float rs_new_perlin_noise(float x, float y) { 188 | 189 | float total = 0; 190 | float p = rs_perlin_conf.persistence; 191 | int n = rs_perlin_conf.octaves - 1; 192 | float frequency; 193 | float amplitude; 194 | 195 | int i; 196 | for (i = 0; i < n; i++) { 197 | 198 | frequency = pow(2.0, i) * rs_perlin_conf.period / rs_perlin_conf.tex_size; 199 | amplitude = pow(p, i); 200 | 201 | total = total + InterpolatedNoise_1 ( (x + 1.0*rs_perlin_conf.shift_y) * frequency, (y ) * frequency) * amplitude; 202 | 203 | } 204 | 205 | return total; 206 | 207 | }; 208 | 209 | 210 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/bridge-base.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'bridge.blend' 4 | element vertex 68 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 34 17 | property list uchar uint vertex_indices 18 | end_header 19 | -0.500000 0.000000 1.000000 -0.969402 -0.245480 -0.000000 0.426208 0.500000 143 143 143 20 | -0.350000 -0.592351 -0.700000 -0.969402 -0.245480 -0.000000 0.073792 0.203824 143 143 143 21 | -0.350000 -0.592351 0.700000 -0.969402 -0.245480 -0.000000 0.426208 0.203824 143 143 143 22 | -0.500000 0.000000 -1.000000 0.000000 -0.451815 -0.892111 1.073792 0.500000 143 143 143 23 | 0.350000 -0.592351 -0.700000 0.000000 -0.451815 -0.892111 0.926208 0.203824 143 143 143 24 | -0.350000 -0.592351 -0.700000 0.000000 -0.451815 -0.892111 1.073792 0.203824 143 143 143 25 | 0.500000 0.000000 -1.000000 0.969402 -0.245480 0.000000 0.926208 0.500000 143 143 143 26 | 0.350000 -0.592351 0.700000 0.969402 -0.245480 0.000000 0.573792 0.203824 143 143 143 27 | 0.350000 -0.592351 -0.700000 0.969402 -0.245480 0.000000 0.926208 0.203824 143 143 143 28 | 0.500000 0.000000 1.000000 0.000000 -0.451815 0.892111 0.573792 0.500000 143 143 143 29 | -0.350000 -0.592351 0.700000 0.000000 -0.451815 0.892111 0.426208 0.203824 143 143 143 30 | 0.350000 -0.592351 0.700000 0.000000 -0.451815 0.892111 0.573792 0.203824 143 143 143 31 | -0.500000 0.000000 -1.000000 0.000000 1.000000 -0.000000 0.999929 0.500000 143 143 143 32 | 0.500000 0.000000 1.000000 0.000000 1.000000 -0.000000 0.000071 0.000071 143 143 143 33 | 0.500000 0.000000 -1.000000 0.000000 1.000000 -0.000000 0.999929 0.000071 143 143 143 34 | 0.536022 -4.027119 1.072044 -0.000000 0.179862 0.983692 0.573792 -1.513560 143 143 143 35 | -0.350000 -1.992351 0.700000 -0.000000 0.179862 0.983692 0.426208 -0.496176 143 143 143 36 | -0.536022 -4.027119 1.072044 -0.000000 0.179862 0.983692 0.426208 -1.513560 143 143 143 37 | 0.350000 -0.592351 0.700000 0.000000 -0.000000 1.000000 0.573792 0.203824 143 143 143 38 | -0.350000 -1.992351 0.700000 0.000000 -0.000000 1.000000 0.426208 -0.496176 143 143 143 39 | 0.350000 -1.992351 0.700000 0.000000 -0.000000 1.000000 0.573792 -0.496176 143 143 143 40 | 0.350000 -1.992351 -0.700000 0.995847 0.091042 -0.000000 0.926208 -0.496176 143 143 143 41 | 0.536022 -4.027119 1.072044 0.995847 0.091042 -0.000000 0.573792 -1.513560 143 143 143 42 | 0.536022 -4.027119 -1.072044 0.995847 0.091042 -0.000000 0.926208 -1.513560 143 143 143 43 | 0.350000 -0.592351 -0.700000 1.000000 -0.000000 0.000000 0.926208 0.203824 143 143 143 44 | 0.350000 -1.992351 0.700000 1.000000 -0.000000 0.000000 0.573792 -0.496176 143 143 143 45 | 0.350000 -1.992351 -0.700000 1.000000 -0.000000 0.000000 0.926208 -0.496176 143 143 143 46 | -0.350000 -1.992351 -0.700000 0.000000 0.179862 -0.983692 1.073792 -0.496176 143 143 143 47 | 0.536022 -4.027119 -1.072044 0.000000 0.179862 -0.983692 0.926208 -1.513560 143 143 143 48 | -0.536022 -4.027119 -1.072044 0.000000 0.179862 -0.983692 1.073792 -1.513560 143 143 143 49 | -0.350000 -0.592351 -0.700000 0.000000 0.000000 -1.000000 1.073792 0.203824 143 143 143 50 | 0.350000 -1.992351 -0.700000 0.000000 0.000000 -1.000000 0.926208 -0.496176 143 143 143 51 | -0.350000 -1.992351 -0.700000 0.000000 0.000000 -1.000000 1.073792 -0.496176 143 143 143 52 | -0.350000 -1.992351 0.700000 -0.995847 0.091042 0.000000 0.426208 -0.496176 143 143 143 53 | -0.536022 -4.027119 -1.072044 -0.995847 0.091042 0.000000 0.073792 -1.513560 143 143 143 54 | -0.536022 -4.027119 1.072044 -0.995847 0.091042 0.000000 0.426208 -1.513560 143 143 143 55 | -0.350000 -0.592351 0.700000 -1.000000 0.000000 0.000000 0.426208 0.203824 143 143 143 56 | -0.350000 -1.992351 -0.700000 -1.000000 0.000000 0.000000 0.073792 -0.496176 143 143 143 57 | -0.350000 -1.992351 0.700000 -1.000000 0.000000 0.000000 0.426208 -0.496176 143 143 143 58 | 0.536022 -4.027119 1.072044 1.000000 0.000000 -0.000000 0.573792 -1.513560 143 143 143 59 | 0.536022 -20.027119 -1.072044 1.000000 0.000000 -0.000000 0.926208 -9.513560 143 143 143 60 | 0.536022 -4.027119 -1.072044 1.000000 0.000000 -0.000000 0.926208 -1.513560 143 143 143 61 | -0.536022 -4.027119 -1.072044 -1.000000 -0.000000 -0.000000 0.073792 -1.513560 143 143 143 62 | -0.536022 -20.027119 1.072044 -1.000000 -0.000000 -0.000000 0.426208 -9.513560 143 143 143 63 | -0.536022 -4.027119 1.072044 -1.000000 -0.000000 -0.000000 0.426208 -1.513560 143 143 143 64 | -0.536022 -4.027119 1.072044 0.000000 0.000000 1.000000 0.426208 -1.513560 143 143 143 65 | 0.536022 -20.027119 1.072044 0.000000 0.000000 1.000000 0.573792 -9.513560 143 143 143 66 | 0.536022 -4.027119 1.072044 0.000000 0.000000 1.000000 0.573792 -1.513560 143 143 143 67 | 0.536022 -4.027119 -1.072044 0.000000 0.000000 -1.000000 0.926208 -1.513560 143 143 143 68 | -0.536022 -20.027119 -1.072044 0.000000 0.000000 -1.000000 1.073792 -9.513560 143 143 143 69 | -0.536022 -4.027119 -1.072044 0.000000 0.000000 -1.000000 1.073792 -1.513560 143 143 143 70 | -0.500000 0.000000 -1.000000 -0.969402 -0.245480 0.000000 0.073792 0.500000 143 143 143 71 | 0.500000 0.000000 -1.000000 -0.000000 -0.451815 -0.892111 0.926208 0.500000 143 143 143 72 | 0.500000 0.000000 1.000000 0.969402 -0.245480 0.000000 0.573792 0.500000 143 143 143 73 | -0.500000 0.000000 1.000000 0.000000 -0.451815 0.892111 0.426208 0.500000 143 143 143 74 | -0.500000 0.000000 1.000000 0.000000 1.000000 0.000000 0.000071 0.500000 143 143 143 75 | 0.350000 -1.992351 0.700000 -0.000000 0.179862 0.983692 0.573792 -0.496176 143 143 143 76 | -0.350000 -0.592351 0.700000 0.000000 0.000000 1.000000 0.426208 0.203824 143 143 143 77 | 0.350000 -1.992351 0.700000 0.995847 0.091042 0.000000 0.573792 -0.496176 143 143 143 78 | 0.350000 -0.592351 0.700000 1.000000 -0.000000 0.000000 0.573792 0.203824 143 143 143 79 | 0.350000 -1.992351 -0.700000 0.000000 0.179862 -0.983692 0.926208 -0.496176 143 143 143 80 | 0.350000 -0.592351 -0.700000 0.000000 0.000000 -1.000000 0.926208 0.203824 143 143 143 81 | -0.350000 -1.992351 -0.700000 -0.995847 0.091042 0.000000 0.073792 -0.496176 143 143 143 82 | -0.350000 -0.592351 -0.700000 -1.000000 0.000000 0.000000 0.073792 0.203824 143 143 143 83 | 0.536022 -20.027119 1.072044 1.000000 0.000000 0.000000 0.573792 -9.513560 143 143 143 84 | -0.536022 -20.027119 -1.072044 -1.000000 0.000000 0.000000 0.073792 -9.513560 143 143 143 85 | -0.536022 -20.027119 1.072044 0.000000 -0.000000 1.000000 0.426208 -9.513560 143 143 143 86 | 0.536022 -20.027119 -1.072044 0.000000 0.000000 -1.000000 0.926208 -9.513560 143 143 143 87 | 3 0 1 2 88 | 3 3 4 5 89 | 3 6 7 8 90 | 3 9 10 11 91 | 3 12 13 14 92 | 3 15 16 17 93 | 3 18 19 20 94 | 3 21 22 23 95 | 3 24 25 26 96 | 3 27 28 29 97 | 3 30 31 32 98 | 3 33 34 35 99 | 3 36 37 38 100 | 3 39 40 41 101 | 3 42 43 44 102 | 3 45 46 47 103 | 3 48 49 50 104 | 3 0 51 1 105 | 3 3 52 4 106 | 3 6 53 7 107 | 3 9 54 10 108 | 3 12 55 13 109 | 3 15 56 16 110 | 3 18 57 19 111 | 3 21 58 22 112 | 3 24 59 25 113 | 3 27 60 28 114 | 3 30 61 31 115 | 3 33 62 34 116 | 3 36 63 37 117 | 3 39 64 40 118 | 3 42 65 43 119 | 3 45 66 46 120 | 3 48 67 49 121 | -------------------------------------------------------------------------------- /src/tiffcompose/tiffcompose.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2020, Roman Shuvalov, www.romanshuvalov.com 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | #include 39 | 40 | #include 41 | 42 | using namespace std; 43 | 44 | char *filename; 45 | char *out_filename; 46 | 47 | 48 | void DummyHandler(const char* module, const char* fmt, va_list ap) 49 | { 50 | // ignore errors and warnings (or handle them your own way) 51 | }; 52 | 53 | int main(int argc, char* argv[]) { 54 | 55 | TIFFSetWarningHandler(DummyHandler); 56 | 57 | if (argc != 5) { 58 | cerr << "Usage: " << argv[0] << " " << endl; 59 | return -1; 60 | } 61 | 62 | char *fn_tiff1 = argv[1]; 63 | char *fn_tiff2 = argv[2]; 64 | char *fn_tiff_mask = argv[3]; 65 | char *fn_tiff_out = argv[4]; 66 | 67 | // only check 68 | FILE *fp; 69 | 70 | fp = fopen(fn_tiff1, "rb"); 71 | if (!fp) { 72 | fprintf(stderr, "Not found: %s. Aborted.\n", fn_tiff1); 73 | return -1; 74 | }; 75 | fclose(fp); 76 | 77 | fp = fopen(fn_tiff2, "rb"); 78 | if (!fp) { 79 | fprintf(stderr, "Not found: %s. Aborted.\n", fn_tiff2); 80 | return -1; 81 | }; 82 | fclose(fp); 83 | 84 | fp = fopen(fn_tiff_mask, "rb"); 85 | if (!fp) { 86 | fprintf(stderr, "Not found: %s. Aborted.\n", fn_tiff_mask); 87 | return -1; 88 | }; 89 | fclose(fp); 90 | 91 | 92 | TIFF *tiff1 = TIFFOpen(fn_tiff1, "rb"); 93 | 94 | TIFF *tiff2 = TIFFOpen(fn_tiff2, "rb"); 95 | 96 | TIFF *tiff_mask = TIFFOpen(fn_tiff_mask, "rb"); 97 | 98 | TIFF *tiff_out = TIFFOpen(fn_tiff_out, "rb+"); 99 | 100 | 101 | 102 | uint32_t width = 0, height = 0, bits_per_sample = 0, samples_per_pixel = 0, sample_format = 0; 103 | 104 | 105 | 106 | TIFFGetField(tiff1, TIFFTAG_IMAGEWIDTH, &width); // uint32 width; 107 | TIFFGetField(tiff1, TIFFTAG_IMAGELENGTH, &height); // uint32 height; 108 | 109 | TIFFGetField(tiff1, TIFFTAG_BITSPERSAMPLE, &bits_per_sample); 110 | TIFFGetField(tiff1, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel); 111 | TIFFGetField(tiff1, TIFFTAG_SAMPLEFORMAT, &sample_format); 112 | 113 | 114 | 115 | printf("%s: (%d x %d, %d bit) (samples per pixel: %d, format: %d) \n", fn_tiff1, width, height, bits_per_sample, samples_per_pixel, sample_format); 116 | 117 | if ( (bits_per_sample != 16) || (sample_format != 2) || (samples_per_pixel != 1) ) { 118 | fprintf(stderr, "ERROR: Bad format. Aborted. \n\n"); 119 | TIFFClose(tiff1); 120 | TIFFClose(tiff2); 121 | TIFFClose(tiff_mask); 122 | TIFFClose(tiff_out); 123 | exit(-1); 124 | }; 125 | 126 | uint32_t width2 = 0, height2 = 0, bits_per_sample2 = 0, samples_per_pixel2 = 0, sample_format2 = 0; 127 | 128 | TIFFGetField(tiff2, TIFFTAG_IMAGEWIDTH, &width2); // uint32 width; 129 | TIFFGetField(tiff2, TIFFTAG_IMAGELENGTH, &height2); // uint32 height; 130 | 131 | TIFFGetField(tiff2, TIFFTAG_BITSPERSAMPLE, &bits_per_sample2); 132 | TIFFGetField(tiff2, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel2); 133 | TIFFGetField(tiff2, TIFFTAG_SAMPLEFORMAT, &sample_format2); 134 | 135 | printf("%s: (%d x %d, %d bit) (samples per pixel: %d, format: %d) \n", fn_tiff2, width2, height2, bits_per_sample2, samples_per_pixel2, sample_format2); 136 | 137 | if ( 138 | (width != width2) 139 | || (height != height2) 140 | || (bits_per_sample != bits_per_sample2) 141 | || (samples_per_pixel != samples_per_pixel2) 142 | || (sample_format != sample_format2) 143 | 144 | ) { 145 | 146 | fprintf(stderr, "ERROR: Format of %s is different from %s. Aborted. \n", fn_tiff2, fn_tiff1 ); 147 | 148 | TIFFClose(tiff1); 149 | TIFFClose(tiff2); 150 | TIFFClose(tiff_mask); 151 | TIFFClose(tiff_out); 152 | 153 | exit(-1); 154 | 155 | }; 156 | 157 | 158 | 159 | uint32_t width_mask = 0, height_mask = 0, bits_per_sample_mask = 0, samples_per_pixel_mask = 0, sample_format_mask = 0; 160 | 161 | TIFFGetField(tiff_mask, TIFFTAG_IMAGEWIDTH, &width_mask); // uint32 width; 162 | TIFFGetField(tiff_mask, TIFFTAG_IMAGELENGTH, &height_mask); // uint32 height; 163 | 164 | TIFFGetField(tiff_mask, TIFFTAG_BITSPERSAMPLE, &bits_per_sample_mask); 165 | TIFFGetField(tiff_mask, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel_mask); 166 | TIFFGetField(tiff_mask, TIFFTAG_SAMPLEFORMAT, &sample_format_mask); 167 | 168 | printf("%s: (%d x %d, %d bit) (samples per pixel: %d, format: %d) \n", fn_tiff_mask, width_mask, height_mask, bits_per_sample_mask, samples_per_pixel_mask, sample_format_mask); 169 | 170 | 171 | 172 | int16_t *buf1, *buf2; 173 | uint8_t *buf_mask; 174 | tsize_t scanline = TIFFScanlineSize(tiff1); 175 | 176 | if (TIFFScanlineSize(tiff2) != scanline) { 177 | fprintf(stderr, "ERROR: Scanline Size of %s (%d) is different from %s (%d).\n", fn_tiff2, (TIFFScanlineSize(tiff2)), fn_tiff1, scanline ); 178 | return -1; 179 | }; 180 | if (2*TIFFScanlineSize(tiff_mask) != scanline) { 181 | fprintf(stderr, "ERROR: Scanline Size of %s (%d) must be 1/2 of scanline size of %s (%d).\n", fn_tiff_mask, (TIFFScanlineSize(tiff_mask)), fn_tiff1, scanline ); 182 | return -1; 183 | }; 184 | 185 | 186 | buf1 = (int16_t*) _TIFFmalloc(scanline); 187 | buf2 = (int16_t*) _TIFFmalloc(scanline); 188 | buf_mask = (uint8_t*) _TIFFmalloc(scanline); 189 | 190 | 191 | for (uint32_t row = 0; row < height; row++) { 192 | 193 | TIFFReadScanline(tiff1, buf1, row); 194 | TIFFReadScanline(tiff2, buf2, row); 195 | TIFFReadScanline(tiff_mask, buf_mask, row); 196 | 197 | 198 | for (int i = 0; i < width; i++) { 199 | 200 | float k = 1.0 / 255.0 * buf_mask[i]; 201 | 202 | buf1[i] = (int16_t) ( (1.0-k)*buf1[i] + k*buf2[i] ); 203 | 204 | }; 205 | 206 | 207 | TIFFWriteScanline(tiff_out, buf1, row); 208 | 209 | }; 210 | 211 | _TIFFfree(buf1); 212 | _TIFFfree(buf2); 213 | _TIFFfree(buf_mask); 214 | 215 | 216 | 217 | TIFFClose(tiff1); 218 | TIFFClose(tiff2); 219 | TIFFClose(tiff_mask); 220 | TIFFClose(tiff_out); 221 | 222 | 223 | 224 | printf("Done.\n"); 225 | 226 | return 0; 227 | } 228 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rsgeotools & rvtgen3d 2 | 3 | OpenStreetMap-based 3D world generator. Originally it was part of Generation Streets, OSM-based video game. Now it is released as a separated command-line tool named **rvtgen3d** and distributed under free license as part of **rsgeotools** toolset. 4 | 5 | ![Screenshot](https://streets.romanshuvalov.com/screenshots/github/rvtgen3d-park1.jpg) 6 | 7 | Features: 8 | * 3D buildings with roof decorations and entrances 9 | * Roof shapes (only dome, onion and cone/pyramid are supported) 10 | * Randomly generated rural houses 11 | * Terrain surface map 12 | * Road marking 13 | * Trees and bushes 14 | * Street lighting on roads and pavements 15 | * Rail roads 16 | * Power tower and power lines (limited support) 17 | * Walls and fences 18 | * Apocalypse-styled destroyed bridges 19 | * Relief, based on other sources, see below 20 | 21 | Please note that this toolset only can generate 3D models, no visual renderer provided. Also, it's designed for mass processing and may not be convenient for single use. 22 | 23 | If you only want to see certain territory rendered in 3D, check out `Generation Streets`: 24 | 25 | * **[Get Generation Streets on Steam](https://store.steampowered.com/app/887970/Generation_Streets/)**. It's free, but you may want to unlock access to global coverage for ~$5. 26 | 27 | To build your own command-line toolset, read instructions below. 28 | 29 | ![Screenshot](https://streets.romanshuvalov.com/screenshots/github/rvtgen3d-zh1.jpg) 30 | 31 | ## Dependencies 32 | 33 | * libgeos_c, LGPL-licensed, for rsgeotools-csv2rvtdata 34 | * gdal, MIT/X style license, for processing heightmaps with rsgeotools-conv and for processing geodata 35 | * libtiff-dev and geotiff-bin, for processing TIFF images 36 | * osmctools (osmconvert and osmfilter) for initial processing OSM planet 37 | * boost library 38 | * zlib, bzip2 and pthread libraries 39 | 40 | This toolset is designed to work on Linux. 41 | 42 | ## Compile 43 | 44 | Just run `make`. 45 | 46 | # Usage (preparation of vector tiles) 47 | 48 | Warning: compiled binaries (`bin` directory) and scripts (`scripts` directory) must be in PATH environment variable. 49 | 50 | Warning: all paths in environment variables must be absolute. 51 | 52 | ## 1. Prepare OSM Planet 53 | 54 | 1. Download OSM Planet from https://planet.openstreetmap.org/ in PBF format. 55 | 2. Run `RVT_O5M_DIR= rsgeotools-planet-init.sh `. 56 | 57 | Planet will be subdivided to zoom 7 tiles and saved to `$RVT_O5M_DIR` in o5m format. 58 | 59 | ## 2. Prepare ocean (waterpoly) 60 | 61 | In OpenStreetMap, large water areas are not stored as polygons, instead, `natural=coastline` tag is used (read more: https://wiki.openstreetmap.org/wiki/Coastline). Ready-to-use polygons are provided by osmdata.openstreetmap.de. 62 | 63 | 1. Download `water-polygons-split-3857.zip` from https://osmdata.openstreetmap.de/data/water-polygons.html and save it to `$RVT_SHP_DIR` directory. 64 | 2. Rename `shapefiles.` to `ocean0_0_0.`. 65 | 3. Split shapefiles up to zoom level 7: 66 | ```sh 67 | cd $RVT_SHP_DIR 68 | rsgeotools-subdiv-shapefile.sh 0 0 0 1 ocean 69 | rsgeotools-subdiv-shapefile.sh 0 0 0 2 ocean && rm ocean1* 70 | rsgeotools-subdiv-shapefile.sh 0 0 0 3 ocean && rm ocean2* 71 | rsgeotools-subdiv-shapefile.sh 0 0 0 4 ocean && rm ocean3* 72 | rsgeotools-subdiv-shapefile.sh 0 0 0 5 ocean && rm ocean4* 73 | rsgeotools-subdiv-shapefile.sh 0 0 0 6 ocean && rm ocean5* 74 | rsgeotools-subdiv-shapefile.sh 0 0 0 7 ocean && rm ocean6* 75 | ``` 76 | 77 | 4. Split shapefiles up to zoom level 11 and pack them into .tar.gz for further usage: 78 | ```sh 79 | rsgeotools-process-mass-subdiv-shapefile.sh 0 0 0 7 ocean 80 | ``` 81 | 82 | You will need to set `$RVT_SHP_ARCHIVE_DIR` (destination dir), `$RVT_SHP_DIR` (source dir, see above) and `$RVT_TEMP_DIR` (usually /tmp) environment variables. 83 | 84 | ## 3. Process geodata 85 | 86 | Run `rsgeotools-planet-process-full.sh 200331 0`. First argument is a timestamp (*YYMMDD* is recommended). Process can take up to 2-3 weeks depending on your PC performance. In case you need to pause and resume the processing process, use second argument (0-11) to continue from certain stage. Current stage is always written in `$RVT_GPAK_DIR/planet_process_log_file.txt`. 87 | 88 | Additional environment variables required: 89 | * `RVT_GPAK_DIR` -- output directory; 90 | * `RVT_CSV_CONF` -- must be pointed to `conf/osm-conf.ini` file. 91 | 92 | ## 4. Process heightmap data 93 | 94 | Relief is based on these two sources: 95 | * NASADEM, see https://lpdaac.usgs.gov/products/nasadem_hgtv001/ 96 | * ASTER GDEM Version 3, see https://ssl.jspacesystems.or.jp/ersdac/GDEM/E/ 97 | 98 | Both sources have no restrictions on reuse, sale, or redistribution (see https://lpdaac.usgs.gov/data/data-citation-and-policies/). 99 | 100 | Because NASADEM images is less noisy, this dataset has been selected as primary source. ASTER GDEM Version 3 is used if no data available in NASADEM dataset. You need to download both datasets before processing. 101 | 102 | To start processing, run `rsgeotools-process-hm-full.sh`. 103 | 104 | You will need to set following environment variables: 105 | * `RVT_GPAK_DIR` -- output directory for heightmap gpaks, it is recommended to make it different from geodata gpaks which was created above; 106 | * `RVT_HGT_DIR_NASADEM` -- directory containing set of ZIP files of NASADEM; 107 | * `RVT_HGT_DIR_ASTERGDEMV3` -- directory containing set of ZIP files of ASTER GDEM V3. 108 | 109 | ![Screenshot](https://streets.romanshuvalov.com/screenshots/github/rvtgen3d-sh1.jpg) 110 | 111 | # Usage (3D world model generation) 112 | 113 | ## rvtgen3d 114 | 115 | Run `rsgeotools-rvtgen3d` to generate 3D world. 116 | * Required parameters: 117 | * --x=, --y=, --w=, --h= - rectangle in tile coordinates at 14th scale. You can use `rsgeotools-conv` to get tile coordinate from lat/lon pair, or use third-party tools like [Geofabrik's Tile Calculator](https://tools.geofabrik.de/calc/#&grid=1); 118 | * --cache-dir= - path to `RVT_GPAK_DIR`, without tailing slash. 119 | * Optional parameters: 120 | * --output-dir= - path to output directory; 121 | * --data-dir= - path to `rvtgen3d-data`; 122 | * --disable-timestamp-folders - by default, separated output folder with unique name will be created. This option disables this feature; 123 | * --flat-terrain - disable relief; 124 | * --z-up - define Z axis as vertical. Default is Y; 125 | * --merge - merge all tiles into one file. Not recommended for large areas; 126 | * --disable-edge-smoothing; 127 | * --obj - set output format to .obj instead of .ply; 128 | * --disable-decorations - disable building decorations; 129 | * --drop-no-outer-ring - ignore broken multipolygons which have no outer ring. 130 | 131 | Following layers will be generated: 132 | 133 | 0. Surface geometry 134 | 1. Buildings 135 | 2. Surface map (area) 136 | 3. Surface map (roads and rivers) 137 | 4. Naturals 138 | 5. Props 139 | 6. Wires 140 | 7. Stripes 141 | 8. Walls 142 | 143 | ## Vertex attributes description 144 | 145 | Buildings layer has `FlagsA` and `FlagsB` vertex attributes. 146 | 147 | * Attribute `FlagsA` contains building texture type: residential (1), commercial (2) or industrial (4). 148 | * Attribute `FlagsB` contains surface type flags: roof (1), flat wall without windows (4). 149 | 150 | In .ply, `FlagsA` is stored in color alpha component, `FlagsB` is stored in 4th component of normal (nw). 151 | 152 | In .obj, vertex has following format: `PosX, PosY, PosZ, ColorR, ColorG, ColorB, FlagsA, FlagsB`. 153 | 154 | Surface map layer is coded with following colors: 155 | 156 | | Surface | RGB vertex color | 157 | | --- | --- | 158 | | Water | (0.0, 1.0, 0.0) | 159 | | Asphalt | (0.2, 0.0, 0.0) | 160 | | Ground (default) | (0.5, 0.0, 0.0) | 161 | | Grass | (0.7, 0.0, 0.0) | 162 | | Sand | (0.0, 0.0, 0.2) | 163 | | Quarry (rock) | (0.0, 0.0, 0.7) | 164 | 165 | # License 166 | 167 | Most of the code is distributed under 3-clause BSD license, see `LICENSE`. 168 | 169 | Note that toolset also contains code based on third-party projects licensed under different licenses, in that cases license provided in source code. 170 | -------------------------------------------------------------------------------- /src/rvtgen3d/rs/rsgeom.h: -------------------------------------------------------------------------------- 1 | #ifndef rs_GEOM_H_INCLUDED 2 | #define rs_GEOM_H_INCLUDED 3 | 4 | #include "rsmx.h" 5 | 6 | #define RS_GEOM_MAX_POINTS_PER_LINESTRING 1024 7 | #define RS_GEOM_MAX_RINGS_PER_POLYGON 128 8 | 9 | #define RS_GEOM_FLAG_DROP_NO_OUTER_RING 0x01 10 | 11 | 12 | extern int rs_geom_flags; 13 | 14 | typedef rs_vec2_t rs_point_t; 15 | 16 | typedef struct rs_triangle_t { 17 | 18 | rs_point_t p[3]; 19 | 20 | } rs_triangle_t; 21 | 22 | 23 | typedef struct rs_triangle_set_t { 24 | int t_count; 25 | int flags; 26 | int max_count; 27 | 28 | rs_triangle_t *t; 29 | 30 | } rs_triangle_set_t; 31 | 32 | typedef struct rs_indexed_triangle_set_t { 33 | 34 | int flags; 35 | 36 | int i_count; // = triangles count / 3 37 | int p_count; 38 | 39 | int max_i_count; 40 | int max_p_count; 41 | 42 | rs_point_t *p_array; 43 | uint32_t *i_array; 44 | 45 | } rs_indexed_triangle_set_t; 46 | 47 | typedef struct rs_linestring_t { 48 | 49 | int points_count; 50 | int max_points_count; 51 | int flags; 52 | int reserved0; 53 | 54 | rs_point_t *p; 55 | 56 | } rs_linestring_t; 57 | 58 | typedef struct rs_static_linestring_t { 59 | int points_count; 60 | int flags; 61 | } rs_static_linestring_t; 62 | 63 | 64 | typedef struct rs_shape_t { 65 | 66 | int rings_count; 67 | int max_rings_count; 68 | int outer_rings_count; 69 | int flags; 70 | 71 | rs_linestring_t **rings; 72 | 73 | } rs_shape_t; 74 | 75 | typedef struct rs_static_shape_t { 76 | int rings_count; 77 | int outer_rings_count; 78 | int flags; 79 | int reserved; 80 | } rs_static_shape_t; 81 | 82 | 83 | typedef struct rs_shape_metadata_t { 84 | int shape_type; 85 | int shape_points_count; 86 | float radius; 87 | float halflength; 88 | float halfwidth; 89 | float lin_ratio; 90 | float azimuth; 91 | float precision; 92 | rs_vec2_t center; 93 | } rs_shape_metadata_t; 94 | 95 | #define RS_SHAPE_TYPE_UNKNOWN_SIMPLE_CONVEX 0x0001 96 | #define RS_SHAPE_TYPE_UNKNOWN_SIMPLE_CONCAVE 0x0002 97 | #define RS_SHAPE_TYPE_UNKNOWN_COMPLEX 0x0008 98 | #define RS_SHAPE_TYPE_UNKNOWN_MASK 0x000F 99 | 100 | #define RS_SHAPE_TYPE_ROUND 0x0010 101 | 102 | #define RS_SHAPE_TYPE_RECTANGLE 0x0100 103 | 104 | 105 | typedef struct rs_angled_point_t { 106 | rs_point_t p; 107 | float azimuth; 108 | } rs_angled_point_t; 109 | 110 | rs_linestring_t* rs_linestring_create(int points_count); 111 | void rs_linestring_destroy(rs_linestring_t *ls); 112 | void rs_linestring_append_point(rs_linestring_t *ls, rs_point_t p); 113 | void rs_linestring_clear(rs_linestring_t *ls); 114 | 115 | rs_linestring_t* rs_linestring_create_copy(rs_linestring_t *ls); 116 | rs_linestring_t* rs_linestring_create_shifted(rs_linestring_t *ls, rs_point_t shift); 117 | 118 | 119 | float rs_linestring_distance_from_point(rs_linestring_t *ls, rs_point_t p); 120 | 121 | rs_angled_point_t rs_linestring_get_middle_angled_point(rs_linestring_t *ls); 122 | 123 | void rs_linestring_printf(rs_linestring_t *ls); 124 | float rs_linestring_length(rs_linestring_t *ls); 125 | float rs_linestring_max_segment_length(rs_linestring_t *ls); 126 | 127 | void rs_shape_printf(rs_shape_t *sh); 128 | 129 | 130 | typedef struct rs_point_set_t { 131 | 132 | rs_angled_point_t *p; 133 | int max_points_count; 134 | int points_count; 135 | 136 | } rs_point_set_t; 137 | 138 | #define POINT_SET_FLAG_ZIGZAG 0x0001 139 | #define POINT_SET_FLAG_CLOSED 0x0002 140 | #define POINT_SET_FLAG_RANDOMIZER_TYPE_SIMPLE 0x0004 141 | #define POINT_SET_FLAG_RANDOMIZER_TYPE_ISLANDS 0x0008 142 | 143 | rs_point_set_t* rs_point_set_create(int max_points_count); 144 | void rs_point_set_add_point(rs_point_set_t *ps, rs_angled_point_t ap ); 145 | 146 | rs_point_set_t * rs_point_set_create_from_linestring(rs_linestring_t *ls, float period, float side_shift, float angle, int flags); 147 | void rs_point_set_destroy(rs_point_set_t *ps); 148 | void rs_point_set_filter_by_distance(rs_point_set_t *ps, float distance); 149 | void rs_point_set_make_azimuths_smooth(rs_point_set_t *ps); 150 | 151 | rs_point_set_t * rs_point_set_create_from_triangle(rs_triangle_t *tr, float distance, float random_k); 152 | rs_point_set_t * rs_point_set_create_from_quad(float distance, float random_k, float quad_side, int randomizer_flags); 153 | rs_point_set_t * rs_point_set_create_from_quad_random_islands(int islands_count, int points_per_island, float island_radius, float quad_side, int randomizer_flags); 154 | 155 | 156 | float rs_triangle_area(rs_triangle_t *tr); 157 | float rs_shape_area(rs_shape_t *sh); 158 | 159 | int rs_is_point_in_triangle(rs_point_t p, rs_triangle_t *tr); 160 | int rs_is_point_in_linestring(rs_point_t p, rs_linestring_t *ls, float threshold); 161 | 162 | 163 | rs_triangle_set_t* rs_triangle_set_create(int max_triangles_count); 164 | rs_triangle_set_t* rs_triangle_set_create_triangulated(rs_shape_t *src); 165 | rs_triangle_set_t* rs_triangle_set_create_triangulated_adv(rs_shape_t *src, double point_distance_epsilon); 166 | 167 | rs_triangle_set_t* rs_triangle_set_create_from_indexed_triangle_set(rs_indexed_triangle_set_t *tset); 168 | 169 | void rs_triangle_set_append_triangle(rs_triangle_set_t *dest, rs_point_t v0, rs_point_t v1, rs_point_t v2 ); 170 | void rs_triangle_set_destroy(rs_triangle_set_t *dest); 171 | void rs_triangle_set_add_max_count(rs_triangle_set_t *dest, int max_count_increment); 172 | 173 | 174 | 175 | rs_triangle_set_t** rs_triangle_set_array_create_subdivided_and_triangulated(rs_shape_t *src, float sc, int subtiles_side_count ); 176 | void rs_triangle_set_array_destroy(rs_triangle_set_t** ar, int subtiles_side_count); 177 | 178 | 179 | void rs_shape_analyze_metadata( rs_shape_metadata_t* metadata, rs_shape_t *sh ); 180 | 181 | 182 | rs_shape_t* rs_shape_create( int max_rings_count ); 183 | void rs_shape_destroy( rs_shape_t *dest ); 184 | void rs_shape_append_ring(rs_shape_t *dest, rs_linestring_t *ring); 185 | 186 | void rs_shape_calculate_outer_rings(rs_shape_t *dest); 187 | 188 | unsigned char* rs_static_shape_data_create( rs_shape_t *sh, int *out_content_len ); 189 | 190 | rs_shape_t* rs_shape_create_from_static( rs_static_shape_t* static_shape ); 191 | 192 | rs_angled_point_t rs_shape_get_middle_angled_point(rs_shape_t *sh); 193 | 194 | 195 | #define RS_POLYGON_CLOSED 0 // (ClipperLib::EndType::etClosedPolygon) 196 | #define RS_LINESTRING_CLOSED 1 // (ClipperLib::EndType::etClosedLine) 197 | #define RS_LINESTRING_OPEN_BUTT 2 // (ClipperLib::EndType::etOpenButt) 198 | #define RS_LINESTRING_OPEN_SQUARE 3 // (ClipperLib::EndType::etOpenSquare) 199 | #define RS_LINESTRING_OPEN_ROUND 4 // (ClipperLib::EndType::etOpenRound) 200 | 201 | enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound}; 202 | 203 | rs_shape_t* rs_shape_create_buffered_from_linestring(rs_linestring_t *src, float factor, int ls_type); 204 | rs_shape_t* rs_shape_create_buffered_from_polygon(rs_shape_t *src, float factor, int p_type); 205 | 206 | rs_shape_t* rs_shape_create_with_offset(rs_shape_t *src, float offset); 207 | 208 | rs_shape_t* rs_shape_create_segmentized(rs_shape_t *src, float max_segment_length); 209 | 210 | rs_shape_t* rs_shape_create_box(float x, float y, float halflength, float halfwidth, float azimuth); 211 | 212 | rs_shape_t *rs_shape_create_simplified(rs_shape_t *src, float tolerance); 213 | rs_shape_t *rs_shape_create_convex_hull(rs_shape_t *src); 214 | 215 | // enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor }; 216 | #define RS_CLIP_INTERSECTION 0 217 | #define RS_CLIP_UNION 1 218 | #define RS_CLIP_DIFFERENCE 2 219 | #define RS_CLIP_XOR 3 220 | 221 | rs_shape_t* rs_shape_create_clipped(rs_shape_t *subj, rs_shape_t *clip, int op, int subj_is_closed); 222 | 223 | rs_shape_t* rs_shape_create_no_side_effect(rs_shape_t *p, float sc); 224 | 225 | int rs_shape_get_total_points(rs_shape_t *sh); 226 | 227 | rs_point_t rs_shape_get_middle_point(rs_shape_t *sh); 228 | rs_point_t rs_linestring_get_middle_point(rs_linestring_t *ls); 229 | 230 | float rs_shape_perimeter(rs_shape_t *sh); 231 | 232 | rs_linestring_t *rs_linestring_create_convex_hull(rs_linestring_t *src_ls); 233 | 234 | #endif // H_INCLUDED 235 | 236 | -------------------------------------------------------------------------------- /rvtgen3d-data/models/street-lamp-footway.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format ascii 1.0 3 | comment Created by Blender 2.78 (sub 0) - www.blender.org, source file: 'street-lamp.blend' 4 | element vertex 84 5 | property float x 6 | property float y 7 | property float z 8 | property float nx 9 | property float ny 10 | property float nz 11 | property float s 12 | property float t 13 | property uchar red 14 | property uchar green 15 | property uchar blue 16 | element face 42 17 | property list uchar uint vertex_indices 18 | end_header 19 | 0.000000 14.500000 -0.707107 0.701646 -0.124035 -0.701646 0.406286 0.207640 190 190 190 20 | 0.353553 12.500000 0.000000 0.701646 -0.124035 -0.701646 0.339036 0.000838 190 190 190 21 | 0.000000 12.500000 -0.353553 0.701646 -0.124035 -0.701646 0.406286 0.000000 190 190 190 22 | 0.000000 14.500000 0.707107 -0.556974 0.616085 0.556974 0.809788 0.312981 130 130 130 23 | -0.260452 14.903799 0.000000 -0.556974 0.616085 0.556974 0.869863 0.384316 130 130 130 24 | -0.707107 14.500000 0.000000 -0.556974 0.616085 0.556974 0.809788 0.417247 130 130 130 25 | -0.707107 14.500000 0.000000 -0.701646 -0.124035 -0.701646 0.540787 0.209316 131 131 131 26 | 0.000000 12.500000 -0.353553 -0.701646 -0.124035 -0.701646 0.406286 0.000000 190 190 190 27 | -0.353553 12.500000 0.000000 -0.701646 -0.124035 -0.701646 0.473537 0.000838 190 190 190 28 | -0.707107 14.500000 0.000000 -0.556974 0.616085 -0.556974 0.809788 0.417247 131 131 131 29 | 0.000000 14.903799 -0.260452 -0.556974 0.616085 -0.556974 0.939925 0.384316 130 130 130 30 | 0.000000 14.500000 -0.707107 -0.556974 0.616085 -0.556974 1.000000 0.417247 130 130 130 31 | 0.707107 14.500000 0.000000 0.701646 -0.124035 0.701646 0.809788 0.520621 130 130 130 32 | 0.000000 12.500000 0.353553 0.701646 -0.124035 0.701646 0.742537 0.313819 190 190 190 33 | 0.353553 12.500000 0.000000 0.701646 -0.124035 0.701646 0.809788 0.312981 190 190 190 34 | 0.000000 14.500000 0.707107 -0.701646 -0.124035 0.701646 0.540787 0.312981 130 130 130 35 | -0.353553 12.500000 0.000000 -0.701646 -0.124035 0.701646 0.675287 0.522297 190 190 190 36 | 0.000000 12.500000 0.353553 -0.701646 -0.124035 0.701646 0.608037 0.521459 190 190 190 37 | 0.707107 14.500000 0.000000 0.556974 0.616085 0.556974 1.000000 0.312981 130 130 130 38 | 0.000000 14.903799 0.260452 0.556974 0.616085 0.556974 0.869863 0.345911 130 130 130 39 | 0.000000 14.500000 0.707107 0.556974 0.616085 0.556974 0.809788 0.312981 130 130 130 40 | 0.000000 14.500000 -0.707107 0.556974 0.616085 -0.556974 1.000000 0.417247 143 143 143 41 | 0.260452 14.903799 0.000000 0.556974 0.616085 -0.556974 0.939925 0.345911 134 134 134 42 | 0.707107 14.500000 0.000000 0.556974 0.616085 -0.556974 1.000000 0.312981 130 130 130 43 | -0.260452 14.903799 0.000000 0.000000 1.000000 -0.000000 0.869863 0.384316 130 130 130 44 | 0.260452 14.903799 0.000000 0.000000 1.000000 -0.000000 0.939925 0.345911 130 130 130 45 | 0.000000 14.903799 -0.260452 0.000000 1.000000 -0.000000 0.939925 0.384316 130 130 130 46 | -0.258482 3.000000 0.258482 0.000000 1.000000 -0.000000 0.412439 0.209316 190 190 190 47 | -0.178607 3.000000 -0.178607 0.000000 1.000000 -0.000000 0.427632 0.254889 190 190 190 48 | -0.258482 3.000000 -0.258482 0.000000 1.000000 -0.000000 0.412439 0.263218 190 190 190 49 | 0.369726 0.000000 -0.369726 0.999313 0.037056 0.000000 0.271786 0.522297 190 190 190 50 | 0.258482 3.000000 0.258482 0.999313 0.037056 0.000000 0.391279 0.209316 190 190 190 51 | 0.369726 0.000000 0.369726 0.999313 0.037056 0.000000 0.412439 0.522297 190 190 190 52 | -0.369726 0.000000 0.369726 -0.999313 0.037056 0.000000 0.540787 0.312981 190 190 190 53 | -0.258482 3.000000 -0.258482 -0.999313 0.037056 0.000000 0.660280 0.000000 190 190 190 54 | -0.369726 0.000000 -0.369726 -0.999313 0.037056 0.000000 0.681440 0.312981 190 190 190 55 | -0.369726 0.000000 -0.369726 0.000000 0.037056 -0.999313 0.822092 0.312981 190 190 190 56 | 0.258482 3.000000 -0.258482 0.000000 0.037056 -0.999313 0.941585 0.000000 190 190 190 57 | 0.369726 0.000000 -0.369726 0.000000 0.037056 -0.999313 0.962745 0.312981 190 190 190 58 | 0.369726 0.000000 0.369726 0.000000 0.037056 0.999313 0.681440 0.312981 190 190 190 59 | -0.258482 3.000000 0.258482 0.000000 0.037056 0.999313 0.800932 0.000000 190 190 190 60 | -0.369726 0.000000 0.369726 0.000000 0.037056 0.999313 0.822092 0.312981 190 190 190 61 | -0.178607 3.000000 -0.178607 0.000000 0.008400 -0.999965 0.203840 1.000000 190 190 190 62 | 0.098038 12.591501 -0.098038 0.000000 0.008400 -0.999965 0.256460 0.000000 190 190 190 63 | 0.178607 3.000000 -0.178607 0.000000 0.008400 -0.999965 0.271786 1.000000 190 190 190 64 | 0.178607 3.000000 -0.178607 0.000000 1.000000 0.000000 0.495578 0.254889 190 190 190 65 | 0.258482 3.000000 -0.258482 0.000000 1.000000 0.000000 0.510772 0.263218 190 190 190 66 | 0.258482 3.000000 0.258482 -0.000000 1.000000 0.000000 0.510772 0.209316 190 190 190 67 | -0.178607 3.000000 0.178607 -0.000000 1.000000 0.000000 0.427632 0.217644 190 190 190 68 | 0.178607 3.000000 0.178607 0.000000 1.000000 0.000000 0.495578 0.217644 190 190 190 69 | 0.178607 3.000000 0.178607 0.000000 0.008400 0.999965 0.067947 1.000000 190 190 190 70 | -0.098038 12.591501 0.098038 0.000000 0.008400 0.999965 0.120567 0.000000 190 190 190 71 | -0.178607 3.000000 0.178607 0.000000 0.008400 0.999965 0.135893 1.000000 190 190 190 72 | 0.178607 3.000000 -0.178607 0.999965 0.008400 0.000000 0.135893 1.000000 190 190 190 73 | 0.098038 12.591501 0.098038 0.999965 0.008400 0.000000 0.188514 0.000000 190 190 190 74 | 0.178607 3.000000 0.178607 0.999965 0.008400 0.000000 0.203840 1.000000 190 190 190 75 | -0.178607 3.000000 0.178607 -0.999965 0.008400 0.000000 0.000000 1.000000 190 190 190 76 | -0.098038 12.591501 -0.098038 -0.999965 0.008400 0.000000 0.052621 0.000000 190 190 190 77 | -0.178607 3.000000 -0.178607 -0.999965 0.008400 0.000000 0.067947 1.000000 190 190 190 78 | 0.707107 14.500000 0.000000 0.701646 -0.124035 -0.701646 0.271786 0.209316 190 190 190 79 | 0.000000 14.500000 0.707107 -0.556973 0.616085 0.556973 0.809788 0.312981 130 130 130 80 | 0.000000 14.903799 0.260452 -0.556973 0.616085 0.556973 0.869863 0.345911 130 130 130 81 | -0.260452 14.903799 0.000000 -0.556973 0.616085 0.556973 0.869863 0.384316 130 130 130 82 | 0.000000 14.500000 -0.707107 -0.701646 -0.124035 -0.701646 0.406286 0.207640 130 130 130 83 | -0.707107 14.500000 0.000000 -0.556973 0.616085 -0.556973 0.809788 0.417247 131 131 131 84 | -0.260452 14.903799 0.000000 -0.556973 0.616085 -0.556973 0.869863 0.384316 130 130 130 85 | 0.000000 14.903799 -0.260452 -0.556973 0.616085 -0.556973 0.939925 0.384316 130 130 130 86 | 0.000000 14.500000 0.707107 0.701646 -0.124035 0.701646 0.675287 0.522297 130 130 130 87 | -0.707107 14.500000 0.000000 -0.701646 -0.124035 0.701646 0.675287 0.314657 130 130 130 88 | 0.707107 14.500000 0.000000 0.556973 0.616085 0.556973 1.000000 0.312981 130 130 130 89 | 0.260452 14.903799 0.000000 0.556973 0.616085 0.556973 0.939925 0.345911 130 130 130 90 | 0.000000 14.903799 0.260452 0.556973 0.616085 0.556973 0.869863 0.345911 130 130 130 91 | 0.000000 14.500000 -0.707107 0.556973 0.616085 -0.556973 1.000000 0.417247 143 143 143 92 | 0.000000 14.903799 -0.260452 0.556973 0.616085 -0.556973 0.939925 0.384316 153 153 153 93 | 0.260452 14.903799 0.000000 0.556973 0.616085 -0.556973 0.939925 0.345911 134 134 134 94 | 0.000000 14.903799 0.260452 0.000000 1.000000 0.000000 0.869863 0.345911 130 130 130 95 | 0.258482 3.000000 -0.258482 0.999313 0.037056 0.000000 0.292946 0.209316 190 190 190 96 | -0.258482 3.000000 0.258482 -0.999313 0.037056 0.000000 0.561947 0.000000 190 190 190 97 | -0.258482 3.000000 -0.258482 0.000000 0.037056 -0.999313 0.843252 0.000000 190 190 190 98 | 0.258482 3.000000 0.258482 -0.000000 0.037056 0.999313 0.702600 0.000000 190 190 190 99 | -0.098038 12.591501 -0.098038 0.000000 0.008400 -0.999965 0.219164 0.000000 190 190 190 100 | 0.098038 12.591501 0.098038 -0.000000 0.008400 0.999965 0.083271 0.000000 190 190 190 101 | 0.098038 12.591501 -0.098038 0.999965 0.008400 0.000000 0.151218 0.000000 190 190 190 102 | -0.098038 12.591501 0.098038 -0.999965 0.008400 0.000000 0.015325 0.000000 190 190 190 103 | 3 0 1 2 104 | 3 3 4 5 105 | 3 6 7 8 106 | 3 9 10 11 107 | 3 12 13 14 108 | 3 15 16 17 109 | 3 18 19 20 110 | 3 21 22 23 111 | 3 24 25 26 112 | 3 27 28 29 113 | 3 30 31 32 114 | 3 33 34 35 115 | 3 36 37 38 116 | 3 39 40 41 117 | 3 42 43 44 118 | 3 29 45 46 119 | 3 47 48 27 120 | 3 46 49 47 121 | 3 50 51 52 122 | 3 53 54 55 123 | 3 56 57 58 124 | 3 0 59 1 125 | 3 60 61 62 126 | 3 6 63 7 127 | 3 64 65 66 128 | 3 12 67 13 129 | 3 15 68 16 130 | 3 69 70 71 131 | 3 72 73 74 132 | 3 24 75 25 133 | 3 27 48 28 134 | 3 30 76 31 135 | 3 33 77 34 136 | 3 36 78 37 137 | 3 39 79 40 138 | 3 42 80 43 139 | 3 29 28 45 140 | 3 47 49 48 141 | 3 46 45 49 142 | 3 50 81 51 143 | 3 53 82 54 144 | 3 56 83 57 145 | -------------------------------------------------------------------------------- /src/rvtgen3d/loader.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "loader.h" 7 | #include "tileloader.h" 8 | 9 | #include "main.h" 10 | 11 | #include "rvt.h" 12 | #include "rvtapp.h" 13 | #include "rvtgen.h" 14 | #include "rvtloader.h" 15 | 16 | 17 | void loader_load_all_vbodata() { 18 | 19 | 20 | char fnbuf[256]; 21 | 22 | loader_create_vbodata( VBODATA_BUILDING_ROOF_PART_1, "models/building-roof-part1.ply" , RVT_APP_LOADER_FORMAT_PLY); 23 | loader_create_vbodata( VBODATA_BUILDING_ROOF_PART_2, "models/building-roof-part2.ply" , RVT_APP_LOADER_FORMAT_PLY); 24 | loader_create_vbodata( VBODATA_BUILDING_CONSTRUCTION_PART, "models/building-construction-part.ply" , RVT_APP_LOADER_FORMAT_PLY); 25 | loader_create_vbodata( VBODATA_BUILDING_ENTRANCE_1, "models/building-entrance-1.ply" , RVT_APP_LOADER_FORMAT_PLY); 26 | 27 | loader_create_vbodata( VBODATA_ROOF_SHAPE_DOME, "models/roof-shape-dome.ply" , RVT_APP_LOADER_FORMAT_PLY); 28 | loader_create_vbodata( VBODATA_ROOF_SHAPE_ONION, "models/roof-shape-onion.ply" , RVT_APP_LOADER_FORMAT_PLY); 29 | 30 | loader_create_vbodata( VBODATA_ROOF_RURAL_01, "models/roof-rural-01.ply" , RVT_APP_LOADER_FORMAT_PLY); 31 | loader_create_vbodata( VBODATA_ROOF_RURAL_02, "models/roof-rural-02.ply" , RVT_APP_LOADER_FORMAT_PLY); 32 | 33 | loader_create_vbodata( VBODATA_POWER_TOWER_METAL, "models/powertower1.ply" , RVT_APP_LOADER_FORMAT_PLY); 34 | loader_create_vbodata( VBODATA_POWER_TOWER, "models/powertower2.ply" , RVT_APP_LOADER_FORMAT_PLY); 35 | 36 | loader_create_vbodata( VBODATA_TREE1, "models/tree1.ply" , RVT_APP_LOADER_FORMAT_PLY); 37 | loader_create_vbodata( VBODATA_TREEPACK1, "models/treepack1.ply" , RVT_APP_LOADER_FORMAT_PLY); 38 | loader_create_vbodata( VBODATA_BUSH1, "models/bush1.ply" , RVT_APP_LOADER_FORMAT_PLY); 39 | 40 | loader_create_vbodata( VBODATA_BRIDGE_END1, "models/bridge-end.ply" , RVT_APP_LOADER_FORMAT_PLY); 41 | loader_create_vbodata( VBODATA_BRIDGE_GARBAGE1, "models/bridge-garbage.ply" , RVT_APP_LOADER_FORMAT_PLY); 42 | loader_create_vbodata( VBODATA_BRIDGE_BASE1, "models/bridge-base.ply" , RVT_APP_LOADER_FORMAT_PLY); 43 | 44 | loader_create_vbodata( VBODATA_HOUSE01, "models/house01.ply" , RVT_APP_LOADER_FORMAT_PLY); 45 | loader_create_vbodata( VBODATA_HOUSE02, "models/house02.ply" , RVT_APP_LOADER_FORMAT_PLY); 46 | loader_create_vbodata( VBODATA_HOUSE03, "models/house03.ply" , RVT_APP_LOADER_FORMAT_PLY); 47 | loader_create_vbodata( VBODATA_HOUSE04, "models/house04.ply" , RVT_APP_LOADER_FORMAT_PLY); 48 | 49 | loader_create_vbodata( VBODATA_STREET_LAMP2, "models/street-lamp-2.ply", RVT_APP_LOADER_FORMAT_PLY); 50 | loader_create_vbodata( VBODATA_STREET_LAMP1_FOOTWAY, "models/street-lamp-footway.ply", RVT_APP_LOADER_FORMAT_PLY); 51 | loader_create_vbodata( VBODATA_RAILWAY_TOWER, "models/railway-tower.ply", RVT_APP_LOADER_FORMAT_PLY); 52 | 53 | loader_create_vbodata( VBODATA_TRAFFIC_LIGHT, "models/traffic-light.ply", RVT_APP_LOADER_FORMAT_PLY); 54 | 55 | loader_create_vbodata( VBODATA_ROAD_SIGN_GIVE_WAY, "models/road-sign-give-way.ply", RVT_APP_LOADER_FORMAT_PLY); 56 | loader_create_vbodata( VBODATA_ROAD_SIGN_STOP, "models/road-sign-stop.ply", RVT_APP_LOADER_FORMAT_PLY); 57 | 58 | 59 | }; 60 | 61 | 62 | 63 | // Can be called in any thread, but it's not thread-safe 64 | void loader_create_vbodata(int vbodata_index, char* filename, int format_type) { 65 | 66 | rvt_vbodata_t *pvbodata = &rvt_app->vbodata[vbodata_index]; 67 | if (pvbodata->data != NULL) { 68 | rs_mem_free(pvbodata->data); 69 | pvbodata->data = NULL; 70 | pvbodata->vertices_count = 0; 71 | }; 72 | 73 | if (format_type == RVT_APP_LOADER_FORMAT_PLY) { 74 | loader_create_vbodata_ply(vbodata_index, filename); 75 | } 76 | else { 77 | // unknown format_type 78 | }; 79 | 80 | }; 81 | 82 | #ifndef RS_VBO_MAX_VERTICES 83 | #define RS_VBO_MAX_VERTICES 65536 84 | #endif 85 | 86 | 87 | void loader_create_vbodata_ply(int vbodata_index, char* filename) { 88 | 89 | 90 | rvt_vbodata_t *pvbodata = &rvt_app->vbodata[vbodata_index]; 91 | 92 | 93 | float *data = (float*) rs_mem_alloc(RS_VBO_MAX_VERTICES * (16) * 4, RS_MEM_POOL_AUTO); // POS1 NORM1 UV00 RGBA 94 | rs_app_assert_memory( data, "", __LINE__ ); 95 | float *data_ptr = data; 96 | 97 | FILE* fp = fopen(filename, "rb"); 98 | if (!fp) { 99 | printf("Missing file %s.\nYou may want to set --data-dir parameter.\nAborted\n", filename); 100 | exit(-1); 101 | }; 102 | 103 | rs_vec3_t *verts = (rs_vec3_t*) rs_mem_alloc( sizeof(rs_vec3_t) * RS_VBO_MAX_VERTICES, RS_MEM_POOL_AUTO ); 104 | rs_vec3_t *norms = (rs_vec3_t*) rs_mem_alloc( sizeof(rs_vec3_t) * RS_VBO_MAX_VERTICES, RS_MEM_POOL_AUTO ); 105 | rs_vec2_t *uvs = (rs_vec2_t*) rs_mem_alloc( sizeof(rs_vec2_t) * RS_VBO_MAX_VERTICES, RS_MEM_POOL_AUTO ); 106 | rs_vec4_t *colors = (rs_vec4_t*) rs_mem_alloc( sizeof(rs_vec4_t) * RS_VBO_MAX_VERTICES, RS_MEM_POOL_AUTO ); 107 | rs_vec4i_t *colors_int = (rs_vec4i_t*) rs_mem_alloc( sizeof(rs_vec4i_t) * RS_VBO_MAX_VERTICES, RS_MEM_POOL_AUTO ); 108 | 109 | 110 | char s[256]; 111 | int d[9]; 112 | int c; 113 | 114 | int vertscount = 0; 115 | int facescount = 0; 116 | int output_vertices_count = 0; 117 | 118 | 119 | while (!feof(fp)) { 120 | 121 | if (!fgets(s, 256, fp)) { 122 | continue; 123 | }; 124 | 125 | 126 | if (s[0] == '#') { 127 | continue; 128 | }; 129 | 130 | if (isspace(s[0])) { 131 | continue; 132 | }; 133 | 134 | if (s[0] == 0) { 135 | continue; 136 | }; 137 | 138 | if (strlen(s) > 22) { // vertex data (hacky, but it works) 139 | 140 | c = sscanf(s, "%f %f %f %f %f %f %f %f %d %d %d", &verts[vertscount].x, &verts[vertscount].y, &verts[vertscount].z, 141 | &norms[vertscount].x, &norms[vertscount].y, &norms[vertscount].z, 142 | &uvs[vertscount].x, &uvs[vertscount].y, 143 | &colors_int[vertscount].x, &colors_int[vertscount].y, &colors_int[vertscount].z 144 | ); 145 | 146 | if (c != 11) { 147 | continue; 148 | }; 149 | 150 | colors[vertscount].x = (float) colors_int[vertscount].x / 255.0; 151 | colors[vertscount].y = (float) colors_int[vertscount].y / 255.0; 152 | colors[vertscount].z = (float) colors_int[vertscount].z / 255.0; 153 | colors[vertscount].w = 1.0; 154 | 155 | vertscount++; 156 | continue; 157 | } 158 | 159 | else { 160 | 161 | c = sscanf(s, "%d %d %d %d", &d[0], &d[1], &d[2], &d[3]); 162 | 163 | if (c != 4) { 164 | continue; 165 | }; 166 | 167 | 168 | if (d[0] != 3) { 169 | rs_critical_alert_and_halt_sprintf("Model %s is not triangulated", filename ); 170 | return; 171 | }; 172 | 173 | int i; 174 | 175 | for (i = 1; i < 4; i++) { 176 | 177 | float *v = &data[output_vertices_count * 16]; 178 | 179 | v[0] = verts[d[i]].x; 180 | v[1] = verts[d[i]].y; 181 | v[2] = verts[d[i]].z; 182 | v[3] = 1.0; 183 | 184 | v[4] = norms[d[i]].x; 185 | v[5] = norms[d[i]].y; 186 | v[6] = norms[d[i]].z; 187 | v[7] = 1.0; 188 | 189 | v[ 8] = uvs[d[i]].x; 190 | v[ 9] = uvs[d[i]].y; 191 | v[10] = 0.0; 192 | v[11] = 0.0; 193 | 194 | v[12] = colors[d[i]].x; 195 | v[13] = colors[d[i]].y; 196 | v[14] = colors[d[i]].z; 197 | v[15] = 1.0; 198 | 199 | output_vertices_count++; 200 | 201 | }; 202 | 203 | facescount++; 204 | continue; 205 | }; 206 | 207 | }; 208 | 209 | 210 | int total_vertices = output_vertices_count; 211 | 212 | 213 | int data_len = 4 * 16 * total_vertices; 214 | pvbodata->data = (float*) rs_mem_alloc( data_len, RS_MEM_POOL_AUTO ); 215 | rs_app_assert_memory( pvbodata->data, "loader", __LINE__ ); 216 | 217 | memcpy(pvbodata->data, data, data_len); 218 | 219 | pvbodata->stride = 16; 220 | pvbodata->vertices_count = total_vertices; 221 | 222 | rs_mem_free(colors_int); 223 | rs_mem_free(colors); 224 | rs_mem_free(uvs); 225 | rs_mem_free(norms); 226 | rs_mem_free(verts); 227 | 228 | rs_mem_free(data); 229 | 230 | 231 | }; 232 | 233 | 234 | 235 | -------------------------------------------------------------------------------- /src/csv2rvtdata/csv.c: -------------------------------------------------------------------------------- 1 | /* csv - read write comma separated value format 2 | * Copyright (c) 2003 Michael B. Allen 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included 14 | * in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | * OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | ////#include "mba/msgno.h" 34 | #include "csv.h" 35 | 36 | #define ST_START 1 37 | #define ST_COLLECT 2 38 | #define ST_TAILSPACE 3 39 | #define ST_END_QUOTE 4 40 | 41 | 42 | #define PMNF 43 | #define PMNO 44 | #define AMSG 45 | 46 | struct sinput { 47 | FILE *in; 48 | const unsigned char *src; 49 | size_t sn; 50 | size_t count; 51 | }; 52 | struct winput { 53 | const wchar_t *src; 54 | size_t sn; 55 | size_t count; 56 | }; 57 | 58 | static int 59 | snextch(struct sinput *in) 60 | { 61 | int ch; 62 | 63 | if (in->in) { 64 | if ((ch = fgetc(in->in)) == EOF) { 65 | if (ferror(in->in)) { 66 | PMNO(errno); 67 | return -1; 68 | } 69 | return 0; 70 | } 71 | } else { 72 | if (in->sn == 0) { 73 | return 0; 74 | } 75 | ch = *(in->src)++; 76 | in->sn--; 77 | } 78 | in->count++; 79 | 80 | return ch; 81 | } 82 | static int 83 | wnextch(struct winput *in) 84 | { 85 | int ch; 86 | 87 | if (in->sn == 0) { 88 | return 0; 89 | } 90 | ch = *(in->src)++; 91 | in->sn--; 92 | in->count++; 93 | 94 | return ch; 95 | } 96 | 97 | static int 98 | csv_parse_str(struct sinput *in, 99 | unsigned char *buf, 100 | size_t bn, 101 | unsigned char *row[], 102 | int rn, 103 | int sep, 104 | int flags) 105 | { 106 | int trim, quotes, ch, state, r, j, t, inquotes; 107 | 108 | trim = flags & CSV_TRIM; 109 | quotes = flags & CSV_QUOTES; 110 | state = ST_START; 111 | inquotes = 0; 112 | ch = r = j = t = 0; 113 | 114 | memset(row, 0, sizeof(unsigned char *) * rn); 115 | 116 | while (rn && bn && (ch = snextch(in)) > 0) { 117 | switch (state) { 118 | case ST_START: 119 | if (ch != '\n' && ch != sep && isspace(ch)) { 120 | if (!trim) { 121 | buf[j++] = ch; bn--; 122 | t = j; 123 | } 124 | break; 125 | } else if (quotes && ch == '"') { 126 | j = t = 0; 127 | state = ST_COLLECT; 128 | inquotes = 1; 129 | break; 130 | } 131 | state = ST_COLLECT; 132 | case ST_COLLECT: 133 | if (inquotes) { 134 | if (ch == '"') { 135 | state = ST_END_QUOTE; 136 | break; 137 | } 138 | } else if (ch == sep || ch == '\n') { 139 | row[r++] = buf; rn--; 140 | if (ch == '\n' && t && buf[t - 1] == '\r') { 141 | t--; bn++; /* crlf -> lf */ 142 | } 143 | buf[t] = '\0'; bn--; 144 | buf += t + 1; 145 | j = t = 0; 146 | state = ST_START; 147 | inquotes = 0; 148 | if (ch == '\n') { 149 | rn = 0; 150 | } 151 | break; 152 | } else if (quotes && ch == '"') { 153 | PMNF(errno = EILSEQ, ": unexpected quote in element %d", (r + 1)); 154 | return -1; 155 | } 156 | buf[j++] = ch; bn--; 157 | if (!trim || isspace(ch) == 0) { 158 | t = j; 159 | } 160 | break; 161 | case ST_TAILSPACE: 162 | case ST_END_QUOTE: 163 | if (ch == sep || ch == '\n') { 164 | row[r++] = buf; rn--; 165 | buf[j] = '\0'; bn--; 166 | buf += j + 1; 167 | j = t = 0; 168 | state = ST_START; 169 | inquotes = 0; 170 | if (ch == '\n') { 171 | rn = 0; 172 | } 173 | break; 174 | } else if (quotes && ch == '"' && state != ST_TAILSPACE) { 175 | buf[j++] = '"'; bn--; /* nope, just an escaped quote */ 176 | t = j; 177 | state = ST_COLLECT; 178 | break; 179 | } else if (isspace(ch)) { 180 | state = ST_TAILSPACE; 181 | break; 182 | } 183 | errno = EILSEQ; 184 | PMNF(errno, ": bad end quote in element %d", (r + 1)); 185 | return -1; 186 | } 187 | } 188 | if (ch == -1) { 189 | AMSG(""); 190 | return -1; 191 | } 192 | if (bn == 0) { 193 | PMNO(errno = E2BIG); 194 | return -1; 195 | } 196 | if (rn) { 197 | if (inquotes && state != ST_END_QUOTE) { 198 | PMNO(errno = EILSEQ); 199 | return -1; 200 | } 201 | row[r] = buf; 202 | buf[t] = '\0'; 203 | } 204 | 205 | return in->count; 206 | } 207 | static int 208 | csv_parse_wcs(struct winput *in, wchar_t *buf, size_t bn, wchar_t *row[], int rn, wint_t sep, int flags) 209 | { 210 | int trim, quotes, state, r, j, t, inquotes; 211 | wint_t ch; 212 | 213 | trim = flags & CSV_TRIM; 214 | quotes = flags & CSV_QUOTES; 215 | state = ST_START; 216 | inquotes = 0; 217 | ch = r = j = t = 0; 218 | 219 | memset(row, 0, sizeof(wchar_t *) * rn); 220 | 221 | while (rn && bn && (ch = wnextch(in)) > 0) { 222 | switch (state) { 223 | case ST_START: 224 | if (ch != L'\n' && ch != sep && iswspace(ch)) { 225 | if (!trim) { 226 | buf[j++] = ch; bn--; 227 | t = j; 228 | } 229 | break; 230 | } else if (quotes && ch == L'"') { 231 | j = t = 0; 232 | state = ST_COLLECT; 233 | inquotes = 1; 234 | break; 235 | } 236 | state = ST_COLLECT; 237 | case ST_COLLECT: 238 | if (inquotes) { 239 | if (ch == L'"') { 240 | state = ST_END_QUOTE; 241 | break; 242 | } 243 | } else if (ch == sep || ch == L'\n') { 244 | row[r++] = buf; rn--; 245 | buf[t] = L'\0'; bn--; 246 | buf += t + 1; 247 | j = t = 0; 248 | state = ST_START; 249 | inquotes = 0; 250 | if (ch == L'\n') { 251 | rn = 0; 252 | } 253 | break; 254 | } else if (quotes && ch == L'"') { 255 | PMNF(errno = EILSEQ, ": unexpected quote in element %d", (r + 1)); 256 | return -1; 257 | } 258 | buf[j++] = ch; bn--; 259 | if (!trim || iswspace(ch) == 0) { 260 | t = j; 261 | } 262 | break; 263 | case ST_TAILSPACE: 264 | case ST_END_QUOTE: 265 | if (ch == sep || ch == L'\n') { 266 | row[r++] = buf; rn--; 267 | buf[j] = L'\0'; bn--; 268 | buf += j + 1; 269 | j = t = 0; 270 | state = ST_START; 271 | inquotes = 0; 272 | if (ch == L'\n') { 273 | rn = 0; 274 | } 275 | break; 276 | } else if (quotes && ch == L'"' && state != ST_TAILSPACE) { 277 | buf[j++] = L'"'; bn--; /* nope, just an escaped quote */ 278 | t = j; 279 | state = ST_COLLECT; 280 | break; 281 | } else if (iswspace(ch)) { 282 | state = ST_TAILSPACE; 283 | break; 284 | } 285 | PMNF(errno = EILSEQ, ": bad end quote in element %d", (r + 1)); 286 | return -1; 287 | } 288 | } 289 | if (ch == (wint_t)-1) { 290 | AMSG(""); 291 | return -1; 292 | } 293 | if (bn == 0) { 294 | PMNO(errno = E2BIG); 295 | return -1; 296 | } 297 | if (rn) { 298 | if (inquotes && state != ST_END_QUOTE) { 299 | PMNO(errno = EILSEQ); 300 | return -1; 301 | } 302 | row[r] = buf; 303 | buf[t] = L'\0'; 304 | } 305 | 306 | return in->count; 307 | } 308 | int 309 | csv_row_parse_wcs(const wchar_t *src, size_t sn, wchar_t *buf, size_t bn, wchar_t *row[], int rn, int sep, int trim) 310 | { 311 | struct winput input; 312 | input.src = src; 313 | input.sn = sn; 314 | input.count = 0; 315 | return csv_parse_wcs(&input, buf, bn, row, rn, (wint_t)sep, trim); 316 | } 317 | int 318 | csv_row_parse_str(const unsigned char *src, size_t sn, unsigned char *buf, size_t bn, unsigned char *row[], int rn, int sep, int trim) 319 | { 320 | struct sinput input; 321 | input.in = NULL; 322 | input.src = src; 323 | input.sn = sn; 324 | input.count = 0; 325 | return csv_parse_str(&input, buf, bn, row, rn, sep, trim); 326 | } 327 | int 328 | csv_row_fread(FILE *in, unsigned char *buf, size_t bn, unsigned char *row[], int numcols, int sep, int trim) 329 | { 330 | struct sinput input; 331 | input.in = in; 332 | input.count = 0; 333 | return csv_parse_str(&input, buf, bn, row, numcols, sep, trim); 334 | } 335 | 336 | 337 | -------------------------------------------------------------------------------- /src/rvtgen3d/rs/rsboost.cpp: -------------------------------------------------------------------------------- 1 | // Based on Boost Custom polygon example code 2 | // https://www.boost.org/doc/libs/1_68_0/libs/geometry/example/c08_custom_non_std_example.cpp 3 | 4 | // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. 5 | // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. 6 | // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. 7 | 8 | // Use, modification and distribution is subject to the Boost Software License, 9 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 10 | // http://www.boost.org/LICENSE_1_0.txt) 11 | 12 | 13 | #include "rsboost.h" 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | extern "C" { 30 | 31 | #include "rsmem.h" 32 | #include "rsdebug.h" 33 | 34 | } 35 | 36 | 37 | // Sample polygon, having legacy methods 38 | // (similar to e.g. COM objects) 39 | 40 | class rs_boost_linestring_t 41 | { 42 | 43 | rs_linestring_t *ls; 44 | 45 | 46 | public : 47 | 48 | typedef rs_point_t value_type; 49 | 50 | rs_boost_linestring_t(rs_linestring_t *ls1) { 51 | ls = ls1; 52 | }; 53 | 54 | void add_point(rs_point_t const& p) { 55 | rs_linestring_append_point(ls, p); 56 | }; 57 | 58 | // Const access 59 | rs_point_t const& get_point(std::size_t i) const 60 | { 61 | //BOOST_ASSERT(i < points.size()); 62 | return ls->p[i]; // points[i]; 63 | } 64 | 65 | // Mutable access 66 | rs_point_t & get_point(std::size_t i) 67 | { 68 | // BOOST_ASSERT(i < points.size()); 69 | return ls->p[i]; 70 | } 71 | 72 | 73 | int point_count() const { 74 | return ls->points_count; 75 | } 76 | void erase_all() { 77 | rs_linestring_clear(ls); 78 | } 79 | 80 | inline void set_size(int n) { 81 | (void)(n); // <-- unused parameter warning supressor 82 | } 83 | }; 84 | 85 | 86 | // ---------------------------------------------------------------------------- 87 | // Adaption: implement iterator and range-extension, and register with Boost.Geometry 88 | 89 | // 1) implement iterator (const and non-const versions) 90 | template 91 | struct custom_iterator : public boost::iterator_facade 92 | < 93 | custom_iterator, 94 | rs_point_t, 95 | boost::random_access_traversal_tag, 96 | typename boost::mpl::if_ 97 | < 98 | boost::is_const, 99 | rs_point_t const, 100 | rs_point_t 101 | >::type& 102 | > 103 | { 104 | // Constructor for begin() 105 | explicit custom_iterator(MyPolygon& polygon) 106 | : m_polygon(&polygon) 107 | , m_index(0) 108 | {} 109 | 110 | // Constructor for end() 111 | explicit custom_iterator(bool, MyPolygon& polygon) 112 | : m_polygon(&polygon) 113 | , m_index(polygon.point_count()) 114 | {} 115 | 116 | 117 | // Default constructor 118 | explicit custom_iterator() 119 | : m_polygon(NULL) 120 | , m_index(-1) 121 | {} 122 | 123 | typedef typename boost::mpl::if_ 124 | < 125 | boost::is_const, 126 | rs_point_t const, 127 | rs_point_t 128 | >::type my_point_type; 129 | 130 | private: 131 | friend class boost::iterator_core_access; 132 | 133 | 134 | typedef boost::iterator_facade 135 | < 136 | custom_iterator, 137 | rs_point_t, 138 | boost::random_access_traversal_tag, 139 | my_point_type& 140 | > facade; 141 | 142 | MyPolygon* m_polygon; 143 | int m_index; 144 | 145 | bool equal(custom_iterator const& other) const 146 | { 147 | return this->m_index == other.m_index; 148 | } 149 | typename facade::difference_type distance_to(custom_iterator const& other) const 150 | { 151 | return other.m_index - this->m_index; 152 | } 153 | 154 | void advance(typename facade::difference_type n) 155 | { 156 | m_index += n; 157 | if(m_polygon != NULL 158 | && (m_index >= m_polygon->point_count() 159 | || m_index < 0) 160 | ) 161 | { 162 | m_index = m_polygon->point_count(); 163 | } 164 | } 165 | 166 | void increment() 167 | { 168 | advance(1); 169 | } 170 | 171 | void decrement() 172 | { 173 | advance(-1); 174 | } 175 | 176 | // const and non-const dereference of this iterator 177 | my_point_type& dereference() const 178 | { 179 | return m_polygon->get_point(m_index); 180 | } 181 | }; 182 | 183 | 184 | 185 | 186 | // 2) Implement Boost.Range const functionality 187 | // using method 2, "provide free-standing functions and specialize metafunctions" 188 | // 2a) meta-functions 189 | namespace boost 190 | { 191 | template<> struct range_mutable_iterator 192 | { 193 | typedef custom_iterator type; 194 | }; 195 | 196 | template<> struct range_const_iterator 197 | { 198 | typedef custom_iterator type; 199 | }; 200 | 201 | // RangeEx 202 | template<> struct range_size 203 | { 204 | typedef std::size_t type; 205 | }; 206 | 207 | } // namespace 'boost' 208 | 209 | 210 | // 2b) free-standing function for Boost.Range ADP 211 | inline custom_iterator range_begin(rs_boost_linestring_t& polygon) 212 | { 213 | return custom_iterator(polygon); 214 | } 215 | 216 | inline custom_iterator range_begin(rs_boost_linestring_t const& polygon) 217 | { 218 | return custom_iterator(polygon); 219 | } 220 | 221 | inline custom_iterator range_end(rs_boost_linestring_t& polygon) 222 | { 223 | return custom_iterator(true, polygon); 224 | } 225 | 226 | inline custom_iterator range_end(rs_boost_linestring_t const& polygon) 227 | { 228 | return custom_iterator(true, polygon); 229 | } 230 | 231 | 232 | 233 | // 3) optional, for writable geometries only, implement push_back/resize/clear 234 | namespace boost { 235 | namespace geometry { 236 | namespace traits { 237 | 238 | template<> struct push_back 239 | { 240 | static inline void apply(rs_boost_linestring_t& polygon, rs_point_t const& point) 241 | { 242 | polygon.add_point(point); 243 | } 244 | }; 245 | 246 | template<> struct resize 247 | { 248 | static inline void apply(rs_boost_linestring_t& polygon, std::size_t new_size) 249 | { 250 | polygon.set_size(new_size); 251 | } 252 | }; 253 | 254 | template<> struct clear 255 | { 256 | static inline void apply(rs_boost_linestring_t& polygon) 257 | { 258 | polygon.erase_all(); 259 | } 260 | }; 261 | 262 | } 263 | } 264 | } 265 | 266 | 267 | // 4) register with Boost.Geometry 268 | BOOST_GEOMETRY_REGISTER_POINT_2D(rs_point_t, float, boost::geometry::cs::cartesian, x, y) 269 | 270 | BOOST_GEOMETRY_REGISTER_LINESTRING(rs_boost_linestring_t) 271 | 272 | 273 | rs_shape_t *rs_boost_shape_create_simplified(rs_shape_t *src, float tolerance) { 274 | 275 | rs_shape_t *sh = rs_shape_create(src->rings_count); 276 | 277 | for (int ri = 0; ri < src->rings_count; ri++) { 278 | 279 | 280 | rs_linestring_t *ls_src = src->rings[ri]; 281 | 282 | rs_linestring_t *ls_simplified = rs_linestring_create(ls_src->points_count); 283 | 284 | rs_boost_linestring_t b_ls_src(ls_src); 285 | rs_boost_linestring_t b_ls_simplified(ls_simplified); 286 | 287 | boost::geometry::simplify(b_ls_src, b_ls_simplified, tolerance); 288 | 289 | rs_shape_append_ring(sh, ls_simplified); 290 | 291 | }; 292 | 293 | return sh; 294 | 295 | }; 296 | 297 | rs_shape_t *rs_boost_shape_create_convex_hull(rs_shape_t *src) { 298 | 299 | rs_linestring_t *ls_src = src->rings[0]; 300 | 301 | rs_shape_t *sh = rs_shape_create(1); 302 | sh->outer_rings_count = 1; 303 | 304 | rs_linestring_t *ls_convex_hull = rs_linestring_create(ls_src->points_count + 1); 305 | 306 | rs_boost_linestring_t b_ls_src(ls_src); 307 | rs_boost_linestring_t b_ls_convex_hull(ls_convex_hull); 308 | 309 | boost::geometry::convex_hull(b_ls_src, b_ls_convex_hull); 310 | 311 | ls_convex_hull->points_count--; 312 | 313 | rs_shape_append_ring(sh, ls_convex_hull); 314 | 315 | return sh; 316 | 317 | }; 318 | --------------------------------------------------------------------------------