Trail3D
A node to draw lines behind moving objects.
A node to draw lines behind moving objects.
The Trail3D node draws a flat line in space, with an optional billboard mode.
Note: This node is designed for visual effects. For solid lines, pipes, and tubes, use a CsgPolygon3D node in CsgPolygon3D.ModeEnum.Path mode.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
Trail3DConstructor
public Trail3D();Properties15
ColorProperty
public Color Color { get; set; }The color of the trail.
Note: Colors with values above 1.0 (overbright) are not supported.
Note: To have a visible effect on a BaseMaterial3D, BaseMaterial3D.VertexColorUseAsAlbedo must be true. For a ShaderMaterial, ALBEDO *= COLOR.rgb; must be inserted in the shader's fragment() function. Otherwise, Trail3D.Color will have no visible effect.
ColorGradientProperty
public Gradient ColorGradient { get; set; }The color gradient over the trail length.
Note: Colors with values above 1.0 (overbright) are not supported.
Note: To have a visible effect on a BaseMaterial3D, BaseMaterial3D.VertexColorUseAsAlbedo must be true. For a ShaderMaterial, ALBEDO *= COLOR.rgb; must be inserted in the shader's fragment() function. Otherwise, Trail3D.Color will have no visible effect.
EmittingProperty
public bool Emitting { get; set; }If true, the trail will generate new points from its head.
Note: Only one active trail is supported. Setting this property to true will cause the existing trail mesh to be cleared.
LifetimeProperty
public float Lifetime { get; set; }The lifetime of the trail when Trail3D.LimitMode is Trail3D.LimitModeEnum.Lifetime.
LimitModeProperty
public Trail3D.LimitModeEnum LimitMode { get; set; }Whether to limit the trail by lifetime or length.
MaterialProperty
public ShaderMaterial Material { get; set; }The material to assign to the trail mesh when Trail3D.MaterialMode is Line3D.MaterialModeEnum.Custom.
Tip: To preserve billboarding, use the following shader as a base:
shader_type spatial;
render_mode blend_mix, depth_draw_never, unshaded, skip_vertex_transform, cull_disabled;
void vertex() {
// Billboarding code for trails
// CUSTOM0 contains the tangent of the trail and the width.
if (dot(CUSTOM0.xyz, CUSTOM0.xyz) > 0.0) {
vec3 p = (inverse(MODELVIEW_MATRIX) * vec4(0.0, 0.0, 0.0, 1.0)).xyz;
p = VERTEX - p;
vec3 t = CUSTOM0.xyz;
vec3 binormal = normalize(cross(p, t));
vec3 normal = normalize(cross(t, binormal));
vec3 tangent = normalize(cross(binormal, normal));
VERTEX += CUSTOM0.w * binormal;
NORMAL = normal;
TANGENT = tangent;
BINORMAL = binormal;
}
}
void fragment() {
ALBEDO = COLOR.rgb;
ALPHA = COLOR.a;
}MaterialModeProperty
public Line3D.MaterialModeEnum MaterialMode { get; set; }The material mode for the trail.
MaxLengthProperty
public float MaxLength { get; set; }The maximum length of the trail when Trail3D.LimitMode is Trail3D.LimitModeEnum.MaxLength.
MeshAlignmentProperty
public Line3D.MeshAlignmentEnum MeshAlignment { get; set; }Alignment of the trail. Possible options are Line3D.MeshAlignmentEnum.Local for a 3D line, and Line3D.MeshAlignmentEnum.Billboard for a billboarded line.
MinSectionLengthProperty
public float MinSectionLength { get; set; }Minimum required distance before adding a new section.
PinUVProperty
public bool PinUV { get; set; }If true, pins the UVs to their positions in space.
TilingModeProperty
public Line3D.TilingModeEnum TilingMode { get; set; }How to tile the UVs across the length of the trail.
TilingMultiplierProperty
public float TilingMultiplier { get; set; }UV multiplier across the length of the trail.
WidthProperty
public float Width { get; set; }Width of the trail.
WidthCurveProperty
public Curve WidthCurve { get; set; }Width across the length of the trail.
Methods32
Clearvoid
public void Clear();Clears the trail.
GetColorColor
public Color GetColor();ColorGetColorGradientGradient
public Gradient GetColorGradient();GradientGetCurrentLengthfloat
public float GetCurrentLength();Returns the current length of the trail.
floatGetLifetimefloat
public float GetLifetime();floatGetLimitModeTrail3D.LimitModeEnum
public Trail3D.LimitModeEnum GetLimitMode();Trail3D.LimitModeEnumGetMaterialShaderMaterial
public ShaderMaterial GetMaterial();ShaderMaterialGetMaterialModeLine3D.MaterialModeEnum
public Line3D.MaterialModeEnum GetMaterialMode();Line3D.MaterialModeEnumGetMaxLengthfloat
public float GetMaxLength();floatGetMeshAlignmentLine3D.MeshAlignmentEnum
public Line3D.MeshAlignmentEnum GetMeshAlignment();Line3D.MeshAlignmentEnumGetMinSectionLengthfloat
public float GetMinSectionLength();floatGetPinUVbool
public bool GetPinUV();boolGetTilingModeLine3D.TilingModeEnum
public Line3D.TilingModeEnum GetTilingMode();Line3D.TilingModeEnumGetTilingMultiplierfloat
public float GetTilingMultiplier();floatGetWidthfloat
public float GetWidth();floatGetWidthCurveCurve
public Curve GetWidthCurve();CurveIsEmittingbool
public bool IsEmitting();boolSetColorvoid
public void SetColor(Color color);| Name | Type | Default |
|---|---|---|
color | Color | — |
SetColorGradientvoid
public void SetColorGradient(Gradient gradient);| Name | Type | Default |
|---|---|---|
gradient | Gradient | — |
SetEmittingvoid
public void SetEmitting(bool emitting);| Name | Type | Default |
|---|---|---|
emitting | bool | — |
SetLifetimevoid
public void SetLifetime(float lifetime);| Name | Type | Default |
|---|---|---|
lifetime | float | — |
SetLimitModevoid
public void SetLimitMode(Trail3D.LimitModeEnum limitMode);| Name | Type | Default |
|---|---|---|
limitMode | Trail3D.LimitModeEnum | — |
SetMaterialvoid
public void SetMaterial(ShaderMaterial material);| Name | Type | Default |
|---|---|---|
material | ShaderMaterial | — |
SetMaterialModevoid
public void SetMaterialMode(Line3D.MaterialModeEnum materialMode);| Name | Type | Default |
|---|---|---|
materialMode | Line3D.MaterialModeEnum | — |
SetMaxLengthvoid
public void SetMaxLength(float maxLength);| Name | Type | Default |
|---|---|---|
maxLength | float | — |
SetMeshAlignmentvoid
public void SetMeshAlignment(Line3D.MeshAlignmentEnum alignment);| Name | Type | Default |
|---|---|---|
alignment | Line3D.MeshAlignmentEnum | — |
SetMinSectionLengthvoid
public void SetMinSectionLength(float minSectionLength);| Name | Type | Default |
|---|---|---|
minSectionLength | float | — |
SetPinUVvoid
public void SetPinUV(bool pinUV);| Name | Type | Default |
|---|---|---|
pinUV | bool | — |
SetTilingModevoid
public void SetTilingMode(Line3D.TilingModeEnum tilingMode);| Name | Type | Default |
|---|---|---|
tilingMode | Line3D.TilingModeEnum | — |
SetTilingMultipliervoid
public void SetTilingMultiplier(float tilingMultiplier);| Name | Type | Default |
|---|---|---|
tilingMultiplier | float | — |
SetWidthvoid
public void SetWidth(float width);| Name | Type | Default |
|---|---|---|
width | float | — |
SetWidthCurvevoid
public void SetWidthCurve(Curve curve);| Name | Type | Default |
|---|---|---|
curve | Curve | — |
Trail3D.LimitModeEnum
| Value | Description |
|---|---|
Lifetime = 0 | Limit the trail length in time. |
Max = 2 | Represents the size of the |
MaxLength = 1 | Limit the trail length in size. |