// FILE: lines.c #include #include "intern.h" #include "globals.h" #include "gdi3D.h" #include "helpers.h" /* PROJECT: GDI3D DLL PROGRAMMER(S): Pasi Paavola COMPILER: Microsoft C/C++ 7.0 ENVIRONMENT: Windows 3.1 running on 386/33/SuperVGA/no 80x87; 386 enhanced mode ROUTINES: Line drawing & moving routines */ //////////////////////////////////////////////////////////////////////////// /* G3MoveTo() moves the current position to the position specified by the point pointed by argument lpG3Point. Parameter Description lpG3Point Far pointer to the 3D point Returns: Return value contains the previous position (x in low word, y in high word). The return value is in output window coordinates. Comments */ //////////////////////////////////////////////////////////////////////////// DWORD WINAPI_LIB G3MoveTo(LPG3POINT lpG3Point) { POINT p; p = G3ToViewport(lpG3Point->x, lpG3Point->y, lpG3Point->z); return MoveTo(GhDC, p.x, p.y); } //////////////////////////////////////////////////////////////////////////// /* G3LineTo() draws a line from the current position to the position specified by the point pointed by argument lpG3Point. Parameter Description lpG3Point Far pointer to the destination 3D point Returns TRUE, if successful, otherwise FALSE Comments */ //////////////////////////////////////////////////////////////////////////// BOOL WINAPI_LIB G3LineTo(LPG3POINT lpG3Point) { POINT p; p = G3ToViewport(lpG3Point->x, lpG3Point->y, lpG3Point->z); return LineTo(GhDC, p.x, p.y); } //////////////////////////////////////////////////////////////////////////// /* G3Box() draws a box in 3D. The edges of the box are always parallel to some of the axes. All edges are drawn (no hidden line removal). Parameter Description x1, x2 Limits in x-direction y1, y2 Limits in y-direction z1, z2 Limits in z-direction Returns Comments */ //////////////////////////////////////////////////////////////////////////// VOID WINAPI_LIB G3Box(double x1, double x2, double y1, double y2, double z1, double z2) { POINT c1, c2, c3, c4, c5, c6, c7, c8; // Corner points // Generate 8 corner points c1 = G3ToViewport(x2, y1, z1); c2 = G3ToViewport(x2, y2, z1); c3 = G3ToViewport(x1, y2, z1); c4 = G3ToViewport(x1, y1, z1); c5 = G3ToViewport(x2, y1, z2); c6 = G3ToViewport(x2, y2, z2); c7 = G3ToViewport(x1, y2, z2); c8 = G3ToViewport(x1, y1, z2); // Draw necessary lines MoveTo(GhDC, c1.x, c1.y); LineTo(GhDC, c2.x, c2.y); LineTo(GhDC, c6.x, c6.y); LineTo(GhDC, c5.x, c5.y); LineTo(GhDC, c1.x, c1.y); LineTo(GhDC, c4.x, c4.y); LineTo(GhDC, c3.x, c3.y); LineTo(GhDC, c7.x, c7.y); LineTo(GhDC, c8.x, c8.y); LineTo(GhDC, c4.x, c4.y); MoveTo(GhDC, c2.x, c2.y); LineTo(GhDC, c3.x, c3.y); MoveTo(GhDC, c6.x, c6.y); LineTo(GhDC, c7.x, c7.y); MoveTo(GhDC, c5.x, c5.y); LineTo(GhDC, c8.x, c8.y); }