⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 毕业设计view.cpp

📁 毕业设计作品
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	glRotated( m_yRotation, 1.0, 0.0, 0.0 );
    glRotated(rotate_left_right, 0.0, 0.0, 1.0 );/*左右旋转*/
	glRotated( rotate_up_down, 1.0, 0.0, 0.0 );/*上下旋转*/
    glTranslated(0.0, 0.0, -1.3*scaleMol);/*向下平移模型*/
   
	
	glPushMatrix();/*绘制开始*/
	
	glTranslated( 0.0, 0.0, 2.514*scaleMol );
    glRotated( (GLfloat)nod, 1.0, 0.0, 0.0 );/*点头*/
	glRotated( (GLfloat)throwHead, 0.0, 1.0, 0.0 );/*摇头*/
	glTranslated( 0.0, 0.0, -2.514*scaleMol );
	
	if( mode == GL_SELECT )
	{
		glLoadName( 1 );
	}
	glmDraw( head, GLM_SMOOTH | GLM_COLOR );/*绘制头模型*/	
    
	glPopMatrix();/*头绘制结束*/
	
	if( mode == GL_SELECT )
	{
		glLoadName( 2 );
	}

	glmDraw( body, GLM_SMOOTH | GLM_COLOR );/*绘制身体*/
    
	
	glPushMatrix();/*左腿开始绘制*/
	glTranslated( 0.12*scaleMol, 0.0, 1.51*scaleMol );
    glRotated( (GLfloat)leftDatui, 1.0, 0.0, 0.0 );/*左大腿旋转*/
	glTranslated( -0.12*scaleMol, 0.0, -1.51*scaleMol );
	
	if( mode == GL_SELECT )
	{
		glLoadName( 3 );
	}
   	glmDraw(leftdatui, GLM_SMOOTH | GLM_COLOR );
	glPushMatrix();/*左小腿开始绘制*/
	glTranslated( 0.164*scaleMol, -0.07*scaleMol, 0.81*scaleMol );
    glRotated( -(GLfloat)leftDatui, 1.0, 0.0, 0.0 );/*左小腿旋转*/
	glTranslated( -0.164*scaleMol, 0.07*scaleMol, -0.81 *scaleMol);

	if( mode == GL_SELECT )
	{
		glLoadName( 4 );
	}
    glmDraw(leftxiaotui, GLM_SMOOTH | GLM_COLOR );
    glPushMatrix();/*左脚开始绘制*/

	if( mode == GL_SELECT )
	{
		glLoadName( 5 );
	}
    glmDraw(leftfoot, GLM_SMOOTH | GLM_COLOR ); 
    glPopMatrix();/*左脚绘制结束*/

	glPopMatrix();/*左小腿绘制结束*/

	glPopMatrix();/*左大腿绘制结束*/

	glPushMatrix();/*右腿开始绘制*/
	glTranslated( 0.12*scaleMol, 0.0, 1.51*scaleMol );
    glRotated( (GLfloat)rightDatui, 1.0, 0.0, 0.0 );/*右腿旋转*/
	glTranslated( -0.12*scaleMol, 0.0, -1.51 *scaleMol);

	if( mode == GL_SELECT )
	{
		glLoadName( 6 );
	}
    glmDraw(rightdatui, GLM_SMOOTH | GLM_COLOR );
	glPushMatrix();/*右小腿工始绘制*/
	glTranslated( 0.164*scaleMol, -0.07*scaleMol, 0.81 *scaleMol);
    glRotated( -(GLfloat)rightDatui, 1.0, 0.0, 0.0 );/*右小腿旋转*/
	glTranslated( -0.164*scaleMol, 0.07*scaleMol, -0.81*scaleMol );

	if( mode == GL_SELECT )
	{
		glLoadName( 7 );
	}
    glmDraw(rightxiaotui, GLM_SMOOTH | GLM_COLOR );
    glPushMatrix();/*右脚开始绘制*/

	if( mode == GL_SELECT )
	{
		glLoadName( 8 );
	}
    glmDraw(rightfoot, GLM_SMOOTH | GLM_COLOR ); 
    glPopMatrix();/*右脚绘制结束*/
    glPopMatrix();/*右小腿绘制结束*/
	glPopMatrix();/*右大腿绘制结束*/


	glPushMatrix();/*左臂开始绘制*/

	glTranslated(0.0, 0.05*scaleMol, 2.23*scaleMol);
	glRotated( (GLfloat)leftHand, 1.0, 0.0, 0.0 );/*左臂旋转*/
	glTranslated(0.0, -0.05*scaleMol, -2.23*scaleMol); 
	
	if( mode == GL_SELECT )
	{
		glLoadName( 9 );
	}
	glPushMatrix();/*将左臂向内旋转30度*/
	glTranslated( 0.25*scaleMol, 0.0, 2.24*scaleMol );
	glRotated( 30, 0.0, 1.0, 0.0 );
	glTranslated( -0.25*scaleMol, 0.0, -2.24*scaleMol );
	glmDraw(leftbi, GLM_SMOOTH | GLM_COLOR );
	
    glPushMatrix();/*左肘开始绘制*/
    glTranslated(0.75*scaleMol, 0.05*scaleMol, 1.95*scaleMol);
    glRotated( (GLfloat)leftHand*0.6, 1.0, 0.0, 0.0);/*左肘旋转*/
	glTranslated(-0.75*scaleMol, -0.05*scaleMol, -1.95*scaleMol);

	if( mode == GL_SELECT )
	{
		glLoadName( 10 );
	}
	glmDraw(leftzhou, GLM_SMOOTH | GLM_COLOR );
    glPushMatrix();/*左手开始绘制*/

	if( mode == GL_SELECT )
	{
		glLoadName( 11 );
	}
    glmDraw(lefthand, GLM_SMOOTH | GLM_COLOR ); 
    glPopMatrix();/*左手绘制结束*/
    glPopMatrix();/*左肘绘制结束*/
    glPopMatrix();/*左臂绘制结束*/
	glPopMatrix();



	glPushMatrix();/*右臂开始绘制*/
	glTranslated(0.0, 0.05*scaleMol, 2.23*scaleMol);
	glRotated( (GLfloat)rightHand, 1.0, 0.0, 0.0 );/*右臂旋转*/
	glTranslated(0.0, -0.05*scaleMol, -2.23*scaleMol);

	if( mode == GL_SELECT )
	{
		glLoadName( 12 );
	}
	glPushMatrix();/*将右臂向内旋转30度*/
	glTranslated( -0.25*scaleMol, 0.0, 2.24*scaleMol );
	glRotated( -30, 0.0, 1.0, 0.0 );
	glTranslated( 0.25*scaleMol, 0.0, -2.24*scaleMol );
    glmDraw(rightbi, GLM_SMOOTH | GLM_COLOR );
	glPushMatrix();/*右肘开始绘制*/
	glTranslated(0.75*scaleMol, 0.05*scaleMol, 1.95*scaleMol);
	glRotated( (GLfloat)rightHand, 1.0, 0.0, 0.0 );/*右肘旋转*/
	glTranslated(-0.75*scaleMol, -0.05*scaleMol, -1.95*scaleMol);

	if( mode == GL_SELECT )
	{
		glLoadName( 13 );
	}
    glmDraw(rightzhou, GLM_SMOOTH | GLM_COLOR );
    glPushMatrix();/*右手开始绘制*/
	if( mode == GL_SELECT )
	{
		glLoadName( 14 );
	}
    glmDraw(righthand, GLM_SMOOTH | GLM_COLOR ); 
    glPopMatrix();/*右手绘制结束*/
    glPopMatrix();/*右肘绘制结束*/
    glPopMatrix();/*右臂绘制结束*/
	glPopMatrix();
	glPopMatrix();/*全部绘制结束*/

}

void CMyView::displayTop( GLenum mode)
{
	glPushMatrix( );//
	
	glTranslated( 0.0, 0.0, -5.0 ); /*将模型向内平移5个单位*/
    glRotated( -90, 1.0, 0.0, 0.0 );/*将模型沿X轴顺时针旋转90度*/
	glRotated( 90, 0.0, 0.0, 1.0 );
	glRotated( m_xRotation, 0.0, 0.0, 1.0 );//Z方向旋转
	glRotated( m_yRotation, 1.0, 0.0, 0.0 );//X方向旋转

    glRotated(rotate_left_right, 0.0, 0.0, 1.0 );/*左右旋转*/
	glRotated( rotate_up_down, 1.0, 0.0, 0.0 );/*上下旋转*/
    glTranslated(0.0, 0.0, -1.3*scaleMol);/*向下平移模型*/
   
	
	glPushMatrix();/*绘制开始*/
	
	glTranslated( 0.0, 0.0, 2.514*scaleMol );
    glRotated( (GLfloat)nod, 1.0, 0.0, 0.0 );/*点头*/
	glRotated( (GLfloat)throwHead, 0.0, 1.0, 0.0 );/*摇头*/
	glTranslated( 0.0, 0.0, -2.514*scaleMol );
	
	if( mode == GL_SELECT )
	{
		glLoadName( 1 );
	}
	glmDraw( head, GLM_SMOOTH | GLM_COLOR );/*绘制头模型*/	
    
	glPopMatrix();/*头绘制结束*/
	
	if( mode == GL_SELECT )
	{
		glLoadName( 2 );
	}

	glmDraw( body, GLM_SMOOTH | GLM_COLOR );/*绘制身体*/
    
	
	glPushMatrix();/*左腿开始绘制*/
	glTranslated( 0.12*scaleMol, 0.0, 1.51*scaleMol );
    glRotated( (GLfloat)leftDatui, 1.0, 0.0, 0.0 );/*左大腿旋转*/
	glTranslated( -0.12*scaleMol, 0.0, -1.51*scaleMol );
	
	if( mode == GL_SELECT )
	{
		glLoadName( 3 );
	}
   	glmDraw(leftdatui, GLM_SMOOTH | GLM_COLOR );
	glPushMatrix();/*左小腿开始绘制*/
	glTranslated( 0.164*scaleMol, -0.07*scaleMol, 0.81*scaleMol );
    glRotated( -(GLfloat)leftDatui, 1.0, 0.0, 0.0 );/*左小腿旋转*/
	glTranslated( -0.164*scaleMol, 0.07*scaleMol, -0.81 *scaleMol);

	if( mode == GL_SELECT )
	{
		glLoadName( 4 );
	}
    glmDraw(leftxiaotui, GLM_SMOOTH | GLM_COLOR );
    glPushMatrix();/*左脚开始绘制*/

	if( mode == GL_SELECT )
	{
		glLoadName( 5 );
	}
    glmDraw(leftfoot, GLM_SMOOTH | GLM_COLOR ); 
    glPopMatrix();/*左脚绘制结束*/

	glPopMatrix();/*左小腿绘制结束*/

	glPopMatrix();/*左大腿绘制结束*/

	glPushMatrix();/*右腿开始绘制*/
	glTranslated( 0.12*scaleMol, 0.0, 1.51*scaleMol );
    glRotated( (GLfloat)rightDatui, 1.0, 0.0, 0.0 );/*右腿旋转*/
	glTranslated( -0.12*scaleMol, 0.0, -1.51 *scaleMol);

	if( mode == GL_SELECT )
	{
		glLoadName( 6 );
	}
    glmDraw(rightdatui, GLM_SMOOTH | GLM_COLOR );
	glPushMatrix();/*右小腿工始绘制*/
	glTranslated( 0.164*scaleMol, -0.07*scaleMol, 0.81 *scaleMol);
    glRotated( -(GLfloat)rightDatui, 1.0, 0.0, 0.0 );/*右小腿旋转*/
	glTranslated( -0.164*scaleMol, 0.07*scaleMol, -0.81*scaleMol );

	if( mode == GL_SELECT )
	{
		glLoadName( 7 );
	}
    glmDraw(rightxiaotui, GLM_SMOOTH | GLM_COLOR );
    glPushMatrix();/*右脚开始绘制*/

	if( mode == GL_SELECT )
	{
		glLoadName( 8 );
	}
    glmDraw(rightfoot, GLM_SMOOTH | GLM_COLOR ); 
    glPopMatrix();/*右脚绘制结束*/
    glPopMatrix();/*右小腿绘制结束*/
	glPopMatrix();/*右大腿绘制结束*/


	glPushMatrix();/*左臂开始绘制*/

	glTranslated(0.0, 0.05*scaleMol, 2.23*scaleMol);
	glRotated( (GLfloat)leftHand, 1.0, 0.0, 0.0 );/*左臂旋转*/
	glTranslated(0.0, -0.05*scaleMol, -2.23*scaleMol); 
	
	if( mode == GL_SELECT )
	{
		glLoadName( 9 );
	}
	glPushMatrix();/*将左臂向内旋转30度*/
	glTranslated( 0.25*scaleMol, 0.0, 2.24*scaleMol );
	glRotated( 30, 0.0, 1.0, 0.0 );
	glTranslated( -0.25*scaleMol, 0.0, -2.24*scaleMol );
	glmDraw(leftbi, GLM_SMOOTH | GLM_COLOR );
	
    glPushMatrix();/*左肘开始绘制*/
    glTranslated(0.75*scaleMol, 0.05*scaleMol, 1.95*scaleMol);
    glRotated( (GLfloat)leftHand*0.6, 1.0, 0.0, 0.0);/*左肘旋转*/
	glTranslated(-0.75*scaleMol, -0.05*scaleMol, -1.95*scaleMol);

	if( mode == GL_SELECT )
	{
		glLoadName( 10 );
	}
	glmDraw(leftzhou, GLM_SMOOTH | GLM_COLOR );
    glPushMatrix();/*左手开始绘制*/

	if( mode == GL_SELECT )
	{
		glLoadName( 11 );
	}
    glmDraw(lefthand, GLM_SMOOTH | GLM_COLOR ); 
    glPopMatrix();/*左手绘制结束*/
    glPopMatrix();/*左肘绘制结束*/
    glPopMatrix();/*左臂绘制结束*/
	glPopMatrix();



	glPushMatrix();/*右臂开始绘制*/
	glTranslated(0.0, 0.05*scaleMol, 2.23*scaleMol);
	glRotated( (GLfloat)rightHand, 1.0, 0.0, 0.0 );/*右臂旋转*/
	glTranslated(0.0, -0.05*scaleMol, -2.23*scaleMol);

	if( mode == GL_SELECT )
	{
		glLoadName( 12 );
	}
	glPushMatrix();/*将右臂向内旋转30度*/
	glTranslated( -0.25*scaleMol, 0.0, 2.24*scaleMol );
	glRotated( -30, 0.0, 1.0, 0.0 );
	glTranslated( 0.25*scaleMol, 0.0, -2.24*scaleMol );
    glmDraw(rightbi, GLM_SMOOTH | GLM_COLOR );
	glPushMatrix();/*右肘开始绘制*/
	glTranslated(0.75*scaleMol, 0.05*scaleMol, 1.95*scaleMol);
	glRotated( (GLfloat)rightHand, 1.0, 0.0, 0.0 );/*右肘旋转*/
	glTranslated(-0.75*scaleMol, -0.05*scaleMol, -1.95*scaleMol);

	if( mode == GL_SELECT )
	{
		glLoadName( 13 );
	}
    glmDraw(rightzhou, GLM_SMOOTH | GLM_COLOR );
    glPushMatrix();/*右手开始绘制*/
	if( mode == GL_SELECT )
	{
		glLoadName( 14 );
	}
    glmDraw(righthand, GLM_SMOOTH | GLM_COLOR ); 
    glPopMatrix();/*右手绘制结束*/
    glPopMatrix();/*右肘绘制结束*/
    glPopMatrix();/*右臂绘制结束*/
	glPopMatrix();
	glPopMatrix();/*全部绘制结束*/

}



