Level 3
Using Level 3 to do a big art pass and get a lot of systems set up and cleaned up. Add Phantom Camera addon with comprehensive 2D/3D camera system
This commit is contained in:
1 parent
5ce882b53d
commit
2c6a395938
1122 files changed
+42103
-40
No files matched your search
@@ -0,0 +1,116 @@
|
||||
using Godot;
|
||||
|
||||
namespace PhantomCamera;
|
||||
|
||||
public enum KeepAspect
|
||||
{
|
||||
KeepWidth,
|
||||
KeepHeight
|
||||
}
|
||||
|
||||
public enum ProjectionType
|
||||
{
|
||||
Perspective,
|
||||
Orthogonal,
|
||||
Frustum
|
||||
}
|
||||
|
||||
public class Camera3DResource(Resource resource)
|
||||
{
|
||||
public readonly Resource Resource = resource;
|
||||
|
||||
public KeepAspect KeepAspect
|
||||
{
|
||||
get => (KeepAspect)(int)Resource.Get(PropertyName.KeepAspect);
|
||||
set => Resource.Set(PropertyName.KeepAspect, (int)value);
|
||||
}
|
||||
|
||||
public int CullMask
|
||||
{
|
||||
get => (int)Resource.Get(PropertyName.CullMask);
|
||||
set => Resource.Set(PropertyName.CullMask, value);
|
||||
}
|
||||
|
||||
|
||||
public float HOffset
|
||||
{
|
||||
get => (float)Resource.Get(PropertyName.HOffset);
|
||||
set => Resource.Set(PropertyName.HOffset, value);
|
||||
}
|
||||
|
||||
public float VOffset
|
||||
{
|
||||
get => (float)Resource.Get(PropertyName.VOffset);
|
||||
set => Resource.Set(PropertyName.VOffset, value);
|
||||
}
|
||||
|
||||
public ProjectionType Projection
|
||||
{
|
||||
get => (ProjectionType)(int)Resource.Get(PropertyName.Projection);
|
||||
set => Resource.Set(PropertyName.Projection, (int)value);
|
||||
}
|
||||
|
||||
public float Fov
|
||||
{
|
||||
get => (float)Resource.Get(PropertyName.Fov);
|
||||
set => Resource.Set(PropertyName.Fov, Mathf.Clamp(value, 1, 179));
|
||||
}
|
||||
|
||||
public float Size
|
||||
{
|
||||
get => (float)Resource.Get(PropertyName.Size);
|
||||
set => Resource.Set(PropertyName.Size, Mathf.Clamp(value, 0.001f, float.PositiveInfinity));
|
||||
}
|
||||
|
||||
public Vector2 FrustumOffset
|
||||
{
|
||||
get => (Vector2)Resource.Get(PropertyName.FrustumOffset);
|
||||
set => Resource.Set(PropertyName.FrustumOffset, value);
|
||||
}
|
||||
|
||||
public float Near
|
||||
{
|
||||
get => (float)Resource.Get(PropertyName.Near);
|
||||
set => Resource.Set(PropertyName.Near, Mathf.Clamp(value, 0.001f, float.PositiveInfinity));
|
||||
}
|
||||
|
||||
public float Far
|
||||
{
|
||||
get => (float)Resource.Get(PropertyName.Far);
|
||||
set => Resource.Set(PropertyName.Far, Mathf.Clamp(value, 0.01f, float.PositiveInfinity));
|
||||
}
|
||||
|
||||
public static Camera3DResource New()
|
||||
{
|
||||
Resource resource = new();
|
||||
#if GODOT4_4_OR_GREATER
|
||||
resource.SetScript(GD.Load<GDScript>("uid://b8hhnqsugykly"));
|
||||
#else
|
||||
resource.SetScript(GD.Load<GDScript>("res://addons/phantom_camera/scripts/resources/camera_3d_resource.gd"));
|
||||
#endif
|
||||
return new Camera3DResource(resource);
|
||||
}
|
||||
|
||||
public static class PropertyName
|
||||
{
|
||||
public static readonly StringName KeepAspect = new("keep_aspect");
|
||||
|
||||
public static readonly StringName CullMask = new("cull_mask");
|
||||
|
||||
public static readonly StringName HOffset = new("h_offset");
|
||||
|
||||
public static readonly StringName VOffset = new("v_offset");
|
||||
|
||||
public static readonly StringName Projection = new("projection");
|
||||
|
||||
public static readonly StringName Fov = new("fov");
|
||||
|
||||
public static readonly StringName Size = new("size");
|
||||
|
||||
public static readonly StringName FrustumOffset = new("frustum_offset");
|
||||
|
||||
public static readonly StringName Near = new("near");
|
||||
|
||||
public static readonly StringName Far = new("far");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://jedyxlihuwbj
|
||||
@@ -0,0 +1,103 @@
|
||||
using Godot;
|
||||
|
||||
namespace PhantomCamera.Noise;
|
||||
|
||||
public class PhantomCameraNoise2D(Resource resource)
|
||||
{
|
||||
public readonly Resource Resource = resource;
|
||||
|
||||
public float Amplitude
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetAmplitude);
|
||||
set => Resource.Call(MethodName.SetAmplitude, value);
|
||||
}
|
||||
|
||||
public float Frequency
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetFrequency);
|
||||
set => Resource.Call(MethodName.SetFrequency, value);
|
||||
}
|
||||
|
||||
public bool RandomizeNoiseSeed
|
||||
{
|
||||
get => (bool)Resource.Call(MethodName.GetRandomizeNoiseSeed);
|
||||
set => Resource.Call(MethodName.SetRandomizeNoiseSeed, value);
|
||||
}
|
||||
|
||||
public int NoiseSeed
|
||||
{
|
||||
get => (int)Resource.Call(MethodName.GetNoiseSeed);
|
||||
set => Resource.Call(MethodName.SetNoiseSeed, value);
|
||||
}
|
||||
|
||||
public bool RotationalNoise
|
||||
{
|
||||
get => (bool)Resource.Call(MethodName.GetRotationalNoise);
|
||||
set => Resource.Call(MethodName.SetRotationalNoise, value);
|
||||
}
|
||||
|
||||
public bool PositionalNoise
|
||||
{
|
||||
get => (bool)Resource.Call(MethodName.GetPositionalNoise);
|
||||
set => Resource.Call(MethodName.SetPositionalNoise, value);
|
||||
}
|
||||
|
||||
public float RotationalMultiplier
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetRotationalMultiplier);
|
||||
set => Resource.Call(MethodName.SetRotationalMultiplier, value);
|
||||
}
|
||||
|
||||
public float PositionalMultiplierX
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetPositionalMultiplierX);
|
||||
set => Resource.Call(MethodName.SetPositionalMultiplierX, value);
|
||||
}
|
||||
|
||||
public float PositionalMultiplierY
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetPositionalMultiplierY);
|
||||
set => Resource.Call(MethodName.SetPositionalMultiplierY, value);
|
||||
}
|
||||
|
||||
public static PhantomCameraNoise2D New()
|
||||
{
|
||||
Resource resource = new();
|
||||
#if GODOT4_4_OR_GREATER
|
||||
resource.SetScript(GD.Load<GDScript>("uid://dimvdouy8g0sv"));
|
||||
#else
|
||||
resource.SetScript(GD.Load<GDScript>("res://addons/phantom_camera/scripts/resources/phantom_camera_noise_2d.gd"));
|
||||
#endif
|
||||
return new PhantomCameraNoise2D(resource);
|
||||
}
|
||||
|
||||
public static class MethodName
|
||||
{
|
||||
public static readonly StringName GetAmplitude = new("get_amplitude");
|
||||
public static readonly StringName SetAmplitude = new("set_amplitude");
|
||||
|
||||
public static readonly StringName GetFrequency = new("get_frequency");
|
||||
public static readonly StringName SetFrequency = new("set_frequency");
|
||||
|
||||
public static readonly StringName GetRandomizeNoiseSeed = new("get_randomize_noise_seed");
|
||||
public static readonly StringName SetRandomizeNoiseSeed = new("set_randomize_noise_seed");
|
||||
|
||||
public static readonly StringName GetNoiseSeed = new("get_noise_seed");
|
||||
public static readonly StringName SetNoiseSeed = new("set_noise_seed");
|
||||
|
||||
public static readonly StringName GetRotationalNoise = new("get_rotational_noise");
|
||||
public static readonly StringName SetRotationalNoise = new("set_rotational_noise");
|
||||
|
||||
public static readonly StringName GetPositionalNoise = new("get_positional_noise");
|
||||
public static readonly StringName SetPositionalNoise = new("set_positional_noise");
|
||||
|
||||
public static readonly StringName GetRotationalMultiplier = new("get_rotational_multiplier");
|
||||
public static readonly StringName SetRotationalMultiplier = new("set_rotational_multiplier");
|
||||
|
||||
public static readonly StringName GetPositionalMultiplierX = new("get_positional_multiplier_x");
|
||||
public static readonly StringName SetPositionalMultiplierX = new("set_positional_multiplier_x");
|
||||
|
||||
public static readonly StringName GetPositionalMultiplierY = new("get_positional_multiplier_y");
|
||||
public static readonly StringName SetPositionalMultiplierY = new("set_positional_multiplier_y");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://capjdoxs6gs6r
|
||||
@@ -0,0 +1,130 @@
|
||||
using Godot;
|
||||
|
||||
namespace PhantomCamera.Noise;
|
||||
|
||||
public class PhantomCameraNoise3D(Resource resource)
|
||||
{
|
||||
public readonly Resource Resource = resource;
|
||||
|
||||
public float Amplitude
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetAmplitude);
|
||||
set => Resource.Call(MethodName.SetAmplitude, value);
|
||||
}
|
||||
|
||||
public float Frequency
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetFrequency);
|
||||
set => Resource.Call(MethodName.SetFrequency, value);
|
||||
}
|
||||
|
||||
public bool RandomizeNoiseSeed
|
||||
{
|
||||
get => (bool)Resource.Call(MethodName.GetRandomizeNoiseSeed);
|
||||
set => Resource.Call(MethodName.SetRandomizeNoiseSeed, value);
|
||||
}
|
||||
|
||||
public int NoiseSeed
|
||||
{
|
||||
get => (int)Resource.Call(MethodName.GetNoiseSeed);
|
||||
set => Resource.Call(MethodName.SetNoiseSeed, value);
|
||||
}
|
||||
|
||||
public bool RotationalNoise
|
||||
{
|
||||
get => (bool)Resource.Call(MethodName.GetRotationalNoise);
|
||||
set => Resource.Call(MethodName.SetRotationalNoise, value);
|
||||
}
|
||||
|
||||
public bool PositionalNoise
|
||||
{
|
||||
get => (bool)Resource.Call(MethodName.GetPositionalNoise);
|
||||
set => Resource.Call(MethodName.SetPositionalNoise, value);
|
||||
}
|
||||
|
||||
public float RotationalMultiplierX
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetRotationalMultiplierX);
|
||||
set => Resource.Call(MethodName.SetRotationalMultiplierX, value);
|
||||
}
|
||||
|
||||
public float RotationalMultiplierY
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetRotationalMultiplierY);
|
||||
set => Resource.Call(MethodName.SetRotationalMultiplierY, value);
|
||||
}
|
||||
|
||||
public float RotationalMultiplierZ
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetRotationalMultiplierZ);
|
||||
set => Resource.Call(MethodName.SetRotationalMultiplierZ, value);
|
||||
}
|
||||
|
||||
public float PositionalMultiplierX
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetPositionalMultiplierX);
|
||||
set => Resource.Call(MethodName.SetPositionalMultiplierX, value);
|
||||
}
|
||||
|
||||
public float PositionalMultiplierY
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetPositionalMultiplierY);
|
||||
set => Resource.Call(MethodName.SetPositionalMultiplierY, value);
|
||||
}
|
||||
|
||||
public float PositionalMultiplierZ
|
||||
{
|
||||
get => (float)Resource.Call(MethodName.GetPositionalMultiplierZ);
|
||||
set => Resource.Call(MethodName.SetPositionalMultiplierZ, value);
|
||||
}
|
||||
|
||||
public static PhantomCameraNoise3D New()
|
||||
{
|
||||
Resource resource = new();
|
||||
#if GODOT4_4_OR_GREATER
|
||||
resource.SetScript(GD.Load<GDScript>("uid://cuffvge5ad4aa"));
|
||||
#else
|
||||
resource.SetScript(GD.Load<GDScript>("res://addons/phantom_camera/scripts/resources/phantom_camera_noise_3d.gd"));
|
||||
#endif
|
||||
return new PhantomCameraNoise3D(resource);
|
||||
}
|
||||
|
||||
public static class MethodName
|
||||
{
|
||||
public static readonly StringName GetAmplitude = new("get_amplitude");
|
||||
public static readonly StringName SetAmplitude = new("set_amplitude");
|
||||
|
||||
public static readonly StringName GetFrequency = new("get_frequency");
|
||||
public static readonly StringName SetFrequency = new("set_frequency");
|
||||
|
||||
public static readonly StringName GetRandomizeNoiseSeed = new("get_randomize_noise_seed");
|
||||
public static readonly StringName SetRandomizeNoiseSeed = new("set_randomize_noise_seed");
|
||||
|
||||
public static readonly StringName GetNoiseSeed = new("get_noise_seed");
|
||||
public static readonly StringName SetNoiseSeed = new("set_noise_seed");
|
||||
|
||||
public static readonly StringName GetRotationalNoise = new("get_rotational_noise");
|
||||
public static readonly StringName SetRotationalNoise = new("set_rotational_noise");
|
||||
|
||||
public static readonly StringName GetPositionalNoise = new("get_positional_noise");
|
||||
public static readonly StringName SetPositionalNoise = new("set_positional_noise");
|
||||
|
||||
public static readonly StringName GetRotationalMultiplierX = new("get_rotational_multiplier_x");
|
||||
public static readonly StringName SetRotationalMultiplierX = new("set_rotational_multiplier_x");
|
||||
|
||||
public static readonly StringName GetRotationalMultiplierY = new("get_rotational_multiplier_y");
|
||||
public static readonly StringName SetRotationalMultiplierY = new("set_rotational_multiplier_y");
|
||||
|
||||
public static readonly StringName GetRotationalMultiplierZ = new("get_rotational_multiplier_z");
|
||||
public static readonly StringName SetRotationalMultiplierZ = new("set_rotational_multiplier_z");
|
||||
|
||||
public static readonly StringName GetPositionalMultiplierX = new("get_positional_multiplier_x");
|
||||
public static readonly StringName SetPositionalMultiplierX = new("set_positional_multiplier_x");
|
||||
|
||||
public static readonly StringName GetPositionalMultiplierY = new("get_positional_multiplier_y");
|
||||
public static readonly StringName SetPositionalMultiplierY = new("set_positional_multiplier_y");
|
||||
|
||||
public static readonly StringName GetPositionalMultiplierZ = new("get_positional_multiplier_z");
|
||||
public static readonly StringName SetPositionalMultiplierZ = new("set_positional_multiplier_z");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://chk7643ynhe4f
|
||||
@@ -0,0 +1,75 @@
|
||||
using Godot;
|
||||
|
||||
namespace PhantomCamera;
|
||||
|
||||
public enum TransitionType
|
||||
{
|
||||
Linear,
|
||||
Sine,
|
||||
Quint,
|
||||
Quart,
|
||||
Quad,
|
||||
Expo,
|
||||
Elastic,
|
||||
Cubic,
|
||||
Circ,
|
||||
Bounce,
|
||||
Back
|
||||
}
|
||||
|
||||
public enum EaseType
|
||||
{
|
||||
EaseIn,
|
||||
EaseOut,
|
||||
EaseInOut,
|
||||
EaseOutIn
|
||||
}
|
||||
|
||||
public static class PhantomCameraTweenExtensions
|
||||
{
|
||||
public static PhantomCameraTween AsPhantomCameraTween(this Resource resource)
|
||||
{
|
||||
return new PhantomCameraTween(resource);
|
||||
}
|
||||
}
|
||||
|
||||
public class PhantomCameraTween(Resource tweenResource)
|
||||
{
|
||||
public Resource Resource { get; } = tweenResource;
|
||||
|
||||
public float Duration
|
||||
{
|
||||
get => (float)Resource.Get(PropertyName.Duration);
|
||||
set => Resource.Set(PropertyName.Duration, value);
|
||||
}
|
||||
|
||||
public TransitionType Transition
|
||||
{
|
||||
get => (TransitionType)(int)Resource.Get(PropertyName.Transition);
|
||||
set => Resource.Set(PropertyName.Transition, (int)value);
|
||||
}
|
||||
|
||||
public EaseType Ease
|
||||
{
|
||||
get => (EaseType)(int)Resource.Get(PropertyName.Ease);
|
||||
set => Resource.Set(PropertyName.Ease, (int)value);
|
||||
}
|
||||
|
||||
public static PhantomCameraTween New()
|
||||
{
|
||||
Resource resource = new();
|
||||
#if GODOT4_4_OR_GREATER
|
||||
resource.SetScript(GD.Load<GDScript>("uid://8umksf8e80fw"));
|
||||
#else
|
||||
resource.SetScript(GD.Load<GDScript>("res://addons/phantom_camera/scripts/resources/tween_resource.gd"));
|
||||
#endif
|
||||
return new PhantomCameraTween(resource);
|
||||
}
|
||||
|
||||
public static class PropertyName
|
||||
{
|
||||
public static readonly StringName Duration = new("duration");
|
||||
public static readonly StringName Transition = new("transition");
|
||||
public static readonly StringName Ease = new("ease");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://ybr5c2s0tfvx
|
||||
@@ -0,0 +1,89 @@
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace PhantomCamera.TweenDirector;
|
||||
|
||||
public enum Type {
|
||||
PhantomCameras = 0,
|
||||
TweenResources = 1,
|
||||
Any = 2,
|
||||
}
|
||||
|
||||
public class TweenDirectorResource(Resource resource)
|
||||
{
|
||||
public readonly Resource Resource = resource;
|
||||
|
||||
public PhantomCameraTween TweenResource
|
||||
{
|
||||
get => new((Resource)Resource.Call(MethodName.GetTweenResource));
|
||||
set => Resource.Call(MethodName.SetTweenResource, (GodotObject)value.Resource);
|
||||
}
|
||||
|
||||
public Type FromType
|
||||
{
|
||||
get => (Type)(int)Resource.Call(MethodName.GetFromType);
|
||||
set => Resource.Call(MethodName.SetFromType, (int)value);
|
||||
}
|
||||
|
||||
public NodePath[] FromPhantomCameras
|
||||
{
|
||||
get => Resource.Call(MethodName.GetFromPhantomCameras).AsGodotArray<NodePath>().ToArray();
|
||||
set => Resource.Call(MethodName.SetFromPhantomCameras, new Array<NodePath>(value));
|
||||
}
|
||||
|
||||
public Resource[] FromTweenResources
|
||||
{
|
||||
get => Resource.Call(MethodName.GetFromTweenResources).AsGodotArray<Resource>().ToArray();
|
||||
set => Resource.Call(MethodName.SetFromTweenResources, new Array<Resource>(value));
|
||||
}
|
||||
|
||||
public Type ToType
|
||||
{
|
||||
get => (Type)(int)Resource.Call(MethodName.GetToType);
|
||||
set => Resource.Call(MethodName.SetToType, (int)value);
|
||||
}
|
||||
|
||||
public NodePath[] ToPhantomCameras
|
||||
{
|
||||
get => (NodePath[])Resource.Call(MethodName.GetToPhantomCameras);
|
||||
set => Resource.Call(MethodName.SetToPhantomCameras, value);
|
||||
}
|
||||
|
||||
public Resource[] ToTweenResources
|
||||
{
|
||||
get => Resource.Call(MethodName.GetToTweenResources).AsGodotArray<Resource>().ToArray();
|
||||
set => Resource.Call(MethodName.SetToTweenResources, new Array<Resource>(value));
|
||||
}
|
||||
|
||||
public static TweenDirectorResource New()
|
||||
{
|
||||
Resource resource = new();
|
||||
resource.SetScript(GD.Load<GDScript>("uid://2au3qse3jc5t"));
|
||||
return new TweenDirectorResource(resource);
|
||||
}
|
||||
|
||||
public static class MethodName
|
||||
{
|
||||
public static readonly StringName GetTweenResource = new("get_tween_resource");
|
||||
public static readonly StringName SetTweenResource = new("set_tween_resource");
|
||||
|
||||
public static readonly StringName GetFromType = new("get_from_type");
|
||||
public static readonly StringName SetFromType = new("set_from_type");
|
||||
|
||||
public static readonly StringName GetFromPhantomCameras = new("get_from_phantom_cameras");
|
||||
public static readonly StringName SetFromPhantomCameras = new("set_from_phantom_cameras");
|
||||
|
||||
public static readonly StringName GetFromTweenResources = new("get_from_tween_resources");
|
||||
public static readonly StringName SetFromTweenResources = new("set_from_tween_resources");
|
||||
|
||||
public static readonly StringName GetToType = new("get_to_type");
|
||||
public static readonly StringName SetToType = new("set_to_type");
|
||||
|
||||
public static readonly StringName GetToPhantomCameras = new("get_to_phantom_cameras");
|
||||
public static readonly StringName SetToPhantomCameras = new("set_to_phantom_cameras");
|
||||
|
||||
public static readonly StringName GetToTweenResources = new("get_to_tween_resources");
|
||||
public static readonly StringName SetToTweenResources = new("set_to_tween_resources");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
@tool
|
||||
@icon("res://addons/phantom_camera/icons/phantom_camera_camera_3d_resource.svg")
|
||||
class_name Camera3DResource
|
||||
extends Resource
|
||||
|
||||
## Resource for [PhantomCamera3D] to override various [Camera3D] properties.
|
||||
##
|
||||
## The overrides defined here will be applied to the [Camera3D] upon the
|
||||
## [PhantomCamera3D] becoming active.
|
||||
|
||||
enum KeepAspect {
|
||||
KEEP_WIDTH = 0, ## Preserves the horizontal aspect ratio; also known as Vert- scaling. This is usually the best option for projects running in portrait mode, as taller aspect ratios will benefit from a wider vertical FOV.
|
||||
KEEP_HEIGHT = 1, ## Preserves the vertical aspect ratio; also known as Hor+ scaling. This is usually the best option for projects running in landscape mode, as wider aspect ratios will automatically benefit from a wider horizontal FOV.
|
||||
}
|
||||
|
||||
enum ProjectionType {
|
||||
PERSPECTIVE = 0, ## Perspective projection. Objects on the screen becomes smaller when they are far away.
|
||||
ORTHOGONAL = 1, ## Orthogonal projection, also known as orthographic projection. Objects remain the same size on the screen no matter how far away they are.
|
||||
FRUSTUM = 2, ## Frustum projection. This mode allows adjusting frustum_offset to create "tilted frustum" effects.
|
||||
}
|
||||
|
||||
## Overrides [member Camera3D.keep_aspect].
|
||||
@export var keep_aspect: KeepAspect = KeepAspect.KEEP_HEIGHT:
|
||||
set(value):
|
||||
keep_aspect = value
|
||||
emit_changed()
|
||||
get:
|
||||
return keep_aspect
|
||||
|
||||
## Overrides [member Camera3D.cull_mask].
|
||||
@export_flags_3d_render var cull_mask: int = 1048575:
|
||||
set(value):
|
||||
cull_mask = value
|
||||
emit_changed()
|
||||
get:
|
||||
return cull_mask
|
||||
|
||||
## Overrides [member Camera3D.h_offset].
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater", "or_less", "hide_slider", "suffix:m") var h_offset: float = 0.0:
|
||||
set(value):
|
||||
h_offset = value
|
||||
emit_changed()
|
||||
get:
|
||||
return h_offset
|
||||
|
||||
## Overrides [member Camera3D.v_offset].
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater", "or_less", "hide_slider", "suffix:m") var v_offset: float = 0.0:
|
||||
set(value):
|
||||
v_offset = value
|
||||
emit_changed()
|
||||
|
||||
## Overrides [member Camera3D.projection].
|
||||
@export var projection: ProjectionType = ProjectionType.PERSPECTIVE:
|
||||
set(value):
|
||||
projection = value
|
||||
notify_property_list_changed()
|
||||
emit_changed()
|
||||
get:
|
||||
return projection
|
||||
|
||||
## Overrides [member Camera3D.fov].
|
||||
@export_range(1.0, 179.0, 0.1, "degrees") var fov: float = 75.0:
|
||||
set(value):
|
||||
fov = value
|
||||
emit_changed()
|
||||
get:
|
||||
return fov
|
||||
|
||||
## Overrides [member Camera3D.size].
|
||||
@export_range(0.001, 100.0, 0.001, "suffix:m", "or_greater") var size: float = 1.0:
|
||||
set(value):
|
||||
size = value
|
||||
emit_changed()
|
||||
get:
|
||||
return size
|
||||
|
||||
## Overrides [member Camera3d.frustum_offset].
|
||||
@export var frustum_offset: Vector2 = Vector2.ZERO:
|
||||
set(value):
|
||||
frustum_offset = value
|
||||
emit_changed()
|
||||
get:
|
||||
return frustum_offset
|
||||
|
||||
## Overrides [member Camera3D.near].
|
||||
@export_range(0.001, 10.0, 0.001, "suffix:m", "or_greater") var near: float = 0.05:
|
||||
set(value):
|
||||
near = value
|
||||
emit_changed()
|
||||
get:
|
||||
return near
|
||||
|
||||
## Overrides [member Camera3D.far].
|
||||
@export_range(0.01, 4000.0, 0.001, "suffix:m","or_greater") var far: float = 4000.0:
|
||||
set(value):
|
||||
far = value
|
||||
emit_changed()
|
||||
get:
|
||||
return far
|
||||
|
||||
|
||||
func _validate_property(property: Dictionary) -> void:
|
||||
if property.name == "fov" and not projection == ProjectionType.PERSPECTIVE:
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
|
||||
if property.name == "size" and projection == ProjectionType.PERSPECTIVE:
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
|
||||
if property.name == "frustum_offset" and not projection == ProjectionType.FRUSTUM:
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
@@ -0,0 +1 @@
|
||||
uid://bc2tn187qiatpcheck
|
||||
@@ -0,0 +1,228 @@
|
||||
@tool
|
||||
@icon("res://addons/phantom_camera/icons/phantom_camera_noise_resource.svg")
|
||||
class_name PhantomCameraNoise2D
|
||||
extends Resource
|
||||
|
||||
## A resource type used to apply noise, or shake, to [Camera2D]s that have a [PhantomCameraHost] as a child.
|
||||
##
|
||||
## Is a resource type that defines, calculates and outputs the noise values to a [Camera2D] through active
|
||||
## [PhantomCamera3D].[br]
|
||||
## It can be applied to either [PhantomCameraNoiseEmitter2D] or a [PhantomCamera2D] noise property directly
|
||||
|
||||
#region Exported Properties
|
||||
|
||||
## Defines the size of the noise pattern.[br]
|
||||
## Higher values will increase the range the noise can reach.
|
||||
@export_range(0.0, 1000.0, 0.001, "or_greater") var amplitude: float = 10.0:
|
||||
set = set_amplitude,
|
||||
get = get_amplitude
|
||||
|
||||
## Sets the density of the noise pattern.[br]
|
||||
## Higher values will result in more erratic noise.
|
||||
@export_range(0.0, 10.0, 0.001, "or_greater") var frequency: float = 0.5:
|
||||
set = set_frequency,
|
||||
get = get_frequency
|
||||
|
||||
## If true, randomizes the noise pattern every time the noise is run.[br]
|
||||
## If disabled, [member seed] can be used to define a fixed noise pattern.
|
||||
@export var randomize_noise_seed: bool = true:
|
||||
set = set_randomize_noise_seed,
|
||||
get = get_randomize_noise_seed
|
||||
|
||||
## Sets a predetermined seed noise value.[br]
|
||||
## Useful if wanting to achieve a persistent noise pattern every time the noise is emitted.
|
||||
@export var noise_seed: int = 0:
|
||||
set = set_noise_seed,
|
||||
get = get_noise_seed
|
||||
|
||||
## Enables noise changes to the [member Camera2D.offset] position.
|
||||
@export var positional_noise: bool = true:
|
||||
set = set_positional_noise,
|
||||
get = get_positional_noise
|
||||
|
||||
## Enables noise changes to the [Camera2D]'s rotation.
|
||||
@export var rotational_noise: bool = false:
|
||||
set = set_rotational_noise,
|
||||
get = get_rotational_noise
|
||||
|
||||
@export_group("Positional Multiplier")
|
||||
## Multiplies positional noise amount in the X-axis.[br]
|
||||
## Set the value to [param 0] to disable noise in the axis.
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater") var positional_multiplier_x: float = 1.0:
|
||||
set = set_positional_multiplier_x,
|
||||
get = get_positional_multiplier_x
|
||||
|
||||
## Multiplies positional noise amount in the Y-axis.[br]
|
||||
## Set the value to [param 0] to disable noise in the axis.
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater") var positional_multiplier_y: float = 1.0:
|
||||
set = set_positional_multiplier_y,
|
||||
get = get_positional_multiplier_y
|
||||
|
||||
@export_group("Rotational Multiplier")
|
||||
## Multiplies rotational noise amount.
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater") var rotational_multiplier: float = 1.0:
|
||||
set = set_rotational_multiplier,
|
||||
get = get_rotational_multiplier
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Variables
|
||||
|
||||
var _noise_algorithm: FastNoiseLite = FastNoiseLite.new()
|
||||
|
||||
var _noise_positional_multiplier: Vector2 = Vector2(
|
||||
positional_multiplier_x,
|
||||
positional_multiplier_y
|
||||
)
|
||||
|
||||
var _trauma: float = 0.0:
|
||||
set(value):
|
||||
_trauma = value
|
||||
|
||||
var _noise_time: float = 0.0
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Functions
|
||||
|
||||
func _init():
|
||||
_noise_algorithm.noise_type = FastNoiseLite.TYPE_PERLIN
|
||||
if randomize_noise_seed: _noise_algorithm.seed = randi()
|
||||
_noise_algorithm.frequency = frequency
|
||||
|
||||
|
||||
func _validate_property(property: Dictionary) -> void:
|
||||
if randomize_noise_seed and property.name == "noise_seed":
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
|
||||
if not rotational_noise and property.name == "rotational_multiplier":
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
|
||||
if not positional_noise:
|
||||
match property.name:
|
||||
"positional_multiplier_x", \
|
||||
"positional_multiplier_y":
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
|
||||
|
||||
func _get_noise_from_seed(noise_seed: int) -> float:
|
||||
return _noise_algorithm.get_noise_2d(noise_seed, _noise_time) * amplitude
|
||||
|
||||
|
||||
func set_trauma(value: float) -> void:
|
||||
_trauma = value
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
|
||||
func get_noise_transform(delta: float) -> Transform2D:
|
||||
var output_position: Vector2 = Vector2.ZERO
|
||||
var output_rotation: float = 0.0
|
||||
_noise_time += delta
|
||||
_trauma = maxf(_trauma, 0.0)
|
||||
|
||||
if positional_noise:
|
||||
for i in 2:
|
||||
output_position[i] = _noise_positional_multiplier[i] * pow(_trauma, 2.0) * _get_noise_from_seed(i + noise_seed)
|
||||
if rotational_noise:
|
||||
output_rotation = rotational_multiplier / 100 * pow(_trauma, 2.0) * _get_noise_from_seed(noise_seed)
|
||||
|
||||
return Transform2D(output_rotation, output_position)
|
||||
|
||||
|
||||
func reset_noise_time() -> void:
|
||||
_noise_time = 0.0
|
||||
|
||||
#endregion
|
||||
|
||||
#region Setters & Getters
|
||||
|
||||
## Sets the [member amplitude] value.
|
||||
func set_amplitude(value: float) -> void:
|
||||
amplitude =value
|
||||
|
||||
## Returns the [member amplitude] value.
|
||||
func get_amplitude() -> float:
|
||||
return amplitude
|
||||
|
||||
|
||||
## Sets the [member frequency] value.
|
||||
func set_frequency(value: float) -> void:
|
||||
frequency = value
|
||||
_noise_algorithm.frequency = value
|
||||
|
||||
## Returns the [member frequency] value.
|
||||
func get_frequency() -> float:
|
||||
return frequency
|
||||
|
||||
|
||||
## Sets the [member randomize_seed] value.
|
||||
func set_randomize_noise_seed(value: bool) -> void:
|
||||
randomize_noise_seed = value
|
||||
if value: _noise_algorithm.seed = randi()
|
||||
notify_property_list_changed()
|
||||
|
||||
## Returns the [member randomize_seed] value.
|
||||
func get_randomize_noise_seed() -> bool:
|
||||
return randomize_noise_seed
|
||||
|
||||
|
||||
## Sets the [member randomize_seed] value.
|
||||
func set_noise_seed(value: int) -> void:
|
||||
noise_seed = value
|
||||
|
||||
## Returns the [member seed] value.
|
||||
func get_noise_seed() -> int:
|
||||
return noise_seed
|
||||
|
||||
|
||||
## Sets the [member positional_noise] value.
|
||||
func set_positional_noise(value: bool) -> void:
|
||||
positional_noise = value
|
||||
notify_property_list_changed()
|
||||
|
||||
## Returns the [member positional_noise] value.
|
||||
func get_positional_noise() -> bool:
|
||||
return positional_noise
|
||||
|
||||
|
||||
## Sets the [member rotational_noise] value.
|
||||
func set_rotational_noise(value: bool) -> void:
|
||||
rotational_noise = value
|
||||
notify_property_list_changed()
|
||||
|
||||
## Returns the [member rotational_noise] value.
|
||||
func get_rotational_noise() -> bool:
|
||||
return rotational_noise
|
||||
|
||||
|
||||
## Sets the [member positional_multiplier_x] value.
|
||||
func set_positional_multiplier_x(value: float) -> void:
|
||||
positional_multiplier_x = value
|
||||
_noise_positional_multiplier.x = value
|
||||
|
||||
## Returns the [member positional_multiplier_x] value.
|
||||
func get_positional_multiplier_x() -> float:
|
||||
return positional_multiplier_x
|
||||
|
||||
|
||||
## Sets the [member positional_multiplier_y] value.
|
||||
func set_positional_multiplier_y(value: float) -> void:
|
||||
positional_multiplier_y = value
|
||||
_noise_positional_multiplier.y = value
|
||||
|
||||
## Returns the [member positional_multiplier_y] value.
|
||||
func get_positional_multiplier_y() -> float:
|
||||
return positional_multiplier_y
|
||||
|
||||
|
||||
## Sets the [member rotational_multiplier] value.
|
||||
func set_rotational_multiplier(value: float) -> void:
|
||||
rotational_multiplier = value
|
||||
|
||||
## Returns the [member rotational_multiplier] value.
|
||||
func get_rotational_multiplier() -> float:
|
||||
return rotational_multiplier
|
||||
|
||||
#endregion
|
||||
@@ -0,0 +1 @@
|
||||
uid://dimvdouy8g0sv
|
||||
@@ -0,0 +1,301 @@
|
||||
@tool
|
||||
@icon("res://addons/phantom_camera/icons/phantom_camera_noise_resource.svg")
|
||||
class_name PhantomCameraNoise3D
|
||||
extends Resource
|
||||
|
||||
## A resource type used to apply noise, or shake, to [Camera3D]s that have a [PhantomCameraHost] as a child.
|
||||
##
|
||||
## Is a resource type that defines, calculates and outputs the noise values to a [Camera3D] through active
|
||||
## [PhantomCamera3D].[br]
|
||||
## It can be applied to either [PhantomCameraNoiseEmitter3D] or a [PhantomCamera3D] noise property directly
|
||||
|
||||
#region Exported Properties
|
||||
|
||||
## Defines the size of the noise pattern.[br]
|
||||
## Higher values will increase the range the noise can reach.
|
||||
@export_range(0.0, 100.0, 0.001, "or_greater") var amplitude: float = 10.0:
|
||||
set = set_amplitude,
|
||||
get = get_amplitude
|
||||
|
||||
## Sets the density of the noise pattern.[br]
|
||||
## Higher values will result in more erratic noise.
|
||||
@export_range(0.0, 10.0, 0.001, "or_greater") var frequency: float = 0.2:
|
||||
set = set_frequency,
|
||||
get = get_frequency
|
||||
|
||||
## If true, randomizes the noise pattern every time the noise is run.[br]
|
||||
## If disabled, [member seed] can be used to define a fixed noise pattern.
|
||||
@export var randomize_noise_seed: bool = true:
|
||||
set = set_randomize_noise_seed,
|
||||
get = get_randomize_noise_seed
|
||||
|
||||
## Sets a predetermined seed noise value.[br]
|
||||
## Useful if wanting to achieve a persistent noise pattern every time the noise is emitted.
|
||||
@export var noise_seed: int = 0:
|
||||
set = set_noise_seed,
|
||||
get = get_noise_seed
|
||||
|
||||
## Enables noise changes to the [Camera3D]'s rotation.
|
||||
@export var rotational_noise: bool = true:
|
||||
set = set_rotational_noise,
|
||||
get = get_rotational_noise
|
||||
|
||||
## Enables noise changes to the camera's position.[br][br]
|
||||
## [b]Important[/b][br]This can cause geometry clipping if the camera gets too close while this is active.
|
||||
@export var positional_noise: bool = false:
|
||||
set = set_positional_noise,
|
||||
get = get_positional_noise
|
||||
|
||||
@export_group("Rotational Multiplier")
|
||||
## Multiplies rotational noise amount in the X-axis.[br]
|
||||
## Set the value to [param 0] to disable noise in the axis.
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater") var rotational_multiplier_x: float = 1.0:
|
||||
set = set_rotational_multiplier_x,
|
||||
get = get_rotational_multiplier_x
|
||||
|
||||
## Multiplies rotational noise amount in the Y-axis.[br]
|
||||
## Set the value to [param 0] to disable noise in the axis.
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater") var rotational_multiplier_y: float = 1.0:
|
||||
set = set_rotational_multiplier_y,
|
||||
get = get_rotational_multiplier_y
|
||||
|
||||
## Multiplies rotational noise amount in the Z-axis.[br]
|
||||
## Set the value to [param 0] to disable noise in the axis.
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater") var rotational_multiplier_z: float = 1.0:
|
||||
set = set_rotational_multiplier_z,
|
||||
get = get_rotational_multiplier_z
|
||||
|
||||
@export_group("Positional Multiplier")
|
||||
## Multiplies positional noise amount in the X-axis.[br]
|
||||
## Set the value to [param 0] to disable noise in the axis.[br]
|
||||
## [b]Note:[/b] Rotational Offset is recommended to avoid potential camera clipping with the environment.
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater") var positional_multiplier_x: float = 1.0:
|
||||
set = set_positional_multiplier_x,
|
||||
get = get_positional_multiplier_x
|
||||
|
||||
## Multiplies positional noise amount in the Y-axis.[br]
|
||||
## Set the value to [param 0] to disable noise in the axis.[br]
|
||||
## [b]Note:[/b] Rotational Offset is recommended to avoid potential camera clipping with the environment.
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater") var positional_multiplier_y: float = 1.0:
|
||||
set = set_positional_multiplier_y,
|
||||
get = get_positional_multiplier_y
|
||||
|
||||
## Multiplies positional noise amount in the Z-axis.[br]
|
||||
## Set the value to [param 0] to disable noise in the axis.[br]
|
||||
## [b]Note:[/b] Rotational Offset is recommended to avoid potential camera clipping with the environment.
|
||||
@export_range(0.0, 1.0, 0.001, "or_greater") var positional_multiplier_z: float = 1.0:
|
||||
set = set_positional_multiplier_z,
|
||||
get = get_positional_multiplier_z
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Variables
|
||||
|
||||
var _noise_algorithm: FastNoiseLite = FastNoiseLite.new()
|
||||
|
||||
var _noise_rotational_multiplier: Vector3 = Vector3(
|
||||
rotational_multiplier_x,
|
||||
rotational_multiplier_y,
|
||||
rotational_multiplier_z,
|
||||
)
|
||||
|
||||
var _noise_positional_multiplier: Vector3 = Vector3(
|
||||
positional_multiplier_x,
|
||||
positional_multiplier_y,
|
||||
positional_multiplier_z,
|
||||
)
|
||||
|
||||
var _trauma: float = 0.0:
|
||||
set(value):
|
||||
_trauma = value
|
||||
if _trauma == 0.0:
|
||||
_noise_time = 0.0
|
||||
|
||||
var _noise_time: float = 0.0
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Functions
|
||||
|
||||
func _init():
|
||||
_noise_algorithm.noise_type = FastNoiseLite.TYPE_PERLIN
|
||||
|
||||
if randomize_noise_seed: _noise_algorithm.seed = randi()
|
||||
_noise_algorithm.frequency = frequency
|
||||
|
||||
|
||||
func _validate_property(property: Dictionary) -> void:
|
||||
if randomize_noise_seed and property.name == "noise_seed":
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
|
||||
if not rotational_noise:
|
||||
match property.name:
|
||||
"rotational_multiplier_x", \
|
||||
"rotational_multiplier_y", \
|
||||
"rotational_multiplier_z":
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
|
||||
if not positional_noise:
|
||||
match property.name:
|
||||
"positional_multiplier_x", \
|
||||
"positional_multiplier_y", \
|
||||
"positional_multiplier_z":
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
|
||||
|
||||
func _get_noise_from_seed(noise_seed: int) -> float:
|
||||
return _noise_algorithm.get_noise_2d(noise_seed, _noise_time) * amplitude
|
||||
|
||||
|
||||
func set_trauma(value: float) -> void:
|
||||
_trauma = value
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Functions
|
||||
|
||||
func get_noise_transform(delta: float) -> Transform3D:
|
||||
var output_rotation: Vector3 = Vector3.ZERO
|
||||
var output_position: Vector3 = Vector3.ZERO
|
||||
_noise_time += delta
|
||||
_trauma = maxf(_trauma, 0.0)
|
||||
|
||||
for i in 3:
|
||||
if rotational_noise:
|
||||
output_rotation[i] = deg_to_rad(
|
||||
_noise_rotational_multiplier[i] * pow(_trauma, 2.0) * _get_noise_from_seed(i + noise_seed)
|
||||
)
|
||||
|
||||
if positional_noise:
|
||||
output_position[i] += _noise_positional_multiplier[i] / 10 * \
|
||||
pow(_trauma, 2.0) * _get_noise_from_seed(i + noise_seed)
|
||||
|
||||
return Transform3D(Quaternion.from_euler(output_rotation), output_position)
|
||||
|
||||
|
||||
func reset_noise_time() -> void:
|
||||
_noise_time = 0.0
|
||||
|
||||
#endregion
|
||||
|
||||
#region Setters & Getters
|
||||
|
||||
## Sets the [member amplitude] value.
|
||||
func set_amplitude(value: float) -> void:
|
||||
amplitude =value
|
||||
|
||||
## Returns the [member amplitude] value.
|
||||
func get_amplitude() -> float:
|
||||
return amplitude
|
||||
|
||||
|
||||
## Sets the [member frequency] value.
|
||||
func set_frequency(value: float) -> void:
|
||||
frequency = value
|
||||
_noise_algorithm.frequency = value
|
||||
|
||||
## Returns the [member frequency] value.
|
||||
func get_frequency() -> float:
|
||||
return frequency
|
||||
|
||||
|
||||
## Sets the [member randomize_seed] value.
|
||||
func set_randomize_noise_seed(value: bool) -> void:
|
||||
randomize_noise_seed = value
|
||||
if value: _noise_algorithm.seed = randi()
|
||||
notify_property_list_changed()
|
||||
|
||||
## Returns the [member randomize_seed] value.
|
||||
func get_randomize_noise_seed() -> bool:
|
||||
return randomize_noise_seed
|
||||
|
||||
|
||||
## Sets the [member randomize_seed] value.
|
||||
func set_noise_seed(value: int) -> void:
|
||||
noise_seed = value
|
||||
|
||||
## Returns the [member seed] value.
|
||||
func get_noise_seed() -> int:
|
||||
return noise_seed
|
||||
|
||||
|
||||
## Sets the [member positional_noise] value.
|
||||
func set_positional_noise(value: bool) -> void:
|
||||
positional_noise = value
|
||||
notify_property_list_changed()
|
||||
|
||||
## Returns the [member positional_noise] value.
|
||||
func get_positional_noise() -> bool:
|
||||
return positional_noise
|
||||
|
||||
|
||||
## Sets the [member rotational_noise] value.
|
||||
func set_rotational_noise(value: bool) -> void:
|
||||
rotational_noise = value
|
||||
notify_property_list_changed()
|
||||
|
||||
## Returns the [member rotational_noise] value.
|
||||
func get_rotational_noise() -> bool:
|
||||
return rotational_noise
|
||||
|
||||
|
||||
## Sets the [member positional_multiplier_x] value.
|
||||
func set_positional_multiplier_x(value: float) -> void:
|
||||
positional_multiplier_x = value
|
||||
_noise_positional_multiplier.x = value
|
||||
|
||||
## Returns the [member positional_multiplier_x] value.
|
||||
func get_positional_multiplier_x() -> float:
|
||||
return positional_multiplier_x
|
||||
|
||||
|
||||
## Sets the [member positional_multiplier_y] value.
|
||||
func set_positional_multiplier_y(value: float) -> void:
|
||||
positional_multiplier_y = value
|
||||
_noise_positional_multiplier.y = value
|
||||
|
||||
## Returns the [member positional_multiplier_y] value.
|
||||
func get_positional_multiplier_y() -> float:
|
||||
return positional_multiplier_y
|
||||
|
||||
|
||||
## Sets the [member positional_multiplier_z] value.
|
||||
func set_positional_multiplier_z(value: float) -> void:
|
||||
positional_multiplier_z = value
|
||||
_noise_positional_multiplier.z = value
|
||||
|
||||
## Returns the [member positional_multiplier_z] value.
|
||||
func get_positional_multiplier_z() -> float:
|
||||
return positional_multiplier_z
|
||||
|
||||
|
||||
## Sets the [member rotational_multiplier_x] value.
|
||||
func set_rotational_multiplier_x(value: float) -> void:
|
||||
rotational_multiplier_x = value
|
||||
_noise_rotational_multiplier.x = value
|
||||
|
||||
## Returns the [member rotational_multiplier_x] value.
|
||||
func get_rotational_multiplier_x() -> float:
|
||||
return rotational_multiplier_x
|
||||
|
||||
|
||||
## Sets the [member rotational_multiplier_y] value.
|
||||
func set_rotational_multiplier_y(value: float) -> void:
|
||||
rotational_multiplier_y = value
|
||||
_noise_rotational_multiplier.y = value
|
||||
|
||||
## Returns the [member rotational_multiplier_y] value.
|
||||
func get_rotational_multiplier_y() -> float:
|
||||
return rotational_multiplier_y
|
||||
|
||||
|
||||
## Sets the [member rotational_multiplier_z] value.
|
||||
func set_rotational_multiplier_z(value: float) -> void:
|
||||
rotational_multiplier_z = value
|
||||
_noise_rotational_multiplier.z = value
|
||||
|
||||
## Returns the [member rotational_multiplier_z] value.
|
||||
func get_rotational_multiplier_z() -> float:
|
||||
return rotational_multiplier_z
|
||||
|
||||
#endregion
|
||||
@@ -0,0 +1 @@
|
||||
uid://cuffvge5ad4aa
|
||||
@@ -0,0 +1,155 @@
|
||||
@tool
|
||||
@icon("res://addons/phantom_camera/icons/phantom_camera_tween_director_resource.svg")
|
||||
class_name TweenDirectorResource
|
||||
extends Resource
|
||||
|
||||
## Resource to conditionally override tweens between specific [param PhantomCameras].
|
||||
##
|
||||
## [param TweenDirectorResource] allows for overriding the [PhantomCameraTween] applied to [param PhantomCameras]
|
||||
## based on a list of [b]To[/b] and [b]From[/b] targets.[br][br]
|
||||
## The targets are defined by either individually selected [param PhantomCameras] in the current scene,
|
||||
## or by the [PhantomCameraTween] resource applied to them.
|
||||
|
||||
#region Enums
|
||||
|
||||
enum Type {
|
||||
PHANTOM_CAMERA = 0, ## Target individual [param PhantomCameras] from the current current scene.
|
||||
TWEEN_RESOURCE = 1, ## Target [param PhantomCameras] based on the [PhantomCameraTween] resource applied to them.[br][color=3AB99A]Note:[/color] The resources [b]must[/b] be saved on the filesystem and applied to [param PhantomCameras] in order to be referenced.
|
||||
ANY = 2, ## Target all [param PhantomCameras] in the scene.
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Public Variables
|
||||
|
||||
## The [PhantomCameraTween] that should be used if a member of [member from_type] and [member to_type] list match when a tween should occur.
|
||||
@export var tween_resource: PhantomCameraTween = null:
|
||||
set = set_tween_resource,
|
||||
get = get_tween_resource
|
||||
|
||||
|
||||
@export_group("From")
|
||||
## The type identifier for the [b]from[/b], or currently active, [param PhantomCamera] that should make the [member tween_resource] override
|
||||
## the tween defined in the [param To] section.
|
||||
@export var from_type: Type = Type.PHANTOM_CAMERA:
|
||||
set = set_from_type,
|
||||
get = get_from_type
|
||||
|
||||
## The list of [param PhantomCameras] that should trigger the [member tween_resource] override when tweened [b]from[/b].
|
||||
@export_node_path("PhantomCamera2D", "PhantomCamera3D") var from_phantom_cameras: Array[NodePath] = []:
|
||||
set = set_from_phantom_cameras,
|
||||
get = get_from_phantom_cameras
|
||||
|
||||
## The list of [param PhantomCameras] with the [PhantomCameraTween] resources applied to them that should trigger the
|
||||
## [member tween_resource] override when tweened [b]from[/b].[br]
|
||||
## [color=3AB99A][b]Important:[/b][/color] The tween resources on the list [b]must[/b] be saved on the filestyle.
|
||||
@export var from_tween_resources: Array[PhantomCameraTween] = []:
|
||||
set = set_from_tween_resources,
|
||||
get = get_from_tween_resources
|
||||
|
||||
@export_group("To")
|
||||
## The type identifier for the [b]to[/b], or about-to-become-active, [param PhantomCamera] that should make the [member tween_resource] override
|
||||
## the tween defined in the [param To] section.
|
||||
@export var to_type: Type = Type.PHANTOM_CAMERA:
|
||||
set = set_to_type,
|
||||
get = get_to_type
|
||||
|
||||
## The list of [param PhantomCamera] nodes that should trigger the [member tween_resource] override when tweened [b]to[/b].
|
||||
@export_node_path("PhantomCamera2D", "PhantomCamera3D") var to_phantom_cameras: Array[NodePath] = []:
|
||||
set = set_to_phantom_cameras,
|
||||
get = get_to_phantom_cameras
|
||||
|
||||
## The list of [param PhantomCameras] with the [PhantomCameraTween] resources applied to them that should trigger the
|
||||
## [member tween_resource] override when tweened [b]to[/b].[br]
|
||||
## [color=3AB99A][b]Important:[/b][/color] The tween resources on the list [b]must[/b] be saved on the filestyle.
|
||||
@export var to_tween_resources: Array[PhantomCameraTween] = []:
|
||||
set = set_to_tween_resources,
|
||||
get = get_to_tween_resources
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Private Functions
|
||||
|
||||
func _validate_property(property: Dictionary) -> void:
|
||||
if property.name == "from_phantom_cameras" and from_type != Type.PHANTOM_CAMERA:
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
if property.name == "from_tween_resources" and from_type != Type.TWEEN_RESOURCE:
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
|
||||
if property.name == "to_phantom_cameras" and to_type != Type.PHANTOM_CAMERA:
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
if property.name == "to_tween_resources" and to_type != Type.TWEEN_RESOURCE:
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Public Functions
|
||||
|
||||
## Sets the [member tween_resource] value.
|
||||
func set_tween_resource(value: PhantomCameraTween) -> void:
|
||||
tween_resource = value
|
||||
|
||||
## Returns the [member tween_resource] value.
|
||||
func get_tween_resource() -> PhantomCameraTween:
|
||||
return tween_resource
|
||||
|
||||
|
||||
## Sets the [member from_type] value.
|
||||
func set_from_type(value: Type) -> void:
|
||||
from_type = value
|
||||
notify_property_list_changed()
|
||||
|
||||
## Returns the [member from_type] value.
|
||||
func get_from_type() -> Type:
|
||||
return from_type
|
||||
|
||||
|
||||
## Sets the [member from_phantom_cameras] value.
|
||||
func set_from_phantom_cameras(value: Array[NodePath]) -> void:
|
||||
from_phantom_cameras = value
|
||||
|
||||
## Returns the [member from_type] value.
|
||||
func get_from_phantom_cameras() -> Array[NodePath]:
|
||||
return from_phantom_cameras
|
||||
|
||||
|
||||
## Sets the [member from_tween_resources] value.
|
||||
func set_from_tween_resources(value: Array[PhantomCameraTween]) -> void:
|
||||
from_tween_resources = value
|
||||
|
||||
## Returns the [member from_type] value.
|
||||
func get_from_tween_resources() -> Array[PhantomCameraTween]:
|
||||
return from_tween_resources
|
||||
|
||||
|
||||
## Sets the [member to_type] value.
|
||||
func set_to_type(value: Type) -> void:
|
||||
to_type = value
|
||||
notify_property_list_changed()
|
||||
|
||||
## Returns the [member from_type] value.
|
||||
func get_to_type() -> Type:
|
||||
return to_type
|
||||
|
||||
|
||||
## Sets the [member to_phantom_cameras] value.
|
||||
func set_to_phantom_cameras(value: Array[NodePath]) -> void:
|
||||
to_phantom_cameras = value
|
||||
|
||||
## Returns the [member to_phantom_cameras] value.
|
||||
func get_to_phantom_cameras() -> Array[NodePath]:
|
||||
return to_phantom_cameras
|
||||
|
||||
|
||||
## Sets the [member to_tween_resources] value.
|
||||
func set_to_tween_resources(value: Array[PhantomCameraTween]) -> void:
|
||||
to_tween_resources = value
|
||||
|
||||
## Returns the [member to_tween_resources] value.
|
||||
func get_to_tween_resources() -> Array[PhantomCameraTween]:
|
||||
return to_tween_resources
|
||||
|
||||
#endregion
|
||||
@@ -0,0 +1 @@
|
||||
uid://2au3qse3jc5t
|
||||
@@ -0,0 +1,41 @@
|
||||
@icon("res://addons/phantom_camera/icons/phantom_camera_tween.svg")
|
||||
class_name PhantomCameraTween
|
||||
extends Resource
|
||||
|
||||
## Tweening resource for [PhantomCamera2D] and [PhantomCamera3D].
|
||||
##
|
||||
## Defines how [param PhantomCameras] transition between one another.
|
||||
## Changing the tween values for a given [param PhantomCamera] determines how
|
||||
## transitioning to that instance will look like.
|
||||
|
||||
enum TransitionType {
|
||||
LINEAR = 0, ## The animation is interpolated linearly.
|
||||
SINE = 1, ## The animation is interpolated using a sine function.
|
||||
QUINT = 2, ## The animation is interpolated with a quintic (to the power of 5) function.
|
||||
QUART = 3, ## The animation is interpolated with a quartic (to the power of 4) function.
|
||||
QUAD = 4, ## The animation is interpolated with a quadratic (to the power of 2) function.
|
||||
EXPO = 5, ## The animation is interpolated with an exponential (to the power of x) function.
|
||||
ELASTIC = 6, ## The animation is interpolated with elasticity, wiggling around the edges.
|
||||
CUBIC = 7, ## The animation is interpolated with a cubic (to the power of 3) function.
|
||||
CIRC = 8, ## The animation is interpolated with a function using square roots.
|
||||
BOUNCE = 9, ## The animation is interpolated by bouncing at the end.
|
||||
BACK = 10, ## The animation is interpolated backing out at ends.
|
||||
# CUSTOM = 11,
|
||||
# NONE = 12,
|
||||
}
|
||||
|
||||
enum EaseType {
|
||||
EASE_IN = 0, ## The interpolation starts slowly and speeds up towards the end.
|
||||
EASE_OUT = 1, ## The interpolation starts quickly and slows down towards the end.
|
||||
EASE_IN_OUT = 2, ## A combination of EASE_IN and EASE_OUT. The interpolation is slowest at both ends.
|
||||
EASE_OUT_IN = 3, ## A combination of EASE_IN and EASE_OUT. The interpolation is fastest at both ends.
|
||||
}
|
||||
|
||||
## The time it takes to tween to this PhantomCamera in [param seconds].
|
||||
@export var duration: float = 1.0
|
||||
|
||||
## The transition bezier type for the tween. The options are defined in the [enum TransitionType].
|
||||
@export var transition: TransitionType = TransitionType.LINEAR
|
||||
|
||||
## The ease type for the tween. The options are defined in the [enum EaseType].
|
||||
@export var ease: EaseType = EaseType.EASE_IN_OUT
|
||||
@@ -0,0 +1 @@
|
||||
uid://8umksf8e80fw
|
||||
Reference in new issue
Block a user