Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //----------------------
- #include <windows.h>
- #include <tchar.h>
- #include <cmath>
- #include <math.h>
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- TCHAR WinName[] = _T("MainFrame");
- //---------------------
- int APIENTRY WinMain(HINSTANCE This, HINSTANCE Prev, LPSTR cmd, int mode)
- {
- HWND hWnd;
- MSG msg;
- WNDCLASS wc;
- wc.hInstance = This;
- wc.lpszClassName = WinName;
- wc.lpfnWndProc = WndProc;
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor (NULL, IDC_ARROW);
- wc.lpszMenuName = NULL;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- if (!RegisterClass(&wc)) return 0;
- hWnd = CreateWindow(WinName, _T("Каркас Windows-приложения"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP,
- NULL,
- This,
- NULL);
- ShowWindow(hWnd, mode);
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
- LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- PAINTSTRUCT ps;
- const int WIDTH = 400;
- const int HEIGHT = 300;
- float v11, v12, v13, v21, v22, v23, v31, v32, v33, v43;
- float rho = 300.,thetta = 75., phi = 30., ScreenDist = 500.;
- float A, B, C, D, An, Bn, Cn;
- float xt[3], yt[3], zt[3];
- float Al, Bl, Cl;
- float alpha;
- float th, ph, costh, cosph, sinth, sinph;
- float factor = atan(1.0)/45.;
- static HBRUSH hBrush;
- class TFPoint {
- public:
- float X;
- float Y;
- float Z;
- };
- TFPoint CubePoints[]= {
- {-50, -50, -50}
- {50, -50, -50}
- {50, 50, -50}
- {-50, 50, -50}
- {-50, 50, 50}
- {-50, -50, 50}
- {50, -50, 50}
- {50, 50, 50}
- };
- int Gran [6][4]= {
- {0,3,4,5}
- {0,5,6,1}
- {2,7,4,3}
- {7,6,5,4}
- {0,1,2,3}
- {2,1,6,7}
- };
- void VidMatCoeff (float rho,float thetta, float phi);
- {
- th = thetta * factor;
- ph = phi * factor;
- costh = cos(th);
- sinth = sin(th);
- cosph = cos (ph);
- sinph = sin (ph);
- v11 = -sinth; v12 = -cosph * costh; v13 = -sinph * costh;
- v21 = costh; v22 = -cosph * sinth; v23 = -sinph * sinth;
- v31 = 0; v32 = sinph; v33 = -cosph;
- v43 = rho;
- }
- POINT Perspective (float x, float y, float z) {
- POINT point;
- float xe, ye, ze;
- VidMatCoeff (rho, thetta, phi);
- xe = v11 * x + v21 * y;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement