SourceValueGenerator
- Last UpdatedDec 07, 2023
- 3 minute read
The SourceValueGenerator node can generate values provided an external source.
-
Only CSV files are supported as source.
-
This node generates new values at every frame. However, when not using interpolations the values stay the same from sample to sample.
Platform support
This node is supported on XR-Windows platform only.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Full support |
No support |
No support |
No support |
No support |
|
|
|
|
|
|
CSV file format
The csv file must comply with the following rules:
-
The first line must contain the column names.
-
All rows must have the same number of elements.
-
At least one column must be numeric because at least one column must be used for time reference.
CSV file example
sample,var0,var1,var2
1,10.37,75,Regular,true
2,10.48,75,Regular,true
3,11.2,83,Big,false
Note: Column name spaces ' ' are automatically converted into underscores '_'.
Interpolating values
-
When interpolate is set to true, the node generates interpolated values between those set in the rows.
-
Interpolation works only for numeric values. All numeric values are assumed to be float. This means that integer columns could generate float values when using interpolation.
-
Interpolation does not work for non-numerical columns, or for non-numerical values in a numerical column.
Automatic or manual generation
-
Value generation can be Automatic or Manual.
-
When set to Manual, a new set of values is generated every frame. If interpolation is set, the node tries to interpolate the values.
-
Playback proceeds according to the timeColumnName values and speed.
-
Use the nextStep parameter to manually generate values.
-
At every call, the node column values are moved to next row, therefore avoiding interpolation.
-
Use currentTime to move directly to a specific position in the timeline.
-
An alternative way to manually generate values is to use the currentTime with progressive values. In this way, interpolation can be used manually.
Code example
This is a code example for the SourceValueGenerator node.
<SourceValueGenerator name="scenario_001" source="GameData/scenarios/Vibration.csv" timeColumnName="SampleNum" interpolate="true" speed="2"/>
SourceValueGenerator fields
These are the fields for SourceValueGenerator node. Only the node-specific fields are indicated, not fields obtained by inheritance.
Field inheritance: NodeBase > SourceValueGenerator
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
active |
sbool |
Optional |
true |
Activates/deactivates the component. |
|
column\XXX |
sstring |
Read only |
Internally calculated |
To each column XXX in the source correspond a column\XXX value in the node. Space included in column names are replaced. |
|
currentTime |
sfloat |
Optional |
Internally calculated |
Reads current position or moves to a particular position. |
|
interpolate |
sbool |
Optional |
false |
The value between two rows/samples are interpolated, if possible. |
|
loop |
sbool |
Optional |
false |
If set, the valuegenerator restarts from beginning after reaching the end. |
|
nextStep |
sevent |
Optional |
Enables you to manually generate new values. |
|
|
pause |
sevent |
Optional |
Pauses and unpauses automatic value generation. |
|
|
sourceType |
senum |
Optional |
Csv |
The CSV file format is the only sourceType supported so far. |
|
sourceType |
sstring |
Mandatory |
Path of the source file, in reference to executable. |
|
|
speed |
sfloat |
Optional |
1 |
Changes playback speed. |
|
start |
sevent |
Optional |
Starts automatic value generation. |
|
|
stop |
sevent |
Optional |
Stops automatic value generation. |
|
|
timeColumnName |
sstring |
Optional |
Time |
Name of the column to use as time base. |
|
timeColumnFormat |
sstring |
Optional |
S |
Changes the time format to use as timebase columns containing dates or datetimes. Supports both standard and personalized formats. By default, time is expressed in seconds. |
|
totalTime |
sfloat |
Read only |
Internally calculated |
Playback length, in seconds. |