Libraries.Interface.Controls.Scenes.Layers.EditorLayer3D Documentation

The EditorLayer3D class is used to show and manage objects in a 3D scene. EditorLayer3D provides a 3D grid, a cursor, and a camera preview for a 3D scene. The cursor goes along the grid and allows the user to select objects and edit them in the scene. For a 3D scene moving the editor camera affects where the camera starts when running a 3D scene.

Inherits from: Libraries.Language.Object, Libraries.Game.Layer3D, Libraries.Game.Layer, Libraries.Interface.Controls.Scenes.Layers.EditorLayer

Actions Documentation

Add(Libraries.Game.Graphics.DirectionalLight light)

This action will add the given light to the Layer3D. It will be used during lighting of all objects on the layer.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(-1, -0.5, 1)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

Add(Libraries.Game.Graphics.PointLight light)

This action will add a PointLight to the Layer3D. The Layer3D will treat it as an Item3D (respecting its position and updating it each frame) as well as using it to light up the scene.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.PointLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(6, 3, 0)
        light:SetIntensity(8)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

Add(Libraries.Interface.Item3D item)

This action will add an Item3D to this Layer. It will be updated along with the rest of the layer, and will be drawn on the screen (if it is visible and possible to draw the given Item3D). The Item3D will be added to the back of the layer's internal array of items.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Item3D objects aren't visible, but can still be used for game logic.
        Item3D area
        area:SetWidth(5)
        area:SetHeight(5)
        area:SetDepth(5)
        area:SetPosition(0, 10, 0)

        // Models inherit from Item3D, so they can be added too.
        Model cylinder
        Color color
        cylinder:LoadCylinder(2, 4, 2, color:Orange())
        cylinder:SetPosition(0, 0, 3)

        Layer3D layer
        layer:Add(area)
        layer:Add(cylinder)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

Add(integer index, Libraries.Interface.Item3D item)

This action will add an Item3D to this Layer's array of items at the index location. It will be updated along with the rest of the layer, and will be drawn on the screen (if it is visible and possible to draw the given Item3D).

Parameters

  • integer index: The index to store the item at in the layer's array of items.
  • Libraries.Interface.Item3D: The Item3D to be added to this layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Item3D objects aren't visible, but can still be used for game logic.
        Item3D area
        area:SetDimensions(5, 5, 5)
        area:SetPosition(0, 10, 10)

        // Models inherit from Item2D, so they can be added too.
        Model box
        Color color
        box:LoadBox(3, 3, 3, color:Green())
        box:SetPosition(0, 0, 2)

        Layer3D layer
        layer:Add(0, area)
        layer:Add(1, box)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

AddCollisionListener(Libraries.Interface.Events.CollisionListener3D listener)

AddCollisionListener will add a collision listener to this layer. The collision listener will be notified of collisions occuring on this layer, and is responsible for managing the collision events.

Parameters

AddGestureListener(Libraries.Interface.Events.GestureListener listener)

This action will add a GestureListener to the layer. When the layer receives a gesture event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all GestureListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.GestureListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from GestureListener.
    GestureListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddGestureListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

AddJoint(Libraries.Game.Physics.Joints.Joint3D joint)

This action will add a MouseWheelListener to the layer. When the layer receives a mouse event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all MouseWheelListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseWheelListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseWheelListener.
    MouseWheelListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseWheelListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

AddMouseListener(Libraries.Interface.Events.MouseListener listener)

This action will add a MouseListener to the layer. When the layer receives a mouse event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all MouseListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseListener.
    MouseListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

AddMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)

This action will add a MouseMovementListener to the layer. When the layer receives a mouse event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all MouseMovementListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseMovementListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseMovementListener.
    MouseMovementListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseMovementListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

AddMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)

This action will add a MouseWheelListener to the layer. When the layer receives a mouse event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all MouseWheelListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseWheelListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseWheelListener.
    MouseWheelListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseWheelListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

AddToFront(Libraries.Interface.Item3D item)

This action will add an Item3D to this layer's array of items at index 0. It will be updated along with the rest of the layer, and will be drawn on the screen (if it is visible and possible to draw the given Item3D). Adding an item to the front will cause it to be drawn and updated before other items in the layer, and other drawn items will appear to be on top of it.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Item3D objects aren't visible, but can still be used for game logic.
        Item3D area
        area:SetDimensions(5, 5, 5)
        area:SetPosition(0, 0, 5)

        // Models inherit from Item3D, so they can be added too.
        Model cylinder
        Color color
        cylinder:LoadCylinder(3, 3, 3, color:Teal())
        cylinder:SetPosition(1, 0, 1)

        Layer3D layer
        layer:AddToFront(area)
        layer:AddToFront(cylinder)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

AddTouchListener(Libraries.Interface.Events.TouchListener listener)

This action will add a TouchListener to the layer. When the layer receives a touch event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all TouchListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.TouchListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from TouchListener.
    TouchListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddTouchListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

ApplyGravity()

This action will remove a MouseWheelListener from the layer. The listener will no longer receive events from the layer. If the given MouseWheelListener is not on the layer before calling this action, then this action will have no effect.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseWheelListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseWheelListener.
    MouseWheelListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseWheelListener(myListener)
        AddLayer(layer)

        layer:RemoveMouseWheelListener(listener)
    end

    action Update(number seconds)
    end

end

AutomaticallyClearForces()

RemoveCollisionListener removes a collision listener to this layer. The collision listener will no longer be notified of collision events occurring on this layer. If the given listener is not a part of this layer, then this action will have no effect.

Return

boolean:

ClearForces()

This action will set the ambient lighting present in this Layer. If the layer already had ambient lighting, it will be overwritten.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(-1, -0.5, 1)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

DisableItemLighting(Libraries.Interface.Item3D item)

This action will disable lighting for the given Item3D (if it is a light) and any of its children (if they are lights). This action is called automatically by the Layer when adding or removing items. Most users will never need to use this action directly.

Parameters

Draw()

This action will draw all items in this Layer on the screen (if they can be drawn and they aren't hidden). If the Layer is currently hidden, then this action will do nothing. This is automatically called by the Game class as needed. Most users will never need to use this action directly.

Empty()

This action will clear all the items in this layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        Model box
        box:LoadBox(2, 2, 2, color:Red())
        box:SetPosition(0, 0, 2)

        Layer3D layer
        layer:Add(box)
        AddLayer(layer)

        layer:Empty()
    end

    action Update(number seconds)
    end
end

EnableItemLighting(Libraries.Interface.Item3D item)

This action will enable lighting for the given Item3D (if it is a light) and any of its children (if they are lights). This action is called automatically by the Layer when adding or removing items. Most users will never need to use this action directly.

Parameters

EnablePhysics(boolean flag)

This action sets the Skybox that should be used by this Layer3D. The given Skybox will be rendered behind all other items in the layer. If the given parameter is undefined, the Layer will not render a skybox. By default, the skybox is undefined.

Parameters

  • boolean flag

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Skybox

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Assuming we have 6 image files, "Sky-Right.png", "Sky-Left.png", etc.
        Skybox skybox
        skybox:Load("Sky-Right.png", "Sky-Left.png", "Sky-Up.png", "Sky-Down.png", "Sky-Forward.png", "Sky-Back.png")

        Layer3D layer = GetCurrentLayer3D()
        layer:SetSkybox(skybox)

        Skybox layerBox = layer:GetSkybox()
    end
end

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GainedSelection()

Internal action that shows the components of the editor when this layer is selected.

Get(integer index)

This action will get an Item3D stored in the layer at the given index in the layer's internal array of items.

Parameters

  • integer index: The index to retrieve an item from in the layer's array of items.

Return

Libraries.Interface.Item3D: The Item3D stored at the index in the array.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model sphere
        sphere:LoadSphere(3, 3, 3, color:White())
        sphere:SetPosition(0, 0, 2)

        Layer3D layer
        layer:Add(sphere)
        AddLayer(layer)

        Item3D item = layer:Get(0)
    end

    action Update(number seconds)
    end
end

GetAmbientLight()

This action will return the AmbientLight being used on this Layer3D. If the scene doesn't have any ambient lighting, then this action will return undefined.

Return

Libraries.Game.Graphics.AmbientLight: The AmbientLight used in the Layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(-1, -0.5, 1)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        AmbientLight returnedLight = layer:GetAmbientLight()
    end

    action Update(number seconds)
    end
end

GetAutomaticResizing()

This action returns whether or not the Layer will automatically respond to ResizeEvents. If this value is true, then the Layer will automatically adjust the camera and resize Items on the Layer when a ResizeEvent occurs.

Return

boolean:

GetCamera()

This action will return the camera being used by this Layer. The camera is used to determine what will be drawn on the screen. Objects will be drawn on the screen as they are seen by the Layer's set camera.

Return

Libraries.Game.Graphics.Camera: The camera currently being used by this layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Camera

class Main is Game

    Camera layerCamera = undefined

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layerCamera = layer:GetCamera()
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

GetCameraPitch()

This action returns the pitch of the camera in degrees.

Return

number: The pitch angle, measured in degrees.

GetCameraRoll()

This action returns the roll of the camera in degrees.

Return

number: The roll angle, measured in degrees.

GetCameraYaw()

This action returns the yaw of the camera in degrees.

Return

number: The yaw angle, measured in degrees.

GetCameraYawPitchRoll()

This action returns the yaw, pitch, and roll of the camera as a Vector3. Each value in the Vector represents the yaw, pitch, and roll in degrees.

Return

Libraries.Compute.Vector3: Vector3 containing the value of the yaw, pitch, and roll in degrees

GetCollisionList()

This action gets the list of items on this layer that are colliding and returns it as an array.

Return

Libraries.Interface.Events.CollisionEvent3D:

GetCollisionManager()

This action gets the collision manager for this object which is responsible for managing the collisions between all colliding items on this layer.

Return

Libraries.Game.Collision.CollisionManager3D:

GetCursor()

GetCursor returns the EditorCursor this layer is using.

Return

Libraries.Interface.Controls.Scenes.Items.EditorCursor: The EditorCursor this layer has

GetDirectionalLight(integer index)

This action will return a directional light stored at the given index in the Layer's array of directional lights. Each type of light stored in the Layer is kept in a separate array from other types. If there are no directional lights added to this layer, or if the index is out of bounds, this action will produce an error.

Parameters

  • integer index: The index to retrieve from the DirectionalLight array in the Layer.

Return

Libraries.Game.Graphics.DirectionalLight: The DirectionalLight stored at the given index in this Layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light1
        light1:SetColor(0.8, 0.8, 0.8, 1)
        light1:SetDirection(1, 0, 1.1)

        DirectionalLight light2
        light2:SetColor(0.8, 0.8, 0.8, 1)
        light2:SetDirection(0, -1, 0)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light1)
        layer:Add(light2)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        // This will retrieve light1, because it was added to the Layer first.
        DirectionalLight returnedLight = layer:GetDirectionalLight(0)
    end

    action Update(number seconds)
    end
end

GetDirectionalLights()

This action will get an iterator containing all of the DirectionalLights stored inside this layer.

Return

Libraries.Containers.Iterator: An iterator containing each of the DirectionalLights added to this Layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight
use Libraries.Containers.Iterator

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(-1, -0.5, 1)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        Iterator<DirectionalLight> lights = layer:GetDirectionalLights()
    end

    action Update(number seconds)
    end
end

GetEditorCamera()

This action returns the Camera of this layer. Unlike the EditorLayer2D the EditorCamera is the camera used to view the layer and not a preview visible in the layer.

Return

Libraries.Interface.Controls.Scenes.Items.EditorCamera3D: The Camera this layer is using.

GetEnvironment()

GetFromEnd()

This action will return the item stored at the end of the layer's array of items.

Return

Libraries.Interface.Item3D: The last item in the layer's array of items.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model sphere
        sphere:LoadSphere(2, 2, 2, color:Green())
        sphere:SetPosition(0, 0, 2)

        Layer3D layer
        layer:Add(sphere)
        AddLayer(layer)

        Item3D item = layer:GetFromEnd()
    end

    action Update(number seconds)
    end
end

GetFromFront()

This action will return the Item3D at the front of the layer's array of items. This is functionally the same as calling "Get(0)".

Return

Libraries.Interface.Item3D: The first item in the layer's array of items.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model cube
        cube:LoadBox(2, 2, 2, color:Yellow())
        cube:SetPosition(0, 0, 2)

        Layer3D layer
        layer:Add(cube)
        AddLayer(layer)

        Item3D item = layer:GetFromFront()
    end

    action Update(number seconds)
    end
end

GetGravity()

This action gets the collision manager for this object which is responsible for managing the collisions between all colliding items on this layer.

Return

Libraries.Compute.Vector3:

GetGrid()

This action returns the Grid3D object the layer is using

Return

Libraries.Interface.Controls.Scenes.Items.Grid3D: the grid object

GetGridUnitSize()

GetGridUnitSize returns the size of a single grid unit

Return

number: The size of a single grid unit

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetItemWithInput(number x, number y, Libraries.Containers.Array<Libraries.Game.InputSet> inputValues)

This action finds an Item on this layer which is present at the given coordinates and will respond to at least one of the given InputSets.

Parameters

Return

Libraries.Interface.Item:

GetIterator()

This action will return an iterator of all the Item3D's stored inside this layer's array of items.

Return

Libraries.Containers.Iterator: An iterator containing all Item3D's stored in this layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D
use Libraries.Containers.Iterator

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Item3D item1
        Item3D item2
        Item3D item3

        Layer3D layer
        layer:Add(item1)
        layer:Add(item2)
        layer:Add(item3)
        AddLayer(layer)

        Iterator<Item3D> itemIterator = layer:GetIterator()
    end

    action Update(number seconds)
    end
end

GetName()

This action returns the name of the Layer. This is used to identify the layer, especially in the Scene system.

Return

text:

GetNearestGridCoordinate(number coordinate)

Given a number this action returns the nearest coordinate that lies on the grid of this layer.

Parameters

  • number coordinate: The number used to calculate the grid coordinate

Return

number: The nearest coordinate on the grid

GetNextGridCoordinate(number coordinate)

Given a number this action returns the nearest coordinate on the grid of this layer that is greater than the number passed.

Parameters

  • number coordinate: The number used to calculate the grid coordinate

Return

number: The next coordinate on the grid

GetPointLight(integer index)

This action will return a point light stored at the given index in the Layer's array of point lights. Each type of light stored in the Layer is kept in a separate array from other types. If there are no directional lights added to this layer, or if the index is out of bounds, this action will produce an error.

Parameters

  • integer index: The index to retrieve from the PointLight array in the Layer.

Return

Libraries.Game.Graphics.PointLight: The PointLight stored at the given index in this Layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.PointLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        PointLight light1
        light1:SetColor(0.8, 0.8, 0.8, 1)
        light1:SetPosition(6, 3, 0)
        light1:SetIntensity(8)

        PointLight light2
        light2:SetColor(0.8, 0.8, 0.8, 1)
        light2:SetPosition(2, 3, 0)
        light2:SetIntensity(8)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light1)
        layer:Add(light2)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        // This will retrieve light1, because it was added to the Layer first.
        PointLight returnedLight = layer:GetPointLight(0)
    end

    action Update(number seconds)
    end
end

GetPointLights()

This action will get an iterator containing all of the PointLights stored inside this layer.

Return

Libraries.Containers.Iterator: An Iterator containing each of the PointLights that have been added to this Layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.PointLight
use Libraries.Game.Graphics.AmbientLight
use Libraries.Containers.Iterator

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(6, 3, 0)
        light:SetIntensity(8)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        Iterator<PointLight> lights = layer:GetPointLights()
    end

    action Update(number seconds)
    end
end

GetPreviousGridCoordinate(number coordinate)

Given a number this action returns the nearest coordinate on the grid of this layer that is less than the number passed.

Parameters

  • number coordinate: The number used to calculate the grid coordinate

Return

number: The previous coordinate on the grid

GetSceneEditor()

Returns the SceneEditor object that this layer is a part of.

Return

Libraries.Interface.Controls.Scenes.SceneEditor: The SceneEditor this layer is attached to

GetSize()

This action will return the number of items that have been added to this layer.

Return

integer: The number of items stored in this layer's array of items.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Item3D item1
        Item3D item2
        Item3D item3

        Layer3D layer
        layer:Add(item1)
        layer:Add(item2)
        layer:Add(item3)
        AddLayer(layer)

        integer size = layer:GetSize()
        output "There are " + size + " items stored in the layer."
    end

    action Update(number seconds)
    end
end

GetSkybox()

This action sets the Skybox that should be used by this Layer3D. The given Skybox will be rendered behind all other items in the layer. If the given parameter is undefined, the Layer will not render a skybox. By default, the skybox is undefined.

Return

Libraries.Game.Graphics.Skybox:

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Skybox

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Assuming we have 6 image files, "Sky-Right.png", "Sky-Left.png", etc.
        Skybox skybox
        skybox:Load("Sky-Right.png", "Sky-Left.png", "Sky-Up.png", "Sky-Down.png", "Sky-Forward.png", "Sky-Back.png")

        Layer3D layer = GetCurrentLayer3D()
        layer:SetSkybox(skybox)

        Skybox layerBox = layer:GetSkybox()
    end
end

GetViewportHeight()

This action will hide the Layer. This will prevent the Layer from appearing when asked to draw.

Return

integer:

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable square
        square:LoadFilledRectangle(200, 200)
        
        Layer2D layer
        layer:Add(square)

        AddLayer(layer)
        layer:Hide()
    end

    action Update(number seconds)
    end
end

GetViewportWidth()

This action will show the Layer. When Draw is called on a Layer which is showing, its items will appear on the screen. Layers begin showing by default.

Return

integer:

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable square
        square:LoadFilledRectangle(200, 200)
        
        Layer2D layer
        layer:Add(square)

        AddLayer(layer)
        layer:Hide()

        // Since layers are visible by default, it's only necessary to Show
        // them after they've been hidden.
        layer:Show()
    end

    action Update(number seconds)
    end
end

GetViewportX()

This action sets the viewport that will be used by this Layer. Anything drawn on this Layer will appear in a rectangle that begins x pixels from the left side of the screen, y pixels from the bottom, and has the given width and height in pixels.

Return

integer:

GetViewportY()

This action will return if the current layer is currently visible or not. Layers which are showing will be drawn on the screen automatically by the Game class. Layers begin showing by default.

Return

integer:

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable square
        square:LoadFilledRectangle(200, 200)
        
        Layer2D layer
        layer:Add(square)

        AddLayer(layer)

        boolean showing = layer:IsShowing()
        output "layer:IsShowing() returned " + showing

        layer:Hide()

        showing = layer:IsShowing()
        output "After calling Hide(), IsShowing() returned " + showing
    end

    action Update(number seconds)
    end
end

Hide()

This action will hide the Layer. This will prevent the Layer from appearing when asked to draw.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable square
        square:LoadFilledRectangle(200, 200)
        
        Layer2D layer
        layer:Add(square)

        AddLayer(layer)
        layer:Hide()
    end

    action Update(number seconds)
    end
end

IntegrateTransforms(number timeStep)

This action will remove a MouseListener from the layer. The listener will no longer receive events from the layer. If the given MouseListener is not on the layer before calling this action, then this action will have no effect.

Parameters

  • number timeStep

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseListener.
    MouseListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseListener(myListener)
        AddLayer(layer)

        layer:RemoveMouseListener(listener)
    end

    action Update(number seconds)
    end

end

IsColliding()

This allows us to know if collisions are on or off for the layer.

Return

boolean:

IsContinuousPhysics()

This action will get an iterator containing all of the PointLights stored inside this layer.

Return

boolean: An Iterator containing each of the PointLights that have been added to this Layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.PointLight
use Libraries.Game.Graphics.AmbientLight
use Libraries.Containers.Iterator

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(6, 3, 0)
        light:SetIntensity(8)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        Iterator<PointLight> lights = layer:GetPointLights()
    end

    action Update(number seconds)
    end
end

IsEmpty()

This action will return false if there are items stored in this layer's array of items, or true if there are none.

Return

boolean: Whether or not any items are stored in this layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Item3D item1
        Item3D item2
        Item3D item3

        Layer3D layer
        boolean empty = layer:IsEmpty()
        output "IsEmpty() returned " + empty

        layer:Add(item1)
        layer:Add(item2)
        layer:Add(item3)

        empty = layer:IsEmpty()
        output "After adding items, IsEmpty() returns " + empty

        AddLayer(layer)            
    end

    action Update(number seconds)
    end
end

IsGridCoordinate(number coordinate)

Returns true if the number passed would lie on the grid of this layer, false otherwise.

Parameters

  • number coordinate

Return

boolean: True if the number is on the grid, false otherwise.

IsGridSnapping()

IsGridSnapping returns if the grid snapping is enabled which for editing 2D scene correlates with whether or not the grid is visible.

Return

boolean: True if grid snapping is enabled, false otherwise

IsShowing()

This action will return if the current layer is currently visible or not. Layers which are showing will be drawn on the screen automatically by the Game class. Layers begin showing by default.

Return

boolean:

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable square
        square:LoadFilledRectangle(200, 200)
        
        Layer2D layer
        layer:Add(square)

        AddLayer(layer)

        boolean showing = layer:IsShowing()
        output "layer:IsShowing() returned " + showing

        layer:Hide()

        showing = layer:IsShowing()
        output "After calling Hide(), IsShowing() returned " + showing
    end

    action Update(number seconds)
    end
end

IsSimulationRequired()

Return

boolean:

IsSubStepping()

This action will remove all ambient lighting from the Layer.

Return

boolean:

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(-1, -0.5, 1)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        layer:RemoveAmbientLight()
    end

    action Update(number seconds)
    end
end

IsWarmStarting()

This action will return a point light stored at the given index in the Layer's array of point lights. Each type of light stored in the Layer is kept in a separate array from other types. If there are no directional lights added to this layer, or if the index is out of bounds, this action will produce an error.

Return

boolean: The PointLight stored at the given index in this Layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.PointLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        PointLight light1
        light1:SetColor(0.8, 0.8, 0.8, 1)
        light1:SetPosition(6, 3, 0)
        light1:SetIntensity(8)

        PointLight light2
        light2:SetColor(0.8, 0.8, 0.8, 1)
        light2:SetPosition(2, 3, 0)
        light2:SetIntensity(8)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light1)
        layer:Add(light2)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        // This will retrieve light1, because it was added to the Layer first.
        PointLight returnedLight = layer:GetPointLight(0)
    end

    action Update(number seconds)
    end
end

LostSelection()

Internal action that hides the components of the editor when this layer is deselected.

PhysicsEnabled()

This action sets the Skybox that should be used by this Layer3D. The given Skybox will be rendered behind all other items in the layer. If the given parameter is undefined, the Layer will not render a skybox. By default, the skybox is undefined.

Return

boolean:

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Skybox

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Assuming we have 6 image files, "Sky-Right.png", "Sky-Left.png", etc.
        Skybox skybox
        skybox:Load("Sky-Right.png", "Sky-Left.png", "Sky-Up.png", "Sky-Down.png", "Sky-Forward.png", "Sky-Back.png")

        Layer3D layer = GetCurrentLayer3D()
        layer:SetSkybox(skybox)
    end
end

ProcessGestureEvent(Libraries.Interface.Events.GestureEvent event)

This action will notify gesture listeners that are a part of this layer of the given gesture event. This is called automatically by the Game engine as needed. Most users will never need to use this action directly.

Parameters

Return

Libraries.Interface.Item:

ProcessMouseEvent(Libraries.Interface.Events.MouseEvent event)

This action will notify mouse listeners that are a part of this layer of the given mouse event. This is called automatically by the Game engine as needed. Most users will never need to use this action directly. This action is overridden here so that the input gets directed to the Layer2D.

Parameters

Return

Libraries.Interface.Item: The Item which intercepted the event, or undefined if no Item received the event.

ProcessTouchEvent(Libraries.Interface.Events.TouchEvent event)

This action will notify touch listeners that are a part of this layer of the given touch event. This is called automatically by the Game engine as needed. Most users will never need to use this action directly.

Parameters

Return

Libraries.Interface.Item:

Remove(Libraries.Game.Graphics.PointLight light)

This action will remove the given PointLight from the Layer3D. It will no longer be part of the item hierarchy of this Layer, and will no longer provide lighting in the scene.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.PointLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(6, 3, 0)
        light:SetIntensity(8)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        layer:Remove(light)
    end

    action Update(number seconds)
    end
end

Remove(Libraries.Game.Graphics.DirectionalLight light)

This action will remove the given DirectionalLight from the Layer3D.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(-1, -0.5, 1)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        layer:Remove(light)
    end

    action Update(number seconds)
    end
end

Remove(Libraries.Interface.Item3D item)

This action will remove an Item3D from this layer. If the item was not a part of this layer, this action will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Orange())
        box:SetPosition(0, 0, 2)

        Layer3D layer
        layer:Add(box)
        AddLayer(layer)

        layer:Remove(box)
    end

    action Update(number seconds)
    end
end

RemoveAmbientLight()

This action will remove all ambient lighting from the Layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(-1, -0.5, 1)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        layer:RemoveAmbientLight()
    end

    action Update(number seconds)
    end
end

RemoveAt(integer index)

This action will remove an Item3D at the index location from this layer's array of items, and return the item that was removed.

Parameters

  • integer index: The index to remove an item from in this layer's array of items.

Return

