Ooops
November 30, 2020, 02:26:18 AM

Author Topic: [bb] Grass by jfk EO-11110 [ 1+ years ago ]  (Read 599 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Grass by jfk EO-11110 [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Grass
Author : jfk EO-11110
Posted : 1+ years ago

Description : This Demo is using Copyentity to multiply a Quad that is textured with Grass in Alphamode (Maskmode 4 can be used as well). A Sinus-based Wind Function is animating the Grass-Quads. Surprisingly the Z-Order works ok even in Alpha Mode. Feel free to use the Textures and Code in your Blitz-Projects.
Download at <a href="http://www.melog.ch/dl/mygrass_nu.zip" target="_blank">http://www.melog.ch/dl/mygrass_nu.zip[/url]

IMPORTANT NOTICE:
MasterBeaker and Elias_t have enhanced this Project, and it is now much faster and has some extra Features.: <a href="http://telias.free.fr/temp/grass_zorder_d.zip" target="_blank">http://telias.free.fr/temp/grass_zorder_d.zip[/url]
If you use it then please mention MasterBeaker, Elias_t and me in the Credits, thanks.


Code :
Code: BlitzBasic
  1. ;Download at http://www.melog.ch/dl/mygrass_nu.zip
  2.  
  3. ;Here is a second Demo that is not included in the Zip. It
  4. ;is using the same Media Files as the Demo in the Zip. This
  5. ;is a bigger Terrain with a huge amount of grass:
  6.  
  7. ; Simple, tiny Grass Demo 2 by JFK aka NORC of CSP
  8. ;Graphics3D 1024,768,32,1
  9. Graphics3D 800,600,16,1
  10. SetBuffer BackBuffer()
  11.  
  12. Global windwave#
  13. Global grasscount
  14.  
  15. camera=CreateCamera()
  16. TranslateEntity camera,0,20,0
  17. CameraClsColor camera,80,110,120
  18. CameraFogMode camera,1
  19. CameraFogColor camera,80,110,120
  20. CameraFogRange camera,100,200
  21. CameraRange camera,1,202
  22. light=CreateLight()
  23.  
  24. terrain=LoadTerrain("hmap.jpg")
  25. ScaleEntity terrain,5,100,5
  26. TranslateEntity terrain,-320,0,-320
  27. floortex=LoadTexture("floor.jpg")
  28. ScaleTexture floortex,32/5,32/5
  29. EntityTexture terrain,floortex
  30.  
  31. quad=LoadMesh("smplquad.3ds")
  32. FitMesh quad,-10,0,0,20,20,0
  33. EntityFX quad,16 Or 1
  34. grasstex=LoadBrush("grass5f.tga",2 Or 48) ; also try Mode 4 instead of 2!
  35. PaintMesh quad,grasstex
  36.  
  37. Dim grass(100000)
  38. Dim grassa#(100000)
  39. grasscount=0
  40. For j=-250 To 250 Step 10
  41.  For i=-250 To 250 Step 10
  42.   grass(grasscount)=CopyEntity(quad)
  43.   x#=(i+Rnd(-5,5))
  44.   z#=(j+Rnd(-5,5))
  45.   y#=TerrainY(terrain,x,0,z)-Rnd(2)
  46.   PositionEntity grass(grasscount),x,y,z
  47.   grassa(grasscount)=Rand(-90,90)
  48.   grasscount=grasscount+1
  49.  Next
  50. Next
  51. HideEntity quad
  52.  
  53. ;-------------------------Mainloop-----------------------
  54. While KeyDown(1)=0
  55.  If KeyDown(200) Then MoveEntity camera,0,0,.5
  56.  If KeyDown(208) Then MoveEntity camera,0,0,-.5
  57.  mxs#=-MouseXSpeed()/4
  58.  mys#=MouseYSpeed()/4
  59.  mxa#=mxa#+mxs#
  60.  mya#=mya#+mys#
  61.  MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
  62.  PositionEntity camera,EntityX(camera),TerrainY(terrain,EntityX(camera),0,EntityZ(camera))+20,EntityZ(camera)
  63.  RotateEntity camera,mya,mxa,0
  64.  wind(15,1.0)
  65.  UpdateWorld()
  66.  RenderWorld()
  67.  Text 0,0,"Quads in Scene: "+(grasscount-1)
  68.  Text 0,12,"Tris rendered: "+TrisRendered()
  69.  Flip
  70. Wend
  71. End
  72.  
  73. Function wind(force#,speed#)
  74.  For i=0 To grasscount-1
  75.   x#=EntityX(grass(i))
  76.   z#=EntityZ(grass(i))
  77.   RotateEntity grass(i),Sin(windwave+x+grassa(i))*force#,grassa(i),Cos(windwave+z-grassa(i))*(force#/2)
  78.  Next
  79.  windwave=(windwave+speed#)Mod 360
  80. End Function


Comments :


Kissme(Posted 1+ years ago)

 Very nice !Kiss.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal