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.<