Ooops
January 26, 2021, 05:44:12 AM

Author Topic: [bb] A tutorial in the basics of 3d. by poopla [ 1+ years ago ]  (Read 1299 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : A tutorial in the basics of 3d.
Author : poopla
Posted : 1+ years ago

Description : This will get you started in the real of walking around in 3d.  Its just very well commented code.

Code :
Code: BlitzBasic
  1. Will make a textured terrain......     TERAIN AND MOVING ON TERRAIN..........
  2.  
  3. Graphics3D 640,480 ;this here sets the display
  4. SetBuffer BackBuffer();sets the current buffer
  5. light=CreateLight();creates a light DUH
  6.  
  7. ter=CreateTerrain(128) ; create a 128 x 128
  8. For x = 1 To 128;this will madify your terrain
  9. For y = 1 To 128;same here
  10.     ;ModifyTerrain terrain,grid_x,grid_z,height#[,realtime]
  11. ModifyTerrain ter,x,y,Rnd(0.0,1.0)
  12. Next
  13. Next
  14.  
  15. ScaleEntity ter,20,50,20 ; make terrain bigger so we can see it
  16.  
  17.  
  18. pivot=CreatePivot() ; pivot for camera rotations
  19. camera=CreateCamera(pivot) ; camera with pivot as its parent entity
  20.  
  21.  
  22. ; make a texture ***
  23. ptex=CreateTexture(16,16)
  24. SetBuffer TextureBuffer(ptex)
  25. Color 0,0,255
  26. Rect 2,2,14,14
  27. Color 0,255,0
  28. Rect 8,8,10,10
  29. ScaleTexture ptex,2,2
  30. ; ******************
  31.  
  32. EntityTexture ter,ptex ; paint the terrain with our texture
  33.  
  34.  
  35. SetBuffer BackBuffer()
  36.  
  37.  
  38. ; main loop **********************************
  39. While Not KeyDown( 1 )
  40.  
  41.  
  42. If MouseDown(1)=1 Then speed#=speed#+.05
  43. speed#=speed#*.99 ; friction
  44.  
  45. TurnEntity camera,MouseYSpeed()/6,0,0 ; turn camera up and down
  46. TurnEntity pivot,0,-MouseXSpeed()/6,0 ; turn pivot left --right
  47. MoveEntity pivot,0,0,speed#
  48.  
  49. xpos#=EntityX(pivot)
  50. zpos#=EntityZ(pivot)
  51. ypos#=TerrainY(ter,xpos,0,zpos)
  52.  
  53. PositionEntity pivot,xpos,ypos+10,zpos
  54. MoveMouse 100,100
  55.  
  56. UpdateWorld
  57. RenderWorld
  58. Flip
  59. Wend
  60. End
  61.  
  62.  
  63. Learned all this from bradford.  So a big thamks to him :)


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal