Cube Sample Application
This section explainins the UE4 Cube Sample application and how to use the Genvid Plugin and Module.
- Origin
- Content
- C++ Classes
- Blueprint Classes
- Blueprint Structures
- How to run the cube sample
- Genvid integration
- Notes
- Assets
See Local Environment Usage for more information about running the cube sample, .
Origin
The Cube sample uses the Unreal Engine 4 Basic Code template (New Project).
The cube application is an adaptation from the Tutorial sample code.
We added all available features to show all parts of the Genvid integration.
Content
The cube application displays 3 cubes named Athos, Porthos, and
Aramis. These cubes rotate and move in various fixed directions. Upon
reaching the extremity of the world, a sound plays and the cube moves
to the opposite side of the world to continue its movement without
interruption.
C++ Classes
- Cube.cpp : This file implements the game module.
- Cube.h : Header file of the game module.
- ActorCube.cpp : Actor class based that contains the matrix
transformation functions for the cubes.
- ActorCube.h : Header file that declares the function to be
callable in Blueprint.
- GameStreamer.cpp : Class derived from UGenvidStreamer and contains
the view projection matrix of the player.
- GameStreamer.h : Header file that declares the function to be
callable in Blueprint.
Blueprint Classes
- BP_Cube : Class used to show and manage a cube.
- BP_Game : Class used to manage the Genvid events.
Blueprint Structures
- BP_CubeData : Structure used to store the cube data.
- BP_GameData : Structure used to store all cubes and the view projection matrix.
- BP_NameToColor : Structure used to store a color and its name.
- BP_Popularity: Structure used to store the popularity of a cube name.
- BP_PopularityData: Structure used to store all the cubes’ popularities.
How to run the cube sample
This guide assumes that your config file is properly set up with a working YouTube account
(see Genvid Configuration) and that you can successfully run the
Genvid services (see Local Environment Usage).
- Declare an environment variable named
UE4ENGINEDIR
that
points to the Engine directory of your version of Unreal Engine 4.
By default, it used UE4ROOT/Engine
, where
UE4ROOT
is the installation directory of Unreal Engine 4.
- Prepare the cube folder for building
This will copy the Genvid Plugin and Genvid Module under the
cube/app
folder.
- Build the project (app and website)
This generate the Visual Studio solution for the project and try to build it right after.
Note
If you encounter some trouble when building the package:
- You can verify the uproject file is associated with Unreal
Engine. You can find a program
UnrealVersionSelector in your Unreal Engine
directory:
Engine\Binaries\Win64
.
- An other problem is when you want to change the engine
version (4.15 to 4.16 for example). You need to delete the
Intermediate
directory in the cube application under
samples\ue4\cube\app
.
- Clean and load the project configuration
genvid-sdk clean-config
genvid-sdk load-config-sdk
py cube.py load
- Start the project
Genvid integration
The GameStreamer class makes it possible to automatically integrate the Genvid SDK.
The class BP_Cube contains all required Genvid code.
The screenshot shows which parts are Genvid.
We currently have only one video stream and one audio stream. The Genvid Module can automatically
manage them through the class AGenvidWorldSettings.
Go to the Engine General Settings window in Project Settings and
set the world settings class GenvidWorldSettings (General Settings) to enable automatic management.
We create 3 streams to send some game data to the servers (Blueprint Game class, Section 3).
One for the game data, one for the popularity, and one for the color change.
Next, we declare all the events and commands coming from the
web page. In our case, we are catching 3 actions that can occur on the web page:
a change of color, a position reset, or a popularity change (Blueprint Game class, Section 2).
To start Genvid, call the Startup
function in Begin Play
(Blueprint Game class, Section 1).
Finally, select the streamer class BP_Game
in the world settings (Main Map).
At this stage, you’re ready!
Notes
The Genvid Module automatically manages all Streams, Events, Commands, and Audio/Video Capture initialisation and finalization.
JSON automatically serializes structures when you submit game data to the server.
There is no need to call the Shutdown
function, as exiting the application automatically calls it.
You can call it explicitly if you want without any problems.
Assets
- MainMap : The game level map.
- Colored_Steel : The material used by the cube.
- galvanized_steel : The texture used by the material of the cube.
- EdSplash.bmp : A splash screen used by the Unreal Editor.
- Splash.bmp : A splash screen used by the cube sample.