Skip to content
This repository was archived by the owner on Dec 5, 2023. It is now read-only.

Using the Coherent UI plugin

gashtio edited this page Oct 29, 2013 · 3 revisions

Sample flow graph

There is a sample flow graph in <Code>/CoherentUI_CryEngine3/samples/GameSDK/Levels/Singleplayer/ForestCOUI/CoUIFlowNodes.xml. The easiest way to use it is to open the sandbox (editor), load the provided ForestCOUI level and import the flow graph into an entity. The scene is already set up and the flowgraph adds UI and web surfaces.

As an example, we'll import the sample into CoherentBreakableEntity's flow. Select the CoherentBreakableEntity entity and click on "Create" in the Flow Graph section of the rollup bar. From the Flow Graph window, select File -> Import... and import CoUIFlowNodes.xml. Exit the Flow Graph window, save the level and export it to the engine (Ctrl+E). Now the flow graph will be used in the GameSDK, too.

Materials for game entities that render Coherent UI content

The rendering of the Coherent UI surfaces is done in a special way that is the only feasible one when using the FreeSDK. Basically, we setup a material for the entity we want to cover with a Coherent UI surface and do not use that material for anything else since its texture will be overridden. The material needs to have a texture that does not have any mip levels, or you may encounter strange blending artifacts. You can make such texture in DDS format using the DirectX texture tool that comes with the DirectX SDK.

The Coherent UI plugin comes with a few sample materials that are setup for usage with Coherent UI. Note that it is important that the texture used for a Coherent UI material should have the same dimensions as the Coherent UI View that will be overriding it. Otherwise your View will be displayed improperly.

After setting up the materials on your entity, you need to add a flownode to display Coherent UI onto it. The 2 essential nodes that you are going to use are the CoherentUI_Plugin:OutputEntity (for 3D objects) and the CoherentUI_Plugin:OutputHUD for the Camera.

A list of the available flownodes follows:

Flownodes

CoherentUI_Plugin:OutputEntity

Renders a Coherent UI View on an entity

Inputs

  • Activate Activate the node
  • Url Initial url to display on the view
  • Width Width of the view in pixels
  • Height Height of the view in pixels
  • Transparent Defines if the view should be transparent or not
  • Clickable Defines if the view should support click-through queries
  • Mesh Geometry object for calculating correct click coordinates on the entity
  • SharedMemory Defines if the view uses shared memory for the rendering data transport or shared textures

Outputs

  • ViewID Id of the view for further use (e.g. for the TriggerEvent node)

CoherentUI_Plugin:OutputHUD

Renders a Coherent UI View on the HUD

Inputs

  • Activate Activate the node
  • Path Path to the html files defining the HUD (e.g. coui://Libs/UI/hud.html)

Outputs

  • ViewID Id of the view for further use (e.g. for the TriggerEvent node)

CoherentUI_Plugin:HandleEvent

Handles an event from a Coherent UI View with an optional string and boolean parameter

Inputs

  • Activate Activate the node
  • ViewID Id of the view as obtained from one of the output nodes
  • Event The event name

Outputs

  • Arg1 String argument received from the view (optional)
  • Arg2 Boolean argument received from the view (optional)

CoherentUI_Plugin:TriggerEvent

Triggers an event on a Coherent UI View with an optional boolean parameter

Inputs

  • Activate Activate the node
  • ViewID Id of the view as obtained from one of the output nodes
  • Event The event name
  • Arg1 Boolean argument to be send to the view (optional)

CoherentUI_Plugin:TriggerEventFloat

Triggers an event on a Coherent UI View with up to four float parameter

Inputs

  • Activate Activate the node
  • ViewID Id of the view as obtained from one of the output nodes
  • Event The event name
  • Arg1 First float argument to be send to the view (optional)
  • Arg2 Second float argument to be send to the view (optional)
  • Arg3 Third float argument to be send to the view (optional)
  • Arg4 Fourth float argument to be send to the view (optional)

CoherentUI_Plugin:SendTokens

Triggers an event on a Coherent UI View that receives the JSON encoded game tokens

Inputs

  • Activate Activate the node
  • ViewID Id of the view as obtained from one of the output nodes
  • Event The event name (default: GameTokens)

CoherentUI_Plugin:SetInput

Switch input between player and Coherent UI. When enabled, all input is sent to Coherent UI and the mouse cursor is displayed.

Inputs

  • Activate Activate the node
  • Enabled Boolean argument. True enables input to Coherent UI, false disables it