Ooops
January 26, 2021, 12:46:29 PM

Author Topic: [bb] redblue realistic3d code by Nate the Great [ 1+ years ago ]  (Read 598 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : redblue realistic3d code
Author : Nate the Great
Posted : 1+ years ago

Description : just some red blue hue code I put together to make any game into a game for red blue 3d glasses

Code :
Code: BlitzBasic
  1. Graphics3D 1024,768,0,1
  2.  
  3. Global cam = CreateCamera()
  4. lit = CreateLight()
  5. TurnEntity lit,60,0,0
  6.  
  7. Type cube
  8.         Field ent
  9. End Type
  10.  
  11. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  12. Global tdcam = CreateCamera()
  13. TurnEntity tdcam,90,0,0
  14.  
  15. plan = CreatePlane()
  16. MoveEntity plan,0,-5,0
  17. EntityPickMode plan,2
  18. EntityAlpha plan,0
  19.  
  20. CameraPick tdcam,0,0
  21. Global x1# = PickedX()
  22. Global y1# = PickedY()
  23. Global z1# = PickedZ()
  24.  
  25. CameraPick tdcam,0,GraphicsHeight()
  26. Global x2# = PickedX()
  27. Global y2# = PickedY()
  28. Global z2# = PickedZ()
  29.  
  30. CameraPick tdcam,GraphicsWidth(),GraphicsHeight()
  31. Global x3# = PickedX()
  32. Global y3# = PickedY()
  33. Global z3# = PickedZ()
  34.  
  35. CameraPick tdcam,GraphicsWidth(),0
  36. Global x4# = PickedX()
  37. Global y4# = PickedY()
  38. Global z4# = PickedZ()
  39.  
  40. m1 = CreateMesh()
  41. s = CreateSurface(m1)
  42.  
  43. fr# = GraphicsWidth()/1024.0
  44. fl# = GraphicsHeight()/1024.0
  45. v1 = AddVertex(s,x1,y1,z1,0,0)
  46. v2 = AddVertex(s,x2,y2,z2,0,fl)
  47. v3 = AddVertex(s,x3,y3,z3,fr,fl)
  48. v4 = AddVertex(s,x4,y4,z4,fr,0)
  49.  
  50. t1 = AddTriangle(s,v2,v1,v3)
  51. t2 = AddTriangle(s,v4,v3,v1)
  52.  
  53. EntityColor m1,0,50,255
  54. EntityFX m1,1
  55.  
  56.  
  57. m2 = CreateMesh()
  58. s = CreateSurface(m2)
  59.  
  60. v1 = AddVertex(s,x1,y1,z1,0,0)
  61. v2 = AddVertex(s,x2,y2,z2,0,fl)
  62. v3 = AddVertex(s,x3,y3,z3,fr,fl)
  63. v4 = AddVertex(s,x4,y4,z4,fr,0)
  64.  
  65. t1 = AddTriangle(s,v2,v1,v3)
  66. t2 = AddTriangle(s,v4,v3,v1)
  67.  
  68. EntityColor m2,255,50,0
  69. EntityFX m2,1
  70.  
  71. redtex = CreateTexture(1024,1024)
  72. blutex = CreateTexture(1024,1024)
  73.  
  74. EntityTexture m1,blutex
  75. EntityTexture m2,redtex
  76.  
  77. EntityBlend m1,3
  78. EntityBlend m2,3
  79.  
  80. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  81.  
  82. SetBuffer BackBuffer()
  83. timer = 0
  84. While Not KeyDown(1)
  85. Cls
  86.  
  87. timer = timer + 1
  88.  
  89. If timer => 3 Then
  90.         timer = 0
  91.         c.cube = New cube
  92.         cent = CreateCube()
  93.         scl# = Rnd(.01,.05)
  94.         ScaleEntity cent,scl,scl,scl
  95.         EntityColor cent,Rnd(255),Rnd(255),Rnd(255)
  96.         MoveEntity cent,Rnd(-1,1),Rnd(-1,1),8
  97. EndIf
  98.  
  99. For c.cube = Each cube
  100.         MoveEntity cent,0,0,-.08
  101.         If EntityZ(cent) < 0 Then
  102.                 FreeEntity cent
  103.                 Delete c.cube
  104.         EndIf
  105. Next
  106.  
  107. ;renderstuff
  108. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  109. ShowEntity cam
  110. HideEntity tdcam
  111. MoveEntity cam,-.05,0,0
  112. TurnEntity cam,0,2,0
  113. RenderWorld()
  114.  
  115. CopyRect(0,0,GraphicsWidth()+1,GraphicsHeight()+1,0,0,BackBuffer(),TextureBuffer(redtex))
  116.  
  117. TurnEntity cam,0,-2,0
  118. MoveEntity cam,.1,0,0
  119. TurnEntity cam,0,-2,0
  120. RenderWorld()
  121.  
  122. CopyRect(0,0,GraphicsWidth()+1,GraphicsHeight()+1,0,0,BackBuffer(),TextureBuffer(blutex))
  123. TurnEntity cam,0,2,0
  124. MoveEntity cam,-.05,0,0
  125.  
  126. ShowEntity tdcam
  127. HideEntity cam
  128. RenderWorld()
  129. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  130.  
  131. Flip
  132. Wend


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal