Ooops
January 15, 2021, 06:02:50 PM

Author Topic: [bb] vertex normal effect by TomToad [ 1+ years ago ]  (Read 611 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] vertex normal effect by TomToad [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : vertex normal effect
Author : TomToad
Posted : 1+ years ago

Description : I was just mesing around with meshes and vertex normals and came up with some nice effects.  Use the arrow keys to move the camera and use 1-5 to change which effect is being rendered.

Code :
Code: BlitzBasic
  1. Graphics3D 800,600,32,0
  2. SetBuffer BackBuffer()
  3. Const size = 128
  4.  
  5. grid = CreateMesh()
  6. surface = CreateSurface(grid)
  7.  
  8.  
  9. For y = -size/2 To (size/2 - 1)
  10.  For x = -size/2 To (size/2 - 1)
  11.   v = AddVertex(surface,x,0,y)
  12.   DebugLog v
  13.  Next
  14. Next
  15.  
  16.  
  17. For y = 0 To (size - 2)
  18.  For x = 0 To (size - 1)
  19.   If x <> 0
  20.    v3 = (x - 1) + y * size
  21.    v2 = x + y * size
  22.    v1 = x + (y + 1) * size
  23.    AddTriangle(surface,v1,v2,v3)
  24.   End If
  25.   If x <> (size - 1)
  26.    v3 = x + y * size
  27.    v2 = x + 1 + (y + 1) * size
  28.    v1 = x + (y + 1) * size
  29.    AddTriangle(surface,v1,v2,v3)
  30.   End If
  31.  Next
  32. Next
  33.  
  34. PositionEntity grid,0,0,0
  35. EntityColor grid,127,127,255
  36. camera = CreateCamera()
  37.  
  38. PositionEntity camera,0,5,-5
  39.  
  40. light = CreateLight()
  41. RotateEntity light,45,0,0
  42.  
  43. angle = 0
  44. mode = 0
  45. timer = CreateTimer(30)
  46.  
  47. While Not KeyDown(1)
  48. WaitTimer(timer)
  49.  
  50. For x = 0 To size - 1
  51.  For y = 0 To size - 1
  52.   Select mode
  53.   Case 0
  54.     VertexNormal(surface,x + y * size,Cos((angle + x*y)Mod 180),Sin((angle + x*y)Mod 180),0)
  55.   Case 1
  56.     VertexNormal(surface,x + y * size,Sin((angle + x*y)Mod 180),Cos((angle + x*y)Mod 180),0)
  57.   Case 2
  58.     VertexNormal(surface,x + y * size,0,Sin((angle + x*y)Mod 180),Cos((angle + x*y)Mod 180))
  59.   Case 3
  60.     VertexNormal(surface,x + y * size,0,Cos((angle + x*y)Mod 180),Sin((angle + x*y)Mod 180))
  61.   Case 4
  62.     VertexNormal(surface,x + y * size,Sin((angle + x*y)Mod 180),0,Cos((angle + x*y)Mod 180))
  63.  
  64.   End Select
  65.  Next
  66. Next
  67.  
  68.  
  69. If KeyDown(200) Then MoveEntity camera,0,0,.1
  70. If KeyDown(208) Then MoveEntity camera,0,0,-.1
  71. If KeyDown(203) Then TurnEntity camera,0,.8,0
  72. If KeyDown(205) Then TurnEntity camera,0,-.8,0
  73. If KeyHit(2) Then mode = 0
  74. If KeyHit(3) Then mode = 1
  75. If KeyHit(4) Then mode = 2
  76. If KeyHit(5) Then mode = 3
  77. If KeyHit(6) Then mode = 4
  78.  
  79. RenderWorld
  80. Flip False
  81.  
  82. angle = angle + 1
  83. If angle = 360 Then angle = 0
  84.  
  85. Wend


Comments :


Clyde(Posted 1+ years ago)

 Snazzy Stuff dude :)


Ross C(Posted 1+ years ago)

 Cool :o) Bet you can't do that in 512 characters ;) ;P


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal