- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

# TextureSwapperViewportFilter/TextureSwapperViewportFilter.cpp

    //**************************************************************************/
    // Copyright (c) 2008 Autodesk, Inc.
    // All rights reserved.
    //
    // Use of this software is subject to the terms of the Autodesk license
    // agreement provided at the time of installation or download, or which
    // otherwise accompanies this software in either electronic or hard copy form.
    //
    //**************************************************************************/
    // DESCRIPTION:
    // CREATED: October 2008
    //**************************************************************************/

    #include "TextureSwapperViewportFilter.h"

    #define _USE_MATH_DEFINES
    #include <cmath>

    using namespace mudbox;

    // Filter plugin macros
    IMPLEMENT_VCLASS( TextureSwapperViewPortFilter, ViewPortFilter, "Texture Swapper Viewport Filter", 1 );

    MB_PLUGIN( "Texture Swapper Filter", "Texture Swapper Viewport Filter", "Autodesk", "http://www.mudbox3d.com", 0 );

    void TextureSwapperViewPortFilter::OnNodeEvent( const Attribute&, NodeEventType eType ) {
        if(eType == etValueChanged) {
            Kernel()->Redraw();
        }
    }

    TextureSwapperViewPortFilter::TextureSwapperViewPortFilter() :
        m_aTextureID(this, "Texture")
    {
        m_aTextureID.AddItem("Color");
        m_aTextureID.AddItem("Depth");
        m_aTextureID.AddItem("Position");
        m_aTextureID.AddItem("Normal");
        m_aTextureID.SetValue(0);

        m_pResultTexture = 0;
    }

    TextureSwapperViewPortFilter::~TextureSwapperViewPortFilter()
    {
        if (m_pResultTexture)
        {
            delete m_pResultTexture;
        }
    }

    void TextureSwapperViewPortFilter::Process( ViewPortState &s )
    {
        switch (m_aTextureID.Value())
        {
        default:
        case 0:
            break;

        case 1:
            s.m_pColor = s.m_pDepth;
            break;

        case 2:
            s.m_pColor = s.m_pPosition;
            break;

        case 3:
            s.m_pColor = s.m_pNormal;
            break;
        }
    /*
        switch (s.m_pColor->Format())
        {
        case Image::e16depth:
        case Image::e24depth:
        case Image::e32depth:
            ConvertTexture(&m_pResultTexture, s.m_pColor);
            s.m_pColor = m_pResultTexture;
            break;

        default:
            break;
        }*/
    };