Tweaked terrain hex mesh
parent
b9393a2b8a
commit
a04ff9bd2f
|
@ -1,3 +1,5 @@
|
||||||
.import/*
|
.import/*
|
||||||
.mono/*
|
.mono/*
|
||||||
*.swp
|
*.swp
|
||||||
|
*.apk
|
||||||
|
*.idsig
|
||||||
|
|
|
@ -9,17 +9,17 @@
|
||||||
config_version=4
|
config_version=4
|
||||||
|
|
||||||
_global_script_classes=[ {
|
_global_script_classes=[ {
|
||||||
"base": "Node",
|
"base": "Reference",
|
||||||
"class": "ClickableComponent",
|
"class": "ClickableComponent",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://components/ClickableComponent.gd"
|
"path": "res://components/ClickableComponent.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "KinematicBody2D",
|
"base": "Reference",
|
||||||
"class": "CollisionLine",
|
"class": "CollisionLine",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://utils/CollisionLine.gd"
|
"path": "res://utils/CollisionLine.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "Node",
|
"base": "Reference",
|
||||||
"class": "ColorComponent",
|
"class": "ColorComponent",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://components/ColorComponent.gd"
|
"path": "res://components/ColorComponent.gd"
|
||||||
|
@ -29,7 +29,7 @@ _global_script_classes=[ {
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://utils/SpringDamper.gd"
|
"path": "res://utils/SpringDamper.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "Sprite",
|
"base": "Reference",
|
||||||
"class": "TintedSpriteComponent",
|
"class": "TintedSpriteComponent",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://components/TintedSpriteComponent.gd"
|
"path": "res://components/TintedSpriteComponent.gd"
|
||||||
|
|
|
@ -9,7 +9,7 @@ onready var tile_pos_label = $CanvasLayer/HBoxContainer/TilePos
|
||||||
onready var player = $Player
|
onready var player = $Player
|
||||||
|
|
||||||
var player_velocity = Vector3.ZERO
|
var player_velocity = Vector3.ZERO
|
||||||
var player_speed = 10
|
var player_speed = 5
|
||||||
var target_coordinate = Vector3.ZERO
|
var target_coordinate = Vector3.ZERO
|
||||||
var target_tile = null
|
var target_tile = null
|
||||||
var current_tile = null
|
var current_tile = null
|
||||||
|
@ -24,7 +24,7 @@ func _ready():
|
||||||
for j in range (-num_tiles_z / 2, num_tiles_z / 2):
|
for j in range (-num_tiles_z / 2, num_tiles_z / 2):
|
||||||
var pos = hexgrid.get_hex_center_from_offset(Vector2(i, j))
|
var pos = hexgrid.get_hex_center_from_offset(Vector2(i, j))
|
||||||
var tile = HexTile3D.instance()
|
var tile = HexTile3D.instance()
|
||||||
var height = (sin(pos.y * 0.3) * sin(pos.y * 0.8) * 0.8 + cos ((pos.x) * 0.9) * 1.24) * 0.5 - 0.5
|
var height = (sin(pos.y * 0.3) * sin(pos.y * 0.8) * 0.8 + cos ((pos.x) * 0.9) * 1.24) * 0.5 + 0.4 + rand_range(-0.3, 0.3)
|
||||||
tile.transform.origin = Vector3(pos.x, height, pos.y)
|
tile.transform.origin = Vector3(pos.x, height, pos.y)
|
||||||
tile.connect("tile_selected", self, "on_tile_selected")
|
tile.connect("tile_selected", self, "on_tile_selected")
|
||||||
tile.connect("tile_mouse_entered", self, "on_tile_hover")
|
tile.connect("tile_mouse_entered", self, "on_tile_hover")
|
||||||
|
@ -58,7 +58,7 @@ func _physics_process(delta):
|
||||||
|
|
||||||
func on_tile_selected(tile):
|
func on_tile_selected(tile):
|
||||||
target_tile = tile
|
target_tile = tile
|
||||||
target_coordinate = Vector3(tile.transform.origin.x, tile.transform.origin.z, tile.transform.origin.z)
|
target_coordinate = Vector3(tile.transform.origin.x, tile.transform.origin.y, tile.transform.origin.z)
|
||||||
var position_error = target_coordinate - player.transform.origin
|
var position_error = target_coordinate - player.transform.origin
|
||||||
print ("clicked on tile " + str(tile.transform.origin) + " error: " + str(position_error))
|
print ("clicked on tile " + str(tile.transform.origin) + " error: " + str(position_error))
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=8 format=2]
|
[gd_scene load_steps=9 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://scenes/HexTile3D.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://scenes/HexTile3D.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://scenes/HexGrid3DTest.gd" type="Script" id=2]
|
[ext_resource path="res://scenes/HexGrid3DTest.gd" type="Script" id=2]
|
||||||
|
@ -72,6 +72,8 @@ radius = 0.2
|
||||||
mid_height = 0.5
|
mid_height = 0.5
|
||||||
radial_segments = 16
|
radial_segments = 16
|
||||||
|
|
||||||
|
[sub_resource type="NoiseTexture" id=5]
|
||||||
|
|
||||||
[node name="HexGrid3DTest" type="Spatial"]
|
[node name="HexGrid3DTest" type="Spatial"]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
@ -133,7 +135,7 @@ __meta__ = {
|
||||||
[node name="Player" type="Spatial" parent="."]
|
[node name="Player" type="Spatial" parent="."]
|
||||||
|
|
||||||
[node name="Camera" type="Camera" parent="Player"]
|
[node name="Camera" type="Camera" parent="Player"]
|
||||||
transform = Transform( 1, 0, 0, 0, 0.511698, 0.859165, 0, -0.859165, 0.511698, 0, 2.72642, 1.60656 )
|
transform = Transform( 1, 0, 0, 0, 0.511698, 0.859165, 0, -0.859165, 0.511698, -4.76837e-07, 6.70866, 3.34822 )
|
||||||
current = true
|
current = true
|
||||||
fov = 60.0
|
fov = 60.0
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
@ -142,3 +144,12 @@ script = ExtResource( 3 )
|
||||||
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.5, 0 )
|
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.5, 0 )
|
||||||
mesh = SubResource( 4 )
|
mesh = SubResource( 4 )
|
||||||
material/0 = null
|
material/0 = null
|
||||||
|
|
||||||
|
[node name="TextureRect" type="TextureRect" parent="."]
|
||||||
|
margin_right = 40.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
texture = SubResource( 5 )
|
||||||
|
expand = true
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
extends MeshInstance
|
extends Spatial
|
||||||
|
|
||||||
onready var is_mouse_over = false
|
onready var is_mouse_over = false
|
||||||
|
onready var mesh = $Mesh
|
||||||
var old_material_override = Material.new()
|
var old_material_override = Material.new()
|
||||||
|
|
||||||
signal tile_selected
|
signal tile_selected
|
||||||
|
@ -9,18 +10,18 @@ signal tile_mouse_entered
|
||||||
|
|
||||||
func _on_Area_mouse_entered():
|
func _on_Area_mouse_entered():
|
||||||
is_mouse_over = true
|
is_mouse_over = true
|
||||||
old_material_override = material_override
|
old_material_override = mesh.material_override
|
||||||
|
|
||||||
var material = self.get_surface_material(0)
|
var material = mesh.get_surface_material(0)
|
||||||
var cloned_material = material.duplicate()
|
var cloned_material = material.duplicate()
|
||||||
cloned_material.albedo_color = Color (1, 0, 0)
|
cloned_material.albedo_color = Color (1, 0, 0)
|
||||||
self.material_override = cloned_material
|
mesh.material_override = cloned_material
|
||||||
emit_signal("tile_mouse_entered", self)
|
emit_signal("tile_mouse_entered", self)
|
||||||
|
|
||||||
|
|
||||||
func _on_Area_mouse_exited():
|
func _on_Area_mouse_exited():
|
||||||
is_mouse_over = false
|
is_mouse_over = false
|
||||||
self.material_override = old_material_override
|
mesh.material_override = old_material_override
|
||||||
|
|
||||||
|
|
||||||
func _on_Area_input_event(camera, event, position, normal, shape_idx):
|
func _on_Area_input_event(camera, event, position, normal, shape_idx):
|
||||||
|
|
|
@ -9,25 +9,27 @@ height = 1.0
|
||||||
radial_segments = 6
|
radial_segments = 6
|
||||||
rings = 1
|
rings = 1
|
||||||
|
|
||||||
[sub_resource type="SpatialMaterial" id=4]
|
[sub_resource type="SpatialMaterial" id=7]
|
||||||
albedo_color = Color( 0.211765, 0.568627, 0.0666667, 1 )
|
albedo_color = Color( 0.160784, 0.384314, 0.0901961, 1 )
|
||||||
roughness = 0.0
|
|
||||||
|
|
||||||
[sub_resource type="CylinderShape" id=5]
|
[sub_resource type="CylinderShape" id=5]
|
||||||
radius = 0.5
|
radius = 0.5
|
||||||
height = 1.0
|
height = 1.0
|
||||||
|
|
||||||
[node name="HexTile3D" type="MeshInstance"]
|
[node name="HexTile3D" type="Spatial"]
|
||||||
transform = Transform( -1.62921e-07, 0, 1, 0, 1, 0, -1, 0, -1.62921e-07, 0, -0.5, 0 )
|
transform = Transform( -1.62921e-07, 0, 1, 0, 1, 0, -1, 0, -1.62921e-07, 0, 0, 0 )
|
||||||
mesh = SubResource( 6 )
|
|
||||||
material/0 = SubResource( 4 )
|
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Area" type="Area" parent="."]
|
[node name="Mesh" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0 )
|
||||||
|
mesh = SubResource( 6 )
|
||||||
|
material/0 = SubResource( 7 )
|
||||||
|
|
||||||
[node name="CollisionShape" type="CollisionShape" parent="Area"]
|
[node name="Area" type="Area" parent="Mesh"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="Mesh/Area"]
|
||||||
shape = SubResource( 5 )
|
shape = SubResource( 5 )
|
||||||
|
|
||||||
[connection signal="input_event" from="Area" to="." method="_on_Area_input_event"]
|
[connection signal="input_event" from="Mesh/Area" to="." method="_on_Area_input_event"]
|
||||||
[connection signal="mouse_entered" from="Area" to="." method="_on_Area_mouse_entered"]
|
[connection signal="mouse_entered" from="Mesh/Area" to="." method="_on_Area_mouse_entered"]
|
||||||
[connection signal="mouse_exited" from="Area" to="." method="_on_Area_mouse_exited"]
|
[connection signal="mouse_exited" from="Mesh/Area" to="." method="_on_Area_mouse_exited"]
|
||||||
|
|
Loading…
Reference in New Issue