void CMyView::OnHelpOperation() 
{
	// TODO: Add your command handler code here
	KillTimer( 1 );
	m_play = false;
	ShellExecute(NULL, "open", "help.chm", NULL, ".\\", SW_SHOW );/*显示帮助文档*/
	
}

void CMyView::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	// TODO: Add your message handler code here
	CMenu menu;
	menu.LoadMenu( IDR_MENU1 );/*载入弹出菜单*/
	menu.GetSubMenu(0)->TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
		                                point.x, point.y, this );
/*	if( menu.GetSubMenu(0)->EnableMenuItem( ID_CONTROL_OPENTB, MF_ENABLED ) == -1)
	{
		AfxMessageBox("-1");
	}
	else if( menu.GetSubMenu(0)->EnableMenuItem( ID_CONTROL_OPENTB, MF_ENABLED ) == (MF_ENABLED) )
	{
		AfxMessageBox("OK");
	}*/
//	menu.GetSubMenu(0)->EnableMenuItem( ID_CONTROL_VIEW, MF_DISABLED );
}

/*左转控制*/
void CMyView::OnControlLrotate() 
{
	// TODO: Add your command handler code here
	rotate_left_right++;

	Invalidate();
}

/*下转控制*/
void CMyView::OnControlDrotate() 
{
	// TODO: Add your command handler code here
	rotate_up_down--;

	Invalidate();	
}

/*右转控制*/
void CMyView::OnControlRrotate() 
{
	// TODO: Add your command handler code here
	rotate_left_right--;

	Invalidate();	
}

void CMyView::OnControlUrotate() 
{
	// TODO: Add your command handler code here
	rotate_up_down++;

	Invalidate();	
}

/*抬左腿控制*/
void CMyView::OnControlTls() 
{
	// TODO: Add your command handler code here
	if( !bWalk )
	{
		if( leftHand == 0 || leftHand == -45 )
		{
			leftHand_x = -leftHand_x;
		}
		
		leftHand = leftHand + leftHand_x;

		Invalidate();	
	}
}

/*抬右腿控制*/
void CMyView::OnControlTrs() 
{
	// TODO: Add your command handler code here
	if( !bWalk )
	{
		if( rightHand == 0 || rightHand == -45 )/*角度控制*/
		{
			rightHand_x = -rightHand_x;
		}
		
		rightHand = rightHand + rightHand_x;
		
		Invalidate();	
	}
}

/*侧顶视图控制*/
void CMyView::OnWindowOpen() 
{
	// TODO: Add your command handler code here
	if( !bWalk )
	{
		ok = !ok;
		scaleMode = false;
		
		GLint recoverMol = scaleMol;	
		if( scaleMol != 1 )/*判断放大次数*/
		{
			glmScale( head, (float)1/recoverMol );
			glmScale( body, (float)1/recoverMol );
			glmScale( leftdatui, (float)1/recoverMol );
			glmScale( rightdatui, (float)1/recoverMol );
			glmScale( leftxiaotui, (float)1/recoverMol );
			glmScale( rightxiaotui, (float)1/recoverMol );
			glmScale( leftfoot, (float)1/recoverMol );
			glmScale( rightfoot, (float)1/recoverMol );
			glmScale( leftbi, (float)1/recoverMol );
			glmScale( rightbi, (float)1/recoverMol );
			glmScale( leftzhou, (float)1/recoverMol );
			glmScale( rightzhou, (float)1/recoverMol );
			glmScale( lefthand, (float)1/recoverMol );
			glmScale( righthand, (float)1/recoverMol );
		}
		scaleMol = 1;/*将放大系数重置为1*/
		
		Invalidate();	/*刷新*/
	}
}

/*侧顶视图菜单更新操作*/
void CMyView::OnUpdateWindowOpen(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck( ok );/*在侧顶视图菜单前作上标记*/

	Invalidate();	
}

void CMyView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
//	OnControlRecover();
	KillTimer( 1 );/*关闭定时器*/
	m_play = false;/*关闭播放按钮*/
	
	m_leftButtonDown = true;/*左键按下标志*/
	
	if( (scaleMode == true) || (bWalk == true) )/*判断是否处于放大模式或走步模式*/
	{
		m_leftButtonDown = false;
	}

	if( (ok == false) && (scaleMode == true) && ( bWalk == false ) )/*判断是否

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -