Simulation Instruments

Home›All functions›Scene and group

Scene and group

Simulation Instrument Studio 1

scene_add

Simulation Instrument Studio 1

Overloads

scene_add(x, y, width, height)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1xNumberThis is the most left point of the scene.
2yNumberThis is the most top point of the scene.
3widthNumberThe scene width in pixels.
4heightNumberThe scene height in pixels.

Example

-- A mesh in the attitude scene
id = scene_add()
Photo slot: shots/scene_add.png

cene_camera_ad

Simulation Instrument Studio 1

Overloads

scene_camera_add(scene_id)

Create a camera object.

Parameters

#NameTypeDescription
1scene_idIDScene id. Can be created by calling scene_add

Example

-- Create scene
scene_id = scene_add(0, 0, 512, 512)

-- Create camera node
camera_id = scene_camera_add(scene_id)
camera_node = scene_node_add(scene_id, camera_id)
scene_node_move(camera_node, 0, 0.5)

-- Create light node
light_node = scene_node_add(scene_id, scene_light_add(scene_id))

-- Create a mesh (this is the 3d object shape)
mesh_id = scene_mesh_add(scene_id, "sphere.obj")

-- Create material (this is the texture which will be drawn on top of the mesh)
material_id = scene_material_add(scene_id, "my_texture.png")

-- Attach the material to the mesh
scene_mesh_set_material(mesh_id, material_id)

-- Create a node from the generated mesh above
node_id = scene_node_add(scene_id, mesh_id)

-- This node can be translated, rotated, scaled etc.
scene_node_move(node_id, nil, nil, -180)
scene_node_scale(node_id, 40, 40, 40)
scene_node_rotate(node_id, nil, 270, nil)

-- Create viewport
viewport_id = scene_viewport_add(scene_id, camera_id)

-- Rotate constantly
timer_start(0, 1, function(count)
    scene_node_rotate(node_id, 1 / 10, 1 / 10, 1 / 10)
end)
Photo slot: shots/cene_camera_ad.png

scene_light_add

Simulation Instrument Studio 1

Overloads

scene_light_add(scene_id)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1scene_idIDScene id. Can be created by calling scene_add

Example

-- A mesh in the attitude scene
id = scene_light_add()
Photo slot: shots/scene_light_add.png

scene_material_add

Simulation Instrument Studio 1

Overloads

scene_material_add(scene_id, resource)
scene_material_add(scene_id, resource, scroll_u, scroll_v, scale_u, scale_v, angle)
scene_material_add(scene_id, w, h, draw_callback)
scene_material_add(scene_id, w, h, draw_callback, scroll_u, scroll_v, scale_u, scale_v, angle)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1scene_idIDScene id. Can be created by calling scene_add
2resourceStringPNG or JPEG file in which to convert to a material.
3scroll_uNumberX scroll (move) of the material in pixels.
4scroll_vNumberY scroll (move) of the material in pixels.
5scale_uNumberX scale of the material in pixels.
6scale_vNumberY scale of the material in pixels.
7angleNumberRotation of the material in degrees.

Example

-- A mesh in the attitude scene
id = scene_material_add()
Photo slot: shots/scene_material_add.png

scene_mesh_add

Simulation Instrument Studio 1

Overloads

scene_mesh_add(scene_id, resource)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1scene_idIDScene id. Can be created by calling scene_add
2resourceString.stl of .obj file in which to convert to the mesh.

Example

-- A mesh in the attitude scene
id = scene_mesh_add()
Photo slot: shots/scene_mesh_add.png

scene_mesh_set_material

Simulation Instrument Studio 1

Overloads

scene_mesh_set_material(mesh_id, material_id)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1mesh_idIDMesh id. Can be created by calling scene_mesh_add
2material_idIDMaterial id. Can be created by calling scene_material_add

Example

-- A mesh in the attitude scene
id = scene_mesh_set_material()
Photo slot: shots/scene_mesh_set_material.png

scene_node_add

Simulation Instrument Studio 1

Overloads

scene_node_add(scene_id)
scene_node_add(scene_id, attach_object)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1scene_idIDScene id. Can be created by calling scene_add
2object_idcamera_id, light_id, mesh_id(Optional) Attach existing camera, light or mesh object to the node.

Example

-- A mesh in the attitude scene
id = scene_node_add()
Photo slot: shots/scene_node_add.png

scene_node_attach

Simulation Instrument Studio 1

Overloads

scene_node_attach(scene_node_id, attach_object)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1scene_node_idIDScene node id. Can be created by calling scene_node_add
2object_idcamera_id, light_id, mesh_id(Optional) Attach existing camera, light or mesh object to the node.

Example

-- A mesh in the attitude scene
id = scene_node_attach()
Photo slot: shots/scene_node_attach.png

scene_node_move

Simulation Instrument Studio 1

Overloads

scene_node_move(scene_node_id, x, y, z)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1scene_node_idIDScene node id. Can be created by calling scene_node_add
2xNumberMove object on x axis. Can be nil.
3yNumberMove object on y axis. Can be nil.
4zNumberMove object on z axis. Can be nil.

Example

-- A mesh in the attitude scene
id = scene_node_move()
Photo slot: shots/scene_node_move.png

scene_node_rotate

Simulation Instrument Studio 1

Overloads

scene_node_rotate(scene_node_id, x, y, z)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1scene_node_idIDScene node id. Can be created by calling scene_node_add
2xNumberRotate object on x axis. Can be nil.
3yNumberRotate object on y axis. Can be nil.
4zNumberRotate object on z axis. Can be nil.

Example

-- A mesh in the attitude scene
id = scene_node_rotate()
Photo slot: shots/scene_node_rotate.png

scene_node_scale

Simulation Instrument Studio 1

Overloads

scene_node_scale(scene_node_id, x, y, z)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1scene_node_idIDScene node id. Can be created by calling scene_node_add
2xNumberScale object on x axis. Can be nil.
3yNumberScale object on y axis. Can be nil.
4zNumberScale object on z axis. Can be nil.

Example

-- A mesh in the attitude scene
id = scene_node_scale()
Photo slot: shots/scene_node_scale.png

scene_viewport_add

Simulation Instrument Studio 1

Overloads

scene_viewport_add(scene_id)

A 3D scene call. Meshes load from OBJ or glTF and draw into a canvas.

Parameters

#NameTypeDescription
1scene_idIDScene id. Can be created by calling scene_add

Example

-- A mesh in the attitude scene
id = scene_viewport_add()
Photo slot: shots/scene_viewport_add.png

group_ad

Simulation Instrument Studio 1

Overloads

group_add(node_id, node_id, ...)

A group holds node ids so move, rotate, and visible apply to all of them.

Parameters

#NameTypeDescription
1group_idIDThis value can be used for further reference. Functions such as visible can use this group_id. Its good practice to store this group_id in your logic code.

Example

function click(var)
end

-- Make some GUI objects, In this case a switch, button and a dial
button_id = button_add("off.png",nil,50,50,145,145,click)
switch_id = switch_add("off.png","on.png","off.png","on.png",50,200,145,145,click)
dial_id = dial_add("on.png",200,200,145,145,click)

-- Group them together
group_id = group_add(button_id, switch_id,  dial_id)

-- Make the entire group not visible
visible(group_id,false)
Photo slot: shots/group_ad.png

group_obj_add

Simulation Instrument Studio 1

Overloads

group_obj_add(group_id, gui_id, ...)

A group holds node ids so move, rotate, and visible apply to all of them.

Parameters

#NameTypeDescription
1group_idStringGroup identifier. This can be obtained from the group_add function
2 .. nnode_idObjectA reference to a gui object. This can be a button_id, switch_id, dial_id, image_id, txt_id or map_id

Example

-- Face and needle move together
group_obj_add(altimeter, face)
group_obj_add(altimeter, needle)
Photo slot: shots/group_obj_add.png

group_obj_remove

Simulation Instrument Studio 1

Overloads

group_obj_remove(group_id, gui_id, ...)

A group holds node ids so move, rotate, and visible apply to all of them.

Parameters

#NameTypeDescription
1group_idStringGroup identifier. This can be obtained from the group_add function.
2 .. nnode_idObjectA reference to a gui object. This can be a button_id, switch_id, dial_id, image_id, txt_id or map_id

Example

