-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using new lighter paths for faster editing
- Loading branch information
1 parent
bd38691
commit 4faec5b
Showing
8 changed files
with
257 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
extends Spatial | ||
|
||
var texture_path | ||
|
||
var color = Color(0.9, 0.1, 0.1) | ||
|
||
var point_list := PoolVector3Array() | ||
|
||
func create_mesh(point_list: PoolVector3Array): | ||
self.point_list = point_list | ||
refresh_mesh() | ||
|
||
func refresh_mesh(): | ||
var tmpMesh = Mesh.new() | ||
var i = 0 | ||
var last_uv: float = 0.0 | ||
for point_index in range(len(point_list)-1): | ||
var point:Vector3 = point_list[point_index] | ||
var next_point:Vector3 = point_list[point_index+1] | ||
|
||
var distance: float = point.distance_to(next_point) | ||
var normal: Vector3 = (next_point - point).normalized() | ||
#print(normal) | ||
var horizontal_tangent:Vector3 = Vector3(normal.z, 0, -normal.x).normalized() | ||
|
||
normal = Vector3(0,0,0) | ||
|
||
var point1: Vector3 = point + normal/2 - horizontal_tangent/2 | ||
var point2: Vector3 = point + normal/2 + horizontal_tangent/2 | ||
var point3: Vector3 = next_point - normal/2 + horizontal_tangent/2 | ||
var point4: Vector3 = next_point - normal/2 - horizontal_tangent/2 | ||
|
||
var vertices = PoolVector3Array() | ||
var UVs = PoolVector2Array() | ||
|
||
vertices.push_back(point1) | ||
vertices.push_back(point2) | ||
vertices.push_back(point3) | ||
vertices.push_back(point4) | ||
|
||
var next_uv = last_uv + distance | ||
|
||
UVs.push_back(Vector2(1,last_uv)) | ||
UVs.push_back(Vector2(0,last_uv)) | ||
UVs.push_back(Vector2(0,next_uv)) | ||
UVs.push_back(Vector2(1,next_uv)) | ||
|
||
last_uv = next_uv | ||
if last_uv > 100: | ||
last_uv = last_uv-100 | ||
|
||
var st = SurfaceTool.new() | ||
st.begin(Mesh.PRIMITIVE_TRIANGLE_FAN) | ||
|
||
for v in vertices.size(): | ||
st.add_color(color) | ||
st.add_uv(UVs[v]) | ||
st.add_vertex(vertices[v]) | ||
st.commit(tmpMesh) | ||
$MeshInstance.mesh = tmpMesh | ||
|
||
|
||
func update_point_vertical(index, y_value): | ||
pass | ||
|
||
func reverse(): | ||
self.point_list.invert() | ||
refresh_mesh() | ||
|
||
func get_point_count(): | ||
return len(self.point_list) | ||
|
||
func get_point_position(index: int): | ||
return self.point_list[index] | ||
|
||
func set_point_position(index: int, position: Vector3): | ||
self.point_list[index] = position | ||
create_mesh(self.point_list) | ||
|
||
func set_texture(texture): | ||
$MeshInstance.material_override.set_shader_param("texture_albedo", texture) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[gd_resource type="ShaderMaterial" load_steps=3 format=2] | ||
|
||
[ext_resource path="res://icon.png" type="Texture" id=1] | ||
|
||
[sub_resource type="Shader" id=1] | ||
code = "shader_type spatial; | ||
//render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx; | ||
render_mode unshaded, blend_mix, depth_draw_opaque, cull_disabled, diffuse_burley, specular_schlick_ggx; | ||
|
||
uniform sampler2D texture_albedo : hint_albedo; // TODO: Make instance uniform sampler2D when 4.0 is released | ||
uniform vec2 map_size; | ||
uniform bool map_flipped; | ||
uniform float map_bottom_offset = 36.0; | ||
|
||
uniform float interval = 1.0; | ||
|
||
void vertex() {} | ||
|
||
|
||
|
||
|
||
void fragment() { | ||
if (SCREEN_UV.x * VIEWPORT_SIZE.x > VIEWPORT_SIZE.x - map_size.x) { | ||
if (map_flipped && SCREEN_UV.y * VIEWPORT_SIZE.y > VIEWPORT_SIZE.y - map_size.y) { | ||
return; | ||
} | ||
if (!map_flipped && SCREEN_UV.y * VIEWPORT_SIZE.y < map_size.y + map_bottom_offset) { | ||
return; | ||
} | ||
} | ||
|
||
vec2 base_uv = vec2(UV.y, -UV.x * interval); | ||
base_uv = vec2(UV.x, -UV.y); | ||
vec4 albedo_tex = texture(texture_albedo,base_uv); | ||
ALBEDO = albedo_tex.rgb; | ||
ALPHA = albedo_tex.a; | ||
//EMISSION = albedo_tex.rgb; | ||
//METALLIC = 0.0; | ||
//ROUGHNESS = 1.0; | ||
//SPECULAR = 0.0; | ||
} | ||
" | ||
|
||
[resource] | ||
resource_local_to_scene = true | ||
shader = SubResource( 1 ) | ||
shader_param/map_size = Vector2( 0, 0 ) | ||
shader_param/map_flipped = null | ||
shader_param/map_bottom_offset = 36.0 | ||
shader_param/interval = 1.0 | ||
shader_param/texture_albedo = ExtResource( 1 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[gd_scene load_steps=3 format=2] | ||
|
||
[ext_resource path="res://Route.gd" type="Script" id=1] | ||
[ext_resource path="res://Route.tres" type="Material" id=2] | ||
|
||
[node name="Path" type="Spatial"] | ||
script = ExtResource( 1 ) | ||
|
||
[node name="MeshInstance" type="MeshInstance" parent="."] | ||
material_override = ExtResource( 2 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.