-- 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 meshscene_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 constantlytimer_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.
A group holds node ids so move, rotate, and visible apply to all of them.
Parameters
#
Name
Type
Description
1
group_id
ID
This 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 visiblevisible(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
#
Name
Type
Description
1
group_id
String
Group identifier. This can be obtained from the group_add function
2 .. n
node_id
Object
A reference to a gui object. This can be a button_id, switch_id, dial_id, image_id, txt_id or map_id
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
#
Name
Type
Description
1
node_id
ID
Node identifier. This number can be obtained by calling functions like img_add or txt_add.
2
x
Number
(Optional) This is the most left point of the canvas where your object should be shown.
3
y
Number
(Optional) This is the most top point of the canvas where your object should be shown.
4
width
Number
(Optional) The new width of the object.
5
height
Number
(Optional) The new height of the object
6
animation_type
String
(Optional) Can be 'OFF', 'LINEAR' or 'LOG'.
7
animation_speed
Float
(Optional) Animation speed. Between 1.0 (Fastest) and 0.0 (Slowest)
Example
-- Slide the off flag out of the windowmove(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
#
Name
Type
Description
1
node_id
ID
Node identifier. This number can be obtained by calling functions like img_add or txt_add.
2
visible
Boolean
True if image should make visible, False if it should be hidden.
Example
-- Hide the glide-slope pointer until we are on an ILSvisible(gs_pointer, false)
Turns a node around its center, or around an instrument-space anchor. LINEAR and LOG ease the turn.
Parameters
#
Name
Type
Description
1
node_id
ID
Node identifier. This number can be obtained by calling functions like img_add, txt_add or canvas_add.
2
degrees
Number
Number of degrees to rotate the object to.
3
anchor_x
Number
(Optional) Rotate around this X coordinate.
4
anchor_y
Number
(Optional) Rotate around this Y coordinate.
5
anchor_z
Number
(Optional) Rotate around this Z coordinate.
6
animation_type
String
(Optional) Can be 'OFF', 'LINEAR' or 'LOG'.
7
animation_speed
Float
(Optional) Animation speed. Between 1.0 (Fastest) and 0.0 (Slowest)
8
animation_direction
String
(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 panelrotate(needle, alt_deg, 120, 120, nil, "LINEAR", 0.6, "FASTEST")
Example: a jump, and a sweep
-- Jump the needle to 90rotate(needle, 90)
-- Later turns take the short way, on a log curverotate(needle, nil, nil, nil, nil, nil, nil)
rotate(needle, 10, 120, 120, nil, "LOG", 0.5, "FASTEST")
-- 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 shapeviewport_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
#
Name
Type
Description
1
node_id
ID
Node identifier. This can be obtained by calling functions like dial_add or switch_add.
2
property
String
Setting property.
3
value
Object
The 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 dialmouse_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
#
Name
Type
Description
1
node_id
ID
Node identifier. This can be obtained by calling functions like dial_add or switch_add.
2
property
String
Setting property.
3
value
Object
The 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 degreestouch_setting(dial_id , "ROTATE_TICK", 90)
-- We do not want to show highlighting on this dialtouch_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
#
Name
Type
Description
1
node_id
ID
Node identifier. This can be obtained from the instrument_get or layer_add function.
2
order
Number
The order. Lowest value is drawn at the back, highest is drawn on the top. The panel root lua is always drawn at order 0.