Example #1
0
void GLWidget::drawNeck(const float NECK_X_SCALE, const float NECK_Y_SCALE,
                         const float BEAK_UP_X_SCALE, const float BEAK_UP_Y_SCALE,
                         const float BEAK_DOWN_X_SCALE, const float BEAK_DOWN_Y_SCALE,
                         const float BODY_Y_SCALE)
{
    transformStack().pushMatrix();
    // position neck and joint together
    transformStack().translate(-2.5, BODY_Y_SCALE/2.5);

    transformStack().pushMatrix();
    transformStack().rotateInDegrees(neck_joint_angle);

    // Draw beak
    drawBeak(NECK_X_SCALE,BEAK_DOWN_X_SCALE,BEAK_DOWN_Y_SCALE,
                BEAK_UP_X_SCALE,BEAK_UP_Y_SCALE);

    transformStack().scale(NECK_X_SCALE,NECK_Y_SCALE); // 50,40
    transformStack().translate(0.0, 0.4);
    m_gl_state.setColor(0.0, 1.0, 1.0);
    m_unit_neck.draw();
    transformStack().popMatrix();

    transformStack().pushMatrix();
    drawJoint(1.0, NECK_Y_SCALE/5.0);
    transformStack().popMatrix();

    transformStack().popMatrix();
}
Example #2
0
void GLWidget::drawJoint(const float JOINT_X_TRANS, const float JOINT_Y_TRANS)
{
    transformStack().translate(JOINT_X_TRANS,JOINT_Y_TRANS);
    transformStack().scale(4.0,4.0);
    m_gl_state.setColor(0.0, 0.0, 1.0);
    m_unit_circle.draw();
}
Example #3
0
void GLWidget::drawLeftArm(const float ARM_X_SCALE, const float ARM_Y_SCALE)
{
    transformStack().pushMatrix();
    // position left arm and joint together
    transformStack().translate(0.0, 30.0);

    transformStack().pushMatrix();
    transformStack().rotateInDegrees(leftarm_joint_angle);
    transformStack().scale(ARM_X_SCALE,ARM_Y_SCALE);
    transformStack().translate(0.0, -0.4);
    m_gl_state.setColor(0.0, 1.0, 0.0);
    m_unit_arm.draw();
    transformStack().popMatrix();

    transformStack().pushMatrix();
    drawJoint(0.0, 4.0);
    transformStack().popMatrix();

    transformStack().popMatrix();
}
Example #4
0
void GLWidget::drawLeftLegFoot(const float LEG_X_SCALE, const float LEG_Y_SCALE,
                                const float LEG_X_INV_SCALE, const float LEG_Y_INV_SCALE,
                                const float FOOT_X_SCALE, const float FOOT_Y_SCALE)
{
    transformStack().translate(-30.0,-50.0);
    transformStack().rotateInDegrees(leftleg_joint_angle);
    transformStack().scale(LEG_X_SCALE,LEG_Y_SCALE);
    transformStack().translate(0.0, -0.5);
    m_gl_state.setColor(1.0, 0.0, 0.0);
    m_unit_square.draw();
    // since foot and joint as children of leg are already drawn,
    // to scale leg, need to inverse scale children of leg and scale everything back
    transformStack().scale(LEG_X_INV_SCALE,LEG_Y_INV_SCALE);

    transformStack().pushMatrix();
    drawJoint(0.0, LEG_Y_SCALE/2-4.0);
    transformStack().popMatrix();

    // Start drawing left foot and joint
    transformStack().pushMatrix();
    drawLeftFoot(LEG_X_SCALE,LEG_Y_SCALE,FOOT_X_SCALE,FOOT_Y_SCALE);
    transformStack().popMatrix();
}
Example #5
0
void GLWidget::drawLeftFoot(const float LEG_X_SCALE, const float LEG_Y_SCALE,
                                const float FOOT_X_SCALE, const float FOOT_Y_SCALE)
{
    // position left foot and joint together
    transformStack().translate(LEG_X_SCALE/2-FOOT_X_SCALE/6, -LEG_Y_SCALE/2+FOOT_X_SCALE/2);

    // left foot
    transformStack().pushMatrix();
    transformStack().rotateInDegrees(leftfoot_joint_angle);
    transformStack().scale(FOOT_X_SCALE,FOOT_Y_SCALE);
    transformStack().translate(0.0, -0.5); // Move down so that the centre of rotation is at top
    m_gl_state.setColor(0.0, 1.0, 0.0);
    m_unit_foot.draw();
    transformStack().popMatrix();

    // left foot joint
    transformStack().pushMatrix();
    drawJoint(-4.0, 0.0);
    transformStack().popMatrix();
}
Example #6
0
void GLWidget::drawBeak(const float NECK_X_SCALE,
                        const float BEAK_DOWN_X_SCALE, const float BEAK_DOWN_Y_SCALE,
                        const float BEAK_UP_X_SCALE, const float BEAK_UP_Y_SCALE)
{
    // Draw lower half beak
    transformStack().pushMatrix();
    transformStack().translate(-NECK_X_SCALE/2, beak_move_vertical_trans);
    transformStack().scale(BEAK_DOWN_X_SCALE,BEAK_DOWN_Y_SCALE);
    m_gl_state.setColor(0.0, 1.0, 0.0);
    m_unit_square.draw();
    transformStack().popMatrix();

    // Draw upper half beak
    transformStack().pushMatrix();
    transformStack().translate(-NECK_X_SCALE/2, 10.0+BEAK_DOWN_X_SCALE/2);
    transformStack().scale(BEAK_UP_X_SCALE,BEAK_UP_Y_SCALE);
    m_gl_state.setColor(0.0, 1.0, 0.0);
    m_unit_beakup.draw();
    transformStack().popMatrix();
}
Example #7
0
void GLWidget::paintGL()
{
    // This method gets called by the event handler to draw the scene, so
    // this is where you need to build your scene -- make your changes and
    // additions here.  All rendering happens in this function.

    checkForGLErrors();

    // Clear the screen with the background colour.
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Setup the model-view transformation matrix stack.
    transformStack().loadIdentity();
    checkForGLErrors();

    const float GLOBAL_X_SCALE = 0.8f;
    const float GLOBAL_Y_SCALE = 0.8f;
    const float BODY_X_SCALE = 120.0f;
    const float BODY_X_INV_SCALE = (float)(1/BODY_X_SCALE);
    const float BODY_Y_SCALE = 150.0f;
    const float BODY_Y_INV_SCALE = (float)(1/BODY_Y_SCALE);
    const float NECK_X_SCALE = 65.0f;
    const float NECK_Y_SCALE = 50.0f;
    const float BEAK_UP_X_SCALE = 28.0f;
    const float BEAK_UP_Y_SCALE = 5.0f;
    const float BEAK_DOWN_X_SCALE = 28.0f;
    const float BEAK_DOWN_Y_SCALE = 5.0f;
    const float ARM_X_SCALE = 20.0f;
    const float ARM_Y_SCALE = 70.0f;
    const float LEG_X_SCALE = 10.0f;
    const float LEG_X_INV_SCALE = (float)(1/LEG_X_SCALE);
    const float LEG_Y_SCALE = 60.0f;
    const float LEG_Y_INV_SCALE = (float)(1/LEG_Y_SCALE);
    const float FOOT_X_SCALE = 10.0f;
    const float FOOT_Y_SCALE = 40.0f;

    // Note that successive transformations are applied *before* the previous
    // ones.

    // Push the current transformation matrix on the stack
    transformStack().pushMatrix();
    transformStack().scale(GLOBAL_X_SCALE,GLOBAL_Y_SCALE);

    // Draw body
    transformStack().pushMatrix(); // Draw body push

    transformStack().translate(body_move_horizontal_trans,body_move_vertical_trans);
    transformStack().scale(BODY_X_SCALE,BODY_Y_SCALE);
    m_gl_state.setColor(1.0, 1.0, 0.0);
    m_unit_body.draw();
    transformStack().scale(BODY_X_INV_SCALE,BODY_Y_INV_SCALE);

    // Draw left leg and foot
    transformStack().pushMatrix();
    drawLeftLegFoot(LEG_X_SCALE,LEG_Y_SCALE,
                    LEG_X_INV_SCALE,LEG_Y_INV_SCALE,
                    FOOT_X_SCALE,FOOT_Y_SCALE);
    transformStack().popMatrix();

    // Draw right leg and foot
    transformStack().pushMatrix();
    drawRightLegFoot(LEG_X_SCALE,LEG_Y_SCALE,
                        LEG_X_INV_SCALE,LEG_Y_INV_SCALE,
                        FOOT_X_SCALE,FOOT_Y_SCALE);
    transformStack().popMatrix();

    // Draw left arm
    transformStack().pushMatrix();
    drawLeftArm(ARM_X_SCALE,ARM_Y_SCALE);
    transformStack().popMatrix();

    // Draw head, upper beak and lower beak
    transformStack().pushMatrix();
    drawNeck(NECK_X_SCALE,NECK_Y_SCALE,
             BEAK_UP_X_SCALE,BEAK_UP_Y_SCALE,
             BEAK_DOWN_X_SCALE,BEAK_DOWN_Y_SCALE,
             BODY_Y_SCALE);
    transformStack().popMatrix();

    transformStack().popMatrix(); // Draw body pop

    // Retrieve the previous state of the transformation stack
    transformStack().popMatrix();


    // Execute any GL functions that are in the queue just to be safe
    glFlush();
    checkForGLErrors();
}
void GLWidget::paintGL()
{
    // This method gets called by the event handler to draw the scene, so
    // this is where you need to build your scene -- make your changes and
    // additions here.  All rendering happens in this function.

    checkForGLErrors();

    // Clear the screen with the background colour.
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  

    // Setup the model-view transformation matrix stack.
    transformStack().loadIdentity();
    checkForGLErrors();

    //////////////////////////////////////////////////////////////////////////
    // TODO:
    //   Modify this function draw the scene.  This should include function
    //   calls to pieces that apply the appropriate transformation matrices
    //   and render the individual body parts.
    //////////////////////////////////////////////////////////////////////////

    // Draw our hinged object
    
    //const float BODY_WIDTH = 60.0f;
    //const float BODY_LENGTH = 100.0f;
    //const float ARM_LENGTH = 100.0f;
    //const float ARM_WIDTH = 20.0f;

	//============================ADDED============================
	const float BODY_WIDTH = 100.0f;
    const float BODY_LENGTH = 200.0f;
    const float ARM_LENGTH = 120.0f;
    const float ARM_WIDTH = 60.0f;
	const float HEAD_LENGTH = 60.0f;
    const float HEAD_WIDTH = 50.0f;
    const float LEG_WIDTH = 20.0f;
    const float LEG_LENGTH = 80.0f;
    const float BEAK_WIDTH = 5.0f;
    const float BEAK_LENGTH = 40.0f;
    
    // Note that successive transformations are applied *before* the previous
    // ones.

    // Push the current transformation matrix on the stack
    transformStack().pushMatrix();
    
    	//move penguin left to right
        transformStack().translate(m_x_move, 0.0);
        
        //move penguin up and down
		transformStack().translate(0.0, m_y_move);
        
        // Draw the 'body'
        transformStack().pushMatrix();
            // Scale square to size of body
            transformStack().scale(BODY_WIDTH, BODY_LENGTH);

            // Set the colour to white
            m_gl_state.setColor(1.0, 1.0,1.0);

            // Draw the body
	    	m_hexagon.draw();
        transformStack().popMatrix();

        //Head objects 
        transformStack().pushMatrix();
    		
        	transformStack().translate(0.0, BODY_LENGTH + HEAD_LENGTH/4);

        	// Rotate along the hinge
        	transformStack().rotateInDegrees(m_head_angle);
        	transformStack().translate(0.0, 2*HEAD_LENGTH/4);
        		
        	//draw the head shape
			transformStack().pushMatrix();
        		// Scale the size of the head
        		transformStack().scale(HEAD_WIDTH, HEAD_LENGTH);
        		
        		m_gl_state.setColor(0.0, 0.0, 0.3);
	    		m_pentagon.draw();
	
       		// Retrieve the previous state of the transformation stack
        	transformStack().popMatrix();
                
        	//Lower beak (moves up and down)
        	transformStack().pushMatrix();
				transformStack().translate(-HEAD_LENGTH, -HEAD_LENGTH/2);
                        
                //move beak up and down
                transformStack().translate(0.0, m_beak);
                        
                //draw "beak"
				transformStack().pushMatrix();
                    // Scale the size of the beak
        			transformStack().scale(BEAK_LENGTH, BEAK_WIDTH);
        			
        			// Draw the square for the beak
        			m_gl_state.setColor(1.0, 1.0, 1.0);
	    			m_unit_square.draw();
	    			
				transformStack().popMatrix();
			
			transformStack().popMatrix();
			
			//Upper beak (doeasn't move)
			transformStack().pushMatrix();
				transformStack().translate(-HEAD_LENGTH, -HEAD_LENGTH/2 + 2*BEAK_WIDTH);
        		//transformStack().translate(-HEAD_LENGTH, -HEAD_LENGTH/2 + 2*BEAK_WIDTH);
        		// Scale the size of the beak
        		transformStack().scale(BEAK_LENGTH, 2*BEAK_WIDTH);
        			
        		// Draw the square for the beak
        		m_gl_state.setColor(1.0, 1.0, 1.0);
	    		m_unit_square.draw();
			
			transformStack().popMatrix();
			
			//Eye
			transformStack().pushMatrix();
			
            	transformStack().translate(-HEAD_WIDTH/2, 0.0);
				transformStack().pushMatrix();
					transformStack().scale(6.0f, 6.0f);
        			m_gl_state.setColor(1.0, 1.0, 1.0);	
        			m_unit_circle.draw();
        		transformStack().popMatrix();
        		
        		transformStack().scale(3.0f, 3.0f);
        		m_gl_state.setColor(0.0, 0.0, 0.0);	
        		m_unit_circle.draw();
        		
			transformStack().popMatrix();
			
       	// Retrieve the previous state of the transformation stack
        transformStack().popMatrix();
    	
    	//draw the joint of a head and body
    	transformStack().pushMatrix();
   
   			transformStack().translate(0.0, BODY_LENGTH);
			transformStack().scale(5.0f, 5.0f);
        	m_gl_state.setColor(0.0, 1.0, 1.0);	
        	m_unit_circle.draw();
   
    	transformStack().popMatrix();
    	
    	
    	
    	//Draw the right leg
    	transformStack().pushMatrix();
    		// Move the leg to the joint hinge
        	transformStack().translate(BODY_WIDTH/2, -BODY_LENGTH/2 + LEG_WIDTH/2);
        	
        	// Rotate along the hinge
        	transformStack().rotateInDegrees(m_leg_angle);
        	
        	// Move to center location of the leg
			transformStack().translate(0.0, -LEG_LENGTH/2 + LEG_WIDTH/2);
			
			transformStack().pushMatrix();
				transformStack().pushMatrix();
			
					transformStack().scale(LEG_WIDTH, LEG_LENGTH);
                	//transformStack().translate(0.0, -0.5);
                	         
        			// Draw the square for the leg
        			m_gl_state.setColor(0.0, 0.0, 0.3);
	    			m_unit_square.draw();
        	
                // Retrieve the previous state of the transformation stack
            	transformStack().popMatrix();
            	
            	transformStack().translate(0.0, -LEG_LENGTH/2 + LEG_WIDTH/2);
			
        		// Rotate along the hinge
        		transformStack().rotateInDegrees(m_foot_angle);
        		
				transformStack().translate(-LEG_LENGTH/2 + LEG_WIDTH/2, 0.0);
                
                transformStack().scale(LEG_LENGTH, LEG_WIDTH);
        			 
        		// Draw the square for the foot
        		m_gl_state.setColor(0.0, 0.0, 0.3);
	    		m_unit_square.draw();
            
             // Retrieve the previous state of the transformation stack	
        	transformStack().popMatrix();	
        	
        	//draw the ankle joint 
        	transformStack().translate(0.0, -LEG_LENGTH/2 + 10.0f);
			transformStack().scale(5.0f, 5.0f);
        	m_gl_state.setColor(0.0, 1.0, 1.0);	
        	m_unit_circle.draw();
            	
        // Retrieve the previous state of the transformation stack    	 
		transformStack().popMatrix();
         
        //draw the joint of a body and a right leg          
   		transformStack().pushMatrix();
   
   			transformStack().translate(BODY_WIDTH/2, -BODY_LENGTH/2 - LEG_LENGTH/4);
   			transformStack().translate(0.0, LEG_LENGTH/2 - LEG_WIDTH/2);
			transformStack().scale(5.0f, 5.0f);
        	m_gl_state.setColor(0.0, 1.0, 1.0);	
        	m_unit_circle.draw();
   
    	transformStack().popMatrix();
   
    	
    	
    	//Draw left leg
    	transformStack().pushMatrix();
    		// Move the leg to the joint hinge
        	transformStack().translate(-BODY_WIDTH/2, -BODY_LENGTH/2 + LEG_WIDTH/2);
        	
        	// Rotate along the hinge
        	transformStack().rotateInDegrees(m_leg_angle);
			
			// Move to center location of the leg
			transformStack().translate(0.0, -LEG_LENGTH/2 + LEG_WIDTH/2);
			
			transformStack().pushMatrix();
				transformStack().pushMatrix();
			
					transformStack().scale(LEG_WIDTH, LEG_LENGTH);
                	//transformStack().translate(0.0, -0.5);
                	         
        			// Draw the square for the leg
        			m_gl_state.setColor(0.0, 0.0, 0.3);
	    			m_unit_square.draw();
        	
                // Retrieve the previous state of the transformation stack
            	transformStack().popMatrix();
            	
            	transformStack().translate(0.0, -LEG_LENGTH/2 + LEG_WIDTH/2);
			
        		// Rotate along the hinge
        		transformStack().rotateInDegrees(m_foot_angle);
        		
				transformStack().translate(-LEG_LENGTH/2 + LEG_WIDTH/2, 0.0);
                
                transformStack().scale(LEG_LENGTH, LEG_WIDTH);
        			 
        		// Draw the square for the foot
        		m_gl_state.setColor(0.0, 0.0, 0.3);
	    		m_unit_square.draw();
            
             // Retrieve the previous state of the transformation stack	
        	transformStack().popMatrix();	
        	
        	//draw the ankle joint 
        	transformStack().translate(0.0, -LEG_LENGTH/2 + 10.0f);
			transformStack().scale(5.0f, 5.0f);
        	m_gl_state.setColor(0.0, 1.0, 1.0);	
        	m_unit_circle.draw();
            	
        // Retrieve the previous state of the transformation stack    	 
		transformStack().popMatrix();
        
        //draw the joint ob a body and a left leg         
   		transformStack().pushMatrix();
   
   			transformStack().translate(-BODY_WIDTH/2, -BODY_LENGTH/2 - LEG_LENGTH/4);
   			transformStack().translate(0.0, LEG_LENGTH/2 - LEG_WIDTH/2);
			transformStack().scale(5.0f, 5.0f);
        	m_gl_state.setColor(0.0, 1.0, 1.0);	
        	m_unit_circle.draw();
   
    	transformStack().popMatrix();
    	
    	
    	
        // Draw the 'arm'
      	transformStack().pushMatrix();
        	// Move the arm to the joint hinge
        	transformStack().translate(0.0, BODY_LENGTH/2  - 10.0f);

       		 // Rotate along the hinge
        	transformStack().rotateInDegrees(m_joint_angle);
			
			// Move to center location of arm, under previous rotation
			transformStack().translate(0.0, -ARM_LENGTH/2 + 10.0f);
			
			transformStack().pushMatrix();
        		// Scale the size of the arm
        		transformStack().scale(ARM_WIDTH, ARM_LENGTH);

        		// Move to center location of arm, under previous rotation
        		//transformStack().translate(0.0, -0.5);

        		// Draw the square for the arm
        		m_gl_state.setColor(0.0, 0.0, 0.3);
        		m_tetragon.draw();

		 	transformStack().popMatrix();
		transformStack().popMatrix(); 
		
		//draw the arm joint
		transformStack().translate(0.0, BODY_LENGTH/2 - 10.0f);
		transformStack().scale(5.0f, 5.0f);
        m_gl_state.setColor(0.0, 1.0, 1.0);	
        m_unit_circle.draw();
        //transformStack().popMatrix();

    // Retrieve the previous state of the transformation stack
    transformStack().popMatrix();
	 
	//============================ADDED============================ 
	 
    // Execute any GL functions that are in the queue just to be safe
    glFlush();
    checkForGLErrors();
}
Example #9
0
int 
main(int argc, char *argv[]) 
{
    try
    {
	    TCLAP::CmdLine cmd("Process Stack of Particle Images", ' ',"100125");
        TCLAP::ValueArg<unsigned int> oMaxSlices("s", "slices", "Limit the number of slices processed", 
                                                 false, std::numeric_limits<unsigned int>::max(), "int");
        cmd.add(oMaxSlices);
        TCLAP::ValueArg<unsigned int> oMaxDelta("m", "delta", "Maximum timestep for difference images", 
                                                 false, std::numeric_limits<unsigned int>::max(), "int");
        cmd.add(oMaxDelta);
        TCLAP::ValueArg<unsigned int> oDeltaInc("i", "increment", "Timestep increment", 
                                                 false, 1, "int");
        cmd.add(oDeltaInc);
        
        TCLAP::UnlabeledValueArg<std::string>  oFileStem("filestem", "Multi-page TIFF Image is filestem.tif", true, "", "filestem");
        cmd.add(oFileStem);
        cmd.parse(argc, argv);

	    npp::StopWatch oStopWatch;
	    oStopWatch.start();
	    
	    // This block is here so the destructors of the 
	    // FreeImageStack objects get called which triggers the saving
	    // of the output data.
	    {
            FreeImageStack oStack(oFileStem.getValue());
            unsigned int nSlices   = std::min<unsigned int>(oMaxSlices.getValue(), oStack.slices());
            unsigned int nMaxDelta = std::min<unsigned int>(oMaxDelta.getValue(), nSlices);
            
                    // Allocate a "fourier-image stack" to receive the fourier transformed images
            NppiSize oResultSizeROI = {oStack.width()/2 + 1, oStack.height()/2 + 1};
            
            FourierImageStack oFourierImages(nSlices, oResultSizeROI.width, oResultSizeROI.height);

            transformStack(oStack, oFourierImages);
            
            FreeImageStack oResultStack(oFileStem.getValue() + "_ConDDM", oResultSizeROI.width, oResultSizeROI.height);
            npp::ImageNPP_32f_C1 oDifferenceImage(oResultSizeROI.width, oResultSizeROI.height);
            for (unsigned int iDelta = 1; iDelta < nMaxDelta; iDelta += oDeltaInc.getValue())
            {
                computeDifferenceImage(oFourierImages, iDelta, oDifferenceImage);
                oResultStack.appendImage(oDifferenceImage);
            }
        } // ending block before we stop the stop watch to complete data writing
        
        oStopWatch.stop();
        std::cout << "Elapsed time: " << oStopWatch.elapsed() / 1000 << " s" << std::endl;
    }
    catch (npp::Exception & rException)
    {
        std::cerr << "Program error! The following exception occurred: \n";
        std::cerr << rException;
        std::cerr << "\nAborting." << std::endl;
        
        return -1;
    }
    catch (...)
    {
        std::cerr << "Program error! An unknow type of exception occurred. \n";
        std::cerr << "Aborting." << std::endl;
        
        return -1;
    }
    
    return 0;
}