ToonMaterial/ToonMaterial.h

//**************************************************************************/
// 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
//**************************************************************************/

#if defined(JAMBUILD)
#include <Mudbox/mudbox.h>
#include <Mudbox/MudBoxGL.h>
#else
#include "../../include/Mudbox/mudbox.h"
#include "../../include/Mudbox/MudBoxGL.h"
#endif

#include <Cg/cg.h>
#include <Cg/cgGL.h>
using namespace mudbox;

class ToonMaterial : public Material
{
    // RTTI macro.
    DECLARE_CLASS;

public:
    ToonMaterial( void );

    ~ToonMaterial( void );

    // The following public functions are overrides

    bool Activate( const Mesh *pMesh, const AxisAlignedBoundingBox &cUVArea, const Color &cColor );

    void Deactivate( void );

    void OnNodeEvent( const Attribute &cAttribute, NodeEventType cType );

    bool IsTCNeeded( void ) const { return true; };

private:

    // Cg vertex & pixel shaders
    CGprogram m_VertexProgram;
    CGprogram m_FragmentProgram;

    // Cg context
    CGcontext m_CGContext;

    // Profiles used for this shader
    CGprofile m_FragmentProfile;
    CGprofile m_VertexProfile;

    // Cg shader parameters, used to set values on shader
    CGparameter m_LightPositionParam;
    CGparameter m_EyePositionParam;
    CGparameter m_ShininessParam;
    CGparameter m_ModelViewProjParam;

    CGparameter m_KdParam;
    CGparameter m_KsParam;
    CGparameter m_DiffuseRampParam;
    CGparameter m_SpecularRampParam;
    CGparameter m_EdgeRampParam;

    // OpenGL texture IDs
    GLuint m_iDiffuseRamp;
    GLuint m_iSpecularRamp;
    GLuint m_iEdgeRamp;

    // Any variables with 'a' in front of them indicate a Qt attribute.
    // They will automatically be added to the UI for this material.
    // Diffuse
    acolor m_aKd; // color picker
    // Specular
    acolor m_aKs; // color picker
    // Shininess
    afloatr m_aShininess; // range slider
};