• 大小: 37.58MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-17
  • 语言: C/C++
  • 标签: 机器人  c++  

资源简介

文采用在Vs2015开发平 台上,基于MFC框架类和OpenGL的函数库来开发仿真软件.

资源截图

代码片段和文件信息

// MyOpenGL.cpp : 实现文件
//

#include “stdafx.h“
#include “RobotControl.h“
#include “MyOpenGL.h“
#include 
// CMyOpenGL

IMPLEMENT_DYNAMIC(CMyOpenGL CWnd)

CMyOpenGL::CMyOpenGL()
{
//Opengl默认
viewWidth = 1;
viewHight = 1;
//定义关接转动角度
theta1=0;theta2=0;theta3=0;
theta4=0;theta5=0;theta6=0; //定义关节转动角度,单位角度
T_x = 0.0;T_y=0.0;T_z=0.0;
R_x = 0.0;R_y=0.0;R_z=0.0;
S_x=1.0;S_y=1.0;S_z=1.0;

maxtheta1 = 270;mintheta1 = -270;//定义机器人每个轴的最大工作范围
maxtheta2 = 120;mintheta2 = -120;   
maxtheta3 = 160;mintheta3 = -160;
maxtheta4 = 150;mintheta4 = -150;
maxtheta5 = 360;mintheta5 = -360;
maxtheta6 = 360;mintheta6 = -360;

//部件颜色初始化
color_s0[0]=   0; color_s0[1]=255; color_s0[2]=  0; //
color_s1[0]= 255; color_s1[1]=255; color_s1[2]=  0; //
color_s2[0]=  80; color_s2[1]= 80; color_s2[2]=200; //
color_s3[0]= 255; color_s3[1]=  0; color_s3[2]=  0; //
color_s4[0]= 255; color_s4[1]=255; color_s4[2]=  0; //
color_s5[0]=  80; color_s5[1]= 80; color_s5[2]=200; //
color_s6[0]= 255; color_s6[1]=255; color_s6[2]=100; //

//图像显示变量初始化
m_AxisOn = true;
m_PlaneOn = false;
m_TarDotOn = false;
m_PathOn = false;

m_TarX = 500; m_TarY = 500; m_TarZ = 500;
m_TarRx =  0; m_TarRy =  0; m_TarRz =  0;
}

CMyOpenGL::~CMyOpenGL()
{
wglMakeCurrent(NULLNULL);  
    wglDeleteContext(hglrc);//删除渲染描述表  
    ::ReleaseDC(m_hWndhdc);//释放设备描述表 
}


BEGIN_MESSAGE_MAP(CMyOpenGL CWnd)
ON_WM_PAINT()
ON_WM_CREATE()
ON_WM_MOUSEMOVE()
// ON_WM_MOUSEWHEEL()
END_MESSAGE_MAP()



// CMyOpenGL 消息处理程序

void CMyOpenGL::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //清除颜色缓存和深度缓存  
// LightShine( );
// Reshape(viewWidthviewHight);
    Display();   
    glFlush();  
    SwapBuffers(hdc);
// 不为绘图消息调用 CWnd::OnPaint()
}


int CMyOpenGL::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;

// TODO:  在此添加您专用的创建代码
if(MySetPixelFormat(::GetDC(m_hWnd))==FALSE)  
        return 0;  
  
    // 获得绘图描述表  
    hdc = ::GetDC(m_hWnd);  
    // 创建渲染描述表  
    hglrc = wglCreateContext(hdc);  
    // 使绘图描述表为当前调用现程的当前绘图描述表   
    wglMakeCurrent(hdc hglrc);

    LightShine( ); //开启渲染

Reshape( viewWidthviewHight ); //设置视口

return 0;
}

