Libraries.Game.Graphics.ColorAttribute Documentation

The ColorAttribute class represents a single visual property of a 3D object or scene which can be described as a color.

Example Code

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

class Main is Game

Model sphere

action Main
    StartGame()
end

action CreateGame
    Color color
    //Model sphere
    sphere:LoadSphere(2, 2, 2, color:Purple())
    Add(sphere)

    AmbientLight ambient
    ambient:SetColor(0.6, 0.6, 0.6, 1)
    SetAmbientLight(ambient)
    
    PointLight light
    light:SetColor(0.8, 0.8, 0.8, 1)
    light:SetPosition(-3, 1, -3)
    light:SetIntensity(15)
    Add(light)

    Model orbiter
    orbiter:LoadSphere(1, 1, 1, color:Orange())
    orbiter:SetPosition(-3, 0, 0)
    sphere:Add(orbiter)

    // When loading a primitive, the resulting Model will contain a single
    // material in the array returned by GetMaterials().
    Array<Material> materials = sphere:GetMaterials()
    Material material = materials:Get(0)

    Array<Material> orbiterMaterials = orbiter:GetMaterials()
    Material orbiterMaterial = orbiterMaterials:Get(0)

    // By adding a specular color attribute to each of these materials, the
    // models will now reflect specular light.
    ColorAttribute specular
    specular:SetAttribute(specular:GetSpecularValue(), color:White())
    material:Add(specular)
    orbiterMaterial:Add(specular)
end

action Update(number seconds)
    // Rotating the Models will help us see the added specular attribute at work.
    sphere:Rotate(0, 1, 0, 30 * seconds)
end
end

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

Variables Table

VariablesDescription
text REFLECTION_ALIAS
integer AMBIENT_LIGHT
text DIFFUSE_ALIAS
integer FOG
text AMBIENT_ALIAS
text FOG_ALIAS
integer DIFFUSE
integer BITMASKThe CreateAmbient action will create a new ColorAttribute using the Ambient value. This attribute can be added to the Material of a Model to set its ambient color. Note that although the Game engine infrastructure will allow for use of this type of Attribute, the rendering step does not currently support it. The AmbientLight attribute, however, is functional and serves a similar purpose.
integer EMISSIVE
text AMBIENT_LIGHT_ALIAS
text SPECULAR_ALIAS
integer AMBIENT
integer SPECULAR
Libraries.Game.Graphics.Color color
integer REFLECTION
text EMISSIVE_ALIAS

Actions Documentation

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)

Copy()

The Copy action returns a new Attribute that is a copy of this ColorAttribute object.

Return

Libraries.Game.Graphics.Attribute: A new Attribute that is a copy of this object.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.ColorAttribute
use Libraries.Game.Graphics.Attribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        ColorAttribute attribute
        attribute:SetAttribute(attribute:GetDiffuseValue(), color:Green())
        Attribute copy = attribute:Copy()
    end
end

CreateAmbient(Libraries.Game.Graphics.Color setColor)

The CreateAmbient action will create a new ColorAttribute using the Ambient value. This attribute can be added to the Material of a Model to set its ambient color. Note that although the Game engine infrastructure will allow for use of this type of Attribute, the rendering step does not currently support it. The AmbientLight attribute, however, is functional and serves a similar purpose.

Parameters

Return

Libraries.Game.Graphics.ColorAttribute: A ColorAttribute set with the Ambient value.

Example

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

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model sphere
        sphere:LoadSphere(2, 2, 2, color:Orange())
        Add(sphere)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(20)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = sphere:GetMaterials()
        Material material = materials:Get(0)

        ColorAttribute attribute
        ColorAttribute ambient = attribute:CreateAmbient(color:Green())
        material:Add(ambient)
    end
end

CreateAmbient(number red, number green, number blue, number alpha)

The CreateAmbient action will create a new ColorAttribute using the Ambient value. This attribute can be added to the Material of a Model to set its ambient color. Note that although the Game engine infrastructure will allow for use of this type of Attribute, the rendering step does not currently support it. The AmbientLight attribute, however, is functional and serves a similar purpose.

Parameters

  • number red: The red component of the color value to use for the ambient attribute.
  • number green: The green component of the color value to use for ambient attribute.
  • number blue: The blue component of the color value to use for ambient attribute.
  • number alpha: The alpha component of the color value to use for ambient attribute.

Return

Libraries.Game.Graphics.ColorAttribute: A ColorAttribute set with the Ambient value.

Example

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

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model sphere
        sphere:LoadSphere(2, 2, 2, color:Orange())
        Add(sphere)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(20)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = sphere:GetMaterials()
        Material material = materials:Get(0)

        ColorAttribute attribute
        ColorAttribute ambient = attribute:CreateAmbient(0, 1, 0, 1)
        material:Add(ambient)
    end
end

CreateAmbientLight(number red, number green, number blue, number alpha)

The CreateAmbientLight action will create a new ColorAttribute using the AmbientLight value. This attribute can be added to an Environment to set the ambient lighting for a scene, or added directly to the Material of a Model to set the ambient lighting for just that Model.

Parameters

  • number red: The red component of the color to use for ambient lighting.
  • number green: The green component of the color to use for ambient lighting.
  • number blue: The blue component of the color to use for ambient lighting.
  • number alpha: The alpha component of the color to use for ambient lighting.

Return

Libraries.Game.Graphics.ColorAttribute: A ColorAttribute set with the AmbientLight value.

Example

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

class Main is Game

    action Main
        StartGame()
    end

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

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(15)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = box:GetMaterials()
        Material material = materials:Get(0)

        // Adding an ambient light to the Model directly will make sure that,
        // regardless of the light in the scene, the box always has at least as
        // much color as the ambient light value. This will override the scene's
        // normal ambient lighting for this object, if there is any.
        ColorAttribute attribute
        ColorAttribute ambientLight = attribute:CreateAmbientLight(0.5, 0.5, 0.5, 1)
        material:Add(ambientLight)
    end
end

CreateAmbientLight(Libraries.Game.Graphics.Color setColor)

The CreateAmbientLight action will create a new ColorAttribute using the AmbientLight value. This attribute can be added to an Environment to set the ambient lighting for a scene, or added directly to the Material of a Model to set the ambient lighting for just that Model.

Parameters

Return

Libraries.Game.Graphics.ColorAttribute: A ColorAttribute set with the AmbientLight value.

Example

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

class Main is Game

    action Main
        StartGame()
    end

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

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(15)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = box:GetMaterials()
        Material material = materials:Get(0)

        // Adding an ambient light to the Model directly will make sure that,
        // regardless of the light in the scene, the box always has at least as
        // much color as the ambient light value. This will override the scene's
        // normal ambient lighting for this object, if there is any.
        ColorAttribute attribute
        ColorAttribute ambientLight = attribute:CreateAmbientLight(color:Gray())
        material:Add(ambientLight)
    end
end

CreateDiffuse(number red, number green, number blue, number alpha)

The CreateDiffuse action will create a new ColorAttribute using the Diffuse value. This attribute can be added to the Material of a Model. Doing so will make the faces of the Model appear to be the given diffuse color.

Parameters

  • number red: The red component of the color value to use for the diffuse attribute.
  • number green: The green component of the color value to use for diffuse attribute.
  • number blue: The blue component of the color value to use for diffuse attribute.
  • number alpha: The alpha component of the color value to use for diffuse attribute.

Return

Libraries.Game.Graphics.ColorAttribute: A ColorAttribute set with the Diffuse value.

Example

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

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model sphere
        sphere:LoadSphere(2, 2, 2, color:Orange())
        Add(sphere)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(20)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = sphere:GetMaterials()
        Material material = materials:Get(0)

        ColorAttribute attribute
        // When we loaded our Model as an orange sphere, the Model's
        // material was already given a diffuse attribute with an orange
        // color. By adding another one with a different color, we overwrite
        // the old color.
        ColorAttribute diffuse = attribute:CreateDiffuse(0, 1, 1, 1)
        material:Add(diffuse)
    end
end

CreateDiffuse(Libraries.Game.Graphics.Color setColor)

The CreateDiffuse action will create a new ColorAttribute using the Diffuse value. This attribute can be added to the Material of a Model. Doing so will make the faces of the Model appear to be the given diffuse color.

Parameters

Return

Libraries.Game.Graphics.ColorAttribute: A ColorAttribute set with the Diffuse value.

Example

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

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model sphere
        sphere:LoadSphere(2, 2, 2, color:Orange())
        Add(sphere)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(20)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = sphere:GetMaterials()
        Material material = materials:Get(0)

        ColorAttribute attribute
        // When we loaded our Model as an orange sphere, the Model's
        // material was already given a diffuse attribute with an orange
        // color. By adding another one with a different color, we overwrite
        // the old color.
        ColorAttribute diffuse = attribute:CreateDiffuse(color:Cyan())
        material:Add(diffuse)
    end
end

CreateEmissive(number red, number green, number blue, number alpha)

The CreateEmissive action will create a new ColorAttribute using the Emissive value. This attribute can be added to the Material of a Model to give the Model a "glow", as if emitting light. Note that although the Game engine infrastructure will allow for use of this type of Attribute, the rendering step does not currently support emissive lighting.

Parameters

  • number red: The red component of the color value to use for the emissive attribute.
  • number green: The green component of the color value to use for emissive attribute.
  • number blue: The blue component of the color value to use for emissive attribute.
  • number alpha: The alpha component of the color value to use for emissive attribute.

Return

Libraries.Game.Graphics.ColorAttribute: A ColorAttribute set with the Emissive value.

Example

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

class Main is Game

    action Main
        StartGame()
    end

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

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(15)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = box:GetMaterials()
        Material material = materials:Get(0)

        ColorAttribute attribute
        ColorAttribute emissive = attribute:CreateEmissive(0.8, 0.8, 0.8, 1)
        material:Add(emissive)
    end
end

CreateEmissive(Libraries.Game.Graphics.Color setColor)

The CreateEmissive action will create a new ColorAttribute using the Emissive value. This attribute can be added to the Material of a Model to give the Model a "glow", as if emitting light. Note that although the Game engine infrastructure will allow for use of this type of Attribute, the rendering step does not currently support emissive lighting.

Parameters

Return

Libraries.Game.Graphics.ColorAttribute: A ColorAttribute set with the Emissive value.

Example

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

class Main is Game

    action Main
        StartGame()
    end

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

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(15)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = box:GetMaterials()
        Material material = materials:Get(0)

        ColorAttribute attribute
        ColorAttribute emissive = attribute:CreateEmissive(color:White())
        material:Add(emissive)
    end
end

CreateFog(number red, number green, number blue, number alpha)

The CreateFog action will create a new ColorAttribute using the Fog value. This can be applied to an Environment to make distant objects appear obscured (i.e., there is fog between the object and the viewer). Note that although the Game engine infrastructure will allow for use of this type of Attribute, the rendering step does not currently support it.

Parameters

  • number red: The red component of the reflective color.
  • number green: The green component of the reflective color.
  • number blue: The blue component of the reflective color.
  • number alpha: The alpha component of the reflective color.

Return

Libraries.Game.Graphics.ColorAttribute:

CreateFog(Libraries.Game.Graphics.Color setColor)

The CreateFog action will create a new ColorAttribute using the Fog value. This can be applied to an Environment to make distant objects appear obscured (i.e., there is fog between the object and the viewer). Note that although the Game engine infrastructure will allow for use of this type of Attribute, the rendering step does not currently support it.

Parameters

Return

Libraries.Game.Graphics.ColorAttribute:

CreateReflection(Libraries.Game.Graphics.Color setColor)

The CreateReflection action will create a new ColorAttribute using the Reflection value. This attribute is meant to be used in conjunction with a reflection TextureAttribute. The two used together signify the color of the reflected scene and the visual appearance of the reflection, respectively. Note that although the Game engine infrastructure will allow for use of this type of Attribute, the rendering step does not currently support it.

Parameters

Return

Libraries.Game.Graphics.ColorAttribute:

CreateReflection(number red, number green, number blue, number alpha)

The CreateReflection action will create a new ColorAttribute using the Reflection value. This attribute is meant to be used in conjunction with a reflection TextureAttribute. The two used together signify the color of the reflected scene and the visual appearance of the reflection, respectively. Note that although the Game engine infrastructure will allow for use of this type of Attribute, the rendering step does not currently support it.

Parameters

  • number red: The red component of the reflective color.
  • number green: The green component of the reflective color.
  • number blue: The blue component of the reflective color.
  • number alpha: The alpha component of the reflective color.

Return

Libraries.Game.Graphics.ColorAttribute:

CreateSpecular(Libraries.Game.Graphics.Color setColor)

The CreateSpecular action will create a new ColorAttribute using the Specular value. This attribute can be added to the Material of a Model to give the Model specular highlighting - most typically seen as a shiny spot reflecting light brightly, similar to a shiny metallic object.

Parameters

Return

Libraries.Game.Graphics.ColorAttribute: A ColorAttribute set with the Specular value.

