Exemplo n.º 1
0
/*
 * Constructor to setup the scene
 */
GLWidget::GLWidget( QWidget *parent ) :
                QGLWidget( QGLFormat( QGL::SampleBuffers ), parent )
{
        // We'll start WITHOUT a logo first because it's put in by 
        // GLWidget::initializeGL() anyway.
        logo = 0;

        ///////////////////////////////////////
        // Attempt to load whatever asset
        ///////////////////////////////////////
        asset = new Asset3ds("models/elecloco/Locomotive chs4 072.3DS");


        std::cerr << "Loaded a new asset" << std::endl ;

        // Look dead-on at the scene to start (no initial rotations)
        setXRotation( 0 );
        setYRotation( 0 );
        setZRotation( 0 );

        // Position Offset Initializer
        xPos = yPos = 0;

        // Push model BACK a bit to start. This is important because
        // some are ungodly huge and need to be visible at least in some
        // fashion right away, less the user thinks something failed.
        zPos = -20.0;

        // Initialize motion state bools
        moveUp_ = moveDn_ = moveRight_ = moveLeft_ = false;

        // These colors must be generated via CMYK values otherwise
        // it seems lighting will simply NOT WORK.
        qtGreen = QColor::fromCmykF( 0.2, 0.1, 0.9, 0.3 );
        qtPurple = QColor::fromCmykF( 0.4, 0.4, 0.0, 0.1 );
        qtGray = QColor::fromCmykF( 0.0, 0.0, 0.0, 0.75 );
        qtRed = QColor::fromCmykF( 0.1, 0.7, 0.9, 0.2 );
        qtDark = QColor::fromCmykF( 0.0, 0.0, 0.0, 0.85 );

        // Initially going to say the ambient light is on
        // (as is the movable light)
        ambientLight = true;
        flashlightOn = true;
        oppositeOn   = true;

        // The starting values for the variable color light
        auxRed(10);
        auxGreen(10);
        auxBlue(10);
        
        // Make the default on instantiation be perspective projection
        p_Perspective();

        // Default size of orthographic projection mode
        // (These are changed with the mouse wheel when in PROJECTION).
        ortho_left = ortho_top = -3.0;
        ortho_bottom = ortho_right = 3.0;

        // Begin the updating of the GLwidget using the QTimerEvent here
        startTimer( 20 );
}
Exemplo n.º 2
0
/*
 * Constructor to setup the scene
 */
GLWidget::GLWidget( QWidget *parent ) :
                QGLWidget( QGLFormat( QGL::SampleBuffers ), parent )
{
        // We'll start WITHOUT a logo first because it's put in by 
        // GLWidget::initializeGL() anyway.
        logo = 0;

        ///////////////////////////////////////
        // Attempt to load whatever asset
        ///////////////////////////////////////
        QStringList args = QCoreApplication::arguments();

        // Pure AWESOME cascading member function calls! WHeeeeeeeeee
        char *assetName = args.at(1).toLocal8Bit().data();

        asset = new Asset3ds(assetName);

        // Look dead-on at the scene to start (no initial rotations)
        // WARNING: This is overruled by the slider settings in window.cpp!!
        setXRotation( 0 );
        setYRotation( 0 );
        setZRotation( 0 );

        // Position Offset Initializer
        xPos = yPos = 0;

        // Push model BACK a bit to start. This is important because
        // some are ungodly huge and need to be visible at least in some
        // fashion right away, less the user thinks something failed.
        zPos = -20.0;

        // Initialize scaling factor to 1, no scale change
        scaleFactor = 1.0;

        // Initialize motion state bools
        moveUp_ = moveDn_ = moveRight_ = moveLeft_ = false;

        // These colors must be generated via CMYK values otherwise
        // it seems lighting will simply NOT WORK.
        qtGreen = QColor::fromCmykF( 0.2, 0.1, 0.9, 0.3 );
        qtPurple = QColor::fromCmykF( 0.4, 0.4, 0.0, 0.1 );
        qtGray = QColor::fromCmykF( 0.0, 0.0, 0.0, 0.75 );
        qtRed = QColor::fromCmykF( 0.1, 0.7, 0.9, 0.2 );
        qtDark = QColor::fromCmykF( 0.0, 0.0, 0.0, 0.85 );

        // Initially going to say the ambient light is on
        // (as is the movable light)
        ambientLight = true;
        flashlightOn = true;
        oppositeOn   = true;

        // The starting values for the variable color light
        auxRed(10);
        auxGreen(10);
        auxBlue(10);
        
        // Make the default on instantiation be perspective projection
        p_Perspective();

        // Default size of orthographic projection mode
        // (These are changed with the mouse wheel when in PROJECTION).
        ortho_left = ortho_top = -3.0;
        ortho_bottom = ortho_right = 3.0;

        // Begin the updating of the GLwidget using the QTimerEvent here
        startTimer( 20 );
}