|
|
6 |
| Practical exercise sample code explanation (1) |
|
|
In this session, we will provide a detailed explanation of the sample programs included in the UC-win/Road SDK. We will use source code to explain the key points. In other cases, unless otherwise specified, application services are referred to as "ApplicationService," and the current project is represented by the variable "project."
|
|
Acquisition of linear direction change point information |
|
UC-win/Road roads are composed of horizontal alignment, vertical alignment, and cross-sectional profiles. Here, you can access the horizontal and vertical alignments. To create a new road or load data, select [Tools] - [Alignment CSV Export..] from the menu, which will display the road selection screen. After selecting a road, clicking the [Output by CSV file format] button will output the information about the direction change points of the horizontal and vertical alignments in CSV format.
 |
 |
 |
| Plain curve |
 |
| Vertical profile alignment |
Direction change point information will be output in CSV format |
■ Approach 1: Planar Figures
The planar alignment of a UC-win/Road design consists of Intersection Points (IPs). The types of IPs are as follows: Among these, the start and end points are type "1", but only their coordinate values are valid.
1. Transition curve - circle - transition curve
2. Transition curve - Circle
3. Curve of gradual transition
4. Yen - easing curve
5. Yen |
For example, if the type is "1," a linear segment consisting of "transition curve -> circle -> transition curve" is inserted at the location where the direction changes. The transition curve is part of a clothoid curve, and its parameters are determined based on the specified type; this parameter information corresponds to the data for the points where the direction changes. In a project involving roads, the relationship between the road, the straight section, and the points where the direction changes in a plane alignment is as follows.
| IF8ProjectForRoad (project) → IF8Road (road) → IF8TurningPoint (turning point) |
The relationships of the parameters accessible in this IF8TurningPoint are as follows: The linear element progresses from the lower left to the upper right.
To access points where the direction of a straight line changes, use the following syntax.
var
road : IF8Road;
turningpoint : IF8TurningPoint;
i, j : integer;
begin
Roads within a project are numbered starting from 1
for i := 1 to project.numbrOfRoads do
begin
road := project.road[i]; // This assigns the i-th element of the "road" array within the "project" object to the variable "road"
// The turning points of the selected route are counted from 1
for j := 1 to road.numberOfTurningPoints do
begin
turningpoint := road.turningpoint[j];
// The j-th road
…
end;
end;
end; |
■ Approach 2: Vertical Alignment
The vertical alignment also consists of sections at points of direction change, but unlike the horizontal alignment, it is defined by a concept called VCL. VCL refers to the length of the easing curve in the vertical alignment. It represents the horizontal distance along the vertical alignment, rather than the actual distance on the ground.
To access the vertical alignment data, use the following syntax.
To access points where the direction of a straight line changes, use the following syntax.
var
road : IF8Road;
turningpoint : IF8TurningPoint;
i, j : integer;
begin
Roads within a project are numbered starting from 1
for i := 1 to project.numbrOfRoads do
begin
road := project.road[i]; // This assigns the i-th element of the "road" array within the "project" object to the variable "road"
// The turning points of the selected route are counted from 1
for j := 1 to road.numberOfTurningPoints do
begin
turningpoint := road.turningpoint[j];
// The j-th road
…
end;
end;
end; |
|
Road creation demonstration |
|
Using the SDK, create a new project, add terrain, and then add roads (plan view, longitudinal profile, cross-section). When creating roads, after adding a new road to the project, you will create the plan alignment, longitudinal alignment, and cross-sectional alignment.
■ Adding Roads
To add a new road to a project, follow these steps:
var
road : IF8Road;
begin
road := project.CreateNewRoad;
…
end; |
■ Planar linear motion
Add the necessary turning points to the added road. The interface used for this process is as follows.
For all points other than the starting and ending points, set the necessary parameters for the IF8TurningPoint function, which determines the return path.
function IF8Road.CreateTurningPoint(x: double; y: double; tpType: TurningPointType)
: IF8TurningPoint;
x: X-coordinate (east-west direction), with the lower left of the terrain defined as 0
y: Y-coordinate (North-South direction). Relative to the lower-left corner of the terrain, the internal data represents: northDistance -.
Enter the Y-coordinate for the lower-left corner.
tyType: Type of direction change point |
■ Vertical profile
First, add vertical alignment to the road using the following interface.
procedure IF8Road.MakeVerticalCurve(const useActualHeights: Boolean = true
);
useActualHeight: true: The starting and ending elevations are based on the actual terrain. false: The starting and ending elevations are based on the terrain plus 0.5 meters. |
After adding the vertical alignment, you can obtain the vertical alignment data using IF8Road.verticalCurve and add turning points using the following interface.
function IF8VerticalCurve.InsertTurningPoint(x: Double; y: Double; out
index: Integer): boolean;
x: The x-coordinate of the point where the direction changes (the horizontal distance from the starting point of the vertical alignment)
y: The y-coordinate (elevation value) of the additional turning point to be added
index: If the return value is True, the added position will be stored in this variable. |
Set the necessary parameters for the added direction change points.
var
road : IF8Road;
verticalCurve : IF8VerticalCurve;
x,y, : double;
index : integer;
begin
verticalCurve := road.verticalCurve;
if verticalCurve.InsertTurningPoint(x, y, index) then
begin
verticalCurve.curvePoint[index].iSaveData....
end;
end; |
For the added inflection points, the actual calculations are performed using CurveSlopes.
■ Road Cross-Section Geometry
The road cross-section consists of 3 parts: the road surface, the bridge deck, and the tunnel lining. Each part is represented by a continuous sequence of node information from left to right. The procedure for adding a cross-section and defining the road surface, bridge deck, and tunnel lining is as follows.
The interfaces for performing each process are as follows:
function IF8Road.AddSection : IF8Section;
// Add road surface nodes
function IF8Section.AddPoint(point: F8PointType) : integer;
point[1]: x-coordinate; This represents the horizontal offset from the origin (0,0), where the line passes through. Negative values indicate a position to the left of the origin, while positive values indicate a position to the right
point[2]: y-coordinate, the vertical offset from the origin
Return value: index
// Access road surface nodes
property IF8Section.point[index:integer] : PluginSectionBitType;
index: Index. If it's immediately after adding a node, it will be the return value of AddPoint()
// Adding nodes to the bridge deck surface
function IF8Section.AddBridgePoint(point: F8PointType) : integer;
// Accessing the bridge interface node
property IF8Section.bridgepoint[index:integer] : PluginSectionBitType;
// Adding nodes to the tunnel face
function IF8Section.AddTunnelPoint (point: F8PointType) : integer;
// Access the tunnel face node
property IF8Section.tunnelpoint[index:integer] : PluginSectionBitType;
|
■ Add the created cross-section to the road
The interface for adding the created cross-sections to the road is as follows:
var
road : IF8Road;
begin
road := project.CreateNewRoad;
…
end; |
This sample demonstrates how to control the main camera using the SDK. Select "Tools" -> "Control Cameras..." from the menu, and then use the controls displayed on the screen to manage the camera.
■ Access to the Camera
The camera information includes viewpoint position and viewpoint direction, and access to each of these parameters is possible.
// Camera viewpoint position
var
eye : GLPointType;
begin
eye := ApplicationService.MainOpenGL.Camera.Eye.point;
end;
// Camera viewpoint direction
var
view : GLPointType;
begin
view := ApplicationService.MainOpenGL.Camera.ViewPoint.point;
end; |
■ Saving and deleting camera positions
To save camera positions (and add them to the project), use the following interface. You can also navigate to the added camera positions through normal operation from the main screen.
// Camera viewpoint position
var
eye : GLPointType;
begin
eye := ApplicationService.MainOpenGL.Camera.Eye.point;
end;
// Camera viewpoint direction
var
view : GLPointType;
begin
view := ApplicationService.MainOpenGL.Camera.ViewPoint.point;
end; |
To delete a camera position, use the following interface.
functin IF8ProjectForRoad.DeleteCamera(index : itneger) : boolean;
index: index (1~) |
To display or hide the added camera positions in the camera view, use the following interface.
// Displaying the camera view
procedure IF8ProjectForRoad.OpenCameraView(index : integer);
index: Saved camera position index
// Hide camera view
procedure IF8ProjectForRoad.CloseCameraView(index : integer);
index: Saved camera position index |
This sample demonstrates how to control 3D models and character movement using the SDK. Select the "Import Object Movement..." option from the Tools menu, and load a text file that contains movement information based on three-dimensional coordinates. This text file is separated by tab spaces, and the MD3 character models or 3D models placed according to this location information will move around the main screen. Also, select the "Control Fixed Models..." option from the Tools menu, and the displayed screen allows you to place each selected model instance on the main screen.
■ Callback Function
A function that registers processes to be executed during a specific event is called a callback function. In UC-win/Road, callback functions are assigned as function pointers to each event, allowing appropriate values to be returned based on the arguments defined for each event.
As a result, the plugin can use these arguments to reset the state of the model, for example. If no callback function is set, nothing happens; however, once a callback function is defined, the processing specified within that function will be executed. In the case of an MD3 character instance, it allows you to set the position of the instance.
procedure Move(dTimeInSeconds : double; Instance : IF8MovingObjectInstance);
dTimeInSeconds: Frame interval
Instance: The target model instance
//Registration method
var
instance : IF8MovingObjectInstance;
begin
if Assigned(Instance) then
begin
// Specifying callback functions
Instance.onMove := self.Move;
end;
end; |
■ Processing flow when loading MD3 character models
The MD3 character model is loaded and registered in UC-win/Road, and the processing flow during actual simulation execution is as shown in the figure below. When registering a character model as a pedestrian, a callback function that controls its behavior is also registered simultaneously.
This allows the UC-win/Road software to execute callback functions registered in character models during simulations, while ignoring functions that are not registered.
 |
| ■ Character model loading process flow |
Announcement of experiential seminars
| UC-win/Road SDK introductory seminar |
| • Date and time |
November 25, 2011 (Thursday), 1:30 PM to 5:00 PM |
| • Course fees |
Free of charge |
| • This venue |
FORUM8 Tokyo headquarters, GT Tower seminar room
※TV conferencing systemThe event will be held simultaneously in Tokyo, Osaka, Nagoya, Fukuoka, and Sendai |
|
|
| Up&Coming '11, featured in the late autumn issue |
 |
|







>> Product comprehensive catalog

>> Premium membership services
>> Financial support
| Recently released products |
|
|
|