├── GraphicsExercise3D ├── MainFrm.h ├── stdafx.h ├── ClassView.h ├── FileView.cpp ├── FileView.h ├── MainFrm.cpp ├── OutputWnd.h ├── Resource.h ├── ViewTree.cpp ├── ViewTree.h ├── res │ ├── sort.bmp │ ├── Toolbar.bmp │ ├── classview.bmp │ ├── explorer.bmp │ ├── file_view.ico │ ├── fileview.bmp │ ├── sort_hc.bmp │ ├── Toolbar256.bmp │ ├── class_view.ico │ ├── explorer_hc.bmp │ ├── fileview_hc.bmp │ ├── menuimages.bmp │ ├── output_wnd.ico │ ├── properties.bmp │ ├── class_view_hc.ico │ ├── classview_hc.bmp │ ├── file_view_hc.ico │ ├── menuimages_hc.bmp │ ├── output_wnd_hc.ico │ ├── properties_hc.bmp │ ├── properties_wnd.ico │ ├── GraphicsExercise3D.ico │ ├── GraphicsExercise3D.rc2 │ ├── properties_wnd_hc.ico │ └── GraphicsExercise3DDoc.ico ├── stdafx.cpp ├── targetver.h ├── ClassView.cpp ├── OutputWnd.cpp ├── UserImages.bmp ├── PropertiesWnd.cpp ├── PropertiesWnd.h ├── GraphicsExercise3D.cpp ├── GraphicsExercise3D.h ├── GraphicsExercise3D.rc ├── GraphicsExercise3DDoc.h ├── GraphicsExercise3DView.h ├── GraphicsExercise3DDoc.cpp ├── GraphicsExercise3DView.cpp ├── ReadMe.txt ├── GraphicsExercise3D.vcxproj.filters └── GraphicsExercise3D.vcxproj ├── GraphicsExercise3D.sln └── README.md /GraphicsExercise3D/MainFrm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/MainFrm.h -------------------------------------------------------------------------------- /GraphicsExercise3D/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/stdafx.h -------------------------------------------------------------------------------- /GraphicsExercise3D/ClassView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/ClassView.h -------------------------------------------------------------------------------- /GraphicsExercise3D/FileView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/FileView.cpp -------------------------------------------------------------------------------- /GraphicsExercise3D/FileView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/FileView.h -------------------------------------------------------------------------------- /GraphicsExercise3D/MainFrm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/MainFrm.cpp -------------------------------------------------------------------------------- /GraphicsExercise3D/OutputWnd.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/OutputWnd.h -------------------------------------------------------------------------------- /GraphicsExercise3D/Resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/Resource.h -------------------------------------------------------------------------------- /GraphicsExercise3D/ViewTree.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/ViewTree.cpp -------------------------------------------------------------------------------- /GraphicsExercise3D/ViewTree.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/ViewTree.h -------------------------------------------------------------------------------- /GraphicsExercise3D/res/sort.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/sort.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/stdafx.cpp -------------------------------------------------------------------------------- /GraphicsExercise3D/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/targetver.h -------------------------------------------------------------------------------- /GraphicsExercise3D/ClassView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/ClassView.cpp -------------------------------------------------------------------------------- /GraphicsExercise3D/OutputWnd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/OutputWnd.cpp -------------------------------------------------------------------------------- /GraphicsExercise3D/UserImages.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/UserImages.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/PropertiesWnd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/PropertiesWnd.cpp -------------------------------------------------------------------------------- /GraphicsExercise3D/PropertiesWnd.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/PropertiesWnd.h -------------------------------------------------------------------------------- /GraphicsExercise3D/res/Toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/Toolbar.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/classview.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/classview.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/explorer.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/explorer.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/file_view.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/file_view.ico -------------------------------------------------------------------------------- /GraphicsExercise3D/res/fileview.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/fileview.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/sort_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/sort_hc.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/Toolbar256.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/Toolbar256.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/class_view.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/class_view.ico -------------------------------------------------------------------------------- /GraphicsExercise3D/res/explorer_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/explorer_hc.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/fileview_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/fileview_hc.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/menuimages.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/menuimages.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/output_wnd.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/output_wnd.ico -------------------------------------------------------------------------------- /GraphicsExercise3D/res/properties.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/properties.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/GraphicsExercise3D.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/GraphicsExercise3D.cpp -------------------------------------------------------------------------------- /GraphicsExercise3D/GraphicsExercise3D.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/GraphicsExercise3D.h -------------------------------------------------------------------------------- /GraphicsExercise3D/GraphicsExercise3D.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/GraphicsExercise3D.rc -------------------------------------------------------------------------------- /GraphicsExercise3D/res/class_view_hc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/class_view_hc.ico -------------------------------------------------------------------------------- /GraphicsExercise3D/res/classview_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/classview_hc.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/file_view_hc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/file_view_hc.ico -------------------------------------------------------------------------------- /GraphicsExercise3D/res/menuimages_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/menuimages_hc.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/output_wnd_hc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/output_wnd_hc.ico -------------------------------------------------------------------------------- /GraphicsExercise3D/res/properties_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/properties_hc.bmp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/properties_wnd.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/properties_wnd.ico -------------------------------------------------------------------------------- /GraphicsExercise3D/GraphicsExercise3DDoc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/GraphicsExercise3DDoc.h -------------------------------------------------------------------------------- /GraphicsExercise3D/GraphicsExercise3DView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/GraphicsExercise3DView.h -------------------------------------------------------------------------------- /GraphicsExercise3D/GraphicsExercise3DDoc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/GraphicsExercise3DDoc.cpp -------------------------------------------------------------------------------- /GraphicsExercise3D/GraphicsExercise3DView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/GraphicsExercise3DView.cpp -------------------------------------------------------------------------------- /GraphicsExercise3D/res/GraphicsExercise3D.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/GraphicsExercise3D.ico -------------------------------------------------------------------------------- /GraphicsExercise3D/res/GraphicsExercise3D.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/GraphicsExercise3D.rc2 -------------------------------------------------------------------------------- /GraphicsExercise3D/res/properties_wnd_hc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/properties_wnd_hc.ico -------------------------------------------------------------------------------- /GraphicsExercise3D/res/GraphicsExercise3DDoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huihut/GraphicsExercise3D/HEAD/GraphicsExercise3D/res/GraphicsExercise3DDoc.ico -------------------------------------------------------------------------------- /GraphicsExercise3D.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GraphicsExercise3D", "GraphicsExercise3D\GraphicsExercise3D.vcxproj", "{B6F73C6C-E387-4D52-AA98-F8C283AC6C22}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {B6F73C6C-E387-4D52-AA98-F8C283AC6C22}.Debug|x64.ActiveCfg = Debug|x64 17 | {B6F73C6C-E387-4D52-AA98-F8C283AC6C22}.Debug|x64.Build.0 = Debug|x64 18 | {B6F73C6C-E387-4D52-AA98-F8C283AC6C22}.Debug|x86.ActiveCfg = Debug|Win32 19 | {B6F73C6C-E387-4D52-AA98-F8C283AC6C22}.Debug|x86.Build.0 = Debug|Win32 20 | {B6F73C6C-E387-4D52-AA98-F8C283AC6C22}.Release|x64.ActiveCfg = Release|x64 21 | {B6F73C6C-E387-4D52-AA98-F8C283AC6C22}.Release|x64.Build.0 = Release|x64 22 | {B6F73C6C-E387-4D52-AA98-F8C283AC6C22}.Release|x86.ActiveCfg = Release|Win32 23 | {B6F73C6C-E387-4D52-AA98-F8C283AC6C22}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /GraphicsExercise3D/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | MICROSOFT 基础类库 : GraphicsExercise3D 项目概述 3 | =============================================================================== 4 | 5 | 应用程序向导已为您创建了此 GraphicsExercise3D 应用程序。此应用程序不仅演示 Microsoft 基础类的基本使用方法,还可作为您编写应用程序的起点。 6 | 7 | 本文件概要介绍组成 GraphicsExercise3D 应用程序的每个文件的内容。 8 | 9 | GraphicsExercise3D.vcxproj 10 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 11 | 12 | GraphicsExercise3D.vcxproj.filters 13 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 14 | 15 | GraphicsExercise3D.h 16 | 这是应用程序的主头文件。 17 | 其中包括其他项目特定的标头(包括 Resource.h),并声明 CGraphicsExercise3DApp 应用程序类。 18 | 19 | GraphicsExercise3D.cpp 20 | 这是包含应用程序类 CGraphicsExercise3DApp 的主应用程序源文件。 21 | 22 | GraphicsExercise3D.rc 23 | 这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源包含在 2052 中。 24 | 25 | res\GraphicsExercise3D.ico 26 | 这是用作应用程序图标的图标文件。此图标包括在主资源文件 GraphicsExercise3D.rc 中。 27 | 28 | res\GraphicsExercise3D.rc2 29 | 此文件包含不在 Microsoft Visual C++ 中进行编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。 30 | 31 | ///////////////////////////////////////////////////////////////////////////// 32 | 33 | 对于主框架窗口: 34 | 该项目包含一个标准的 MFC 接口。 35 | 36 | MainFrm.h, MainFrm.cpp 37 | 这些文件中包含框架类 CMainFrame,该类派生自 38 | CFrameWnd 并控制所有 SDI 框架功能。 39 | 40 | res\Toolbar.bmp 41 | 此位图文件用于为工具栏创建平铺图像。 42 | 初始工具栏和状态栏在 CMainFrame 类中构造。使用资源编辑器编辑此工具栏位图,并更新 GraphicsExercise3D.rc 中的 IDR_MAINFRAME TOOLBAR 数组以添加工具栏按钮。 43 | ///////////////////////////////////////////////////////////////////////////// 44 | 45 | 应用程序向导创建一种文档类型和一个视图: 46 | 47 | GraphicsExercise3DDoc.h、GraphicsExercise3DDoc.cpp - 文档 48 | 这些文件包含 CGraphicsExercise3DDoc 类。编辑这些文件以添加特殊文档数据并实现文件保存和加载(通过 CGraphicsExercise3DDoc::Serialize)。 49 | 50 | GraphicsExercise3DView.h、GraphicsExercise3DView.cpp - 文档视图 51 | 这些文件包含 CGraphicsExercise3DView 类。 52 | CGraphicsExercise3DView 对象用于查看 CGraphicsExercise3DDoc 对象。 53 | 54 | 55 | 56 | 57 | ///////////////////////////////////////////////////////////////////////////// 58 | 59 | 其他功能: 60 | 61 | ActiveX 控件 62 | 该应用程序包含对使用 ActiveX 控件的支持。 63 | 64 | 打印和打印预览支持 65 | 应用程序向导通过从 MFC 库调用 CView 类中的成员函数生成代码,来处理打印、打印设置和打印预览命令。 66 | 67 | ///////////////////////////////////////////////////////////////////////////// 68 | 69 | 其他标准文件: 70 | 71 | StdAfx.h, StdAfx.cpp 72 | 这些文件用于生成名为 GraphicsExercise3D.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 73 | 74 | Resource.h 75 | 这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。 76 | 77 | GraphicsExercise3D.manifest 78 | Windows XP 使用应用程序清单文件来描述特定版本的并行程序集的应用程序依赖项。加载程序使用这些信息来从程序集缓存中加载相应的程序集,并保护其不被应用程序访问。应用程序清单可能会包含在内,以作为与应用程序可执行文件安装在同一文件夹中的外部 .manifest 文件进行重新分发,它还可能以资源的形式包含在可执行文件中。 79 | ///////////////////////////////////////////////////////////////////////////// 80 | 81 | 其他注释: 82 | 83 | 应用程序向导使用“TODO:”来指示应添加或自定义的源代码部分。 84 | 85 | 如果应用程序使用共享 DLL 中的 MFC,您将需要重新分发 MFC DLL。如果应用程序所使用的语言与操作系统的区域设置不同,则还需要重新分发相应的本地化资源 mfc110XXX.DLL。 86 | 有关上述话题的更多信息,请参见 MSDN 文档中有关重新分发 Visual C++ 应用程序的部分。 87 | 88 | ///////////////////////////////////////////////////////////////////////////// 89 | -------------------------------------------------------------------------------- /GraphicsExercise3D/GraphicsExercise3D.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 头文件 32 | 33 | 34 | 头文件 35 | 36 | 37 | 头文件 38 | 39 | 40 | 头文件 41 | 42 | 43 | 头文件 44 | 45 | 46 | 头文件 47 | 48 | 49 | 头文件 50 | 51 | 52 | 头文件 53 | 54 | 55 | 头文件 56 | 57 | 58 | 59 | 60 | 源文件 61 | 62 | 63 | 源文件 64 | 65 | 66 | 源文件 67 | 68 | 69 | 源文件 70 | 71 | 72 | 源文件 73 | 74 | 75 | 源文件 76 | 77 | 78 | 源文件 79 | 80 | 81 | 源文件 82 | 83 | 84 | 源文件 85 | 86 | 87 | 源文件 88 | 89 | 90 | 91 | 92 | 资源文件 93 | 94 | 95 | 96 | 97 | 资源文件 98 | 99 | 100 | 资源文件 101 | 102 | 103 | 资源文件 104 | 105 | 106 | 资源文件 107 | 108 | 109 | 资源文件 110 | 111 | 112 | 资源文件 113 | 114 | 115 | 资源文件 116 | 117 | 118 | 资源文件 119 | 120 | 121 | 资源文件 122 | 123 | 124 | 资源文件 125 | 126 | 127 | 资源文件 128 | 129 | 130 | 资源文件 131 | 132 | 133 | 资源文件 134 | 135 | 136 | 资源文件 137 | 138 | 139 | 资源文件 140 | 141 | 142 | 资源文件 143 | 144 | 145 | 资源文件 146 | 147 | 148 | 资源文件 149 | 150 | 151 | 资源文件 152 | 153 | 154 | 资源文件 155 | 156 | 157 | 资源文件 158 | 159 | 160 | 资源文件 161 | 162 | 163 | 资源文件 164 | 165 | 166 | 资源文件 167 | 168 | 169 | 资源文件 170 | 171 | 172 | 173 | 174 | 资源文件 175 | 176 | 177 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 使用MFC的CDC类绘制三维坐标系及球面函数 2 | 3 | ## 系列链接 4 | 5 | * [使用MFC的CDC类绘制二维坐标系及正余弦函数](https://blog.huihut.com/2017/10/13/GraphicsExercise2D/) / [源码](https://github.com/huihut/GraphicsExercise2D) 6 | 7 | * [使用MFC的CDC类绘制三维坐标系及球面函数](https://blog.huihut.com/2017/10/13/GraphicsExercise3D/) / [源码](https://github.com/huihut/GraphicsExercise3D) 8 | 9 | ## 概述 10 | 11 | 本文使用MFC的CDC类绘制三维坐标系及球面函数。首先计算推导出三维坐标在二维平面显示的坐标变换方程(使用斜二测视图),使用球面的参数方程,然后定义图形缩放比例规模、坐标轴位移,变换坐标系和规模等,最后绘制坐标轴及球面函数。 12 | 13 | 如果对绘制二维坐标系还不太熟悉可以先看上面系列链接的:[使用MFC的CDC类绘制二维坐标系及正余弦函数](https://blog.huihut.com/2017/10/13/GraphicsExercise2D/),本文对二维绘制及绘制函数部分不再赘述。因为二维坐标系的博文已经分模块讲解地比较清楚了,而与三维坐标系的基本思路相同,所以本文大部分直接使用注释讲解。 14 | 15 | ## 三维转二维的推导 16 | 17 | ![Transform3Dto2D](http://huihut-img.oss-cn-shenzhen.aliyuncs.com/Transform3Dto2D.png) 18 | 19 | 上图可知,只要使用`Transform3Dto2D()`函数,即可方便的把三维坐标转化为二维坐标(斜二测视图)。 20 | 21 | ## 球面参数方程 22 | 23 | 在三维空间直角坐标系中,以原点为球心、半径为 `r` 的球面的方程为 `x^2 + y^2 + z^2 = r^2`,其参数方程为 24 | 25 | ![SphericalParameterEquation](http://huihut-img.oss-cn-shenzhen.aliyuncs.com/SphericalParameterEquation.png) 26 | 27 | ## 新建项目 28 | 29 | `Visual Studio`- `新建项目` - `MFC应用程序` - 命名为`GraphicsExercise3D` - `确定` - `下一步` - 应用程序类型选择`单个文档` - `完成` 30 | 31 | ## GraphicsExercise3DView.h 32 | 33 | 在`GraphicsExercise3DView.h`添加以下内容 34 | 35 | ``` 36 | // 操作 37 | public: 38 | void SetScale(int scale); 39 | void SetTransformOrigin(float transformOriginX, float transformOriginY); 40 | void SetPlotSphere(float radius, float stepPhi, float stepTheta); 41 | void SetSlantRadian(float slant); 42 | 43 | float TransformScale(float num); 44 | float TransformOriginX(float x); 45 | float TransformOriginY(float y); 46 | float TransformOriginScaleX(float x); 47 | float TransformOriginScaleY(float y); 48 | void Transform3Dto2D(float &x, float &y, float z); 49 | 50 | private: 51 | int scale; 52 | float radius, stepPhi, stepTheta, slant, transformOriginX, transformOriginY; 53 | ``` 54 | 55 | ## GraphicsExercise3DView.cpp 56 | 57 | 引入数学函数库 58 | ``` 59 | #include 60 | ``` 61 | 62 | 定义π 63 | ``` 64 | #ifndef PI 65 | #define PI 3.14159 66 | #endif // !PI 67 | ``` 68 | 69 | 在构造函数初始化 70 | 71 | ``` 72 | CGraphicsExercise3DView::CGraphicsExercise3DView() 73 | { 74 | // TODO: 在此处添加构造代码 75 | 76 | // 设置斜二测视图倾斜角度(弧度制) 77 | SetSlantRadian(PI / 4); 78 | 79 | // 设置规模比例 80 | SetScale(70); 81 | 82 | // 设置坐标系在x、y方向的位移(不改变规模情况下,即移动像素) 83 | SetTransformOrigin(300, 350); 84 | 85 | // 设置球面半径radius、取样步长stepPhi、stepTheta 86 | SetPlotSphere(2.0, 0.01, 0.1); 87 | } 88 | ``` 89 | 90 | 设置初始化参数的Set函数 91 | 92 | ``` 93 | // 设置规模 94 | void CGraphicsExercise3DView::SetScale(int scale) 95 | { 96 | this->scale = scale; 97 | } 98 | 99 | // 设置坐标系原点在x、y方向的位移(不改变规模情况下,即移动像素) 100 | void CGraphicsExercise3DView::SetTransformOrigin(float transformOriginX, float transformOriginY) 101 | { 102 | this->transformOriginX = transformOriginX; 103 | this->transformOriginY = transformOriginY; 104 | } 105 | 106 | // 设置球面半径radius、取样步长stepPhi、stepTheta 107 | void CGraphicsExercise3DView::SetPlotSphere(float radius, float stepPhi, float stepTheta) 108 | { 109 | this->radius = radius; 110 | this->stepPhi = stepPhi; 111 | this->stepTheta = stepTheta; 112 | } 113 | 114 | // 设置斜二测视图的倾斜角(单位弧度) 115 | void CGraphicsExercise3DView::SetSlantRadian(float slant) 116 | { 117 | this->slant = slant; 118 | } 119 | ``` 120 | 121 | 坐标及规模变换 122 | 123 | ``` 124 | // 变换规模 125 | float CGraphicsExercise3DView::TransformScale(float num) 126 | { 127 | return num * scale; 128 | } 129 | 130 | // 坐标系X轴方向位移 131 | float CGraphicsExercise3DView::TransformOriginX(float x) 132 | { 133 | return x + transformOriginX / scale; 134 | } 135 | 136 | // 坐标系y轴方向位移 137 | float CGraphicsExercise3DView::TransformOriginY(float y) 138 | { 139 | return y - transformOriginY / scale; 140 | } 141 | 142 | // 变换坐标系X和规模 143 | float CGraphicsExercise3DView::TransformOriginScaleX(float x) 144 | { 145 | return TransformScale(TransformOriginX(x)); 146 | } 147 | 148 | // 变换坐标系Y和规模 149 | float CGraphicsExercise3DView::TransformOriginScaleY(float y) 150 | { 151 | return -TransformScale(TransformOriginY(y)); 152 | } 153 | ``` 154 | 155 | 三维坐标转化为二维坐标 156 | 157 | ``` 158 | // 使用斜二测视图,把三维坐标点转化为二维平面上的点 159 | void CGraphicsExercise3DView::Transform3Dto2D(float &x, float &y, float z) 160 | { 161 | x = x - (z * cos(slant)) / 2; 162 | y = y - (z * sin(slant)) / 2; 163 | } 164 | ``` 165 | 166 | 绘制坐标轴及函数图形 167 | 168 | ``` 169 | // CGraphicsExercise2View 绘制 170 | 171 | void CGraphicsExercise3DView::OnDraw(CDC* pDC) 172 | { 173 | CGraphicsExercise3DDoc* pDoc = GetDocument(); 174 | ASSERT_VALID(pDoc); 175 | if (!pDoc) 176 | return; 177 | 178 | // TODO: 在此处为本机数据添加绘制代码 179 | 180 | float x, y, z; 181 | 182 | // -------------------- 绘制坐标系 ------------------------- 183 | 184 | // 坐标x轴 185 | pDC->MoveTo(TransformOriginScaleX(0), TransformOriginScaleY(0)); 186 | pDC->LineTo(TransformOriginScaleX(radius + 2), TransformOriginScaleY(0)); 187 | 188 | // 坐标y轴 189 | pDC->MoveTo(TransformOriginScaleX(0), TransformOriginScaleY(0)); 190 | pDC->LineTo(TransformOriginScaleX(0), TransformOriginScaleY(radius + 2)); 191 | 192 | // 坐标z轴 193 | x = 0, y = 0; 194 | Transform3Dto2D(x, y, radius + 5); 195 | pDC->MoveTo(TransformOriginScaleX(0), TransformOriginScaleY(0)); 196 | pDC->LineTo(TransformOriginScaleX(x), TransformOriginScaleY(y)); 197 | 198 | // 坐标x轴的箭头 199 | pDC->MoveTo(TransformOriginScaleX(radius + 1.8), TransformOriginScaleY(0.2)); 200 | pDC->LineTo(TransformOriginScaleX(radius + 2), TransformOriginScaleY(0)); 201 | pDC->LineTo(TransformOriginScaleX(radius + 1.8), TransformOriginScaleY(-0.2)); 202 | 203 | // 坐标y轴的箭头 204 | pDC->MoveTo(TransformOriginScaleX(-0.2), TransformOriginScaleY(radius + 1.8)); 205 | pDC->LineTo(TransformOriginScaleX(0), TransformOriginScaleY(radius + 2)); 206 | pDC->LineTo(TransformOriginScaleX(0.2), TransformOriginScaleY(radius + 1.8)); 207 | 208 | // 坐标z轴的箭头 209 | x = 0, y = 0.2; 210 | Transform3Dto2D(x, y, radius + 5 - 0.2); 211 | pDC->MoveTo(TransformOriginScaleX(x), TransformOriginScaleY(y)); 212 | x = 0, y = 0; 213 | Transform3Dto2D(x, y, radius + 5); 214 | pDC->LineTo(TransformOriginScaleX(x), TransformOriginScaleY(y)); 215 | x = 0.2, y = 0; 216 | Transform3Dto2D(x, y, radius + 5 - 0.2); 217 | pDC->LineTo(TransformOriginScaleX(x), TransformOriginScaleY(y)); 218 | 219 | // -------------------- 绘制刻度线 ------------------------- 220 | 221 | // 绘制x轴刻度线 222 | for (float scaleX = 0.2; scaleX < radius + 1; scaleX += 0.2) 223 | { 224 | pDC->MoveTo((int)TransformOriginScaleX(scaleX), (int)TransformOriginScaleY(0)); 225 | pDC->LineTo((int)TransformOriginScaleX(scaleX), (int)TransformOriginScaleY(0.1)); 226 | } 227 | 228 | // 绘制y轴刻度线 229 | for (float scaleY = 0.2; scaleY <= radius + 1; scaleY += 0.2) 230 | { 231 | pDC->MoveTo((int)TransformOriginScaleX(0), (int)TransformOriginScaleY(scaleY)); 232 | pDC->LineTo((int)TransformOriginScaleX(0.1), (int)TransformOriginScaleY(scaleY)); 233 | } 234 | 235 | // 绘制z轴刻度线 236 | for (float x = 0, y = 0, scaleZ = 0.2; scaleZ <= radius + 4; scaleZ += 0.2, x = 0, y = 0) 237 | { 238 | Transform3Dto2D(x, y, scaleZ); 239 | pDC->MoveTo((int)TransformOriginScaleX(x), (int)TransformOriginScaleY(y)); 240 | pDC->LineTo((int)TransformOriginScaleX(x + 0.1), (int)TransformOriginScaleY(y)); 241 | } 242 | 243 | 244 | // -------------------- 绘制文字 ------------------------- 245 | 246 | // 绘制x轴的x 247 | pDC->TextOutW(TransformOriginScaleX(radius + 1.6), TransformOriginScaleY(-0.2), CString("x")); 248 | // 绘制y轴的y 249 | pDC->TextOutW(TransformOriginScaleX(-0.2), TransformOriginScaleY(radius + 1.6), CString("y")); 250 | // 绘制z轴的z 251 | x = 0.2, y = 0; 252 | Transform3Dto2D(x, y, radius + 5 - 0.4); 253 | pDC->TextOutW(TransformOriginScaleX(x), TransformOriginScaleY(y), CString("z")); 254 | 255 | CString s; 256 | // 绘制x轴刻度文字 257 | for (float ScaleTextX = 0.4; ScaleTextX < radius + 1; ScaleTextX += 0.4) 258 | { 259 | s.Format(_T("%.1f"), ScaleTextX); 260 | pDC->TextOutW(TransformOriginScaleX(ScaleTextX - 0.1), TransformOriginScaleY(-0.1), s); 261 | } 262 | 263 | // 绘制y轴刻度文字 264 | for (float ScaleTextY = 0.4; ScaleTextY <= radius + 1; ScaleTextY += 0.4) 265 | { 266 | s.Format(_T("%.1f"), ScaleTextY); 267 | pDC->TextOutW(TransformOriginScaleX(-0.4), TransformOriginScaleY(ScaleTextY + 0.1), s); 268 | } 269 | 270 | // 绘制z轴刻度文字 271 | for (float ScaleTextZ = 0.6; ScaleTextZ <= radius + 4; ScaleTextZ += 0.6) 272 | { 273 | s.Format(_T("%.1f"), ScaleTextZ); 274 | x = 0, y = 0; 275 | Transform3Dto2D(x, y, ScaleTextZ); 276 | pDC->TextOutW(TransformOriginScaleX(x + 0.15), TransformOriginScaleY(y + 0.12), s); 277 | } 278 | 279 | // 绘制函数图的Title 280 | x = 0, y = 0; 281 | Transform3Dto2D(x, y, radius + 5); 282 | pDC->TextOutW(TransformOriginScaleX(x + 3), TransformOriginScaleY(y), CString("x^2 + y^2 + z^2 = r^2")); 283 | 284 | // -------------------- 绘制函数 ------------------------- 285 | 286 | // 球面 287 | float phi, theta; 288 | for (phi = 0; phi < 2 * PI; phi += stepPhi) 289 | { 290 | for (theta = 0; theta < PI; theta += stepTheta) 291 | { 292 | x = radius * sin(phi) * cos(theta); 293 | y = radius * sin(phi) * sin(theta); 294 | z = radius * cos(phi); 295 | 296 | Transform3Dto2D(x, y, z); 297 | 298 | srand(z); 299 | pDC->SetPixel(TransformOriginScaleX(x), TransformOriginScaleY(y), RGB(rand() % 255, rand() % 255, rand() % 255)); 300 | } 301 | } 302 | 303 | 304 | //// 三棱锥(测试用) 305 | //x = 1, y = 0, z = 0; 306 | //Transform3Dto2D(x, y, z); 307 | //pDC->MoveTo((int)TransformOriginScaleX(x), (int)TransformOriginScaleY(y)); 308 | 309 | //x = 0, y = 1, z = 0; 310 | //Transform3Dto2D(x, y, z); 311 | //pDC->LineTo((int)TransformOriginScaleX(x), (int)TransformOriginScaleY(y)); 312 | 313 | //x = 0, y = 0, z = 1; 314 | //Transform3Dto2D(x, y, z); 315 | //pDC->LineTo((int)TransformOriginScaleX(x), (int)TransformOriginScaleY(y)); 316 | 317 | //x = 1, y = 0, z = 0; 318 | //Transform3Dto2D(x, y, z); 319 | //pDC->LineTo((int)TransformOriginScaleX(x), (int)TransformOriginScaleY(y)); 320 | 321 | } 322 | ``` 323 | 324 | ## 效果图 325 | 326 | ![GraphicsExercise3DCapture](http://huihut-img.oss-cn-shenzhen.aliyuncs.com/GraphicsExercise3DCapture.png) 327 | 328 | -------------------------------------------------------------------------------- /GraphicsExercise3D/GraphicsExercise3D.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {B6F73C6C-E387-4D52-AA98-F8C283AC6C22} 23 | GraphicsExercise3D 24 | 8.1 25 | MFCProj 26 | 27 | 28 | 29 | Application 30 | true 31 | v140 32 | Unicode 33 | Dynamic 34 | 35 | 36 | Application 37 | false 38 | v140 39 | true 40 | Unicode 41 | Dynamic 42 | 43 | 44 | Application 45 | true 46 | v140 47 | Unicode 48 | Dynamic 49 | 50 | 51 | Application 52 | false 53 | v140 54 | true 55 | Unicode 56 | Dynamic 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | true 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | false 87 | 88 | 89 | 90 | Use 91 | Level3 92 | Disabled 93 | WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) 94 | true 95 | 96 | 97 | Windows 98 | 99 | 100 | false 101 | true 102 | _DEBUG;%(PreprocessorDefinitions) 103 | 104 | 105 | 0x0804 106 | _DEBUG;%(PreprocessorDefinitions) 107 | $(IntDir);%(AdditionalIncludeDirectories) 108 | 109 | 110 | 111 | 112 | Use 113 | Level3 114 | Disabled 115 | _WINDOWS;_DEBUG;%(PreprocessorDefinitions) 116 | true 117 | 118 | 119 | Windows 120 | 121 | 122 | false 123 | true 124 | _DEBUG;%(PreprocessorDefinitions) 125 | 126 | 127 | 0x0804 128 | _DEBUG;%(PreprocessorDefinitions) 129 | $(IntDir);%(AdditionalIncludeDirectories) 130 | 131 | 132 | 133 | 134 | Level3 135 | Use 136 | MaxSpeed 137 | true 138 | true 139 | WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) 140 | true 141 | 142 | 143 | Windows 144 | true 145 | true 146 | 147 | 148 | false 149 | true 150 | NDEBUG;%(PreprocessorDefinitions) 151 | 152 | 153 | 0x0804 154 | NDEBUG;%(PreprocessorDefinitions) 155 | $(IntDir);%(AdditionalIncludeDirectories) 156 | 157 | 158 | 159 | 160 | Level3 161 | Use 162 | MaxSpeed 163 | true 164 | true 165 | _WINDOWS;NDEBUG;%(PreprocessorDefinitions) 166 | true 167 | 168 | 169 | Windows 170 | true 171 | true 172 | 173 | 174 | false 175 | true 176 | NDEBUG;%(PreprocessorDefinitions) 177 | 178 | 179 | 0x0804 180 | NDEBUG;%(PreprocessorDefinitions) 181 | $(IntDir);%(AdditionalIncludeDirectories) 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | Create 212 | Create 213 | Create 214 | Create 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | --------------------------------------------------------------------------------