TE.bb 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ;Multitexture on terrains
  2. ;David Bird
  3. ;[email protected]
  4. ;http://www.birdie72.freeserve.co.uk
  5. ;14/6/01 (beta 2.24)
  6. ;Example of belnding two textures
  7. Graphics3D 640,480
  8. SetBuffer BackBuffer()
  9. HWMultiTex True
  10. lit=CreateLight()
  11. cam=CreateCamera()
  12. CameraRange cam,1,25000
  13. PositionEntity cam,0,50,-152
  14. terr=LoadTerrain("hmap.bmp")
  15. TerrainShading terr,True
  16. TerrainDetail terr,2000
  17. ;Load textures
  18. tex0=LoadTexture("hmap.bmp") ;Mask 1
  19. tex1=LoadTexture("forest.bmp") ;Grass Texture
  20. tex2=LoadTexture("hmap2.bmp") ;Inverted Mask1
  21. tex3=LoadTexture("rock.bmp") ;Rock texture
  22. ;sort out the blending here
  23. ;((grass*mask1)*rock)*mask2)
  24. TextureBlend tex0,3 ;Blend mode (add)
  25. TextureBlend tex2,2 ;Blend mode (multiply)
  26. TextureBlend tex3,2
  27. ;resize textures
  28. ScaleTexture tex2,128,128
  29. ScaleTexture tex0,128,128
  30. ScaleTexture tex3,4,4
  31. ScaleTexture tex1,32,32
  32. ;Do the blending here
  33. EntityTexture terr,tex1,0,0
  34. EntityTexture terr,tex0,0,1
  35. EntityTexture terr,tex3,0,2
  36. EntityTexture terr,tex2,0,3
  37. ;scale terrain to size
  38. ScaleEntity terr,50,375,50
  39. EntityColor terr,30,30,30
  40. ;Add an infinate plane
  41. plane=CreatePlane()
  42. EntityTexture plane,tex1
  43. ScaleEntity plane,50,1,50
  44. EntityOrder plane,1
  45. AmbientLight 30,30,30
  46. While Not KeyDown(1)
  47. ClsColor flash,flash,flash
  48. Cls
  49. If KeyDown(203) TurnEntity cam,0,+1,0 ;cursors to move
  50. If KeyDown(205) TurnEntity cam,0,-1,0
  51. If KeyDown(200) TurnEntity cam,+1,0,0
  52. If KeyDown(208) TurnEntity cam,-1,0,0
  53. If KeyDown(44) MoveEntity cam,0,0,-8 ;A - fly foward
  54. If KeyDown(30) MoveEntity cam,0,0,8 ;Z - fly backward
  55. UpdateWorld
  56. RenderWorld
  57. Flip
  58. Wend
  59. ;Freeup entity's and textures
  60. FreeTexture tex0
  61. FreeTexture tex1
  62. FreeTexture tex2
  63. FreeTexture tex3
  64. FreeEntity terr
  65. FreeEntity plane
  66. FreeEntity cam
  67. EndGraphics
  68. End