Splines
Description
The spline actor can be used to create both curves and straight lines. Line color can be set for the entire line, and line width can be set on a per-control point basis. Splines are created by first spawning a spline actor and then adding control points. Depending on the configuration used when spawned, you can get variations on the curve shape or straight lines.
See the Splines Tutorial to get a better understanding of using splines in Quanser Interactive Labs.
Library
Constants
- QLabsSplineLine.ID_SPLINE_LINE = 180
Class ID
- QLabsSplineLine.LINEAR = 0
See configurations
- QLabsSplineLine.CURVE = 1
See configurations
- QLabsSplineLine.CONSTANT = 2
See configurations
- QLabsSplineLine.CLAMPED_CURVE = 3
See configurations
Member Variables
- QLabsSplineLine.actorNumber = None
The current actor number of this class to be addressed. This will be set by spawn methods and cleared by destroy methods. It will not be modified by the destroy all actors. This can be manually altered at any time to use one object to address multiple actors.
Methods
- QLabsSplineLine.set_points(color, pointList, alignEndPointTangents=False, waitForConfirmation=True)[source]
After spawning the origin of the spline actor, this method is used to create the individual points. At least 2 points must be specified to make a line.
- Parameters
color (float array[3]) – Red, Green, Blue components of the RGB color on a 0.0 to 1.0 scale.
pointList (float 2D array[4][n]) – A 2D array with each row containing [x,y,z,width] elements. Width is in m.
alignEndPointTangents (boolean) – (Optional) Sets the tangent of the first and last point to be the same.
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - True if successful, False otherwise
- Return type
boolean
- QLabsSplineLine.circle_from_center(radius, lineWidth=0.1, color=[1, 0, 0], numSplinePoints=8, waitForConfirmation=True)[source]
After spawning the origin of the spline actor, this method is used to create a circle. Configuration 1 is recommended when spawning the line.
- Parameters
radius (float) – Radius in m
lineWidth (float) – Line width in m
color (float array[3]) – Red, Green, Blue components of the RGB color on a 0.0 to 1.0 scale.
numSplinePoints (integer) – The number of points distributed around the circle. Splines will automatically round the edges, but more points will be needed for larger circles to achieve an accurate circle.
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - True if successful, False otherwise
- Return type
boolean
- QLabsSplineLine.arc_from_center(radius, startAngle=0, endAngle=math.pi / 2, lineWidth=1, color=[1, 0, 0], numSplinePoints=8, waitForConfirmation=True)[source]
After spawning the origin of the spline actor, this method is used to create an arc. Configuration 1 is recommended when spawning the line.
- Parameters
radius (float) – Radius in m
startAngle (float) – Angle relative to the spawn orientation in radians
endAngle (float) – Angle relative to the spawn orientation in radians
lineWidth (float) – Line width in m
color (float array[3]) – Red, Green, Blue components of the RGB color on a 0.0 to 1.0 scale.
numSplinePoints (integer) – The number of points distributed around the circle. Splines will automatically round the edges, but more points will be needed for larger circles to achieve an accurate circle.
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - True if successful, False otherwise
- Return type
boolean
- QLabsSplineLine.arc_from_center_degrees(radius, startAngle=0, endAngle=90, lineWidth=1, color=[1, 0, 0], numSplinePoints=4, waitForConfirmation=True)[source]
After spawning the origin of the spline actor, this method is used to create an arc. Configuration 1 is recommended when spawning the line.
- Parameters
radius (float) – Radius in m
startAngle (float) – Angle relative to the spawn orientation in degrees
endAngle (float) – Angle relative to the spawn orientation in degrees
lineWidth (float) – Line width in m
color (float array[3]) – Red, Green, Blue components of the RGB color on a 0.0 to 1.0 scale.
numSplinePoints (integer) – The number of points distributed around the circle. Splines will automatically round the edges, but more points will be needed for larger circles to achieve an accurate circle.
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - True if successful, False otherwise
- Return type
boolean
- QLabsSplineLine.rounded_rectangle_from_center(cornerRadius, xWidth, yLength, lineWidth=0.1, color=[1, 0, 0], waitForConfirmation=True)[source]
After spawning the origin of the spline actor, this method is used to create a rounded rectangle. Configuration 1 is recommended when spawning the line.
- Parameters
cornerRadius (float) – Corner radius in m
xWidth (float) – Dimension in m of the rectangle in the local x axis
yLength (float) – Dimension in m of the rectangle in the local y axis
lineWidth (float) – Line width in m
color (float array[3]) – Red, Green, Blue components of the RGB color on a 0.0 to 1.0 scale.
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - True if successful, False otherwise
- Return type
boolean
Parent Class (actor.py) Methods
- QLabsSplineLine.__init__(qlabs, verbose=False)[source]
Constructor Method
- Parameters
qlabs (object) – A QuanserInteractiveLabs object
verbose (boolean) – (Optional) Print error information to the console.
- QLabsSplineLine.spawn(location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, waitForConfirmation=True)
Spawns a new actor with the next available actor number within this class.
- Parameters
location (float array[3]) – (Optional) An array of floats for x, y and z coordinates
rotation (float array[3]) – (Optional) An array of floats for the roll, pitch, and yaw in radians
scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.
configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred. Note that if this is False, the returned actor number will be invalid.
- Returns
status - 0 if successful, 1 class not available, 3 unknown error, -1 communications error.
actorNumber - An actor number to use for future references.
- Return type
int32, int32
- QLabsSplineLine.spawn_degrees(location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, waitForConfirmation=True)
Spawns a new actor with the next available actor number within this class.
- Parameters
location (float array[3]) – (Optional) An array of floats for x, y and z coordinates
rotation (float array[3]) – (Optional) An array of floats for the roll, pitch, and yaw in degrees
scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.
configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred. Note that if this is False, the returned actor number will be invalid.
- Returns
status - 0 if successful, 1 class not available, 3 unknown error, -1 communications error.
actorNumber - An actor number to use for future references.
- Return type
int32, int32
- QLabsSplineLine.spawn_id(actorNumber, location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, waitForConfirmation=True)
Spawns a new actor.
- Parameters
actorNumber (uint32) – User defined unique identifier for the class actor in QLabs
location (float array[3]) – (Optional) An array of floats for x, y and z coordinates
rotation (float array[3]) – (Optional) An array of floats for the roll, pitch, and yaw in radians
scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.
configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - 0 if successful, 1 class not available, 2 actor number not available or already in use, 3 unknown error, -1 communications error
- Return type
int32
- QLabsSplineLine.spawn_id_degrees(actorNumber, location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, waitForConfirmation=True)
Spawns a new actor.
- Parameters
actorNumber (uint32) – User defined unique identifier for the class actor in QLabs
location (float array[3]) – (Optional) An array of floats for x, y and z coordinates
rotation (float array[3]) – (Optional) An array of floats for the roll, pitch, and yaw in radians
scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.
configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - 0 if successful, 1 class not available, 2 actor number not available or already in use, 3 unknown error, -1 communications error
- Return type
int32
- QLabsSplineLine.spawn_id_and_parent_with_relative_transform(actorNumber, location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, parentClassID=0, parentActorNumber=0, parentComponent=0, waitForConfirmation=True)
Spawns a new actor relative to an existing actor and creates a kinematic relationship.
- Parameters
actorNumber (uint32) – User defined unique identifier for the class actor in QLabs
location (float array[3]) – (Optional) An array of floats for x, y and z coordinates
rotation (float array[3]) – (Optional) An array of floats for the roll, pitch, and yaw in radians
scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.
configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.
parentClassID (uint32) – See the ID variables in the respective library classes for the class identifier
parentActorNumber (uint32) – User defined unique identifier for the class actor in QLabs
parentComponent (uint32) – 0 for the origin of the parent actor, see the parent class for additional reference frame options
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - 0 if successful, 1 class not available, 2 actor number not available or already in use, 3 cannot find the parent actor, 4 unknown error, -1 communications error
- Return type
int32
- QLabsSplineLine.spawn_id_and_parent_with_relative_transform_degrees(actorNumber, location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], configuration=0, parentClassID=0, parentActorNumber=0, parentComponent=0, waitForConfirmation=True)
Spawns a new actor relative to an existing actor and creates a kinematic relationship.
- Parameters
actorNumber (uint32) – User defined unique identifier for the class actor in QLabs
location (float array[3]) – (Optional) An array of floats for x, y and z coordinates
rotation (float array[3]) – (Optional) An array of floats for the roll, pitch, and yaw in degrees
scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.
configuration (uint32) – (Optional) Spawn configuration. See class library for configuration options.
parentClassID (uint32) – See the ID variables in the respective library classes for the class identifier
parentActorNumber (uint32) – User defined unique identifier for the class actor in QLabs
parentComponent (uint32) – 0 for the origin of the parent actor, see the parent class for additional reference frame options
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - 0 if successful, 1 class not available, 2 actor number not available or already in use, 3 cannot find the parent actor, 4 unknown error, -1 communications error
- Return type
int32
- QLabsSplineLine.destroy()
Find and destroy a specific actor. This is a blocking operation.
- Returns
numActorsDestroyed - The number of actors destroyed. -1 if failed.
- Return type
int32
- QLabsSplineLine.destroy_all_actors_of_class()
Find and destroy all actors of this class. This is a blocking operation.
- Returns
numActorsDestroyed - The number of actors destroyed. -1 if failed.
- Return type
int32
- QLabsSplineLine.ping()
Checks if the actor is still present in the environment. Note that if you did not spawn the actor with one of the spawn functions, you may need to manually set the actorNumber member variable.
- Returns
status - True if successful, False otherwise
- Return type
boolean
- QLabsSplineLine.get_world_transform()
Get the location, rotation, and scale in world coordinates of the actor.
- Returns
status - True if successful, False otherwise
location
rotation
scale
- Return type
boolean, float array[3], float array[3], float array[3]
- QLabsSplineLine.get_world_transform_degrees()
Get the location, rotation, and scale in world coordinates of the actor.
- Returns
status - True if successful, False otherwise
location
rotation
scale
- Return type
boolean, float array[3], float array[3], float array[3]
- QLabsSplineLine.parent_with_relative_transform(location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], parentClassID=0, parentActorNumber=0, parentComponent=0, waitForConfirmation=True)
Parents one existing actor to another to create a kinematic relationship.
- Parameters
location (float array[3]) – (Optional) An array of floats for x, y and z coordinates
rotation (float array[3]) – (Optional) An array of floats for the roll, pitch, and yaw in radians
scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.
parentClassID (uint32) – See the ID variables in the respective library classes for the class identifier
parentActorNumber (uint32) – User defined unique identifier for the class actor in QLabs
parentComponent (uint32) – 0 for the origin of the parent actor, see the parent class for additional reference frame options
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - 0 if successful, 1 cannot find this actor, 2 cannot find the parent actor, 3 unknown error, -1 communications error
- Return type
int32
- QLabsSplineLine.parent_with_relative_transform_degrees(location=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], parentClassID=0, parentActorNumber=0, parentComponent=0, waitForConfirmation=True)
Parents one existing actor to another to create a kinematic relationship.
- Parameters
location (float array[3]) – (Optional) An array of floats for x, y and z coordinates
rotation (float array[3]) – (Optional) An array of floats for the roll, pitch, and yaw in degrees
scale (float array[3]) – (Optional) An array of floats for the scale in the x, y, and z directions. Scale values of 0.0 should not be used.
parentClassID (uint32) – (Optional) See the ID variables in the respective library classes for the class identifier
parentActorNumber (uint32) – (Optional) User defined unique identifier for the class actor in QLabs
parentComponent (uint32) – (Optional) 0 for the origin of the parent actor, see the parent class for additional reference frame options
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - 0 if successful, 1 cannot find this actor, 2 cannot find the parent actor, 3 unknown error, -1 communications error
- Return type
int32
- QLabsSplineLine.parent_with_current_world_transform(parentClassID=0, parentActorNumber=0, parentComponent=0, waitForConfirmation=True)
Parents one existing actor to another to create a kinematic relationship while preserving the current world transform of the child actor.
- Parameters
parentClassID (uint32) – See the ID variables in the respective library classes for the class identifier
parentActorNumber (uint32) – User defined unique identifier for the class actor in QLabs
parentComponent (uint32) – 0 for the origin of the parent actor, see the parent class for additional reference frame options
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - 0 if successful, 1 cannot find this actor, 2 cannot find the parent actor, 3 unknown error, -1 communications error
- Return type
int32
- QLabsSplineLine.parent_break(waitForConfirmation=True)
Breaks any relationship with a parent actor (if it exists) and preserves the current world transform
- Parameters
waitForConfirmation (boolean) – (Optional) Make this operation blocking until confirmation of the spawn has occurred.
- Returns
status - 0 if successful, 1 cannot find this actor, -1 communications error
- Return type
int32
Configurations
Configurations 0 to 3 are shown from top to bottom in the above image using the same set of control points.
Configuration |
Mode |
Description |
|---|---|---|
0 |
Linear |
The tangent of the curve at each control point is set to match the tangent of the start of each line segment. |
1 |
Curve |
The tangent of the curve at each control point is an average of the two adjacent line segments and matched to the start and end tangents. |
2 |
Constant |
Straight line segments |
3 |
Clamped Curve |
As angles become more acute, the curve will transition from a smooth change to a sharp point. |
Connection Points
There are no connection points for this actor class.
Splines Tutorial
Python Tutorial
Raw to download this tutorial: Splines Tutorial (.py).
1"""
2Splines Tutorial
3---------------
4
5.. note::
6
7 Make sure you have Quanser Interactive Labs open before running this
8 example. This example is designed to run ONLY in the Plane environment.
9
10"""
11
12# imports to important libraries
13import math
14import time
15
16from qvl.qlabs import QuanserInteractiveLabs
17from qvl.system import QLabsSystem
18from qvl.spline_line import QLabsSplineLine
19from qvl.free_camera import QLabsFreeCamera
20
21
22# Clears the screen in Windows
23
24def main():
25
26 print("\n\n------------------------------ Communications --------------------------------\n")
27
28 # Creates a server connection with Quanser Interactive Labs and manages
29 # the communications
30 qlabs = QuanserInteractiveLabs()
31
32 # Ensure that QLabs is running on your local machine
33 print("Connecting to QLabs...")
34 if (not qlabs.open("localhost")):
35 print("Unable to connect to QLabs")
36 return
37
38 print("Connected")
39
40 # Use hSystem to set the tutorial title in the upper left of the qlabs window
41 hSystem = QLabsSystem(qlabs)
42 hSystem.set_title_string('Splines Tutorial')
43
44 # Create top view camera and go to that view
45 camera = QLabsFreeCamera(qlabs)
46 camera.spawn([5.971, 11.781, 30.704], [0, 1.569, 1.57] )
47 camera.possess()
48
49 height = 0
50 width = 1
51 color = [0,0,0]
52
53 # create splines to create virtual roads of 1m of thickness
54 # Using the same initialization of QLabsSplineLine because the
55 # actors will not have to be referenced again. So overwriting them
56 # once they are spawned is not a problem.
57
58 # In functions (not spawn) that do not have a height value, height needs
59 # to be specified in the spawn function as a Z translation
60 splineRoads = QLabsSplineLine(qlabs)
61 splineRoads.spawn(location=[10,10,height], scale=[1,1,1], configuration=1)
62 splineRoads.rounded_rectangle_from_center(cornerRadius=.5,xWidth=20, yLength=20, lineWidth=width, color=color)
63
64 splineRoads.spawn(location=[0,0,0], scale=[1,1,1], configuration=1)
65 splineRoads.set_points(color=color, pointList=[[0,13.8,height,width],[6,16.8,height,width], [11,12,height,width], [15.5, 14.5, height,width], [20, 11, height,width]], alignEndPointTangents=False)
66
67 splineRoads.spawn(location=[14,4.5,height], scale=[1,1,1], configuration=1)
68 splineRoads.circle_from_center(radius=3, lineWidth=width, color=color, numSplinePoints=8)
69
70 splineRoads.spawn(location=[0,0,0], scale=[1,1,1], configuration=1)
71 splineRoads.set_points(color=color, pointList=[[13.7,13.1,height,width],[14.8,11.8,height,width],[15.5,7.15,height,width]], alignEndPointTangents=False)
72
73 splineRoads.spawn(location=[0,0,0], scale=[1,1,1], configuration=1)
74 splineRoads.set_points(color=color, pointList=[[10.987, 4.199,height,width],[9.399, 6.559, height,width],[3.002, 4.034,height,width],[1.112, 3.004, height,width],[-0.045, 4.465, height,width]], alignEndPointTangents=False)
75
76 splineRoads.spawn(location=[0,0,0], scale=[1,1,1], configuration=1)
77 splineRoads.set_points(color=color, pointList=[[3, 20,height,width],[3, 4, height,width]], alignEndPointTangents=False)
78
79 splineRoads.spawn(location=[0,0,0], scale=[1,1,1], configuration=1)
80 splineRoads.set_points(color=color, pointList=[[8.7, 14.2, height,width],[8.7,0,height,width]], alignEndPointTangents=False)
81
82 splineRoads.spawn(location=[20,20,height], scale=[1,1,1], configuration=1)
83 splineRoads.arc_from_center(radius=5, startAngle= math.pi, endAngle= 3*math.pi/2, lineWidth=width, color=color)
84
85
86 # create same splines with color and .1 m of thickness to simulate lines in the road
87 # the next lines are a copy of the above one under a different name to differentiate
88 # both sets of lines. Height needs to be higher than the road since overlays will
89 # reproduce weirdly in QLabs.
90 height = .02
91 width = .1
92 color = [1,1,0]
93
94 splineLines = QLabsSplineLine(qlabs)
95 splineLines.spawn(location=[10,10,height], scale=[1,1,1], configuration=1)
96 splineLines.rounded_rectangle_from_center(cornerRadius=.5,xWidth=20, yLength=20, lineWidth=width, color=color)
97
98 splineLines.spawn(location=[0,0,0], scale=[1,1,1], configuration=1)
99 splineLines.set_points(color=color, pointList=[[0,13.8,height,width],[6,16.8,height,width], [11,12,height,width], [15.5, 14.5, height,width], [20, 11, height,width]], alignEndPointTangents=False)
100
101 splineLines.spawn(location=[14,4.5,height], scale=[1,1,1], configuration=1)
102 splineLines.circle_from_center(radius=3, lineWidth=width, color=color, numSplinePoints=8)
103
104 splineLines.spawn(location=[0,0,0], scale=[1,1,1], configuration=1)
105 splineLines.set_points(color=color, pointList=[[13.7,13.1,height,width],[14.8,11.8,height,width],[15.5,7.15,height,width]], alignEndPointTangents=False)
106
107 splineLines.spawn(location=[0,0,0], scale=[1,1,1], configuration=1)
108 splineLines.set_points(color=color, pointList=[[10.987, 4.199,height,width],[9.399, 6.559, height,width],[3.002, 4.034,height,width],[1.112, 3.004, height,width],[-0.045, 4.465, height,width]], alignEndPointTangents=False)
109
110 splineLines.spawn(location=[0,0,0], scale=[1,1,1], configuration=1)
111 splineLines.set_points(color=color, pointList=[[3, 20,height,width],[3, 4, height,width]], alignEndPointTangents=False)
112
113 splineLines.spawn(location=[0,0,0], scale=[1,1,1], configuration=1)
114 splineLines.set_points(color=color, pointList=[[8.7, 14.2, height,width],[8.7,0,height,width]], alignEndPointTangents=False)
115
116 splineLines.spawn(location=[20,20,height], scale=[1,1,1], configuration=1)
117 splineLines.arc_from_center(radius=5, startAngle= math.pi, endAngle= 3*math.pi/2, lineWidth=width, color=color)
118
119
120 qlabs.close()
121 print('Done!')
122# -- -- -- -- -- -- -- -- -- -- -- -- --
123
124if __name__ == "__main__":
125 main()
126
Matlab Tutorial
Raw to download this tutorial: Splines tutorial (.m).
1% Splines Tutorial
2% -------------------------
3%
4% .. note::
5%
6% Make sure you have Quanser Interactive Labs open before running this
7% example. This example is designed to be run ONLY in the Plane environment.
8
9close all;
10clear all;
11clc;
12
13% --------------------------------------------------------------
14% Setting MATLAB Path for the libraries
15% Always keep at the start, it will make sure it finds the correct references
16newPathEntry = fullfile(getenv('QAL_DIR'), '0_libraries', 'matlab', 'qvl');
17pathCell = regexp(path, pathsep, 'split');
18if ispc % Windows is not case-sensitive
19 onPath = any(strcmpi(newPathEntry, pathCell));
20else
21 onPath = any(strcmp(newPathEntry, pathCell));
22end
23
24if onPath == 0
25 path(path, newPathEntry)
26 savepath
27end
28% --------------------------------------------------------------
29
30fprintf('\n\n------------------------------ Communications --------------------------------\n\n');
31
32qlabs = QuanserInteractiveLabs();
33connection_established = qlabs.open('localhost');
34
35if connection_established == false
36 disp("Failed to open connection.")
37 return
38end
39
40disp('Connected');
41
42num_destroyed = qlabs.destroy_all_spawned_actors();
43
44fprintf('%d actors destroyed', num_destroyed, '');
45
46% Use hSystem to set the tutorial title on the qlabs display screen
47hSystem = QLabsSystem(qlabs);
48hSystem.set_title_string('Splines Tutorial');
49
50
51% Initialize an instance of a camera
52camera = QLabsFreeCamera(qlabs);
53
54% Set the spawn of the camera in a specific location
55camera.spawn([5.971, 11.781, 30.704], [0, 1.569, 1.57], 0, 1);
56
57% Spawn the camera
58camera.possess();
59
60height = 0;
61width = 1;
62color = [0,0,0];
63
64% create splines to create virtual roads of 1m of thickness
65% Using the same initialization of QLabsSplineLine because the
66% actors will not have to be referenced again. So overwriting them
67% once they are spawned is not a problem.
68
69% In functions (not spawn) that do not have a height value, height needs
70% to be specified in the spawn function as a Z translation
71splineRoads = QLabsSplineLine(qlabs);
72splineRoads.spawn([10,10,height], [0,0,0], [1,1,1], 1);
73splineRoads.rounded_rectangle_from_center(.5, 20, 20, width, color);
74
75splineRoads.spawn( [0,0,0], [0,0,0], [1,1,1], 1);
76splineRoads.set_points(color, [[0,13.8,height,width];[6,16.8,height,width]; [11,12,height,width]; [15.5, 14.5, height,width]; [20, 11, height,width]], false);
77
78splineRoads.spawn( [14,4.5,height], [0,0,0], [1,1,1],1);
79splineRoads.circle_from_center(3, width, color, 8);
80
81splineRoads.spawn( [0,0,0], [0,0,0], [1,1,1], 1);
82splineRoads.set_points(color, [[13.7,13.1,height,width];[14.8,11.8,height,width];[15.5,7.15,height,width]], false);
83
84splineRoads.spawn( [0,0,0], [0,0,0], [1,1,1], 1);
85splineRoads.set_points(color, [[10.987, 4.199,height,width];[9.399, 6.559, height,width];[3.002, 4.034,height,width];[1.112, 3.004, height,width];[-0.045, 4.465, height,width]], false);
86
87splineRoads.spawn( [0,0,0],[0,0,0], [1,1,1], 1);
88splineRoads.set_points(color, [[3, 20,height,width];[3, 4, height,width]], false);
89
90splineRoads.spawn( [0,0,0], [0,0,0], [1,1,1], 1);
91splineRoads.set_points(color, [[8.7, 14.2, height,width];[8.7,0,height,width]], false);
92
93splineRoads.spawn( [20,20,height], [0,0,0], [1,1,1], 1);
94splineRoads.arc_from_center(5, pi, 3*pi/2, width, color);
95
96pause(1);
97
98% create same splines with color and .1 m of thickness to simulate lines in the road
99% the next lines are a copy of the above one under a different name to differentiate
100% both sets of lines. Height needs to be higher than the road since overlays will
101% reproduce weirdly in QLabs.
102height = .02;
103width = .1;
104color = [1,1,0];
105
106splineLines = QLabsSplineLine(qlabs);
107splineLines.spawn([10,10,height], [0,0,0], [1,1,1], 1);
108splineLines.rounded_rectangle_from_center(.5, 20, 20, width, color);
109
110splineLines.spawn( [0,0,0], [0,0,0], [1,1,1], 1);
111splineLines.set_points(color, [[0,13.8,height,width];[6,16.8,height,width]; [11,12,height,width]; [15.5, 14.5, height,width]; [20, 11, height,width]], false);
112
113splineLines.spawn( [14,4.5,height], [0,0,0], [1,1,1],1);
114splineLines.circle_from_center(3, width, color, 8);
115
116splineLines.spawn( [0,0,0], [0,0,0], [1,1,1], 1);
117splineLines.set_points(color, [[13.7,13.1,height,width];[14.8,11.8,height,width];[15.5,7.15,height,width]], false);
118
119splineLines.spawn( [0,0,0], [0,0,0], [1,1,1], 1);
120splineLines.set_points(color, [[10.987, 4.199,height,width];[9.399, 6.559, height,width];[3.002, 4.034,height,width];[1.112, 3.004, height,width];[-0.045, 4.465, height,width]], false);
121
122splineLines.spawn( [0,0,0],[0,0,0], [1,1,1], 1);
123splineLines.set_points(color, [[3, 20,height,width];[3, 4, height,width]], false);
124
125splineLines.spawn( [0,0,0], [0,0,0], [1,1,1], 1);
126splineLines.set_points(color, [[8.7, 14.2, height,width];[8.7,0,height,width]], false);
127
128splineLines.spawn( [20,20,height], [0,0,0], [1,1,1], 1);
129splineLines.arc_from_center(5, pi, 3*pi/2, width, color);
130
131% Closing qlabs
132qlabs.close();
133disp('Done!');