BotNavSim  v0.4.3
Mobile Robot Simulation
Draw Class Reference

Draws stuff, useful for displaying debug data in the simulation. Note that GL implementations require that this Monobehaviour be attached to a the rendering camera (OnPostRender event) More...

Inheritance diagram for Draw:
Collaboration diagram for Draw:

Classes

class  CubeData
 
class  LineData
 

Public Member Functions

void Line (Vector3 start, Vector3 end, Color color, Space relativeTo=Space.World)
 Draw a line between two positions, start and end, in a specified color. More...
 
void Bearing (Vector3 origin, Vector3 direction, Color color)
 Draw a line in a direction starting at a specified location, in a specified color. More...
 
void Cube (Vector3 center, Vector3 size, Color color)
 Draw any sized cube at a location in any color. More...
 

Static Public Attributes

static Draw Instance
 Reference to the MonoBehaviour instance. More...
 

Private Member Functions

void Awake ()
 
void Update ()
 
void GLLine (LineData line)
 
void GLCube (CubeData cube)
 
void OnPostRender ()
 Raises the post render event. Use this for GL stuff. More...
 

Private Attributes

Material glLineMaterial
 
List< LineDatagl_lines = new List<LineData>()
 
List< CubeDatagl_cubes = new List<CubeData>()
 

Detailed Description

Draws stuff, useful for displaying debug data in the simulation. Note that GL implementations require that this Monobehaviour be attached to a the rendering camera (OnPostRender event)

Definition at line 10 of file Draw.cs.

Member Function Documentation

void Draw.Awake ( )
private

Definition at line 49 of file Draw.cs.

49  {
50  if (Instance == null){
51  Instance = this;
52  }
53  else {
54  Destroy(this);
55  }
56 
57  glLineMaterial = Resources.Load<Material>("Materials/Line");
58  }
Material glLineMaterial
Definition: Draw.cs:44
static Draw Instance
Reference to the MonoBehaviour instance.
Definition: Draw.cs:39
void Draw.Bearing ( Vector3  origin,
Vector3  direction,
Color  color 
)

Draw a line in a direction starting at a specified location, in a specified color.

Parameters
originOrigin.
directionDirection.
colorColor.

Definition at line 90 of file Draw.cs.

90  {
91  Vector3 end = origin + direction;
92  gl_lines.Add(new LineData(origin, end, color));
93  }
List< LineData > gl_lines
Definition: Draw.cs:45

Here is the caller graph for this function:

void Draw.Cube ( Vector3  center,
Vector3  size,
Color  color 
)

Draw any sized cube at a location in any color.

Parameters
centerCenter.
sizeSize.
colorColor.

Definition at line 101 of file Draw.cs.

101  {
102  //if (Simulation.robot.navigation.spaceRelativeTo == Space.Self) {
103  // center = Simulation.robot.transform.TransformPoint(center);
104  //}
105  gl_cubes.Add(new CubeData(size, center, color));
106  }
List< CubeData > gl_cubes
Definition: Draw.cs:46

Here is the caller graph for this function:

void Draw.GLCube ( CubeData  cube)
private

Definition at line 116 of file Draw.cs.

116  {
117  float w = cube.size.x;
118  float h = cube.size.y;
119  float d = cube.size.z;
120  float x = cube.center.x;
121  float y = cube.center.y;
122  float z = cube.center.z;
123 
124  GL.Color(cube.color);
125 
126  GL.Vertex3(x - w/2f, y - h/2f, z - d/2f); // 4
127  GL.Vertex3(x - w/2f, y - h/2f, z + d/2f); // 1
128  GL.Vertex3(x - w/2f, y + h/2f, z + d/2f); // 2
129  GL.Vertex3(x - w/2f, y + h/2f, z - d/2f); // 3
130 
131  GL.Vertex3(x + w/2f, y - h/2f, z - d/2f); // 5
132  GL.Vertex3(x - w/2f, y - h/2f, z - d/2f); // 4
133  GL.Vertex3(x - w/2f, y + h/2f, z - d/2f); // 3
134  GL.Vertex3(x + w/2f, y + h/2f, z - d/2f); // 8
135 
136  GL.Vertex3(x + w/2f, y - h/2f, z + d/2f); // 6
137  GL.Vertex3(x + w/2f, y - h/2f, z - d/2f); // 5
138  GL.Vertex3(x + w/2f, y + h/2f, z - d/2f); // 8
139  GL.Vertex3(x + w/2f, y + h/2f, z + d/2f); // 7
140 
141  GL.Vertex3(x - w/2f, y - h/2f, z + d/2f); // 1
142  GL.Vertex3(x + w/2f, y - h/2f, z + d/2f); // 6
143  GL.Vertex3(x + w/2f, y + h/2f, z + d/2f); // 7
144  GL.Vertex3(x - w/2f, y + h/2f, z + d/2f); // 2
145  }