Libraries.Interface.Item3D: The item that was removed from the item array in the layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model cube
        cube:LoadBox(3, 3, 3, color:Maroon())
        cube:SetPosition(0, 0, 2)

        Layer3D layer
        layer:Add(cube)
        AddLayer(layer)

        Item3D item = layer:RemoveAt(0)
    end

    action Update(number seconds)
    end
end

RemoveCollisionListener(Libraries.Interface.Events.CollisionListener3D listener)

RemoveCollisionListener removes a collision listener to this layer. The collision listener will no longer be notified of collision events occurring on this layer. If the given listener is not a part of this layer, then this action will have no effect.

Parameters

RemoveFromEnd()

This action will remove an Item3D from the end of the array of items in this layer, and return the item that was removed.

Return

Libraries.Interface.Item3D: The item that was removed from the end of the layer's item array.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model cylinder
        cylinder:LoadCylinder(2, 4, 2, color:Pink())
        cylinder:SetPosition(0, 0, 2)

        Layer3D layer
        layer:Add(cylinder)
        AddLayer(layer)

        Item3D item = layer:RemoveFromEnd()
    end

    action Update(number seconds)
    end
end

RemoveFromFront()

This action will remove an Item3D from the front of the array of items in this layer, and return the item that was removed. This is functionally the same as calling "RemoveAt(0)".

Return

Libraries.Interface.Item3D: The item that was removed from the front of the layer's item array.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model cylinder
        cylinder:LoadCylinder(2, 4, 2, color:Pink())
        cylinder:SetPosition(0, 0, 2)

        Layer3D layer
        layer:Add(cylinder)
        AddLayer(layer)

        Item3D item = layer:RemoveFromFront()
    end

    action Update(number seconds)
    end
end

RemoveGestureListener(Libraries.Interface.Events.GestureListener listener)

This action will remove a GestureListener from the layer. The listener will no longer receive events from the layer. If the given GestureListener is not on the layer before calling this action, then this action will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.GestureListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from GestureListener.
    GestureListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddGestureListener(myListener)
        AddLayer(layer)

        layer:RemoveGestureListener(myListener)
    end

    action Update(number seconds)
    end

end

RemoveJoint(Libraries.Game.Physics.Joints.Joint3D joint)

This action will add a MouseMovementListener to the layer. When the layer receives a mouse event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all MouseMovementListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseMovementListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseMovementListener.
    MouseMovementListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseMovementListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

RemoveMouseListener(Libraries.Interface.Events.MouseListener listener)

This action will remove a MouseListener from the layer. The listener will no longer receive events from the layer. If the given MouseListener is not on the layer before calling this action, then this action will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseListener.
    MouseListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseListener(myListener)
        AddLayer(layer)

        layer:RemoveMouseListener(listener)
    end

    action Update(number seconds)
    end

end

RemoveMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)

This action will remove a MouseMovementListener from the layer. The listener will no longer receive events from the layer. If the given MouseMovementListener is not on the layer before calling this action, then this action will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseMovementListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseMovementListener.
    MouseMovementListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseMovementListener(myListener)
        AddLayer(layer)

        layer:RemoveMouseMovementListener(listener)
    end

    action Update(number seconds)
    end

end

RemoveMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)

This action will remove a MouseWheelListener from the layer. The listener will no longer receive events from the layer. If the given MouseWheelListener is not on the layer before calling this action, then this action will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseWheelListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseWheelListener.
    MouseWheelListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseWheelListener(myListener)
        AddLayer(layer)

        layer:RemoveMouseWheelListener(listener)
    end

    action Update(number seconds)
    end

end

RemoveTouchListener(Libraries.Interface.Events.TouchListener listener)

This action will remove a TouchListener from the layer. The listener will no longer receive events from the layer. If the given TouchListener is not on the layer before calling this action, then this action will have no effect.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.TouchListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from TouchListener.
    TouchListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddTouchListener(myListener)
        AddLayer(layer)

        layer:RemoveTouchListener(listener)
    end

    action Update(number seconds)
    end

end

RequireSimulation(boolean flag)

This action will get an iterator containing all of the DirectionalLights stored inside this layer.

Parameters

  • boolean flag

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight
use Libraries.Containers.Iterator

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(-1, -0.5, 1)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        Iterator<DirectionalLight> lights = layer:GetDirectionalLights()
    end

    action Update(number seconds)
    end
end

Resize(Libraries.Interface.Events.ResizeEvent event)

This action will add a MouseListener to the layer. When the layer receives a mouse event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all MouseListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseListener.
    MouseListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

SaveKinematicState(number timeStep)

This action will remove a MouseMovementListener from the layer. The listener will no longer receive events from the layer. If the given MouseMovementListener is not on the layer before calling this action, then this action will have no effect.

Parameters

  • number timeStep

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.MouseMovementListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseMovementListener.
    MouseMovementListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddMouseMovementListener(myListener)
        AddLayer(layer)

        layer:RemoveMouseMovementListener(listener)
    end

    action Update(number seconds)
    end

end

Set(integer index, Libraries.Interface.Item3D item)

This action will set the value of the given index in the layer's array of items to be the given Item3D. The previous value will be overwritten. If the index does not exist in the array (e.g., the given index is larger than the number of items stored in this layer), an error will be thrown.

