Skip to content
LuoLei Zhao edited this page Sep 14, 2016 · 2 revisions

The loader file is intended as a User-customizable file that is intended to be modified to fit the current dataset's needs. The loader file path is specified in the Configuration File by modifying the variable loaderScript. For more information regarding the configuration file, check the Configuration File page.

The loader file specifies the Data Mode options, which determine which variables the colormap function will work with. It also defines pointCloud and dataset objects.

Initializing the Firefly Loader

In order to load points in to firefly, you will need to initialize a "FireLoader" class object and specify the path of the hdf5 file that you are trying to load. If the path has already been specified in the Configuration File, the global variable datasetPath can be used as the argument.

FireLoader(): Initializes a new Fire Loader object

FireLoader.setLoader( string filePath) : Specifies the path of the HDF5 file from which firefly will be loading data from.

Importing Datasets

Every set of points in an hdf5 file is represented by a separate "Dataset" object.

Dataset Dataset.create(string setName) : Takes a string corresponding with the name of a subset in the hdf5 file, returns a dataset object.

Dataset.setLoader(Loader mLoader): For a dataset to properly load data, it must be assigned a FireLoader object, which will determine which hdf5 files the dataset will load from.

Dimension Dataset.addDimension(string dimensionName, DimensionType dataType, int dataIndex, string label ) Creates a new Dimension object of data that you are able to load from and display. Data within the dimension are not accessed or in memory until use. Returns a DimensionType class object which can be used as a variable for colormapping or setting point coordinates. - dimensionName: The name of the dimension within the hdf5 file within the current pointset. - dataType: The type of data stored within the dimension. - dataIndex: For variables with multiple values (ex: Coordinates), this values specifies the index of the variable will be used as a dimension. - label: Assigns a string to the current index.

Creating PointCloud Objects

After specifying Datasets of data, "PointCloud" class objects will need to be created to visualize the data. While Dataset Objects hold data, pointCloud objects are the objects that will eventually display the data points.

PointCloud.create(string name): Creates a new Point cloud object with the name passed as an id.

PointCloud.setOptions(string loaderOptions ) The loader options string should be in the format: "50000 0:100000:X" where X is the decimation level for the loader. The true decimation level is the product of the loader decimation level and the display decimation level. Higher decimation levels result in fewer points being loaded. If the pointCloudLoadOptions is specified in the Configuration file, you can set it as the argument.

PointCloud.setDimension(Dimension xAxis, Dimension yAxis, Dimension zAxis): Indicate the variables that will be plotted for each axis, with the first variable specifying the x coordinate of the point, the second the y-coordinate, and the third, the z. For most visualizations, the point coordinates in world space will be used. However, there is no restrictions to what variables can be mapped to each axis.

PointCloud.setColor(Color mColor) : Sets the default color of the point cloud object. This color will only display if the prog_fixedColor shader is used. In the default Javascript interface, this color will be displayed if the feature "Advanced Colormapping" is turned off.

PointCloud.setData(Dimension dataDimension): specifies which dimension the pointcloud will as the basis for the colormap. Specifically, the variables specified here will be sent to the current Geometry shader as the attribute attrib_filter for every point.

PointCloud.setVisible(bool visible): specifies whether the PointCloud object will display any points.

PointCloud.setProgram(Shader mProgram )`: Specifies which shader the pointCloud object will use when rendering points: - prog_fixedColor: Only use if you want all points to use their uniform, default colors. - prog_channel: Use when using a colormap that only includes a single dimension. - prog_vector: Use when displaying a variable that requires Vector plotting, such as Velocity. For more information regarding shaders, check the Shader Files page.

PointCloud.setVector(Dimension vec1, Dimension vec2, Dimension vec3): Similar to setData, it maps the colormap to a data Dimension, but sends multiple variables to the geometry shader. Intended for vector plots.

parts: Global array variable. Fill this array with all PointClouds that you are planning to use.

dataModes: Global array variable. Fill this array with strings specifying the names of the dataModes that you want to visualize. This array will then be passed to the User interface as options. The strings in this array will also be sent as parameters to the setDataMode function

setDataMode(string mode): You will need to modify this function to specify what happens when each dataMode is selected. typically you will need to use an if statement for each dataMode option.

Example usage:

l = FireLoader()
l.open("datasetPath/data.hdf5")

ds0 = Dataset.create("PartType0")
ds0.setLoader(l)

x0 = ds0.addDimension('Coordinates', DimensionType.Float, 0, 'x')
y0 = ds0.addDimension('Coordinates', DimensionType.Float, 1, 'y')
z0 = ds0.addDimension('Coordinates', DimensionType.Float, 2, 'z')
sl0 = ds0.addDimension('SmoothingLength', DimensionType.Float, 0, 'SmoothingLength')


pc0 = PointCloud.create('pc0')
pc0.setOptions(pointCloudLoadOptions)
pc0.setDimensions(x0, y0, z0)
pc0.setColor(Color('red'))

# PartType1
ds1 = Dataset.create('PartType2')
ds1.setLoader(l)

x1 = ds1.addDimension('Coordinates', DimensionType.Float, 0, 'x')
y1 = ds1.addDimension('Coordinates', DimensionType.Float, 1, 'y')
z1 = ds1.addDimension('Coordinates', DimensionType.Float, 2, 'z')

pc1 = PointCloud.create('pc1')
pc1.setOptions(pointCloudLoadOptions)
pc1.setDimensions(x1, y1, z1)
pc1.setColor(Color('blue'))

In addition to specifying DataModes. Camera settings, and other global settings can also be adjusted in this file. The following lists miscellaneous features that can be adjusted.

Camera Functions

setCamPos(float x, float y, float z) Sets the camera coordinates.

setPivotPoint(float x, float y, float z) Sets the center of rotation for the galaxy.

setCamOrientation(float w, float ix, float iy, float iz ) Determines the direction the camera is facing in Quaternion form - w the real component of the quaternion. - ix,iy,iz: Values of the imaginary components for each axis in the quaternion.

setCamNearFar( float nearPlain, float FarPlane) - Sets the bounds of how near or far an object can be to the camera for it to be drawn. - Objects closer then the nearPlane to the camera will not be drawn. Objects further then the farPlane will also not be drawn. - Do not set the range to be too high (> 1000000). Increasing the draw range will reduce the precision of the objects drawn along the Z-axis

Other Variables

imagePath: Global string variable. Will specify the destination path that screenshots taken will be saved to.

presetPath: Global string variable. Will specify the destination path that the presets will be loaded and saved to.

Clone this wiki locally