int CMyOpenGL::MySetPixelFormat(HDC hDC)  
{  
    PIXELFORMATDEscriptOR pixelDesc;  
  
    pixelDesc.nSize = sizeof(PIXELFORMATDEscriptOR);  
    pixelDesc.nVersion = 1;  
  
    pixelDesc.dwFlags = PFD_DRAW_TO_WINDOW |   
        PFD_SUPPORT_OPENGL |  
        PFD_DOUBLEBUFFER |  
        PFD_TYPE_RGBA;  
  
    pixelDesc.iPixelType = PFD_TYPE_RGBA;  
    pixelDesc.cColorBits = 32;  
    pixelDesc.cRedBits = 0;  
    pixelDesc.cRedShift = 0;  
    pixelDesc.cGreenBits = 0;  
    pixelDesc.cGreenShift = 0;  
    pixelDesc.cBlueBits = 0;  
    pixelDesc.cBlueShift = 0;  
    pixelDesc.cAlpha

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     597504  2017-09-07 18:31  RobotControl\Debug\RobotControl.exe

     文件    2976940  2017-09-07 18:31  RobotControl\Debug\RobotControl.ilk

     文件   15346688  2017-09-07 18:31  RobotControl\Debug\RobotControl.pdb

     文件   95879168  2017-08-30 16:27  RobotControl\ipch\robotcontrol-fd427c02\robotcontrol-94fb8eb3.ipch

     文件       3660  2017-09-07 18:30  RobotControl\RobotControl\Debug\cl.command.1.tlog

     文件     164858  2017-09-07 18:30  RobotControl\RobotControl\Debug\CL.read.1.tlog

     文件       1914  2017-09-07 18:30  RobotControl\RobotControl\Debug\CL.write.1.tlog

     文件          2  2017-09-07 18:31  RobotControl\RobotControl\Debug\link-cvtres.read.1.tlog

     文件          2  2017-09-07 18:31  RobotControl\RobotControl\Debug\link-cvtres.write.1.tlog

     文件       1954  2017-09-07 18:31  RobotControl\RobotControl\Debug\link.command.1.tlog

     文件       6622  2017-09-07 18:31  RobotControl\RobotControl\Debug\link.read.1.tlog

     文件       1146  2017-09-07 18:31  RobotControl\RobotControl\Debug\link.write.1.tlog

     文件        754  2017-09-07 18:31  RobotControl\RobotControl\Debug\mt.command.1.tlog

     文件        516  2017-09-07 18:31  RobotControl\RobotControl\Debug\mt.read.1.tlog

     文件        470  2017-09-07 18:31  RobotControl\RobotControl\Debug\mt.write.1.tlog

     文件      81818  2017-09-07 18:30  RobotControl\RobotControl\Debug\MyOpenGL.obj

     文件     121251  2017-09-07 18:30  RobotControl\RobotControl\Debug\MyOrocosKDL.obj

     文件       1148  2017-09-07 18:31  RobotControl\RobotControl\Debug\rc.command.1.tlog

     文件       3396  2017-09-07 18:31  RobotControl\RobotControl\Debug\rc.read.1.tlog

     文件        470  2017-09-07 18:31  RobotControl\RobotControl\Debug\rc.write.1.tlog

     文件       1755  2017-09-07 18:30  RobotControl\RobotControl\Debug\RobotControl.Build.CppClean.log

     文件        915  2017-09-07 18:31  RobotControl\RobotControl\Debug\RobotControl.exe.embed.manifest

     文件        980  2017-09-07 18:31  RobotControl\RobotControl\Debug\RobotControl.exe.embed.manifest.res

     文件        640  2017-09-07 18:31  RobotControl\RobotControl\Debug\RobotControl.exe.intermediate.manifest

     文件         49  2017-09-07 18:31  RobotControl\RobotControl\Debug\RobotControl.lastbuildstate

     文件       4205  2017-09-07 18:31  RobotControl\RobotControl\Debug\RobotControl.log

     文件      97102  2017-09-07 18:30  RobotControl\RobotControl\Debug\RobotControl.obj

     文件      71824  2017-09-07 18:31  RobotControl\RobotControl\Debug\RobotControl.res

     文件        713  2017-09-07 18:30  RobotControl\RobotControl\Debug\RobotControl.vcxprojResolveAssemblyReference.cache

     文件          0  2017-09-07 18:30  RobotControl\RobotControl\Debug\RobotControl.write.1.tlog

............此处省略38个文件信息

评论

共有 条评论