#include <moldpers.h>
Inheritance diagram for GPerspective:
Public Member Functions | |
GPerspective () | |
virtual BOOL | Redefine (POINT *P) |
virtual void | CopyShape (POINT *P) |
virtual BOOL | FitPath (CONST POINT *IPoints, CONST BYTE *ITypes, DWORD ILength, LPPOINT OPoints, LPBYTE OTypes, DWORD OLength, BOOL Close=FALSE) |
BOOL | Valid () |
BOOL | WhichVanishingPoint (POINT v, BOOL &b) |
void | VanishingPoints (POINT &a, POINT &b) |
INT32 | GetVPointState () |
void | DragVanishingPoints (POINT &NewI, BOOL Flag, LPPOINT P) |
Private Member Functions | |
virtual void | ScaleView () |
virtual void | CalcViewBBox () |
virtual void | CalcViewConsts () |
virtual void | Transform (DPOINT a, DPOINT &b) |
void | Intersect (DPOINT I, DPOINT P0, DPOINT P1, DPOINT P2, POINT &O) |
Private Attributes | |
POINT | P0 |
POINT | P1 |
POINT | P2 |
POINT | P3 |
DPOINT | V0 |
DPOINT | V1 |
DPOINT | V2 |
DPOINT | V3 |
BOOL | I0flag |
BOOL | I1flag |
BOOL | I0pos |
BOOL | I1pos |
DPOINT | I0 |
DPOINT | I1 |
DPOINT | A |
DPOINT | B |
Definition at line 128 of file moldpers.h.
|
Definition at line 1778 of file moldpers.cpp. 01779 { 01780 // Initialise the perspective with sensible values 01781 P0.x = 0; P0.y = 0; 01782 P1.x = 0; P1.y = 1; 01783 P2.x = 1; P2.y = 1; 01784 P3.x = 1; P3.y = 0; 01785 01786 ScaleView(); 01787 CalcViewConsts(); 01788 }
|
|
Implements GMould. Definition at line 1811 of file moldpers.cpp. 01812 { 01813 MinX = MaxX = P0.x ; 01814 MinY = MaxY = P0.y ; 01815 MinX = min( MinX, INT32(P1.x) ) ; MaxX = max( MaxX, INT32(P1.x) ) ; 01816 MinY = min( MinY, INT32(P1.y) ) ; MaxY = max( MaxY, INT32(P1.y) ) ; 01817 MinX = min( MinX, INT32(P2.x) ) ; MaxX = max( MaxX, INT32(P2.x) ) ; 01818 MinY = min( MinY, INT32(P2.y) ) ; MaxY = max( MaxY, INT32(P2.y) ) ; 01819 MinX = min( MinX, INT32(P3.x) ) ; MaxX = max( MaxX, INT32(P3.x) ) ; 01820 MinY = min( MinY, INT32(P3.y) ) ; MaxY = max( MaxY, INT32(P3.y) ) ; 01821 Width = MaxX-MinX ; 01822 Depth = MaxY-MinY ; 01823 }
|
|
Implements GMould. Definition at line 1840 of file moldpers.cpp. 01841 { 01842 // Calculate the view constants 01843 double N, D ; 01844 D = (V1.y-V0.y)*(V2.x-V3.x) - (V1.x-V0.x)*(V2.y-V3.y) ; 01845 01846 if (( I0flag = (fabs(D) >= EPSILON) )) 01847 { 01848 N = (V3.y-V0.y)*(V2.x-V3.x) - (V3.x-V0.x)*(V2.y-V3.y) ; 01849 I0pos = (N<0.0) ^ (D<0.0) ; 01850 I0.x = V0.x+(V1.x-V0.x)*N/D ; 01851 I0.y = V0.y+(V1.y-V0.y)*N/D ; 01852 A.x = (V0.x-I0.x)*(V1.x-I0.x) ; 01853 A.y = (V0.y-I0.y)*(V1.y-I0.y) ; 01854 B.x = (V3.x-I0.x)*(V2.x-I0.x) ; 01855 B.y = (V3.y-I0.y)*(V2.y-I0.y) ; 01856 } 01857 01858 D = (V0.y-V3.y)*(V1.x-V2.x) - (V0.x-V3.x)*(V1.y-V2.y) ; 01859 01860 if (( I1flag = (fabs(D) >= EPSILON) )) 01861 { 01862 N = (V2.y-V3.y)*(V1.x-V2.x) - (V2.x-V3.x)*(V1.y-V2.y) ; 01863 I1pos = (N<0.0) ^ (D<0.0) ; 01864 I1.x = V3.x+(V0.x-V3.x)*N/D ; 01865 I1.y = V3.y+(V0.y-V3.y)*N/D ; 01866 } 01867 }
|
|
Implements GMould. Definition at line 1871 of file moldpers.cpp. 01872 { 01873 P[0].x = P0.x ; P[0].y = P0.y ; 01874 P[1].x = P1.x ; P[1].y = P1.y ; 01875 P[2].x = P2.x ; P[2].y = P2.y ; 01876 P[3].x = P3.x ; P[3].y = P3.y ; 01877 }
|
|
Definition at line 1949 of file moldpers.cpp. 01950 { 01951 DPOINT I ; 01952 Scale( NewI, I ) ; 01953 if ( !Flag ) 01954 if ( !I0pos ) 01955 { 01956 Intersect( I, V0, V1, V2, P[1] ) ; 01957 Intersect( I, V3, V1, V2, P[2] ) ; 01958 } 01959 else 01960 { 01961 Intersect( I, V1, V0, V3, P[0] ) ; 01962 Intersect( I, V2, V0, V3, P[3] ) ; 01963 } 01964 else 01965 if ( I1pos ) 01966 { 01967 Intersect( I, V0, V3, V2, P[3] ) ; 01968 Intersect( I, V1, V3, V2, P[2] ) ; 01969 } 01970 else 01971 { 01972 Intersect( I, V3, V0, V1, P[0] ) ; 01973 Intersect( I, V2, V0, V1, P[1] ) ; 01974 } 01975 }
|
|
Implements GMould. Definition at line 1980 of file moldpers.cpp. 01989 { 01990 OPoints = pOPoints ; 01991 OTypes = pOTypes ; 01992 OLength = pOLength ; 01993 01994 DPOINT C2, C4 ; 01995 DPOINT P0, P2, P4, P6 ; 01996 DPOINT T0, T2, T4, T6 ; 01997 while ( ILength ) 01998 { 01999 switch ( *ITypes & PT_MOVETO ) 02000 { 02001 case PT_MOVETO : 02002 case PT_LINETO : 02003 --ILength ; 02004 ScaleSrc( *IPoints++, P0 ) ; 02005 Transform( P0, T0 ) ; 02006 if ( !GenOp( *ITypes++, T0 ) ) return -1 ; 02007 break ; 02008 case PT_BEZIERTO : 02009 ILength -= 3 ; 02010 ScaleSrc( *IPoints++, C2 ) ; 02011 ScaleSrc( *IPoints++, C4 ) ; 02012 ScaleSrc( *IPoints++, P6 ) ; 02013 P2.x = (8*P0.x+12*C2.x+ 6*C4.x+ P6.x)/27 ; 02014 P2.y = (8*P0.y+12*C2.y+ 6*C4.y+ P6.y)/27 ; 02015 P4.x = ( P0.x+ 6*C2.x+12*C4.x+8*P6.x)/27 ; 02016 P4.y = ( P0.y+ 6*C2.y+12*C4.y+8*P6.y)/27 ; 02017 Transform( P2, T2 ) ; 02018 Transform( P4, T4 ) ; 02019 Transform( P6, T6 ) ; 02020 if ( !GenCurve( C2, C4, P0, P2, P4, P6, T0, T2, T4, T6 ) ) return -1 ; 02021 P0.x = P6.x ; P0.y = P6.y ; 02022 T0.x = T6.x ; T0.y = T6.y ; 02023 ITypes += 3 ; 02024 *(OTypes-1) = *(ITypes-1) ; 02025 break ; 02026 default : 02027 return -1 ; 02028 } 02029 } 02030 if ( ILength ) 02031 return -1 ; 02032 return pOLength-OLength ; 02033 }
|
|
Definition at line 1927 of file moldpers.cpp. 01928 { 01929 INT32 num=0; 01930 if (I0pos) num+=1; 01931 if (I1pos) num+=2; 01932 return num; 01933 }
|
|
Definition at line 2081 of file moldpers.cpp. 02082 { 02083 double N, D ; 02084 DPOINT T ; 02085 N = (P1.y-P0.y)*(P2.x-P1.x) - (P1.x-P0.x)*(P2.y-P1.y) ; 02086 D = ( I.y-P0.y)*(P2.x-P1.x) - ( I.x-P0.x)*(P2.y-P1.y) ; 02087 T.x = P0.x+(I.x-P0.x)*N/D ; 02088 T.y = P0.y+(I.y-P0.y)*N/D ; 02089 InverseScale( T, O ) ; 02090 }
|
|
Implements GMould. Definition at line 1791 of file moldpers.cpp. 01792 { 01793 // Read the four point perspective 01794 P0.x = P[0].x ; P0.y = P[0].y ; 01795 P1.x = P[1].x ; P1.y = P[1].y ; 01796 P2.x = P[2].x ; P2.y = P[2].y ; 01797 P3.x = P[3].x ; P3.y = P[3].y ; 01798 01799 // Calc the bounds of the perspective 01800 CalcViewBBox(); 01801 if (Width<1024) Width=1024; 01802 if (Depth<1024) Depth=1024; 01803 01804 ScaleView(); 01805 CalcViewConsts(); 01806 01807 return TRUE; 01808 }
|
|
Implements GMould. Definition at line 1826 of file moldpers.cpp. 01827 { 01828 // normalise the view 01829 V0.x = (double)(P0.x-MinX)/Width ; 01830 V0.y = (double)(P0.y-MinY)/Depth ; 01831 V1.x = (double)(P1.x-MinX)/Width ; 01832 V1.y = (double)(P1.y-MinY)/Depth ; 01833 V2.x = (double)(P2.x-MinX)/Width ; 01834 V2.y = (double)(P2.y-MinY)/Depth ; 01835 V3.x = (double)(P3.x-MinX)/Width ; 01836 V3.y = (double)(P3.y-MinY)/Depth ; 01837 }
|
|
Implements GMould. Definition at line 2037 of file moldpers.cpp. 02038 { 02039 DPOINT p, q ; 02040 p.x = V0.x ; 02041 p.y = V0.y ; 02042 q.x = V3.x ; 02043 q.y = V3.y ; 02044 if ( notequal(a.y,0) ) 02045 if ( I0flag ) 02046 { 02047 if ( notequal(V0.x,V1.x) ) 02048 p.x = I0.x+A.x/(a.y*(V0.x-V1.x)+V1.x-I0.x) ; 02049 if ( notequal(V0.y,V1.y) ) 02050 p.y = I0.y+A.y/(a.y*(V0.y-V1.y)+V1.y-I0.y) ; 02051 if ( notequal(V3.x,V2.x) ) 02052 q.x = I0.x+B.x/(a.y*(V3.x-V2.x)+V2.x-I0.x) ; 02053 if ( notequal(V3.y,V2.y) ) 02054 q.y = I0.y+B.y/(a.y*(V3.y-V2.y)+V2.y-I0.y) ; 02055 } 02056 else 02057 { 02058 p.x = V0.x+a.y*(V1.x-V0.x) ; 02059 p.y = V0.y+a.y*(V1.y-V0.y) ; 02060 q.x = V3.x+a.y*(V2.x-V3.x) ; 02061 q.y = V3.y+a.y*(V2.y-V3.y) ; 02062 } 02063 b.x = p.x ; 02064 b.y = p.y ; 02065 if ( notequal(a.x,0) ) 02066 if ( I1flag ) 02067 { 02068 if ( notequal(p.x,q.x) ) 02069 b.x = I1.x+(p.x-I1.x)*(q.x-I1.x)/(a.x*(p.x-q.x)+q.x-I1.x) ; 02070 if ( notequal(p.y,q.y) ) 02071 b.y = I1.y+(p.y-I1.y)*(q.y-I1.y)/(a.x*(p.y-q.y)+q.y-I1.y) ; 02072 } 02073 else 02074 { 02075 b.x = p.x+a.x*(q.x-p.x) ; 02076 b.y = p.y+a.x*(q.y-p.y) ; 02077 } 02078 }
|
|
Definition at line 1881 of file moldpers.cpp. 01882 { 01883 BOOL F = ( 01884 ((V0.x==V1.x) && (V0.y==V1.y)) || 01885 ((V1.x==V2.x) && (V1.y==V2.y)) || 01886 ((V2.x==V3.x) && (V2.y==V3.y)) || 01887 ((V3.x==V0.x) && (V3.y==V0.y)) 01888 ); 01889 01890 if (F) return FALSE; 01891 01892 F = (V1.x-V0.x)*(V3.y-V0.y) > (V1.y-V0.y)*(V3.x-V0.x) ; 01893 if ( F != ((V2.x-V1.x)*(V0.y-V1.y) > (V2.y-V1.y)*(V0.x-V1.x)) ) return FALSE ; 01894 if ( F != ((V3.x-V2.x)*(V1.y-V2.y) > (V3.y-V2.y)*(V1.x-V2.x)) ) return FALSE ; 01895 if ( F != ((V0.x-V3.x)*(V2.y-V3.y) > (V0.y-V3.y)*(V2.x-V3.x)) ) return FALSE ; 01896 return TRUE ; 01897 }
|
|
Definition at line 1935 of file moldpers.cpp. 01936 { 01937 if ( I0flag ) 01938 InverseScale( I0, a ) ; 01939 else 01940 a.x = a.y = 0x80000000 ; 01941 if ( I1flag ) 01942 InverseScale( I1, b ) ; 01943 else 01944 b.x = b.y = 0x80000000 ; 01945 }
|
|
Definition at line 1900 of file moldpers.cpp. 01901 { 01902 if (I0flag) 01903 { 01904 POINT a; 01905 InverseScale(I0,a); 01906 if (a.x==v.x && a.y==v.y) 01907 { 01908 b=FALSE; 01909 return TRUE; 01910 } 01911 } 01912 01913 if (I1flag) 01914 { 01915 POINT a; 01916 InverseScale(I1,a); 01917 if (a.x==v.x && a.y==v.y) 01918 { 01919 b=TRUE; 01920 return TRUE; 01921 } 01922 } 01923 return FALSE; 01924 }
|
|
Definition at line 165 of file moldpers.h. |
|
Definition at line 165 of file moldpers.h. |
|
Definition at line 164 of file moldpers.h. |
|
Definition at line 162 of file moldpers.h. |
|
Definition at line 163 of file moldpers.h. |
|
Definition at line 164 of file moldpers.h. |
|
Definition at line 162 of file moldpers.h. |
|
Definition at line 163 of file moldpers.h. |
|
Definition at line 160 of file moldpers.h. |
|
Definition at line 160 of file moldpers.h. |
|
Definition at line 160 of file moldpers.h. |
|
Definition at line 160 of file moldpers.h. |
|
Definition at line 161 of file moldpers.h. |
|
Definition at line 161 of file moldpers.h. |
|
Definition at line 161 of file moldpers.h. |
|
Definition at line 161 of file moldpers.h. |