Changeset 80 for Include


Ignore:
Timestamp:
Jan 31, 2007, 6:31:44 AM (18 years ago)
Author:
NoWest
Message:

update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/abgl.ab

    r78 r80  
    1717Class Vector2f
    1818Public /* constructor */
     19    Sub Vector2f()
     20        This.X=0.0 As GLfloat
     21        This.Y=0.0 As GLfloat
     22    End Sub
    1923    Sub Vector2f(x As GLfloat, y As GLfloat)
    2024        This.X=x
     
    4145
    4246Public /* operator */
    43     Sub Operator = (ByRef vec As Vector2f)
    44         This.X=vec.X
    45         This.Y=vec.Y
    46     End Sub
    47     Function Operator + (ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
    48         Return Add(vec1,vec2)
    49     End Function
    50     Function Operator - (ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
    51         Return Substract(vec1,vec2)
    52     End Function
    53 /*  Function Operator * (vec1 As Vector2f, vec2 As Vector2f) As Vector2f
    54         Return Dot(vec1,vec2)
     47    Sub Operator = (ByRef SrcVec As Vector2f)
     48        This.X=SrcVec.X
     49        This.Y=SrcVec.Y
     50    End Sub
     51    Function Operator + (SrcVec As Vector2f) As Vector2f
     52        Return Add(This,SrcVec)
     53    End Function
     54    Function Operator - (SrcVec As Vector2f) As Vector2f
     55        Return Substract(This,SrcVec)
     56    End Function
     57/*  Function Operator * (SrcVec As Vector2f) As Vector2f
     58        Return Dot(This,SrcVec)
    5559    End Function
    5660*/
    57     Function Operator * (ByRef vec As Vector2f, sca As GLfloat) As Vector2f
    58         Dim ret As Vector2f(vec.X*sca,vec.Y*sca)
    59         Return ret
    60     End Function
    61     Function Operator / (ByRef vec As Vector2f, sca As GLfloat) As Vector2f
    62         Dim ret As Vector2f(vec.X/sca,vec.Y/sca)
     61    Function Operator * (Src As GLint) As Vector2f
     62        Dim ret As Vector2f(This.X*Src,This.Y*Src)
     63        Return ret
     64    End Function
     65    Function Operator * (Src As GLfloat) As Vector2f
     66        Dim ret As Vector2f(This.X*Src,This.Y*Src)
     67        Return ret
     68    End Function
     69    Function Operator * (Src As GLdouble) As Vector2f
     70        Dim ret As Vector2f(This.X*Src As GLfloat,This.Y*Src As GLfloat)
     71        Return ret
     72    End Function
     73    Function Operator / (Src As GLint) As Vector2f
     74        Dim ret As Vector2f(This.X/Src,This.Y/Src)
     75        Return ret
     76    End Function
     77    Function Operator / (Src As GLfloat) As Vector2f
     78        Dim ret As Vector2f(This.X/Src,This.Y/Src)
     79        Return ret
     80    End Function
     81    Function Operator / (Src As GLdouble) As Vector2f
     82        Dim ret As Vector2f(This.X/Src,This.Y/Src)
    6383        Return ret
    6484    End Function
     
    6686
    6787Public /* method */
    68     Function Add(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
    69         Dim ret As Vector2f(vec1.X+vec2.X,vec1.Y+vec2.Y)
    70         Return ret
    71     End Function
    72     Function Distance(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As GLfloat
     88    Static Function Add(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As Vector2f
     89        Dim ret As Vector2f(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y)
     90        Return ret
     91    End Function
     92    Static Function Distance(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As GLfloat
    7393        Dim ret As Vector2f
    74         ret=vec1-vec2
     94        ret=SrcVec1-SrcVec2
    7595        Return ret.Magnitude
    7696    End Function
    77     Function Dot(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As GLfloat
    78         Return vec1.X*vec2.X+vec1.Y*vec2.Y
     97    Static Function Dot(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As GLfloat
     98        Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y
    7999    End Function
    80100    Function Magnitude() As GLfloat
     
    89109        Return ret
    90110    End Function
    91     Function Substract(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
    92         Dim ret As Vector2f(vec1.X-vec2.X,vec1.Y-vec2.Y)
     111    Static Function Substract(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As Vector2f
     112        Dim ret As Vector2f(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y)
    93113        Return ret
    94114    End Function
     
    108128Class Vector2d
    109129Public /* constructor */
     130    Sub Vector2d()
     131        This.X=0.0 As GLdouble
     132        This.Y=0.0 As GLdouble
     133    End Sub
    110134    Sub Vector2d(x As GLdouble, y As GLdouble)
    111135        xy.x=x
     
    132156
    133157Public /* operator */
    134     Sub Operator = (ByRef vec As Vector2d)
    135         This.X=vec.X
    136         This.Y=vec.Y
    137     End Sub
    138     Function Operator + (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
    139         Return Add(vec1,vec2)
    140     End Function
    141     Function Operator - (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
    142         Return Substract(vec1,vec2)
    143     End Function
    144 /*  Function Operator * (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
    145         Return Dot(vec1,vec2)
     158    Sub Operator = (ByRef SrcVec As Vector2d)
     159        This.X=SrcVec.X
     160        This.Y=SrcVec.Y
     161    End Sub
     162    Function Operator + (SrcVec As Vector2d) As Vector2d
     163        Return Add(This,SrcVec2)
     164    End Function
     165    Function Operator - (SrcVec As Vector2d) As Vector2d
     166        Return Substract(This,SrcVec2)
     167    End Function
     168/*  Function Operator * (SrcVec As Vector2d) As Vector2d
     169        Return Dot(This,SrcVec2)
    146170    End Function*/
    147171
    148     Function Operator * (vec As Vector2d, sca As GLfloat) As Vector2d
    149         Dim ret As Vector2d(vec.X*sca,vec.Y*sca)
    150         Return ret
    151     End Function
    152     Function Operator / (vec As Vector2d, sca As GLfloat) As Vector2d
    153         Dim ret As Vector2d(vec.X/sca,vec.Y/sca)
     172    Function Operator * (Src As GLint) As Vector2d
     173        Dim ret As Vector2d(This.X*Src,SrcVec.Y*Src)
     174        Return ret
     175    End Function
     176    Function Operator * (Src As GLfloat) As Vector2d
     177        Dim ret As Vector2d(This.X*Src,SrcVec.Y*Src)
     178        Return ret
     179    End Function
     180    Function Operator * (Src As GLdouble) As Vector2d
     181        Dim ret As Vector2d(This.X*Src,SrcVec.Y*Src)
     182        Return ret
     183    End Function
     184    Function Operator / (Src As GLint) As Vector2d
     185        Dim ret As Vector2d(This.X/Src,SrcVec.Y/Src)
     186        Return ret
     187    End Function
     188    Function Operator / (Src As GLfloat) As Vector2d
     189        Dim ret As Vector2d(This.X/Src,SrcVec.Y/Src)
     190        Return ret
     191    End Function
     192    Function Operator / (Src As GLdouble) As Vector2d
     193        Dim ret As Vector2d(This.X/Src,SrcVec.Y/Src)
    154194        Return ret
    155195    End Function
     
    157197
    158198Public /* method */
    159     Function Add(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
    160         Dim ret As Vector2d(vec1.X+vec2.X,vec1.Y+vec2.Y)
    161         Return ret
    162     End Function
    163     Function Distance(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As GLdouble
     199    Function Add(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As Vector2d
     200        Dim ret As Vector2d(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y)
     201        Return ret
     202    End Function
     203    Function Distance(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As GLdouble
    164204        Dim ret As Vector2d
    165         ret=vec1-vec2
     205        ret=SrcVec1-SrcVec2
    166206        Return ret.Magnitude
    167207    End Function
    168     Function Dot(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As GLdouble
    169         Return vec1.X*vec2.X+vec1.Y*vec2.Y
     208    Function Dot(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As GLdouble
     209        Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y
    170210    End Function
    171211    Function Magnitude() As GLdouble
     
    180220        Return ret
    181221    End Function
    182     Function Substract(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
    183         Dim ret As Vector2d(vec1.X-vec2.X,vec1.Y-vec2.Y)
     222    Function Substract(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As Vector2d
     223        Dim ret As Vector2d(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y)
    184224        Return ret
    185225    End Function
     
    193233    End Function
    194234
    195 Protected
     235Public
    196236    xz As XY_DOUBLE
    197237End Class
     
    212252Class Vector3f
    213253Public /* constructor */
     254    Sub Vector3f()
     255        This.X=0.0 As GLfloat
     256        This.Y=0.0 As GLfloat
     257        This.Z=0.0 As GLfloat
     258    End Sub
    214259    Sub Vector3f(x As GLfloat, y As GLfloat, z As GLfloat)
    215260        xyz.x=x
     
    243288
    244289Public /* operator */
    245     Sub Operator = (vec As Vector3f)
    246         This.X=vec.X
    247         This.Y=vec.Y
    248     End Sub
    249     Function Operator + (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
    250         Return Add(vec1,vec2)
    251     End Function
    252     Function Operator - (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
    253         Return Substract(vec1,vec2)
    254     End Function
    255 /*  Function Operator * (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
    256         Return Dot(vec1,vec2)
     290    Sub Operator = (ByRef SrcVec As Vector3f)
     291        This.X=SrcVec.X
     292        This.Y=SrcVec.Y
     293    End Sub
     294    Function Operator + (SrcVec As Vector3f) As Vector3f
     295        Return Add(This,SrcVec)
     296    End Function
     297    Function Operator - (SrcVec As Vector3f) As Vector3f
     298        Return Substract(This,SrcVec)
     299    End Function
     300/*  Function Operator * (SrcVec As Vector3f) As Vector3f
     301        Return Dot(This,SrcVec)
    257302    End Function*/
    258     Function Operator ^ (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
    259         Return Cross(vec1,vec2)
    260     End Function
    261 
    262     Function Operator * (vec As Vector3f, sca As GLfloat) As Vector3f
    263         Dim ret As Vector3f(vec.X*sca,vec.Y*sca)
    264         Return ret
    265     End Function
    266     Function Operator / (vec As Vector3f, sca As GLfloat) As Vector3f
    267         Dim ret As Vector3f(vec.X/sca,vec.Y/sca)
     303    Function Operator ^ (SrcVec As Vector3f) As Vector3f
     304        Return Cross(This,SrcVec)
     305    End Function
     306
     307    Function Operator * (Src As GLint) As Vector3f
     308        Dim ret As Vector3f(This.X*Src,This.Y*Src,This.Z*Src)
     309        Return ret
     310    End Function
     311    Function Operator * (Src As GLfloat) As Vector3f
     312        Dim ret As Vector3f(This.X*Src,This.Y*Src,This.Z*Src)
     313        Return ret
     314    End Function
     315    Function Operator * (Src As GLdouble) As Vector3f
     316        Dim ret As Vector3f(This.X*Src,This.Y*Src,This.Z*Src)
     317        Return ret
     318    End Function
     319    Function Operator / (Src As GLint) As Vector3f
     320        Dim ret As Vector3f(This.X/Src,This.Y/Src,This.Z/Src)
     321        Return ret
     322    End Function
     323    Function Operator / (Src As GLfloat) As Vector3f
     324        Dim ret As Vector3f(This.X/Src,This.Y/Src,This.Z/Src)
     325        Return ret
     326    End Function
     327    Function Operator / (Src As GLdouble) As Vector3f
     328        Dim ret As Vector3f(This.X/Src,This.Y/Src,This.Z/Src)
    268329        Return ret
    269330    End Function
     
    271332
    272333Public /* method */
    273     Function Add(vec1 As Vector3f, vec2 As Vector3f) As Vector3f
    274         Dim ret As Vector3f(vec1.X+vec2.X,vec1.Y+vec2.Y,vec1.Z-vec2.Z)
    275         Return ret
    276     End Function
    277     Function Cross(vec1 As Vector3f, vec2 As Vector3f) As Vector3f
    278         Dim ret As Vector3f(vec1.Y*vec2.Z-vec1.Z*vec2.Y,vec1.Z*vec2.X-vec1.X*vec2.Z,vec1.X*vec2.Y-vec1.Y*vec2.X)
    279         Return ret
    280     End Function
    281     Function Distance(vec1 As Vector3f, vec2 As Vector3f) As GLfloat
     334    Function Add(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As Vector3f
     335        Dim ret As Vector3f(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y,SrcVec1.Z-SrcVec2.Z)
     336        Return ret
     337    End Function
     338    Function Cross(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As Vector3f
     339        Dim ret As Vector3f(SrcVec1.Y*SrcVec2.Z-SrcVec1.Z*SrcVec2.Y,SrcVec1.Z*SrcVec2.X-SrcVec1.X*SrcVec2.Z,SrcVec1.X*SrcVec2.Y-SrcVec1.Y*SrcVec2.X)
     340        Return ret
     341    End Function
     342    Function Distance(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As GLfloat
    282343        Dim ret As Vector3f
    283         ret=vec1-vec2
     344        ret=SrcVec1-SrcVec2
    284345        Return ret.Magnitude
    285346    End Function
    286     Function Dot(vec1 As Vector3f, vec2 As Vector3f) As GLfloat
    287         Return vec1.X*vec2.X+vec1.Y*vec2.Y+vec1.Z*vec2.Z
     347    Function Dot(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As GLfloat
     348        Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y+SrcVec1.Z*SrcVec2.Z
    288349    End Function
    289350    Function Magnitude() As GLfloat
     
    298359        Return ret
    299360    End Function
    300     Function Substract(vec1 As Vector3f, vec2 As Vector3f) As Vector3f
    301         Dim ret As Vector3f(vec1.X-vec2.X,vec1.Y-vec2.Y,vec1.Z-vec2.Z)
     361    Function Substract(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As Vector3f
     362        Dim ret As Vector3f(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y,SrcVec1.Z-SrcVec2.Z)
    302363        Return ret
    303364    End Function
     
    311372    End Function
    312373
    313 Protected
     374Public
    314375    xyz As XYZ_FLOAT
    315376End Class
     
    317378Class Vector3d
    318379Public /* constructor */
     380    Sub Vector3d()
     381        This.X=0.0 As GLdouble
     382        This.Y=0.0 As GLdouble
     383        This.Z=0.0 As GLdouble
     384    End Sub
    319385    Sub Vector3d(x As GLdouble, y As GLdouble, z As GLdouble)
    320386        xyz.x=x
     
    350416
    351417Public /* operator */
    352     Sub Operator = (vec As Vector3d)
    353         This.X=vec.X
    354         This.Y=vec.Y
    355     End Sub
    356     Function Operator + (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
    357         Return Add(vec1,vec2)
    358     End Function
    359     Function Operator - (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
    360         Return Substract(vec1,vec2)
    361     End Function
    362 /*  Function Operator * (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
    363         Return Dot(vec1,vec2)
     418    Sub Operator = (ByRef SrcVec As Vector3d)
     419        This.X=SrcVec.X
     420        This.Y=SrcVec.Y
     421    End Sub
     422    Function Operator + (SrcVec As Vector3d) As Vector3d
     423        Return Add(This,SrcVec)
     424    End Function
     425    Function Operator - (SrcVec As Vector3d) As Vector3d
     426        Return Substract(This,SrcVec)
     427    End Function
     428/*  Function Operator * (SrcVec As Vector3d) As Vector3d
     429        Return Dot(This,SrcVec)
    364430    End Function*/
    365     Function Operator ^ (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
    366         Return Cross(vec1,vec2)
    367     End Function
    368 
    369     Function Operator * (vec As Vector3d, sca As GLdouble) As Vector3d
    370         Dim ret As Vector3d(vec.X*sca,vec.Y*sca)
    371         Return ret
    372     End Function
    373     Function Operator / (vec As Vector3d, sca As GLdouble) As Vector3d
    374         Dim ret As Vector3d(vec.X/sca,vec.Y/sca)
     431    Function Operator ^ (SrcVec As Vector3d) As Vector3d
     432        Return Cross(This,SrcVec)
     433    End Function
     434
     435    Function Operator * (Src As GLint) As Vector3d
     436        Dim ret As Vector3d(This.X*Src,This.Y*Src,This.Z*Src)
     437        Return ret
     438    End Function
     439    Function Operator * (Src As GLfloat) As Vector3d
     440        Dim ret As Vector3d(This.X*Src,This.Y*Src,This.Z*Src)
     441        Return ret
     442    End Function
     443    Function Operator * (Src As GLdouble) As Vector3d
     444        Dim ret As Vector3d(This.X*Src,This.Y*Src,This.Z*Src)
     445        Return ret
     446    End Function
     447    Function Operator / (Src As GLint) As Vector3d
     448        Dim ret As Vector3d(This.X/Src,This.Y/Src,This.Z/Src)
     449        Return ret
     450    End Function
     451    Function Operator / (Src As GLfloat) As Vector3d
     452        Dim ret As Vector3d(This.X/Src,This.Y/Src,This.Z/Src)
     453        Return ret
     454    End Function
     455    Function Operator / (Src As GLdouble) As Vector3d
     456        Dim ret As Vector3d(This.X/Src,This.Y/Src,This.Z/Src)
    375457        Return ret
    376458    End Function
     
    378460
    379461Public /* method */
    380     Function Add(vec1 As Vector3d, vec2 As Vector3d) As Vector3d
    381         Dim ret As Vector3d(vec1.X+vec2.X,vec1.Y+vec2.Y,vec1.Z-vec2.Z)
    382         Return ret
    383     End Function
    384     Function Cross(vec1 As Vector3d, vec2 As Vector3d) As Vector3d
    385         Dim ret As Vector3d(vec1.Y*vec2.Z-vec1.Z*vec2.Y,vec1.Z*vec2.X-vec1.X*vec2.Z,vec1.X*vec2.Y-vec1.Y*vec2.X)
    386         Return ret
    387     End Function
    388     Function Distance(vec1 As Vector3d, vec2 As Vector3d) As GLdouble
     462    Function Add(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As Vector3d
     463        Dim ret As Vector3d(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y,SrcVec1.Z-SrcVec2.Z)
     464        Return ret
     465    End Function
     466    Function Cross(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As Vector3d
     467        Dim ret As Vector3d(SrcVec1.Y*SrcVec2.Z-SrcVec1.Z*SrcVec2.Y,SrcVec1.Z*SrcVec2.X-SrcVec1.X*SrcVec2.Z,SrcVec1.X*SrcVec2.Y-SrcVec1.Y*SrcVec2.X)
     468        Return ret
     469    End Function
     470    Function Distance(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As GLdouble
    389471        Dim ret As Vector3d
    390         ret=vec1-vec2
     472        ret=SrcVec1-SrcVec2
    391473        Return ret.Magnitude
    392474    End Function
    393     Function Dot(vec1 As Vector3d, vec2 As Vector3d) As GLdouble
    394         Return vec1.X*vec2.X+vec1.Y*vec2.Y+vec1.Z*vec2.Z
     475    Function Dot(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As GLdouble
     476        Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y+SrcVec1.Z*SrcVec2.Z
    395477    End Function
    396478    Function Magnitude() As GLdouble
     
    405487        Return ret
    406488    End Function
    407     Function Substract(vec1 As Vector3d, vec2 As Vector3d) As Vector3d
    408         Dim ret As Vector3d(vec1.X-vec2.X,vec1.Y-vec2.Y,vec1.Z-vec2.Z)
     489    Function Substract(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As Vector3d
     490        Dim ret As Vector3d(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y,SrcVec1.Z-SrcVec2.Z)
    409491        Return ret
    410492    End Function
     
    418500    End Function
    419501
    420 
    421 Protected
     502Public
    422503    xyz As XYZ_DOUBLE
    423504End Class
     
    456537    End Function
    457538    Function B() As GLfloat
    458         Return rgb.r
     539        Return rgb.b
    459540    End Function
    460541    Sub R(r As GLfloat)
     
    469550
    470551Public /* operator */
    471     Function operator () As Color3f
    472         Return This
    473     End Function
    474552    Sub operator = (c As Color3f)
    475553        This.R=c.R
     
    519597        Return ret
    520598    End Function
    521     Static Function FromHSB(h As GLfloat, s As GLfloat, v As GLfloat) As Color3f
     599    Static Function FromHSV(h As GLfloat, s As GLfloat, v As GLfloat) As Color3f
    522600        Dim r As GLfloat
    523601        Dim g As GLfloat
    524602        Dim b As GLfloat
    525603        If h<0 Then h+=360.0
    526         Select Case (h\60)
     604        If h>360.0 Then h-=360.0
     605        Select Case (h/60) As Long
    527606            Case 0
    528607                r=v
    529                 g=v*(1-s*(1-(h/60-h\60)))
     608                g=v*(1-s*(1-(h/60-(h/60) As Long)))
    530609                b=v*(1-s)
    531610            Case 1
    532                 r=v*(1-s*(h/60-h\60))
     611                r=v*(1-s*(h/60-(h/60) As Long))
    533612                g=v
    534613                b=v*(1-s)
     
    536615                r=v*(1-s)
    537616                g=v
    538                 b=v*(1-s*(1-(h/60-h\60)))
     617                b=v*(1-s*(1-(h/60-(h/60) As Long)))
    539618            Case 3
    540619                r=v*(1-s)
    541                 g=v*(1-s*(h/60-h\60))
     620                g=v*(1-s*(h/60-(h/60) As Long))
    542621                b=v
    543622            Case 4
    544                 r=v*(1-s*(1-(h/60-h\60)))
     623                r=v*(1-s*(1-(h/60-(h/60) As Long)))
    545624                g=v*(1-s)
    546625                b=v
     
    548627                r=v
    549628                g=v*(1-s)
    550                 b=v*(1-s*(h/60-h\60))
     629                b=v*(1-s*(h/60-(h/60) As Long))
     630            Case 6
     631                r=v
     632                g=v*(1-s*(1-(h/60-(h/60) As Long)))
     633                b=v*(1-s)
    551634        End Select
    552635
     
    555638    End Function
    556639
    557 Protected
     640Public
    558641    rgb As RGB_FLOAT
    559642End Class
     
    579662    End Function
    580663    Function B() As GLdouble
    581         Return rgb.r
     664        Return rgb.b
    582665    End Function
    583666    Sub R(r As GLdouble)
     
    591674    End Sub
    592675
    593 Protected
     676Public /* method */
     677    ' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にした
     678    ' Drawwing\Color.abをさらに参考にしました。
     679    Function GetHue() As GLdouble
     680        Dim max As GLdouble, min As GLdouble, d As GLdouble
     681        max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
     682        min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
     683        d = max - min
     684        If rgb.g = max Then
     685            Return ((rgb.b - rgb.r) As Double / d * 60.0 + 120.0) As GLfloat
     686        ElseIf rgb.b = max Then
     687            Return ((rgb.r - rgb.g) As Double / d * 60.0 + 240.0) As GLfloat
     688        ElseIf rgb.g < rgb.b Then
     689            Return ((rgb.g - rgb.b) As Double / d * 60.0 + 360.0) As GLfloat
     690        Else
     691            Return ((rgb.g - rgb.b) As Double / d * 60.0) As GLfloat
     692        EndIf
     693    End Function
     694
     695    Function GetSaturation() As GLdouble
     696        Dim max As GLdouble, min As GLdouble
     697        max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
     698        min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
     699        Return (max - min) / max
     700    End Function
     701
     702    Function GetVolue() As GLdouble
     703        Dim max As GLdouble
     704        max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
     705        Return max
     706    End Function
     707
     708Public /* static method */
     709    Static Function FromRGB(r As GLbyte, g As GLbyte, b As GLbyte) As Color3d
     710        Dim ret As Color3d(r/255,g/255,b/255)
     711        Return ret
     712    End Function
     713    Static Function FromCOLORREF(c As COLORREF) As Color3d
     714        Dim ret As Color3d((c and &hff)/255,(c>>8 and &hff)/255,(c>>16 and &hff)/255)
     715        Return ret
     716    End Function
     717    Static Function FromHSV(h As GLdouble, s As GLdouble, v As GLdouble) As Color3f
     718        Dim r As GLdouble
     719        Dim g As GLdouble
     720        Dim b As GLfloat
     721        If h<0 Then h+=360.0
     722        If h>360.0 Then h-=360.0
     723        Select Case (h/60) As Long
     724            Case 0
     725                r=v
     726                g=v*(1-s*(1-(h/60-(h/60) As Long)))
     727                b=v*(1-s)
     728            Case 1
     729                r=v*(1-s*(h/60-(h/60) As Long))
     730                g=v
     731                b=v*(1-s)
     732            Case 2
     733                r=v*(1-s)
     734                g=v
     735                b=v*(1-s*(1-(h/60-(h/60) As Long)))
     736            Case 3
     737                r=v*(1-s)
     738                g=v*(1-s*(h/60-(h/60) As Long))
     739                b=v
     740            Case 4
     741                r=v*(1-s*(1-(h/60-(h/60) As Long)))
     742                g=v*(1-s)
     743                b=v
     744            Case 5
     745                r=v
     746                g=v*(1-s)
     747                b=v*(1-s*(h/60-(h/60) As Long))
     748            Case 6
     749                r=v
     750                g=v*(1-s*(1-(h/60-(h/60) As Long)))
     751                b=v*(1-s)
     752        End Select
     753
     754        Dim ret As Color3d(r,g,b)
     755        Return ret
     756    End Function
     757Public
    594758    rgb As RGB_DOUBLE
    595759End Class
     
    630794    End Function
    631795    Function B() As GLfloat
    632         Return rgba.r
     796        Return rgba.b
    633797    End Function
    634798    Function A() As GLfloat
     
    648812    End Sub
    649813
    650 Protected
     814Public
    651815    rgba As RGBA_FLOAT
    652816End Class
     
    674838    End Function
    675839    Function B() As GLdouble
    676         Return rgba.r
     840        Return rgba.b
    677841    End Function
    678842    Function A() As GLdouble
     
    692856    End Sub
    693857
    694 Protected
     858Public
    695859    rgba As RGBA_DOUBLE
    696860End Class
     
    700864Class Light
    701865Private
    702     Number As GLenum
     866    Const Number As GLenum
    703867
    704868Public
     
    730894        glLightfv(Number,GL_AMBIENT,amb)
    731895    End Sub
    732     Sub SetAmbient(color As Color4f)
     896    Sub SetAmbient(ByRef color As Color4f)
    733897        Dim amb[3] As GLfloat
    734898        amb[0]=color.R
     
    750914        glLightfv(Number,GL_DIFFUSE,dif)
    751915    End Sub
    752     Sub SetDiffuse(color As Color4f)
     916    Sub SetDiffuse(ByRef color As Color4f)
    753917        Dim dif[3] As GLfloat
    754918        amb[0]=color.R
     
    770934        glLightfv(Number,GL_SPECULAR,spc)
    771935    End Sub
    772     Sub SetSpecular(color As Color4f)
     936    Sub SetSpecular(ByRef color As Color4f)
    773937        Dim spc[3] As GLfloat
    774938        amb[0]=color.R
     
    799963        glMaterialfv(face,GL_AMBIENT,amb)
    800964    End Sub
    801     Sub Ambient(color As Color4f)
     965    Sub Ambient(ByRef color As Color4f)
    802966        Dim face As GLenum
    803967        glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
     
    823987        glMaterialfv(face,GL_DIFFUSE,dif)
    824988    End Sub
    825     Sub Diffuse(color As Color4f)
     989    Sub Diffuse(ByRef color As Color4f)
    826990        Dim face As GLenum
    827991        glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
     
    8471011        glMaterialfv(face,GL_SPECULAR,spc)
    8481012    End Sub
    849     Sub Specular(color As Color4f)
     1013    Sub Specular(ByRef color As Color4f)
    8501014        Dim face As GLenum
    8511015        glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
     
    10141178Class LightModel
    10151179Public
    1016 /*  Function Ambient () As GLenum
    1017         Dim amb As GLenum
    1018         glGetFloatv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb))
    1019         Return func
    1020     End Function*/
    1021     Sub Ambient(amb As *GLfloat)
    1022         glLightModelfv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb))
     1180    Function Ambient () As Color4f
     1181        Dim amb As Color4f
     1182        glGetFloatv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb.rgba))
     1183        Return amb
     1184    End Function
     1185    Sub Ambient(amb As Color4f)
     1186        glLightModelfv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb.rgba))
    10231187    End Sub
    10241188
     
    15101674    End Sub
    15111675    Sub Color(c As Color3f)
    1512         glColor3fv(c)
     1676        glColor3fv(VarPtr(c.rgb))
    15131677    End Sub
    15141678    Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
Note: See TracChangeset for help on using the changeset viewer.