Parcourir la source

Merge pull request #1297 from seanpaultaylor/next

Updated removing shadow interfaces in Model.
Sean Taylor il y a 12 ans
Parent
commit
9290ca669d

+ 41 - 41
README.md

@@ -1,41 +1,41 @@
-## GamePlay v2.0.0
-
-GamePlay3D is an open-source, cross-platform 3D native C++ game framework making it easy to learn and write mobile and desktop games. 
-
-<img align="right" src="https://raw.github.com/wiki/blackberry/GamePlay/img/logo.png" alt="gameplay3d" />
-
-- [Website](http://www.gameplay3d.org/)
-- [Forums](http://www.gameplay3d.org/forums/)
-- [Wiki](https://github.com/blackberry/GamePlay/wiki)
-- [API Reference](http://blackberry.github.io/GamePlay/api/index.html)
-- [Development Guide](https://github.com/blackberry/GamePlay/wiki#wiki-Development_Guide)
-
-## Supported Platforms
-- [Microsoft Windows](https://github.com/blackberry/GamePlay/wiki/Visual-Studio-Setup) (using Microsoft Visual Studio)
-- [Apple MacOS X](https://github.com/blackberry/GamePlay/wiki/Apple-Xcode-Setup) (using Apple XCode)
-- [Linux](https://github.com/blackberry/GamePlay/wiki/Linux-Setup) (using CMake)
-- [Apple iOS](https://github.com/blackberry/GamePlay/wiki/Apple-Xcode-Setup) (using Apple XCode)
-- [Google Android](https://github.com/blackberry/GamePlay/wiki/Android-NDK-Setup) (using Google Android NDK)
-- [BlackBerry](https://github.com/blackberry/GamePlay/wiki/BlackBerry-Setup) (using BlackBerry Native SDK)
-
-## Roadmap for 'next' branch
-- [2.0.0](https://github.com/blackberry/GamePlay/issues?milestone=6&page=1&state=open)
-- [backlog](https://github.com/blackberry/GamePlay/issues?milestone=5&page=1&state=open)
-
-## License
-The project is open sourced under the [Apache 2.0 license](http://www.tldrlegal.com/license/apache-license-2.0-%28apache-2.0%29).
-
-## Bug Reporting
-Please log bugs under [Issues](https://github.com/blackberry/GamePlay/issues) on github.
-If you are unsure if your problem is a bug then post on the [Help Forum](http://www.gameplay3d.org/forums/viewforum.php?f=3).
-
-## Feature Requests
-Please post feature requests on the [Feature Request Forum](http://www.gameplay3d.org/forums/viewforum.php?f=4). Approved feature requests will be added to the github backlog issues list. 
-
-## Disclaimer
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
-INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 
-OTHER DEALINGS IN THE SOFTWARE.
+## GamePlay v2.0.0
+
+GamePlay3D is an open-source, cross-platform 3D native C++ game framework making it easy to learn and write mobile and desktop games. 
+
+<img align="right" src="https://raw.github.com/wiki/blackberry/GamePlay/img/logo.png" alt="gameplay3d" />
+
+- [Website](http://www.gameplay3d.org/)
+- [Forums](http://www.gameplay3d.org/forums/)
+- [Wiki](https://github.com/blackberry/GamePlay/wiki)
+- [API Reference](http://blackberry.github.io/GamePlay/api/index.html)
+- [Development Guide](https://github.com/blackberry/GamePlay/wiki#wiki-Development_Guide)
+
+## Supported Platforms
+- [Microsoft Windows](https://github.com/blackberry/GamePlay/wiki/Visual-Studio-Setup) (using Microsoft Visual Studio)
+- [Apple MacOS X](https://github.com/blackberry/GamePlay/wiki/Apple-Xcode-Setup) (using Apple XCode)
+- [Linux](https://github.com/blackberry/GamePlay/wiki/Linux-Setup) (using CMake)
+- [Apple iOS](https://github.com/blackberry/GamePlay/wiki/Apple-Xcode-Setup) (using Apple XCode)
+- [Google Android](https://github.com/blackberry/GamePlay/wiki/Android-NDK-Setup) (using Google Android NDK)
+- [BlackBerry](https://github.com/blackberry/GamePlay/wiki/BlackBerry-Setup) (using BlackBerry Native SDK)
+
+## Roadmap for 'next' branch
+- [2.0.0](https://github.com/blackberry/GamePlay/issues?milestone=6&page=1&state=open)
+- [backlog](https://github.com/blackberry/GamePlay/issues?milestone=5&page=1&state=open)
+
+## License
+The project is open sourced under the [Apache 2.0 license](http://www.tldrlegal.com/license/apache-license-2.0-%28apache-2.0%29).
+
+## Bug Reporting
+Please log bugs under [Issues](https://github.com/blackberry/GamePlay/issues) on github.
+If you are unsure if your problem is a bug then post on the [Help Forum](http://www.gameplay3d.org/forums/viewforum.php?f=3).
+
+## Feature Requests
+Please post feature requests on the [Feature Request Forum](http://www.gameplay3d.org/forums/viewforum.php?f=4). Approved feature requests will be added to the github backlog issues list. 
+
+## Disclaimer
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 
+OTHER DEALINGS IN THE SOFTWARE.

+ 666 - 666
gameplay/src/AnimationClip.cpp

@@ -1,666 +1,666 @@
-#include "Base.h"
-#include "AnimationClip.h"
-#include "Animation.h"
-#include "AnimationTarget.h"
-#include "Game.h"
-#include "Quaternion.h"
-#include "ScriptController.h"
-
-namespace gameplay
-{
-
-AnimationClip::AnimationClip(const char* id, Animation* animation, unsigned long startTime, unsigned long endTime)
-    : _id(id), _animation(animation), _startTime(startTime), _endTime(endTime), _duration(_endTime - _startTime), 
-      _stateBits(0x00), _repeatCount(1.0f), _loopBlendTime(0), _activeDuration(_duration * _repeatCount), _speed(1.0f), _timeStarted(0), 
-      _elapsedTime(0), _crossFadeToClip(NULL), _crossFadeOutElapsed(0), _crossFadeOutDuration(0), _blendWeight(1.0f),
-      _beginListeners(NULL), _endListeners(NULL), _listeners(NULL), _listenerItr(NULL), _scriptListeners(NULL)
-{
-    GP_ASSERT(_animation);
-    GP_ASSERT(0 <= startTime && startTime <= _animation->_duration && 0 <= endTime && endTime <= _animation->_duration);
-
-    for (size_t i = 0, count = _animation->_channels.size(); i < count; i++)
-    {
-        GP_ASSERT(_animation->_channels[i]);
-        GP_ASSERT(_animation->_channels[i]->getCurve());
-        _values.push_back(new AnimationValue(_animation->_channels[i]->getCurve()->getComponentCount()));
-    }
-}
-
-AnimationClip::~AnimationClip()
-{
-    std::vector<AnimationValue*>::iterator valueIter = _values.begin();
-    while (valueIter != _values.end())
-    {
-        SAFE_DELETE(*valueIter);
-        valueIter++;
-    }
-    _values.clear();
-
-    SAFE_RELEASE(_crossFadeToClip);
-    SAFE_DELETE(_beginListeners);
-    SAFE_DELETE(_endListeners);
-
-    if (_scriptListeners)
-    {
-        for (size_t i = 0; i < _scriptListeners->size(); i++)
-        {
-            SAFE_DELETE((*_scriptListeners)[i]);
-        }
-        SAFE_DELETE(_scriptListeners);
-    }
-
-    if (_listeners)
-    {
-        *_listenerItr = _listeners->begin();
-        while (*_listenerItr != _listeners->end())
-        {
-            ListenerEvent* lEvt = **_listenerItr;
-            SAFE_DELETE(lEvt);
-            ++*_listenerItr;
-        }
-        SAFE_DELETE(_listeners);
-    }
-    SAFE_DELETE(_listenerItr);
-}
-
-AnimationClip::ListenerEvent::ListenerEvent(Listener* listener, unsigned long eventTime)
-{
-    _listener = listener;
-    _eventTime = eventTime;
-}
-
-AnimationClip::ListenerEvent::~ListenerEvent()
-{
-}
-
-const char* AnimationClip::getId() const
-{
-    return _id.c_str();
-}
-
-Animation* AnimationClip::getAnimation() const
-{
-    return _animation;
-}
-
-unsigned long AnimationClip::getStartTime() const
-{
-    return _startTime;
-}
-
-unsigned long AnimationClip::getEndTime() const
-{
-    return _endTime;
-}
-
-float AnimationClip::getElapsedTime() const
-{
-    return _elapsedTime;
-}
-
-void AnimationClip::setRepeatCount(float repeatCount)
-{
-    GP_ASSERT(repeatCount == REPEAT_INDEFINITE || repeatCount > 0.0f);
-
-    _repeatCount = repeatCount;
-
-    if (repeatCount == REPEAT_INDEFINITE)
-    {
-        _activeDuration = _duration + _loopBlendTime;
-    }
-    else
-    {
-        _activeDuration = _duration * _repeatCount;
-
-        if (repeatCount > 1.0f && _loopBlendTime > 0.0f)
-            _activeDuration += std::ceil(repeatCount - 1.0f) * _loopBlendTime;
-    }
-}
-
-float AnimationClip::getRepeatCount() const
-{
-    return _repeatCount;
-}
-
-void AnimationClip::setActiveDuration(unsigned long duration)
-{
-    GP_ASSERT(duration >= 0);
-
-    if (duration == REPEAT_INDEFINITE)
-    {
-        _activeDuration = _duration + _loopBlendTime;
-    }
-    else
-    {
-        _activeDuration = duration;
-        _repeatCount = (float)_activeDuration / (float)_duration;
-    }
-}
-
-unsigned long AnimationClip::getActiveDuration() const
-{
-    if (_repeatCount == REPEAT_INDEFINITE)
-        return REPEAT_INDEFINITE;
-
-    return _activeDuration;
-}
-
-unsigned long AnimationClip::getDuration() const
-{
-    return _duration;
-}
-
-void AnimationClip::setSpeed(float speed)
-{
-    _speed = speed;
-}
-
-float AnimationClip::getSpeed() const
-{
-    return _speed;
-}
-
-void AnimationClip::setBlendWeight(float blendWeight)
-{
-    _blendWeight = blendWeight;
-}
-
-float AnimationClip::getBlendWeight() const
-{
-    return _blendWeight;
-}
-
-void AnimationClip::setLoopBlendTime(float loopBlendTime)
-{
-    _loopBlendTime = loopBlendTime;
-    if (_loopBlendTime < 0.0f)
-        _loopBlendTime = 0.0f;
-}
-
-float AnimationClip::getLoopBlendTime() const
-{
-    return _loopBlendTime;
-}
-
-bool AnimationClip::isPlaying() const
-{
-    return (isClipStateBitSet(CLIP_IS_PLAYING_BIT) && !isClipStateBitSet(CLIP_IS_PAUSED_BIT));
-}
-
-void AnimationClip::play()
-{
-    if (isClipStateBitSet(CLIP_IS_PLAYING_BIT))
-    {
-        // If paused, reset the bit and return.
-        if (isClipStateBitSet(CLIP_IS_PAUSED_BIT))
-        {
-            resetClipStateBit(CLIP_IS_PAUSED_BIT);
-            return;
-        }
-
-        // If the clip is set to be removed, reset the flag.
-        if (isClipStateBitSet(CLIP_IS_MARKED_FOR_REMOVAL_BIT))
-            resetClipStateBit(CLIP_IS_MARKED_FOR_REMOVAL_BIT);
-
-        // Set the state bit to restart.
-        setClipStateBit(CLIP_IS_RESTARTED_BIT);
-    }
-    else
-    {
-        setClipStateBit(CLIP_IS_PLAYING_BIT);
-        GP_ASSERT(_animation);
-        GP_ASSERT(_animation->_controller);
-        _animation->_controller->schedule(this);
-    }
-    
-    _timeStarted = Game::getGameTime();
-}
-
-void AnimationClip::stop()
-{
-    if (isClipStateBitSet(CLIP_IS_PLAYING_BIT))
-    {
-        // Reset the restarted and paused bits. 
-        resetClipStateBit(CLIP_IS_RESTARTED_BIT);
-        resetClipStateBit(CLIP_IS_PAUSED_BIT);
-
-        // Mark the clip to removed from the AnimationController.
-        setClipStateBit(CLIP_IS_MARKED_FOR_REMOVAL_BIT);
-    }
-}
-
-void AnimationClip::pause()
-{
-    if (isClipStateBitSet(CLIP_IS_PLAYING_BIT) && !isClipStateBitSet(CLIP_IS_MARKED_FOR_REMOVAL_BIT))
-    {
-        setClipStateBit(CLIP_IS_PAUSED_BIT);
-    }
-}
-
-void AnimationClip::crossFade(AnimationClip* clip, unsigned long duration)
-{
-    GP_ASSERT(clip);
-
-    // Check if the given clip is fading into this clip.
-    // We should reset the clip from fading out, and this one from fading in 
-    // in order to start the crossfade back the other way.
-    if (clip->isClipStateBitSet(CLIP_IS_FADING_OUT_BIT) && clip->_crossFadeToClip == this)
-    {
-        clip->resetClipStateBit(CLIP_IS_FADING_OUT_BIT);
-        clip->_crossFadeToClip->resetClipStateBit(CLIP_IS_FADING_IN_BIT);
-        SAFE_RELEASE(clip->_crossFadeToClip);
-    }
-
-    // If I already have a clip I'm fading to and it's not the same as the given clip release it.
-    // Assign the new clip and increase it's ref count.
-    if (_crossFadeToClip)
-    {
-        SAFE_RELEASE(_crossFadeToClip);
-    }
-
-    // Set and initialize the crossfade clip
-    _crossFadeToClip = clip;
-    _crossFadeToClip->addRef();
-    _crossFadeToClip->setClipStateBit(CLIP_IS_FADING_IN_BIT);
-    _crossFadeToClip->_blendWeight = 0.0f;
-    
-    // Set and initialize this clip to fade out
-    setClipStateBit(CLIP_IS_FADING_OUT_STARTED_BIT);
-    setClipStateBit(CLIP_IS_FADING_OUT_BIT);
-    _crossFadeOutElapsed = 0.0f;
-    _crossFadeOutDuration = duration;
-    
-    // If this clip is currently not playing, we should start playing it.
-    if (!isClipStateBitSet(CLIP_IS_PLAYING_BIT))
-        play();
-
-    // Start playing the cross fade clip.
-    _crossFadeToClip->play(); 
-}
-
-void AnimationClip::addListener(AnimationClip::Listener* listener, unsigned long eventTime)
-{
-    GP_ASSERT(listener);
-    GP_ASSERT(eventTime < _activeDuration);
-
-    ListenerEvent* listenerEvent = new ListenerEvent(listener, eventTime);
-
-    if (!_listeners)
-    {
-        _listeners = new std::list<ListenerEvent*>;
-        _listeners->push_front(listenerEvent);
-
-        _listenerItr = new std::list<ListenerEvent*>::iterator;
-        if (isClipStateBitSet(CLIP_IS_PLAYING_BIT))
-            *_listenerItr = _listeners->begin();
-    }
-    else
-    {
-        for (std::list<ListenerEvent*>::iterator itr = _listeners->begin(); itr != _listeners->end(); itr++)
-        {
-            GP_ASSERT(*itr);
-            if (eventTime < (*itr)->_eventTime)
-            {
-                itr = _listeners->insert(itr, listenerEvent);
-
-                // If playing, update the iterator if we need to.
-                // otherwise, it will just be set the next time the clip gets played.
-                if (isClipStateBitSet(CLIP_IS_PLAYING_BIT))
-                {
-                    float currentTime = fmodf(_elapsedTime, (float)_duration);
-                    GP_ASSERT(**_listenerItr || *_listenerItr == _listeners->end());
-                    if ((_speed >= 0.0f && currentTime < eventTime && (*_listenerItr == _listeners->end() || eventTime < (**_listenerItr)->_eventTime)) || 
-                        (_speed <= 0 && currentTime > eventTime && (*_listenerItr == _listeners->begin() || eventTime > (**_listenerItr)->_eventTime)))
-                        *_listenerItr = itr;
-                }
-                return;
-            }
-        }
-        _listeners->push_back(listenerEvent);
-    }
-}
-
-void AnimationClip::addBeginListener(AnimationClip::Listener* listener)
-{
-    if (!_beginListeners)
-        _beginListeners = new std::vector<Listener*>;
-
-    GP_ASSERT(listener);
-    _beginListeners->push_back(listener);
-}
-
-void AnimationClip::addEndListener(AnimationClip::Listener* listener)
-{
-    if (!_endListeners)
-        _endListeners = new std::vector<Listener*>;
-
-    GP_ASSERT(listener);
-    _endListeners->push_back(listener);
-}
-
-void AnimationClip::addBeginListener(const char* function)
-{
-    if (!_scriptListeners)
-        _scriptListeners = new std::vector<ScriptListener*>;
-
-    ScriptListener* listener = new ScriptListener(function);
-    _scriptListeners->push_back(listener);
-    addBeginListener(listener);
-}
-
-void AnimationClip::addEndListener(const char* function)
-{
-    if (!_scriptListeners)
-        _scriptListeners = new std::vector<ScriptListener*>;
-
-    ScriptListener* listener = new ScriptListener(function);
-    _scriptListeners->push_back(listener);
-    addEndListener(listener);
-}
-
-void AnimationClip::addListener(const char* function, unsigned long eventTime)
-{
-    if (!_scriptListeners)
-        _scriptListeners = new std::vector<ScriptListener*>;
-
-    ScriptListener* listener = new ScriptListener(function);
-    _scriptListeners->push_back(listener);
-    addListener(listener, eventTime);
-}
-
-bool AnimationClip::update(float elapsedTime)
-{
-    if (isClipStateBitSet(CLIP_IS_PAUSED_BIT))
-    {
-        return false;
-    }
-
-    if (isClipStateBitSet(CLIP_IS_MARKED_FOR_REMOVAL_BIT))
-    {
-        // If the marked for removal bit is set, it means stop() was called on the AnimationClip at some point
-        // after the last update call. Reset the flag, and return true so the AnimationClip is removed from the 
-        // running clips on the AnimationController.
-        onEnd();
-        return true;
-    }
-
-    if (!isClipStateBitSet(CLIP_IS_STARTED_BIT))
-    {
-        // Clip is just starting
-        onBegin();
-    }
-    else
-    {
-        // Clip was already running
-        _elapsedTime += elapsedTime * _speed;
-
-        if (_repeatCount == REPEAT_INDEFINITE && _elapsedTime <= 0)
-        {
-            // Elapsed time is moving backwards, so wrap it back around the end when it falls below zero
-            _elapsedTime = _activeDuration + _elapsedTime;
-
-            // TODO: account for _loopBlendTime
-        }
-    }
-
-    // Current time within a loop of the clip
-    float currentTime = 0.0f;
-
-    // Check to see if clip is complete.
-    if (_repeatCount != REPEAT_INDEFINITE && ((_speed >= 0.0f && _elapsedTime >= _activeDuration) || (_speed <= 0.0f && _elapsedTime <= 0.0f)))
-    {
-        // We finished our active duration (including repeats), so clamp to our end value.
-        resetClipStateBit(CLIP_IS_STARTED_BIT);
-
-        // Ensure we end off at the endpoints of our clip (-speed==0, +speed==_duration)
-        currentTime = _speed < 0.0f ? 0.0f : _duration;
-    }
-    else
-    {
-        // If _duration == 0, we have a "pose". Just set currentTime to 0.
-        if (_duration == 0)
-        {
-            currentTime = 0.0f;
-        }
-        else
-        {
-            // Animation is running normally.
-            currentTime = fmodf(_elapsedTime, _duration + _loopBlendTime);
-        }
-    }
-
-    // Notify any listeners of Animation events.
-    if (_listeners)
-    {
-        GP_ASSERT(_listenerItr);
-
-        if (_speed >= 0.0f)
-        {
-            while (*_listenerItr != _listeners->end() && _elapsedTime >= (long) (**_listenerItr)->_eventTime)
-            {
-                GP_ASSERT(_listenerItr);
-                GP_ASSERT(**_listenerItr);
-                GP_ASSERT((**_listenerItr)->_listener);
-
-                (**_listenerItr)->_listener->animationEvent(this, Listener::TIME);
-                ++*_listenerItr;
-            }
-        }
-        else
-        {
-            while (*_listenerItr != _listeners->begin() && _elapsedTime <= (long) (**_listenerItr)->_eventTime)
-            {
-                GP_ASSERT(_listenerItr);
-                GP_ASSERT(**_listenerItr);
-                GP_ASSERT((**_listenerItr)->_listener);
-
-                (**_listenerItr)->_listener->animationEvent(this, Listener::TIME);
-                --*_listenerItr;
-            }
-        }
-    }
-
-    // Add back in start time, and divide by the total animation's duration to get the actual percentage complete
-    GP_ASSERT(_animation);
-
-    // Compute percentage complete for the current loop (prevent a divide by zero if _duration==0).
-    // Note that we don't use (currentTime/(_duration+_loopBlendTime)). That's because we want a
-    // % value that is outside the 0-1 range for loop smoothing/blending purposes.
-    float percentComplete = _duration == 0 ? 1 : currentTime / (float)_duration;
-
-    if (_loopBlendTime == 0.0f)
-        percentComplete = MATH_CLAMP(percentComplete, 0.0f, 1.0f);
-
-    // If we're cross fading, compute blend weights
-    if (isClipStateBitSet(CLIP_IS_FADING_OUT_BIT))
-    {
-        GP_ASSERT(_crossFadeToClip);
-        GP_ASSERT(_crossFadeOutDuration > 0);
-
-        if (isClipStateBitSet(CLIP_IS_FADING_OUT_STARTED_BIT)) // Calculate elapsed time since the fade out begin.
-        {
-            GP_ASSERT(_crossFadeToClip);
-            _crossFadeOutElapsed = (Game::getGameTime() - _crossFadeToClip->_timeStarted) * fabs(_speed); 
-            resetClipStateBit(CLIP_IS_FADING_OUT_STARTED_BIT);
-        }
-        else
-        {
-            // continue tracking elapsed time.
-            _crossFadeOutElapsed += elapsedTime * fabs(_speed);
-        }
-
-        if (_crossFadeOutElapsed < _crossFadeOutDuration)
-        {
-            // Calculate this clip's blend weight.
-            float tempBlendWeight = ((float)_crossFadeOutDuration - _crossFadeOutElapsed) / (float)_crossFadeOutDuration;
-            
-            // If this clip is fading in, adjust the crossfade clip's weight to be a percentage of your current blend weight
-            if (isClipStateBitSet(CLIP_IS_FADING_IN_BIT))
-            {
-                _crossFadeToClip->_blendWeight = (1.0f - tempBlendWeight) * _blendWeight;
-                _blendWeight -= _crossFadeToClip->_blendWeight;
-            }
-            else
-            {
-                // Just set the blend weight.
-                _crossFadeToClip->_blendWeight = (1.0f - tempBlendWeight);
-                _blendWeight = tempBlendWeight;
-            }
-        }
-        else
-        {
-            // Fade is done.
-            _crossFadeToClip->_blendWeight = 1.0f;
-            _blendWeight = 0.0f;
-            resetClipStateBit(CLIP_IS_STARTED_BIT);            
-            resetClipStateBit(CLIP_IS_FADING_OUT_BIT);
-            _crossFadeToClip->resetClipStateBit(CLIP_IS_FADING_IN_BIT);
-            SAFE_RELEASE(_crossFadeToClip);
-        }
-    }
-    
-    // Evaluate this clip.
-    Animation::Channel* channel = NULL;
-    AnimationValue* value = NULL;
-    AnimationTarget* target = NULL;
-    size_t channelCount = _animation->_channels.size();
-    float percentageStart = (float)_startTime / (float)_animation->_duration;
-    float percentageEnd = (float)_endTime / (float)_animation->_duration;
-    float percentageBlend = (float)_loopBlendTime / (float)_animation->_duration;
-    for (size_t i = 0; i < channelCount; i++)
-    {
-        channel = _animation->_channels[i];
-        GP_ASSERT(channel);
-        target = channel->_target;
-        GP_ASSERT(target);
-        value = _values[i];
-        GP_ASSERT(value);
-
-        // Evaluate the point on Curve
-        GP_ASSERT(channel->getCurve());
-        channel->getCurve()->evaluate(percentComplete, percentageStart, percentageEnd, percentageBlend, value->_value);
-
-        // Set the animation value on the target property.
-        target->setAnimationPropertyValue(channel->_propertyId, value, _blendWeight);
-    }
-
-    // When ended. Probably should move to it's own method so we can call it when the clip is ended early.
-    if (isClipStateBitSet(CLIP_IS_MARKED_FOR_REMOVAL_BIT) || !isClipStateBitSet(CLIP_IS_STARTED_BIT))
-    {
-        onEnd();
-        return true;
-    }
-
-    return false;
-}
-
-void AnimationClip::onBegin()
-{
-    addRef();
-
-    // Initialize animation to play.
-    setClipStateBit(CLIP_IS_STARTED_BIT);
-    if (_speed >= 0)
-    {
-        _elapsedTime = (Game::getGameTime() - _timeStarted) * _speed;
-
-        if (_listeners)
-            *_listenerItr = _listeners->begin();
-    }
-    else
-    {
-        _elapsedTime = _activeDuration + (Game::getGameTime() - _timeStarted) * _speed;
-
-        if (_listeners)
-            *_listenerItr = _listeners->end();
-    }
-    
-    // Notify begin listeners if any.
-    if (_beginListeners)
-    {
-        std::vector<Listener*>::iterator listener = _beginListeners->begin();
-        while (listener != _beginListeners->end())
-        {
-            GP_ASSERT(*listener);
-            (*listener)->animationEvent(this, Listener::BEGIN);
-            listener++;
-        }
-    }
-
-    release();
-}
-
-void AnimationClip::onEnd()
-{
-    addRef();
-
-    _blendWeight = 1.0f;
-    resetClipStateBit(CLIP_ALL_BITS);
-
-    // Notify end listeners if any.
-    if (_endListeners)
-    {
-        std::vector<Listener*>::iterator listener = _endListeners->begin();
-        while (listener != _endListeners->end())
-        {
-            GP_ASSERT(*listener);
-            (*listener)->animationEvent(this, Listener::END);
-            listener++;
-        }
-    }
-
-    release();
-}
-
-bool AnimationClip::isClipStateBitSet(unsigned char bit) const
-{
-    return (_stateBits & bit) == bit;
-}
-
-void AnimationClip::setClipStateBit(unsigned char bit)
-{
-    _stateBits |= bit;
-}
-
-void AnimationClip::resetClipStateBit(unsigned char bit)
-{
-    _stateBits &= ~bit;
-}
-
-AnimationClip* AnimationClip::clone(Animation* animation) const
-{
-    // Don't clone the elapsed time, listeners or crossfade information.
-    AnimationClip* newClip = new AnimationClip(getId(), animation, getStartTime(), getEndTime());
-    newClip->setSpeed(getSpeed());
-    newClip->setRepeatCount(getRepeatCount());
-    newClip->setBlendWeight(getBlendWeight());
-    
-    size_t size = _values.size();
-    newClip->_values.resize(size, NULL);
-    for (size_t i = 0; i < size; ++i)
-    {
-        if (newClip->_values[i] == NULL)
-        {
-            newClip->_values[i] = new AnimationValue(*_values[i]);
-        }
-        else
-        {
-            *newClip->_values[i] = *_values[i];
-        }
-    }
-    return newClip;
-}
-
-AnimationClip::ScriptListener::ScriptListener(const std::string& function)
-{
-    // Store the function name.
-    this->function = Game::getInstance()->getScriptController()->loadUrl(function.c_str());
-}
-
-void AnimationClip::ScriptListener::animationEvent(AnimationClip* clip, EventType type)
-{
-    Game::getInstance()->getScriptController()->executeFunction<void>(function.c_str(), "<AnimationClip>[AnimationClip::Listener::EventType]", clip, type);
-}
-
-
-}
+#include "Base.h"
+#include "AnimationClip.h"
+#include "Animation.h"
+#include "AnimationTarget.h"
+#include "Game.h"
+#include "Quaternion.h"
+#include "ScriptController.h"
+
+namespace gameplay
+{
+
+AnimationClip::AnimationClip(const char* id, Animation* animation, unsigned long startTime, unsigned long endTime)
+    : _id(id), _animation(animation), _startTime(startTime), _endTime(endTime), _duration(_endTime - _startTime), 
+      _stateBits(0x00), _repeatCount(1.0f), _loopBlendTime(0), _activeDuration(_duration * _repeatCount), _speed(1.0f), _timeStarted(0), 
+      _elapsedTime(0), _crossFadeToClip(NULL), _crossFadeOutElapsed(0), _crossFadeOutDuration(0), _blendWeight(1.0f),
+      _beginListeners(NULL), _endListeners(NULL), _listeners(NULL), _listenerItr(NULL), _scriptListeners(NULL)
+{
+    GP_ASSERT(_animation);
+    GP_ASSERT(0 <= startTime && startTime <= _animation->_duration && 0 <= endTime && endTime <= _animation->_duration);
+
+    for (size_t i = 0, count = _animation->_channels.size(); i < count; i++)
+    {
+        GP_ASSERT(_animation->_channels[i]);
+        GP_ASSERT(_animation->_channels[i]->getCurve());
+        _values.push_back(new AnimationValue(_animation->_channels[i]->getCurve()->getComponentCount()));
+    }
+}
+
+AnimationClip::~AnimationClip()
+{
+    std::vector<AnimationValue*>::iterator valueIter = _values.begin();
+    while (valueIter != _values.end())
+    {
+        SAFE_DELETE(*valueIter);
+        valueIter++;
+    }
+    _values.clear();
+
+    SAFE_RELEASE(_crossFadeToClip);
+    SAFE_DELETE(_beginListeners);
+    SAFE_DELETE(_endListeners);
+
+    if (_scriptListeners)
+    {
+        for (size_t i = 0; i < _scriptListeners->size(); i++)
+        {
+            SAFE_DELETE((*_scriptListeners)[i]);
+        }
+        SAFE_DELETE(_scriptListeners);
+    }
+
+    if (_listeners)
+    {
+        *_listenerItr = _listeners->begin();
+        while (*_listenerItr != _listeners->end())
+        {
+            ListenerEvent* lEvt = **_listenerItr;
+            SAFE_DELETE(lEvt);
+            ++*_listenerItr;
+        }
+        SAFE_DELETE(_listeners);
+    }
+    SAFE_DELETE(_listenerItr);
+}
+
+AnimationClip::ListenerEvent::ListenerEvent(Listener* listener, unsigned long eventTime)
+{
+    _listener = listener;
+    _eventTime = eventTime;
+}
+
+AnimationClip::ListenerEvent::~ListenerEvent()
+{
+}
+
+const char* AnimationClip::getId() const
+{
+    return _id.c_str();
+}
+
+Animation* AnimationClip::getAnimation() const
+{
+    return _animation;
+}
+
+unsigned long AnimationClip::getStartTime() const
+{
+    return _startTime;
+}
+
+unsigned long AnimationClip::getEndTime() const
+{
+    return _endTime;
+}
+
+float AnimationClip::getElapsedTime() const
+{
+    return _elapsedTime;
+}
+
+void AnimationClip::setRepeatCount(float repeatCount)
+{
+    GP_ASSERT(repeatCount == REPEAT_INDEFINITE || repeatCount > 0.0f);
+
+    _repeatCount = repeatCount;
+
+    if (repeatCount == REPEAT_INDEFINITE)
+    {
+        _activeDuration = _duration + _loopBlendTime;
+    }
+    else
+    {
+        _activeDuration = _duration * _repeatCount;
+
+        if (repeatCount > 1.0f && _loopBlendTime > 0.0f)
+            _activeDuration += std::ceil(repeatCount - 1.0f) * _loopBlendTime;
+    }
+}
+
+float AnimationClip::getRepeatCount() const
+{
+    return _repeatCount;
+}
+
+void AnimationClip::setActiveDuration(unsigned long duration)
+{
+    GP_ASSERT(duration >= 0);
+
+    if (duration == REPEAT_INDEFINITE)
+    {
+        _activeDuration = _duration + _loopBlendTime;
+    }
+    else
+    {
+        _activeDuration = duration;
+        _repeatCount = (float)_activeDuration / (float)_duration;
+    }
+}
+
+unsigned long AnimationClip::getActiveDuration() const
+{
+    if (_repeatCount == REPEAT_INDEFINITE)
+        return REPEAT_INDEFINITE;
+
+    return _activeDuration;
+}
+
+unsigned long AnimationClip::getDuration() const
+{
+    return _duration;
+}
+
+void AnimationClip::setSpeed(float speed)
+{
+    _speed = speed;
+}
+
+float AnimationClip::getSpeed() const
+{
+    return _speed;
+}
+
+void AnimationClip::setBlendWeight(float blendWeight)
+{
+    _blendWeight = blendWeight;
+}
+
+float AnimationClip::getBlendWeight() const
+{
+    return _blendWeight;
+}
+
+void AnimationClip::setLoopBlendTime(float loopBlendTime)
+{
+    _loopBlendTime = loopBlendTime;
+    if (_loopBlendTime < 0.0f)
+        _loopBlendTime = 0.0f;
+}
+
+float AnimationClip::getLoopBlendTime() const
+{
+    return _loopBlendTime;
+}
+
+bool AnimationClip::isPlaying() const
+{
+    return (isClipStateBitSet(CLIP_IS_PLAYING_BIT) && !isClipStateBitSet(CLIP_IS_PAUSED_BIT));
+}
+
+void AnimationClip::play()
+{
+    if (isClipStateBitSet(CLIP_IS_PLAYING_BIT))
+    {
+        // If paused, reset the bit and return.
+        if (isClipStateBitSet(CLIP_IS_PAUSED_BIT))
+        {
+            resetClipStateBit(CLIP_IS_PAUSED_BIT);
+            return;
+        }
+
+        // If the clip is set to be removed, reset the flag.
+        if (isClipStateBitSet(CLIP_IS_MARKED_FOR_REMOVAL_BIT))
+            resetClipStateBit(CLIP_IS_MARKED_FOR_REMOVAL_BIT);
+
+        // Set the state bit to restart.
+        setClipStateBit(CLIP_IS_RESTARTED_BIT);
+    }
+    else
+    {
+        setClipStateBit(CLIP_IS_PLAYING_BIT);
+        GP_ASSERT(_animation);
+        GP_ASSERT(_animation->_controller);
+        _animation->_controller->schedule(this);
+    }
+    
+    _timeStarted = Game::getGameTime();
+}
+
+void AnimationClip::stop()
+{
+    if (isClipStateBitSet(CLIP_IS_PLAYING_BIT))
+    {
+        // Reset the restarted and paused bits. 
+        resetClipStateBit(CLIP_IS_RESTARTED_BIT);
+        resetClipStateBit(CLIP_IS_PAUSED_BIT);
+
+        // Mark the clip to removed from the AnimationController.
+        setClipStateBit(CLIP_IS_MARKED_FOR_REMOVAL_BIT);
+    }
+}
+
+void AnimationClip::pause()
+{
+    if (isClipStateBitSet(CLIP_IS_PLAYING_BIT) && !isClipStateBitSet(CLIP_IS_MARKED_FOR_REMOVAL_BIT))
+    {
+        setClipStateBit(CLIP_IS_PAUSED_BIT);
+    }
+}
+
+void AnimationClip::crossFade(AnimationClip* clip, unsigned long duration)
+{
+    GP_ASSERT(clip);
+
+    // Check if the given clip is fading into this clip.
+    // We should reset the clip from fading out, and this one from fading in 
+    // in order to start the crossfade back the other way.
+    if (clip->isClipStateBitSet(CLIP_IS_FADING_OUT_BIT) && clip->_crossFadeToClip == this)
+    {
+        clip->resetClipStateBit(CLIP_IS_FADING_OUT_BIT);
+        clip->_crossFadeToClip->resetClipStateBit(CLIP_IS_FADING_IN_BIT);
+        SAFE_RELEASE(clip->_crossFadeToClip);
+    }
+
+    // If I already have a clip I'm fading to and it's not the same as the given clip release it.
+    // Assign the new clip and increase it's ref count.
+    if (_crossFadeToClip)
+    {
+        SAFE_RELEASE(_crossFadeToClip);
+    }
+
+    // Set and initialize the crossfade clip
+    _crossFadeToClip = clip;
+    _crossFadeToClip->addRef();
+    _crossFadeToClip->setClipStateBit(CLIP_IS_FADING_IN_BIT);
+    _crossFadeToClip->_blendWeight = 0.0f;
+    
+    // Set and initialize this clip to fade out
+    setClipStateBit(CLIP_IS_FADING_OUT_STARTED_BIT);
+    setClipStateBit(CLIP_IS_FADING_OUT_BIT);
+    _crossFadeOutElapsed = 0.0f;
+    _crossFadeOutDuration = duration;
+    
+    // If this clip is currently not playing, we should start playing it.
+    if (!isClipStateBitSet(CLIP_IS_PLAYING_BIT))
+        play();
+
+    // Start playing the cross fade clip.
+    _crossFadeToClip->play(); 
+}
+
+void AnimationClip::addListener(AnimationClip::Listener* listener, unsigned long eventTime)
+{
+    GP_ASSERT(listener);
+    GP_ASSERT(eventTime < _activeDuration);
+
+    ListenerEvent* listenerEvent = new ListenerEvent(listener, eventTime);
+
+    if (!_listeners)
+    {
+        _listeners = new std::list<ListenerEvent*>;
+        _listeners->push_front(listenerEvent);
+
+        _listenerItr = new std::list<ListenerEvent*>::iterator;
+        if (isClipStateBitSet(CLIP_IS_PLAYING_BIT))
+            *_listenerItr = _listeners->begin();
+    }
+    else
+    {
+        for (std::list<ListenerEvent*>::iterator itr = _listeners->begin(); itr != _listeners->end(); itr++)
+        {
+            GP_ASSERT(*itr);
+            if (eventTime < (*itr)->_eventTime)
+            {
+                itr = _listeners->insert(itr, listenerEvent);
+
+                // If playing, update the iterator if we need to.
+                // otherwise, it will just be set the next time the clip gets played.
+                if (isClipStateBitSet(CLIP_IS_PLAYING_BIT))
+                {
+                    float currentTime = fmodf(_elapsedTime, (float)_duration);
+                    GP_ASSERT(**_listenerItr || *_listenerItr == _listeners->end());
+                    if ((_speed >= 0.0f && currentTime < eventTime && (*_listenerItr == _listeners->end() || eventTime < (**_listenerItr)->_eventTime)) || 
+                        (_speed <= 0 && currentTime > eventTime && (*_listenerItr == _listeners->begin() || eventTime > (**_listenerItr)->_eventTime)))
+                        *_listenerItr = itr;
+                }
+                return;
+            }
+        }
+        _listeners->push_back(listenerEvent);
+    }
+}
+
+void AnimationClip::addBeginListener(AnimationClip::Listener* listener)
+{
+    if (!_beginListeners)
+        _beginListeners = new std::vector<Listener*>;
+
+    GP_ASSERT(listener);
+    _beginListeners->push_back(listener);
+}
+
+void AnimationClip::addEndListener(AnimationClip::Listener* listener)
+{
+    if (!_endListeners)
+        _endListeners = new std::vector<Listener*>;
+
+    GP_ASSERT(listener);
+    _endListeners->push_back(listener);
+}
+
+void AnimationClip::addBeginListener(const char* function)
+{
+    if (!_scriptListeners)
+        _scriptListeners = new std::vector<ScriptListener*>;
+
+    ScriptListener* listener = new ScriptListener(function);
+    _scriptListeners->push_back(listener);
+    addBeginListener(listener);
+}
+
+void AnimationClip::addEndListener(const char* function)
+{
+    if (!_scriptListeners)
+        _scriptListeners = new std::vector<ScriptListener*>;
+
+    ScriptListener* listener = new ScriptListener(function);
+    _scriptListeners->push_back(listener);
+    addEndListener(listener);
+}
+
+void AnimationClip::addListener(const char* function, unsigned long eventTime)
+{
+    if (!_scriptListeners)
+        _scriptListeners = new std::vector<ScriptListener*>;
+
+    ScriptListener* listener = new ScriptListener(function);
+    _scriptListeners->push_back(listener);
+    addListener(listener, eventTime);
+}
+
+bool AnimationClip::update(float elapsedTime)
+{
+    if (isClipStateBitSet(CLIP_IS_PAUSED_BIT))
+    {
+        return false;
+    }
+
+    if (isClipStateBitSet(CLIP_IS_MARKED_FOR_REMOVAL_BIT))
+    {
+        // If the marked for removal bit is set, it means stop() was called on the AnimationClip at some point
+        // after the last update call. Reset the flag, and return true so the AnimationClip is removed from the 
+        // running clips on the AnimationController.
+        onEnd();
+        return true;
+    }
+
+    if (!isClipStateBitSet(CLIP_IS_STARTED_BIT))
+    {
+        // Clip is just starting
+        onBegin();
+    }
+    else
+    {
+        // Clip was already running
+        _elapsedTime += elapsedTime * _speed;
+
+        if (_repeatCount == REPEAT_INDEFINITE && _elapsedTime <= 0)
+        {
+            // Elapsed time is moving backwards, so wrap it back around the end when it falls below zero
+            _elapsedTime = _activeDuration + _elapsedTime;
+
+            // TODO: account for _loopBlendTime
+        }
+    }
+
+    // Current time within a loop of the clip
+    float currentTime = 0.0f;
+
+    // Check to see if clip is complete.
+    if (_repeatCount != REPEAT_INDEFINITE && ((_speed >= 0.0f && _elapsedTime >= _activeDuration) || (_speed <= 0.0f && _elapsedTime <= 0.0f)))
+    {
+        // We finished our active duration (including repeats), so clamp to our end value.
+        resetClipStateBit(CLIP_IS_STARTED_BIT);
+
+        // Ensure we end off at the endpoints of our clip (-speed==0, +speed==_duration)
+        currentTime = _speed < 0.0f ? 0.0f : _duration;
+    }
+    else
+    {
+        // If _duration == 0, we have a "pose". Just set currentTime to 0.
+        if (_duration == 0)
+        {
+            currentTime = 0.0f;
+        }
+        else
+        {
+            // Animation is running normally.
+            currentTime = fmodf(_elapsedTime, _duration + _loopBlendTime);
+        }
+    }
+
+    // Notify any listeners of Animation events.
+    if (_listeners)
+    {
+        GP_ASSERT(_listenerItr);
+
+        if (_speed >= 0.0f)
+        {
+            while (*_listenerItr != _listeners->end() && _elapsedTime >= (long) (**_listenerItr)->_eventTime)
+            {
+                GP_ASSERT(_listenerItr);
+                GP_ASSERT(**_listenerItr);
+                GP_ASSERT((**_listenerItr)->_listener);
+
+                (**_listenerItr)->_listener->animationEvent(this, Listener::TIME);
+                ++*_listenerItr;
+            }
+        }
+        else
+        {
+            while (*_listenerItr != _listeners->begin() && _elapsedTime <= (long) (**_listenerItr)->_eventTime)
+            {
+                GP_ASSERT(_listenerItr);
+                GP_ASSERT(**_listenerItr);
+                GP_ASSERT((**_listenerItr)->_listener);
+
+                (**_listenerItr)->_listener->animationEvent(this, Listener::TIME);
+                --*_listenerItr;
+            }
+        }
+    }
+
+    // Add back in start time, and divide by the total animation's duration to get the actual percentage complete
+    GP_ASSERT(_animation);
+
+    // Compute percentage complete for the current loop (prevent a divide by zero if _duration==0).
+    // Note that we don't use (currentTime/(_duration+_loopBlendTime)). That's because we want a
+    // % value that is outside the 0-1 range for loop smoothing/blending purposes.
+    float percentComplete = _duration == 0 ? 1 : currentTime / (float)_duration;
+
+    if (_loopBlendTime == 0.0f)
+        percentComplete = MATH_CLAMP(percentComplete, 0.0f, 1.0f);
+
+    // If we're cross fading, compute blend weights
+    if (isClipStateBitSet(CLIP_IS_FADING_OUT_BIT))
+    {
+        GP_ASSERT(_crossFadeToClip);
+        GP_ASSERT(_crossFadeOutDuration > 0);
+
+        if (isClipStateBitSet(CLIP_IS_FADING_OUT_STARTED_BIT)) // Calculate elapsed time since the fade out begin.
+        {
+            GP_ASSERT(_crossFadeToClip);
+            _crossFadeOutElapsed = (Game::getGameTime() - _crossFadeToClip->_timeStarted) * fabs(_speed); 
+            resetClipStateBit(CLIP_IS_FADING_OUT_STARTED_BIT);
+        }
+        else
+        {
+            // continue tracking elapsed time.
+            _crossFadeOutElapsed += elapsedTime * fabs(_speed);
+        }
+
+        if (_crossFadeOutElapsed < _crossFadeOutDuration)
+        {
+            // Calculate this clip's blend weight.
+            float tempBlendWeight = ((float)_crossFadeOutDuration - _crossFadeOutElapsed) / (float)_crossFadeOutDuration;
+            
+            // If this clip is fading in, adjust the crossfade clip's weight to be a percentage of your current blend weight
+            if (isClipStateBitSet(CLIP_IS_FADING_IN_BIT))
+            {
+                _crossFadeToClip->_blendWeight = (1.0f - tempBlendWeight) * _blendWeight;
+                _blendWeight -= _crossFadeToClip->_blendWeight;
+            }
+            else
+            {
+                // Just set the blend weight.
+                _crossFadeToClip->_blendWeight = (1.0f - tempBlendWeight);
+                _blendWeight = tempBlendWeight;
+            }
+        }
+        else
+        {
+            // Fade is done.
+            _crossFadeToClip->_blendWeight = 1.0f;
+            _blendWeight = 0.0f;
+            resetClipStateBit(CLIP_IS_STARTED_BIT);            
+            resetClipStateBit(CLIP_IS_FADING_OUT_BIT);
+            _crossFadeToClip->resetClipStateBit(CLIP_IS_FADING_IN_BIT);
+            SAFE_RELEASE(_crossFadeToClip);
+        }
+    }
+    
+    // Evaluate this clip.
+    Animation::Channel* channel = NULL;
+    AnimationValue* value = NULL;
+    AnimationTarget* target = NULL;
+    size_t channelCount = _animation->_channels.size();
+    float percentageStart = (float)_startTime / (float)_animation->_duration;
+    float percentageEnd = (float)_endTime / (float)_animation->_duration;
+    float percentageBlend = (float)_loopBlendTime / (float)_animation->_duration;
+    for (size_t i = 0; i < channelCount; i++)
+    {
+        channel = _animation->_channels[i];
+        GP_ASSERT(channel);
+        target = channel->_target;
+        GP_ASSERT(target);
+        value = _values[i];
+        GP_ASSERT(value);
+
+        // Evaluate the point on Curve
+        GP_ASSERT(channel->getCurve());
+        channel->getCurve()->evaluate(percentComplete, percentageStart, percentageEnd, percentageBlend, value->_value);
+
+        // Set the animation value on the target property.
+        target->setAnimationPropertyValue(channel->_propertyId, value, _blendWeight);
+    }
+
+    // When ended. Probably should move to it's own method so we can call it when the clip is ended early.
+    if (isClipStateBitSet(CLIP_IS_MARKED_FOR_REMOVAL_BIT) || !isClipStateBitSet(CLIP_IS_STARTED_BIT))
+    {
+        onEnd();
+        return true;
+    }
+
+    return false;
+}
+
+void AnimationClip::onBegin()
+{
+    addRef();
+
+    // Initialize animation to play.
+    setClipStateBit(CLIP_IS_STARTED_BIT);
+    if (_speed >= 0)
+    {
+        _elapsedTime = (Game::getGameTime() - _timeStarted) * _speed;
+
+        if (_listeners)
+            *_listenerItr = _listeners->begin();
+    }
+    else
+    {
+        _elapsedTime = _activeDuration + (Game::getGameTime() - _timeStarted) * _speed;
+
+        if (_listeners)
+            *_listenerItr = _listeners->end();
+    }
+    
+    // Notify begin listeners if any.
+    if (_beginListeners)
+    {
+        std::vector<Listener*>::iterator listener = _beginListeners->begin();
+        while (listener != _beginListeners->end())
+        {
+            GP_ASSERT(*listener);
+            (*listener)->animationEvent(this, Listener::BEGIN);
+            listener++;
+        }
+    }
+
+    release();
+}
+
+void AnimationClip::onEnd()
+{
+    addRef();
+
+    _blendWeight = 1.0f;
+    resetClipStateBit(CLIP_ALL_BITS);
+
+    // Notify end listeners if any.
+    if (_endListeners)
+    {
+        std::vector<Listener*>::iterator listener = _endListeners->begin();
+        while (listener != _endListeners->end())
+        {
+            GP_ASSERT(*listener);
+            (*listener)->animationEvent(this, Listener::END);
+            listener++;
+        }
+    }
+
+    release();
+}
+
+bool AnimationClip::isClipStateBitSet(unsigned char bit) const
+{
+    return (_stateBits & bit) == bit;
+}
+
+void AnimationClip::setClipStateBit(unsigned char bit)
+{
+    _stateBits |= bit;
+}
+
+void AnimationClip::resetClipStateBit(unsigned char bit)
+{
+    _stateBits &= ~bit;
+}
+
+AnimationClip* AnimationClip::clone(Animation* animation) const
+{
+    // Don't clone the elapsed time, listeners or crossfade information.
+    AnimationClip* newClip = new AnimationClip(getId(), animation, getStartTime(), getEndTime());
+    newClip->setSpeed(getSpeed());
+    newClip->setRepeatCount(getRepeatCount());
+    newClip->setBlendWeight(getBlendWeight());
+    
+    size_t size = _values.size();
+    newClip->_values.resize(size, NULL);
+    for (size_t i = 0; i < size; ++i)
+    {
+        if (newClip->_values[i] == NULL)
+        {
+            newClip->_values[i] = new AnimationValue(*_values[i]);
+        }
+        else
+        {
+            *newClip->_values[i] = *_values[i];
+        }
+    }
+    return newClip;
+}
+
+AnimationClip::ScriptListener::ScriptListener(const std::string& function)
+{
+    // Store the function name.
+    this->function = Game::getInstance()->getScriptController()->loadUrl(function.c_str());
+}
+
+void AnimationClip::ScriptListener::animationEvent(AnimationClip* clip, EventType type)
+{
+    Game::getInstance()->getScriptController()->executeFunction<void>(function.c_str(), "<AnimationClip>[AnimationClip::Listener::EventType]", clip, type);
+}
+
+
+}

+ 489 - 509
gameplay/src/Model.cpp

@@ -1,509 +1,489 @@
-#include "Base.h"
-#include "Model.h"
-#include "MeshPart.h"
-#include "Scene.h"
-#include "Technique.h"
-#include "Pass.h"
-#include "Node.h"
-
-namespace gameplay
-{
-
-Model::Model(Mesh* mesh) :
-    _mesh(mesh), _material(NULL), _partCount(0), _partMaterials(NULL), _node(NULL), _skin(NULL), _shadowCaster(true), _shadowReceiver(true)
-{
-    GP_ASSERT(mesh);
-    _partCount = mesh->getPartCount();
-}
-
-Model::~Model()
-{
-    SAFE_RELEASE(_material);
-
-    if (_partMaterials)
-    {
-        for (unsigned int i = 0; i < _partCount; ++i)
-        {
-            SAFE_RELEASE(_partMaterials[i]);
-        }
-        SAFE_DELETE_ARRAY(_partMaterials);
-    }
-
-    SAFE_RELEASE(_mesh);
-
-    SAFE_DELETE(_skin);
-}
-
-Model* Model::create(Mesh* mesh)
-{
-    GP_ASSERT(mesh);
-    mesh->addRef();
-    return new Model(mesh);
-}
-
-Mesh* Model::getMesh() const
-{
-    return _mesh;
-}
-
-unsigned int Model::getMeshPartCount() const
-{
-    GP_ASSERT(_mesh);
-    return _mesh->getPartCount();
-}
-
-Material* Model::getMaterial(int partIndex)
-{
-    GP_ASSERT(partIndex == -1 || partIndex >= 0);
-
-    Material* m = NULL;
-
-    if (partIndex < 0)
-        return _material;
-
-    if (partIndex >= (int)_partCount)
-        return NULL;
-
-    // Look up explicitly specified part material.
-    if (_partMaterials)
-    {
-        m = _partMaterials[partIndex];
-    }
-
-    if (m == NULL)
-    {
-        // Return the shared material.
-         m = _material;
-    }
-
-    return m;
-}
-
-void Model::setMaterial(Material* material, int partIndex)
-{
-    GP_ASSERT(partIndex == -1 || (partIndex >= 0 && partIndex < (int)getMeshPartCount()));
-
-    Material* oldMaterial = NULL;
-
-    if (partIndex == -1)
-    {
-        oldMaterial = _material;
-
-        // Set new shared material.
-        if (material)
-        {
-            _material = material;
-            _material->addRef();
-        }
-    }
-    else if (partIndex >= 0 && partIndex < (int)getMeshPartCount())
-    {
-        // Ensure mesh part count is up-to-date.
-        validatePartCount();
-
-        // Release existing part material and part binding.
-        if (_partMaterials)
-        {
-            oldMaterial = _partMaterials[partIndex];
-        }
-        else
-        {
-            // Allocate part arrays for the first time.
-            if (_partMaterials == NULL)
-            {
-                _partMaterials = new Material*[_partCount];
-                memset(_partMaterials, 0, sizeof(Material*) * _partCount);
-            }
-        }
-
-        // Set new part material.
-        if (material)
-        {
-            _partMaterials[partIndex] = material;
-            material->addRef();
-        }
-    }
-
-    // Release existing material and binding.
-    if (oldMaterial)
-    {
-        for (unsigned int i = 0, tCount = oldMaterial->getTechniqueCount(); i < tCount; ++i)
-        {
-            Technique* t = oldMaterial->getTechniqueByIndex(i);
-            GP_ASSERT(t);
-            for (unsigned int j = 0, pCount = t->getPassCount(); j < pCount; ++j)
-            {
-                GP_ASSERT(t->getPassByIndex(j));
-                t->getPassByIndex(j)->setVertexAttributeBinding(NULL);
-            }
-        }
-        SAFE_RELEASE(oldMaterial);
-    }
-
-    if (material)
-    {
-        // Hookup vertex attribute bindings for all passes in the new material.
-        for (unsigned int i = 0, tCount = material->getTechniqueCount(); i < tCount; ++i)
-        {
-            Technique* t = material->getTechniqueByIndex(i);
-            GP_ASSERT(t);
-            for (unsigned int j = 0, pCount = t->getPassCount(); j < pCount; ++j)
-            {
-                Pass* p = t->getPassByIndex(j);
-                GP_ASSERT(p);
-                VertexAttributeBinding* b = VertexAttributeBinding::create(_mesh, p->getEffect());
-                p->setVertexAttributeBinding(b);
-                SAFE_RELEASE(b);
-            }
-        }
-
-        // Apply node binding for the new material.
-        if (_node)
-        {
-            setMaterialNodeBinding(material);
-        }
-    }
-}
-
-Material* Model::setMaterial(const char* vshPath, const char* fshPath, const char* defines, int partIndex)
-{
-    // Try to create a Material with the given parameters.
-    Material* material = Material::create(vshPath, fshPath, defines);
-    if (material == NULL)
-    {
-        GP_ERROR("Failed to create material for model.");
-        return NULL;
-    }
-
-    // Assign the material to us.
-    setMaterial(material, partIndex);
-
-    // Release the material since we now have a reference to it.
-    material->release();
-
-    return material;
-}
-
-Material* Model::setMaterial(const char* materialPath, int partIndex)
-{
-    // Try to create a Material from the specified material file.
-    Material* material = Material::create(materialPath);
-    if (material == NULL)
-    {
-        GP_ERROR("Failed to create material for model.");
-        return NULL;
-    }
-
-    // Assign the material to us
-    setMaterial(material, partIndex);
-
-    // Release the material since we now have a reference to it
-    material->release();
-
-    return material;
-}
-
-bool Model::hasMaterial(unsigned int partIndex) const
-{
-    return (partIndex < _partCount && _partMaterials && _partMaterials[partIndex]);
-}
-
-MeshSkin* Model::getSkin() const
-{
-    return _skin;
-}
-
-void Model::setSkin(MeshSkin* skin)
-{
-    if (_skin != skin)
-    {
-        // Free the old skin
-        SAFE_DELETE(_skin);
-
-        // Assign the new skin
-        _skin = skin;
-        if (_skin)
-            _skin->_model = this;
-    }
-}
-
-Node* Model::getNode() const
-{
-    return _node;
-}
-
-void Model::setNode(Node* node)
-{
-    _node = node;
-
-    // Re-bind node related material parameters
-    if (node)
-    {
-        if (_material)
-        {
-           setMaterialNodeBinding(_material);
-        }
-        if (_partMaterials)
-        {
-            for (unsigned int i = 0; i < _partCount; ++i)
-            {
-                if (_partMaterials[i])
-                {
-                    setMaterialNodeBinding(_partMaterials[i]);
-                }
-            }
-        }
-    }
-}
-
-void Model::setShadowCaster(bool casts)
-{
-    _shadowCaster = casts;
-}
-
-bool Model::isShadowCaster() const
-{
-    return _shadowCaster;
-}
-
-void Model::setShadowReceiver(bool receives)
-{
-    _shadowReceiver = receives;
-}
-
-bool Model::isShadowReceiver() const
-{
-    return _shadowReceiver;
-}
-
-static bool drawWireframe(Mesh* mesh)
-{
-    switch (mesh->getPrimitiveType())
-    {
-    case Mesh::TRIANGLES:
-        {
-            unsigned int vertexCount = mesh->getVertexCount();
-            for (unsigned int i = 0; i < vertexCount; i += 3)
-            {
-                GL_ASSERT( glDrawArrays(GL_LINE_LOOP, i, 3) );
-            }
-        }
-        return true;
-
-    case Mesh::TRIANGLE_STRIP:
-        {
-            unsigned int vertexCount = mesh->getVertexCount();
-            for (unsigned int i = 2; i < vertexCount; ++i)
-            {
-                GL_ASSERT( glDrawArrays(GL_LINE_LOOP, i-2, 3) );
-            }
-        }
-        return true;
-
-    default:
-        // not supported
-        return false;
-    }
-}
-
-static bool drawWireframe(MeshPart* part)
-{
-    unsigned int indexCount = part->getIndexCount();
-    unsigned int indexSize = 0;
-    switch (part->getIndexFormat())
-    {
-    case Mesh::INDEX8:
-        indexSize = 1;
-        break;
-    case Mesh::INDEX16:
-        indexSize = 2;
-        break;
-    case Mesh::INDEX32:
-        indexSize = 4;
-        break;
-    default:
-        GP_ERROR("Unsupported index format (%d).", part->getIndexFormat());
-        return false;
-    }
-
-    switch (part->getPrimitiveType())
-    {
-    case Mesh::TRIANGLES:
-        {
-            for (unsigned int i = 0; i < indexCount; i += 3)
-            {
-                GL_ASSERT( glDrawElements(GL_LINE_LOOP, 3, part->getIndexFormat(), ((const GLvoid*)(i*indexSize))) );
-            }
-        }
-        return true;
-
-    case Mesh::TRIANGLE_STRIP:
-        {
-            for (unsigned int i = 2; i < indexCount; ++i)
-            {
-                GL_ASSERT( glDrawElements(GL_LINE_LOOP, 3, part->getIndexFormat(), ((const GLvoid*)((i-2)*indexSize))) );
-            }
-        }
-        return true;
-
-    default:
-        // not supported
-        return false;
-    }
-}
-
-unsigned int Model::draw(bool wireframe)
-{
-    GP_ASSERT(_mesh);
-
-    unsigned int partCount = _mesh->getPartCount();
-    if (partCount == 0)
-    {
-        // No mesh parts (index buffers).
-        if (_material)
-        {
-            Technique* technique = _material->getTechnique();
-            GP_ASSERT(technique);
-            unsigned int passCount = technique->getPassCount();
-            for (unsigned int i = 0; i < passCount; ++i)
-            {
-                Pass* pass = technique->getPassByIndex(i);
-                GP_ASSERT(pass);
-                pass->bind();
-                GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) );
-                if (!wireframe || !drawWireframe(_mesh))
-                {
-                    GL_ASSERT( glDrawArrays(_mesh->getPrimitiveType(), 0, _mesh->getVertexCount()) );
-                }
-                pass->unbind();
-            }
-        }
-    }
-    else
-    {
-        for (unsigned int i = 0; i < partCount; ++i)
-        {
-            MeshPart* part = _mesh->getPart(i);
-            GP_ASSERT(part);
-
-            // Get the material for this mesh part.
-            Material* material = getMaterial(i);
-            if (material)
-            {
-                Technique* technique = material->getTechnique();
-                GP_ASSERT(technique);
-                unsigned int passCount = technique->getPassCount();
-                for (unsigned int j = 0; j < passCount; ++j)
-                {
-                    Pass* pass = technique->getPassByIndex(j);
-                    GP_ASSERT(pass);
-                    pass->bind();
-                    GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, part->_indexBuffer) );
-                    if (!wireframe || !drawWireframe(part))
-                    {
-                        GL_ASSERT( glDrawElements(part->getPrimitiveType(), part->getIndexCount(), part->getIndexFormat(), 0) );
-                    }
-                    pass->unbind();
-                }
-            }
-        }
-    }
-    return partCount;
-}
-
-void Model::setMaterialNodeBinding(Material *material)
-{
-    GP_ASSERT(material);
-
-    if (_node)
-    {
-        material->setNodeBinding(_node);
-
-        unsigned int techniqueCount = material->getTechniqueCount();
-        for (unsigned int i = 0; i < techniqueCount; ++i)
-        {
-            Technique* technique = material->getTechniqueByIndex(i);
-            GP_ASSERT(technique);
-            
-            technique->setNodeBinding(_node);
-
-            unsigned int passCount = technique->getPassCount();
-            for (unsigned int j = 0; j < passCount; ++j)
-            {
-                Pass* pass = technique->getPassByIndex(j);
-                GP_ASSERT(pass);
-
-                pass->setNodeBinding(_node);
-            }
-        }
-    }
-}
-
-Model* Model::clone(NodeCloneContext &context)
-{
-    Model* model = Model::create(getMesh());
-    if (!model)
-    {
-        GP_ERROR("Failed to clone model.");
-        return NULL;
-    }
-
-    if (getSkin())
-    {
-        model->setSkin(getSkin()->clone(context));
-    }
-    if (getMaterial())
-    {
-        Material* materialClone = getMaterial()->clone(context);
-        if (!materialClone)
-        {
-            GP_ERROR("Failed to clone material for model.");
-            return model;
-        }
-        model->setMaterial(materialClone);
-        materialClone->release();
-    }
-    if (_partMaterials)
-    {
-        GP_ASSERT(_partCount == model->_partCount);
-        for (unsigned int i = 0; i < _partCount; ++i)
-        {
-            if (_partMaterials[i])
-            {
-                Material* materialClone = _partMaterials[i]->clone(context);
-                model->setMaterial(materialClone, i);
-                materialClone->release();
-            }
-        }
-    }
-    return model;
-}
-
-void Model::validatePartCount()
-{
-    GP_ASSERT(_mesh);
-    unsigned int partCount = _mesh->getPartCount();
-
-    if (_partCount != partCount)
-    {
-        // Allocate new arrays and copy old items to them.
-        if (_partMaterials)
-        {
-            Material** oldArray = _partMaterials;
-            _partMaterials = new Material*[partCount];
-            memset(_partMaterials, 0, sizeof(Material*) * partCount);
-            if (oldArray)
-            {
-                for (unsigned int i = 0; i < _partCount; ++i)
-                {
-                    _partMaterials[i] = oldArray[i];
-                }
-            }
-            SAFE_DELETE_ARRAY(oldArray);
-        }
-        // Update local part count.
-        _partCount = _mesh->getPartCount();
-    }
-}
-
-}
+#include "Base.h"
+#include "Model.h"
+#include "MeshPart.h"
+#include "Scene.h"
+#include "Technique.h"
+#include "Pass.h"
+#include "Node.h"
+
+namespace gameplay
+{
+
+Model::Model(Mesh* mesh) :
+    _mesh(mesh), _material(NULL), _partCount(0), _partMaterials(NULL), _node(NULL), _skin(NULL)
+{
+    GP_ASSERT(mesh);
+    _partCount = mesh->getPartCount();
+}
+
+Model::~Model()
+{
+    SAFE_RELEASE(_material);
+
+    if (_partMaterials)
+    {
+        for (unsigned int i = 0; i < _partCount; ++i)
+        {
+            SAFE_RELEASE(_partMaterials[i]);
+        }
+        SAFE_DELETE_ARRAY(_partMaterials);
+    }
+
+    SAFE_RELEASE(_mesh);
+
+    SAFE_DELETE(_skin);
+}
+
+Model* Model::create(Mesh* mesh)
+{
+    GP_ASSERT(mesh);
+    mesh->addRef();
+    return new Model(mesh);
+}
+
+Mesh* Model::getMesh() const
+{
+    return _mesh;
+}
+
+unsigned int Model::getMeshPartCount() const
+{
+    GP_ASSERT(_mesh);
+    return _mesh->getPartCount();
+}
+
+Material* Model::getMaterial(int partIndex)
+{
+    GP_ASSERT(partIndex == -1 || partIndex >= 0);
+
+    Material* m = NULL;
+
+    if (partIndex < 0)
+        return _material;
+
+    if (partIndex >= (int)_partCount)
+        return NULL;
+
+    // Look up explicitly specified part material.
+    if (_partMaterials)
+    {
+        m = _partMaterials[partIndex];
+    }
+
+    if (m == NULL)
+    {
+        // Return the shared material.
+         m = _material;
+    }
+
+    return m;
+}
+
+void Model::setMaterial(Material* material, int partIndex)
+{
+    GP_ASSERT(partIndex == -1 || (partIndex >= 0 && partIndex < (int)getMeshPartCount()));
+
+    Material* oldMaterial = NULL;
+
+    if (partIndex == -1)
+    {
+        oldMaterial = _material;
+
+        // Set new shared material.
+        if (material)
+        {
+            _material = material;
+            _material->addRef();
+        }
+    }
+    else if (partIndex >= 0 && partIndex < (int)getMeshPartCount())
+    {
+        // Ensure mesh part count is up-to-date.
+        validatePartCount();
+
+        // Release existing part material and part binding.
+        if (_partMaterials)
+        {
+            oldMaterial = _partMaterials[partIndex];
+        }
+        else
+        {
+            // Allocate part arrays for the first time.
+            if (_partMaterials == NULL)
+            {
+                _partMaterials = new Material*[_partCount];
+                memset(_partMaterials, 0, sizeof(Material*) * _partCount);
+            }
+        }
+
+        // Set new part material.
+        if (material)
+        {
+            _partMaterials[partIndex] = material;
+            material->addRef();
+        }
+    }
+
+    // Release existing material and binding.
+    if (oldMaterial)
+    {
+        for (unsigned int i = 0, tCount = oldMaterial->getTechniqueCount(); i < tCount; ++i)
+        {
+            Technique* t = oldMaterial->getTechniqueByIndex(i);
+            GP_ASSERT(t);
+            for (unsigned int j = 0, pCount = t->getPassCount(); j < pCount; ++j)
+            {
+                GP_ASSERT(t->getPassByIndex(j));
+                t->getPassByIndex(j)->setVertexAttributeBinding(NULL);
+            }
+        }
+        SAFE_RELEASE(oldMaterial);
+    }
+
+    if (material)
+    {
+        // Hookup vertex attribute bindings for all passes in the new material.
+        for (unsigned int i = 0, tCount = material->getTechniqueCount(); i < tCount; ++i)
+        {
+            Technique* t = material->getTechniqueByIndex(i);
+            GP_ASSERT(t);
+            for (unsigned int j = 0, pCount = t->getPassCount(); j < pCount; ++j)
+            {
+                Pass* p = t->getPassByIndex(j);
+                GP_ASSERT(p);
+                VertexAttributeBinding* b = VertexAttributeBinding::create(_mesh, p->getEffect());
+                p->setVertexAttributeBinding(b);
+                SAFE_RELEASE(b);
+            }
+        }
+
+        // Apply node binding for the new material.
+        if (_node)
+        {
+            setMaterialNodeBinding(material);
+        }
+    }
+}
+
+Material* Model::setMaterial(const char* vshPath, const char* fshPath, const char* defines, int partIndex)
+{
+    // Try to create a Material with the given parameters.
+    Material* material = Material::create(vshPath, fshPath, defines);
+    if (material == NULL)
+    {
+        GP_ERROR("Failed to create material for model.");
+        return NULL;
+    }
+
+    // Assign the material to us.
+    setMaterial(material, partIndex);
+
+    // Release the material since we now have a reference to it.
+    material->release();
+
+    return material;
+}
+
+Material* Model::setMaterial(const char* materialPath, int partIndex)
+{
+    // Try to create a Material from the specified material file.
+    Material* material = Material::create(materialPath);
+    if (material == NULL)
+    {
+        GP_ERROR("Failed to create material for model.");
+        return NULL;
+    }
+
+    // Assign the material to us
+    setMaterial(material, partIndex);
+
+    // Release the material since we now have a reference to it
+    material->release();
+
+    return material;
+}
+
+bool Model::hasMaterial(unsigned int partIndex) const
+{
+    return (partIndex < _partCount && _partMaterials && _partMaterials[partIndex]);
+}
+
+MeshSkin* Model::getSkin() const
+{
+    return _skin;
+}
+
+void Model::setSkin(MeshSkin* skin)
+{
+    if (_skin != skin)
+    {
+        // Free the old skin
+        SAFE_DELETE(_skin);
+
+        // Assign the new skin
+        _skin = skin;
+        if (_skin)
+            _skin->_model = this;
+    }
+}
+
+Node* Model::getNode() const
+{
+    return _node;
+}
+
+void Model::setNode(Node* node)
+{
+    _node = node;
+
+    // Re-bind node related material parameters
+    if (node)
+    {
+        if (_material)
+        {
+           setMaterialNodeBinding(_material);
+        }
+        if (_partMaterials)
+        {
+            for (unsigned int i = 0; i < _partCount; ++i)
+            {
+                if (_partMaterials[i])
+                {
+                    setMaterialNodeBinding(_partMaterials[i]);
+                }
+            }
+        }
+    }
+}
+
+static bool drawWireframe(Mesh* mesh)
+{
+    switch (mesh->getPrimitiveType())
+    {
+    case Mesh::TRIANGLES:
+        {
+            unsigned int vertexCount = mesh->getVertexCount();
+            for (unsigned int i = 0; i < vertexCount; i += 3)
+            {
+                GL_ASSERT( glDrawArrays(GL_LINE_LOOP, i, 3) );
+            }
+        }
+        return true;
+
+    case Mesh::TRIANGLE_STRIP:
+        {
+            unsigned int vertexCount = mesh->getVertexCount();
+            for (unsigned int i = 2; i < vertexCount; ++i)
+            {
+                GL_ASSERT( glDrawArrays(GL_LINE_LOOP, i-2, 3) );
+            }
+        }
+        return true;
+
+    default:
+        // not supported
+        return false;
+    }
+}
+
+static bool drawWireframe(MeshPart* part)
+{
+    unsigned int indexCount = part->getIndexCount();
+    unsigned int indexSize = 0;
+    switch (part->getIndexFormat())
+    {
+    case Mesh::INDEX8:
+        indexSize = 1;
+        break;
+    case Mesh::INDEX16:
+        indexSize = 2;
+        break;
+    case Mesh::INDEX32:
+        indexSize = 4;
+        break;
+    default:
+        GP_ERROR("Unsupported index format (%d).", part->getIndexFormat());
+        return false;
+    }
+
+    switch (part->getPrimitiveType())
+    {
+    case Mesh::TRIANGLES:
+        {
+            for (unsigned int i = 0; i < indexCount; i += 3)
+            {
+                GL_ASSERT( glDrawElements(GL_LINE_LOOP, 3, part->getIndexFormat(), ((const GLvoid*)(i*indexSize))) );
+            }
+        }
+        return true;
+
+    case Mesh::TRIANGLE_STRIP:
+        {
+            for (unsigned int i = 2; i < indexCount; ++i)
+            {
+                GL_ASSERT( glDrawElements(GL_LINE_LOOP, 3, part->getIndexFormat(), ((const GLvoid*)((i-2)*indexSize))) );
+            }
+        }
+        return true;
+
+    default:
+        // not supported
+        return false;
+    }
+}
+
+unsigned int Model::draw(bool wireframe)
+{
+    GP_ASSERT(_mesh);
+
+    unsigned int partCount = _mesh->getPartCount();
+    if (partCount == 0)
+    {
+        // No mesh parts (index buffers).
+        if (_material)
+        {
+            Technique* technique = _material->getTechnique();
+            GP_ASSERT(technique);
+            unsigned int passCount = technique->getPassCount();
+            for (unsigned int i = 0; i < passCount; ++i)
+            {
+                Pass* pass = technique->getPassByIndex(i);
+                GP_ASSERT(pass);
+                pass->bind();
+                GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) );
+                if (!wireframe || !drawWireframe(_mesh))
+                {
+                    GL_ASSERT( glDrawArrays(_mesh->getPrimitiveType(), 0, _mesh->getVertexCount()) );
+                }
+                pass->unbind();
+            }
+        }
+    }
+    else
+    {
+        for (unsigned int i = 0; i < partCount; ++i)
+        {
+            MeshPart* part = _mesh->getPart(i);
+            GP_ASSERT(part);
+
+            // Get the material for this mesh part.
+            Material* material = getMaterial(i);
+            if (material)
+            {
+                Technique* technique = material->getTechnique();
+                GP_ASSERT(technique);
+                unsigned int passCount = technique->getPassCount();
+                for (unsigned int j = 0; j < passCount; ++j)
+                {
+                    Pass* pass = technique->getPassByIndex(j);
+                    GP_ASSERT(pass);
+                    pass->bind();
+                    GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, part->_indexBuffer) );
+                    if (!wireframe || !drawWireframe(part))
+                    {
+                        GL_ASSERT( glDrawElements(part->getPrimitiveType(), part->getIndexCount(), part->getIndexFormat(), 0) );
+                    }
+                    pass->unbind();
+                }
+            }
+        }
+    }
+    return partCount;
+}
+
+void Model::setMaterialNodeBinding(Material *material)
+{
+    GP_ASSERT(material);
+
+    if (_node)
+    {
+        material->setNodeBinding(_node);
+
+        unsigned int techniqueCount = material->getTechniqueCount();
+        for (unsigned int i = 0; i < techniqueCount; ++i)
+        {
+            Technique* technique = material->getTechniqueByIndex(i);
+            GP_ASSERT(technique);
+            
+            technique->setNodeBinding(_node);
+
+            unsigned int passCount = technique->getPassCount();
+            for (unsigned int j = 0; j < passCount; ++j)
+            {
+                Pass* pass = technique->getPassByIndex(j);
+                GP_ASSERT(pass);
+
+                pass->setNodeBinding(_node);
+            }
+        }
+    }
+}
+
+Model* Model::clone(NodeCloneContext &context)
+{
+    Model* model = Model::create(getMesh());
+    if (!model)
+    {
+        GP_ERROR("Failed to clone model.");
+        return NULL;
+    }
+
+    if (getSkin())
+    {
+        model->setSkin(getSkin()->clone(context));
+    }
+    if (getMaterial())
+    {
+        Material* materialClone = getMaterial()->clone(context);
+        if (!materialClone)
+        {
+            GP_ERROR("Failed to clone material for model.");
+            return model;
+        }
+        model->setMaterial(materialClone);
+        materialClone->release();
+    }
+    if (_partMaterials)
+    {
+        GP_ASSERT(_partCount == model->_partCount);
+        for (unsigned int i = 0; i < _partCount; ++i)
+        {
+            if (_partMaterials[i])
+            {
+                Material* materialClone = _partMaterials[i]->clone(context);
+                model->setMaterial(materialClone, i);
+                materialClone->release();
+            }
+        }
+    }
+    return model;
+}
+
+void Model::validatePartCount()
+{
+    GP_ASSERT(_mesh);
+    unsigned int partCount = _mesh->getPartCount();
+
+    if (_partCount != partCount)
+    {
+        // Allocate new arrays and copy old items to them.
+        if (_partMaterials)
+        {
+            Material** oldArray = _partMaterials;
+            _partMaterials = new Material*[partCount];
+            memset(_partMaterials, 0, sizeof(Material*) * partCount);
+            if (oldArray)
+            {
+                for (unsigned int i = 0; i < _partCount; ++i)
+                {
+                    _partMaterials[i] = oldArray[i];
+                }
+            }
+            SAFE_DELETE_ARRAY(oldArray);
+        }
+        // Update local part count.
+        _partCount = _mesh->getPartCount();
+    }
+}
+
+}

+ 209 - 248
gameplay/src/Model.h

@@ -1,248 +1,209 @@
-#ifndef MODEL_H_
-#define MODEL_H_
-
-#include "Mesh.h"
-#include "MeshSkin.h"
-#include "Material.h"
-
-namespace gameplay
-{
-
-class Bundle;
-class MeshSkin;
-class Node;
-class NodeCloneContext;
-
-/**
- * Defines a Model (MeshRenderer) which is an instance of a Mesh that can be drawn with the specified Materials.
- */
-class Model : public Ref
-{
-    friend class Node;
-    friend class Scene;
-    friend class Mesh;
-    friend class Bundle;
-
-public:
-
-    /**
-     * Creates a new Model.
-     * @script{create}
-     */
-    static Model* create(Mesh* mesh);
-
-    /**
-     * Returns the Mesh for this Model.
-     *
-     * @return The Mesh for this Model.
-     */
-    Mesh* getMesh() const;
-
-    /**
-     * Returns the number of parts in the Mesh for this Model.
-     *
-     * @return The number of parts in the Mesh for this Model.
-     */
-    unsigned int getMeshPartCount() const;
-
-    /**
-     * Returns the Material currently bound to the specified mesh part.
-     *
-     * If partIndex is >= 0 and no Material is directly bound to the specified
-     * mesh part, the shared Material will be returned.
-     *
-     * @param partIndex The index of the mesh part whose Material to return (-1 for shared material).
-     *
-     * @return The requested Material, or NULL if no Material is set.
-     */
-    Material* getMaterial(int partIndex = -1);
-
-    /**
-     * Sets a material to be used for drawing this Model.
-     *
-     * The specified Material is applied for the MeshPart at the given index in
-     * this Model's Mesh. A partIndex of -1 sets a shared Material for
-     * all mesh parts, whereas a value of 0 or greater sets the Material for the
-     * specified mesh part only.
-     *
-     * Mesh parts will use an explicitly set part material, if set; otherwise they
-     * will use the globally set material.
-     *
-     * @param material The new material.
-     * @param partIndex The index of the mesh part to set the material for (-1 for shared material).
-     */
-    void setMaterial(Material* material, int partIndex = -1);
-
-    /**
-     * Sets a material to be used for drawing this Model.
-     *
-     * A Material is created from the given vertex and fragment shader source files.
-     * The Material is applied for the MeshPart at the given index in this Model's
-     * Mesh. A partIndex of -1 sets a shared Material for all mesh parts, whereas a
-     * value of 0 or greater sets the Material for the specified mesh part only.
-     *
-     * Mesh parts will use an explicitly set part material, if set; otherwise they
-     * will use the globally set material.
-     *
-     * @param vshPath The path to the vertex shader file.
-     * @param fshPath The path to the fragment shader file.
-     * @param defines A new-line delimited list of preprocessor defines. May be NULL.
-     * @param partIndex The index of the mesh part to set the material for (-1 for shared material).
-     *
-     * @return The newly created and bound Material, or NULL if the Material could not be created.
-     */
-    Material* setMaterial(const char* vshPath, const char* fshPath, const char* defines = NULL, int partIndex = -1);
-
-    /**
-     * Sets a material to be used for drawing this Model.
-     *
-     * A Material is created from the specified material file.
-     * The Material is applied for the MeshPart at the given index in this Model's
-     * Mesh. A partIndex of -1 sets a shared Material for all mesh parts, whereas a
-     * value of 0 or greater sets the Material for the specified mesh part only.
-     *
-     * Mesh parts will use an explicitly set part material, if set; otherwise they
-     * will use the globally set material.
-     *
-     * @param materialPath The path to the material file.
-     * @param partIndex The index of the mesh part to set the material for (-1 for shared material).
-     *
-     * @return The newly created and bound Material, or NULL if the Material could not be created.
-     */
-    Material* setMaterial(const char* materialPath, int partIndex = -1);
-
-    /**
-     * Determines if a custom (non-shared) material is set for the specified part index.
-     *
-     * @param partIndex MeshPart index.
-     *
-     * @return True if a custom MeshPart material is set for the specified index, false otherwise.
-     */
-    bool hasMaterial(unsigned int partIndex) const;
-
-    /**
-     * Returns the MeshSkin.
-     *
-     * @return The MeshSkin, or NULL if one is not set.
-     */
-    MeshSkin* getSkin() const;
-
-    /**
-     * Returns the node that is associated with this model.
-     *
-     * @return The node that is associated with this model.
-     */
-    Node* getNode() const;
-
-    /**
-     * Sets the node that is associated with this model.
-     *
-     * This method is automatically called when a model is attached to a node
-     * and therefore should not normally be called explicitly.
-     *
-     * @param node The node that is associated with this model.
-     */
-    void setNode(Node* node);
-
-    /**
-     * Sets if this model cast shadows.
-     *
-     * Note: This is only applied to a SceneRenderer.
-     *
-     * @param casts if this model casts shadows
-     * @see SceneRenderer
-     */
-    void setShadowCaster(bool casts);
-
-    /**
-     * Returns whether this model cast shadows.
-     *
-     * Note: This is only applied to a SceneRenderer.
-     *
-     * @return if this model casts shadows
-     * @see SceneRenderer
-     */
-    bool isShadowCaster() const;
-
-    /**
-     * Sets if this object receives shadows.
-     *
-     * @param bool if this object receives shadows
-     */
-    void setShadowReceiver(bool receives);
-
-    /**
-     * Returns whether this objects receives shadows.
-     *
-     * Note: This is only applied to a SceneRenderer.
-     *
-     * @return if this object receives shadows
-     * @see SceneRenderer
-     */
-    bool isShadowReceiver() const;
-
-    /**
-     * Draws this mesh instance.
-     *
-     * This method binds the vertex buffer and index buffers for the Mesh and
-     * all of its MeshParts and draws the mesh geometry. Any other state
-     * necessary to render the Mesh, such as rendering states, shader state,
-     * and so on, should be set up before calling this method.
-     *
-     * @param wireframe If true, draw the model in wireframe mode.
-     * @return The number of draw calls (mesh parts).
-     */
-    unsigned int draw(bool wireframe = false);
-
-private:
-
-    /**
-     * Constructor.
-     */
-    Model(Mesh* mesh);
-
-    /**
-     * Destructor. Hidden use release() instead.
-     */
-    ~Model();
-
-    /**
-     * Hidden copy assignment operator.
-     */
-    Model& operator=(const Model&);
-
-    /**
-     * Sets the MeshSkin for this model.
-     *
-     * @param skin The MeshSkin for this model.
-     */
-    void setSkin(MeshSkin* skin);
-
-    /**
-     * Sets the specified material's node binding to this model's node.
-     */
-    void setMaterialNodeBinding(Material *m);
-
-    /**
-     * Clones the model and returns a new model.
-     *
-     * @param context The clone context.
-     * @return The new cloned model.
-     */
-    Model* clone(NodeCloneContext &context);
-
-    void validatePartCount();
-
-    Mesh* _mesh;
-    Material* _material;
-    unsigned int _partCount;
-    Material** _partMaterials;
-    Node* _node;
-    MeshSkin* _skin;
-    bool _shadowCaster;
-    bool _shadowReceiver;
-};
-
-}
-
-#endif
+#ifndef MODEL_H_
+#define MODEL_H_
+
+#include "Mesh.h"
+#include "MeshSkin.h"
+#include "Material.h"
+
+namespace gameplay
+{
+
+class Bundle;
+class MeshSkin;
+class Node;
+class NodeCloneContext;
+
+/**
+ * Defines a Model (MeshRenderer) which is an instance of a Mesh that can be drawn with the specified Materials.
+ */
+class Model : public Ref
+{
+    friend class Node;
+    friend class Scene;
+    friend class Mesh;
+    friend class Bundle;
+
+public:
+
+    /**
+     * Creates a new Model.
+     * @script{create}
+     */
+    static Model* create(Mesh* mesh);
+
+    /**
+     * Returns the Mesh for this Model.
+     *
+     * @return The Mesh for this Model.
+     */
+    Mesh* getMesh() const;
+
+    /**
+     * Returns the number of parts in the Mesh for this Model.
+     *
+     * @return The number of parts in the Mesh for this Model.
+     */
+    unsigned int getMeshPartCount() const;
+
+    /**
+     * Returns the Material currently bound to the specified mesh part.
+     *
+     * If partIndex is >= 0 and no Material is directly bound to the specified
+     * mesh part, the shared Material will be returned.
+     *
+     * @param partIndex The index of the mesh part whose Material to return (-1 for shared material).
+     *
+     * @return The requested Material, or NULL if no Material is set.
+     */
+    Material* getMaterial(int partIndex = -1);
+
+    /**
+     * Sets a material to be used for drawing this Model.
+     *
+     * The specified Material is applied for the MeshPart at the given index in
+     * this Model's Mesh. A partIndex of -1 sets a shared Material for
+     * all mesh parts, whereas a value of 0 or greater sets the Material for the
+     * specified mesh part only.
+     *
+     * Mesh parts will use an explicitly set part material, if set; otherwise they
+     * will use the globally set material.
+     *
+     * @param material The new material.
+     * @param partIndex The index of the mesh part to set the material for (-1 for shared material).
+     */
+    void setMaterial(Material* material, int partIndex = -1);
+
+    /**
+     * Sets a material to be used for drawing this Model.
+     *
+     * A Material is created from the given vertex and fragment shader source files.
+     * The Material is applied for the MeshPart at the given index in this Model's
+     * Mesh. A partIndex of -1 sets a shared Material for all mesh parts, whereas a
+     * value of 0 or greater sets the Material for the specified mesh part only.
+     *
+     * Mesh parts will use an explicitly set part material, if set; otherwise they
+     * will use the globally set material.
+     *
+     * @param vshPath The path to the vertex shader file.
+     * @param fshPath The path to the fragment shader file.
+     * @param defines A new-line delimited list of preprocessor defines. May be NULL.
+     * @param partIndex The index of the mesh part to set the material for (-1 for shared material).
+     *
+     * @return The newly created and bound Material, or NULL if the Material could not be created.
+     */
+    Material* setMaterial(const char* vshPath, const char* fshPath, const char* defines = NULL, int partIndex = -1);
+
+    /**
+     * Sets a material to be used for drawing this Model.
+     *
+     * A Material is created from the specified material file.
+     * The Material is applied for the MeshPart at the given index in this Model's
+     * Mesh. A partIndex of -1 sets a shared Material for all mesh parts, whereas a
+     * value of 0 or greater sets the Material for the specified mesh part only.
+     *
+     * Mesh parts will use an explicitly set part material, if set; otherwise they
+     * will use the globally set material.
+     *
+     * @param materialPath The path to the material file.
+     * @param partIndex The index of the mesh part to set the material for (-1 for shared material).
+     *
+     * @return The newly created and bound Material, or NULL if the Material could not be created.
+     */
+    Material* setMaterial(const char* materialPath, int partIndex = -1);
+
+    /**
+     * Determines if a custom (non-shared) material is set for the specified part index.
+     *
+     * @param partIndex MeshPart index.
+     *
+     * @return True if a custom MeshPart material is set for the specified index, false otherwise.
+     */
+    bool hasMaterial(unsigned int partIndex) const;
+
+    /**
+     * Returns the MeshSkin.
+     *
+     * @return The MeshSkin, or NULL if one is not set.
+     */
+    MeshSkin* getSkin() const;
+
+    /**
+     * Returns the node that is associated with this model.
+     *
+     * @return The node that is associated with this model.
+     */
+    Node* getNode() const;
+
+    /**
+     * Sets the node that is associated with this model.
+     *
+     * This method is automatically called when a model is attached to a node
+     * and therefore should not normally be called explicitly.
+     *
+     * @param node The node that is associated with this model.
+     */
+    void setNode(Node* node);
+
+    /**
+     * Draws this mesh instance.
+     *
+     * This method binds the vertex buffer and index buffers for the Mesh and
+     * all of its MeshParts and draws the mesh geometry. Any other state
+     * necessary to render the Mesh, such as rendering states, shader state,
+     * and so on, should be set up before calling this method.
+     *
+     * @param wireframe If true, draw the model in wireframe mode.
+     * @return The number of draw calls (mesh parts).
+     */
+    unsigned int draw(bool wireframe = false);
+
+private:
+
+    /**
+     * Constructor.
+     */
+    Model(Mesh* mesh);
+
+    /**
+     * Destructor. Hidden use release() instead.
+     */
+    ~Model();
+
+    /**
+     * Hidden copy assignment operator.
+     */
+    Model& operator=(const Model&);
+
+    /**
+     * Sets the MeshSkin for this model.
+     *
+     * @param skin The MeshSkin for this model.
+     */
+    void setSkin(MeshSkin* skin);
+
+    /**
+     * Sets the specified material's node binding to this model's node.
+     */
+    void setMaterialNodeBinding(Material *m);
+
+    /**
+     * Clones the model and returns a new model.
+     *
+     * @param context The clone context.
+     * @return The new cloned model.
+     */
+    Model* clone(NodeCloneContext &context);
+
+    void validatePartCount();
+
+    Mesh* _mesh;
+    Material* _material;
+    unsigned int _partCount;
+    Material** _partMaterials;
+    Node* _node;
+    MeshSkin* _skin;
+};
+
+}
+
+#endif

+ 459 - 459
gameplay/src/Scene.cpp

@@ -1,459 +1,459 @@
-#include "Base.h"
-#include "AudioListener.h"
-#include "Scene.h"
-#include "SceneLoader.h"
-#include "MeshSkin.h"
-#include "Joint.h"
-#include "Terrain.h"
-#include "Bundle.h"
-
-namespace gameplay
-{
-
-// Global list of active scenes
-static std::vector<Scene*> __sceneList;
-
-static inline char lowercase(char c)
-{
-    if (c >= 'A' && c <='Z')
-    {
-        c |= 0x20;
-    }
-    return c;
-}
-
-// Returns true if 'str' ends with 'suffix'; false otherwise.
-static bool endsWith(const char* str, const char* suffix, bool ignoreCase)
-{
-    if (str == NULL || suffix == NULL)
-        return false;
-    size_t length = strlen(str);
-    size_t suffixLength = strlen(suffix);
-
-    if (suffixLength > length)
-    {
-        return false;
-    }
-
-    size_t offset = length - suffixLength;
-
-    const char* p = str + offset;
-    while (*p != '\0' && *suffix != '\0')
-    {
-        if (ignoreCase)
-        {
-            if (lowercase(*p) != lowercase(*suffix))
-            {
-                return false;
-            }
-        }
-        else if (*p != *suffix)
-        {
-            return false;
-        }
-        
-        ++p;
-        ++suffix;
-    }
-    return true;
-}
-
-
-Scene::Scene()
-    : _id(""), _activeCamera(NULL), _firstNode(NULL), _lastNode(NULL), _nodeCount(0), _bindAudioListenerToCamera(true), 
-      _nextItr(NULL), _nextReset(true)
-{
-    __sceneList.push_back(this);
-}
-
-Scene::~Scene()
-{
-    // Unbind our active camera from the audio listener
-    if (_activeCamera)
-    {
-        AudioListener* audioListener = AudioListener::getInstance();
-        if (audioListener && (audioListener->getCamera() == _activeCamera))
-        {
-            audioListener->setCamera(NULL);
-        }
-
-        SAFE_RELEASE(_activeCamera);
-    }
-
-    // Remove all nodes from the scene
-    removeAllNodes();
-
-    // Remove the scene from global list
-    std::vector<Scene*>::iterator itr = std::find(__sceneList.begin(), __sceneList.end(), this);
-    if (itr != __sceneList.end())
-        __sceneList.erase(itr);
-}
-
-Scene* Scene::create(const char* id)
-{
-    Scene* scene = new Scene();
-    scene->setId(id);
-    return scene;
-}
-
-Scene* Scene::load(const char* filePath)
-{
-    if (endsWith(filePath, ".gpb", true))
-    {
-        Scene* scene = NULL;
-        Bundle* bundle = Bundle::create(filePath);
-        if (bundle)
-        {
-            scene = bundle->loadScene();
-            SAFE_RELEASE(bundle);
-        }
-        return scene;
-    }
-    return SceneLoader::load(filePath);
-}
-
-Scene* Scene::getScene(const char* id)
-{
-    if (id == NULL)
-        return __sceneList.size() ? __sceneList[0] : NULL;
-
-    for (size_t i = 0, count = __sceneList.size(); i < count; ++i)
-    {
-        if (__sceneList[i]->_id == id)
-            return __sceneList[i];
-    }
-
-    return NULL;
-}
-
-
-const char* Scene::getId() const
-{
-    return _id.c_str();
-}
-
-void Scene::setId(const char* id)
-{
-    _id = id ? id : "";
-}
-
-Node* Scene::findNode(const char* id, bool recursive, bool exactMatch) const
-{
-    GP_ASSERT(id);
-
-    // Search immediate children first.
-    for (Node* child = getFirstNode(); child != NULL; child = child->getNextSibling())
-    {
-        // Does this child's ID match?
-        if ((exactMatch && child->_id == id) || (!exactMatch && child->_id.find(id) == 0))
-        {
-            return child;
-        }
-    }
-
-    // Recurse.
-    if (recursive)
-    {
-        for (Node* child = getFirstNode(); child != NULL; child = child->getNextSibling())
-        {
-            Node* match = child->findNode(id, true, exactMatch);
-            if (match)
-            {
-                return match;
-            }
-        }
-    }
-    return NULL;
-}
-
-unsigned int Scene::findNodes(const char* id, std::vector<Node*>& nodes, bool recursive, bool exactMatch) const
-{
-    GP_ASSERT(id);
-
-    unsigned int count = 0;
-
-    // Search immediate children first.
-    for (Node* child = getFirstNode(); child != NULL; child = child->getNextSibling())
-    {
-        // Does this child's ID match?
-        if ((exactMatch && child->_id == id) || (!exactMatch && child->_id.find(id) == 0))
-        {
-            nodes.push_back(child);
-            ++count;
-        }
-    }
-
-    // Recurse.
-    if (recursive)
-    {
-        for (Node* child = getFirstNode(); child != NULL; child = child->getNextSibling())
-        {
-            count += child->findNodes(id, nodes, true, exactMatch);
-        }
-    }
-
-    return count;
-}
-
-void Scene::visitNode(Node* node, const char* visitMethod)
-{
-    ScriptController* sc = Game::getInstance()->getScriptController();
-
-    // Invoke the visit method for this node.
-    if (!sc->executeFunction<bool>(visitMethod, "<Node>", node))
-        return;
-
-    // If this node has a model with a mesh skin, visit the joint hierarchy within it
-    // since we don't add joint hierarcies directly to the scene. If joints are never
-    // visited, it's possible that nodes embedded within the joint hierarchy that contain
-    // models will never get visited (and therefore never get drawn).
-    if (node->_model && node->_model->_skin && node->_model->_skin->_rootNode)
-    {
-        visitNode(node->_model->_skin->_rootNode, visitMethod);
-    }
-
-    // Recurse for all children.
-    for (Node* child = node->getFirstChild(); child != NULL; child = child->getNextSibling())
-    {
-        visitNode(child, visitMethod);
-    }
-}
-
-Node* Scene::addNode(const char* id)
-{
-    Node* node = Node::create(id);
-    GP_ASSERT(node);
-    addNode(node);
-
-    // Call release to decrement the ref count to 1 before returning.
-    node->release();
-
-    return node;
-}
-
-void Scene::addNode(Node* node)
-{
-    GP_ASSERT(node);
-
-    if (node->_scene == this)
-    {
-        // The node is already a member of this scene.
-        return;
-    }
-
-    node->addRef();
-
-    // If the node is part of another scene, remove it.
-    if (node->_scene && node->_scene != this)
-    {
-        node->_scene->removeNode(node);
-    }
-
-    // If the node is part of another node hierarchy, remove it.
-    if (node->getParent())
-    {
-        node->getParent()->removeChild(node);
-    }
-
-    // Link the new node into the end of our list.
-    if (_lastNode)
-    {
-        _lastNode->_nextSibling = node;
-        node->_prevSibling = _lastNode;
-        _lastNode = node;
-    }
-    else
-    {
-        _firstNode = _lastNode = node;
-    }
-
-    node->_scene = this;
-
-    ++_nodeCount;
-
-    // If we don't have an active camera set, then check for one and set it.
-    if (_activeCamera == NULL)
-    {
-        Camera* camera = node->getCamera();
-        if (camera)
-        {
-            setActiveCamera(camera);
-        }
-    }
-}
-
-void Scene::removeNode(Node* node)
-{
-    GP_ASSERT(node);
-
-    if (node->_scene != this)
-        return;
-
-    if (node == _firstNode)
-    {
-        _firstNode = node->_nextSibling;
-    }
-    if (node == _lastNode)
-    {
-        _lastNode = node->_prevSibling;
-    }
-
-    node->remove();
-    node->_scene = NULL;
-
-    SAFE_RELEASE(node);
-
-    --_nodeCount;
-}
-
-void Scene::removeAllNodes()
-{
-    while (_lastNode)
-    {
-        removeNode(_lastNode);
-    }
-}
-
-unsigned int Scene::getNodeCount() const
-{
-    return _nodeCount;
-}
-
-Node* Scene::getFirstNode() const
-{
-    return _firstNode;
-}
-
-Camera* Scene::getActiveCamera()
-{
-    return _activeCamera;
-}
-
-void Scene::setActiveCamera(Camera* camera)
-{
-    // Make sure we don't release the camera if the same camera is set twice.
-    if (_activeCamera != camera)
-    {
-        AudioListener* audioListener = AudioListener::getInstance();
-
-        if (_activeCamera)
-        {
-            // Unbind the active camera from the audio listener
-            if (audioListener && (audioListener->getCamera() == _activeCamera))
-            {
-                audioListener->setCamera(NULL);
-            }
-
-            SAFE_RELEASE(_activeCamera);
-        }
-
-        _activeCamera = camera;
-
-        if (_activeCamera)
-        {
-            _activeCamera->addRef();
-
-            if (audioListener && _bindAudioListenerToCamera)
-            {
-                audioListener->setCamera(_activeCamera);
-            }
-        }
-    }
-}
-
-void Scene::bindAudioListenerToCamera(bool bind)
-{
-    if (_bindAudioListenerToCamera != bind)
-    {
-        _bindAudioListenerToCamera = bind;
-
-        if (AudioListener::getInstance())
-        {
-            AudioListener::getInstance()->setCamera(bind ? _activeCamera : NULL);
-        }
-    }
-}
-
-const Vector3& Scene::getAmbientColor() const
-{
-    return _ambientColor;
-}
-
-void Scene::setAmbientColor(float red, float green, float blue)
-{
-    _ambientColor.set(red, green, blue);
-}
-
-void Scene::update(float elapsedTime)
-{
-    for (Node* node = _firstNode; node != NULL; node = node->_nextSibling)
-    {
-        if (node->isActive())
-            node->update(elapsedTime);
-    }
-}
-
-void Scene::reset()
-{
-    _nextItr = NULL;
-    _nextReset = true;
-}
-
-Node* Scene::getNext()
-{
-    if (_nextReset)
-    {
-        _nextItr = findNextVisibleSibling(getFirstNode());
-        _nextReset = false;
-    }
-    else if (_nextItr)
-    {
-        Node* node = findNextVisibleSibling(_nextItr->getFirstChild());
-        if (node == NULL)
-        {
-            node = findNextVisibleSibling(_nextItr->getNextSibling());
-            if (node == NULL)
-            {
-                // Find first parent with a sibling
-                node = _nextItr->getParent();
-                while (node && (!findNextVisibleSibling(node->getNextSibling())))
-                {
-                    node = node->getParent();
-                }
-                if (node)
-                {
-                    node = findNextVisibleSibling(node->getNextSibling());
-                }
-            }
-        }
-        _nextItr = node;
-    }
-    return _nextItr;
-}
-
-
-Node* Scene::findNextVisibleSibling(Node* node)
-{
-    while (node != NULL && !isNodeVisible(node))
-    {
-        node = node->getNextSibling();
-    }
-    return node;
-}
-
-bool Scene::isNodeVisible(Node* node)
-{
-    if (!node->isActive())
-        return false;
-
-    if (node->getForm() || node->getParticleEmitter() || node->getTerrain() || node->getLight() || node->getCamera())
-    {
-        return true;
-    }
-    else
-    {
-        return node->getBoundingSphere().intersects(_activeCamera->getFrustum());
-    }
-}
-
-}
+#include "Base.h"
+#include "AudioListener.h"
+#include "Scene.h"
+#include "SceneLoader.h"
+#include "MeshSkin.h"
+#include "Joint.h"
+#include "Terrain.h"
+#include "Bundle.h"
+
+namespace gameplay
+{
+
+// Global list of active scenes
+static std::vector<Scene*> __sceneList;
+
+static inline char lowercase(char c)
+{
+    if (c >= 'A' && c <='Z')
+    {
+        c |= 0x20;
+    }
+    return c;
+}
+
+// Returns true if 'str' ends with 'suffix'; false otherwise.
+static bool endsWith(const char* str, const char* suffix, bool ignoreCase)
+{
+    if (str == NULL || suffix == NULL)
+        return false;
+    size_t length = strlen(str);
+    size_t suffixLength = strlen(suffix);
+
+    if (suffixLength > length)
+    {
+        return false;
+    }
+
+    size_t offset = length - suffixLength;
+
+    const char* p = str + offset;
+    while (*p != '\0' && *suffix != '\0')
+    {
+        if (ignoreCase)
+        {
+            if (lowercase(*p) != lowercase(*suffix))
+            {
+                return false;
+            }
+        }
+        else if (*p != *suffix)
+        {
+            return false;
+        }
+        
+        ++p;
+        ++suffix;
+    }
+    return true;
+}
+
+
+Scene::Scene()
+    : _id(""), _activeCamera(NULL), _firstNode(NULL), _lastNode(NULL), _nodeCount(0), _bindAudioListenerToCamera(true), 
+      _nextItr(NULL), _nextReset(true)
+{
+    __sceneList.push_back(this);
+}
+
+Scene::~Scene()
+{
+    // Unbind our active camera from the audio listener
+    if (_activeCamera)
+    {
+        AudioListener* audioListener = AudioListener::getInstance();
+        if (audioListener && (audioListener->getCamera() == _activeCamera))
+        {
+            audioListener->setCamera(NULL);
+        }
+
+        SAFE_RELEASE(_activeCamera);
+    }
+
+    // Remove all nodes from the scene
+    removeAllNodes();
+
+    // Remove the scene from global list
+    std::vector<Scene*>::iterator itr = std::find(__sceneList.begin(), __sceneList.end(), this);
+    if (itr != __sceneList.end())
+        __sceneList.erase(itr);
+}
+
+Scene* Scene::create(const char* id)
+{
+    Scene* scene = new Scene();
+    scene->setId(id);
+    return scene;
+}
+
+Scene* Scene::load(const char* filePath)
+{
+    if (endsWith(filePath, ".gpb", true))
+    {
+        Scene* scene = NULL;
+        Bundle* bundle = Bundle::create(filePath);
+        if (bundle)
+        {
+            scene = bundle->loadScene();
+            SAFE_RELEASE(bundle);
+        }
+        return scene;
+    }
+    return SceneLoader::load(filePath);
+}
+
+Scene* Scene::getScene(const char* id)
+{
+    if (id == NULL)
+        return __sceneList.size() ? __sceneList[0] : NULL;
+
+    for (size_t i = 0, count = __sceneList.size(); i < count; ++i)
+    {
+        if (__sceneList[i]->_id == id)
+            return __sceneList[i];
+    }
+
+    return NULL;
+}
+
+
+const char* Scene::getId() const
+{
+    return _id.c_str();
+}
+
+void Scene::setId(const char* id)
+{
+    _id = id ? id : "";
+}
+
+Node* Scene::findNode(const char* id, bool recursive, bool exactMatch) const
+{
+    GP_ASSERT(id);
+
+    // Search immediate children first.
+    for (Node* child = getFirstNode(); child != NULL; child = child->getNextSibling())
+    {
+        // Does this child's ID match?
+        if ((exactMatch && child->_id == id) || (!exactMatch && child->_id.find(id) == 0))
+        {
+            return child;
+        }
+    }
+
+    // Recurse.
+    if (recursive)
+    {
+        for (Node* child = getFirstNode(); child != NULL; child = child->getNextSibling())
+        {
+            Node* match = child->findNode(id, true, exactMatch);
+            if (match)
+            {
+                return match;
+            }
+        }
+    }
+    return NULL;
+}
+
+unsigned int Scene::findNodes(const char* id, std::vector<Node*>& nodes, bool recursive, bool exactMatch) const
+{
+    GP_ASSERT(id);
+
+    unsigned int count = 0;
+
+    // Search immediate children first.
+    for (Node* child = getFirstNode(); child != NULL; child = child->getNextSibling())
+    {
+        // Does this child's ID match?
+        if ((exactMatch && child->_id == id) || (!exactMatch && child->_id.find(id) == 0))
+        {
+            nodes.push_back(child);
+            ++count;
+        }
+    }
+
+    // Recurse.
+    if (recursive)
+    {
+        for (Node* child = getFirstNode(); child != NULL; child = child->getNextSibling())
+        {
+            count += child->findNodes(id, nodes, true, exactMatch);
+        }
+    }
+
+    return count;
+}
+
+void Scene::visitNode(Node* node, const char* visitMethod)
+{
+    ScriptController* sc = Game::getInstance()->getScriptController();
+
+    // Invoke the visit method for this node.
+    if (!sc->executeFunction<bool>(visitMethod, "<Node>", node))
+        return;
+
+    // If this node has a model with a mesh skin, visit the joint hierarchy within it
+    // since we don't add joint hierarcies directly to the scene. If joints are never
+    // visited, it's possible that nodes embedded within the joint hierarchy that contain
+    // models will never get visited (and therefore never get drawn).
+    if (node->_model && node->_model->_skin && node->_model->_skin->_rootNode)
+    {
+        visitNode(node->_model->_skin->_rootNode, visitMethod);
+    }
+
+    // Recurse for all children.
+    for (Node* child = node->getFirstChild(); child != NULL; child = child->getNextSibling())
+    {
+        visitNode(child, visitMethod);
+    }
+}
+
+Node* Scene::addNode(const char* id)
+{
+    Node* node = Node::create(id);
+    GP_ASSERT(node);
+    addNode(node);
+
+    // Call release to decrement the ref count to 1 before returning.
+    node->release();
+
+    return node;
+}
+
+void Scene::addNode(Node* node)
+{
+    GP_ASSERT(node);
+
+    if (node->_scene == this)
+    {
+        // The node is already a member of this scene.
+        return;
+    }
+
+    node->addRef();
+
+    // If the node is part of another scene, remove it.
+    if (node->_scene && node->_scene != this)
+    {
+        node->_scene->removeNode(node);
+    }
+
+    // If the node is part of another node hierarchy, remove it.
+    if (node->getParent())
+    {
+        node->getParent()->removeChild(node);
+    }
+
+    // Link the new node into the end of our list.
+    if (_lastNode)
+    {
+        _lastNode->_nextSibling = node;
+        node->_prevSibling = _lastNode;
+        _lastNode = node;
+    }
+    else
+    {
+        _firstNode = _lastNode = node;
+    }
+
+    node->_scene = this;
+
+    ++_nodeCount;
+
+    // If we don't have an active camera set, then check for one and set it.
+    if (_activeCamera == NULL)
+    {
+        Camera* camera = node->getCamera();
+        if (camera)
+        {
+            setActiveCamera(camera);
+        }
+    }
+}
+
+void Scene::removeNode(Node* node)
+{
+    GP_ASSERT(node);
+
+    if (node->_scene != this)
+        return;
+
+    if (node == _firstNode)
+    {
+        _firstNode = node->_nextSibling;
+    }
+    if (node == _lastNode)
+    {
+        _lastNode = node->_prevSibling;
+    }
+
+    node->remove();
+    node->_scene = NULL;
+
+    SAFE_RELEASE(node);
+
+    --_nodeCount;
+}
+
+void Scene::removeAllNodes()
+{
+    while (_lastNode)
+    {
+        removeNode(_lastNode);
+    }
+}
+
+unsigned int Scene::getNodeCount() const
+{
+    return _nodeCount;
+}
+
+Node* Scene::getFirstNode() const
+{
+    return _firstNode;
+}
+
+Camera* Scene::getActiveCamera()
+{
+    return _activeCamera;
+}
+
+void Scene::setActiveCamera(Camera* camera)
+{
+    // Make sure we don't release the camera if the same camera is set twice.
+    if (_activeCamera != camera)
+    {
+        AudioListener* audioListener = AudioListener::getInstance();
+
+        if (_activeCamera)
+        {
+            // Unbind the active camera from the audio listener
+            if (audioListener && (audioListener->getCamera() == _activeCamera))
+            {
+                audioListener->setCamera(NULL);
+            }
+
+            SAFE_RELEASE(_activeCamera);
+        }
+
+        _activeCamera = camera;
+
+        if (_activeCamera)
+        {
+            _activeCamera->addRef();
+
+            if (audioListener && _bindAudioListenerToCamera)
+            {
+                audioListener->setCamera(_activeCamera);
+            }
+        }
+    }
+}
+
+void Scene::bindAudioListenerToCamera(bool bind)
+{
+    if (_bindAudioListenerToCamera != bind)
+    {
+        _bindAudioListenerToCamera = bind;
+
+        if (AudioListener::getInstance())
+        {
+            AudioListener::getInstance()->setCamera(bind ? _activeCamera : NULL);
+        }
+    }
+}
+
+const Vector3& Scene::getAmbientColor() const
+{
+    return _ambientColor;
+}
+
+void Scene::setAmbientColor(float red, float green, float blue)
+{
+    _ambientColor.set(red, green, blue);
+}
+
+void Scene::update(float elapsedTime)
+{
+    for (Node* node = _firstNode; node != NULL; node = node->_nextSibling)
+    {
+        if (node->isActive())
+            node->update(elapsedTime);
+    }
+}
+
+void Scene::reset()
+{
+    _nextItr = NULL;
+    _nextReset = true;
+}
+
+Node* Scene::getNext()
+{
+    if (_nextReset)
+    {
+        _nextItr = findNextVisibleSibling(getFirstNode());
+        _nextReset = false;
+    }
+    else if (_nextItr)
+    {
+        Node* node = findNextVisibleSibling(_nextItr->getFirstChild());
+        if (node == NULL)
+        {
+            node = findNextVisibleSibling(_nextItr->getNextSibling());
+            if (node == NULL)
+            {
+                // Find first parent with a sibling
+                node = _nextItr->getParent();
+                while (node && (!findNextVisibleSibling(node->getNextSibling())))
+                {
+                    node = node->getParent();
+                }
+                if (node)
+                {
+                    node = findNextVisibleSibling(node->getNextSibling());
+                }
+            }
+        }
+        _nextItr = node;
+    }
+    return _nextItr;
+}
+
+
+Node* Scene::findNextVisibleSibling(Node* node)
+{
+    while (node != NULL && !isNodeVisible(node))
+    {
+        node = node->getNextSibling();
+    }
+    return node;
+}
+
+bool Scene::isNodeVisible(Node* node)
+{
+    if (!node->isActive())
+        return false;
+
+    if (node->getForm() || node->getParticleEmitter() || node->getTerrain() || node->getLight() || node->getCamera())
+    {
+        return true;
+    }
+    else
+    {
+        return node->getBoundingSphere().intersects(_activeCamera->getFrustum());
+    }
+}
+
+}

+ 651 - 654
gameplay/src/lua/lua_AudioListener.cpp

@@ -1,654 +1,651 @@
-#include "Base.h"
-#include "ScriptController.h"
-#include "lua_AudioListener.h"
-#include "Animation.h"
-#include "AnimationTarget.h"
-#include "AudioListener.h"
-#include "Base.h"
-#include "Game.h"
-#include "Node.h"
-#include "ScriptController.h"
-#include "ScriptTarget.h"
-#include "Transform.h"
-#include "lua_CurveInterpolationType.h"
-
-namespace gameplay
-{
-
-void luaRegister_AudioListener()
-{
-    const luaL_Reg lua_members[] = 
-    {
-        {"getCamera", lua_AudioListener_getCamera},
-        {"getGain", lua_AudioListener_getGain},
-        {"getOrientationForward", lua_AudioListener_getOrientationForward},
-        {"getOrientationUp", lua_AudioListener_getOrientationUp},
-        {"getPosition", lua_AudioListener_getPosition},
-        {"getVelocity", lua_AudioListener_getVelocity},
-        {"setCamera", lua_AudioListener_setCamera},
-        {"setGain", lua_AudioListener_setGain},
-        {"setOrientation", lua_AudioListener_setOrientation},
-        {"setPosition", lua_AudioListener_setPosition},
-        {"setVelocity", lua_AudioListener_setVelocity},
-        {NULL, NULL}
-    };
-    const luaL_Reg lua_statics[] = 
-    {
-        {"getInstance", lua_AudioListener_static_getInstance},
-        {NULL, NULL}
-    };
-    std::vector<std::string> scopePath;
-
-    gameplay::ScriptUtil::registerClass("AudioListener", lua_members, NULL, NULL, lua_statics, scopePath);
-}
-
-static AudioListener* getInstance(lua_State* state)
-{
-    void* userdata = luaL_checkudata(state, 1, "AudioListener");
-    luaL_argcheck(state, userdata != NULL, 1, "'AudioListener' expected.");
-    return (AudioListener*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
-}
-
-int lua_AudioListener_getCamera(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                AudioListener* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getCamera();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Camera");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_AudioListener_getCamera - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_getGain(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                AudioListener* instance = getInstance(state);
-                float result = instance->getGain();
-
-                // Push the return value onto the stack.
-                lua_pushnumber(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_AudioListener_getGain - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_getOrientationForward(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                AudioListener* instance = getInstance(state);
-                void* returnPtr = (void*)&(instance->getOrientationForward());
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Vector3");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_AudioListener_getOrientationForward - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_getOrientationUp(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                AudioListener* instance = getInstance(state);
-                void* returnPtr = (void*)&(instance->getOrientationUp());
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Vector3");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_AudioListener_getOrientationUp - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_getPosition(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                AudioListener* instance = getInstance(state);
-                void* returnPtr = (void*)&(instance->getPosition());
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Vector3");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_AudioListener_getPosition - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_getVelocity(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                AudioListener* instance = getInstance(state);
-                void* returnPtr = (void*)&(instance->getVelocity());
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Vector3");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_AudioListener_getVelocity - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_setCamera(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                bool param1Valid;
-                gameplay::ScriptUtil::LuaArray<Camera> param1 = gameplay::ScriptUtil::getObjectPointer<Camera>(2, "Camera", false, &param1Valid);
-                if (!param1Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Camera'.");
-                    lua_error(state);
-                }
-
-                AudioListener* instance = getInstance(state);
-                instance->setCamera(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_AudioListener_setCamera - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_setGain(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                float param1 = (float)luaL_checknumber(state, 2);
-
-                AudioListener* instance = getInstance(state);
-                instance->setGain(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_AudioListener_setGain - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_setOrientation(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 3:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
-                    (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
-                    if (!param1Valid)
-                        break;
-
-                    // Get parameter 2 off the stack.
-                    bool param2Valid;
-                    gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true, &param2Valid);
-                    if (!param2Valid)
-                        break;
-
-                    AudioListener* instance = getInstance(state);
-                    instance->setOrientation(*param1, *param2);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_AudioListener_setOrientation - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 7:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    lua_type(state, 2) == LUA_TNUMBER &&
-                    lua_type(state, 3) == LUA_TNUMBER &&
-                    lua_type(state, 4) == LUA_TNUMBER &&
-                    lua_type(state, 5) == LUA_TNUMBER &&
-                    lua_type(state, 6) == LUA_TNUMBER &&
-                    lua_type(state, 7) == LUA_TNUMBER)
-                {
-                    // Get parameter 1 off the stack.
-                    float param1 = (float)luaL_checknumber(state, 2);
-
-                    // Get parameter 2 off the stack.
-                    float param2 = (float)luaL_checknumber(state, 3);
-
-                    // Get parameter 3 off the stack.
-                    float param3 = (float)luaL_checknumber(state, 4);
-
-                    // Get parameter 4 off the stack.
-                    float param4 = (float)luaL_checknumber(state, 5);
-
-                    // Get parameter 5 off the stack.
-                    float param5 = (float)luaL_checknumber(state, 6);
-
-                    // Get parameter 6 off the stack.
-                    float param6 = (float)luaL_checknumber(state, 7);
-
-                    AudioListener* instance = getInstance(state);
-                    instance->setOrientation(param1, param2, param3, param4, param5, param6);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_AudioListener_setOrientation - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3 or 7).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_setPosition(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
-                    if (!param1Valid)
-                        break;
-
-                    AudioListener* instance = getInstance(state);
-                    instance->setPosition(*param1);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_AudioListener_setPosition - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 4:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    lua_type(state, 2) == LUA_TNUMBER &&
-                    lua_type(state, 3) == LUA_TNUMBER &&
-                    lua_type(state, 4) == LUA_TNUMBER)
-                {
-                    // Get parameter 1 off the stack.
-                    float param1 = (float)luaL_checknumber(state, 2);
-
-                    // Get parameter 2 off the stack.
-                    float param2 = (float)luaL_checknumber(state, 3);
-
-                    // Get parameter 3 off the stack.
-                    float param3 = (float)luaL_checknumber(state, 4);
-
-                    AudioListener* instance = getInstance(state);
-                    instance->setPosition(param1, param2, param3);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_AudioListener_setPosition - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2 or 4).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_setVelocity(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
-                    if (!param1Valid)
-                        break;
-
-                    AudioListener* instance = getInstance(state);
-                    instance->setVelocity(*param1);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_AudioListener_setVelocity - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 4:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    lua_type(state, 2) == LUA_TNUMBER &&
-                    lua_type(state, 3) == LUA_TNUMBER &&
-                    lua_type(state, 4) == LUA_TNUMBER)
-                {
-                    // Get parameter 1 off the stack.
-                    float param1 = (float)luaL_checknumber(state, 2);
-
-                    // Get parameter 2 off the stack.
-                    float param2 = (float)luaL_checknumber(state, 3);
-
-                    // Get parameter 3 off the stack.
-                    float param3 = (float)luaL_checknumber(state, 4);
-
-                    AudioListener* instance = getInstance(state);
-                    instance->setVelocity(param1, param2, param3);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_AudioListener_setVelocity - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2 or 4).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_AudioListener_static_getInstance(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 0:
-        {
-            void* returnPtr = (void*)AudioListener::getInstance();
-            if (returnPtr)
-            {
-                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                object->instance = returnPtr;
-                object->owns = false;
-                luaL_getmetatable(state, "AudioListener");
-                lua_setmetatable(state, -2);
-            }
-            else
-            {
-                lua_pushnil(state);
-            }
-
-            return 1;
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 0).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-}
+#include "Base.h"
+#include "ScriptController.h"
+#include "lua_AudioListener.h"
+#include "AudioListener.h"
+#include "Base.h"
+#include "Camera.h"
+#include "Game.h"
+#include "Node.h"
+#include "PhysicsController.h"
+#include "lua_CameraType.h"
+
+namespace gameplay
+{
+
+void luaRegister_AudioListener()
+{
+    const luaL_Reg lua_members[] = 
+    {
+        {"getCamera", lua_AudioListener_getCamera},
+        {"getGain", lua_AudioListener_getGain},
+        {"getOrientationForward", lua_AudioListener_getOrientationForward},
+        {"getOrientationUp", lua_AudioListener_getOrientationUp},
+        {"getPosition", lua_AudioListener_getPosition},
+        {"getVelocity", lua_AudioListener_getVelocity},
+        {"setCamera", lua_AudioListener_setCamera},
+        {"setGain", lua_AudioListener_setGain},
+        {"setOrientation", lua_AudioListener_setOrientation},
+        {"setPosition", lua_AudioListener_setPosition},
+        {"setVelocity", lua_AudioListener_setVelocity},
+        {NULL, NULL}
+    };
+    const luaL_Reg lua_statics[] = 
+    {
+        {"getInstance", lua_AudioListener_static_getInstance},
+        {NULL, NULL}
+    };
+    std::vector<std::string> scopePath;
+
+    gameplay::ScriptUtil::registerClass("AudioListener", lua_members, NULL, NULL, lua_statics, scopePath);
+}
+
+static AudioListener* getInstance(lua_State* state)
+{
+    void* userdata = luaL_checkudata(state, 1, "AudioListener");
+    luaL_argcheck(state, userdata != NULL, 1, "'AudioListener' expected.");
+    return (AudioListener*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
+}
+
+int lua_AudioListener_getCamera(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                AudioListener* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getCamera();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Camera");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_AudioListener_getCamera - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_getGain(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                AudioListener* instance = getInstance(state);
+                float result = instance->getGain();
+
+                // Push the return value onto the stack.
+                lua_pushnumber(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_AudioListener_getGain - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_getOrientationForward(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                AudioListener* instance = getInstance(state);
+                void* returnPtr = (void*)&(instance->getOrientationForward());
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Vector3");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_AudioListener_getOrientationForward - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_getOrientationUp(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                AudioListener* instance = getInstance(state);
+                void* returnPtr = (void*)&(instance->getOrientationUp());
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Vector3");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_AudioListener_getOrientationUp - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_getPosition(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                AudioListener* instance = getInstance(state);
+                void* returnPtr = (void*)&(instance->getPosition());
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Vector3");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_AudioListener_getPosition - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_getVelocity(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                AudioListener* instance = getInstance(state);
+                void* returnPtr = (void*)&(instance->getVelocity());
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Vector3");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_AudioListener_getVelocity - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_setCamera(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<Camera> param1 = gameplay::ScriptUtil::getObjectPointer<Camera>(2, "Camera", false, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Camera'.");
+                    lua_error(state);
+                }
+
+                AudioListener* instance = getInstance(state);
+                instance->setCamera(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_AudioListener_setCamera - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_setGain(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                float param1 = (float)luaL_checknumber(state, 2);
+
+                AudioListener* instance = getInstance(state);
+                instance->setGain(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_AudioListener_setGain - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_setOrientation(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 3:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
+                    (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    // Get parameter 2 off the stack.
+                    bool param2Valid;
+                    gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true, &param2Valid);
+                    if (!param2Valid)
+                        break;
+
+                    AudioListener* instance = getInstance(state);
+                    instance->setOrientation(*param1, *param2);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AudioListener_setOrientation - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 7:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    lua_type(state, 2) == LUA_TNUMBER &&
+                    lua_type(state, 3) == LUA_TNUMBER &&
+                    lua_type(state, 4) == LUA_TNUMBER &&
+                    lua_type(state, 5) == LUA_TNUMBER &&
+                    lua_type(state, 6) == LUA_TNUMBER &&
+                    lua_type(state, 7) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    float param1 = (float)luaL_checknumber(state, 2);
+
+                    // Get parameter 2 off the stack.
+                    float param2 = (float)luaL_checknumber(state, 3);
+
+                    // Get parameter 3 off the stack.
+                    float param3 = (float)luaL_checknumber(state, 4);
+
+                    // Get parameter 4 off the stack.
+                    float param4 = (float)luaL_checknumber(state, 5);
+
+                    // Get parameter 5 off the stack.
+                    float param5 = (float)luaL_checknumber(state, 6);
+
+                    // Get parameter 6 off the stack.
+                    float param6 = (float)luaL_checknumber(state, 7);
+
+                    AudioListener* instance = getInstance(state);
+                    instance->setOrientation(param1, param2, param3, param4, param5, param6);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AudioListener_setOrientation - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3 or 7).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_setPosition(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    AudioListener* instance = getInstance(state);
+                    instance->setPosition(*param1);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AudioListener_setPosition - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 4:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    lua_type(state, 2) == LUA_TNUMBER &&
+                    lua_type(state, 3) == LUA_TNUMBER &&
+                    lua_type(state, 4) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    float param1 = (float)luaL_checknumber(state, 2);
+
+                    // Get parameter 2 off the stack.
+                    float param2 = (float)luaL_checknumber(state, 3);
+
+                    // Get parameter 3 off the stack.
+                    float param3 = (float)luaL_checknumber(state, 4);
+
+                    AudioListener* instance = getInstance(state);
+                    instance->setPosition(param1, param2, param3);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AudioListener_setPosition - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2 or 4).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_setVelocity(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    AudioListener* instance = getInstance(state);
+                    instance->setVelocity(*param1);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AudioListener_setVelocity - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 4:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    lua_type(state, 2) == LUA_TNUMBER &&
+                    lua_type(state, 3) == LUA_TNUMBER &&
+                    lua_type(state, 4) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    float param1 = (float)luaL_checknumber(state, 2);
+
+                    // Get parameter 2 off the stack.
+                    float param2 = (float)luaL_checknumber(state, 3);
+
+                    // Get parameter 3 off the stack.
+                    float param3 = (float)luaL_checknumber(state, 4);
+
+                    AudioListener* instance = getInstance(state);
+                    instance->setVelocity(param1, param2, param3);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_AudioListener_setVelocity - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2 or 4).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_AudioListener_static_getInstance(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 0:
+        {
+            void* returnPtr = (void*)AudioListener::getInstance();
+            if (returnPtr)
+            {
+                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                object->instance = returnPtr;
+                object->owns = false;
+                luaL_getmetatable(state, "AudioListener");
+                lua_setmetatable(state, -2);
+            }
+            else
+            {
+                lua_pushnil(state);
+            }
+
+            return 1;
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 0).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+}

+ 1017 - 1017
gameplay/src/lua/lua_Global.cpp

@@ -1,1017 +1,1017 @@
-#include "ScriptController.h"
-#include "lua_Global.h"
-
-namespace gameplay
-{
-
-void luaRegister_lua_Global()
-{
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Button");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Container");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Control");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Form");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "ImageControl");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Joint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Joystick");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Label");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "MaterialParameter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Node");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Slider");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "TextBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Transform");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Button", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Button", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Camera::Listener", "TerrainPatch");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Container", "Form");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Button");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Container");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Form");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "ImageControl");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Joystick");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Label");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Slider");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "TextBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "Button");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "Slider");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "TextBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "AbsoluteLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "FlowLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "VerticalLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Node", "Joint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsCharacter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsGhostObject");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsRigidBody");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsVehicle");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsVehicleWheel");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsFixedConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsGenericConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsHingeConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsSocketConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsSpringConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGenericConstraint", "PhysicsFixedConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGenericConstraint", "PhysicsSpringConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGhostObject", "PhysicsCharacter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AIAgent");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AIState");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AbsoluteLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Animation");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AnimationClip");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AudioBuffer");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AudioSource");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Bundle");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Button");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Camera");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Container");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Control");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Curve");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "DepthStencilTarget");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Effect");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "FlowLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Font");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Form");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "FrameBuffer");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "HeightField");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Image");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "ImageControl");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Joint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Joystick");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Label");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Layout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Light");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Material");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "MaterialParameter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Mesh");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Model");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Node");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "ParticleEmitter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Pass");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "PhysicsCollisionShape");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderState");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderState::StateBlock");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderTarget");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Scene");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Slider");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Technique");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Terrain");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "TextBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Texture");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Texture::Sampler");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Theme");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Theme::ThemeImage");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "VertexAttributeBinding");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "VerticalLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Material");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Pass");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Technique");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "AIAgent");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "AIState");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Button");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Container");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Control");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Form");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "ImageControl");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Joint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Joystick");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Label");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Node");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "PhysicsController");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Slider");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "TextBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Transform");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform", "Joint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform", "Node");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "AudioListener");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "AudioSource");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "Camera");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "MeshSkin");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsCharacter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsGhostObject");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsRigidBody");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "Terrain");
-    gameplay::ScriptUtil::addStringFromEnumConversionFunction(&gameplay::lua_stringFromEnumGlobal);
-
-    // Register enumeration AIMessage::ParameterType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("AIMessage");
-        gameplay::ScriptUtil::registerConstantString("UNDEFINED", "UNDEFINED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("INTEGER", "INTEGER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LONG", "LONG", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FLOAT", "FLOAT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DOUBLE", "DOUBLE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOOLEAN", "BOOLEAN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STRING", "STRING", scopePath);
-    }
-
-    // Register enumeration AnimationClip::Listener::EventType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("AnimationClip");
-        scopePath.push_back("Listener");
-        gameplay::ScriptUtil::registerConstantString("BEGIN", "BEGIN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("END", "END", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TIME", "TIME", scopePath);
-    }
-
-    // Register enumeration AudioSource::State.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("AudioSource");
-        gameplay::ScriptUtil::registerConstantString("INITIAL", "INITIAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("PLAYING", "PLAYING", scopePath);
-        gameplay::ScriptUtil::registerConstantString("PAUSED", "PAUSED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STOPPED", "STOPPED", scopePath);
-    }
-
-    // Register enumeration Camera::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Camera");
-        gameplay::ScriptUtil::registerConstantString("PERSPECTIVE", "PERSPECTIVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ORTHOGRAPHIC", "ORTHOGRAPHIC", scopePath);
-    }
-
-    // Register enumeration Container::Scroll.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Container");
-        gameplay::ScriptUtil::registerConstantString("SCROLL_NONE", "SCROLL_NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SCROLL_HORIZONTAL", "SCROLL_HORIZONTAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SCROLL_VERTICAL", "SCROLL_VERTICAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SCROLL_BOTH", "SCROLL_BOTH", scopePath);
-    }
-
-    // Register enumeration Control::Alignment.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Control");
-        gameplay::ScriptUtil::registerConstantString("ALIGN_LEFT", "ALIGN_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_HCENTER", "ALIGN_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_RIGHT", "ALIGN_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP", "ALIGN_TOP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER", "ALIGN_VCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM", "ALIGN_BOTTOM", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_LEFT", "ALIGN_TOP_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_LEFT", "ALIGN_VCENTER_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_LEFT", "ALIGN_BOTTOM_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_HCENTER", "ALIGN_TOP_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_HCENTER", "ALIGN_VCENTER_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_HCENTER", "ALIGN_BOTTOM_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_RIGHT", "ALIGN_TOP_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_RIGHT", "ALIGN_VCENTER_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_RIGHT", "ALIGN_BOTTOM_RIGHT", scopePath);
-    }
-
-    // Register enumeration Control::AutoSize.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Control");
-        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_NONE", "AUTO_SIZE_NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_STRETCH", "AUTO_SIZE_STRETCH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_FIT", "AUTO_SIZE_FIT", scopePath);
-    }
-
-    // Register enumeration Control::Listener::EventType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Control");
-        scopePath.push_back("Listener");
-        gameplay::ScriptUtil::registerConstantString("PRESS", "PRESS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RELEASE", "RELEASE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLICK", "CLICK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VALUE_CHANGED", "VALUE_CHANGED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXT_CHANGED", "TEXT_CHANGED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MIDDLE_CLICK", "MIDDLE_CLICK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RIGHT_CLICK", "RIGHT_CLICK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ENTER", "ENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LEAVE", "LEAVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FOCUS_GAINED", "FOCUS_GAINED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FOCUS_LOST", "FOCUS_LOST", scopePath);
-    }
-
-    // Register enumeration Control::State.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Control");
-        gameplay::ScriptUtil::registerConstantString("NORMAL", "NORMAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FOCUS", "FOCUS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ACTIVE", "ACTIVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DISABLED", "DISABLED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("HOVER", "HOVER", scopePath);
-    }
-
-    // Register enumeration Curve::InterpolationType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Curve");
-        gameplay::ScriptUtil::registerConstantString("BEZIER", "BEZIER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BSPLINE", "BSPLINE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FLAT", "FLAT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("HERMITE", "HERMITE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINEAR", "LINEAR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SMOOTH", "SMOOTH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STEP", "STEP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUADRATIC_IN", "QUADRATIC_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUADRATIC_OUT", "QUADRATIC_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUADRATIC_IN_OUT", "QUADRATIC_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUADRATIC_OUT_IN", "QUADRATIC_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CUBIC_IN", "CUBIC_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CUBIC_OUT", "CUBIC_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CUBIC_IN_OUT", "CUBIC_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CUBIC_OUT_IN", "CUBIC_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUARTIC_IN", "QUARTIC_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUARTIC_OUT", "QUARTIC_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUARTIC_IN_OUT", "QUARTIC_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUARTIC_OUT_IN", "QUARTIC_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUINTIC_IN", "QUINTIC_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUINTIC_OUT", "QUINTIC_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUINTIC_IN_OUT", "QUINTIC_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUINTIC_OUT_IN", "QUINTIC_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SINE_IN", "SINE_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SINE_OUT", "SINE_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SINE_IN_OUT", "SINE_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SINE_OUT_IN", "SINE_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_IN", "EXPONENTIAL_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_OUT", "EXPONENTIAL_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_IN_OUT", "EXPONENTIAL_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_OUT_IN", "EXPONENTIAL_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CIRCULAR_IN", "CIRCULAR_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CIRCULAR_OUT", "CIRCULAR_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CIRCULAR_IN_OUT", "CIRCULAR_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CIRCULAR_OUT_IN", "CIRCULAR_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ELASTIC_IN", "ELASTIC_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ELASTIC_OUT", "ELASTIC_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ELASTIC_IN_OUT", "ELASTIC_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ELASTIC_OUT_IN", "ELASTIC_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_IN", "OVERSHOOT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_OUT", "OVERSHOOT_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_IN_OUT", "OVERSHOOT_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_OUT_IN", "OVERSHOOT_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOUNCE_IN", "BOUNCE_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOUNCE_OUT", "BOUNCE_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOUNCE_IN_OUT", "BOUNCE_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOUNCE_OUT_IN", "BOUNCE_OUT_IN", scopePath);
-    }
-
-    // Register enumeration DepthStencilTarget::Format.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("DepthStencilTarget");
-        gameplay::ScriptUtil::registerConstantString("DEPTH", "DEPTH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_STENCIL", "DEPTH_STENCIL", scopePath);
-    }
-
-    // Register enumeration Font::Format.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Font");
-        gameplay::ScriptUtil::registerConstantString("BITMAP", "BITMAP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DISTANCE_FIELD", "DISTANCE_FIELD", scopePath);
-    }
-
-    // Register enumeration Font::Justify.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Font");
-        gameplay::ScriptUtil::registerConstantString("ALIGN_LEFT", "ALIGN_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_HCENTER", "ALIGN_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_RIGHT", "ALIGN_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP", "ALIGN_TOP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER", "ALIGN_VCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM", "ALIGN_BOTTOM", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_LEFT", "ALIGN_TOP_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_LEFT", "ALIGN_VCENTER_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_LEFT", "ALIGN_BOTTOM_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_HCENTER", "ALIGN_TOP_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_HCENTER", "ALIGN_VCENTER_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_HCENTER", "ALIGN_BOTTOM_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_RIGHT", "ALIGN_TOP_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_RIGHT", "ALIGN_VCENTER_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_RIGHT", "ALIGN_BOTTOM_RIGHT", scopePath);
-    }
-
-    // Register enumeration Font::Style.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Font");
-        gameplay::ScriptUtil::registerConstantString("PLAIN", "PLAIN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOLD", "BOLD", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ITALIC", "ITALIC", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOLD_ITALIC", "BOLD_ITALIC", scopePath);
-    }
-
-    // Register enumeration Game::ClearFlags.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Game");
-        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR", "CLEAR_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_DEPTH", "CLEAR_DEPTH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_STENCIL", "CLEAR_STENCIL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_DEPTH", "CLEAR_COLOR_DEPTH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_STENCIL", "CLEAR_COLOR_STENCIL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_DEPTH_STENCIL", "CLEAR_DEPTH_STENCIL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_DEPTH_STENCIL", "CLEAR_COLOR_DEPTH_STENCIL", scopePath);
-    }
-
-    // Register enumeration Game::State.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Game");
-        gameplay::ScriptUtil::registerConstantString("UNINITIALIZED", "UNINITIALIZED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RUNNING", "RUNNING", scopePath);
-        gameplay::ScriptUtil::registerConstantString("PAUSED", "PAUSED", scopePath);
-    }
-
-    // Register enumeration Gamepad::ButtonMapping.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Gamepad");
-        gameplay::ScriptUtil::registerConstantString("BUTTON_A", "BUTTON_A", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_B", "BUTTON_B", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_C", "BUTTON_C", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_X", "BUTTON_X", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_Y", "BUTTON_Y", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_Z", "BUTTON_Z", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU1", "BUTTON_MENU1", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU2", "BUTTON_MENU2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU3", "BUTTON_MENU3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU4", "BUTTON_MENU4", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_L1", "BUTTON_L1", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_L2", "BUTTON_L2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_L3", "BUTTON_L3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_R1", "BUTTON_R1", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_R2", "BUTTON_R2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_R3", "BUTTON_R3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_UP", "BUTTON_UP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_DOWN", "BUTTON_DOWN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_LEFT", "BUTTON_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_RIGHT", "BUTTON_RIGHT", scopePath);
-    }
-
-    // Register enumeration Gamepad::GamepadEvent.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Gamepad");
-        gameplay::ScriptUtil::registerConstantString("CONNECTED_EVENT", "CONNECTED_EVENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DISCONNECTED_EVENT", "DISCONNECTED_EVENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_EVENT", "BUTTON_EVENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("JOYSTICK_EVENT", "JOYSTICK_EVENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TRIGGER_EVENT", "TRIGGER_EVENT", scopePath);
-    }
-
-    // Register enumeration Gesture::GestureEvent.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Gesture");
-        gameplay::ScriptUtil::registerConstantString("GESTURE_TAP", "GESTURE_TAP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GESTURE_SWIPE", "GESTURE_SWIPE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GESTURE_PINCH", "GESTURE_PINCH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GESTURE_ANY_SUPPORTED", "GESTURE_ANY_SUPPORTED", scopePath);
-    }
-
-    // Register enumeration Image::Format.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Image");
-        gameplay::ScriptUtil::registerConstantString("RGB", "RGB", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RGBA", "RGBA", scopePath);
-    }
-
-    // Register enumeration Keyboard::Key.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Keyboard");
-        gameplay::ScriptUtil::registerConstantString("KEY_NONE", "KEY_NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PAUSE", "KEY_PAUSE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SCROLL_LOCK", "KEY_SCROLL_LOCK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PRINT", "KEY_PRINT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SYSREQ", "KEY_SYSREQ", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_BREAK", "KEY_BREAK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_ESCAPE", "KEY_ESCAPE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_BACKSPACE", "KEY_BACKSPACE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_TAB", "KEY_TAB", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_BACK_TAB", "KEY_BACK_TAB", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RETURN", "KEY_RETURN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPS_LOCK", "KEY_CAPS_LOCK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SHIFT", "KEY_SHIFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CTRL", "KEY_CTRL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_ALT", "KEY_ALT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_MENU", "KEY_MENU", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_HYPER", "KEY_HYPER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_INSERT", "KEY_INSERT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_HOME", "KEY_HOME", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PG_UP", "KEY_PG_UP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_DELETE", "KEY_DELETE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_END", "KEY_END", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PG_DOWN", "KEY_PG_DOWN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_ARROW", "KEY_LEFT_ARROW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_ARROW", "KEY_RIGHT_ARROW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_UP_ARROW", "KEY_UP_ARROW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_DOWN_ARROW", "KEY_DOWN_ARROW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_NUM_LOCK", "KEY_NUM_LOCK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_PLUS", "KEY_KP_PLUS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_MINUS", "KEY_KP_MINUS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_MULTIPLY", "KEY_KP_MULTIPLY", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_DIVIDE", "KEY_KP_DIVIDE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_ENTER", "KEY_KP_ENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_HOME", "KEY_KP_HOME", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_UP", "KEY_KP_UP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_PG_UP", "KEY_KP_PG_UP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_LEFT", "KEY_KP_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_FIVE", "KEY_KP_FIVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_RIGHT", "KEY_KP_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_END", "KEY_KP_END", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_DOWN", "KEY_KP_DOWN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_PG_DOWN", "KEY_KP_PG_DOWN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_INSERT", "KEY_KP_INSERT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_DELETE", "KEY_KP_DELETE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F1", "KEY_F1", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F2", "KEY_F2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F3", "KEY_F3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F4", "KEY_F4", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F5", "KEY_F5", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F6", "KEY_F6", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F7", "KEY_F7", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F8", "KEY_F8", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F9", "KEY_F9", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F10", "KEY_F10", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F11", "KEY_F11", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F12", "KEY_F12", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SPACE", "KEY_SPACE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_EXCLAM", "KEY_EXCLAM", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_QUOTE", "KEY_QUOTE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_NUMBER", "KEY_NUMBER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_DOLLAR", "KEY_DOLLAR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PERCENT", "KEY_PERCENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CIRCUMFLEX", "KEY_CIRCUMFLEX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_AMPERSAND", "KEY_AMPERSAND", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_APOSTROPHE", "KEY_APOSTROPHE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_PARENTHESIS", "KEY_LEFT_PARENTHESIS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_PARENTHESIS", "KEY_RIGHT_PARENTHESIS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_ASTERISK", "KEY_ASTERISK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PLUS", "KEY_PLUS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_COMMA", "KEY_COMMA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_MINUS", "KEY_MINUS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PERIOD", "KEY_PERIOD", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SLASH", "KEY_SLASH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_ZERO", "KEY_ZERO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_ONE", "KEY_ONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_TWO", "KEY_TWO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_THREE", "KEY_THREE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_FOUR", "KEY_FOUR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_FIVE", "KEY_FIVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SIX", "KEY_SIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SEVEN", "KEY_SEVEN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_EIGHT", "KEY_EIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_NINE", "KEY_NINE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_COLON", "KEY_COLON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SEMICOLON", "KEY_SEMICOLON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_LESS_THAN", "KEY_LESS_THAN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_EQUAL", "KEY_EQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_GREATER_THAN", "KEY_GREATER_THAN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_QUESTION", "KEY_QUESTION", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_AT", "KEY_AT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_A", "KEY_CAPITAL_A", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_B", "KEY_CAPITAL_B", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_C", "KEY_CAPITAL_C", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_D", "KEY_CAPITAL_D", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_E", "KEY_CAPITAL_E", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_F", "KEY_CAPITAL_F", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_G", "KEY_CAPITAL_G", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_H", "KEY_CAPITAL_H", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_I", "KEY_CAPITAL_I", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_J", "KEY_CAPITAL_J", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_K", "KEY_CAPITAL_K", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_L", "KEY_CAPITAL_L", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_M", "KEY_CAPITAL_M", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_N", "KEY_CAPITAL_N", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_O", "KEY_CAPITAL_O", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_P", "KEY_CAPITAL_P", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Q", "KEY_CAPITAL_Q", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_R", "KEY_CAPITAL_R", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_S", "KEY_CAPITAL_S", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_T", "KEY_CAPITAL_T", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_U", "KEY_CAPITAL_U", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_V", "KEY_CAPITAL_V", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_W", "KEY_CAPITAL_W", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_X", "KEY_CAPITAL_X", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Y", "KEY_CAPITAL_Y", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Z", "KEY_CAPITAL_Z", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_BRACKET", "KEY_LEFT_BRACKET", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_BACK_SLASH", "KEY_BACK_SLASH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_BRACKET", "KEY_RIGHT_BRACKET", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_UNDERSCORE", "KEY_UNDERSCORE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_GRAVE", "KEY_GRAVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_A", "KEY_A", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_B", "KEY_B", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_C", "KEY_C", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_D", "KEY_D", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_E", "KEY_E", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F", "KEY_F", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_G", "KEY_G", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_H", "KEY_H", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_I", "KEY_I", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_J", "KEY_J", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_K", "KEY_K", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_L", "KEY_L", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_M", "KEY_M", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_N", "KEY_N", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_O", "KEY_O", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_P", "KEY_P", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_Q", "KEY_Q", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_R", "KEY_R", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_S", "KEY_S", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_T", "KEY_T", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_U", "KEY_U", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_V", "KEY_V", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_W", "KEY_W", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_X", "KEY_X", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_Y", "KEY_Y", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_Z", "KEY_Z", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_BRACE", "KEY_LEFT_BRACE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_BAR", "KEY_BAR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_BRACE", "KEY_RIGHT_BRACE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_TILDE", "KEY_TILDE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_EURO", "KEY_EURO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_POUND", "KEY_POUND", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_YEN", "KEY_YEN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_MIDDLE_DOT", "KEY_MIDDLE_DOT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SEARCH", "KEY_SEARCH", scopePath);
-    }
-
-    // Register enumeration Keyboard::KeyEvent.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Keyboard");
-        gameplay::ScriptUtil::registerConstantString("KEY_PRESS", "KEY_PRESS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RELEASE", "KEY_RELEASE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CHAR", "KEY_CHAR", scopePath);
-    }
-
-    // Register enumeration Layout::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Layout");
-        gameplay::ScriptUtil::registerConstantString("LAYOUT_FLOW", "LAYOUT_FLOW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LAYOUT_VERTICAL", "LAYOUT_VERTICAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LAYOUT_ABSOLUTE", "LAYOUT_ABSOLUTE", scopePath);
-    }
-
-    // Register enumeration Light::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Light");
-        gameplay::ScriptUtil::registerConstantString("DIRECTIONAL", "DIRECTIONAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("POINT", "POINT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SPOT", "SPOT", scopePath);
-    }
-
-    // Register enumeration Logger::Level.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Logger");
-        gameplay::ScriptUtil::registerConstantString("LEVEL_INFO", "LEVEL_INFO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LEVEL_WARN", "LEVEL_WARN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LEVEL_ERROR", "LEVEL_ERROR", scopePath);
-    }
-
-    // Register enumeration Mesh::IndexFormat.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Mesh");
-        gameplay::ScriptUtil::registerConstantString("INDEX8", "INDEX8", scopePath);
-        gameplay::ScriptUtil::registerConstantString("INDEX16", "INDEX16", scopePath);
-        gameplay::ScriptUtil::registerConstantString("INDEX32", "INDEX32", scopePath);
-    }
-
-    // Register enumeration Mesh::PrimitiveType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Mesh");
-        gameplay::ScriptUtil::registerConstantString("TRIANGLES", "TRIANGLES", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TRIANGLE_STRIP", "TRIANGLE_STRIP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINES", "LINES", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINE_STRIP", "LINE_STRIP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("POINTS", "POINTS", scopePath);
-    }
-
-    // Register enumeration Mouse::MouseEvent.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Mouse");
-        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_LEFT_BUTTON", "MOUSE_PRESS_LEFT_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_LEFT_BUTTON", "MOUSE_RELEASE_LEFT_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_MIDDLE_BUTTON", "MOUSE_PRESS_MIDDLE_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_MIDDLE_BUTTON", "MOUSE_RELEASE_MIDDLE_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_RIGHT_BUTTON", "MOUSE_PRESS_RIGHT_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_RIGHT_BUTTON", "MOUSE_RELEASE_RIGHT_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_MOVE", "MOUSE_MOVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_WHEEL", "MOUSE_WHEEL", scopePath);
-    }
-
-    // Register enumeration Node::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Node");
-        gameplay::ScriptUtil::registerConstantString("NODE", "NODE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("JOINT", "JOINT", scopePath);
-    }
-
-    // Register enumeration ParticleEmitter::TextureBlending.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("ParticleEmitter");
-        gameplay::ScriptUtil::registerConstantString("BLEND_OPAQUE", "BLEND_OPAQUE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_TRANSPARENT", "BLEND_TRANSPARENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ADDITIVE", "BLEND_ADDITIVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_MULTIPLIED", "BLEND_MULTIPLIED", scopePath);
-    }
-
-    // Register enumeration PhysicsCollisionObject::CollisionListener::EventType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("PhysicsCollisionObject");
-        scopePath.push_back("CollisionListener");
-        gameplay::ScriptUtil::registerConstantString("COLLIDING", "COLLIDING", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NOT_COLLIDING", "NOT_COLLIDING", scopePath);
-    }
-
-    // Register enumeration PhysicsCollisionObject::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("PhysicsCollisionObject");
-        gameplay::ScriptUtil::registerConstantString("RIGID_BODY", "RIGID_BODY", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CHARACTER", "CHARACTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GHOST_OBJECT", "GHOST_OBJECT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VEHICLE", "VEHICLE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VEHICLE_WHEEL", "VEHICLE_WHEEL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
-    }
-
-    // Register enumeration PhysicsCollisionShape::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("PhysicsCollisionShape");
-        gameplay::ScriptUtil::registerConstantString("SHAPE_NONE", "SHAPE_NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SHAPE_BOX", "SHAPE_BOX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SHAPE_SPHERE", "SHAPE_SPHERE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SHAPE_CAPSULE", "SHAPE_CAPSULE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SHAPE_MESH", "SHAPE_MESH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SHAPE_HEIGHTFIELD", "SHAPE_HEIGHTFIELD", scopePath);
-    }
-
-    // Register enumeration PhysicsController::Listener::EventType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("PhysicsController");
-        scopePath.push_back("Listener");
-        gameplay::ScriptUtil::registerConstantString("ACTIVATED", "ACTIVATED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEACTIVATED", "DEACTIVATED", scopePath);
-    }
-
-    // Register enumeration Properties::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Properties");
-        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STRING", "STRING", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NUMBER", "NUMBER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VECTOR2", "VECTOR2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VECTOR3", "VECTOR3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VECTOR4", "VECTOR4", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MATRIX", "MATRIX", scopePath);
-    }
-
-    // Register enumeration RenderState::AutoBinding.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("WORLD_MATRIX", "WORLD_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VIEW_MATRIX", "VIEW_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("PROJECTION_MATRIX", "PROJECTION_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("WORLD_VIEW_MATRIX", "WORLD_VIEW_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VIEW_PROJECTION_MATRIX", "VIEW_PROJECTION_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("WORLD_VIEW_PROJECTION_MATRIX", "WORLD_VIEW_PROJECTION_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("INVERSE_TRANSPOSE_WORLD_MATRIX", "INVERSE_TRANSPOSE_WORLD_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX", "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CAMERA_WORLD_POSITION", "CAMERA_WORLD_POSITION", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CAMERA_VIEW_POSITION", "CAMERA_VIEW_POSITION", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MATRIX_PALETTE", "MATRIX_PALETTE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SCENE_AMBIENT_COLOR", "SCENE_AMBIENT_COLOR", scopePath);
-    }
-
-    // Register enumeration RenderState::Blend.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("BLEND_ZERO", "BLEND_ZERO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE", "BLEND_ONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_COLOR", "BLEND_SRC_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_SRC_COLOR", "BLEND_ONE_MINUS_SRC_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_DST_COLOR", "BLEND_DST_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_DST_COLOR", "BLEND_ONE_MINUS_DST_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_ALPHA", "BLEND_SRC_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_SRC_ALPHA", "BLEND_ONE_MINUS_SRC_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_DST_ALPHA", "BLEND_DST_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_DST_ALPHA", "BLEND_ONE_MINUS_DST_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_CONSTANT_ALPHA", "BLEND_CONSTANT_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_CONSTANT_ALPHA", "BLEND_ONE_MINUS_CONSTANT_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_ALPHA_SATURATE", "BLEND_SRC_ALPHA_SATURATE", scopePath);
-    }
-
-    // Register enumeration RenderState::CullFaceSide.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_BACK", "CULL_FACE_SIDE_BACK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_FRONT", "CULL_FACE_SIDE_FRONT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_FRONT_AND_BACK", "CULL_FACE_SIDE_FRONT_AND_BACK", scopePath);
-    }
-
-    // Register enumeration RenderState::DepthFunction.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("DEPTH_NEVER", "DEPTH_NEVER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_LESS", "DEPTH_LESS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_EQUAL", "DEPTH_EQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_LEQUAL", "DEPTH_LEQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_GREATER", "DEPTH_GREATER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_NOTEQUAL", "DEPTH_NOTEQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_GEQUAL", "DEPTH_GEQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_ALWAYS", "DEPTH_ALWAYS", scopePath);
-    }
-
-    // Register enumeration RenderState::FrontFace.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("FRONT_FACE_CW", "FRONT_FACE_CW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FRONT_FACE_CCW", "FRONT_FACE_CCW", scopePath);
-    }
-
-    // Register enumeration RenderState::StencilFunction.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("STENCIL_NEVER", "STENCIL_NEVER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_ALWAYS", "STENCIL_ALWAYS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_LESS", "STENCIL_LESS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_LEQUAL", "STENCIL_LEQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_EQUAL", "STENCIL_EQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_GREATER", "STENCIL_GREATER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_GEQUAL", "STENCIL_GEQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_NOTEQUAL", "STENCIL_NOTEQUAL", scopePath);
-    }
-
-    // Register enumeration RenderState::StencilOperation.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_KEEP", "STENCIL_OP_KEEP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_ZERO", "STENCIL_OP_ZERO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_REPLACE", "STENCIL_OP_REPLACE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INCR", "STENCIL_OP_INCR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_DECR", "STENCIL_OP_DECR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INVERT", "STENCIL_OP_INVERT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INCR_WRAP", "STENCIL_OP_INCR_WRAP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_DECR_WRAP", "STENCIL_OP_DECR_WRAP", scopePath);
-    }
-
-    // Register enumeration Terrain::Flags.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Terrain");
-        gameplay::ScriptUtil::registerConstantString("DEBUG_PATCHES", "DEBUG_PATCHES", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FRUSTUM_CULLING", "FRUSTUM_CULLING", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LEVEL_OF_DETAIL", "LEVEL_OF_DETAIL", scopePath);
-    }
-
-    // Register enumeration TextBox::InputMode.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("TextBox");
-        gameplay::ScriptUtil::registerConstantString("TEXT", "TEXT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("PASSWORD", "PASSWORD", scopePath);
-    }
-
-    // Register enumeration Texture::Filter.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Texture");
-        gameplay::ScriptUtil::registerConstantString("NEAREST", "NEAREST", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINEAR", "LINEAR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NEAREST_MIPMAP_NEAREST", "NEAREST_MIPMAP_NEAREST", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINEAR_MIPMAP_NEAREST", "LINEAR_MIPMAP_NEAREST", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NEAREST_MIPMAP_LINEAR", "NEAREST_MIPMAP_LINEAR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINEAR_MIPMAP_LINEAR", "LINEAR_MIPMAP_LINEAR", scopePath);
-    }
-
-    // Register enumeration Texture::Format.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Texture");
-        gameplay::ScriptUtil::registerConstantString("UNKNOWN", "UNKNOWN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RGB", "RGB", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RGBA", "RGBA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALPHA", "ALPHA", scopePath);
-    }
-
-    // Register enumeration Texture::Wrap.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Texture");
-        gameplay::ScriptUtil::registerConstantString("REPEAT", "REPEAT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLAMP", "CLAMP", scopePath);
-    }
-
-    // Register enumeration Touch::TouchEvent.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Touch");
-        gameplay::ScriptUtil::registerConstantString("TOUCH_PRESS", "TOUCH_PRESS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TOUCH_RELEASE", "TOUCH_RELEASE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TOUCH_MOVE", "TOUCH_MOVE", scopePath);
-    }
-
-    // Register enumeration VertexFormat::Usage.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("VertexFormat");
-        gameplay::ScriptUtil::registerConstantString("POSITION", "POSITION", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NORMAL", "NORMAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("COLOR", "COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TANGENT", "TANGENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BINORMAL", "BINORMAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLENDWEIGHTS", "BLENDWEIGHTS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLENDINDICES", "BLENDINDICES", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD0", "TEXCOORD0", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD1", "TEXCOORD1", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD2", "TEXCOORD2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD3", "TEXCOORD3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD4", "TEXCOORD4", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD5", "TEXCOORD5", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD6", "TEXCOORD6", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD7", "TEXCOORD7", scopePath);
-    }
-}
-
-static const char* enumStringEmpty = "";
-
-const char* lua_stringFromEnumGlobal(std::string& enumname, unsigned int value)
-{
-    if (enumname == "AIMessage::ParameterType")
-        return lua_stringFromEnum_AIMessageParameterType((AIMessage::ParameterType)value);
-    if (enumname == "AnimationClip::Listener::EventType")
-        return lua_stringFromEnum_AnimationClipListenerEventType((AnimationClip::Listener::EventType)value);
-    if (enumname == "AudioSource::State")
-        return lua_stringFromEnum_AudioSourceState((AudioSource::State)value);
-    if (enumname == "Camera::Type")
-        return lua_stringFromEnum_CameraType((Camera::Type)value);
-    if (enumname == "Container::Scroll")
-        return lua_stringFromEnum_ContainerScroll((Container::Scroll)value);
-    if (enumname == "Control::Alignment")
-        return lua_stringFromEnum_ControlAlignment((Control::Alignment)value);
-    if (enumname == "Control::AutoSize")
-        return lua_stringFromEnum_ControlAutoSize((Control::AutoSize)value);
-    if (enumname == "Control::Listener::EventType")
-        return lua_stringFromEnum_ControlListenerEventType((Control::Listener::EventType)value);
-    if (enumname == "Control::State")
-        return lua_stringFromEnum_ControlState((Control::State)value);
-    if (enumname == "Curve::InterpolationType")
-        return lua_stringFromEnum_CurveInterpolationType((Curve::InterpolationType)value);
-    if (enumname == "DepthStencilTarget::Format")
-        return lua_stringFromEnum_DepthStencilTargetFormat((DepthStencilTarget::Format)value);
-    if (enumname == "Font::Format")
-        return lua_stringFromEnum_FontFormat((Font::Format)value);
-    if (enumname == "Font::Justify")
-        return lua_stringFromEnum_FontJustify((Font::Justify)value);
-    if (enumname == "Font::Style")
-        return lua_stringFromEnum_FontStyle((Font::Style)value);
-    if (enumname == "Game::ClearFlags")
-        return lua_stringFromEnum_GameClearFlags((Game::ClearFlags)value);
-    if (enumname == "Game::State")
-        return lua_stringFromEnum_GameState((Game::State)value);
-    if (enumname == "Gamepad::ButtonMapping")
-        return lua_stringFromEnum_GamepadButtonMapping((Gamepad::ButtonMapping)value);
-    if (enumname == "Gamepad::GamepadEvent")
-        return lua_stringFromEnum_GamepadGamepadEvent((Gamepad::GamepadEvent)value);
-    if (enumname == "Gesture::GestureEvent")
-        return lua_stringFromEnum_GestureGestureEvent((Gesture::GestureEvent)value);
-    if (enumname == "Image::Format")
-        return lua_stringFromEnum_ImageFormat((Image::Format)value);
-    if (enumname == "Keyboard::Key")
-        return lua_stringFromEnum_KeyboardKey((Keyboard::Key)value);
-    if (enumname == "Keyboard::KeyEvent")
-        return lua_stringFromEnum_KeyboardKeyEvent((Keyboard::KeyEvent)value);
-    if (enumname == "Layout::Type")
-        return lua_stringFromEnum_LayoutType((Layout::Type)value);
-    if (enumname == "Light::Type")
-        return lua_stringFromEnum_LightType((Light::Type)value);
-    if (enumname == "Logger::Level")
-        return lua_stringFromEnum_LoggerLevel((Logger::Level)value);
-    if (enumname == "Mesh::IndexFormat")
-        return lua_stringFromEnum_MeshIndexFormat((Mesh::IndexFormat)value);
-    if (enumname == "Mesh::PrimitiveType")
-        return lua_stringFromEnum_MeshPrimitiveType((Mesh::PrimitiveType)value);
-    if (enumname == "Mouse::MouseEvent")
-        return lua_stringFromEnum_MouseMouseEvent((Mouse::MouseEvent)value);
-    if (enumname == "Node::Type")
-        return lua_stringFromEnum_NodeType((Node::Type)value);
-    if (enumname == "ParticleEmitter::TextureBlending")
-        return lua_stringFromEnum_ParticleEmitterTextureBlending((ParticleEmitter::TextureBlending)value);
-    if (enumname == "PhysicsCollisionObject::CollisionListener::EventType")
-        return lua_stringFromEnum_PhysicsCollisionObjectCollisionListenerEventType((PhysicsCollisionObject::CollisionListener::EventType)value);
-    if (enumname == "PhysicsCollisionObject::Type")
-        return lua_stringFromEnum_PhysicsCollisionObjectType((PhysicsCollisionObject::Type)value);
-    if (enumname == "PhysicsCollisionShape::Type")
-        return lua_stringFromEnum_PhysicsCollisionShapeType((PhysicsCollisionShape::Type)value);
-    if (enumname == "PhysicsController::Listener::EventType")
-        return lua_stringFromEnum_PhysicsControllerListenerEventType((PhysicsController::Listener::EventType)value);
-    if (enumname == "Properties::Type")
-        return lua_stringFromEnum_PropertiesType((Properties::Type)value);
-    if (enumname == "RenderState::AutoBinding")
-        return lua_stringFromEnum_RenderStateAutoBinding((RenderState::AutoBinding)value);
-    if (enumname == "RenderState::Blend")
-        return lua_stringFromEnum_RenderStateBlend((RenderState::Blend)value);
-    if (enumname == "RenderState::CullFaceSide")
-        return lua_stringFromEnum_RenderStateCullFaceSide((RenderState::CullFaceSide)value);
-    if (enumname == "RenderState::DepthFunction")
-        return lua_stringFromEnum_RenderStateDepthFunction((RenderState::DepthFunction)value);
-    if (enumname == "RenderState::FrontFace")
-        return lua_stringFromEnum_RenderStateFrontFace((RenderState::FrontFace)value);
-    if (enumname == "RenderState::StencilFunction")
-        return lua_stringFromEnum_RenderStateStencilFunction((RenderState::StencilFunction)value);
-    if (enumname == "RenderState::StencilOperation")
-        return lua_stringFromEnum_RenderStateStencilOperation((RenderState::StencilOperation)value);
-    if (enumname == "Terrain::Flags")
-        return lua_stringFromEnum_TerrainFlags((Terrain::Flags)value);
-    if (enumname == "TextBox::InputMode")
-        return lua_stringFromEnum_TextBoxInputMode((TextBox::InputMode)value);
-    if (enumname == "Texture::Filter")
-        return lua_stringFromEnum_TextureFilter((Texture::Filter)value);
-    if (enumname == "Texture::Format")
-        return lua_stringFromEnum_TextureFormat((Texture::Format)value);
-    if (enumname == "Texture::Wrap")
-        return lua_stringFromEnum_TextureWrap((Texture::Wrap)value);
-    if (enumname == "Touch::TouchEvent")
-        return lua_stringFromEnum_TouchTouchEvent((Touch::TouchEvent)value);
-    if (enumname == "VertexFormat::Usage")
-        return lua_stringFromEnum_VertexFormatUsage((VertexFormat::Usage)value);
-
-    GP_ERROR("Unrecognized enumeration type '%s'.", enumname.c_str());
-    return enumStringEmpty;
-}
-
-}
+#include "ScriptController.h"
+#include "lua_Global.h"
+
+namespace gameplay
+{
+
+void luaRegister_lua_Global()
+{
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Button");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Container");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Control");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Form");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "ImageControl");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Joint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Joystick");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Label");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "MaterialParameter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Node");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Slider");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "TextBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Transform");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Button", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Button", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Camera::Listener", "AudioListener");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Camera::Listener", "TerrainPatch");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Container", "Form");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Button");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Container");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Form");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "ImageControl");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Joystick");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Label");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Slider");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "TextBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "Button");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "Slider");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "TextBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "AbsoluteLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "FlowLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "VerticalLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Node", "Joint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsCharacter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsGhostObject");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsRigidBody");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsVehicle");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsVehicleWheel");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsFixedConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsGenericConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsHingeConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsSocketConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsSpringConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGenericConstraint", "PhysicsFixedConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGenericConstraint", "PhysicsSpringConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGhostObject", "PhysicsCharacter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AIAgent");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AIState");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AbsoluteLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Animation");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AnimationClip");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AudioBuffer");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AudioSource");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Bundle");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Button");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Camera");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Container");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Control");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Curve");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "DepthStencilTarget");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Effect");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "FlowLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Font");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Form");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "FrameBuffer");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "HeightField");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Image");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "ImageControl");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Joint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Joystick");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Label");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Layout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Light");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Material");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "MaterialParameter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Mesh");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Model");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Node");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "ParticleEmitter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Pass");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "PhysicsCollisionShape");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderState");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderState::StateBlock");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderTarget");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Scene");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Slider");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Technique");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Terrain");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "TextBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Texture");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Texture::Sampler");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Theme");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Theme::ThemeImage");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "VertexAttributeBinding");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "VerticalLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Material");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Pass");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Technique");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "AIAgent");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "AIState");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Button");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Container");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Control");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Form");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "ImageControl");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Joint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Joystick");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Label");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Node");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "PhysicsController");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Slider");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "TextBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Transform");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform", "Joint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform", "Node");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "AudioSource");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "Camera");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "MeshSkin");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsCharacter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsGhostObject");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsRigidBody");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "Terrain");
+    gameplay::ScriptUtil::addStringFromEnumConversionFunction(&gameplay::lua_stringFromEnumGlobal);
+
+    // Register enumeration AIMessage::ParameterType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("AIMessage");
+        gameplay::ScriptUtil::registerConstantString("UNDEFINED", "UNDEFINED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("INTEGER", "INTEGER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LONG", "LONG", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FLOAT", "FLOAT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DOUBLE", "DOUBLE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOOLEAN", "BOOLEAN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STRING", "STRING", scopePath);
+    }
+
+    // Register enumeration AnimationClip::Listener::EventType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("AnimationClip");
+        scopePath.push_back("Listener");
+        gameplay::ScriptUtil::registerConstantString("BEGIN", "BEGIN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("END", "END", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TIME", "TIME", scopePath);
+    }
+
+    // Register enumeration AudioSource::State.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("AudioSource");
+        gameplay::ScriptUtil::registerConstantString("INITIAL", "INITIAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PLAYING", "PLAYING", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PAUSED", "PAUSED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STOPPED", "STOPPED", scopePath);
+    }
+
+    // Register enumeration Camera::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Camera");
+        gameplay::ScriptUtil::registerConstantString("PERSPECTIVE", "PERSPECTIVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ORTHOGRAPHIC", "ORTHOGRAPHIC", scopePath);
+    }
+
+    // Register enumeration Container::Scroll.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Container");
+        gameplay::ScriptUtil::registerConstantString("SCROLL_NONE", "SCROLL_NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SCROLL_HORIZONTAL", "SCROLL_HORIZONTAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SCROLL_VERTICAL", "SCROLL_VERTICAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SCROLL_BOTH", "SCROLL_BOTH", scopePath);
+    }
+
+    // Register enumeration Control::Alignment.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Control");
+        gameplay::ScriptUtil::registerConstantString("ALIGN_LEFT", "ALIGN_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_HCENTER", "ALIGN_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_RIGHT", "ALIGN_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP", "ALIGN_TOP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER", "ALIGN_VCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM", "ALIGN_BOTTOM", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_LEFT", "ALIGN_TOP_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_LEFT", "ALIGN_VCENTER_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_LEFT", "ALIGN_BOTTOM_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_HCENTER", "ALIGN_TOP_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_HCENTER", "ALIGN_VCENTER_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_HCENTER", "ALIGN_BOTTOM_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_RIGHT", "ALIGN_TOP_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_RIGHT", "ALIGN_VCENTER_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_RIGHT", "ALIGN_BOTTOM_RIGHT", scopePath);
+    }
+
+    // Register enumeration Control::AutoSize.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Control");
+        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_NONE", "AUTO_SIZE_NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_STRETCH", "AUTO_SIZE_STRETCH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_FIT", "AUTO_SIZE_FIT", scopePath);
+    }
+
+    // Register enumeration Control::Listener::EventType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Control");
+        scopePath.push_back("Listener");
+        gameplay::ScriptUtil::registerConstantString("PRESS", "PRESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RELEASE", "RELEASE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLICK", "CLICK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VALUE_CHANGED", "VALUE_CHANGED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXT_CHANGED", "TEXT_CHANGED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MIDDLE_CLICK", "MIDDLE_CLICK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RIGHT_CLICK", "RIGHT_CLICK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ENTER", "ENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LEAVE", "LEAVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FOCUS_GAINED", "FOCUS_GAINED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FOCUS_LOST", "FOCUS_LOST", scopePath);
+    }
+
+    // Register enumeration Control::State.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Control");
+        gameplay::ScriptUtil::registerConstantString("NORMAL", "NORMAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FOCUS", "FOCUS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ACTIVE", "ACTIVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DISABLED", "DISABLED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("HOVER", "HOVER", scopePath);
+    }
+
+    // Register enumeration Curve::InterpolationType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Curve");
+        gameplay::ScriptUtil::registerConstantString("BEZIER", "BEZIER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BSPLINE", "BSPLINE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FLAT", "FLAT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("HERMITE", "HERMITE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINEAR", "LINEAR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SMOOTH", "SMOOTH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STEP", "STEP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUADRATIC_IN", "QUADRATIC_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUADRATIC_OUT", "QUADRATIC_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUADRATIC_IN_OUT", "QUADRATIC_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUADRATIC_OUT_IN", "QUADRATIC_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CUBIC_IN", "CUBIC_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CUBIC_OUT", "CUBIC_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CUBIC_IN_OUT", "CUBIC_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CUBIC_OUT_IN", "CUBIC_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUARTIC_IN", "QUARTIC_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUARTIC_OUT", "QUARTIC_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUARTIC_IN_OUT", "QUARTIC_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUARTIC_OUT_IN", "QUARTIC_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUINTIC_IN", "QUINTIC_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUINTIC_OUT", "QUINTIC_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUINTIC_IN_OUT", "QUINTIC_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUINTIC_OUT_IN", "QUINTIC_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SINE_IN", "SINE_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SINE_OUT", "SINE_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SINE_IN_OUT", "SINE_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SINE_OUT_IN", "SINE_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_IN", "EXPONENTIAL_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_OUT", "EXPONENTIAL_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_IN_OUT", "EXPONENTIAL_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_OUT_IN", "EXPONENTIAL_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CIRCULAR_IN", "CIRCULAR_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CIRCULAR_OUT", "CIRCULAR_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CIRCULAR_IN_OUT", "CIRCULAR_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CIRCULAR_OUT_IN", "CIRCULAR_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ELASTIC_IN", "ELASTIC_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ELASTIC_OUT", "ELASTIC_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ELASTIC_IN_OUT", "ELASTIC_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ELASTIC_OUT_IN", "ELASTIC_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_IN", "OVERSHOOT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_OUT", "OVERSHOOT_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_IN_OUT", "OVERSHOOT_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_OUT_IN", "OVERSHOOT_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOUNCE_IN", "BOUNCE_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOUNCE_OUT", "BOUNCE_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOUNCE_IN_OUT", "BOUNCE_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOUNCE_OUT_IN", "BOUNCE_OUT_IN", scopePath);
+    }
+
+    // Register enumeration DepthStencilTarget::Format.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("DepthStencilTarget");
+        gameplay::ScriptUtil::registerConstantString("DEPTH", "DEPTH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_STENCIL", "DEPTH_STENCIL", scopePath);
+    }
+
+    // Register enumeration Font::Format.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Font");
+        gameplay::ScriptUtil::registerConstantString("BITMAP", "BITMAP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DISTANCE_FIELD", "DISTANCE_FIELD", scopePath);
+    }
+
+    // Register enumeration Font::Justify.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Font");
+        gameplay::ScriptUtil::registerConstantString("ALIGN_LEFT", "ALIGN_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_HCENTER", "ALIGN_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_RIGHT", "ALIGN_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP", "ALIGN_TOP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER", "ALIGN_VCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM", "ALIGN_BOTTOM", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_LEFT", "ALIGN_TOP_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_LEFT", "ALIGN_VCENTER_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_LEFT", "ALIGN_BOTTOM_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_HCENTER", "ALIGN_TOP_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_HCENTER", "ALIGN_VCENTER_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_HCENTER", "ALIGN_BOTTOM_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_RIGHT", "ALIGN_TOP_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_RIGHT", "ALIGN_VCENTER_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_RIGHT", "ALIGN_BOTTOM_RIGHT", scopePath);
+    }
+
+    // Register enumeration Font::Style.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Font");
+        gameplay::ScriptUtil::registerConstantString("PLAIN", "PLAIN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOLD", "BOLD", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ITALIC", "ITALIC", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOLD_ITALIC", "BOLD_ITALIC", scopePath);
+    }
+
+    // Register enumeration Game::ClearFlags.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Game");
+        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR", "CLEAR_COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_DEPTH", "CLEAR_DEPTH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_STENCIL", "CLEAR_STENCIL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_DEPTH", "CLEAR_COLOR_DEPTH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_STENCIL", "CLEAR_COLOR_STENCIL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_DEPTH_STENCIL", "CLEAR_DEPTH_STENCIL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_DEPTH_STENCIL", "CLEAR_COLOR_DEPTH_STENCIL", scopePath);
+    }
+
+    // Register enumeration Game::State.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Game");
+        gameplay::ScriptUtil::registerConstantString("UNINITIALIZED", "UNINITIALIZED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RUNNING", "RUNNING", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PAUSED", "PAUSED", scopePath);
+    }
+
+    // Register enumeration Gamepad::ButtonMapping.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Gamepad");
+        gameplay::ScriptUtil::registerConstantString("BUTTON_A", "BUTTON_A", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_B", "BUTTON_B", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_C", "BUTTON_C", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_X", "BUTTON_X", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_Y", "BUTTON_Y", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_Z", "BUTTON_Z", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU1", "BUTTON_MENU1", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU2", "BUTTON_MENU2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU3", "BUTTON_MENU3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU4", "BUTTON_MENU4", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_L1", "BUTTON_L1", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_L2", "BUTTON_L2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_L3", "BUTTON_L3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_R1", "BUTTON_R1", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_R2", "BUTTON_R2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_R3", "BUTTON_R3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_UP", "BUTTON_UP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_DOWN", "BUTTON_DOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_LEFT", "BUTTON_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_RIGHT", "BUTTON_RIGHT", scopePath);
+    }
+
+    // Register enumeration Gamepad::GamepadEvent.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Gamepad");
+        gameplay::ScriptUtil::registerConstantString("CONNECTED_EVENT", "CONNECTED_EVENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DISCONNECTED_EVENT", "DISCONNECTED_EVENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_EVENT", "BUTTON_EVENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("JOYSTICK_EVENT", "JOYSTICK_EVENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TRIGGER_EVENT", "TRIGGER_EVENT", scopePath);
+    }
+
+    // Register enumeration Gesture::GestureEvent.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Gesture");
+        gameplay::ScriptUtil::registerConstantString("GESTURE_TAP", "GESTURE_TAP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GESTURE_SWIPE", "GESTURE_SWIPE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GESTURE_PINCH", "GESTURE_PINCH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GESTURE_ANY_SUPPORTED", "GESTURE_ANY_SUPPORTED", scopePath);
+    }
+
+    // Register enumeration Image::Format.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Image");
+        gameplay::ScriptUtil::registerConstantString("RGB", "RGB", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RGBA", "RGBA", scopePath);
+    }
+
+    // Register enumeration Keyboard::Key.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Keyboard");
+        gameplay::ScriptUtil::registerConstantString("KEY_NONE", "KEY_NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PAUSE", "KEY_PAUSE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SCROLL_LOCK", "KEY_SCROLL_LOCK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PRINT", "KEY_PRINT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SYSREQ", "KEY_SYSREQ", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_BREAK", "KEY_BREAK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_ESCAPE", "KEY_ESCAPE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_BACKSPACE", "KEY_BACKSPACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_TAB", "KEY_TAB", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_BACK_TAB", "KEY_BACK_TAB", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RETURN", "KEY_RETURN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPS_LOCK", "KEY_CAPS_LOCK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SHIFT", "KEY_SHIFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CTRL", "KEY_CTRL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_ALT", "KEY_ALT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_MENU", "KEY_MENU", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_HYPER", "KEY_HYPER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_INSERT", "KEY_INSERT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_HOME", "KEY_HOME", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PG_UP", "KEY_PG_UP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_DELETE", "KEY_DELETE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_END", "KEY_END", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PG_DOWN", "KEY_PG_DOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_ARROW", "KEY_LEFT_ARROW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_ARROW", "KEY_RIGHT_ARROW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_UP_ARROW", "KEY_UP_ARROW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_DOWN_ARROW", "KEY_DOWN_ARROW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_NUM_LOCK", "KEY_NUM_LOCK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_PLUS", "KEY_KP_PLUS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_MINUS", "KEY_KP_MINUS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_MULTIPLY", "KEY_KP_MULTIPLY", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_DIVIDE", "KEY_KP_DIVIDE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_ENTER", "KEY_KP_ENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_HOME", "KEY_KP_HOME", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_UP", "KEY_KP_UP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_PG_UP", "KEY_KP_PG_UP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_LEFT", "KEY_KP_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_FIVE", "KEY_KP_FIVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_RIGHT", "KEY_KP_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_END", "KEY_KP_END", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_DOWN", "KEY_KP_DOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_PG_DOWN", "KEY_KP_PG_DOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_INSERT", "KEY_KP_INSERT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_DELETE", "KEY_KP_DELETE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F1", "KEY_F1", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F2", "KEY_F2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F3", "KEY_F3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F4", "KEY_F4", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F5", "KEY_F5", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F6", "KEY_F6", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F7", "KEY_F7", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F8", "KEY_F8", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F9", "KEY_F9", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F10", "KEY_F10", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F11", "KEY_F11", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F12", "KEY_F12", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SPACE", "KEY_SPACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_EXCLAM", "KEY_EXCLAM", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_QUOTE", "KEY_QUOTE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_NUMBER", "KEY_NUMBER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_DOLLAR", "KEY_DOLLAR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PERCENT", "KEY_PERCENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CIRCUMFLEX", "KEY_CIRCUMFLEX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_AMPERSAND", "KEY_AMPERSAND", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_APOSTROPHE", "KEY_APOSTROPHE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_PARENTHESIS", "KEY_LEFT_PARENTHESIS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_PARENTHESIS", "KEY_RIGHT_PARENTHESIS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_ASTERISK", "KEY_ASTERISK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PLUS", "KEY_PLUS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_COMMA", "KEY_COMMA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_MINUS", "KEY_MINUS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PERIOD", "KEY_PERIOD", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SLASH", "KEY_SLASH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_ZERO", "KEY_ZERO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_ONE", "KEY_ONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_TWO", "KEY_TWO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_THREE", "KEY_THREE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_FOUR", "KEY_FOUR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_FIVE", "KEY_FIVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SIX", "KEY_SIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SEVEN", "KEY_SEVEN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_EIGHT", "KEY_EIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_NINE", "KEY_NINE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_COLON", "KEY_COLON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SEMICOLON", "KEY_SEMICOLON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_LESS_THAN", "KEY_LESS_THAN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_EQUAL", "KEY_EQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_GREATER_THAN", "KEY_GREATER_THAN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_QUESTION", "KEY_QUESTION", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_AT", "KEY_AT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_A", "KEY_CAPITAL_A", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_B", "KEY_CAPITAL_B", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_C", "KEY_CAPITAL_C", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_D", "KEY_CAPITAL_D", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_E", "KEY_CAPITAL_E", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_F", "KEY_CAPITAL_F", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_G", "KEY_CAPITAL_G", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_H", "KEY_CAPITAL_H", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_I", "KEY_CAPITAL_I", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_J", "KEY_CAPITAL_J", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_K", "KEY_CAPITAL_K", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_L", "KEY_CAPITAL_L", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_M", "KEY_CAPITAL_M", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_N", "KEY_CAPITAL_N", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_O", "KEY_CAPITAL_O", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_P", "KEY_CAPITAL_P", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Q", "KEY_CAPITAL_Q", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_R", "KEY_CAPITAL_R", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_S", "KEY_CAPITAL_S", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_T", "KEY_CAPITAL_T", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_U", "KEY_CAPITAL_U", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_V", "KEY_CAPITAL_V", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_W", "KEY_CAPITAL_W", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_X", "KEY_CAPITAL_X", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Y", "KEY_CAPITAL_Y", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Z", "KEY_CAPITAL_Z", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_BRACKET", "KEY_LEFT_BRACKET", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_BACK_SLASH", "KEY_BACK_SLASH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_BRACKET", "KEY_RIGHT_BRACKET", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_UNDERSCORE", "KEY_UNDERSCORE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_GRAVE", "KEY_GRAVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_A", "KEY_A", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_B", "KEY_B", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_C", "KEY_C", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_D", "KEY_D", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_E", "KEY_E", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F", "KEY_F", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_G", "KEY_G", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_H", "KEY_H", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_I", "KEY_I", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_J", "KEY_J", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_K", "KEY_K", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_L", "KEY_L", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_M", "KEY_M", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_N", "KEY_N", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_O", "KEY_O", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_P", "KEY_P", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_Q", "KEY_Q", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_R", "KEY_R", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_S", "KEY_S", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_T", "KEY_T", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_U", "KEY_U", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_V", "KEY_V", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_W", "KEY_W", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_X", "KEY_X", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_Y", "KEY_Y", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_Z", "KEY_Z", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_BRACE", "KEY_LEFT_BRACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_BAR", "KEY_BAR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_BRACE", "KEY_RIGHT_BRACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_TILDE", "KEY_TILDE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_EURO", "KEY_EURO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_POUND", "KEY_POUND", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_YEN", "KEY_YEN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_MIDDLE_DOT", "KEY_MIDDLE_DOT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SEARCH", "KEY_SEARCH", scopePath);
+    }
+
+    // Register enumeration Keyboard::KeyEvent.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Keyboard");
+        gameplay::ScriptUtil::registerConstantString("KEY_PRESS", "KEY_PRESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RELEASE", "KEY_RELEASE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CHAR", "KEY_CHAR", scopePath);
+    }
+
+    // Register enumeration Layout::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Layout");
+        gameplay::ScriptUtil::registerConstantString("LAYOUT_FLOW", "LAYOUT_FLOW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LAYOUT_VERTICAL", "LAYOUT_VERTICAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LAYOUT_ABSOLUTE", "LAYOUT_ABSOLUTE", scopePath);
+    }
+
+    // Register enumeration Light::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Light");
+        gameplay::ScriptUtil::registerConstantString("DIRECTIONAL", "DIRECTIONAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("POINT", "POINT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SPOT", "SPOT", scopePath);
+    }
+
+    // Register enumeration Logger::Level.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Logger");
+        gameplay::ScriptUtil::registerConstantString("LEVEL_INFO", "LEVEL_INFO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LEVEL_WARN", "LEVEL_WARN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LEVEL_ERROR", "LEVEL_ERROR", scopePath);
+    }
+
+    // Register enumeration Mesh::IndexFormat.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Mesh");
+        gameplay::ScriptUtil::registerConstantString("INDEX8", "INDEX8", scopePath);
+        gameplay::ScriptUtil::registerConstantString("INDEX16", "INDEX16", scopePath);
+        gameplay::ScriptUtil::registerConstantString("INDEX32", "INDEX32", scopePath);
+    }
+
+    // Register enumeration Mesh::PrimitiveType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Mesh");
+        gameplay::ScriptUtil::registerConstantString("TRIANGLES", "TRIANGLES", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TRIANGLE_STRIP", "TRIANGLE_STRIP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINES", "LINES", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINE_STRIP", "LINE_STRIP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("POINTS", "POINTS", scopePath);
+    }
+
+    // Register enumeration Mouse::MouseEvent.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Mouse");
+        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_LEFT_BUTTON", "MOUSE_PRESS_LEFT_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_LEFT_BUTTON", "MOUSE_RELEASE_LEFT_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_MIDDLE_BUTTON", "MOUSE_PRESS_MIDDLE_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_MIDDLE_BUTTON", "MOUSE_RELEASE_MIDDLE_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_RIGHT_BUTTON", "MOUSE_PRESS_RIGHT_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_RIGHT_BUTTON", "MOUSE_RELEASE_RIGHT_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_MOVE", "MOUSE_MOVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_WHEEL", "MOUSE_WHEEL", scopePath);
+    }
+
+    // Register enumeration Node::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Node");
+        gameplay::ScriptUtil::registerConstantString("NODE", "NODE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("JOINT", "JOINT", scopePath);
+    }
+
+    // Register enumeration ParticleEmitter::TextureBlending.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("ParticleEmitter");
+        gameplay::ScriptUtil::registerConstantString("BLEND_OPAQUE", "BLEND_OPAQUE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_TRANSPARENT", "BLEND_TRANSPARENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ADDITIVE", "BLEND_ADDITIVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_MULTIPLIED", "BLEND_MULTIPLIED", scopePath);
+    }
+
+    // Register enumeration PhysicsCollisionObject::CollisionListener::EventType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("PhysicsCollisionObject");
+        scopePath.push_back("CollisionListener");
+        gameplay::ScriptUtil::registerConstantString("COLLIDING", "COLLIDING", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NOT_COLLIDING", "NOT_COLLIDING", scopePath);
+    }
+
+    // Register enumeration PhysicsCollisionObject::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("PhysicsCollisionObject");
+        gameplay::ScriptUtil::registerConstantString("RIGID_BODY", "RIGID_BODY", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CHARACTER", "CHARACTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GHOST_OBJECT", "GHOST_OBJECT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VEHICLE", "VEHICLE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VEHICLE_WHEEL", "VEHICLE_WHEEL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
+    }
+
+    // Register enumeration PhysicsCollisionShape::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("PhysicsCollisionShape");
+        gameplay::ScriptUtil::registerConstantString("SHAPE_NONE", "SHAPE_NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SHAPE_BOX", "SHAPE_BOX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SHAPE_SPHERE", "SHAPE_SPHERE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SHAPE_CAPSULE", "SHAPE_CAPSULE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SHAPE_MESH", "SHAPE_MESH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SHAPE_HEIGHTFIELD", "SHAPE_HEIGHTFIELD", scopePath);
+    }
+
+    // Register enumeration PhysicsController::Listener::EventType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("PhysicsController");
+        scopePath.push_back("Listener");
+        gameplay::ScriptUtil::registerConstantString("ACTIVATED", "ACTIVATED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEACTIVATED", "DEACTIVATED", scopePath);
+    }
+
+    // Register enumeration Properties::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Properties");
+        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STRING", "STRING", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NUMBER", "NUMBER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VECTOR2", "VECTOR2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VECTOR3", "VECTOR3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VECTOR4", "VECTOR4", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MATRIX", "MATRIX", scopePath);
+    }
+
+    // Register enumeration RenderState::AutoBinding.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("WORLD_MATRIX", "WORLD_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VIEW_MATRIX", "VIEW_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PROJECTION_MATRIX", "PROJECTION_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("WORLD_VIEW_MATRIX", "WORLD_VIEW_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VIEW_PROJECTION_MATRIX", "VIEW_PROJECTION_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("WORLD_VIEW_PROJECTION_MATRIX", "WORLD_VIEW_PROJECTION_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("INVERSE_TRANSPOSE_WORLD_MATRIX", "INVERSE_TRANSPOSE_WORLD_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX", "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CAMERA_WORLD_POSITION", "CAMERA_WORLD_POSITION", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CAMERA_VIEW_POSITION", "CAMERA_VIEW_POSITION", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MATRIX_PALETTE", "MATRIX_PALETTE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SCENE_AMBIENT_COLOR", "SCENE_AMBIENT_COLOR", scopePath);
+    }
+
+    // Register enumeration RenderState::Blend.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("BLEND_ZERO", "BLEND_ZERO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE", "BLEND_ONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_COLOR", "BLEND_SRC_COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_SRC_COLOR", "BLEND_ONE_MINUS_SRC_COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_DST_COLOR", "BLEND_DST_COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_DST_COLOR", "BLEND_ONE_MINUS_DST_COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_ALPHA", "BLEND_SRC_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_SRC_ALPHA", "BLEND_ONE_MINUS_SRC_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_DST_ALPHA", "BLEND_DST_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_DST_ALPHA", "BLEND_ONE_MINUS_DST_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_CONSTANT_ALPHA", "BLEND_CONSTANT_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_CONSTANT_ALPHA", "BLEND_ONE_MINUS_CONSTANT_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_ALPHA_SATURATE", "BLEND_SRC_ALPHA_SATURATE", scopePath);
+    }
+
+    // Register enumeration RenderState::CullFaceSide.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_BACK", "CULL_FACE_SIDE_BACK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_FRONT", "CULL_FACE_SIDE_FRONT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_FRONT_AND_BACK", "CULL_FACE_SIDE_FRONT_AND_BACK", scopePath);
+    }
+
+    // Register enumeration RenderState::DepthFunction.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("DEPTH_NEVER", "DEPTH_NEVER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_LESS", "DEPTH_LESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_EQUAL", "DEPTH_EQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_LEQUAL", "DEPTH_LEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_GREATER", "DEPTH_GREATER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_NOTEQUAL", "DEPTH_NOTEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_GEQUAL", "DEPTH_GEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_ALWAYS", "DEPTH_ALWAYS", scopePath);
+    }
+
+    // Register enumeration RenderState::FrontFace.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("FRONT_FACE_CW", "FRONT_FACE_CW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FRONT_FACE_CCW", "FRONT_FACE_CCW", scopePath);
+    }
+
+    // Register enumeration RenderState::StencilFunction.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("STENCIL_NEVER", "STENCIL_NEVER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_ALWAYS", "STENCIL_ALWAYS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_LESS", "STENCIL_LESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_LEQUAL", "STENCIL_LEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_EQUAL", "STENCIL_EQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_GREATER", "STENCIL_GREATER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_GEQUAL", "STENCIL_GEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_NOTEQUAL", "STENCIL_NOTEQUAL", scopePath);
+    }
+
+    // Register enumeration RenderState::StencilOperation.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_KEEP", "STENCIL_OP_KEEP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_ZERO", "STENCIL_OP_ZERO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_REPLACE", "STENCIL_OP_REPLACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INCR", "STENCIL_OP_INCR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_DECR", "STENCIL_OP_DECR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INVERT", "STENCIL_OP_INVERT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INCR_WRAP", "STENCIL_OP_INCR_WRAP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_DECR_WRAP", "STENCIL_OP_DECR_WRAP", scopePath);
+    }
+
+    // Register enumeration Terrain::Flags.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Terrain");
+        gameplay::ScriptUtil::registerConstantString("DEBUG_PATCHES", "DEBUG_PATCHES", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FRUSTUM_CULLING", "FRUSTUM_CULLING", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LEVEL_OF_DETAIL", "LEVEL_OF_DETAIL", scopePath);
+    }
+
+    // Register enumeration TextBox::InputMode.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("TextBox");
+        gameplay::ScriptUtil::registerConstantString("TEXT", "TEXT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PASSWORD", "PASSWORD", scopePath);
+    }
+
+    // Register enumeration Texture::Filter.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Texture");
+        gameplay::ScriptUtil::registerConstantString("NEAREST", "NEAREST", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINEAR", "LINEAR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NEAREST_MIPMAP_NEAREST", "NEAREST_MIPMAP_NEAREST", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINEAR_MIPMAP_NEAREST", "LINEAR_MIPMAP_NEAREST", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NEAREST_MIPMAP_LINEAR", "NEAREST_MIPMAP_LINEAR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINEAR_MIPMAP_LINEAR", "LINEAR_MIPMAP_LINEAR", scopePath);
+    }
+
+    // Register enumeration Texture::Format.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Texture");
+        gameplay::ScriptUtil::registerConstantString("UNKNOWN", "UNKNOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RGB", "RGB", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RGBA", "RGBA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALPHA", "ALPHA", scopePath);
+    }
+
+    // Register enumeration Texture::Wrap.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Texture");
+        gameplay::ScriptUtil::registerConstantString("REPEAT", "REPEAT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLAMP", "CLAMP", scopePath);
+    }
+
+    // Register enumeration Touch::TouchEvent.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Touch");
+        gameplay::ScriptUtil::registerConstantString("TOUCH_PRESS", "TOUCH_PRESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TOUCH_RELEASE", "TOUCH_RELEASE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TOUCH_MOVE", "TOUCH_MOVE", scopePath);
+    }
+
+    // Register enumeration VertexFormat::Usage.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("VertexFormat");
+        gameplay::ScriptUtil::registerConstantString("POSITION", "POSITION", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NORMAL", "NORMAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("COLOR", "COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TANGENT", "TANGENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BINORMAL", "BINORMAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLENDWEIGHTS", "BLENDWEIGHTS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLENDINDICES", "BLENDINDICES", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD0", "TEXCOORD0", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD1", "TEXCOORD1", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD2", "TEXCOORD2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD3", "TEXCOORD3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD4", "TEXCOORD4", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD5", "TEXCOORD5", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD6", "TEXCOORD6", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD7", "TEXCOORD7", scopePath);
+    }
+}
+
+static const char* enumStringEmpty = "";
+
+const char* lua_stringFromEnumGlobal(std::string& enumname, unsigned int value)
+{
+    if (enumname == "AIMessage::ParameterType")
+        return lua_stringFromEnum_AIMessageParameterType((AIMessage::ParameterType)value);
+    if (enumname == "AnimationClip::Listener::EventType")
+        return lua_stringFromEnum_AnimationClipListenerEventType((AnimationClip::Listener::EventType)value);
+    if (enumname == "AudioSource::State")
+        return lua_stringFromEnum_AudioSourceState((AudioSource::State)value);
+    if (enumname == "Camera::Type")
+        return lua_stringFromEnum_CameraType((Camera::Type)value);
+    if (enumname == "Container::Scroll")
+        return lua_stringFromEnum_ContainerScroll((Container::Scroll)value);
+    if (enumname == "Control::Alignment")
+        return lua_stringFromEnum_ControlAlignment((Control::Alignment)value);
+    if (enumname == "Control::AutoSize")
+        return lua_stringFromEnum_ControlAutoSize((Control::AutoSize)value);
+    if (enumname == "Control::Listener::EventType")
+        return lua_stringFromEnum_ControlListenerEventType((Control::Listener::EventType)value);
+    if (enumname == "Control::State")
+        return lua_stringFromEnum_ControlState((Control::State)value);
+    if (enumname == "Curve::InterpolationType")
+        return lua_stringFromEnum_CurveInterpolationType((Curve::InterpolationType)value);
+    if (enumname == "DepthStencilTarget::Format")
+        return lua_stringFromEnum_DepthStencilTargetFormat((DepthStencilTarget::Format)value);
+    if (enumname == "Font::Format")
+        return lua_stringFromEnum_FontFormat((Font::Format)value);
+    if (enumname == "Font::Justify")
+        return lua_stringFromEnum_FontJustify((Font::Justify)value);
+    if (enumname == "Font::Style")
+        return lua_stringFromEnum_FontStyle((Font::Style)value);
+    if (enumname == "Game::ClearFlags")
+        return lua_stringFromEnum_GameClearFlags((Game::ClearFlags)value);
+    if (enumname == "Game::State")
+        return lua_stringFromEnum_GameState((Game::State)value);
+    if (enumname == "Gamepad::ButtonMapping")
+        return lua_stringFromEnum_GamepadButtonMapping((Gamepad::ButtonMapping)value);
+    if (enumname == "Gamepad::GamepadEvent")
+        return lua_stringFromEnum_GamepadGamepadEvent((Gamepad::GamepadEvent)value);
+    if (enumname == "Gesture::GestureEvent")
+        return lua_stringFromEnum_GestureGestureEvent((Gesture::GestureEvent)value);
+    if (enumname == "Image::Format")
+        return lua_stringFromEnum_ImageFormat((Image::Format)value);
+    if (enumname == "Keyboard::Key")
+        return lua_stringFromEnum_KeyboardKey((Keyboard::Key)value);
+    if (enumname == "Keyboard::KeyEvent")
+        return lua_stringFromEnum_KeyboardKeyEvent((Keyboard::KeyEvent)value);
+    if (enumname == "Layout::Type")
+        return lua_stringFromEnum_LayoutType((Layout::Type)value);
+    if (enumname == "Light::Type")
+        return lua_stringFromEnum_LightType((Light::Type)value);
+    if (enumname == "Logger::Level")
+        return lua_stringFromEnum_LoggerLevel((Logger::Level)value);
+    if (enumname == "Mesh::IndexFormat")
+        return lua_stringFromEnum_MeshIndexFormat((Mesh::IndexFormat)value);
+    if (enumname == "Mesh::PrimitiveType")
+        return lua_stringFromEnum_MeshPrimitiveType((Mesh::PrimitiveType)value);
+    if (enumname == "Mouse::MouseEvent")
+        return lua_stringFromEnum_MouseMouseEvent((Mouse::MouseEvent)value);
+    if (enumname == "Node::Type")
+        return lua_stringFromEnum_NodeType((Node::Type)value);
+    if (enumname == "ParticleEmitter::TextureBlending")
+        return lua_stringFromEnum_ParticleEmitterTextureBlending((ParticleEmitter::TextureBlending)value);
+    if (enumname == "PhysicsCollisionObject::CollisionListener::EventType")
+        return lua_stringFromEnum_PhysicsCollisionObjectCollisionListenerEventType((PhysicsCollisionObject::CollisionListener::EventType)value);
+    if (enumname == "PhysicsCollisionObject::Type")
+        return lua_stringFromEnum_PhysicsCollisionObjectType((PhysicsCollisionObject::Type)value);
+    if (enumname == "PhysicsCollisionShape::Type")
+        return lua_stringFromEnum_PhysicsCollisionShapeType((PhysicsCollisionShape::Type)value);
+    if (enumname == "PhysicsController::Listener::EventType")
+        return lua_stringFromEnum_PhysicsControllerListenerEventType((PhysicsController::Listener::EventType)value);
+    if (enumname == "Properties::Type")
+        return lua_stringFromEnum_PropertiesType((Properties::Type)value);
+    if (enumname == "RenderState::AutoBinding")
+        return lua_stringFromEnum_RenderStateAutoBinding((RenderState::AutoBinding)value);
+    if (enumname == "RenderState::Blend")
+        return lua_stringFromEnum_RenderStateBlend((RenderState::Blend)value);
+    if (enumname == "RenderState::CullFaceSide")
+        return lua_stringFromEnum_RenderStateCullFaceSide((RenderState::CullFaceSide)value);
+    if (enumname == "RenderState::DepthFunction")
+        return lua_stringFromEnum_RenderStateDepthFunction((RenderState::DepthFunction)value);
+    if (enumname == "RenderState::FrontFace")
+        return lua_stringFromEnum_RenderStateFrontFace((RenderState::FrontFace)value);
+    if (enumname == "RenderState::StencilFunction")
+        return lua_stringFromEnum_RenderStateStencilFunction((RenderState::StencilFunction)value);
+    if (enumname == "RenderState::StencilOperation")
+        return lua_stringFromEnum_RenderStateStencilOperation((RenderState::StencilOperation)value);
+    if (enumname == "Terrain::Flags")
+        return lua_stringFromEnum_TerrainFlags((Terrain::Flags)value);
+    if (enumname == "TextBox::InputMode")
+        return lua_stringFromEnum_TextBoxInputMode((TextBox::InputMode)value);
+    if (enumname == "Texture::Filter")
+        return lua_stringFromEnum_TextureFilter((Texture::Filter)value);
+    if (enumname == "Texture::Format")
+        return lua_stringFromEnum_TextureFormat((Texture::Format)value);
+    if (enumname == "Texture::Wrap")
+        return lua_stringFromEnum_TextureWrap((Texture::Wrap)value);
+    if (enumname == "Touch::TouchEvent")
+        return lua_stringFromEnum_TouchTouchEvent((Touch::TouchEvent)value);
+    if (enumname == "VertexFormat::Usage")
+        return lua_stringFromEnum_VertexFormatUsage((VertexFormat::Usage)value);
+
+    GP_ERROR("Unrecognized enumeration type '%s'.", enumname.c_str());
+    return enumStringEmpty;
+}
+
+}

+ 864 - 1010
gameplay/src/lua/lua_Model.cpp

@@ -1,1010 +1,864 @@
-#include "Base.h"
-#include "ScriptController.h"
-#include "lua_Model.h"
-#include "Base.h"
-#include "Game.h"
-#include "MeshPart.h"
-#include "Model.h"
-#include "Node.h"
-#include "Pass.h"
-#include "Ref.h"
-#include "Scene.h"
-#include "Technique.h"
-
-namespace gameplay
-{
-
-void luaRegister_Model()
-{
-    const luaL_Reg lua_members[] = 
-    {
-        {"addRef", lua_Model_addRef},
-        {"draw", lua_Model_draw},
-        {"getMaterial", lua_Model_getMaterial},
-        {"getMesh", lua_Model_getMesh},
-        {"getMeshPartCount", lua_Model_getMeshPartCount},
-        {"getNode", lua_Model_getNode},
-        {"getRefCount", lua_Model_getRefCount},
-        {"getSkin", lua_Model_getSkin},
-        {"hasMaterial", lua_Model_hasMaterial},
-        {"isShadowCaster", lua_Model_isShadowCaster},
-        {"isShadowReceiver", lua_Model_isShadowReceiver},
-        {"release", lua_Model_release},
-        {"setMaterial", lua_Model_setMaterial},
-        {"setNode", lua_Model_setNode},
-        {"setShadowCaster", lua_Model_setShadowCaster},
-        {"setShadowReceiver", lua_Model_setShadowReceiver},
-        {NULL, NULL}
-    };
-    const luaL_Reg lua_statics[] = 
-    {
-        {"create", lua_Model_static_create},
-        {NULL, NULL}
-    };
-    std::vector<std::string> scopePath;
-
-    gameplay::ScriptUtil::registerClass("Model", lua_members, NULL, lua_Model__gc, lua_statics, scopePath);
-}
-
-static Model* getInstance(lua_State* state)
-{
-    void* userdata = luaL_checkudata(state, 1, "Model");
-    luaL_argcheck(state, userdata != NULL, 1, "'Model' expected.");
-    return (Model*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
-}
-
-int lua_Model__gc(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                void* userdata = luaL_checkudata(state, 1, "Model");
-                luaL_argcheck(state, userdata != NULL, 1, "'Model' expected.");
-                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
-                if (object->owns)
-                {
-                    Model* instance = (Model*)object->instance;
-                    SAFE_RELEASE(instance);
-                }
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Model__gc - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_addRef(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                instance->addRef();
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Model_addRef - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_draw(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                unsigned int result = instance->draw();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_draw - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TBOOLEAN)
-            {
-                // Get parameter 1 off the stack.
-                bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
-
-                Model* instance = getInstance(state);
-                unsigned int result = instance->draw(param1);
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_draw - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_getMaterial(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getMaterial();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Material");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_getMaterial - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                int param1 = (int)luaL_checkint(state, 2);
-
-                Model* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getMaterial(param1);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Material");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_getMaterial - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_getMesh(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getMesh();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Mesh");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_getMesh - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_getMeshPartCount(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                unsigned int result = instance->getMeshPartCount();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_getMeshPartCount - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_getNode(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getNode();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Node");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_getNode - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_getRefCount(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                unsigned int result = instance->getRefCount();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_getRefCount - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_getSkin(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getSkin();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "MeshSkin");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_getSkin - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_hasMaterial(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
-
-                Model* instance = getInstance(state);
-                bool result = instance->hasMaterial(param1);
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_hasMaterial - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_isShadowCaster(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                bool result = instance->isShadowCaster();
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_isShadowCaster - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_isShadowReceiver(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                bool result = instance->isShadowReceiver();
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_isShadowReceiver - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_release(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Model* instance = getInstance(state);
-                instance->release();
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Model_release - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_setMaterial(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<Material> param1 = gameplay::ScriptUtil::getObjectPointer<Material>(2, "Material", false, &param1Valid);
-                    if (!param1Valid)
-                        break;
-
-                    Model* instance = getInstance(state);
-                    instance->setMaterial(param1);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                    Model* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->setMaterial(param1);
-                    if (returnPtr)
-                    {
-                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                        object->instance = returnPtr;
-                        object->owns = false;
-                        luaL_getmetatable(state, "Material");
-                        lua_setmetatable(state, -2);
-                    }
-                    else
-                    {
-                        lua_pushnil(state);
-                    }
-
-                    return 1;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_Model_setMaterial - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 3:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
-                    lua_type(state, 3) == LUA_TNUMBER)
-                {
-                    // Get parameter 1 off the stack.
-                    bool param1Valid;
-                    gameplay::ScriptUtil::LuaArray<Material> param1 = gameplay::ScriptUtil::getObjectPointer<Material>(2, "Material", false, &param1Valid);
-                    if (!param1Valid)
-                        break;
-
-                    // Get parameter 2 off the stack.
-                    int param2 = (int)luaL_checkint(state, 3);
-
-                    Model* instance = getInstance(state);
-                    instance->setMaterial(param1, param2);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                    (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                    // Get parameter 2 off the stack.
-                    const char* param2 = gameplay::ScriptUtil::getString(3, false);
-
-                    Model* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->setMaterial(param1, param2);
-                    if (returnPtr)
-                    {
-                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                        object->instance = returnPtr;
-                        object->owns = false;
-                        luaL_getmetatable(state, "Material");
-                        lua_setmetatable(state, -2);
-                    }
-                    else
-                    {
-                        lua_pushnil(state);
-                    }
-
-                    return 1;
-                }
-            } while (0);
-
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                    lua_type(state, 3) == LUA_TNUMBER)
-                {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                    // Get parameter 2 off the stack.
-                    int param2 = (int)luaL_checkint(state, 3);
-
-                    Model* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->setMaterial(param1, param2);
-                    if (returnPtr)
-                    {
-                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                        object->instance = returnPtr;
-                        object->owns = false;
-                        luaL_getmetatable(state, "Material");
-                        lua_setmetatable(state, -2);
-                    }
-                    else
-                    {
-                        lua_pushnil(state);
-                    }
-
-                    return 1;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_Model_setMaterial - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 4:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                    (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
-                    (lua_type(state, 4) == LUA_TSTRING || lua_type(state, 4) == LUA_TNIL))
-                {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                    // Get parameter 2 off the stack.
-                    const char* param2 = gameplay::ScriptUtil::getString(3, false);
-
-                    // Get parameter 3 off the stack.
-                    const char* param3 = gameplay::ScriptUtil::getString(4, false);
-
-                    Model* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->setMaterial(param1, param2, param3);
-                    if (returnPtr)
-                    {
-                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                        object->instance = returnPtr;
-                        object->owns = false;
-                        luaL_getmetatable(state, "Material");
-                        lua_setmetatable(state, -2);
-                    }
-                    else
-                    {
-                        lua_pushnil(state);
-                    }
-
-                    return 1;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_Model_setMaterial - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 5:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                    (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
-                    (lua_type(state, 4) == LUA_TSTRING || lua_type(state, 4) == LUA_TNIL) &&
-                    lua_type(state, 5) == LUA_TNUMBER)
-                {
-                    // Get parameter 1 off the stack.
-                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                    // Get parameter 2 off the stack.
-                    const char* param2 = gameplay::ScriptUtil::getString(3, false);
-
-                    // Get parameter 3 off the stack.
-                    const char* param3 = gameplay::ScriptUtil::getString(4, false);
-
-                    // Get parameter 4 off the stack.
-                    int param4 = (int)luaL_checkint(state, 5);
-
-                    Model* instance = getInstance(state);
-                    void* returnPtr = (void*)instance->setMaterial(param1, param2, param3, param4);
-                    if (returnPtr)
-                    {
-                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                        object->instance = returnPtr;
-                        object->owns = false;
-                        luaL_getmetatable(state, "Material");
-                        lua_setmetatable(state, -2);
-                    }
-                    else
-                    {
-                        lua_pushnil(state);
-                    }
-
-                    return 1;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_Model_setMaterial - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2, 3, 4 or 5).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_setNode(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                bool param1Valid;
-                gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(2, "Node", false, &param1Valid);
-                if (!param1Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
-                    lua_error(state);
-                }
-
-                Model* instance = getInstance(state);
-                instance->setNode(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Model_setNode - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_setShadowCaster(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TBOOLEAN)
-            {
-                // Get parameter 1 off the stack.
-                bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
-
-                Model* instance = getInstance(state);
-                instance->setShadowCaster(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Model_setShadowCaster - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_setShadowReceiver(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 2:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TBOOLEAN)
-            {
-                // Get parameter 1 off the stack.
-                bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
-
-                Model* instance = getInstance(state);
-                instance->setShadowReceiver(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Model_setShadowReceiver - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Model_static_create(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                bool param1Valid;
-                gameplay::ScriptUtil::LuaArray<Mesh> param1 = gameplay::ScriptUtil::getObjectPointer<Mesh>(1, "Mesh", false, &param1Valid);
-                if (!param1Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Mesh'.");
-                    lua_error(state);
-                }
-
-                void* returnPtr = (void*)Model::create(param1);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = true;
-                    luaL_getmetatable(state, "Model");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Model_static_create - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-}
+#include "Base.h"
+#include "ScriptController.h"
+#include "lua_Model.h"
+#include "Base.h"
+#include "Game.h"
+#include "MeshPart.h"
+#include "Model.h"
+#include "Node.h"
+#include "Pass.h"
+#include "Ref.h"
+#include "Scene.h"
+#include "Technique.h"
+
+namespace gameplay
+{
+
+void luaRegister_Model()
+{
+    const luaL_Reg lua_members[] = 
+    {
+        {"addRef", lua_Model_addRef},
+        {"draw", lua_Model_draw},
+        {"getMaterial", lua_Model_getMaterial},
+        {"getMesh", lua_Model_getMesh},
+        {"getMeshPartCount", lua_Model_getMeshPartCount},
+        {"getNode", lua_Model_getNode},
+        {"getRefCount", lua_Model_getRefCount},
+        {"getSkin", lua_Model_getSkin},
+        {"hasMaterial", lua_Model_hasMaterial},
+        {"release", lua_Model_release},
+        {"setMaterial", lua_Model_setMaterial},
+        {"setNode", lua_Model_setNode},
+        {NULL, NULL}
+    };
+    const luaL_Reg lua_statics[] = 
+    {
+        {"create", lua_Model_static_create},
+        {NULL, NULL}
+    };
+    std::vector<std::string> scopePath;
+
+    gameplay::ScriptUtil::registerClass("Model", lua_members, NULL, lua_Model__gc, lua_statics, scopePath);
+}
+
+static Model* getInstance(lua_State* state)
+{
+    void* userdata = luaL_checkudata(state, 1, "Model");
+    luaL_argcheck(state, userdata != NULL, 1, "'Model' expected.");
+    return (Model*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
+}
+
+int lua_Model__gc(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                void* userdata = luaL_checkudata(state, 1, "Model");
+                luaL_argcheck(state, userdata != NULL, 1, "'Model' expected.");
+                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
+                if (object->owns)
+                {
+                    Model* instance = (Model*)object->instance;
+                    SAFE_RELEASE(instance);
+                }
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Model__gc - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_addRef(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Model* instance = getInstance(state);
+                instance->addRef();
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Model_addRef - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_draw(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Model* instance = getInstance(state);
+                unsigned int result = instance->draw();
+
+                // Push the return value onto the stack.
+                lua_pushunsigned(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_draw - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TBOOLEAN)
+            {
+                // Get parameter 1 off the stack.
+                bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
+
+                Model* instance = getInstance(state);
+                unsigned int result = instance->draw(param1);
+
+                // Push the return value onto the stack.
+                lua_pushunsigned(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_draw - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_getMaterial(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Model* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getMaterial();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Material");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_getMaterial - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                int param1 = (int)luaL_checkint(state, 2);
+
+                Model* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getMaterial(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Material");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_getMaterial - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_getMesh(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Model* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getMesh();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Mesh");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_getMesh - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_getMeshPartCount(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Model* instance = getInstance(state);
+                unsigned int result = instance->getMeshPartCount();
+
+                // Push the return value onto the stack.
+                lua_pushunsigned(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_getMeshPartCount - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_getNode(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Model* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getNode();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Node");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_getNode - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_getRefCount(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Model* instance = getInstance(state);
+                unsigned int result = instance->getRefCount();
+
+                // Push the return value onto the stack.
+                lua_pushunsigned(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_getRefCount - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_getSkin(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Model* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getSkin();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "MeshSkin");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_getSkin - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_hasMaterial(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
+
+                Model* instance = getInstance(state);
+                bool result = instance->hasMaterial(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_hasMaterial - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_release(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Model* instance = getInstance(state);
+                instance->release();
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Model_release - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_setMaterial(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<Material> param1 = gameplay::ScriptUtil::getObjectPointer<Material>(2, "Material", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    Model* instance = getInstance(state);
+                    instance->setMaterial(param1);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    Model* instance = getInstance(state);
+                    void* returnPtr = (void*)instance->setMaterial(param1);
+                    if (returnPtr)
+                    {
+                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                        object->instance = returnPtr;
+                        object->owns = false;
+                        luaL_getmetatable(state, "Material");
+                        lua_setmetatable(state, -2);
+                    }
+                    else
+                    {
+                        lua_pushnil(state);
+                    }
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_Model_setMaterial - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 3:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
+                    lua_type(state, 3) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<Material> param1 = gameplay::ScriptUtil::getObjectPointer<Material>(2, "Material", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    // Get parameter 2 off the stack.
+                    int param2 = (int)luaL_checkint(state, 3);
+
+                    Model* instance = getInstance(state);
+                    instance->setMaterial(param1, param2);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                    (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    // Get parameter 2 off the stack.
+                    const char* param2 = gameplay::ScriptUtil::getString(3, false);
+
+                    Model* instance = getInstance(state);
+                    void* returnPtr = (void*)instance->setMaterial(param1, param2);
+                    if (returnPtr)
+                    {
+                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                        object->instance = returnPtr;
+                        object->owns = false;
+                        luaL_getmetatable(state, "Material");
+                        lua_setmetatable(state, -2);
+                    }
+                    else
+                    {
+                        lua_pushnil(state);
+                    }
+
+                    return 1;
+                }
+            } while (0);
+
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                    lua_type(state, 3) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    // Get parameter 2 off the stack.
+                    int param2 = (int)luaL_checkint(state, 3);
+
+                    Model* instance = getInstance(state);
+                    void* returnPtr = (void*)instance->setMaterial(param1, param2);
+                    if (returnPtr)
+                    {
+                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                        object->instance = returnPtr;
+                        object->owns = false;
+                        luaL_getmetatable(state, "Material");
+                        lua_setmetatable(state, -2);
+                    }
+                    else
+                    {
+                        lua_pushnil(state);
+                    }
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_Model_setMaterial - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 4:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                    (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
+                    (lua_type(state, 4) == LUA_TSTRING || lua_type(state, 4) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    // Get parameter 2 off the stack.
+                    const char* param2 = gameplay::ScriptUtil::getString(3, false);
+
+                    // Get parameter 3 off the stack.
+                    const char* param3 = gameplay::ScriptUtil::getString(4, false);
+
+                    Model* instance = getInstance(state);
+                    void* returnPtr = (void*)instance->setMaterial(param1, param2, param3);
+                    if (returnPtr)
+                    {
+                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                        object->instance = returnPtr;
+                        object->owns = false;
+                        luaL_getmetatable(state, "Material");
+                        lua_setmetatable(state, -2);
+                    }
+                    else
+                    {
+                        lua_pushnil(state);
+                    }
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_Model_setMaterial - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 5:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                    (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
+                    (lua_type(state, 4) == LUA_TSTRING || lua_type(state, 4) == LUA_TNIL) &&
+                    lua_type(state, 5) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                    // Get parameter 2 off the stack.
+                    const char* param2 = gameplay::ScriptUtil::getString(3, false);
+
+                    // Get parameter 3 off the stack.
+                    const char* param3 = gameplay::ScriptUtil::getString(4, false);
+
+                    // Get parameter 4 off the stack.
+                    int param4 = (int)luaL_checkint(state, 5);
+
+                    Model* instance = getInstance(state);
+                    void* returnPtr = (void*)instance->setMaterial(param1, param2, param3, param4);
+                    if (returnPtr)
+                    {
+                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                        object->instance = returnPtr;
+                        object->owns = false;
+                        luaL_getmetatable(state, "Material");
+                        lua_setmetatable(state, -2);
+                    }
+                    else
+                    {
+                        lua_pushnil(state);
+                    }
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_Model_setMaterial - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2, 3, 4 or 5).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_setNode(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(2, "Node", false, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
+                    lua_error(state);
+                }
+
+                Model* instance = getInstance(state);
+                instance->setNode(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Model_setNode - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Model_static_create(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<Mesh> param1 = gameplay::ScriptUtil::getObjectPointer<Mesh>(1, "Mesh", false, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Mesh'.");
+                    lua_error(state);
+                }
+
+                void* returnPtr = (void*)Model::create(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "Model");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Model_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+}

+ 27 - 31
gameplay/src/lua/lua_Model.h

@@ -1,31 +1,27 @@
-#ifndef LUA_MODEL_H_
-#define LUA_MODEL_H_
-
-namespace gameplay
-{
-
-// Lua bindings for Model.
-int lua_Model__gc(lua_State* state);
-int lua_Model_addRef(lua_State* state);
-int lua_Model_draw(lua_State* state);
-int lua_Model_getMaterial(lua_State* state);
-int lua_Model_getMesh(lua_State* state);
-int lua_Model_getMeshPartCount(lua_State* state);
-int lua_Model_getNode(lua_State* state);
-int lua_Model_getRefCount(lua_State* state);
-int lua_Model_getSkin(lua_State* state);
-int lua_Model_hasMaterial(lua_State* state);
-int lua_Model_isShadowCaster(lua_State* state);
-int lua_Model_isShadowReceiver(lua_State* state);
-int lua_Model_release(lua_State* state);
-int lua_Model_setMaterial(lua_State* state);
-int lua_Model_setNode(lua_State* state);
-int lua_Model_setShadowCaster(lua_State* state);
-int lua_Model_setShadowReceiver(lua_State* state);
-int lua_Model_static_create(lua_State* state);
-
-void luaRegister_Model();
-
-}
-
-#endif
+#ifndef LUA_MODEL_H_
+#define LUA_MODEL_H_
+
+namespace gameplay
+{
+
+// Lua bindings for Model.
+int lua_Model__gc(lua_State* state);
+int lua_Model_addRef(lua_State* state);
+int lua_Model_draw(lua_State* state);
+int lua_Model_getMaterial(lua_State* state);
+int lua_Model_getMesh(lua_State* state);
+int lua_Model_getMeshPartCount(lua_State* state);
+int lua_Model_getNode(lua_State* state);
+int lua_Model_getRefCount(lua_State* state);
+int lua_Model_getSkin(lua_State* state);
+int lua_Model_hasMaterial(lua_State* state);
+int lua_Model_release(lua_State* state);
+int lua_Model_setMaterial(lua_State* state);
+int lua_Model_setNode(lua_State* state);
+int lua_Model_static_create(lua_State* state);
+
+void luaRegister_Model();
+
+}
+
+#endif

+ 180 - 180
tools/encoder/src/Light.cpp

@@ -1,180 +1,180 @@
-#include "Base.h"
-#include "Light.h"
-
-namespace gameplay
-{
-
-Light::Light(void) :
-    _lightType(0),
-    _constantAttenuation(0.0f),
-    _linearAttenuation(0.0f),
-    _quadraticAttenuation(0.0f),
-    _falloffExponent(0.0f),
-    _range(-1.0f),
-    _innerAngle(-1.0f),
-    _outerAngle(0.0f)
-{
-    fillArray(_color, 0.0f, COLOR_SIZE);
-}
-
-Light::~Light(void)
-{
-}
-
-unsigned int Light::getTypeId(void) const
-{
-    return LIGHT_ID;
-}
-const char* Light::getElementName(void) const
-{
-    return "Light";
-}
-
-float Light::computeRange(float constantAttenuation, float linearAttenuation, float quadraticAttenuation)
-{
-    if (constantAttenuation == 0.0f && linearAttenuation == 0.0f && quadraticAttenuation == 0.0f)
-    {
-        return 0.0f;
-    }
-
-    // Constant Attenuation is currently not supported.
-    if (constantAttenuation == 1.0f)
-    {
-        return 1.0f;
-    }
-
-    const float step = 0.01f;
-    float range = 0.01f;
-    float att = 1.0f;
-    while (att > 0.01f)
-    {
-        att = 1 / (constantAttenuation + (range * linearAttenuation) + (range * range * quadraticAttenuation));
-        range += step;
-    }
-    return range;
-}
-
-void Light::writeBinary(FILE* file)
-{
-    Object::writeBinary(file);
-    write(_lightType, file);
-    write(_color, COLOR_SIZE, file);
-
-    // Compute an approximate light range with Collada's attenuation parameters.
-    // This facilitates bringing in the light nodes directly from maya to gameplay.
-    if (_range == -1.0f)
-    {
-        _range = computeRange(_constantAttenuation, _linearAttenuation, _quadraticAttenuation);
-    }
-
-    if (_lightType == SpotLight)
-    {
-        write(_range, file);
-        write(_innerAngle, file);
-        write(_outerAngle, file);
-    }
-    else if (_lightType == PointLight)
-    {
-        write(_range, file);
-    }
-}
-
-void Light::writeText(FILE* file)
-{
-    fprintElementStart(file);
-    fprintfElement(file, "lightType", _lightType);
-    fprintfElement(file, "color", _color, COLOR_SIZE);
-
-    // Compute an approximate light range with Collada's attenuation parameters.
-    // This facilitates bringing in the light nodes directly from maya to gameplay.
-    if (_range == -1.0f)
-    {
-        _range = computeRange(_constantAttenuation, _linearAttenuation, _quadraticAttenuation);
-    }
-
-    if (_lightType == SpotLight)
-    {
-        fprintfElement(file, "range", _range);
-        fprintfElement(file, "innerAngle", MATH_DEG_TO_RAD(_innerAngle));
-        fprintfElement(file, "outerAngle", MATH_DEG_TO_RAD(_outerAngle));
-    }
-    else if (_lightType == PointLight)
-    {
-        fprintfElement(file, "range", _range);
-    }
-
-    fprintElementEnd(file);
-}
-
-float Light::getRed() const
-{
-    return _color[0];
-}
-float Light::getGreen() const
-{
-    return _color[1];
-}
-float Light::getBlue() const
-{
-    return _color[2];
-}
-
-bool Light::isAmbient() const
-{
-    return _lightType == AmbientLight;
-}
-
-void Light::setAmbientLight()
-{
-    _lightType = AmbientLight;
-}
-void Light::setDirectionalLight()
-{
-    _lightType = DirectionalLight;
-}
-void Light::setPointLight()
-{
-    _lightType = PointLight;
-}
-void Light::setSpotLight()
-{
-    _lightType = SpotLight;
-}
-
-void Light::setColor(float r, float g, float b)
-{
-    _color[0] = r;
-    _color[1] = g;
-    _color[2] = b;
-}
-
-void Light::setConstantAttenuation(float value)
-{
-    _constantAttenuation = value;
-}
-void Light::setLinearAttenuation(float value)
-{
-    _linearAttenuation = value;
-}
-void Light::setQuadraticAttenuation(float value)
-{
-    _quadraticAttenuation = value;
-}
-void Light::setInnerAngle(float value)
-{
-    _innerAngle = value;
-}
-void Light::setOuterAngle(float value)
-{
-    _outerAngle = value;
-}
-void Light::setFalloffExponent(float value)
-{
-    _falloffExponent = value;
-    if ( value != 1.0)
-    {
-        LOG(1, "Warning: spot light falloff_exponent must be 1.0. \n");
-    }
-}
-
-}
+#include "Base.h"
+#include "Light.h"
+
+namespace gameplay
+{
+
+Light::Light(void) :
+    _lightType(0),
+    _constantAttenuation(0.0f),
+    _linearAttenuation(0.0f),
+    _quadraticAttenuation(0.0f),
+    _falloffExponent(0.0f),
+    _range(-1.0f),
+    _innerAngle(-1.0f),
+    _outerAngle(0.0f)
+{
+    fillArray(_color, 0.0f, COLOR_SIZE);
+}
+
+Light::~Light(void)
+{
+}
+
+unsigned int Light::getTypeId(void) const
+{
+    return LIGHT_ID;
+}
+const char* Light::getElementName(void) const
+{
+    return "Light";
+}
+
+float Light::computeRange(float constantAttenuation, float linearAttenuation, float quadraticAttenuation)
+{
+    if (constantAttenuation == 0.0f && linearAttenuation == 0.0f && quadraticAttenuation == 0.0f)
+    {
+        return 0.0f;
+    }
+
+    // Constant Attenuation is currently not supported.
+    if (constantAttenuation == 1.0f)
+    {
+        return 1.0f;
+    }
+
+    const float step = 0.01f;
+    float range = 0.01f;
+    float att = 1.0f;
+    while (att > 0.01f)
+    {
+        att = 1 / (constantAttenuation + (range * linearAttenuation) + (range * range * quadraticAttenuation));
+        range += step;
+    }
+    return range;
+}
+
+void Light::writeBinary(FILE* file)
+{
+    Object::writeBinary(file);
+    write(_lightType, file);
+    write(_color, COLOR_SIZE, file);
+
+    // Compute an approximate light range with Collada's attenuation parameters.
+    // This facilitates bringing in the light nodes directly from maya to gameplay.
+    if (_range == -1.0f)
+    {
+        _range = computeRange(_constantAttenuation, _linearAttenuation, _quadraticAttenuation);
+    }
+
+    if (_lightType == SpotLight)
+    {
+        write(_range, file);
+        write(_innerAngle, file);
+        write(_outerAngle, file);
+    }
+    else if (_lightType == PointLight)
+    {
+        write(_range, file);
+    }
+}
+
+void Light::writeText(FILE* file)
+{
+    fprintElementStart(file);
+    fprintfElement(file, "lightType", _lightType);
+    fprintfElement(file, "color", _color, COLOR_SIZE);
+
+    // Compute an approximate light range with Collada's attenuation parameters.
+    // This facilitates bringing in the light nodes directly from maya to gameplay.
+    if (_range == -1.0f)
+    {
+        _range = computeRange(_constantAttenuation, _linearAttenuation, _quadraticAttenuation);
+    }
+
+    if (_lightType == SpotLight)
+    {
+        fprintfElement(file, "range", _range);
+        fprintfElement(file, "innerAngle", MATH_DEG_TO_RAD(_innerAngle));
+        fprintfElement(file, "outerAngle", MATH_DEG_TO_RAD(_outerAngle));
+    }
+    else if (_lightType == PointLight)
+    {
+        fprintfElement(file, "range", _range);
+    }
+
+    fprintElementEnd(file);
+}
+
+float Light::getRed() const
+{
+    return _color[0];
+}
+float Light::getGreen() const
+{
+    return _color[1];
+}
+float Light::getBlue() const
+{
+    return _color[2];
+}
+
+bool Light::isAmbient() const
+{
+    return _lightType == AmbientLight;
+}
+
+void Light::setAmbientLight()
+{
+    _lightType = AmbientLight;
+}
+void Light::setDirectionalLight()
+{
+    _lightType = DirectionalLight;
+}
+void Light::setPointLight()
+{
+    _lightType = PointLight;
+}
+void Light::setSpotLight()
+{
+    _lightType = SpotLight;
+}
+
+void Light::setColor(float r, float g, float b)
+{
+    _color[0] = r;
+    _color[1] = g;
+    _color[2] = b;
+}
+
+void Light::setConstantAttenuation(float value)
+{
+    _constantAttenuation = value;
+}
+void Light::setLinearAttenuation(float value)
+{
+    _linearAttenuation = value;
+}
+void Light::setQuadraticAttenuation(float value)
+{
+    _quadraticAttenuation = value;
+}
+void Light::setInnerAngle(float value)
+{
+    _innerAngle = value;
+}
+void Light::setOuterAngle(float value)
+{
+    _outerAngle = value;
+}
+void Light::setFalloffExponent(float value)
+{
+    _falloffExponent = value;
+    if ( value != 1.0)
+    {
+        LOG(1, "Warning: spot light falloff_exponent must be 1.0. \n");
+    }
+}
+
+}

+ 82 - 82
tools/encoder/src/Light.h

@@ -1,82 +1,82 @@
-#ifndef LIGHT_H_
-#define LIGHT_H_
-
-#include "Object.h"
-
-namespace gameplay
-{
-
-class Light : public Object
-{
-public:
-
-    static const int COLOR_SIZE = 3;
-
-    /**
-     * Constructor.
-     */
-    Light(void);
-
-    /**
-     * Destructor.
-     */
-    virtual ~Light(void);
-
-    virtual unsigned int getTypeId(void) const;
-    virtual const char* getElementName(void) const;
-    virtual void writeBinary(FILE* file);
-    virtual void writeText(FILE* file);
-
-    float getRed() const;
-    float getGreen() const;
-    float getBlue() const;
-
-    bool isAmbient() const;
-
-    /**
-     * Sets the light type to ambient.
-     */
-    void setAmbientLight();
-    void setDirectionalLight();
-    void setPointLight();
-    void setSpotLight();
-
-    void setColor(float r, float g, float b);
-    void setColor(float r, float g, float b, float a);
-
-    void setConstantAttenuation(float value);
-    void setLinearAttenuation(float value);
-    void setQuadraticAttenuation(float value);
-    void setInnerAngle(float value);
-    void setOuterAngle(float value);
-    void setFalloffExponent(float value);
-
-    enum LightType
-    {
-        DirectionalLight = 1,
-        PointLight = 2,
-        SpotLight = 3,
-        AmbientLight = 255
-    };
-
-private:
-
-    static float computeRange(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
-    static float computeInnerAngle(float outerAngle);
-    
-    unsigned char _lightType;
-    float _color[COLOR_SIZE];
-
-    float _constantAttenuation;
-    float _linearAttenuation;
-    float _quadraticAttenuation;
-    float _falloffExponent;
-
-    float _range;
-    float _innerAngle;
-    float _outerAngle;
-};
-
-}
-
-#endif
+#ifndef LIGHT_H_
+#define LIGHT_H_
+
+#include "Object.h"
+
+namespace gameplay
+{
+
+class Light : public Object
+{
+public:
+
+    static const int COLOR_SIZE = 3;
+
+    /**
+     * Constructor.
+     */
+    Light(void);
+
+    /**
+     * Destructor.
+     */
+    virtual ~Light(void);
+
+    virtual unsigned int getTypeId(void) const;
+    virtual const char* getElementName(void) const;
+    virtual void writeBinary(FILE* file);
+    virtual void writeText(FILE* file);
+
+    float getRed() const;
+    float getGreen() const;
+    float getBlue() const;
+
+    bool isAmbient() const;
+
+    /**
+     * Sets the light type to ambient.
+     */
+    void setAmbientLight();
+    void setDirectionalLight();
+    void setPointLight();
+    void setSpotLight();
+
+    void setColor(float r, float g, float b);
+    void setColor(float r, float g, float b, float a);
+
+    void setConstantAttenuation(float value);
+    void setLinearAttenuation(float value);
+    void setQuadraticAttenuation(float value);
+    void setInnerAngle(float value);
+    void setOuterAngle(float value);
+    void setFalloffExponent(float value);
+
+    enum LightType
+    {
+        DirectionalLight = 1,
+        PointLight = 2,
+        SpotLight = 3,
+        AmbientLight = 255
+    };
+
+private:
+
+    static float computeRange(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
+    static float computeInnerAngle(float outerAngle);
+    
+    unsigned char _lightType;
+    float _color[COLOR_SIZE];
+
+    float _constantAttenuation;
+    float _linearAttenuation;
+    float _quadraticAttenuation;
+    float _falloffExponent;
+
+    float _range;
+    float _innerAngle;
+    float _outerAngle;
+};
+
+}
+
+#endif