3D views are highly realistic and many people prefer them.
In CChart, I am stupid to implement several types of 3D views.
One of them is a fake 3D view built on the basis of a common line chart. This 3D is not really 3D, but it is also very useful. It is very stupid to use it to draw a waterfall chart, and the effect is very good.
The other two 3D views are real 3D, and OpenGL is used. The first is a 3D line chart and the second is a 3D Surface Chart.
Currently, 3D curved surface images have some disadvantages, mainly because they are stupid and unfamiliar with OpenGL. I am so stupid that I want to use texture maps to change the color of the surface, but I am not doing well yet, so I won't be ugly here. It would be appreciated if the student could help to set the surface color with the zcoordinate.
This lesson introduces the 3D line chart, which is still an example.
Follow the method in Lesson 1 to create a VC6 project Lesson14.
Because a math library is used, header file references are added to the Lesson14.cpp header.
#include <math.h>
The following is the response routine for WM_CREATE.
Case WM_CREATE: chartWnd. attach (hWnd, kType3DLine); {int I; int nNum = 1080; double * pX, * pY, * pZ; pX = new double [nNum]; pY = new double [nNum]; pZ = new double [nNum]; for (I = 0; I <nNum; I ++) {pX [I] = 2.0*3.1415926536 * I/nNum * 5; pY [I] = cos (pX [I]); pZ [I] = sin (pX [I]);} chartWnd. getChart ()-> AddCurve (pX, pY, pZ, nNum); for (I = 0; I <nNum; I ++) {pX [I] = (I-nNum/2.0)/nNum * 2.0; pY [I] = pX [I] * pX [I]; pZ [I] = pY [I] * pX [I];} chartWnd. getChart ()-> AddCurve (pX, pY, pZ, nNum); delete [] pX; delete [] pY; delete [] pZ;} chartWnd. getChart ()-> SetTitle (_ TEXT ("test 3D curve"); break;
Run the program.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130919173235171? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
Because it is a real 3D image implemented by OpenGL, you can drag the image with the mouse to see the 3D effect, which is a certain State during the drag process.
650) this. width = 650; "src =" http://img.blog.csdn.net/20130919173302843? Watermark/2/text/plain =/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA =/dissolve/70/gravity/SouthEast "alt =" SouthEast "/>
We can see that all the images and texts are suspended in space, and the coordinate plane is not transparent.
This section briefly introduces the 3D view function of CChart.