|
|
5 |
| VR Development Course (1) |
|
|
This time, we will introduce the structure and contents of the UC-win/Road SDK, and further explain the API details and plugin operation. By utilizing the SDK's API, free plugin development as an option for UC-win/Road becomes possible. As examples, we will cover topics such as real-time data reading and writing, and user interface customization, using sample code.
|
The UC-win/Road SDK allows for the development of plugins to extend UC-win/Road. By using the SDK, you can develop plugins that operate at the same level as the plugins included in UC-win/Road products.
By using the UC-win/Road SDK, the following types of customization are possible:
Reading, writing, and editing of static data
・Customization of the user interface
・Acquiring the state of an operational model
・Acquiring user operation status
・Main screen viewpoint control
・Real-time control of models and characters
・Accessing OpenGL controls
・Customization of vehicle driving models |
|
UC-win/Road SDK components |
|
When you install the UC-win/Road SDK, it is by default extracted to the "C:\UCwinRoad_SDK" folder.
| The "UC-win/Road_SDK" folder |
| ├─ |
"Library" folder |
|
The various library files required for compiling the plugin will be copied. |
| ├─ |
"Plugins folder" |
|
A separate folder is created for the sample plugin, and the source code of the sample is copied into it. |
| └─ |
"UIL folder" |
|
The plugin framework files will be copied. |
|
■ Contents of the Plugin Folder
The "Plugins" folder contains sample programs similar to those shown in Table 1, and building them results in working examples.
The parent folder contains Word Samples, Access Samples, and AutoCAD Samples, so it would be a good idea to check them. First, make sure these samples are working correctly. If they don't work properly, try reinstalling the application.
| Sample name |
Content |
| AlignmentIPPlugin |
Linear IP information output tool |
| MakeAlignmentDemoPlugin |
Road data creation |
| TerrainInfoProcessing |
Terrain processing |
| TrafficSetupSamplePlugin |
Road traffic settings |
| CameraControlSamplePlugin |
Camera and viewpoint control functions |
| EnvironmentControlSamplePlugin |
Environment settings |
| ModelControlSamplePlugin |
Controlling human characters |
| ModelExportPlugin |
Output of 3D landscape models |
| ModelImportPlugin |
Creating 3D models |
| PerformanceProfileEditorSamplePlugin |
Vehicle operation profile editing |
| InteractionSamplePlugin |
Log acquisition function, user click event |
| VehicleDynamicsSample |
Vehicle motion model replacement |
| LogExportPlugin |
Log output control, scenario event customization, and waypoint customization |
| StationPointEditorPlugin |
Road measurement point management |
| SpeedMeterPlugin |
Speedometer display |
• Table 1: List of sample programs stored in the Plugin folder
■ Contents of the Library folder and information about the API
The libraries for the UC-win/Road SDK are located in the Library folder within the directory where the SDK is installed. The core component of these libraries is PluginCore. PluginCore defines all interfaces and primary data types for the UC-win/Road SDK. When using the interfaces of UC-win/Road objects, access must be through the interfaces defined here. Therefore, in the source code of your plugin, you need to add PluginCore to the "uses" section.
Furthermore, the Library folder contains API libraries, and by utilizing the APIs provided there, various functionalities can be developed as follows.
Simulation-related functions
It allows for control of simulations within a virtual reality space.
- Real-time control of models and characters
- Main screen viewpoint control
- Driving simulation: start and control
Customizing basic functions
- Customization of vehicle motion models in driving simulators
- Free drawing on OpenGL controls
Editing-related features
It allows for reading, writing, and editing of static data.
- The following items are relevant: topography, aerial photographs, roads, intersections, traffic, and 3D models
GUI-related functions
The user interface can be customized.
- Adding controls to the main screen, controlling existing controls
Interaction features
It can acquire simulation data and perform control operations related to it.
- Calling callback functions through keyboard, mouse, and game controller operations
- Perspective settings, log output
UC-win/Road is composed of common "objects" in programming terms. For each object (element) within UC-win/Road, a single object is assigned, representing things like terrain, roads, cross-sections, 3D models, cameras, and textures. This API exposes certain procedures and functions from among these objects using Delphi's interface mechanism.
|
UC-win/Road and plugin integration |
|
■ Implementation of the Interface
Here, we will briefly explain how to access various information and objects within UC-win/Road from a plugin, and how to integrate it with the procedures and functions you want to add.
In Delphi, an interface is a definition of methods that are implemented in a class. Classes that support an interface must implement the methods defined in that interface. A single class can implement multiple interfaces. UC-win/Road consists of many objects, but objects within UC-win/Road cannot be directly accessed from the plugin side. Access to these objects is achieved through their interfaces. By using the interfaces defined in PluginCore, it is possible to retrieve and set states [Table 2].
| Interface name |
Explanation |
| IF8UserPlugin |
Interfaces required for creating plugins |
| IF8ApplicationServices |
UC-win/Road application interface |
| IF8ProjectForRoad |
Project interface |
| IF8Road |
Road object interface |
| IF8Terrain |
Terrain object interface |
| IF8DBObject |
The base interface for all objects |
| IF8ThreeDeeStudio |
3D object interface |
| IF8ModelInstance |
Interface for 3D model instance objects |
| IF8OpenGLPlugin |
The interface used for rendering with OpenGL |
| IF8LogServer |
Interface for obtaining logs |
• Table 2: Main interfaces defined in PluginCore
In Delphi, the Supports function can be used to return an interface if a specified object supports that interface. This can be used to determine whether an interface supports the values you want to obtain from UC-win/Road.
As an example, here we will show a method for dividing the targets when acquiring log information. We will extract relevant sections from the source code of the InteractionSamplePlugin sample within the SDK.
In this way, if the object being logged is a car model, vehicle information (vehicleLogs) is retrieved; if it's a character model, character information is retrieved; and for anything else (movingModel), its corresponding information is retrieved.
procedure TFormLogDisplay.OnLog(dTimeInSeconds: double; instance: IF8DBObject;
group: TLogExportOption);
var
| |
vehicleLogs : IF8VehicleLogs; ---Car
movingModel: IF8InstanceLogs; ---Other
character : IF8CharacterLogs; --- Character --- |
|
Various access points |
begin
if Supports(instance, IF8VehicleLogs, vehicleLogs) then
begin
if Assigned(vehicleLogs.model) then
logRecord.name := vehicleLogs.model.name
else
logRecord.name := '';
| |
logRecord.ID := vehicleLogs.ID;
logRecord.position := vehicleLogs.position;
logRecord.yawAngle := vehicleLogs.yawAngle;
logRecord.pitchAngle := vehicleLogs.pitchAngle;
logRecord.rollAngle := vehicleLogs.rollAngle; |
|
Various types of cars
Log information |
end
else if Supports(instance, IF8InstanceLogs, movingModel) then
begin
if Supports(instance, IF8CharacterLogs, character) then
logRecord.name := character.characterModel.GetName
else
if Assigned(movingModel.model) then
logRecord.name := movingModel.model.name
else
logRecord.name := '';
logRecord.ID := movingModel.ID;
logRecord.position := movingModel.position;
logRecord.yawAngle := movingModel.yawAngle;
logRecord.pitchAngle := movingModel.pitchAngle;
logRecord.rollAngle := movingModel.rollAngle;
end;
end; |
■ Callback
Callback functions are a programming technique where pre-defined functions are called during program execution to perform specific tasks. In PluginCore, if the required event procedures or function types are defined, the plugin sets corresponding procedures or functions according to those types. When an event occurs on the UC-win/Road side, the system checks whether a corresponding callback function has been set, and if it has, it calls that function, enabling communication between UC-win/Road and the plugin (Figure 1).
 |
| ■ Figure 1: Callback mechanism |
■ Setting up callbacks for user input:
Game controller input: examples of button presses and releases
procedure TFormGetUserInputs.FormCreate(Sender: TObject);
var
method : TMethod;
begin
//Game controller callbacks
//Registers game controller button down event
JoystickButtonUpDownProc(method) := JoystickButtonDown;
F8InteractionSamplePlugin.winRoadApplication.RegisterEventHandler( _plgJoystickButtonDown,
method);
//Registers game controller button up event
JoystickButtonUpDownProc(method) := JoystickButtonUp;
F8InteractionSamplePlugin.winRoadApplication.RegisterEventHandler( _plgJoystickButtonUp,
method);
end; |
|
Basic usage of the UC-win/Road SDK |
|
The Application Services are the entry point for the UC-win/Road API. Plugins access UC-win/Road data and controls through the application services (Figure 2). The application service interface is at the top level of the API, providing access to features such as menus, data, and simulation functions.
 |
| ■ Figure 2: The mechanism of application services |
unit Sample;
interface
uses upfIntf,PluginCore,SysUtils;
function GetUCWinRoadApplicationServices : IF8ApplicationServices;
// function to acquire UC-win/Road's ApplicationServices
implementation
function GetUCWinRoadApplicationServices : IF8ApplicationServices;
var
UCWinRoadApplicationServices : IF8ApplicationServices;
begin
// The global ApplicationServices variable are adjusted to the ApplicationServices
of UC-win/Road
if Supports(ApplicationServices, IF8ApplicationServices, UCWinRoadApplicationServices)
then
result := UCWinRoadApplicationServices
else
result := nil;
end;
end. |
Plugins created using the SDK operate within the same process as UC-win/Road. Therefore, when a plugin is loaded or unloaded, it is necessary to properly perform the registration and unregistration processes for the plugin.
The application services are global variables defined within the upfCore7.bpl package in the upfIntf unit. To access these application services, you need to add "upfIntf" to the uses clause.
|
The structure of the UC-win/Road core system |
|
The core components of UC-win/Road consist of the main screen for displaying 3D scenes, menus (user interface, UI) for inputting and simulating each object, and various data sections (Figure 3).
In the user interface, a 3-dimensional landscape is displayed using OpenGL on the main screen, and each menu provides access to input screens that allow users to modify parameters of specific objects. While there may be minor variations in the input screens depending on the version, the fundamental concept remains the same. The data processing section interprets the information entered by the user, processes it appropriately, and returns the processed information to the UI. The amount of data processed varies depending on the user's input.
While basic functions cannot be modified, extensive customization is possible by using the UC-win/Road SDK. For example, it's possible to place models on the main screen or add menus for new features.
 |
| ■ Figure 3: The UC-win/Road interface |
UC-win/Road data can be considered as a collection of objects. In this context, "objects" refer to elements necessary for creating landscapes, such as terrain, roads, structures, trees, and signs. Individual input and editing screens are provided for each object, allowing for detailed settings.
In the program, "classes" serve as the units that access these objects. A class provides parameter information for each object and a method to access those parameters. To generate, edit, or delete user-added objects, appropriate processing methods implemented for each object are used.
In UC-win/Road, a project class is generated when creating new data. This project class manages all input data, including added roads, structures, and trees (Figure 4). In other words, each input screen interacts with this project class to exchange data.
Furthermore, there are classes that exist solely for data processing unrelated to the user interface. These types of classes perform auxiliary processing to properly render 3-dimensional landscapes on the main screen.
Roads are composed of horizontal alignment, vertical alignment, and road cross-sections, each of which is an individual object. In this way, some objects are also comprised of multiple objects.
 |
| ■ Figure 4 illustrates the concepts of project classes and objects |
The UC-win/Road SDK's API is implemented using Delphi's interface features. An interface defines the methods for accessing existing objects. In this context, "access" refers to the methods of creating, editing, and deleting objects. Basically, interfaces exist on a class basis as mentioned previously, so data access occurs at the object level.
When using the API, there are various ways to access each object. The entry point for the SDK's API is "Application Services." When creating a plugin for UC-win/Road using the SDK, you must always access this Application Service to access the main program's data. There is 1 instance of this per running application process.
When you acquire an application service, you will be able to access the "Menu" on the main screen. From the "Menu," you can add or remove submenus for each main menu. Generally speaking, plugins are considered a type of tool, so the "Tools" menu is frequently used. Also, due to the concept of tool options, the "Options" menu is often utilized.
By writing click event handlers for each menu item, it is possible to add new input screens and reflect the entered information onto the main screen via an interface. It is also possible to add tool buttons, so frequently used functions can be registered as a group of tool buttons along with the menu. Furthermore, it becomes possible to obtain a "project" that allows access to objects displayed within the main screen. A "project" is a collection of objects displayed in the main screen. By obtaining a "project," you can use that interface to add new model or tree object instances to the screen, edit existing models (e.g., position and size), and even delete objects.
By using the application service's interface, users can create new projects, edit terrain, and add or modify roads, which means that most landscapes can be created through plugins.
Please note that Figure 5 illustrates the structure of the API related to "projects."
Furthermore, it allows for camera control, separate screen display of viewpoint locations, and simulation control. With camera control, settings such as viewpoint position and direction are possible. It enables driving and operation on arbitrary roads, along with waypoint and scenario control during those operations.

| Legend |
|
|
|
| IF8ProjectForRoad |
Project data |
IF8ThreeDeeStudio |
3D model objects |
| IF8Road |
Road data |
IF8ModelInstance |
3D model object instances |
| IF8Section |
Road cross-section data |
IF8MovingObjectInstance |
Mobile model instance |
| IF8TurningPoint |
Road alignment direction change point data |
IF8QuakeIII |
MD3 character list object |
| IF8RoadThing |
Road cross-section change point data |
IF8CharacterInstance |
MD3 character object instance |
| IF8VerticalCurve |
Road alignment data |
IF8Tree2D |
2D tree objects |
| IF8VerticalCurveTurningPoint |
Road crossing change point data |
IF8Tree2DInstance |
2D tree object instances |
|
|
IF8Terrain |
Terrain data |
|
■ Figure 5: Structure of the API related to the project
When an object is clicked or the screen is rendered, certain events occur. By registering specific content as event handlers for these events, various functions can be added each time an event occurs.
For example, by adding custom controls when a certain input screen opens, it becomes possible to add an input section for extended data to that screen, or to display something independent of the scene at the end of the main screen through event control.
Event handlers each have a specific type. A type is like the arrangement of function arguments, and when an event is executed, appropriate values are assigned to the arguments based on the type. Then, processing is performed within the event handler. For details, please refer to the UC-win/Road SDK help documentation.
Normally, using the SDK's interface allows you to edit the data of each object. However, for road polygon (quad) data, the values are calculated from the alignment, grades, and cross-sections. While the SDK's API provides access to the road's alignment and polygons, since the polygons are calculated results, direct editing such as data modification is not possible. If editing is necessary, you should modify the alignment and cross-sections instead.
We have explained the structure of UC-win/Road, covering the core components, data, and SDK APIs in that order. In this explanation, we only focused on the concepts and mechanisms, without delving into actual programming details. However, understanding the basic structure of UC-win/Road will be helpful for comprehending the subsequent explanations about programming.
Announcement of paid seminars
| Introduction to Programming for Engineers Seminar CPD certified: 6.2 points |
| • Date and time |
September 15, 2011 (Thursday), 9:30 AM to 5:00 PM |
| • Course fees |
Price for 1 person: 15,750 yen (including tax) |
| • This venue |
FORUM8 Tokyo headquarters, GT Tower seminar room
※TV conferencing systemThe event will be held simultaneously in Tokyo, Osaka, Nagoya, Fukuoka, and Sendai |
|
|
| (Featured in the Autumn issue of Up&Coming '11) |
 |
|







>> Product comprehensive catalog

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