Parameters

  • integer index: What index to set inside the layer's array of items.
  • Libraries.Interface.Item3D: The item to store at the given index in the array.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Item3D

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Item3D item1
        Item3D item2
        Item3D item3

        Layer3D layer
        layer:Add(item1)
        layer:Add(item2)
        layer:Set(1, item3)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

SetAmbientLight(Libraries.Game.Graphics.AmbientLight light)

This action will set the ambient lighting present in this Layer. If the layer already had ambient lighting, it will be overwritten.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(-1, -0.5, 1)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

SetAutomaticResizing(boolean resizing)

This action sets if the Layer should automatically respond to ResizeEvents. If this value is true, then the Layer will automatically adjust the camera and resize Items on the Layer when a ResizeEvent occurs.

Parameters

  • boolean resizing

SetAutomaticallyClearForces(boolean flag)

This action gets the list of items on this layer that are colliding and returns it as an array.

Parameters

  • boolean flag

SetCamera(Libraries.Game.Graphics.Camera cam)

This action will set the camera being used by this Layer. The camera is used to determine what will be drawn on the screen. Objects will be drawn on the screen as they are seen by the Layer's set camera.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.PerspectiveCamera

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        PerspectiveCamera camera
        Layer3D layer
        layer:SetCamera(camera)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

SetCameraPitch(number pitch)

The SetCameraYawPitchRoll action sets the direction and orientation of the Camera using pitch angles. All angles are in degrees. The pitch describes how far the camera is angled up or down. The pitch value should typically be between -90 and 90 degrees. Larger values will cause the camera to look in the opposite direction specified by the yaw value. For pitch values between -90 and 90, positive values angle the camera upwards, and negative values angle it downwards.

Parameters

  • number pitch: The pitch angle, measured in degrees.

SetCameraRoll(number roll)

The SetCameraYawPitchRoll action sets the direction and orientation of the Camera using roll angles. All angles are in degrees. The roll describes how the top of the camera is oriented. A roll value of 0 will angle the camera so the top of the camera points upward, towards the positive Y axis. A positive roll value "twists" the camera clockwise, and a negative value will twist it counter-clockwise.

Parameters

  • number roll: The roll angle, measured in degrees.

SetCameraYaw(number yaw)

The SetCameraYawPitchRoll action sets the direction and orientation of the Camera using yaw angles. All angles are in degrees. The yaw describes how far the camera is rotated along the X/Z axis. It effectively controls how the camera turns left and right. A positive value will rotate the camera clockwise (typically to the right).

Parameters

  • number yaw: The yaw angle, measured in degrees.

SetCameraYawPitchRoll(number yaw, number pitch, number roll)

The SetCameraYawPitchRoll action sets the direction and orientation of the Camera using yaw, pitch, and roll angles. All angles are in degrees. The yaw describes how far the camera is rotated along the X/Z axis. It effectively controls how the camera turns left and right. A positive value will rotate the camera clockwise (typically to the right). The pitch describes how far the camera is angled up or down. The pitch value should typically be between -90 and 90 degrees. Larger values will cause the camera to look in the opposite direction specified by the yaw value. For pitch values between -90 and 90, positive values angle the camera upwards, and negative values angle it downwards. The roll describes how the top of the camera is oriented. A roll value of 0 will angle the camera so the top of the camera points upward, towards the positive Y axis. A positive roll value "twists" the camera clockwise, and a negative value will twist it counter-clockwise.

Parameters

  • number yaw: The yaw angle, measured in degrees.
  • number pitch: The pitch angle, measured in degrees.
  • number roll: The roll angle, measured in degrees.

SetColliding(boolean collide)

This allows us to turn collisions on or off for the layer.

Parameters

  • boolean collide

SetContinuousPhysics(boolean flag)

This action will return a directional light stored at the given index in the Layer's array of directional lights. Each type of light stored in the Layer is kept in a separate array from other types. If there are no directional lights added to this layer, or if the index is out of bounds, this action will produce an error.

Parameters

  • boolean flag

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light1
        light1:SetColor(0.8, 0.8, 0.8, 1)
        light1:SetDirection(1, 0, 1.1)

        DirectionalLight light2
        light2:SetColor(0.8, 0.8, 0.8, 1)
        light2:SetDirection(0, -1, 0)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light1)
        layer:Add(light2)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        // This will retrieve light1, because it was added to the Layer first.
        DirectionalLight returnedLight = layer:GetDirectionalLight(0)
    end

    action Update(number seconds)
    end
end

SetGravity(Libraries.Compute.Vector3 gravity)

This action triggers collision detection for this layer during a frame in the Game engine. This action will automatically be called by the Game class as necessary. Most users should never need to use this action directly.

Parameters

SetGravity(number x, number y, number z)

This action indicates that the layer has received a new item that it must manage during collision detection. This is automatically called by the Game engine as necessary, and most users should never need to use this action directly.

Parameters

  • number x
  • number y
  • number z

SetGridSnapping(boolean enabled)

SetGridSnapping turns the grid on or off

Parameters

  • boolean enabled: If true the grid will be enabled, the grid will be hidden if false

SetGridUnitSize(number units)

SetGridUnitSize sets the size of a single grid unit which affects the size of the grid and the size of the cursor.

Parameters

  • number units: the size of a single grid unit

SetName(text name)

This action sets the name of the Layer. This is used to identify the layer, especially in the Scene system.

Parameters

  • text name

SetNewItemAdded(boolean flag)

This action indicates that the layer has received a new item that it must manage during collision detection. This is automatically called by the Game engine as necessary, and most users should never need to use this action directly.

Parameters

  • boolean flag

SetSceneEditor(Libraries.Interface.Controls.Scenes.SceneEditor editor)

Sets the SceneEditor object that this layer is a part of.

Parameters

SetScreenPositionsFromPhysicsPositions()

This action will add a TouchListener to the layer. When the layer receives a touch event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all TouchListeners in the layer will receive the event.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.TouchListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from TouchListener.
    TouchListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddTouchListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

SetSkybox(Libraries.Game.Graphics.Skybox box)

This action sets the Skybox that should be used by this Layer3D. The given Skybox will be rendered behind all other items in the layer. If the given parameter is undefined, the Layer will not render a skybox. By default, the skybox is undefined.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Skybox

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Assuming we have 6 image files, "Sky-Right.png", "Sky-Left.png", etc.
        Skybox skybox
        skybox:Load("Sky-Right.png", "Sky-Left.png", "Sky-Up.png", "Sky-Down.png", "Sky-Forward.png", "Sky-Back.png")

        Layer3D layer = GetCurrentLayer3D()
        layer:SetSkybox(skybox)
    end
end

SetSubStepping(boolean flag)

This action will return the AmbientLight being used on this Layer3D. If the scene doesn't have any ambient lighting, then this action will return undefined.

Parameters

  • boolean flag

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.DirectionalLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        DirectionalLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetDirection(-1, -0.5, 1)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        AmbientLight returnedLight = layer:GetAmbientLight()
    end

    action Update(number seconds)
    end
end

SetViewport(integer x, integer y, integer width, integer height)

This action sets the viewport that will be used by this Layer. Anything drawn on this Layer will appear in a rectangle that begins x pixels from the left side of the screen, y pixels from the bottom, and has the given width and height in pixels.

Parameters

  • integer x
  • integer y
  • integer width
  • integer height

SetViewportAndCamera(integer x, integer y, integer width, integer height)

This actions sets the viewport that will be used by this Layer, and adjusts the Layer's camera to match the dimensions of the viewport.

Parameters

  • integer x
  • integer y
  • integer width
  • integer height

SetWarmStarting(boolean flag)

AddCollisionListener will add a collision listener to this layer. The collision listener will be notified of collisions occuring on this layer, and is responsible for managing the collision events.

Parameters

  • boolean flag

Show()

This action will show the Layer. When Draw is called on a Layer which is showing, its items will appear on the screen. Layers begin showing by default.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable square
        square:LoadFilledRectangle(200, 200)
        
        Layer2D layer
        layer:Add(square)

        AddLayer(layer)
        layer:Hide()

        // Since layers are visible by default, it's only necessary to Show
        // them after they've been hidden.
        layer:Show()
    end

    action Update(number seconds)
    end
end

ShowCursor(boolean visible)

Shows or hides the cursor based on the passed parameter.

Parameters

  • boolean visible: If true the cursor will be shown, hidden otherwise.

ShowEditorComponents(boolean shouldShow)

ShowEditorComponents toggles the editor components which consists of the grid, and the cursor. When toggled off they will be hidden. When toggled on the grid will be visible in the editor.

Parameters

  • boolean shouldShow

SolvePhysics(number seconds)

This action will add a GestureListener to the layer. When the layer receives a gesture event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all GestureListeners in the layer will receive the event.

Parameters

  • number seconds

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.GestureListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from GestureListener.
    GestureListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddGestureListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

StepPhysics(number seconds)

This action will remove the given PointLight from the Layer3D. It will no longer be part of the item hierarchy of this Layer, and will no longer provide lighting in the scene.

Parameters

  • number seconds

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Game.Graphics.Model
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.PointLight
use Libraries.Game.Graphics.AmbientLight

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model box
        box:LoadBox(2, 2, 2, color:Green())
        box:SetPosition(4, 0, 2)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(6, 3, 0)
        light:SetIntensity(8)

        AmbientLight ambient
        ambient:SetColor(0.4, 0.4, 0.4, 1)

        Layer3D layer
        layer:Add(box)
        layer:Add(light)
        layer:SetAmbientLight(ambient)
        AddLayer(layer)

        layer:Remove(light)
    end

    action Update(number seconds)
    end
end

SynchronizeTransforms()

This action will remove a TouchListener from the layer. The listener will no longer receive events from the layer. If the given TouchListener is not on the layer before calling this action, then this action will have no effect.

Example

use Libraries.Game.Game
use Libraries.Game.Layer3D
use Libraries.Interface.Events.TouchListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from TouchListener.
    TouchListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer3D layer
        layer:AddTouchListener(myListener)
        AddLayer(layer)

        layer:RemoveTouchListener(listener)
    end

    action Update(number seconds)
    end

end

TestForCollisions(number seconds)

This action triggers collision detection for this layer during a frame in the Game engine. This action will automatically be called by the Game class as necessary. Most users should never need to use this action directly.

Parameters

  • number seconds

Update(number seconds)

Update is called by the Game loop every frame. This action resizes the viewport to fit the Layer so resizing the Game doesn't leave unused space in the EditorLayer.

Parameters

  • number seconds