Axial tilt and sun rotation
This commit is contained in:
parent
63f4423baf
commit
edffc76e05
5 changed files with 129 additions and 28 deletions
|
|
@ -11,7 +11,7 @@ config_version=5
|
|||
[application]
|
||||
|
||||
config/name="adatonic"
|
||||
config/version="0.0.3"
|
||||
config/version="0.0.4"
|
||||
run/main_scene="uid://csfh7ptgerpm2"
|
||||
config/features=PackedStringArray("4.6", "C#", "GL Compatibility")
|
||||
config/icon="res://icon.svg"
|
||||
|
|
|
|||
|
|
@ -13,13 +13,20 @@
|
|||
sky_material = SubResource("ProceduralSkyMaterial_uxrcv")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_rf2cd"]
|
||||
background_mode = 2
|
||||
background_mode = 1
|
||||
background_color = Color(0.11748905, 0.11748903, 0.11748903, 1)
|
||||
sky = SubResource("Sky_tlwt5")
|
||||
ambient_light_source = 3
|
||||
reflected_light_source = 2
|
||||
|
||||
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_a814b"]
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_ygjfp"]
|
||||
top_radius = 0.005
|
||||
bottom_radius = 0.005
|
||||
height = 3.0
|
||||
radial_segments = 24
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_rpqi1"]
|
||||
radius = 1.0
|
||||
|
||||
|
|
@ -31,11 +38,11 @@ anchor_bottom = 1.0
|
|||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_611at")
|
||||
_yawNode = NodePath("TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo/Yaw")
|
||||
_pitchNode = NodePath("TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo/Yaw/Pitch")
|
||||
_cameraNode = NodePath("TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo/Yaw/Pitch/Camera3D")
|
||||
_meshInstance = NodePath("TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo/Icosphere")
|
||||
World = NodePath("TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo")
|
||||
_yawNode = NodePath("TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo/Yaw")
|
||||
_pitchNode = NodePath("TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo/Yaw/Pitch")
|
||||
_cameraNode = NodePath("TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo/Yaw/Pitch/Camera3D")
|
||||
_meshInstance = NodePath("TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo/Icosphere")
|
||||
World = NodePath("TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo")
|
||||
_textureRect = NodePath("TabContainer/Projection")
|
||||
_gradient = ExtResource("2_ygjfp")
|
||||
|
||||
|
|
@ -52,51 +59,82 @@ current_tab = 0
|
|||
layout_mode = 2
|
||||
metadata/_tab_index = 0
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="TabContainer/Planet" unique_id=58474785]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/Planet" unique_id=1579792581]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 1.44
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="TabContainer/Planet/VBoxContainer" unique_id=58474785]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 1.44
|
||||
stretch = true
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="TabContainer/Planet/SubViewportContainer" unique_id=1257998631]
|
||||
[node name="SubViewport" type="SubViewport" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer" unique_id=1257998631]
|
||||
handle_input_locally = false
|
||||
size = Vector2i(677, 617)
|
||||
size = Vector2i(677, 554)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="ZaWarudo" type="Node3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport" unique_id=937719505]
|
||||
[node name="ZaWarudo" type="Node3D" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport" unique_id=937719505]
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=610642146]
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo" unique_id=610642146]
|
||||
environment = SubResource("Environment_rf2cd")
|
||||
camera_attributes = SubResource("CameraAttributesPractical_a814b")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=899426195]
|
||||
[node name="Sun" type="DirectionalLight3D" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo" unique_id=899426195]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(0.99999994, 0, 0, 0, 0.99999994, 0, 0, 0, 0.99999994, 0, 0, 0)
|
||||
|
||||
[node name="Icosphere" type="MeshInstance3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=793654005]
|
||||
[node name="Icosphere" type="MeshInstance3D" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo" unique_id=793654005]
|
||||
transform = Transform3D(0.01, 0, 0, 0, 0.01, 0, 0, 0, 0.01, 0, 0, 0)
|
||||
mesh = ExtResource("2_k24pf")
|
||||
surface_material_override/0 = ExtResource("3_ygjfp")
|
||||
|
||||
[node name="Yaw" type="Node3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=2073443785]
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo/Icosphere" unique_id=1889403188]
|
||||
transform = Transform3D(100, 0, 0, 0, 100, 0, 0, 0, 100, 0, 0, 0)
|
||||
mesh = SubResource("CylinderMesh_ygjfp")
|
||||
|
||||
[node name="Pitch" type="Node3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo/Yaw" unique_id=98015529]
|
||||
[node name="Yaw" type="Node3D" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo" unique_id=2073443785]
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo/Yaw/Pitch" unique_id=1654616370]
|
||||
[node name="Pitch" type="Node3D" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo/Yaw" unique_id=98015529]
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo/Yaw/Pitch" unique_id=1654616370]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
|
||||
fov = 5.0
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=330930041]
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo" unique_id=330930041]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo/StaticBody3D" unique_id=299495076]
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo/StaticBody3D" unique_id=299495076]
|
||||
shape = SubResource("SphereShape3D_rpqi1")
|
||||
|
||||
[node name="Pointer" type="Sprite3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=1498529325]
|
||||
[node name="Pointer" type="Sprite3D" parent="TabContainer/Planet/VBoxContainer/SubViewportContainer/SubViewport/ZaWarudo" unique_id=1498529325]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(0.01, 0, 0, 0, 0.01, 0, 0, 0, 0.01, 0, 0, 0)
|
||||
modulate = Color(1, 0, 0, 1)
|
||||
billboard = 1
|
||||
texture = ExtResource("5_ygjfp")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="TabContainer/Planet/VBoxContainer" unique_id=1706135009]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/Planet/VBoxContainer/MarginContainer" unique_id=781791664]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="TabContainer/Planet/VBoxContainer/MarginContainer/VBoxContainer" unique_id=882691555]
|
||||
layout_mode = 2
|
||||
text = "Sun Angle"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="SunAngle" type="HSlider" parent="TabContainer/Planet/VBoxContainer/MarginContainer/VBoxContainer" unique_id=1452623828]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
max_value = 360.0
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="TabContainer/Planet" unique_id=716838825]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
|
@ -111,6 +149,24 @@ theme_override_constants/margin_bottom = 12
|
|||
[node name="VBoxContainer2" type="VBoxContainer" parent="TabContainer/Planet/PanelContainer/MarginContainer" unique_id=1788559732]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="TabContainer/Planet/PanelContainer/MarginContainer/VBoxContainer2" unique_id=525897562]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/Planet/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer2" unique_id=902181636]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="TabContainer/Planet/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer2/HBoxContainer" unique_id=1460559875]
|
||||
layout_mode = 2
|
||||
text = "Axial Tilt"
|
||||
|
||||
[node name="AxialTilt" type="LineEdit" parent="TabContainer/Planet/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer2/HBoxContainer" unique_id=1085416630]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "23.5"
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="TabContainer/Planet/PanelContainer/MarginContainer/VBoxContainer2" unique_id=907047328]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/Planet/PanelContainer/MarginContainer/VBoxContainer2" unique_id=654818970]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -257,6 +313,11 @@ stretch_mode = 5
|
|||
metadata/_tab_index = 1
|
||||
|
||||
[connection signal="tab_changed" from="TabContainer" to="." method="Tab"]
|
||||
[connection signal="mouse_entered" from="TabContainer/Planet/VBoxContainer/SubViewportContainer" to="." method="MouseInViewport"]
|
||||
[connection signal="mouse_exited" from="TabContainer/Planet/VBoxContainer/SubViewportContainer" to="." method="MouseLeftViewport"]
|
||||
[connection signal="drag_ended" from="TabContainer/Planet/VBoxContainer/MarginContainer/VBoxContainer/SunAngle" to="." method="SunAngleStop"]
|
||||
[connection signal="drag_started" from="TabContainer/Planet/VBoxContainer/MarginContainer/VBoxContainer/SunAngle" to="." method="SunAngleStart"]
|
||||
[connection signal="text_changed" from="TabContainer/Planet/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer2/HBoxContainer/AxialTilt" to="." method="AxialTiltChanged"]
|
||||
[connection signal="pressed" from="TabContainer/Planet/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer/HBoxContainer3/Reset" to="." method="MakeGo"]
|
||||
[connection signal="pressed" from="TabContainer/Planet/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer/HBoxContainer3/Advance" to="." method="Advance"]
|
||||
[connection signal="pressed" from="TabContainer/Planet/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer/HBoxContainer3/AutoRun" to="." method="AutoRun"]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
shader_type spatial;
|
||||
render_mode unshaded;
|
||||
|
||||
uniform int mode = 1;
|
||||
uniform sampler2D gradient;
|
||||
|
|
|
|||
47
src/Main.cs
47
src/Main.cs
|
|
@ -8,6 +8,7 @@ using Godot.Collections;
|
|||
|
||||
public partial class Main : Control
|
||||
{
|
||||
public static Random Random = Random.Shared;
|
||||
private bool _moving = false;
|
||||
[Export]
|
||||
private Node3D _yawNode;
|
||||
|
|
@ -35,17 +36,29 @@ public partial class Main : Control
|
|||
_planetHelper = new PlanetHelper(_meshInstance, _textureRect);
|
||||
UpdateStats();
|
||||
Projector.GatherPoints(_planetHelper, int.Parse(GetNode<LineEdit>("%Resolution").Text));
|
||||
AxialTiltChanged(GetNode<LineEdit>("%AxialTilt").Text);
|
||||
}
|
||||
|
||||
Vector3 _pointerPosition = Vector3.Zero;
|
||||
private const float RayLength = 1000.0f;
|
||||
|
||||
private bool _rotateable = false;
|
||||
public void MouseInViewport()
|
||||
{
|
||||
_rotateable = true;
|
||||
}
|
||||
|
||||
public void MouseLeftViewport()
|
||||
{
|
||||
_rotateable = false;
|
||||
}
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventMouseButton mouseEvent)
|
||||
{
|
||||
if (mouseEvent.ButtonIndex == MouseButton.Left)
|
||||
{
|
||||
_moving = mouseEvent.Pressed;
|
||||
_moving = mouseEvent.Pressed && _rotateable;
|
||||
}
|
||||
if (mouseEvent.ButtonIndex == MouseButton.WheelUp)
|
||||
{
|
||||
|
|
@ -83,8 +96,8 @@ public partial class Main : Control
|
|||
if (result.Count > 0)
|
||||
{
|
||||
Vector3 pos = result["position"].AsVector3();
|
||||
|
||||
GD.Print($"Hit: '{pos}'");
|
||||
pos *= _meshInstance.Transform.Basis.Orthonormalized();
|
||||
var closest = _planetHelper.Octree.SearchNearest(pos)?.Id;
|
||||
if (closest != null)
|
||||
{
|
||||
|
|
@ -95,6 +108,7 @@ public partial class Main : Control
|
|||
_plate = null;
|
||||
UpdateStats();
|
||||
Vector3 vertexPos = _planetHelper.Mdt.GetVertex(_vertex.Id) * 0.01f;
|
||||
vertexPos *= _meshInstance.Transform.Basis.Inverse().Orthonormalized();
|
||||
_pointerPosition = (Vector3)vertexPos + (vertexPos * (_vertex.Height + 0.01f) * 0.1f); // vertexPos * 1.01f;
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +124,12 @@ public partial class Main : Control
|
|||
_planetHelper.AutoRun = true;
|
||||
}
|
||||
_planetHelper.Process();
|
||||
GetNode<Node3D>("%Pointer").Position = _pointerPosition;
|
||||
GetNode<Node3D>("%Pointer").GlobalPosition = _pointerPosition;
|
||||
if (_sunRotating)
|
||||
{
|
||||
GetNode<Node3D>("%Sun").Rotation -= GetNode<Node3D>("%Sun").Rotation;
|
||||
GetNode<Node3D>("%Sun").Rotation += new Vector3(0, (float)Mathf.DegToRad(GetNode<HSlider>("%SunAngle").Value), 0);
|
||||
}
|
||||
}
|
||||
public void UpdateStats()
|
||||
{
|
||||
|
|
@ -201,4 +220,26 @@ public partial class Main : Control
|
|||
_resolution = Int32.Parse(change);
|
||||
_resolution = Math.Clamp(_resolution, 64, 2048);
|
||||
}
|
||||
|
||||
public void AxialTiltChanged(string value)
|
||||
{
|
||||
if (float.TryParse(value, out float tilt))
|
||||
{
|
||||
_meshInstance.RotateZ(-_meshInstance.Rotation.Z);
|
||||
_meshInstance.RotateZ(Mathf.DegToRad(tilt));
|
||||
_axialTilt = tilt;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _sunRotating = false;
|
||||
private float _axialTilt = 0f;
|
||||
public void SunAngleStart()
|
||||
{
|
||||
_sunRotating = true;
|
||||
}
|
||||
|
||||
public void SunAngleStop(bool changed)
|
||||
{
|
||||
_sunRotating = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class PlanetHelper
|
|||
{
|
||||
public static float RandF(float min, float max)
|
||||
{
|
||||
return min + (max - min) * Random.Shared.NextSingle();
|
||||
return min + (max - min) * Main.Random.NextSingle();
|
||||
}
|
||||
public class PlateData(int Id = 0, Color Color = new(), bool IsLandform = false, List<int> Vertices = null)
|
||||
{
|
||||
|
|
@ -115,7 +115,7 @@ public class PlanetHelper
|
|||
|
||||
for (int i = 0; i < Mdt.GetVertexCount(); i++)
|
||||
{
|
||||
Octree.Insert(new Node(i, Mdt.GetVertex(i) * 0.001f));
|
||||
Octree.Insert(new Node(i, Mdt.GetVertex(i) * 0.01f));
|
||||
Mdt.SetVertexColor(i, Colors.Black);
|
||||
}
|
||||
if (_meshInstance.GetSurfaceOverrideMaterial(0) is ShaderMaterial shaderMaterial)
|
||||
|
|
@ -434,7 +434,7 @@ public class PlanetHelper
|
|||
}
|
||||
public void SpreadStress()
|
||||
{
|
||||
var availableVerts = Vertices.Where(d => d.StageComplete == false && d.IsEdge && d.StrainSamples.Any()).OrderByDescending(d => Mathf.Abs(d.StrainSamples.Max(s => s.Magnitude))).Take(500).ToList();
|
||||
var availableVerts = Vertices.Where(d => d.StageComplete == false && d.IsEdge && d.StrainSamples.Any()).OrderByDescending(d => Mathf.Abs(d.StrainSamples.Max(s => s.Magnitude))).Take(2500).ToList();
|
||||
foreach (VertexData vertexData in availableVerts)
|
||||
{
|
||||
var neighbours = GetNeighboringVertices(vertexData.Id, false).ToList();
|
||||
|
|
@ -491,7 +491,7 @@ public class PlanetHelper
|
|||
float mountainNoise = (1.0f + _mountainNoise.GetNoise3Dv(GetVertexPosition(vertexData.Id))) * 0.5f;
|
||||
float hfNoise = _hfNoise.GetNoise3Dv(GetVertexPosition(vertexData.Id));
|
||||
var majorStrain = AverageStrainList(vertexData.StrainSamples);
|
||||
var normalRate = -majorStrain.NormalRate * majorStrain.Magnitude * (plate.IsLandform ? 1f : 0.5f);
|
||||
var normalRate = -majorStrain.NormalRate * majorStrain.Magnitude; // * (plate.IsLandform ? 1f : 0.5f);
|
||||
var edgeDistance = vertexData.EdgeDistance * (plate.IsLandform ? 1f : -1f);
|
||||
float height = 0.5f;
|
||||
//height *= plate.PlateExpansion;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue