# Class: l3dtrail

Contains a collection of points, that are rendered as a quad strip.

## Hierarchy

    o-+ l3dlist
      o-+ l3dnode
        o-+ l3dtrail

## Interfaces:

- matobject
- renderflag
- rendersurface

## Methods:

### Method overview:

- closed
- closestdistance
- closestpoint
- color
- datapointer
- drawlength
- facecamera
- firstpoint
- indexcolor
- indexsize
- localtime
- materialnormalized
- materialscale
- matsurface
- memto_size0
- memto_size1
- memtonext
- memtonormal
- memtopos
- memtovel
- new
- normalizedsize
- planarmap
- planarscale
- recompile
- reset
- size
- spawn
- spawnstep
- spawnworldref
- tpIndex
- tpNormal
- tpNormalarray
- tpPos
- tpPosarray
- tpVel
- tpVelarray
- typelocal
- typeworld
- typeworldref
- uselocaltime
- usevelocity
- velocity
- vertexpointer

new (string name,|l3dlayerid|,int length)
  returns: (trail)
  a new trail system
closed (l3dtrail,[boolean])
  returns: ([boolean])
  sets or returns if trail ends where it starts. The last added point will be skipped and the first is used instead, so add one more point than the ones you really need.
closestdistance (l3dtrail,[float x,y,z])
  returns: ([float dist,trailpoint,float fracc ])
  returns closest line segment and distance to it. The closest point is fracc*(nexttpoint-tpoint). Last frame's state is used.
closestpoint (l3dtrail,[float x,y,z])
  returns: ([float dist,trailpoint])
  returns closest active trailpoint and distance to it. Last frame's state is used.
color (l3dtrail,int step,[float r,g,b,a])
  returns: ([float r,g,b,a])
  sets or returns color interpolater at step. There is 0-2 steps, step 3 or -1 sets all.
datapointer (l3dtrail)
  returns: (pointer start,end)
  returns first and end address of trailpointer array. Operations must be weithin [start,end[. Trailpoints are saved in cyclic array, the first index can be retrieved with firstpoint. Subsequent points are stored after the first and wrapped around trailpoint array. Within this array the size scalers for the trail sides are stored linearly from start to end pointer.
drawlength (l3dtrail,[int])
  returns: ([int])
  sets or return drawlength of trail
facecamera (l3dtrail,[bool])
  returns: ([bool])
  sets or return facecamera flag
firstpoint (l3dtrail)
  returns: ([trailpoint])
  returns first trailpoint
indexcolor (l3dtrail,int step,[float r,g,b,a])
  returns: ([float r,g,b,a])
  sets or returns color at index. There is 0...length-1 steps. The regular color function creates linear interpolated values. This function lets you precisely modify every single value. However if you start using it, the regular color function will be ignored
indexsize (l3dtrail,int step,[float r,g,b,a])
  returns: ([float r,g,b,a])
  sets or returns size at index. There is 0...length-1 steps. The regular size function creates linear interpolated values. This function lets you precisely modify every single value. However if you start using it, the regular size function will be ignored.
localtime (l3dtrail,[int])
  returns: ([int])
  sets or returns trail's own localtime (in ms). Only active when uselocaltime is used.
materialnormalized (l3dtrail,[boolean])
  returns: ([boolean])
  sets or returns if the material/texture is stretched in such a fashion that its width is the length of the trail. If materialscale was applied before uscale will be applied, too.
materialscale (l3dtrail,float length, width)
  returns: ()
  sets how often a material/texture is repeated/minified. length is along x axis
matsurface (l3dtrail,[matsurface])
  returns: ([material/texture])
  sets or returns matsurface
memto_size0 ()
  returns: (int bytes)
  byte offset within tpoint to size scaler (will not belong to the trailpoint, but stored interleaved).
memto_size1 ()
  returns: (int bytes)
  byte offset within tpoint to size scaler (will not belong to the trailpoint, but stored interleaved). Size1 is always multiplied by -1.
memtonext ()
  returns: (int bytes)
  size of the trailpoint structure.
memtonormal ()
  returns: (int bytes)
  byte offset within tpoint to normal (float3, SSE aligned, w can be overwritten)
memtopos ()
  returns: (int bytes)
  byte offset within tpoint to position (float3, SSE aligned, w can be overwritten
memtovel ()
  returns: (int bytes)
  byte offset within tpoint to velocity (float3, SSE aligned, w can be overwritten)
normalizedsize (l3dtrail,[float])
  returns: ([float])
  sets or returns size of an absolute ulength when materialnormalized is used (0 disables).
planarmap (l3dtrail,[int])
  returns: ([int])
  sets or returns planar projection axis. -1 is none/disabled, 0 = x, 1 = y, z = 2. Materials will be projected along these axis.
planarscale (l3dtrail,[float])
  returns: ([float])
  sets or returns planarscale multiplier. texcoord = worldpos.projected * planarscale.
recompile (l3dtrail)
  returns: ()
  tells trail mesh to be recompiled. Useful if mounted arrays modify trail data.
reset (l3dtrail)
  returns: ()
  clears all points
size (l3dtrail,int step,[float size])
  returns: ([float s])
  sets or returns size interpolater at step. There is 0-2 steps, step 3 or -1 sets all.
spawn (l3dtrail,float pos x,y,z,float normal x,y,z,[float vel x,y,z])
  returns: (trailpoint)
  spawns a new point in world/local coordinates, normal is needed when you dont use facecamera, and velocity when you use velocity. You can automaically spawn points with spawnstep. Illegal if typeworldref is used.
spawnstep (l3dtrail,[int])
  returns: (int)
  sets or returns spawnstep in ms, one point will be spawned every spawnstep, if spanwstep is greater 0.
spawnworldref (l3dtrail,actornode/scenenode,int axis)
  returns: (trailpoint)
  spawns a single particle that is autolinked to the given node. Axis is 0(X),1(Y),2(Z) and will mark the axis used for normals. Only works if typeworldref is used.
tpIndex (l3dtrail,trailpoint)
  returns: (int index)
  gets offset within trailpoint memory.
tpNormal (l3dtrail,trailpoint,[float x,y,z])
  returns: ([float x,y,z])
  gets or sets trailpoint's position. Either local or world coordinates, depending on if trail:uselocalpoints is set.
tpNormalarray (l3dtrail,[floatarray 3t])
  returns: ([floatarray 3t])
  sets or returns normal of active trailpoints from floatarray
tpPos (l3dtrail,trailpoint,[float x,y,z])
  returns: ([float x,y,z])
  gets or sets trailpoint's position. Either local or world coordinates, depending on if trail:uselocalpoints is set.
tpPosarray (l3dtrail,[floatarray 3t])
  returns: ([floatarray 3t])
  sets or returns position of active trailpoints from floatarray
tpVel (l3dtrail,trailpoint,[float x,y,z])
  returns: ([float x,y,z])
  gets or sets trailpoint's position. Either local or world coordinates, depending on if trail:uselocalpoints is set.
tpVelarray (l3dtrail,[floatarray 3t])
  returns: ([floatarray 3t])
  sets or returns velocity of active trailpoints from floatarray
typelocal (l3dtrail)
  returns: ()
  local transforms are used on the points, ie points are in local coordinates. You should do this after a new trail, or after resetting. It does not allow spawnstep.
typeworld (l3dtrail)
  returns: ()
  local transforms are not used on the points, ie all points are in world coordinates. You should do this after a new trail, or after resetting. (default)
typeworldref (l3dtrail)
  returns: ()
  points take their world coordinates from linked references. You should do this after a new trail, or after resetting. It does not allow spawnstep.
uselocaltime (l3dtrail,[boolean])
  returns: ([boolean])
  sets or returns if trail uses its own localtime (in ms). If false(default) the global time by luxinia is used. All events such as spawstep, usevelocity and spawntime for manually created tpoints depend on this.
usevelocity (l3dtrail,[boolean])
  returns: ([boolean])
  sets or returns if velocity vector should be added
velocity (l3dtrail,[float x,y,z])
  returns: ([float x,y,z])
  sets or returns velocity vector in local space, units per second.
vertexpointer (l3dtrail)
  returns: (pointer start,end)
  returns first and end address of mesh array. Operations must be weithin [start,end[. The mesh has 2 vertices (vertex32lit) per trailpoint. You can manipulate color and texcoords directly with these pointers.

## Inherited Methods:

### From l3dnode

cambox, camsphere, camvolumedelete, color, delete, isanimateable, lastframe, lightmap, lightmaptexmatrix, linkinterface, localmatrix, localpos, localrotaxis, localrotdeg, localrotquat, localrotrad, name, novistest, parent, parentbone, renderscale, rotationlock, setlayer, unlink, unparentbone, uselocal, uselookat, usemanualworld, visflag, worldmatrix, worldpos, worldrotaxis, worldrotdeg, worldrotquat, worldrotrad

### From l3dlist