Initial commit: VR Messs workspace (grab v5.3.1, body-physics research)
This commit is contained in:
commit
5d2c5bf265
57 files changed
+4990
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using Godot;
|
||||
|
||||
public partial class TeleportMarker : Node3D
|
||||
{
|
||||
private static readonly Color IdleColor = new(0.2f, 0.55f, 0.9f);
|
||||
private static readonly Color HotColor = new(0.4f, 0.95f, 1.0f);
|
||||
|
||||
[Export]
|
||||
public string MarkerLabel { get; set; } = "1";
|
||||
|
||||
private StandardMaterial3D _discMaterial;
|
||||
private StandardMaterial3D _beamMaterial;
|
||||
private MeshInstance3D _beam;
|
||||
private Label3D _label;
|
||||
|
||||
public bool IsNear { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
AddToGroup("teleport_marker");
|
||||
|
||||
_discMaterial = MakeMaterial(IdleColor, false);
|
||||
_beamMaterial = MakeMaterial(new Color(IdleColor, 0.35f), true);
|
||||
|
||||
GetNode<MeshInstance3D>("Disc").SetSurfaceOverrideMaterial(0, _discMaterial);
|
||||
_beam = GetNode<MeshInstance3D>("Beam");
|
||||
_beam.SetSurfaceOverrideMaterial(0, _beamMaterial);
|
||||
_label = GetNode<Label3D>("Label3D");
|
||||
_label.Text = MarkerLabel;
|
||||
}
|
||||
|
||||
public void SetNear(bool near)
|
||||
{
|
||||
if (IsNear == near)
|
||||
return;
|
||||
IsNear = near;
|
||||
GetNode<MeshInstance3D>("Disc").Visible = !near;
|
||||
_beam.Visible = !near;
|
||||
_label.Visible = !near;
|
||||
}
|
||||
|
||||
public void SetHighlighted(bool highlighted)
|
||||
{
|
||||
Color c = highlighted ? HotColor : IdleColor;
|
||||
_discMaterial.AlbedoColor = c;
|
||||
_discMaterial.Emission = c;
|
||||
_beamMaterial.AlbedoColor = new Color(c, 0.35f);
|
||||
_beamMaterial.Emission = c;
|
||||
}
|
||||
|
||||
private static StandardMaterial3D MakeMaterial(Color color, bool transparent) => new()
|
||||
{
|
||||
AlbedoColor = color,
|
||||
EmissionEnabled = true,
|
||||
Emission = color,
|
||||
EmissionEnergyMultiplier = 2.0f,
|
||||
Transparency = transparent ? BaseMaterial3D.TransparencyEnum.Alpha : BaseMaterial3D.TransparencyEnum.Disabled,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user