Skip to content
0.2.0-dev Download ZIP
116 lines ·5.9 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="Trail3D" inherits="LineBase3D" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A node to draw lines behind moving objects.
5 </brief_description>
6 <description>
7 The [Trail3D] node draws a flat line in space, with an optional billboard mode.
8 [b]Note:[/b] This node is designed for visual effects. For solid lines, pipes, and tubes, use a [CSGPolygon3D] node in [constant CSGPolygon3D.MODE_PATH] mode.
9 </description>
10 <tutorials>
11 </tutorials>
12 <methods>
13 <method name="clear">
14 <return type="void" />
15 <description>
16 Clears the trail.
17 </description>
18 </method>
19 <method name="get_current_length" qualifiers="const">
20 <return type="float" />
21 <description>
22 Returns the current length of the trail.
23 </description>
24 </method>
25 </methods>
26 <members>
27 <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)">
28 The color of the trail.
29 [b]Note:[/b] Colors with values above [code]1.0[/code] (overbright) are not supported.
30 [b]Note:[/b] To have a visible effect on a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color] will have no visible effect.
31 </member>
32 <member name="color_gradient" type="Gradient" setter="set_color_gradient" getter="get_color_gradient">
33 The color gradient over the trail length.
34 [b]Note:[/b] Colors with values above [code]1.0[/code] (overbright) are not supported.
35 [b]Note:[/b] To have a visible effect on a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color] will have no visible effect.
36 </member>
37 <member name="emitting" type="bool" setter="set_emitting" getter="is_emitting" default="true">
38 If [code]true[/code], the trail will generate new points from its head.
39 [b]Note:[/b] Only one active trail is supported. Setting this property to [code]true[/code] will cause the existing trail mesh to be cleared.
40 </member>
41 <member name="lifetime" type="float" setter="set_lifetime" getter="get_lifetime" default="0.2">
42 The lifetime of the trail when [member limit_mode] is [constant LIMIT_MODE_LIFETIME].
43 </member>
44 <member name="limit_mode" type="int" setter="set_limit_mode" getter="get_limit_mode" enum="Trail3D.LimitMode" default="0">
45 Whether to limit the trail by lifetime or length.
46 </member>
47 <member name="material" type="ShaderMaterial" setter="set_material" getter="get_material">
48 The material to assign to the trail mesh when [member material_mode] is [constant LineBase3D.MATERIAL_MODE_CUSTOM].
49 [b]Tip:[/b] To preserve billboarding, use the following shader as a base:
50 [codeblock]
51 shader_type spatial;
52 render_mode blend_mix, depth_draw_never, unshaded, skip_vertex_transform, cull_disabled;
53
54 void vertex() {
55 // Billboarding code for trails
56 // CUSTOM0 contains the tangent of the trail and the width.
57 if (dot(CUSTOM0.xyz, CUSTOM0.xyz) &gt; 0.0) {
58 vec3 p = (inverse(MODELVIEW_MATRIX) * vec4(0.0, 0.0, 0.0, 1.0)).xyz;
59 p = VERTEX - p;
60 vec3 t = CUSTOM0.xyz;
61 vec3 binormal = normalize(cross(p, t));
62 vec3 normal = normalize(cross(t, binormal));
63 vec3 tangent = normalize(cross(binormal, normal));
64 VERTEX += CUSTOM0.w * binormal;
65 NORMAL = normal;
66 TANGENT = tangent;
67 BINORMAL = binormal;
68 }
69 }
70
71 void fragment() {
72 ALBEDO = COLOR.rgb;
73 ALPHA = COLOR.a;
74 }
75 [/codeblock]
76 </member>
77 <member name="material_mode" type="int" setter="set_material_mode" getter="get_material_mode" enum="LineBase3D.MaterialMode" default="0">
78 The material mode for the trail.
79 </member>
80 <member name="max_length" type="float" setter="set_max_length" getter="get_max_length">
81 The maximum length of the trail when [member limit_mode] is [constant LIMIT_MODE_MAX_LENGTH].
82 </member>
83 <member name="mesh_alignment" type="int" setter="set_mesh_alignment" getter="get_mesh_alignment" enum="LineBase3D.MeshAlignment" default="1">
84 Alignment of the trail. Possible options are [constant LineBase3D.MESH_ALIGNMENT_LOCAL] for a 3D line, and [constant LineBase3D.MESH_ALIGNMENT_BILLBOARD] for a billboarded line.
85 </member>
86 <member name="min_section_length" type="float" setter="set_min_section_length" getter="get_min_section_length" default="0.2">
87 Minimum required distance before adding a new section.
88 </member>
89 <member name="pin_uv" type="bool" setter="set_pin_uv" getter="get_pin_uv" default="false">
90 If [code]true[/code], pins the UVs to their positions in space.
91 </member>
92 <member name="tiling_mode" type="int" setter="set_tiling_mode" getter="get_tiling_mode" enum="LineBase3D.TilingMode" default="1">
93 How to tile the UVs across the length of the trail.
94 </member>
95 <member name="tiling_multiplier" type="float" setter="set_tiling_multiplier" getter="get_tiling_multiplier" default="1.0">
96 UV multiplier across the length of the trail.
97 </member>
98 <member name="width" type="float" setter="set_width" getter="get_width" default="0.3">
99 Width of the trail.
100 </member>
101 <member name="width_curve" type="Curve" setter="set_width_curve" getter="get_width_curve">
102 Width across the length of the trail.
103 </member>
104 </members>
105 <constants>
106 <constant name="LIMIT_MODE_LIFETIME" value="0" enum="LimitMode">
107 Limit the trail length in time.
108 </constant>
109 <constant name="LIMIT_MODE_MAX_LENGTH" value="1" enum="LimitMode">
110 Limit the trail length in size.
111 </constant>
112 <constant name="LIMIT_MODE_MAX" value="2" enum="LimitMode">
113 Represents the size of the [enum LimitMode] enum.
114 </constant>
115 </constants>
116</class>