CurveBrush/CurveDisplayer.cpp
#include "CurveDisplayer.h"
#include "CurveCreator.h"
#include <QtGui/QApplication>
#include <QtCore/QVector>
#include <float.h>
MB_PLUGIN(
"CurveBrush",
"Draw",
"Autodesk",
"http://www.mudbox3d.com", CurveDisplayer::Initializer );
CurveDisplayer* CurveDisplayer::s_pThis = 0;
void CurveDisplayer::Initializer( void )
{
MB_ADD_CONFIG2( CurveCreator, 0,
NTR(
"Create Curve"), tr(
"Create Curve"),
NTR(
"Curve Tools"), tr(
"Curve Tools"), tr(
"createCurveToolTip"));
CurveDisplayer::s_pThis = CreateInstance<CurveDisplayer>();
};
CurveDisplayer::CurveDisplayer( void ) : m_eEndRender(this)
{
m_eEndRender.Connect(
Kernel()->ViewPort()->EndRenderEvent );
};
void CurveDisplayer::OnEvent( const EventGate &e )
{
if ( e == m_eEndRender )
{
glMatrixMode( GL_PROJECTION );
{
Matrix m =
Kernel()->Scene()->ActiveCamera()->Matrix();
Matrix m2 =
Kernel()->Scene()->ActiveCamera()->Transformation()->LocalToWorldMatrix();
Matrix m3 =
Kernel()->Scene()->ActiveCamera()->Transformation()->WorldToLocalMatrix();
m = m2 * m;
Matrix move;
move.SetIdentity();
move(3,2) = 0.4f;
m = m3 * move * m;
glLoadMatrixf( m );
};
glMatrixMode( GL_MODELVIEW );
Matrix m;
m.SetIdentity();
glLoadMatrixf( m );
for(
int i = 0; i < lines.
size(); ++i )
{
if(lines[i]->ItemCount() > 2 )
{
for( unsigned int j = 0; j < lines[i]->ItemCount(); ++j )
glVertex3fv( lines[i]->operator[](j) );
glEnd();
};
};
};
};