group_obj_remove(altimeter, flag)
Photo slot: shots/group_obj_remove.png

move

Simulation Instrument Studio 1

Overloads

move(node_id, x)
move(node_id, x, y)
move(node_id, x, y, width)
move(node_id, x, y, width, height)
move(node_id, x, y, width, height, animation_type)
move(node_id, x, y, width, height, animation_type, animation_speed)

Moves a node, or a group, in instrument pixels. LINEAR and LOG ease to the new place.

Parameters

#NameTypeDescription
1node_idIDNode identifier. This number can be obtained by calling functions like img_add or txt_add.
2xNumber(Optional) This is the most left point of the canvas where your object should be shown.
3yNumber(Optional) This is the most top point of the canvas where your object should be shown.
4widthNumber(Optional) The new width of the object.
5heightNumber(Optional) The new height of the object
6animation_typeString(Optional) Can be 'OFF', 'LINEAR' or 'LOG'.
7animation_speedFloat(Optional) Animation speed. Between 1.0 (Fastest) and 0.0 (Slowest)

Example

-- Slide the off flag out of the window
move(flag, 240, 90, "LINEAR", 0.4)

Example: a jump, and a slide

-- Jump the flag. nil leaves width and height alone.
move(flag, 200, 40)

-- Ease it back. Later moves use this easing.
move(flag, nil, nil, nil, nil, "LOG", 0.3)
move(flag, 20, 40)
Photo slot: shots/move.png

visible

Simulation Instrument Studio 1

Overloads

visible(node_id,visible)

Shows or hides a node.

Parameters

#NameTypeDescription
1node_idIDNode identifier. This number can be obtained by calling functions like img_add or txt_add.
2visibleBooleanTrue if image should make visible, False if it should be hidden.

Example

-- Hide the glide-slope pointer until we are on an ILS
visible(gs_pointer, false)
Photo slot: shots/visible.png

rotate

Simulation Instrument Studio 1

Overloads

rotate(node_id, degrees)
rotate(node_id, degrees, anchor_x, anchor_y, anchor_z)
rotate(node_id, degrees, animation_type, animation_speed)
rotate(node_id, degrees, animation_type, animation_speed, animation_direction)
rotate(node_id, degrees, anchor_x, anchor_y, anchor_z, animation_type, animation_speed, animation_direction)

Turns a node around its center, or around an instrument-space anchor. LINEAR and LOG ease the turn.

Parameters

#NameTypeDescription
1node_idIDNode identifier. This number can be obtained by calling functions like img_add, txt_add or canvas_add.
2degreesNumberNumber of degrees to rotate the object to.
3anchor_xNumber(Optional) Rotate around this X coordinate.
4anchor_yNumber(Optional) Rotate around this Y coordinate.
5anchor_zNumber(Optional) Rotate around this Z coordinate.
6animation_typeString(Optional) Can be 'OFF', 'LINEAR' or 'LOG'.
7animation_speedFloat(Optional) Animation speed. Between 1.0 (Fastest) and 0.0 (Slowest)
8animation_directionString(Optional) Can be 'DIRECT', 'CW', 'CCW', 'FASTEST' or 'SLOWEST'. Default is 'DIRECT'. The 'DIRECT' mode will use the absolute rotation value (so it you go from 0 to 720 it will make two full rotations). All others will use the relative position (from 0 720 won't do anything since they are the same angle).

Example

-- Needle around the instrument center, not the panel
rotate(needle, alt_deg, 120, 120, nil, "LINEAR", 0.6, "FASTEST")

Example: a jump, and a sweep

-- Jump the needle to 90
rotate(needle, 90)

-- Later turns take the short way, on a log curve
rotate(needle, nil, nil, nil, nil, nil, nil)
rotate(needle, 10, 120, 120, nil, "LOG", 0.5, "FASTEST")
Photo slot: shots/rotate.png

opacity

Simulation Instrument Studio 1

Overloads

opacity(node_id, opacity)
opacity(node_id, opacity, animation_type)
opacity(node_id, opacity, animation_type, animation_speed)

Sets how solid a node is, from 0 to 1. LINEAR and LOG ease the change.

Parameters

#NameTypeDescription
1node_idIDNode identifier. This number can be obtained by calling functions like img_add or txt_add.
2opacityFloatRanges from 0.0 (Transparent) to 1.0 (Opaque).
3animation_typeString(Optional) Can be 'OFF', 'LINEAR' or 'LOG'.
4animation_speedFloat(Optional) Animation speed. Between 1.0 (Fastest) and 0.0 (Slowest)

Example

-- Dim the whole face for night
opacity(face, 0.45, "LOG", 0.3)

Example: a jump, and a fade

opacity(face, 0.4)
opacity(face, nil, "LOG", 0.3)
opacity(face, 1.0)
Photo slot: shots/opacity.png

viewport_rect

Simulation Instrument Studio 1

Overloads

viewport_rect(node_id,x,y,width,height)

Clips a node to a rectangle, in instrument pixels.

Parameters

#NameTypeDescription
1node_idIDThe node id of which the viewport should be applied.
2xNumberThis is the most left point of the canvas where the viewport starts.
3yNumberThis is the most top point of the canvas where the viewport starts.
4widthNumberThe width of the viewport.
5heightNumberThe height of the viewport.

Example

-- Only the drum window shows. The rest of the tape is clipped.
viewport_rect(tape, 150, 80, 70, 48)
Photo slot: shots/viewport_rect.png

viewport_shape

Simulation Instrument Studio 1

Overloads

viewport_shape(node_id, draw_fuction)

Clips a node to a path.

Parameters

#NameTypeDescription
1node_idIDThe node id of which the viewport should be applied.
2draw_functionFunctionDefine your shape inside this draw function. See the calls below

Calls you can use in the shape

_move_to, _line_to, _bezier_to, _quad_to, _arc, _arc_to, _rect, _circle, _ellipse.

Example

-- Create a blue rectangle using canvas. (Note that in this case we use canvas, viewport_shape can be used on all node types like text, images, dial etc.)
canvas_id = canvas_add(0, 0, 200, 200, function()
  _rect(0, 0, 100, 100)
  _fill("blue")
end)

-- Define a shape in which we look at this blue box, in this case through a circle shape
viewport_shape(canvas_id, function()
    _circle(80, 80, 50)
end)
Photo slot: shots/viewport_shape.png

mouse_setting

Simulation Instrument Studio 1

Overloads

mouse_setting(node_id,property,value)

Sets how the node receives mouse input.

Parameters

#NameTypeDescription
1node_idIDNode identifier. This can be obtained by calling functions like dial_add or switch_add.
2propertyStringSetting property.
3valueObjectThe value to set for the property. The type of value depends on the chosen property.

Example

function callback(direction)
  print("dial has been turned")
end

dial_id = dial_add("a.png", 100,100,100,100,callback)

-- We want to set our custom cursors for this dial
mouse_setting(dial_id , "CURSOR_LEFT", "cursor_left.png")
mouse_setting(dial_id , "CURSOR_RIGHT", "cursor_right.png")
Photo slot: shots/mouse_setting.png

touch_setting

Simulation Instrument Studio 1

Overloads

touch_setting(node_id,property,value)

Sets how the node receives touch input.

Parameters

#NameTypeDescription
1node_idIDNode identifier. This can be obtained by calling functions like dial_add or switch_add.
2propertyStringSetting property.
3valueObjectThe value to set for the property. The type of value depends on the chosen property.

Example

function callback(direction)
  print("dial has been turned another 90 degrees")
end

dial_id = dial_add("a.png", 100,100,100,100,callback)

-- We want to get a dial tick every 90 degrees
touch_setting(dial_id , "ROTATE_TICK", 90)

-- We do not want to show highlighting on this dial
touch_setting(dial_id , "SHOW_HIGHLIGHT", false)
Photo slot: shots/touch_setting.png

z_order

Simulation Instrument Studio 1

Overloads

z_order(node_id, order)

Sets the draw order. Higher draws later.

Parameters

#NameTypeDescription
1node_idIDNode identifier. This can be obtained from the instrument_get or layer_add function.
2orderNumberThe order. Lowest value is drawn at the back, highest is drawn on the top. The panel root lua is always drawn at order 0.

Example

-- Needle above the face
z_order(needle, 2)
Photo slot: shots/z_order.png