Changeset 80 for Include/abgl.ab
- Timestamp:
- Jan 31, 2007, 6:31:44 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/abgl.ab
r78 r80 17 17 Class Vector2f 18 18 Public /* constructor */ 19 Sub Vector2f() 20 This.X=0.0 As GLfloat 21 This.Y=0.0 As GLfloat 22 End Sub 19 23 Sub Vector2f(x As GLfloat, y As GLfloat) 20 24 This.X=x … … 41 45 42 46 Public /* operator */ 43 Sub Operator = (ByRef vec As Vector2f)44 This.X= vec.X45 This.Y= vec.Y46 End Sub 47 Function Operator + ( ByRef vec1 As Vector2f, ByRef vec2As Vector2f) As Vector2f48 Return Add( vec1,vec2)49 End Function 50 Function Operator - ( ByRef vec1 As Vector2f, ByRef vec2As Vector2f) As Vector2f51 Return Substract( vec1,vec2)52 End Function 53 /* Function Operator * ( vec1 As Vector2f, vec2As Vector2f) As Vector2f54 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) 55 59 End Function 56 60 */ 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) 63 83 Return ret 64 84 End Function … … 66 86 67 87 Public /* method */ 68 Function Add(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f69 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 GLfloat88 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 73 93 Dim ret As Vector2f 74 ret= vec1-vec294 ret=SrcVec1-SrcVec2 75 95 Return ret.Magnitude 76 96 End Function 77 Function Dot(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As GLfloat78 Return vec1.X*vec2.X+vec1.Y*vec2.Y97 Static Function Dot(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As GLfloat 98 Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y 79 99 End Function 80 100 Function Magnitude() As GLfloat … … 89 109 Return ret 90 110 End Function 91 Function Substract(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f92 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) 93 113 Return ret 94 114 End Function … … 108 128 Class Vector2d 109 129 Public /* constructor */ 130 Sub Vector2d() 131 This.X=0.0 As GLdouble 132 This.Y=0.0 As GLdouble 133 End Sub 110 134 Sub Vector2d(x As GLdouble, y As GLdouble) 111 135 xy.x=x … … 132 156 133 157 Public /* operator */ 134 Sub Operator = (ByRef vec As Vector2d)135 This.X= vec.X136 This.Y= vec.Y137 End Sub 138 Function Operator + ( ByRef vec1 As Vector2d, ByRef vec2As Vector2d) As Vector2d139 Return Add( vec1,vec2)140 End Function 141 Function Operator - ( ByRef vec1 As Vector2d, ByRef vec2As Vector2d) As Vector2d142 Return Substract( vec1,vec2)143 End Function 144 /* Function Operator * ( ByRef vec1 As Vector2d, ByRef vec2As Vector2d) As Vector2d145 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) 146 170 End Function*/ 147 171 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) 154 194 Return ret 155 195 End Function … … 157 197 158 198 Public /* method */ 159 Function Add( ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d160 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 GLdouble199 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 164 204 Dim ret As Vector2d 165 ret= vec1-vec2205 ret=SrcVec1-SrcVec2 166 206 Return ret.Magnitude 167 207 End Function 168 Function Dot( ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As GLdouble169 Return vec1.X*vec2.X+vec1.Y*vec2.Y208 Function Dot(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As GLdouble 209 Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y 170 210 End Function 171 211 Function Magnitude() As GLdouble … … 180 220 Return ret 181 221 End Function 182 Function Substract( ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d183 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) 184 224 Return ret 185 225 End Function … … 193 233 End Function 194 234 195 P rotected235 Public 196 236 xz As XY_DOUBLE 197 237 End Class … … 212 252 Class Vector3f 213 253 Public /* 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 214 259 Sub Vector3f(x As GLfloat, y As GLfloat, z As GLfloat) 215 260 xyz.x=x … … 243 288 244 289 Public /* operator */ 245 Sub Operator = ( vec As Vector3f)246 This.X= vec.X247 This.Y= vec.Y248 End Sub 249 Function Operator + ( vec1 As Vector3f, vec2As Vector3f) As Vector3f250 Return Add( vec1,vec2)251 End Function 252 Function Operator - ( vec1 As Vector3f, vec2As Vector3f) As Vector3f253 Return Substract( vec1,vec2)254 End Function 255 /* Function Operator * ( vec1 As Vector3f, vec2As Vector3f) As Vector3f256 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) 257 302 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) 268 329 Return ret 269 330 End Function … … 271 332 272 333 Public /* method */ 273 Function Add( vec1 As Vector3f, vec2 As Vector3f) As Vector3f274 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 Vector3f278 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 GLfloat334 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 282 343 Dim ret As Vector3f 283 ret= vec1-vec2344 ret=SrcVec1-SrcVec2 284 345 Return ret.Magnitude 285 346 End Function 286 Function Dot( vec1 As Vector3f, vec2 As Vector3f) As GLfloat287 Return vec1.X*vec2.X+vec1.Y*vec2.Y+vec1.Z*vec2.Z347 Function Dot(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As GLfloat 348 Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y+SrcVec1.Z*SrcVec2.Z 288 349 End Function 289 350 Function Magnitude() As GLfloat … … 298 359 Return ret 299 360 End Function 300 Function Substract( vec1 As Vector3f, vec2 As Vector3f) As Vector3f301 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) 302 363 Return ret 303 364 End Function … … 311 372 End Function 312 373 313 P rotected374 Public 314 375 xyz As XYZ_FLOAT 315 376 End Class … … 317 378 Class Vector3d 318 379 Public /* 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 319 385 Sub Vector3d(x As GLdouble, y As GLdouble, z As GLdouble) 320 386 xyz.x=x … … 350 416 351 417 Public /* operator */ 352 Sub Operator = ( vec As Vector3d)353 This.X= vec.X354 This.Y= vec.Y355 End Sub 356 Function Operator + ( vec1 As Vector3d, vec2As Vector3d) As Vector3d357 Return Add( vec1,vec2)358 End Function 359 Function Operator - ( vec1 As Vector3d, vec2As Vector3d) As Vector3d360 Return Substract( vec1,vec2)361 End Function 362 /* Function Operator * ( vec1 As Vector3d, vec2As Vector3d) As Vector3d363 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) 364 430 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) 375 457 Return ret 376 458 End Function … … 378 460 379 461 Public /* method */ 380 Function Add( vec1 As Vector3d, vec2 As Vector3d) As Vector3d381 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 Vector3d385 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 GLdouble462 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 389 471 Dim ret As Vector3d 390 ret= vec1-vec2472 ret=SrcVec1-SrcVec2 391 473 Return ret.Magnitude 392 474 End Function 393 Function Dot( vec1 As Vector3d, vec2 As Vector3d) As GLdouble394 Return vec1.X*vec2.X+vec1.Y*vec2.Y+vec1.Z*vec2.Z475 Function Dot(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As GLdouble 476 Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y+SrcVec1.Z*SrcVec2.Z 395 477 End Function 396 478 Function Magnitude() As GLdouble … … 405 487 Return ret 406 488 End Function 407 Function Substract( vec1 As Vector3d, vec2 As Vector3d) As Vector3d408 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) 409 491 Return ret 410 492 End Function … … 418 500 End Function 419 501 420 421 Protected 502 Public 422 503 xyz As XYZ_DOUBLE 423 504 End Class … … 456 537 End Function 457 538 Function B() As GLfloat 458 Return rgb. r539 Return rgb.b 459 540 End Function 460 541 Sub R(r As GLfloat) … … 469 550 470 551 Public /* operator */ 471 Function operator () As Color3f472 Return This473 End Function474 552 Sub operator = (c As Color3f) 475 553 This.R=c.R … … 519 597 Return ret 520 598 End Function 521 Static Function FromHS B(h As GLfloat, s As GLfloat, v As GLfloat) As Color3f599 Static Function FromHSV(h As GLfloat, s As GLfloat, v As GLfloat) As Color3f 522 600 Dim r As GLfloat 523 601 Dim g As GLfloat 524 602 Dim b As GLfloat 525 603 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 527 606 Case 0 528 607 r=v 529 g=v*(1-s*(1-(h/60- h\60)))608 g=v*(1-s*(1-(h/60-(h/60) As Long))) 530 609 b=v*(1-s) 531 610 Case 1 532 r=v*(1-s*(h/60- h\60))611 r=v*(1-s*(h/60-(h/60) As Long)) 533 612 g=v 534 613 b=v*(1-s) … … 536 615 r=v*(1-s) 537 616 g=v 538 b=v*(1-s*(1-(h/60- h\60)))617 b=v*(1-s*(1-(h/60-(h/60) As Long))) 539 618 Case 3 540 619 r=v*(1-s) 541 g=v*(1-s*(h/60- h\60))620 g=v*(1-s*(h/60-(h/60) As Long)) 542 621 b=v 543 622 Case 4 544 r=v*(1-s*(1-(h/60- h\60)))623 r=v*(1-s*(1-(h/60-(h/60) As Long))) 545 624 g=v*(1-s) 546 625 b=v … … 548 627 r=v 549 628 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) 551 634 End Select 552 635 … … 555 638 End Function 556 639 557 P rotected640 Public 558 641 rgb As RGB_FLOAT 559 642 End Class … … 579 662 End Function 580 663 Function B() As GLdouble 581 Return rgb. r664 Return rgb.b 582 665 End Function 583 666 Sub R(r As GLdouble) … … 591 674 End Sub 592 675 593 Protected 676 Public /* 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 708 Public /* 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 757 Public 594 758 rgb As RGB_DOUBLE 595 759 End Class … … 630 794 End Function 631 795 Function B() As GLfloat 632 Return rgba. r796 Return rgba.b 633 797 End Function 634 798 Function A() As GLfloat … … 648 812 End Sub 649 813 650 P rotected814 Public 651 815 rgba As RGBA_FLOAT 652 816 End Class … … 674 838 End Function 675 839 Function B() As GLdouble 676 Return rgba. r840 Return rgba.b 677 841 End Function 678 842 Function A() As GLdouble … … 692 856 End Sub 693 857 694 P rotected858 Public 695 859 rgba As RGBA_DOUBLE 696 860 End Class … … 700 864 Class Light 701 865 Private 702 Number As GLenum866 Const Number As GLenum 703 867 704 868 Public … … 730 894 glLightfv(Number,GL_AMBIENT,amb) 731 895 End Sub 732 Sub SetAmbient( color As Color4f)896 Sub SetAmbient(ByRef color As Color4f) 733 897 Dim amb[3] As GLfloat 734 898 amb[0]=color.R … … 750 914 glLightfv(Number,GL_DIFFUSE,dif) 751 915 End Sub 752 Sub SetDiffuse( color As Color4f)916 Sub SetDiffuse(ByRef color As Color4f) 753 917 Dim dif[3] As GLfloat 754 918 amb[0]=color.R … … 770 934 glLightfv(Number,GL_SPECULAR,spc) 771 935 End Sub 772 Sub SetSpecular( color As Color4f)936 Sub SetSpecular(ByRef color As Color4f) 773 937 Dim spc[3] As GLfloat 774 938 amb[0]=color.R … … 799 963 glMaterialfv(face,GL_AMBIENT,amb) 800 964 End Sub 801 Sub Ambient( color As Color4f)965 Sub Ambient(ByRef color As Color4f) 802 966 Dim face As GLenum 803 967 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face)) … … 823 987 glMaterialfv(face,GL_DIFFUSE,dif) 824 988 End Sub 825 Sub Diffuse( color As Color4f)989 Sub Diffuse(ByRef color As Color4f) 826 990 Dim face As GLenum 827 991 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face)) … … 847 1011 glMaterialfv(face,GL_SPECULAR,spc) 848 1012 End Sub 849 Sub Specular( color As Color4f)1013 Sub Specular(ByRef color As Color4f) 850 1014 Dim face As GLenum 851 1015 glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face)) … … 1014 1178 Class LightModel 1015 1179 Public 1016 /* Function Ambient () As GLenum 1017 Dim amb As GLenum1018 glGetFloatv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb ))1019 Return func1020 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)) 1023 1187 End Sub 1024 1188 … … 1510 1674 End Sub 1511 1675 Sub Color(c As Color3f) 1512 glColor3fv( c)1676 glColor3fv(VarPtr(c.rgb)) 1513 1677 End Sub 1514 1678 Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
Note:
See TracChangeset
for help on using the changeset viewer.