Here is the caller graph for this function:

void Draw.GLLine ( LineData  line)
private

Definition at line 109 of file Draw.cs.

109  {
110  GL.Color(line.color);
111  GL.Vertex(line.start);
112  GL.Vertex(line.end);
113  }

Here is the caller graph for this function:

void Draw.Line ( Vector3  start,
Vector3  end,
Color  color,
Space  relativeTo = Space.World 
)

Draw a line between two positions, start and end, in a specified color.

Parameters
startStart.
endEnd.
colorColor.
relativeToChoose world-space or Robot local-space.

Definition at line 76 of file Draw.cs.

76  {
77  if (relativeTo == Space.Self && Simulation.robot != null) {
78  start = Simulation.robot.transform.TransformPoint(start);
79  end = Simulation.robot.transform.TransformPoint(end);
80  }
81  gl_lines.Add(new LineData(start, end, color));
82  }
static Robot robot
Gets reference to the robot in the current simulation.
Definition: Simulation.cs:273
List< LineData > gl_lines
Definition: Draw.cs:45
This is a manager class used to overlook the running of a simulation.
Definition: Simulation.cs:8

Here is the caller graph for this function:

void Draw.OnPostRender ( )
private

Raises the post render event. Use this for GL stuff.

Definition at line 150 of file Draw.cs.

150  {
151  if (CamController.renderMode == CamController.RenderMode.Normal) return;
152  GL.PushMatrix();
153  glLineMaterial.SetPass(0);
154  GL.Begin(GL.LINES);
155  foreach(LineData line in gl_lines) {
156  GLLine(line);
157  }
158  foreach(CubeData cube in gl_cubes) {
159  GLCube(cube);
160  }
161  GL.End();
162  GL.PopMatrix();
163  gl_lines.Clear();
164  gl_cubes.Clear();
165  }
Material glLineMaterial
Definition: Draw.cs:44
void GLLine(LineData line)
Definition: Draw.cs:109
List< LineData > gl_lines
Definition: Draw.cs:45
void GLCube(CubeData cube)
Definition: Draw.cs:116
Controls the camera orientation and render modes according to ViewMode in viewModeList user input...
List< CubeData > gl_cubes
Definition: Draw.cs:46
static RenderMode renderMode
Gets or sets the RenderMode in use. RenderMode determines which render layers are drawn...

Here is the call graph for this function:

void Draw.Update ( )
private

Definition at line 61 of file Draw.cs.

61  {
62  // clear lists while the camera isn't being rendered
63  if (Camera.current != camera) {
64  gl_lines.Clear();
65  gl_cubes.Clear();
66  }
67  }
List< LineData > gl_lines
Definition: Draw.cs:45
List< CubeData > gl_cubes
Definition: Draw.cs:46

Member Data Documentation

List<CubeData> Draw.gl_cubes = new List<CubeData>()
private

Definition at line 46 of file Draw.cs.

List<LineData> Draw.gl_lines = new List<LineData>()
private

Definition at line 45 of file Draw.cs.

Material Draw.glLineMaterial
private

Definition at line 44 of file Draw.cs.

Draw Draw.Instance
static

Reference to the MonoBehaviour instance.

Definition at line 39 of file Draw.cs.


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