vertex3f.monkey2 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. Namespace mojo.graphics
  2. Struct Vertex3f
  3. Const Format:=New Vertex3fFormat
  4. Const Pitch:=80 '80
  5. Field position:Vec3f '0
  6. Field texCoord0:Vec2f '12
  7. Field texCoord1:Vec2f '20
  8. Field color:UInt=~0 '28
  9. Field normal:Vec3f '32
  10. Field tangent:Vec4f '44
  11. Field weights:Vec4f '60
  12. Field bones:UInt '76
  13. Method New()
  14. End
  15. Method New( x:Float,y:Float,z:Float,s0:Float=0,t0:Float=0,nx:Float=0,ny:Float=0,nz:Float=0 )
  16. position.x=x
  17. position.y=y
  18. position.z=z
  19. texCoord0.x=s0
  20. texCoord0.y=t0
  21. normal.x=nx
  22. normal.y=ny
  23. normal.z=nz
  24. End
  25. Method New( position:Vec3f,texCoord0:Vec2f=New Vec2f,normal:Vec3f=New Vec3f )
  26. Self.position=position
  27. Self.texCoord0=texCoord0
  28. Self.normal=normal
  29. End
  30. Operator To:String()
  31. Return "Vertex3f("+position+")"
  32. End
  33. Property Tx:Float()
  34. Return position.x
  35. Setter( tx:Float )
  36. position.x=tx
  37. End
  38. Property Ty:Float()
  39. Return position.y
  40. Setter( ty:Float )
  41. position.y=ty
  42. End
  43. Property Tz:Float()
  44. Return position.z
  45. Setter( tz:Float )
  46. position.z=tz
  47. End
  48. Property Sx:Float()
  49. Return texCoord0.x
  50. Setter( sx:Float )
  51. texCoord0.x=sx
  52. End
  53. Property Sy:Float()
  54. Return texCoord0.y
  55. Setter( sy:Float )
  56. texCoord0.y=sy
  57. End
  58. Property Sx0:Float()
  59. Return texCoord0.x
  60. Setter( sx:Float )
  61. texCoord0.x=sx
  62. End
  63. Property Sy0:Float()
  64. Return texCoord0.y
  65. Setter( sy:Float )
  66. texCoord0.y=sy
  67. End
  68. Property Sx1:Float()
  69. Return texCoord1.x
  70. Setter( sx:Float )
  71. texCoord1.x=sx
  72. End
  73. Property Sy1:Float()
  74. Return texCoord1.y
  75. Setter( sy:Float )
  76. texCoord1.y=sy
  77. End
  78. End
  79. Class Vertex3fFormat Extends VertexFormat
  80. Property Pitch:Int() Override
  81. Return Vertex3f.Pitch
  82. End
  83. Method UpdateGLAttribs() Override
  84. glEnableVertexAttribArray( A_POSITION ) ; glVertexAttribPointer( A_POSITION,3,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 0 ) )
  85. glEnableVertexAttribArray( A_TEXCOORD0 ) ; glVertexAttribPointer( A_TEXCOORD0,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 12 ) )
  86. glEnableVertexAttribArray( A_TEXCOORD1 ) ; glVertexAttribPointer( A_TEXCOORD1,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 20 ) )
  87. glEnableVertexAttribArray( A_COLOR ) ; glVertexAttribPointer( A_COLOR,4,GL_UNSIGNED_BYTE,True,Pitch,Cast<Void Ptr>( 28 ) )
  88. glEnableVertexAttribArray( A_NORMAL ) ; glVertexAttribPointer( A_NORMAL,3,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 32 ) )
  89. glEnableVertexAttribArray( A_TANGENT ) ; glVertexAttribPointer( A_TANGENT,4,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 44 ) )
  90. glEnableVertexAttribArray( A_WEIGHTS ) ; glVertexAttribPointer( A_WEIGHTS,4,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 60 ) )
  91. glEnableVertexAttribArray( A_BONES ) ; glVertexAttribPointer( A_BONES,4,GL_UNSIGNED_BYTE,False,Pitch,Cast<Void Ptr>( 76 ) )
  92. End
  93. End