Skip to content

Communication between the CLI and OGrEE 3D

Cédric Vautrain edited this page Dec 18, 2023 · 16 revisions

OGrEE-3D is listening to the TCP port 5500.

All data are given with a simple json structure:

{
  "type" : "keyword",
  "data" : <serialized corresponding data structure>
}

The keyword will identify which type of data is given, in order to deserialize it with the corresponding structure. Data content will always be a serialized structure or the id of the concerned object.

Login

{
  "type" : "login",
  "data" : <login data>
}
  • login data:
{
  "api_url" : "",
  "api_token : ""
}

These values will override/replace the ones given in config.json.

Load a template

Corresponding CLI command here.

{
  "type" : "load template",
  "data" : <JSON of the template>
}

JSON Template structure is described here.

Hierarchy commands

Select an object

Corresponding CLI command here

{
  "type" : "select",
  "data" : "id of the object to select"
}

Delete an object

Corresponding CLI command here

{
  "type" : "delete",
  "data" : "id of the object to delete"
}

Focus an object

Corresponding CLI command here

{
  "type" : "focus",
  "data" : "id of the object to focus"
}

Objects manipulation

Create commands

Corresponding CLI commands here

{
  "type" : "create",
  "data" : <JSON of the created object>
}

JSON object structure is described here.

Set commands

Corresponding CLI command here

Modify an object

{
  "type" : "modify",
  "data" : <JSON of the updated object>
}

JSON object structure is described here

Interact with an object

Some keywords are used only for interacting with OGrEE 3D

{
  "type" : "interact",
  "data" : <interact instruction>
}
  • Structure of an interact data:
{
  "id"    : "id of the targeted object",  //eg: "rackId"
  "param" : "The interaction keyword",    //eg: "slots"
  "value" : "The value to set"            //eg: "false"
}

Manipulate UI

Corresponding CLI commands here

{
  "type" : "ui",
  "data" : <UI instruction>
}

Possible UI instructions:

Delay

{
  "command" : "delay",
  "data"    : "time" 
}

Infos panel

{
  "command" : "infos",
  "data"    : "true|false" 
}

Debug panel

{
  "command" : "debug",
  "data"    : "true|false" 
}

Highlight an object

{
  "command" : "highlight",
  "data"    : "id of the object to highlight" 
}

Clear cache

{
  "command" : "clearcache",
  "data" : ""
}

Manipulate camera

Corresponding CLI commands here

{
  "type" : "camera",
  "data" : <camera instruction>
}

A camera instruction is:

{
  "command"  : "",
  "position" : <Serialized Vector3>,
  "rotation" : <Serialized Vector2>
}

Possible camera instructions:

Move

{
  "command"  : "move",
  "position" : "{"x":posX, "y":posY, "z":posZ}",
  "rotation" : "{"x":rotX, "y":rotY}"
}

Translate

{
  "command"  : "translate",
  "position" : "{"x":posX, "y":posY, "z":posZ}",
  "rotation" : "{"x":rotX, "y":rotY}"
}

Wait

{
  "command"  : "wait",
  "position" : "{"x":0, "y":0, "z":0}",
  "rotation" : "{"x":999, "y":time}"
}

This one is a "hack" to keep the same data structure as the other camera commands: rotation.x = 999 is used as a keycode for rotation.y = time to wait.

Tags

Modify

{
  "type" : "modify-tag",
  "data" : 
    {
        "old-slug" : ""
        "tag" : <JSON of the updated tag>
    }
}

Delete

{
    "type" : "delete-tag",
    "data" : "tag-slug"
}

Layers

Create

  "type" : "create-layer",
  "data" : <JSON of the created layer>

Modify

{
  "type" : "modify-layer",
  "data" : 
    {
        "old-slug" : ""
        "layer" : <JSON of the updated layer>
    }
}

Delete

{
    "type" : "delete-layer",
    "data" : "layer-slug"
}