Changeset 78


Ignore:
Timestamp:
Jan 29, 2007, 1:21:03 AM (13 years ago)
Author:
NoWest
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/abgl.ab

    r72 r78  
    4141
    4242Public /* operator */
    43     Sub Operator = (vec As Vector2f)
     43    Sub Operator = (ByRef vec As Vector2f)
    4444        This.X=vec.X
    4545        This.Y=vec.Y
    4646    End Sub
    47     Function Operator + (vec1 As Vector2f, vec2 As Vector2f) As Vector2f
     47    Function Operator + (ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
    4848        Return Add(vec1,vec2)
    4949    End Function
    50     Function Operator - (vec1 As Vector2f, vec2 As Vector2f) As Vector2f
     50    Function Operator - (ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
    5151        Return Substract(vec1,vec2)
    5252    End Function
     
    5555    End Function
    5656*/
    57     Function Operator * (vec As Vector2f, sca As GLfloat) As Vector2f
     57    Function Operator * (ByRef vec As Vector2f, sca As GLfloat) As Vector2f
    5858        Dim ret As Vector2f(vec.X*sca,vec.Y*sca)
    5959        Return ret
    6060    End Function
    61     Function Operator / (vec As Vector2f, sca As GLfloat) As Vector2f
     61    Function Operator / (ByRef vec As Vector2f, sca As GLfloat) As Vector2f
    6262        Dim ret As Vector2f(vec.X/sca,vec.Y/sca)
    6363        Return ret
     
    6666
    6767Public /* method */
    68     Function Add(vec1 As Vector2f, vec2 As Vector2f) As Vector2f
     68    Function Add(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
    6969        Dim ret As Vector2f(vec1.X+vec2.X,vec1.Y+vec2.Y)
    7070        Return ret
    7171    End Function
    72     Function Distance(vec1 As Vector2f, vec2 As Vector2f) As GLfloat
     72    Function Distance(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As GLfloat
    7373        Dim ret As Vector2f
    7474        ret=vec1-vec2
    7575        Return ret.Magnitude
    7676    End Function
    77     Function Dot(vec1 As Vector2f, vec2 As Vector2f) As GLfloat
     77    Function Dot(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As GLfloat
    7878        Return vec1.X*vec2.X+vec1.Y*vec2.Y
    7979    End Function
     
    8989        Return ret
    9090    End Function
    91     Function Substract(vec1 As Vector2f, vec2 As Vector2f) As Vector2f
     91    Function Substract(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
    9292        Dim ret As Vector2f(vec1.X-vec2.X,vec1.Y-vec2.Y)
    9393        Return ret
     
    132132
    133133Public /* operator */
    134     Sub Operator = (vec As Vector2d)
     134    Sub Operator = (ByRef vec As Vector2d)
    135135        This.X=vec.X
    136136        This.Y=vec.Y
    137137    End Sub
    138     Function Operator + (vec1 As Vector2d, vec2 As Vector2d) As Vector2d
     138    Function Operator + (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
    139139        Return Add(vec1,vec2)
    140140    End Function
    141     Function Operator - (vec1 As Vector2d, vec2 As Vector2d) As Vector2d
     141    Function Operator - (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
    142142        Return Substract(vec1,vec2)
    143143    End Function
    144 /*  Function Operator * (vec1 As Vector2d, vec2 As Vector2d) As Vector2d
     144/*  Function Operator * (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
    145145        Return Dot(vec1,vec2)
    146146    End Function*/
     
    157157
    158158Public /* method */
    159     Function Add(vec1 As Vector2d, vec2 As Vector2d) As Vector2d
     159    Function Add(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
    160160        Dim ret As Vector2d(vec1.X+vec2.X,vec1.Y+vec2.Y)
    161161        Return ret
    162162    End Function
    163     Function Distance(vec1 As Vector2d, vec2 As Vector2d) As GLdouble
     163    Function Distance(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As GLdouble
    164164        Dim ret As Vector2d
    165165        ret=vec1-vec2
    166166        Return ret.Magnitude
    167167    End Function
    168     Function Dot(vec1 As Vector2d, vec2 As Vector2d) As GLdouble
     168    Function Dot(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As GLdouble
    169169        Return vec1.X*vec2.X+vec1.Y*vec2.Y
    170170    End Function
     
    180180        Return ret
    181181    End Function
    182     Function Substract(vec1 As Vector2d, vec2 As Vector2d) As Vector2d
     182    Function Substract(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
    183183        Dim ret As Vector2d(vec1.X-vec2.X,vec1.Y-vec2.Y)
    184184        Return ret
     
    469469
    470470Public /* operator */
    471 
     471    Function operator () As Color3f
     472        Return This
     473    End Function
     474    Sub operator = (c As Color3f)
     475        This.R=c.R
     476        This.G=c.G
     477        This.B=c.B
     478    End Sub
     479
     480Public /* method */
    472481    ' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にした
    473482    ' Drawwing\Color.abをさらに参考にしました。
     
    478487        d = max - min
    479488        If rgb.g = max Then
    480             Return ((rgb.b - rgb.r) As Double / d * 1.0*_System_PI/3.0 + 2.0*_System_PI/3.0) As GLfloat
     489            Return ((rgb.b - rgb.r) As Double / d * 60.0 + 120.0) As GLfloat
    481490        ElseIf rgb.b = max Then
    482             Return ((rgb.r - rgb.g) As Double / d * 1.0*_System_PI/3.0 + 4.0*_System_PI/3.0) As GLfloat
     491            Return ((rgb.r - rgb.g) As Double / d * 60.0 + 240.0) As GLfloat
    483492        ElseIf rgb.g < rgb.b Then
    484             Return ((rgb.g - rgb.b) As Double / d * 1.0*_System_PI/3.0 + 6.0*_System_PI/3.0) As GLfloat
    485         Else
    486             Return ((rgb.g - rgb.b) As Double / d * 1.0*_System_PI/3.0) As GLfloat
     493            Return ((rgb.g - rgb.b) As Double / d * 60.0 + 360.0) As GLfloat
     494        Else
     495            Return ((rgb.g - rgb.b) As Double / d * 60.0) As GLfloat
    487496        EndIf
    488497    End Function
     
    495504    End Function
    496505
    497     Function GetBrightness() As GLfloat
     506    Function GetVolue() As GLfloat
    498507        Dim max As GLfloat
    499508        max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
    500509        Return max
    501510    End Function
     511
     512Public /* static method */
     513    Static Function FromRGB(r As GLbyte, g As GLbyte, b As GLbyte) As Color3f
     514        Dim ret As Color3f(r/255,g/255,b/255)
     515        Return ret
     516    End Function
     517    Static Function FromCOLORREF(c As COLORREF) As Color3f
     518        Dim ret As Color3f((c and &hff)/255,(c>>8 and &hff)/255,(c>>16 and &hff)/255)
     519        Return ret
     520    End Function
     521    Static Function FromHSB(h As GLfloat, s As GLfloat, v As GLfloat) As Color3f
     522        Dim r As GLfloat
     523        Dim g As GLfloat
     524        Dim b As GLfloat
     525        If h<0 Then h+=360.0
     526        Select Case (h\60)
     527            Case 0
     528                r=v
     529                g=v*(1-s*(1-(h/60-h\60)))
     530                b=v*(1-s)
     531            Case 1
     532                r=v*(1-s*(h/60-h\60))
     533                g=v
     534                b=v*(1-s)
     535            Case 2
     536                r=v*(1-s)
     537                g=v
     538                b=v*(1-s*(1-(h/60-h\60)))
     539            Case 3
     540                r=v*(1-s)
     541                g=v*(1-s*(h/60-h\60))
     542                b=v
     543            Case 4
     544                r=v*(1-s*(1-(h/60-h\60)))
     545                g=v*(1-s)
     546                b=v
     547            Case 5
     548                r=v
     549                g=v*(1-s)
     550                b=v*(1-s*(h/60-h\60))
     551        End Select
     552
     553        Dim ret As Color3f(r,g,b)
     554        Return ret
     555    End Function
     556
    502557Protected
    503558    rgb As RGB_FLOAT
     
    14541509        glColor3f(red,green,blue)
    14551510    End Sub
     1511    Sub Color(c As Color3f)
     1512        glColor3fv(c)
     1513    End Sub
    14561514    Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
    14571515        glColor4f(red,green,blue,alpha)
Note: See TracChangeset for help on using the changeset viewer.