Empeld
Empeld plugin documentation.
essentials.action.Pathing.Rails.AbstractRail Class Referenceabstract

A rail that consistents of points, with the ability to follow this points More...

Inheritance diagram for essentials.action.Pathing.Rails.AbstractRail:
essentials.action.Pathing.IPathRail essentials.action.Pathing.Rails.LinearRail essentials.action.Pathing.Rails.QuadraticRail

Public Member Functions

 AbstractRail (IEnumerable< Vector3d > path)
 
void Advance (double dst)
 

Protected Member Functions

abstract Vector3d GetPosition (double t)
 

Protected Attributes

readonly Vector3d [] Rail
 

Properties

Vector3d Position [get]
 
Vector3d LookDirection [get]
 
double Time [get, set]
 
double TimeLength [get]
 
bool Done [get]
 
- Properties inherited from essentials.action.Pathing.IPathRail
double Time [get, set]
 
double TimeLength [get]
 
Vector3d Position [get]
 
Vector3d LookDirection [get]
 
bool Done [get]
 

Detailed Description

A rail that consistents of points, with the ability to follow this points

Constructor & Destructor Documentation

◆ AbstractRail()

essentials.action.Pathing.Rails.AbstractRail.AbstractRail ( IEnumerable< Vector3d >  path)

Attribute: 0

;

Attribute: 1] - this.Rail[0

);

Attribute: Rail.Length

;

Attribute: i] = Math.Max( (Rail[i+1] - Rail[i

).Length, 0.01);

Attribute: Rail.Length-1

= 1.0;

56  {
57  this.Rail = path.ToArray();
58  if (this.Rail.Length > 0)
59  {
60  _prevPos = _position = this.Rail [0];
61  _facing = Vector3d.UnitX;
62  }
63  if (this.Rail.Length > 1)
64  {
65  _facing = Vector3d.Normalize(this.Rail[1] - this.Rail[0]);
66  }
67 
68  //Do a little precomp to help us later
69  _railLengths = new double[Rail.Length];
70  for (int i=0; i<Rail.Length-1; ++i)
71  {
72  _railLengths[i] = Math.Max( (Rail[i+1] - Rail[i]).Length, 0.01);
73  }
74  _railLengths[Rail.Length-1] = 1.0;
75  }
float Length
Definition: Vector2i.cs:129
readonly Vector3d [] Rail
Definition: AbstractRail.cs:14

Member Function Documentation

◆ Advance()

void essentials.action.Pathing.Rails.AbstractRail.Advance ( double  dst)

Attribute: (int)_t

;

Implements essentials.action.Pathing.IPathRail.

78  {
79  if (this.Rail.Length <= 1)
80  {
81  return; //Can't do anything
82  }
83 
84  _t += dst / _railLengths [(int)_t];
85  if (_t < 0.0)
86  _t = 0.0;
87  if (_t >= this.Rail.Length - 1)
88  {
89  _t = this.Rail.Length - 1;
90  _done = true;
91  }
92  _position = GetPosition(_t);
93 
94  Vector3d dir = _position - _prevPos;
95  if (dir.LengthFast > 0.01)
96  {
97  _facing = Vector3d.Normalize(dir);
98  _prevPos = _position;
99  }
100  }
abstract Vector3d GetPosition(double t)
readonly Vector3d [] Rail
Definition: AbstractRail.cs:14

◆ GetPosition()

abstract Vector3d essentials.action.Pathing.Rails.AbstractRail.GetPosition ( double  t)
protectedpure virtual

Member Data Documentation

◆ Rail

readonly Vector3d [] essentials.action.Pathing.Rails.AbstractRail.Rail
protected

Property Documentation

◆ Done

bool essentials.action.Pathing.Rails.AbstractRail.Done
get

◆ LookDirection

Vector3d essentials.action.Pathing.Rails.AbstractRail.LookDirection
get

◆ Position

Vector3d essentials.action.Pathing.Rails.AbstractRail.Position
get

◆ Time

double essentials.action.Pathing.Rails.AbstractRail.Time
getset

◆ TimeLength

double essentials.action.Pathing.Rails.AbstractRail.TimeLength
get

The documentation for this class was generated from the following file: