November 28, 2020, 02:30:18 PM

Author Topic: [bb] tex face cam by Nate the Great [ 1+ years ago ]  (Read 536 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] tex face cam by Nate the Great [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : tex face cam
Author : Nate the Great
Posted : 1+ years ago

Description : Im not really sure what to call this but I thought it was pretty cool and admitedly useless.  It is pretty cool though.  It basically flattens the texture to look the same no matter where or what rotation the object is at.  Sorry there are some welding bugs with the cube.

Code :
Code: BlitzBasic
  1. Graphics3D 1024,768,0,2
  2. SetBuffer BackBuffer()
  3.  
  4. Global cam1 = CreateCamera()
  5. MoveEntity cam1,0,0,-8
  6.  
  7. lit = CreateLight()
  8. TurnEntity lit,90,0,0
  9.  
  10. cub = CreateCube()
  11. sph = CreateSphere(32,cub)
  12. con = CreateCone(32,True,cub)
  13.  
  14. Tex = CreateTexture(256,256)
  15.  
  16. SetBuffer TextureBuffer(tex)
  17.  
  18. ClsColor 255,0,255
  19. Cls
  20. Color 0,255,0
  21.  
  22. For i = 1 To 100
  23.         Line Rnd(256),Rnd(256),Rnd(256),Rnd(256)
  24. Next
  25.  
  26. EntityTexture(cub,tex)
  27. EntityTexture(con,tex)
  28. EntityTexture(sph,tex)
  29. MoveEntity con,-3,0,0
  30. MoveEntity sph,3,0,0
  31.  
  32. SetBuffer BackBuffer()
  33. ClsColor 0,0,0
  34. tim = CreateTimer(60)
  35. While Not KeyDown(1)
  36. Cls
  37.  
  38. updateflattex(cub,256)
  39. updateflattex(sph,256)
  40. updateflattex(con,256)
  41.  
  42. RotateMesh cub,1,1,0
  43.  
  44. If KeyDown(203)
  45.         MoveEntity cub,-.02,0,0
  46. ElseIf KeyDown(205)
  47.         MoveEntity cub,.02,0,0
  48. EndIf
  49. If KeyDown(208)
  50.         MoveEntity cub,0,-.02,0
  51. ElseIf KeyDown(200)
  52.         MoveEntity cub,0,.02,0
  53. EndIf
  54.  
  55. UpdateWorld()
  56. RenderWorld()
  57. WaitTimer(tim)
  58.  
  59. Flip
  60. Wend
  61.  
  62. End
  63.  
  64. Function updateflattex(ent,num)
  65.  
  66. For s = 1 To CountSurfaces(ent)
  67.         surf = GetSurface(ent,s)
  68.         For v = 0 To CountVertices(surf)-1
  69.                 TFormPoint VertexX(surf,v), VertexY(surf, v),VertexZ(surf, v), ent, 0
  70.                 CameraProject cam1,TFormedX(),TFormedY(),TFormedZ()
  71.                 x# = ProjectedX()
  72.                 y# = ProjectedY()
  73.                 VertexTexCoords surf,v,x#/num,y#/num
  74.         Next
  75. Next
  76.  
  77. End Function


Comments :


Nate the Great(Posted 1+ years ago)

 perhaps this should be moved to the 3d graphics mesh section of the code archives.. sorry i misplaeced it


Nate the Great(Posted 1+ years ago)

 perhaps this should be moved to the 3d graphics mesh section of the code archives.. sorry i misplaced it


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal