Included in the Communicator package are a number of example programs for libsc. For the C++ API, the examples are located in authoring/libsc/examples.
For the Java API, the Java source files are located in authoring/libsc/java/examples.
The examples cover a variety of topics, including setting up clip regions, creating geometry, adding textures and materials, vector culling, and working with text. Below are instructions for building and running the libsc examples.
In addition to the example code, project files are provided which allow the examples to be compiled into a single executable. Individual examples can be executed by invoking the example executable with the name of a example and an output directory. The list of all available examples can be viewed by running the executable with no parameters.
Building and Running the C++ Examples on Windows
On Windows, solution and project files are provided for Visual Studio 2015. By default, the project is configured to run a basic example and output the result to the authoring_samples_data folder in the quick_start/content directory. The example that will be executed and the output directory can be configured by modifying the Command Arguments property of the Debugging section of the project's properties in Visual Studio.
Alternatively, the examples can be run from the command line in the Windows Command Prompt. The following command line will run the SC_Store_Text example:
Building and Running the C++ Examples on Linux
On Linux, a makefile is provided which will build the example application simply by running make from the authoring/libsc/examples directory. The Linux example project does not include any default values, so the name and output directory must be specified on each invocation of the executable.
The following command line will run the SC_Store_Text example from a Linux terminal:
These examples illustrate how to author models from Java programs running on Windows and Linux. All examples depend on scj.jar and the sc_java shared library for your platform.
The SCStoreUtilsText example, which illustrates how to insert text as geometry, has additional dependencies consisting of: scj_utils_text.jar as well as the sc_java_utils_text and hps_core shared libraries for your platform. These additional dependencies are only required if you need to generate geometry for text strings.
A license is included in the ScLicense.java file for evaluation use only.
Running the Java Examples on Windows
To run a example on Windows, open up a command window, navigate to the authoring/libsc/java directory. Then copy the Java sample files, sc_java.dll, and scj.jar to a new working directory, where you'll compile the samples and dependencies together. (You must have the Java Development Kit installed and available in your path to run the compilation.)
After compilation, create an empty directory to store your Stream Cache model. Finally, run the example with scj.jar in your classpath and the model directory as a parameter.
Here are the Windows commands:
Running the Java Examples on Linux
To run an example on Linux, open up a terminal window, navigate to the authoring/libsc/java directory. Then copy the Java example files, the sc_java shared object, and the scj.jar file to a new working directory, where you'll compile the samples and dependencies together. (You must have the Java Development Kit installed and available in your path to run the compilation.)
After compilation, create an empty directory to store your Stream Cache model and set the LD_LIBRARY_PATH environment variable (this tells Java where to find libraries to load). Finally, run the example with scj.jar in your classpath and the model directory as a parameter.
Here are the Linux commands:
Viewing the Model in a Browser
To view your newly authored model, copy "modeldir" to quick_start/content/model_data in the Communicator package. Then, navigate to the quickstart directory and run start_server.sh (or start_server.bat on Windows) to start the local server.
Finally, in a browser, navigate to the following URL, setting the "instance" variable in the querystring to the name of your model directory: