home *** CD-ROM | disk | FTP | other *** search
- //
- // File name: Panel3D.HPP
- //
- // Description: Header file for a 3D panel class
- //
- // Author: John De Goes
- //
- // Project: Cutting Edge 3D Game Programming
- //
-
- #ifndef POINT3DHPP
- #define POINT3DHPP
- #include "Point3D.HPP"
- #endif
-
- #ifndef POINT2DHPP
- #define POINT2DHPP
- #include "Point2D.HPP"
- #endif
-
- #ifndef VECTOR3DHPP
- #define VECTOR3DHPP
- #include "Vector3D.HPP"
- #endif
-
- #ifndef DETAIL3DHPP
- #define DETAIL3DHPP
- #include "Detail3D.HPP"
- #endif
-
- #ifndef ATYPESHPP
- #define ATYPESHPP
- #include "ATypes.HPP"
- #endif
-
- #ifndef POLYEDGEHPP
- #define POLYEDGEHPP
- #include "PolyEdge.HPP"
- #endif
-
- #ifndef MATRIX3DHPP
- #define MATRIX3DHPP
- #include "Matrix3D.HPP"
- #endif
-
- #ifndef TEXTTYPEHPP
- #define TEXTTYPEHPP
- #include "TextType.HPP"
- #endif
-
- #include <Dos.H>
-
- // Forward declaration:
- class PanelObject;
-
- // The panel class:
- class Panel3D {
- protected: // Data is protected
- // Functions:
- void CalcRadius (); // Calculates panel radius
- long CalcCenterZ (); // Calculates center Z
- int inline CalcBFace (); // Determines if panel is backface
- void CalcNormal (); // Calculates the panel normal
- int CheckExtents (); // Determines if panel lies within
- // the Z extents
- int CalcVisible3D (); // Determines panel's visibility
- // in 3D
- int CalcVisible2D (); // Determines panel's visibility
- // in 2D
- void DisplaySel ( unsigned char *Dest );
- void DisplayNorm ( unsigned char *Dest );
- // Data:
- Point3D *VPoint [ 4 ]; // 4 pointers to a vertex list
- Detail3D Attrib [ 4 ]; // The panel's detail attributes
- Vector Normal; // The panel normal
- Point2D SPoint [ 5 ]; // Maximum of 5 on-screen points
- WORD SPCount, Invis; // Screen point count & invisible flag
- BYTE Color, TextHan; // The panel color * texture handle
- BYTE A, Pad1;
- double Radius; // The panel's radius
- public: // Data is public
- Panel3D () { A = Color = Invis = 0; } // Constructor:
- void Update ( Matrix3D &M ); // Update normal and misc. information
- void Display ( unsigned char *Dest )
- {
- if ( A )
- DisplaySel ( Dest );
- else
- DisplayNorm ( Dest );
- }
- void Project (); // Project panel onto screen
- void InitPosition () { CalcNormal (); CalcRadius (); } // Performs initialization
- void CalcInten (); // Calculates panel's intensity
- int Invisible () { return Invis; } // Determine invisibility
- int IsVisible2D () { return CalcVisible2D (); } // Determine visibility in 3D
- int IsVisible3D () { return CalcVisible3D (); } // Determine visibility in 2D
-
- friend class PanelObject; // Declare a friend class
-
- int HasVert ( Point3D &P )
- {
- if ( ( *VPoint [ 0 ] ) == P )
- return 1;
- if ( ( *VPoint [ 1 ] ) == P )
- return 1;
- if ( ( *VPoint [ 2 ] ) == P )
- return 1;
- if ( ( *VPoint [ 3 ] ) == P )
- return 1;
- return 0;
- }
-
- void Select () { A = 10; }
- void Deselect () { A = 0; }
- BYTE GetState () { return A; }
- void NexText ()
- {
- TextHan = ( BYTE ) ( ( TextHan + 1 ) % TextDat.TCount );
- }
- void RotText ()
- {
- Detail3D Temp;
- Temp = Attrib [ 0 ];
- Attrib [ 0 ] = Attrib [ 1 ];
- Attrib [ 1 ] = Attrib [ 2 ];
- Attrib [ 2 ] = Attrib [ 3 ];
- Attrib [ 3 ] = Temp;
- }
- };
-