├── icon.png ├── Camera.vs ├── zekton.ttf ├── Planet.material ├── maps ├── faceoff.dat ├── levl2001.dat ├── levl2002.dat ├── levl2003.dat ├── levl2004.dat ├── levl2005.dat ├── levl2006.dat ├── levl2007.dat ├── levl2008.dat ├── levl2009.dat ├── levl2010.dat ├── levl2011.dat ├── levl2012.dat ├── levl2013.dat ├── levl2014.dat ├── levl2015.dat ├── levl2016.dat ├── levl2017.dat ├── levl2018.dat ├── levl2019.dat ├── levl2020.dat ├── levl2021.dat ├── levl2022.dat ├── levl2023.dat ├── levl2024.dat ├── levl2025.dat ├── levl2079.dat ├── levl2080.dat ├── levl2082.dat ├── levl2083.dat ├── levl2084.dat ├── levl2094.dat ├── levl2099.dat ├── levl2100.dat ├── levl2105.dat ├── levl2109.dat ├── levl2110.dat ├── levl2111.dat ├── levl2112.dat ├── levl2120.dat ├── levl2124.dat ├── levl2127.dat ├── levl2128.dat ├── levl2131.dat └── levl2133.dat ├── screenshots ├── 1.png ├── 2.png └── 3.png ├── textures ├── grass.jpg ├── rock.jpg ├── sand.jpg ├── snow.jpg ├── tile.png ├── rock.jpg.import ├── sand.jpg.import ├── snow.jpg.import ├── tile.png.import └── grass.jpg.import ├── World.gd ├── zekton.tres ├── README.md ├── default_env.tres ├── LICENSE ├── World.tscn ├── planet.shader ├── project.godot └── Planet.gd /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/icon.png -------------------------------------------------------------------------------- /Camera.vs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/Camera.vs -------------------------------------------------------------------------------- /zekton.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/zekton.ttf -------------------------------------------------------------------------------- /Planet.material: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/Planet.material -------------------------------------------------------------------------------- /maps/faceoff.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/faceoff.dat -------------------------------------------------------------------------------- /maps/levl2001.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2001.dat -------------------------------------------------------------------------------- /maps/levl2002.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2002.dat -------------------------------------------------------------------------------- /maps/levl2003.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2003.dat -------------------------------------------------------------------------------- /maps/levl2004.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2004.dat -------------------------------------------------------------------------------- /maps/levl2005.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2005.dat -------------------------------------------------------------------------------- /maps/levl2006.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2006.dat -------------------------------------------------------------------------------- /maps/levl2007.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2007.dat -------------------------------------------------------------------------------- /maps/levl2008.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2008.dat -------------------------------------------------------------------------------- /maps/levl2009.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2009.dat -------------------------------------------------------------------------------- /maps/levl2010.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2010.dat -------------------------------------------------------------------------------- /maps/levl2011.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2011.dat -------------------------------------------------------------------------------- /maps/levl2012.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2012.dat -------------------------------------------------------------------------------- /maps/levl2013.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2013.dat -------------------------------------------------------------------------------- /maps/levl2014.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2014.dat -------------------------------------------------------------------------------- /maps/levl2015.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2015.dat -------------------------------------------------------------------------------- /maps/levl2016.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2016.dat -------------------------------------------------------------------------------- /maps/levl2017.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2017.dat -------------------------------------------------------------------------------- /maps/levl2018.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2018.dat -------------------------------------------------------------------------------- /maps/levl2019.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2019.dat -------------------------------------------------------------------------------- /maps/levl2020.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2020.dat -------------------------------------------------------------------------------- /maps/levl2021.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2021.dat -------------------------------------------------------------------------------- /maps/levl2022.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2022.dat -------------------------------------------------------------------------------- /maps/levl2023.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2023.dat -------------------------------------------------------------------------------- /maps/levl2024.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2024.dat -------------------------------------------------------------------------------- /maps/levl2025.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2025.dat -------------------------------------------------------------------------------- /maps/levl2079.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2079.dat -------------------------------------------------------------------------------- /maps/levl2080.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2080.dat -------------------------------------------------------------------------------- /maps/levl2082.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2082.dat -------------------------------------------------------------------------------- /maps/levl2083.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2083.dat -------------------------------------------------------------------------------- /maps/levl2084.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2084.dat -------------------------------------------------------------------------------- /maps/levl2094.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2094.dat -------------------------------------------------------------------------------- /maps/levl2099.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2099.dat -------------------------------------------------------------------------------- /maps/levl2100.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2100.dat -------------------------------------------------------------------------------- /maps/levl2105.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2105.dat -------------------------------------------------------------------------------- /maps/levl2109.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2109.dat -------------------------------------------------------------------------------- /maps/levl2110.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2110.dat -------------------------------------------------------------------------------- /maps/levl2111.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2111.dat -------------------------------------------------------------------------------- /maps/levl2112.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2112.dat -------------------------------------------------------------------------------- /maps/levl2120.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2120.dat -------------------------------------------------------------------------------- /maps/levl2124.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2124.dat -------------------------------------------------------------------------------- /maps/levl2127.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2127.dat -------------------------------------------------------------------------------- /maps/levl2128.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2128.dat -------------------------------------------------------------------------------- /maps/levl2131.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2131.dat -------------------------------------------------------------------------------- /maps/levl2133.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/maps/levl2133.dat -------------------------------------------------------------------------------- /screenshots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/screenshots/1.png -------------------------------------------------------------------------------- /screenshots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/screenshots/2.png -------------------------------------------------------------------------------- /screenshots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/screenshots/3.png -------------------------------------------------------------------------------- /textures/grass.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/textures/grass.jpg -------------------------------------------------------------------------------- /textures/rock.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/textures/rock.jpg -------------------------------------------------------------------------------- /textures/sand.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/textures/sand.jpg -------------------------------------------------------------------------------- /textures/snow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/textures/snow.jpg -------------------------------------------------------------------------------- /textures/tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Chaosus/GDPlanet/HEAD/textures/tile.png -------------------------------------------------------------------------------- /World.gd: -------------------------------------------------------------------------------- 1 | extends Node 2 | 3 | onready var fps_label = $UI/fps_label 4 | 5 | func _ready(): 6 | set_process(true) 7 | 8 | func _process(delta): 9 | fps_label.set_text(str(Engine.get_frames_per_second())) 10 | -------------------------------------------------------------------------------- /zekton.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="DynamicFont" load_steps=2 format=2] 2 | 3 | [ext_resource path="res://zekton.ttf" type="DynamicFontData" id=1] 4 | 5 | [resource] 6 | 7 | size = 25 8 | use_mipmaps = false 9 | use_filter = false 10 | font_data = ExtResource( 1 ) 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GDPlanet 2 | Planet simulation demo 3 | 4 | This is non-realistic planet simulation on Godot(based on initial Populous : The beginning alike 128x128 grid). 5 | You can make own Spore-like or strategy games from this... 6 | 7 | ![Alt text](https://github.com/Chaosus/GDPlanet/blob/master/screenshots/1.png) 8 | 9 | ![Alt text](https://github.com/Chaosus/GDPlanet/blob/master/screenshots/2.png) 10 | 11 | ![Alt text](https://github.com/Chaosus/GDPlanet/blob/master/screenshots/3.png) 12 | -------------------------------------------------------------------------------- /default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 ) 6 | sky_horizon_color = Color( 0.0431373, 0.454902, 0.976471, 1 ) 7 | sky_curve = 0.25 8 | ground_bottom_color = Color( 0.0431373, 0.454902, 0.976471, 1 ) 9 | ground_horizon_color = Color( 0.0431373, 0.454902, 0.976471, 1 ) 10 | ground_curve = 0.01 11 | sun_latitude = 90.0 12 | sun_longitude = 90.0 13 | 14 | [resource] 15 | 16 | background_sky = SubResource( 1 ) 17 | background_color = Color( 0, 0.507812, 1, 1 ) 18 | ambient_light_color = Color( 0.214844, 0.214844, 0.214844, 1 ) 19 | fog_color = Color( 0.0431373, 0.454902, 0.976471, 1 ) 20 | fog_transmit_enabled = true 21 | 22 | -------------------------------------------------------------------------------- /textures/rock.jpg.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path.s3tc="res://.import/rock.jpg-46144f2c16704d479acd484d806d995e.s3tc.stex" 6 | path.etc2="res://.import/rock.jpg-46144f2c16704d479acd484d806d995e.etc2.stex" 7 | 8 | [deps] 9 | 10 | source_file="res://textures/rock.jpg" 11 | dest_files=[ "res://.import/rock.jpg-46144f2c16704d479acd484d806d995e.s3tc.stex", "res://.import/rock.jpg-46144f2c16704d479acd484d806d995e.etc2.stex" ] 12 | 13 | [params] 14 | 15 | compress/mode=2 16 | compress/lossy_quality=0.7 17 | compress/no_bptc_if_rgb=false 18 | compress/hdr_mode=0 19 | compress/normal_map=0 20 | flags/repeat=true 21 | flags/filter=true 22 | flags/mipmaps=true 23 | flags/anisotropic=true 24 | flags/srgb=2 25 | process/fix_alpha_border=true 26 | process/premult_alpha=false 27 | process/HDR_as_SRGB=false 28 | process/invert_color=false 29 | stream=false 30 | size_limit=0 31 | detect_3d=false 32 | svg/scale=1.0 33 | -------------------------------------------------------------------------------- /textures/sand.jpg.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path.s3tc="res://.import/sand.jpg-d56551c6e463d141e9a32b6f8ec96dbc.s3tc.stex" 6 | path.etc2="res://.import/sand.jpg-d56551c6e463d141e9a32b6f8ec96dbc.etc2.stex" 7 | 8 | [deps] 9 | 10 | source_file="res://textures/sand.jpg" 11 | dest_files=[ "res://.import/sand.jpg-d56551c6e463d141e9a32b6f8ec96dbc.s3tc.stex", "res://.import/sand.jpg-d56551c6e463d141e9a32b6f8ec96dbc.etc2.stex" ] 12 | 13 | [params] 14 | 15 | compress/mode=2 16 | compress/lossy_quality=0.7 17 | compress/no_bptc_if_rgb=false 18 | compress/hdr_mode=0 19 | compress/normal_map=0 20 | flags/repeat=true 21 | flags/filter=true 22 | flags/mipmaps=true 23 | flags/anisotropic=true 24 | flags/srgb=2 25 | process/fix_alpha_border=true 26 | process/premult_alpha=false 27 | process/HDR_as_SRGB=false 28 | process/invert_color=false 29 | stream=false 30 | size_limit=0 31 | detect_3d=false 32 | svg/scale=1.0 33 | -------------------------------------------------------------------------------- /textures/snow.jpg.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path.s3tc="res://.import/snow.jpg-14dfad66049ae9ec1cbe03dadd3236a7.s3tc.stex" 6 | path.etc2="res://.import/snow.jpg-14dfad66049ae9ec1cbe03dadd3236a7.etc2.stex" 7 | 8 | [deps] 9 | 10 | source_file="res://textures/snow.jpg" 11 | dest_files=[ "res://.import/snow.jpg-14dfad66049ae9ec1cbe03dadd3236a7.s3tc.stex", "res://.import/snow.jpg-14dfad66049ae9ec1cbe03dadd3236a7.etc2.stex" ] 12 | 13 | [params] 14 | 15 | compress/mode=2 16 | compress/lossy_quality=0.7 17 | compress/no_bptc_if_rgb=false 18 | compress/hdr_mode=0 19 | compress/normal_map=0 20 | flags/repeat=true 21 | flags/filter=true 22 | flags/mipmaps=true 23 | flags/anisotropic=true 24 | flags/srgb=2 25 | process/fix_alpha_border=true 26 | process/premult_alpha=false 27 | process/HDR_as_SRGB=false 28 | process/invert_color=false 29 | stream=false 30 | size_limit=0 31 | detect_3d=false 32 | svg/scale=1.0 33 | -------------------------------------------------------------------------------- /textures/tile.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path.s3tc="res://.import/tile.png-8644383a6c109d9e066d6d3d1e5f8130.s3tc.stex" 6 | path.etc2="res://.import/tile.png-8644383a6c109d9e066d6d3d1e5f8130.etc2.stex" 7 | 8 | [deps] 9 | 10 | source_file="res://textures/tile.png" 11 | dest_files=[ "res://.import/tile.png-8644383a6c109d9e066d6d3d1e5f8130.s3tc.stex", "res://.import/tile.png-8644383a6c109d9e066d6d3d1e5f8130.etc2.stex" ] 12 | 13 | [params] 14 | 15 | compress/mode=2 16 | compress/lossy_quality=0.7 17 | compress/no_bptc_if_rgb=false 18 | compress/hdr_mode=0 19 | compress/normal_map=0 20 | flags/repeat=true 21 | flags/filter=true 22 | flags/mipmaps=true 23 | flags/anisotropic=true 24 | flags/srgb=2 25 | process/fix_alpha_border=true 26 | process/premult_alpha=false 27 | process/HDR_as_SRGB=false 28 | process/invert_color=false 29 | stream=false 30 | size_limit=0 31 | detect_3d=false 32 | svg/scale=1.0 33 | -------------------------------------------------------------------------------- /textures/grass.jpg.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path.s3tc="res://.import/grass.jpg-7c31b068203bf1d53a3db469e9ee2f5d.s3tc.stex" 6 | path.etc2="res://.import/grass.jpg-7c31b068203bf1d53a3db469e9ee2f5d.etc2.stex" 7 | 8 | [deps] 9 | 10 | source_file="res://textures/grass.jpg" 11 | dest_files=[ "res://.import/grass.jpg-7c31b068203bf1d53a3db469e9ee2f5d.s3tc.stex", "res://.import/grass.jpg-7c31b068203bf1d53a3db469e9ee2f5d.etc2.stex" ] 12 | 13 | [params] 14 | 15 | compress/mode=2 16 | compress/lossy_quality=0.7 17 | compress/no_bptc_if_rgb=false 18 | compress/hdr_mode=0 19 | compress/normal_map=0 20 | flags/repeat=true 21 | flags/filter=true 22 | flags/mipmaps=true 23 | flags/anisotropic=true 24 | flags/srgb=2 25 | process/fix_alpha_border=true 26 | process/premult_alpha=false 27 | process/HDR_as_SRGB=false 28 | process/invert_color=false 29 | stream=false 30 | size_limit=0 31 | detect_3d=false 32 | svg/scale=1.0 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Yuri Roubinski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /World.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=5 format=2] 2 | 3 | [ext_resource path="res://World.gd" type="Script" id=1] 4 | [ext_resource path="res://Planet.gd" type="Script" id=2] 5 | [ext_resource path="res://zekton.tres" type="DynamicFont" id=3] 6 | 7 | [sub_resource type="ArrayMesh" id=1] 8 | 9 | 10 | [node name="World" type="Node"] 11 | script = ExtResource( 1 ) 12 | 13 | [node name="Planet" type="Spatial" parent="."] 14 | script = ExtResource( 2 ) 15 | 16 | [node name="MeshInstance" type="MeshInstance" parent="Planet"] 17 | mesh = SubResource( 1 ) 18 | 19 | [node name="Sun" type="DirectionalLight" parent="Planet"] 20 | transform = Transform( 0.866025, -0.469846, 0.17101, 0, 0.34202, 0.939693, -0.5, -0.813798, 0.296198, 0, 1.81959, 0 ) 21 | 22 | [node name="Camera" type="Camera" parent="."] 23 | transform = Transform( 1, 0, 0, 0, 0.866025, 0.5, 0, -0.5, 0.866025, 0, 0, 0 ) 24 | keep_aspect = 0 25 | current = true 26 | fov = 65.0 27 | near = 1.0 28 | far = 1000.0 29 | 30 | [node name="UI" type="CanvasLayer" parent="."] 31 | 32 | [node name="fps_label" type="Label" parent="UI"] 33 | margin_right = 43.0 34 | margin_bottom = 28.0 35 | custom_fonts/font = ExtResource( 3 ) 36 | text = "FPS" 37 | 38 | [node name="pos_label" type="Label" parent="UI"] 39 | margin_top = 30.0 40 | margin_right = 53.0 41 | margin_bottom = 58.0 42 | custom_fonts/font = ExtResource( 3 ) 43 | text = "Pos:" 44 | 45 | -------------------------------------------------------------------------------- /planet.shader: -------------------------------------------------------------------------------- 1 | shader_type spatial; 2 | 3 | render_mode cull_back; 4 | 5 | uniform sampler2D texture1; 6 | 7 | uniform sampler2D texture2; 8 | 9 | uniform sampler2D texture3; 10 | 11 | uniform sampler2D texture4; 12 | 13 | uniform sampler2D grid_texture; 14 | 15 | uniform sampler2D map_texture; 16 | 17 | uniform bool enable_grid = false; 18 | 19 | uniform float sphere_ratio = 0.01; 20 | 21 | uniform float hdecr_factor = 0.0; 22 | 23 | uniform vec2 tpos; 24 | 25 | uniform vec2 rpos; 26 | 27 | uniform int size = 128; 28 | 29 | varying vec4 mtVal; 30 | 31 | void vertex() 32 | { 33 | // compute normals 34 | 35 | int x = (int(VERTEX.x) - int(rpos.x)) % size; 36 | int z = (int(VERTEX.z) - int(rpos.y)) % size; 37 | float hL = texelFetch(map_texture, ivec2((x-1) % size, z), 0).r; 38 | float hR = texelFetch(map_texture, ivec2((x+1) % size, z), 0).r; 39 | float hD = texelFetch(map_texture, ivec2(x, (z-1) % size), 0).r; 40 | float hU = texelFetch(map_texture, ivec2(x, (z+1) % size), 0).r; 41 | vec3 n; 42 | n.x = hL - hR; 43 | n.y = hD - hU; 44 | n.z = 2.0; 45 | n = normalize(n); 46 | NORMAL = n; 47 | 48 | float c2 = texelFetch(map_texture, ivec2(x, z), 0).r; 49 | 50 | VERTEX.x += tpos.x; 51 | VERTEX.z += tpos.y; 52 | 53 | VERTEX.y = c2 * 2.0; 54 | 55 | // water 56 | 57 | if(VERTEX.y == 0.0) 58 | COLOR = vec4(0.0,0.0,1.0,1.0); 59 | else 60 | COLOR = vec4(1.0,1.0,1.0,1.0); 61 | 62 | float f1 = VERTEX.x; 63 | float f2 = VERTEX.z; 64 | f1 = f1 * f1; 65 | f2 = f2 * f2; 66 | float rf1 = sqrt(f1 + f2); 67 | float h = VERTEX.y * 8.0; 68 | mtVal.x = clamp(1.0 - abs((h - 0.0) / 5.0), 0.0, 1.0); 69 | mtVal.y = clamp(1.0 - abs((h - 5.0) / 5.0), 0.0, 1.0); 70 | mtVal.z = clamp(1.0 - abs((h - 10.0) / 5.0), 0.0, 1.0); 71 | mtVal.w = clamp(1.0 - abs((h - 20.0) / 10.0), 0.0, 1.0); 72 | float total = mtVal.x + mtVal.y + mtVal.z + mtVal.w; 73 | mtVal.x /= total; 74 | mtVal.y /= total; 75 | mtVal.z /= total; 76 | mtVal.w /= total; 77 | VERTEX.y = clamp(VERTEX.y - hdecr_factor, 0, 1000); 78 | VERTEX.y += -rf1*rf1*sphere_ratio; 79 | } 80 | 81 | void fragment() 82 | { 83 | vec2 uv = UV.xy; 84 | 85 | ALBEDO = texture(texture1, uv).rgb * mtVal.x; 86 | ALBEDO += texture(texture2, uv).rgb * mtVal.y; 87 | ALBEDO += texture(texture3, uv).rgb * mtVal.z; 88 | ALBEDO += texture(texture4, uv).rgb * mtVal.w; 89 | 90 | 91 | if(enable_grid) 92 | { 93 | vec4 t = texture(grid_texture, uv).rgba; 94 | if(t.a==0.0) 95 | { 96 | ALBEDO.rgb *= COLOR.rgb; 97 | } 98 | else 99 | { 100 | ALBEDO.rgb *= t.rgb * COLOR.rgb; 101 | } 102 | } 103 | else 104 | { 105 | ALBEDO.rgb *= COLOR.rgb; 106 | } 107 | } -------------------------------------------------------------------------------- /project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | _global_script_classes=[ ] 12 | _global_script_class_icons={ 13 | 14 | } 15 | 16 | [application] 17 | 18 | config/name="Planet" 19 | run/main_scene="res://World.tscn" 20 | config/icon="res://icon.png" 21 | 22 | [debug] 23 | 24 | gdscript/warnings/unused_argument=false 25 | 26 | [display] 27 | 28 | window/size/width=1920 29 | window/size/height=1080 30 | window/size/fullscreen=true 31 | window/vsync/use_vsync=false 32 | 33 | [gdnative] 34 | 35 | singletons=[ ] 36 | 37 | [input] 38 | 39 | planet_rotate_forward={ 40 | "deadzone": 0.5, 41 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null) 42 | ] 43 | } 44 | planet_rotate_backward={ 45 | "deadzone": 0.5, 46 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null) 47 | ] 48 | } 49 | planet_rotate_left={ 50 | "deadzone": 0.5, 51 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null) 52 | ] 53 | } 54 | planet_rotate_right={ 55 | "deadzone": 0.5, 56 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null) 57 | ] 58 | } 59 | planet_accelkey={ 60 | "deadzone": 0.5, 61 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777237,"unicode":0,"echo":false,"script":null) 62 | ] 63 | } 64 | planet_view={ 65 | "deadzone": 0.5, 66 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null) 67 | ] 68 | } 69 | planet_altkey={ 70 | "deadzone": 0.5, 71 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777238,"unicode":0,"echo":false,"script":null) 72 | ] 73 | } 74 | change_grid={ 75 | "deadzone": 0.5, 76 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) 77 | ] 78 | } 79 | 80 | [rendering] 81 | 82 | environment/default_environment="res://default_env.tres" 83 | -------------------------------------------------------------------------------- /Planet.gd: -------------------------------------------------------------------------------- 1 | extends Spatial 2 | 3 | const GROUND_X_SIZE = 128 4 | const GROUND_Z_SIZE = 128 5 | const VIEW_RANGE2 = 60.0 6 | const VIEW_RANGE = VIEW_RANGE2 / 2 7 | const SPEED = 5 8 | const ROTSPEED = 50 9 | const GROUND_BLOCK_HEIGHT = 0.01 10 | const DEF_ENGINE_ROT_X = 35.0 11 | const DEF_ENGINE_POS_Y = 9.5 12 | const VERTEX_OFFSET = -VIEW_RANGE 13 | 14 | var mat = preload("res://Planet.material") 15 | 16 | var sphere_ratio = 0.01 17 | 18 | onready var camera = get_parent().get_node("Camera") 19 | var beginZoom = false 20 | var zoom = false 21 | var camera_pos = Vector3(0, 3.5, -3) 22 | var camera_target = Vector3(0, 0, 4) 23 | 24 | var enginePosX = 128/2 25 | var enginePosY = 0.0 26 | var enginePosZ = 128/2 27 | 28 | var engineRotX = DEF_ENGINE_ROT_X 29 | var engineRotY = 0.0 30 | var engineRotZ = 0.0 31 | var hdecr_factor = 0.0 32 | 33 | var st = null 34 | var map_image 35 | var map_texture 36 | 37 | class PlanetVertex: 38 | var height = 0.0 39 | var volume 40 | 41 | var vertexes = [] 42 | var quad = [Vector3(),Vector3(),Vector3(),Vector3()] 43 | 44 | func combine_2byte(a, b): 45 | return (b << 8) | (a & 0xff) 46 | 47 | func get_pindex(x, y): 48 | x = wrapi(x, 0, GROUND_X_SIZE) 49 | y = wrapi(y, 0, GROUND_Z_SIZE) 50 | return x + y * GROUND_X_SIZE 51 | 52 | 53 | func _ready(): 54 | 55 | map_image = Image.new() 56 | map_image.create(128, 128, 0, Image.FORMAT_RGB8) 57 | 58 | var file = File.new() 59 | file.open("maps/faceoff.dat", File.READ) 60 | var buffer = file.get_buffer(16384 * 2) 61 | var data = [] 62 | var i = 0 63 | var j = 0 64 | while j < 16384: 65 | data.push_back(combine_2byte(buffer[i], buffer[i+1])) 66 | i+=2 67 | j+=1 68 | map_image.lock() 69 | for x in range(GROUND_X_SIZE): 70 | for z in range(GROUND_Z_SIZE): 71 | var v = PlanetVertex.new() 72 | v.height = float(data[x + z * 128]) * 0.3 73 | v.volume = CollisionShape.new() 74 | var box = BoxShape.new() 75 | box.extents = Vector3(x + 0.5,0.5,z + 0.5) 76 | v.volume.set_shape(box) 77 | vertexes.append(v) 78 | var c = clamp(data[x + z * 128] / 700.0, 0.0, 1.0) 79 | map_image.set_pixel(wrapi(x, 0, 128), wrapi(z, 0, 128), Color(c,c,c)) 80 | map_image.unlock() 81 | file.close() 82 | 83 | map_texture = ImageTexture.new() 84 | map_texture.create_from_image(map_image, Texture.FLAG_REPEAT) 85 | #$Sprite.texture = texture 86 | st = SurfaceTool.new() 87 | mat.set_shader_param("map_texture", map_texture) 88 | 89 | create_mesh() 90 | # var data = map_texture.get_data() 91 | # data.lock() 92 | # for x in range(GROUND_X_SIZE): 93 | # for z in range(GROUND_Z_SIZE): 94 | # var v = PlanetVertex.new() 95 | # v.height = data.get_pixel(x,z).r * 255 96 | # vertexes.append(v) 97 | # data.unlock() 98 | 99 | func rotate_forward(step): 100 | var f = 360.0 - engineRotY 101 | while f >= 360.0: 102 | f -= 360.0 103 | while f < 0.0: 104 | f += 360.0 105 | enginePosX -= sin(deg2rad(f)) * step 106 | enginePosZ -= cos(deg2rad(f)) * step 107 | 108 | func rotate_backward(step): 109 | var f = 360.0 - engineRotY 110 | while f >= 360.0: 111 | f -= 360.0 112 | while f < 0.0: 113 | f += 360.0 114 | enginePosX += sin(deg2rad(f)) * step 115 | enginePosZ += cos(deg2rad(f)) * step 116 | 117 | func rotate_left(step): 118 | var f = 360.0 - engineRotY + 90.0 119 | while f >= 360.0: 120 | f -= 360.0 121 | while f < 0.0: 122 | f += 360.0 123 | enginePosX -= sin(deg2rad(f)) * step 124 | enginePosZ -= cos(deg2rad(f)) * step 125 | 126 | func rotate_right(step): 127 | var f = 360.0 - engineRotY + 90.0 128 | while f >= 360.0: 129 | f -= 360.0 130 | while f < 0.0: 131 | f += 360.0 132 | enginePosX += sin(deg2rad(f)) * step 133 | enginePosZ += cos(deg2rad(f)) * step 134 | 135 | func rotate_view_left(step): 136 | engineRotY -= step 137 | 138 | func rotate_view_right(step): 139 | engineRotY += step 140 | 141 | 142 | 143 | func process_input(delta): 144 | 145 | var speed = SPEED 146 | var rspeed = ROTSPEED 147 | var strafe = false 148 | if Input.is_action_pressed("planet_accelkey"): 149 | speed *= 2 150 | rspeed *= 2 151 | if Input.is_action_pressed("planet_altkey"): 152 | strafe = true 153 | 154 | if Input.is_action_pressed("planet_rotate_forward"): 155 | rotate_forward(speed * delta) 156 | elif Input.is_action_pressed("planet_rotate_backward"): 157 | rotate_backward(speed * delta) 158 | if Input.is_action_pressed("planet_rotate_left"): 159 | if strafe: 160 | rotate_left(speed * delta) 161 | else: 162 | rotate_view_left(rspeed * delta) 163 | elif Input.is_action_pressed("planet_rotate_right"): 164 | if strafe: 165 | rotate_right(speed * delta) 166 | else: 167 | rotate_view_right(rspeed * delta) 168 | 169 | if Input.is_action_just_pressed("planet_view"): 170 | if !beginZoom: 171 | beginZoom = true 172 | zoom = !zoom 173 | 174 | update_zoom(delta) 175 | 176 | 177 | func update_zoom(delta): 178 | 179 | var s = 60.0 180 | 181 | if beginZoom: 182 | if zoom: 183 | if enginePosY >= 60: 184 | enginePosY = 60 185 | beginZoom = false 186 | 187 | 188 | enginePosY += 1 * s * delta 189 | hdecr_factor += 0.1 * s * delta 190 | 191 | sphere_ratio += 0.001 * s * delta 192 | camera_target.y -= 0.5 * s * delta 193 | camera_pos.y += 0.11 * s * delta 194 | 195 | camera_pos.z += 0.02 * s * delta 196 | else: 197 | 198 | if enginePosY <= 0: 199 | enginePosY = 0 200 | beginZoom = false 201 | 202 | enginePosY -= 1 * s * delta 203 | hdecr_factor -= 0.1* s * delta; 204 | 205 | sphere_ratio -= 0.001 * s * delta 206 | camera_target.y += 0.5 * s * delta 207 | camera_pos.y -= 0.11 * s * delta 208 | 209 | camera_pos.z -= 0.02 * s * delta 210 | 211 | mat.set_shader_param("sphere_ratio", sphere_ratio) 212 | mat.set_shader_param("hdecr_factor", hdecr_factor) 213 | 214 | #if enginePosY > 9.5 215 | 216 | func _process(delta): 217 | process_input(delta) 218 | 219 | 220 | enginePosX = wrapf(enginePosX, 0, 128) 221 | enginePosZ = wrapf(enginePosZ, 0, 128) 222 | engineRotX = wrapf(engineRotX, 0.0, 360.0) 223 | engineRotY = wrapf(engineRotY, 0.0, 360.0) 224 | engineRotZ = wrapf(engineRotZ, 0.0, 360.0) 225 | 226 | get_parent().get_node("UI/pos_label").text = str(int(enginePosX)) + "," + str(int(enginePosZ)) 227 | 228 | if Input.is_action_just_pressed("change_grid"): 229 | mat.set_shader_param("enable_grid", !mat.get_shader_param("enable_grid")) 230 | 231 | camera.look_at_from_position(camera_pos, camera_target, Vector3(0,1,0)) 232 | 233 | update_transforms() 234 | 235 | mat.set_shader_param("tpos", Vector2(wrapf(enginePosX, 0.0, 1.0), wrapf(enginePosZ, 0.0, 1.0))) 236 | mat.set_shader_param("rpos", Vector2(enginePosX, enginePosZ)) 237 | 238 | if Input.is_key_pressed(KEY_ESCAPE): 239 | get_tree().quit() 240 | 241 | if Input.is_key_pressed(KEY_X): 242 | var x = wrapi(128-enginePosX, 0, 128) 243 | var y = wrapi(128-enginePosZ, 0, 128) 244 | map_image.lock() 245 | map_image.set_pixel(x, y, map_image.get_pixel(x, y) + Color(0.005,0.005,0.005)) 246 | map_image.unlock() 247 | map_texture.set_data(map_image) 248 | 249 | func update_transforms(): 250 | rotation = (Vector3(0,deg2rad(engineRotY),0)) 251 | 252 | func compute_normal(x, z): 253 | var hL = vertexes[get_pindex(x-1,z)].height 254 | var hR = vertexes[get_pindex(x+1,z)].height 255 | var hD = vertexes[get_pindex(x,z-1)].height 256 | var hU = vertexes[get_pindex(x,z+1)].height 257 | 258 | var N = Vector3() 259 | N.x = hL - hR 260 | N.y = hD - hU 261 | N.z = 2.0 262 | N = N.normalized() 263 | 264 | return N 265 | 266 | func create_mesh(): 267 | st.clear() 268 | st.begin(Mesh.PRIMITIVE_TRIANGLE_STRIP) 269 | st.set_material(mat) 270 | var z = wrapf(enginePosZ, 0, VIEW_RANGE2) 271 | for az in VIEW_RANGE2: 272 | var x = wrapf(enginePosX, 0, VIEW_RANGE2) 273 | for ax in VIEW_RANGE2: 274 | quad[0] = Vector3(x + VERTEX_OFFSET, 0.0, z + VERTEX_OFFSET) 275 | quad[1] = Vector3(x+1 + VERTEX_OFFSET, 0.0, z + VERTEX_OFFSET) 276 | quad[2] = Vector3(x + VERTEX_OFFSET, 0.0, z+1 + VERTEX_OFFSET) 277 | quad[3] = Vector3(x+1 + VERTEX_OFFSET, 0.0, z+1 + VERTEX_OFFSET) 278 | 279 | st.add_uv(Vector2(0,0)) 280 | st.add_normal(Vector3(0,1,0)) 281 | st.add_vertex(quad[0]) 282 | 283 | st.add_uv(Vector2(1,0)) 284 | st.add_normal(Vector3(0,1,0)) 285 | st.add_vertex(quad[1]) 286 | 287 | st.add_uv(Vector2(0,1)) 288 | st.add_normal(Vector3(0,1,0)) 289 | st.add_vertex(quad[2]) 290 | 291 | st.add_uv(Vector2(1,1)) 292 | st.add_normal(Vector3(0,1,0)) 293 | st.add_vertex(quad[3]) 294 | 295 | x = wrapf(x + 1, 0, VIEW_RANGE2) 296 | z = wrapf(z + 1, 0, VIEW_RANGE2) 297 | $MeshInstance.mesh = st.commit() 298 | --------------------------------------------------------------------------------