Example

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

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model sphere
        sphere:LoadSphere(2, 2, 2, color:Orange())
        Add(sphere)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(20)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = sphere:GetMaterials()
        Material material = materials:Get(0)

        ColorAttribute attribute
        // Typically, specular lighting looks best when it's set to white,
        // but to make it easier to distinguish from the normal lighting in
        // the scene, we set it to green in this example.
        ColorAttribute specular = attribute:CreateSpecular(color:Green())
        material:Add(specular)
    end
end

CreateSpecular(number red, number green, number blue, number alpha)

The CreateSpecular action will create a new ColorAttribute using the Specular value. This attribute can be added to the Material of a Model to give the Model specular highlighting - most typically seen as a shiny spot reflecting light brightly, similar to a shiny metallic object.

Parameters

  • number red: The red component of the color value to use for the specular attribute.
  • number green: The green component of the color value to use for specular attribute.
  • number blue: The blue component of the color value to use for specular attribute.
  • number alpha: The alpha component of the color value to use for specular attribute.

Return

Libraries.Game.Graphics.ColorAttribute: A ColorAttribute set with the Specular value.

Example

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

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model sphere
        sphere:LoadSphere(2, 2, 2, color:Orange())
        Add(sphere)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(20)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = sphere:GetMaterials()
        Material material = materials:Get(0)

        ColorAttribute attribute
        // Typically, specular lighting looks best when it's set to white,
        // but to make it easier to distinguish from the normal lighting in
        // the scene, we set it to green in this example.
        ColorAttribute specular = attribute:CreateSpecular(0, 1, 0, 1)
        material:Add(specular)
    end
end

Equals(Libraries.Game.Graphics.Attribute other)

This action will test to see if two Attributes are of the same type. Note that it will not test if the contents of the Attributes are the same.

Parameters

Return

boolean: Whether or not the two attributes are of the same type.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.ColorAttribute
use Libraries.Game.Graphics.Attribute
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color

        // Using the ColorAttribute class, which inherits from Attribute.
        ColorAttribute attribute1

        attribute1:SetAttribute(attribute1:GetDiffuseValue(), color:Green())
        Attribute attribute2 = attribute1:Copy()

        output "attribute1 = attribute2 is " + attribute1:Equals(attribute2)

    end
end

Equals(Libraries.Language.Object object)

This action determines if the given object is equal to this Attribute.

Parameters

Return

boolean: True if the object is an Attribute with the same type, otherwise it returns false.

GetAmbientLightValue()

This action returns the integer value representing an AmbientLight color attribute.

Return

integer: An integer code representing an AmbientLight ColorAttribute.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.ColorAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        ColorAttribute attribute

        integer value = attribute:GetAmbientLightValue()
        attribute:SetAttribute(value, color:Green())
    end
end

GetAmbientValue()

This action returns the integer value representing an Ambient color attribute.

Return

integer: An integer code representing an Ambient ColorAttribute.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.ColorAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        ColorAttribute attribute

        integer value = attribute:GetAmbientValue()
        attribute:SetAttribute(value, color:Green())
    end
end

GetAttributeAlias(integer type)

GetAttributeAlias will take an integer code for a particular type of Attribute and return a text alias representing that type. Each class that inherits from Attribute will contain a series of actions that will return an integer code for a given type. The contents of this Attribute are not considered during this action, and can be ignored.

Parameters

  • integer type: An integer code describing an Attribute type.

Return

text: A text alias representing the described Attribute type.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.TextureAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Using the TextureAttribute class, which inherits from Attribute.
        TextureAttribute attribute
        text alias = attribute:GetAttributeAlias(attribute:GetDiffuseValue())

        output "The alias for a diffuse TextureAttribute is " + alias
    end
end

GetAttributeType(text alias)

GetAttributeType will take a text alias for a particular type of Attribute and return an integer code representing that type. Each class that inherits from Attribute will contain a series of public constant text fields that contain an alias for a given type. The contents of this Attribute are not considered during this action, and can be ignored.

Parameters

  • text alias: A text alias describing an Attribute type.

Return

integer: An integer code representing the described Attribute type.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.TextureAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Using the TextureAttribute class, which inherits from Attribute.
        TextureAttribute attribute
        integer code = attribute:GetAttributeType(attribute:DIFFUSE_ALIAS)

        output "The type code for a diffuse TextureAttribute is " + code
    end
end

GetColorAttributeMask()

Returns the sum of all color attribute values.

Return

integer: The sum of all integer codes of attribute types supported by this class.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.ColorAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        ColorAttribute attribute

        integer mask = attribute:GetColorAttributeMask()

        output "The ColorAttribute's mask is " + mask + "."
    end
end

GetDiffuseValue()

This action returns the integer value representing a Diffuse color attribute.

Return

integer: An integer code representing a Diffuse ColorAttribute.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.ColorAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        ColorAttribute attribute

        integer value = attribute:GetDiffuseValue()
        attribute:SetAttribute(value, color:Green())
    end
end

GetEmissiveValue()

This action returns the integer value representing an Emissive color attribute.

Return

integer: An integer code representing an Emissive ColorAttribute.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.ColorAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        ColorAttribute attribute

        integer value = attribute:GetEmissiveValue()
        attribute:SetAttribute(value, color:Green())
    end
end

GetFogValue()

This action returns the integer value representing a Fog color attribute.

Return

integer: An integer code representing a Fog ColorAttribute.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.ColorAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        ColorAttribute attribute

        integer value = attribute:GetFogValue()
        attribute:SetAttribute(value, color:Green())
    end
end

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()

GetReflectionValue()

This action returns the integer value representing a Reflection color attribute.

Return

integer: An integer code representing a Reflection ColorAttribute.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.ColorAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        ColorAttribute attribute

        integer value = attribute:GetReflectionValue()
        attribute:SetAttribute(value, color:Green())
    end
end

GetSpecularValue()

This action returns the integer value representing a Specular color attribute.

Return

integer: An integer code representing a Specular ColorAttribute.

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.ColorAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        ColorAttribute attribute

        integer value = attribute:GetSpecularValue()
        attribute:SetAttribute(value, color:Green())
    end
end

GetType()

This action returns an integer code representing what type is stored in this Attribute. This can be compared against results from the GetAttributeType(text) action to more precisely determine what the meaning behind the code is.

Return

integer: An integer code representing this Attribute's type.

HashCode()

This action will return a hash code that identifies an Attribute by its type.

Return

integer:

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.ColorAttribute
use Libraries.Game.Graphics.Attribute
use Libraries.Game.Graphics.Color

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Using the ColorAttribute class, which inherits from Attribute.
        ColorAttribute attribute
        Color green
        green:SetColor(0, 1, 0, 1)
        attribute:SetAttribute(attribute:GetDiffuseValue(), green)

        output "The hash code for the attribute is " + attribute:GetHashCode()
    end
end

SetAttribute(integer setType, Libraries.Game.Graphics.Color setColor)

The SetAttribute action is used to set the type and color of this ColorAttribute. The type should be set using one of the actions in this class that provide a type code, such as GetSpecularValue or GetDiffuseValue.

Parameters

  • integer setType: An integer code representing the type of this Attribute.
  • Libraries.Game.Graphics.Color: The color to use for this ColorAttribute.

Example

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

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Color color
        Model sphere
        sphere:LoadSphere(2, 2, 2, color:Orange())
        Add(sphere)

        PointLight light
        light:SetColor(0.8, 0.8, 0.8, 1)
        light:SetPosition(-3, 2, -3)
        light:SetIntensity(20)
        Add(light)

        // When loading a primitive, the resulting Model will contain a single
        // material in the array returned by GetMaterials().
        Array<Material> materials = sphere:GetMaterials()
        Material material = materials:Get(0)

        ColorAttribute attribute
        attribute:SetAttribute(attribute:GetSpecularValue(), color:Green())
        material:Add(attribute)
    end
end

SetAttribute(integer setType)

SetAttribute will set data used by this Attribute. Note that most classes which inherit from Attribute will have their own implementations of SetAttribute which may require different parameters - e.g., to use SetAttribute in the ColorAttribute class, it requires both an integer type, but also a color. Most users should not use this action directly.

Parameters

  • integer setType: The type to set this Attribute to.

SupportsAttribute(integer type)

This action returns whether or not the given attribute type is supported by the ColorAttribute class.

Parameters

  • integer type: An integer code representing an Attribute type.

Return

boolean: Whether or not the given Attribute type is supported by the ColorAttribute class.

Example


use Libraries.Game.Game
use Libraries.Game.Graphics.ColorAttribute

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        ColorAttribute attribute
        boolean supports = attribute:SupportsAttribute(attribute:GetDiffuseValue())
        output "The value of supports is " + supports
    end
end