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

Summary

Variable Summary Table

VariablesDescription
text DIFFUSE_ALIAS
text EMISSIVE_ALIAS
Libraries.Game.Graphics.Color color
text REFLECTION_ALIAS
text FOG_ALIAS
text AMBIENT_ALIAS
text SPECULAR_ALIAS
text AMBIENT_LIGHT_ALIAS

Actions Summary Table

ActionsDescription
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns a CompareResult.
Copy()The Copy action returns a new Attribute that is a copy of this ColorAttribute object.
CreateAmbient(Libraries.Game.Graphics.Color setColor)The CreateAmbient action will create a new ColorAttribute using the Ambient value.
CreateAmbient(number red, number green, number blue, number alpha)The CreateAmbient action will create a new ColorAttribute using the Ambient value.
CreateAmbientLight(number red, number green, number blue, number alpha)The CreateAmbientLight action will create a new ColorAttribute using the AmbientLight value.
CreateAmbientLight(Libraries.Game.Graphics.Color setColor)The CreateAmbientLight action will create a new ColorAttribute using the AmbientLight value.
CreateDiffuse(number red, number green, number blue, number alpha)The CreateDiffuse action will create a new ColorAttribute using the Diffuse value.
CreateDiffuse(Libraries.Game.Graphics.Color setColor)The CreateDiffuse action will create a new ColorAttribute using the Diffuse value.
CreateEmissive(number red, number green, number blue, number alpha)The CreateEmissive action will create a new ColorAttribute using the Emissive value.
CreateEmissive(Libraries.Game.Graphics.Color setColor)The CreateEmissive action will create a new ColorAttribute using the Emissive value.
CreateFog(number red, number green, number blue, number alpha)The CreateFog action will create a new ColorAttribute using the Fog value.
CreateFog(Libraries.Game.Graphics.Color setColor)The CreateFog action will create a new ColorAttribute using the Fog value.
CreateReflection(Libraries.Game.Graphics.Color setColor)The CreateReflection action will create a new ColorAttribute using the Reflection value.
CreateReflection(number red, number green, number blue, number alpha)The CreateReflection action will create a new ColorAttribute using the Reflection value.
CreateSpecular(Libraries.Game.Graphics.Color setColor)The CreateSpecular action will create a new ColorAttribute using the Specular value.
CreateSpecular(number red, number green, number blue, number alpha)The CreateSpecular action will create a new ColorAttribute using the Specular value.
Equals(Libraries.Game.Graphics.Attribute other)This action will test to see if two Attributes are of the same type.
Equals(Libraries.Language.Object object)This action determines if the given object is equal to this Attribute.
GetAmbientLightValue()This action returns the integer value representing an AmbientLight color attribute.
GetAmbientValue()This action returns the integer value representing an Ambient color attribute.
GetAttributeAlias(integer type)GetAttributeAlias will take an integer code for a particular type of Attribute and return a text alias representing that type.
GetAttributeType(text alias)GetAttributeType will take a text alias for a particular type of Attribute and return an integer code representing that type.
GetColorAttributeMask()Returns the sum of all color attribute values.
GetDiffuseValue()This action returns the integer value representing a Diffuse color attribute.
GetEmissiveValue()This action returns the integer value representing an Emissive color attribute.
GetFogValue()This action returns the integer value representing a Fog color attribute.
GetHashCode()This action gets the hash code for an object.
GetReflectionValue()This action returns the integer value representing a Reflection color attribute.
GetSpecularValue()This action returns the integer value representing a Specular color attribute.
HashCode()This action will return a hash code that identifies an Attribute by its type.
SetAttribute(integer setType, Libraries.Game.Graphics.Color setColor)The SetAttribute action is used to set the type and color of this ColorAttribute.
SetAttribute(integer setType)SetAttribute will set data used by this Attribute.
SupportsAttribute(integer type)This action returns whether or not the given attribute type is supported by the ColorAttribute class.

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

Example Code

use Libraries.Language.Support.CompareResult
        Object o
        Object t
        CompareResult result = o:Compare(t)

Parameters

Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

Copy()

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

Example Code

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

Return

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

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.

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

Parameters

Return

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

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.

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

Parameters

Return

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

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.

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

        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

Parameters

Return

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

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.

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

        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

Parameters

Return

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

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.

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

Parameters

Return

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

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.

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

Parameters

Return

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

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.

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

        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

Parameters

Return

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

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.

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

        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

Parameters

Return

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

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

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

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.

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

Parameters

Return

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

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.

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

Parameters

Return

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

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.

Example Code

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

Parameters

Return

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

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.

Example Code

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

Return

integer: An integer code representing an AmbientLight ColorAttribute.

GetAmbientValue()

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

Example Code

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

Return

integer: An integer code representing an Ambient ColorAttribute.

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.

Example Code

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

Parameters

Return

text: A text alias representing the described Attribute type.

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.

Example Code

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

Parameters

Return

integer: An integer code representing the described Attribute type.

GetColorAttributeMask()

Returns the sum of all color attribute values.

Example Code

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

Return

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

GetDiffuseValue()

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

Example Code

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

Return

integer: An integer code representing a Diffuse ColorAttribute.

GetEmissiveValue()

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

Example Code

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

Return

integer: An integer code representing an Emissive ColorAttribute.

GetFogValue()

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

Example Code

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

Return

integer: An integer code representing a Fog ColorAttribute.

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.

GetReflectionValue()

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

Example Code

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

Return

integer: An integer code representing a Reflection ColorAttribute.

GetSpecularValue()

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

Example Code

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

Return

integer: An integer code representing a Specular ColorAttribute.

HashCode()

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

Example Code

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

Return

integer:

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.

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

Parameters

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

SupportsAttribute(integer type)

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

Example Code

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

Parameters

Return

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