Libraries.Game.Graphics.Environment Documentation

The Environment class is a set of Attributes that specifically handles lighting.

Inherits from: Libraries.Language.Object, Libraries.Game.Graphics.Attributes

Summary

Actions Summary Table

ActionsDescription
Add(Libraries.Game.Graphics.PointLight light)Adds a PointLight to this environment.
Add(Libraries.Containers.Array<Libraries.Game.Graphics.Light> array)This action will add an array of lights to the environment.
Add(Libraries.Game.Graphics.AmbientLight light)This action will add ambient lighting to the Environment.
Add(Libraries.Game.Graphics.Attributes attributes)This action will add all of the attribute objects stored in the given Attributes object to this Attributes object.
Add(Libraries.Game.Graphics.DirectionalLight light)Adds a DirectionalLight to this environment.
Add(Libraries.Game.Graphics.Attribute attribute)This action will add an Attribute to this Attributes object.
Add(Libraries.Game.Graphics.Light light)This action will add a light to the environment.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
ContainsLighting()This action will return whether the Environment currently contains any lighting elements.
Disable(integer disableMask)This action will disable the given type (or multiple types, if combined using the Or operation of the BitwiseOperations class) in this Attributes object.
Empty()This action removes all Attribute objects from this Attributes object.
Enable(integer enableMask)This action will enable the given type (or multiple types, if combined using the Or operation of the BitwiseOperations class) in this Attributes object.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetAmbientLight()Gets the AmbientLight set for this environment.
GetAttribute(integer type)This action returns the Attribute stored within this Attributes object with the given type.
GetAttributeArray()This action returns the array of Attribute objects contained within this Attributes object.
GetDirectionalLightIterator()This action returns an iterator containing all of the DirectionLights in the environment.
GetHashCode()This action gets the hash code for an object.
GetMask()This action returns an integer mask containing the combined integer code values of each Attribute type present in this Attributes object.
GetSize()This action returns the number of Attribute objects that are currently part of this Attributes object.
GetTypeIndex(integer type)This action will identify the index of a given Attribute type.
HasAttribute(integer type)This action tests if the given Attribute type is currently a part of this Attributes object.
Remove(Libraries.Game.Graphics.DirectionalLight light)This action will remove the given DirectionalLight from the Environment.
Remove(integer mask)This action will remove an Attribute of the given Attribute type from this Attributes object, or remove multiple Attribute objects if the integer code provided is the combined values of multiple Attribute types.
Remove(Libraries.Game.Graphics.Light light)This action will remove a light from the environment.
Remove(Libraries.Containers.Array<Libraries.Game.Graphics.Light> array)This action will remove each light that is present in the given array from the Environment.
Remove(Libraries.Game.Graphics.PointLight light)This action will remove the given PointLight from the Environment.
Remove(Libraries.Game.Graphics.AmbientLight light)This action will remove all ambient lighting from this Environment.
RemoveAmbientLight()This action will remove all ambient lighting from this Environment.

Actions Documentation

Add(Libraries.Game.Graphics.PointLight light)

Adds a PointLight to this environment.

Parameters

Add(Libraries.Containers.Array<Libraries.Game.Graphics.Light> array)

This action will add an array of lights to the environment. Each light must be usable by the Environment. The Environment can use DirectionalLight and PointLight.

Parameters

Add(Libraries.Game.Graphics.AmbientLight light)

This action will add ambient lighting to the Environment.

Parameters

Add(Libraries.Game.Graphics.Attributes attributes)

This action will add all of the attribute objects stored in the given Attributes object to this Attributes object.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array
    use Libraries.Game.Graphics.AmbientLight
    use Libraries.Game.Graphics.DirectionalLight
    use Libraries.Game.Graphics.Attributes

    class Main is Game

        Model sphere

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            sphere:LoadSphere(3, 3, 3, color:Orange())
            Add(sphere)

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

            DirectionalLight light
            light:SetColor(0.8, 0.8, 0.8, 1)
            light:SetDirection(0, -1, 1)
            Add(light)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = sphere:GetMaterials()

            integer counter = 0

            repeat while counter < materialsArray:GetSize()
                Material material = materialsArray:Get(counter)

                Attributes newAttributes

                ColorAttribute specularAttribute
                specular

Parameters

Add(Libraries.Game.Graphics.DirectionalLight light)

Adds a DirectionalLight to this environment.

Parameters

Add(Libraries.Game.Graphics.Attribute attribute)

This action will add an Attribute to this Attributes object.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array
    use Libraries.Game.Graphics.AmbientLight
    use Libraries.Game.Graphics.DirectionalLight

    class Main is Game

        Model sphere

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            sphere:LoadSphere(3, 3, 3, color:Orange())
            Add(sphere)

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

            DirectionalLight light
            light:SetColor(0.8, 0.8, 0.8, 1)
            light:SetDirection(0, -1, 1)
            Add(light)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = sphere:GetMaterials()

            integer counter = 0

            repeat while counter < materialsArray:GetSize()
                Material material = materialsArray:Get(counter)

                ColorAttribute colorAttribute
                color

Parameters

Add(Libraries.Game.Graphics.Light light)

This action will add a light to the environment. It can accept any light that inherits from Light as a parameter, but the Environment can only use lights that are either DirectionalLight or PointLight. If the given light can't be used by the Environment, an error will be alerted.

Parameters

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.

Example Code

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

Parameters

Return

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

ContainsLighting()

This action will return whether the Environment currently contains any lighting elements. An Environment that contains no lighting elements will be ignored during rendering.

Return

boolean:

Disable(integer disableMask)

This action will disable the given type (or multiple types, if combined using the Or operation of the BitwiseOperations class) in this Attributes object.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array

    class Main is Game

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            Model box
            box:LoadBox(1, 1, 1, color:Purple())
            Add(box)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = box:GetMaterials()

            output "The box is using " + materialsArray:GetSize() + " material(s)."

            integer counter = 0
            ColorAttribute colorAttribute

            // We store the Diffuse value from the ColorAttribute class. Each type
            // of attribute has a unique code that identifies the Attribute. This
            // particular code represents the Diffuse color attribute.
            integer diffuseValue = color

Parameters

Empty()

This action removes all Attribute objects from this Attributes object.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array

    class Main is Game

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            Model box
            box:LoadBox(1, 1, 1, color:Purple())
            Add(box)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = box:GetMaterials()

            output "The box is using " + materialsArray:GetSize() + " material(s)."

            integer counter = 0

            repeat while counter < materialsArray:GetSize()
                Material material = materialsArray:Get(counter)

                // This will remove all the Attribute objects being used by the Material.
                material:Empty()

                counter = counter + 1
            end
        end
    end

Enable(integer enableMask)

This action will enable the given type (or multiple types, if combined using the Or operation of the BitwiseOperations class) in this Attributes object.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array

    class Main is Game

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            Model box
            box:LoadBox(1, 1, 1, color:Purple())
            Add(box)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = box:GetMaterials()

            output "The box is using " + materialsArray:GetSize() + " material(s)."

            integer counter = 0
            ColorAttribute colorAttribute

            // We store the Diffuse value from the ColorAttribute class. Each type
            // of attribute has a unique code that identifies the Attribute. This
            // particular code represents the Diffuse color attribute.
            integer diffuseValue = color

Parameters

Equals(Libraries.Language.Object object)

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

Example Code

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

Parameters

Return

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

GetAmbientLight()

Gets the AmbientLight set for this environment. If none is set, will return undefined.

Return

Libraries.Game.Graphics.AmbientLight:

GetAttribute(integer type)

This action returns the Attribute stored within this Attributes object with the given type. If no such Attribute has been stored in this object, it will return undefined.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array

    class Main is Game

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            Model box
            box:LoadBox(1, 1, 1, color:Purple())
            Add(box)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = box:GetMaterials()

            output "The box is using " + materialsArray:GetSize() + " material(s)."

            integer counter = 0
            ColorAttribute colorAttribute

            // We store the Diffuse value from the ColorAttribute class. Each type
            // of attribute has a unique code that identifies the Attribute. This
            // particular code represents the Diffuse color attribute.
            integer diffuseValue = color

Parameters

Return

Libraries.Game.Graphics.Attribute: An attribute of the requested type, or undefined if the Attribute wasn't contained in this object.

GetAttributeArray()

This action returns the array of Attribute objects contained within this Attributes object.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array
    use Libraries.Game.Graphics.Attribute

    class Main is Game

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            Model box
            box:LoadBox(1, 1, 1, color:Purple())
            Add(box)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = box:GetMaterials()

            integer counter = 0
            ColorAttribute colorAttribute

            // We store the Diffuse value from the ColorAttribute class. Each type
            // of attribute has a unique code that identifies the Attribute. This
            // particular code represents the Diffuse color attribute.
            integer diffuseValue = color

Return

Libraries.Containers.Array: An array containing each Attribute object stored by this object.

GetDirectionalLightIterator()

This action returns an iterator containing all of the DirectionLights in the environment.

Return

Libraries.Containers.Iterator:

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetMask()

This action returns an integer mask containing the combined integer code values of each Attribute type present in this Attributes object. The codes are combined using bitwise Or operations.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array
    use Libraries.Compute.BitwiseOperations

    class Main is Game

        action Main
            StartGame()
        end

        action CreateGame
            BitwiseOperations bits
            Color color

            Model box
            box:LoadBox(1, 1, 1, color:Purple())
            Add(box)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = box:GetMaterials()

            output "The box is using " + materialsArray:GetSize() + " material(s)."

            integer counter = 0
            ColorAttribute colorAttribute

            // We store the Diffuse value from the ColorAttribute class. Each type
            // of attribute has a unique code that identifies the Attribute. This
            // particular code represents the Diffuse color attribute.
            integer diffuseValue = color

Return

integer: An integer mask formed by using bitwise Or on all of the Attribute codes in this Attributes object.

GetSize()

This action returns the number of Attribute objects that are currently part of this Attributes object.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array

    class Main is Game

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            Model box
            box:LoadBox(1, 1, 1, color:Purple())
            Add(box)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = box:GetMaterials()

            output "The box is using " + materialsArray:GetSize() + " material(s)."

            integer counter = 0

            repeat while counter < materialsArray:GetSize()
                Material material = materialsArray:Get(counter)

                output "Material " + counter + " has " + material:GetSize() + " attribute(s)."

                counter = counter + 1
            end
        end
    end

Return

integer: The number of Attribute objects contained in this object.

GetTypeIndex(integer type)

This action will identify the index of a given Attribute type. If the Attributes object does not currently have the given type, -1 will be returned.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array
    use Libraries.Game.Graphics.Attribute

    class Main is Game

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            Model box
            box:LoadBox(1, 1, 1, color:Purple())
            Add(box)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = box:GetMaterials()

            integer counter = 0
            ColorAttribute colorAttribute

            // We store the Diffuse value from the ColorAttribute class. Each type
            // of attribute has a unique code that identifies the Attribute. This
            // particular code represents the Diffuse color attribute.
            integer diffuseValue = color

Parameters

Return

integer: The index of the Attribute of the requested type, or -1 if there was none.

HasAttribute(integer type)

This action tests if the given Attribute type is currently a part of this Attributes object. A boolean value is returned based on the result.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array

    class Main is Game

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            Model box
            box:LoadBox(1, 1, 1, color:Purple())
            Add(box)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = box:GetMaterials()

            output "The box is using " + materialsArray:GetSize() + " material(s)."

            integer counter = 0
            ColorAttribute colorAttribute

            // We store the Diffuse value from the ColorAttribute class. Each type
            // of attribute has a unique code that identifies the Attribute. This
            // particular code represents the Diffuse color attribute.
            integer diffuseValue = color

Parameters

Return

boolean: Whether or not this object contains an Attribute of the given type.

Remove(Libraries.Game.Graphics.DirectionalLight light)

This action will remove the given DirectionalLight from the Environment. If the light was not present in the Environment before using this action, it will have no effect.

Parameters

Remove(integer mask)

This action will remove an Attribute of the given Attribute type from this Attributes object, or remove multiple Attribute objects if the integer code provided is the combined values of multiple Attribute types.

Example Code

use Libraries.Game.Game
    use Libraries.Game.Graphics.Model
    use Libraries.Game.Graphics.Color
    use Libraries.Game.Graphics.Material
    use Libraries.Game.Graphics.ColorAttribute
    use Libraries.Containers.Array

    class Main is Game

        action Main
            StartGame()
        end

        action CreateGame
            Color color

            Model box
            box:LoadBox(1, 1, 1, color:Purple())
            Add(box)

            // The Material class inherits from Attributes. Whenever a user wants to
            // manipulate the attributes being used in a game, they will most likely
            // be working with a Material object.
            Array<Material> materialsArray = box:GetMaterials()

            output "The box is using " + materialsArray:GetSize() + " material(s)."

            integer counter = 0
            ColorAttribute colorAttribute

            // We store the Diffuse value from the ColorAttribute class. Each type
            // of attribute has a unique code that identifies the Attribute. This
            // particular code represents the Diffuse color attribute.
            integer diffuseValue = color

Parameters

Remove(Libraries.Game.Graphics.Light light)

This action will remove a light from the environment. The given light must be usable by the Environment, i.e. it is a DirectionalLight or PointLight. If the given light was not a part of the Environment before using Remove, nothing will happen.

Parameters

Remove(Libraries.Containers.Array<Libraries.Game.Graphics.Light> array)

This action will remove each light that is present in the given array from the Environment. Each light must be usable by the Environment, i.e., it is a DirectionalLight or PointLight. Otherwise, an error will be alerted. Lights that are present in the array but not in the Environment will have no effect.

Parameters

Remove(Libraries.Game.Graphics.PointLight light)

This action will remove the given PointLight from the Environment. If the light was not present in the Environment before using this action, it will have no effect.

Parameters

Remove(Libraries.Game.Graphics.AmbientLight light)

This action will remove all ambient lighting from this Environment.

Parameters

RemoveAmbientLight()

This action will remove all ambient lighting from this Environment.