Ooops
October 28, 2021, 12:17:43

Author Topic: [bb] OPIS2 by Baystep Productions [ 1+ years ago ]  (Read 633 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] OPIS2 by Baystep Productions [ 1+ years ago ]
« on: June 29, 2017, 00:28:40 »
Title : OPIS2
Author : Baystep Productions
Posted : 1+ years ago

Description : I made this to make things easier for me. It takes a color map ("OPI.BMP") runs through all the pixels and traps the green dots, and translates their position into a new blitz file. Then I include the file it made, use the replace tool in the EDIT menu. to replace "replc" with my basic tree. The only problem is the height. It uses terrainheight function but that doesn't work well with scales. So thats why its not in the toolbox... figure it out. Oh yah, I used this in my project Kartoon. Check it out in the worklog area. See that it works ;)

Code :
Code: BlitzBasic
  1. ; You need a few files to use this.
  2. ; First a "ground.bmp" texture file:
  3. ; It's only used in the test mode.
  4. ; Second a heightmap by the name of "level.bmp"
  5. ; Third a water.bmp texture: for the water.
  6. ; And lastly the OPI.BMP file: I just copy the heightmap
  7. ; and put some green dots where I need to. It's easier.
  8. Graphics 640,480,16,0
  9. AppTitle "Information for OPIS"
  10. scales%=Input$("Map Scale:")
  11.  
  12. Graphics3D 800,600,32,0
  13. AppTitle "OPIS version 2"
  14. SetBuffer BackBuffer()
  15.  
  16. Const obj=1,scn=2
  17. Global opi=LoadImage("opi.bmp")
  18. Global gx,gy,clrr,clrg,clrb
  19. Global ltimer$
  20.  
  21. cam=CreateCamera()
  22. PositionEntity cam,0,100,0
  23. EntityType cam,obj
  24. EntityRadius cam,10
  25.  
  26. light=CreateLight()
  27. RotateEntity light,90,0,0
  28.  
  29. land=LoadTerrain("level.bmp")
  30. ScaleEntity land,scales,95,scales
  31. TerrainDetail land,8000
  32. EntityType land,scn
  33.  
  34. water=CreatePlane()
  35. PositionEntity water,0,15.5,0
  36.  
  37. watertex=LoadBrush("water.bmp",2,6,6)
  38. BrushAlpha watertex,.5
  39. PaintEntity water,watertex
  40.  
  41. ground=LoadTexture("ground.bmp",512)
  42. EntityTexture land,ground
  43. ScaleTexture ground,512,512
  44.  
  45. tree=CreateCylinder()
  46. ScaleEntity tree,4,25,4
  47. EntityColor tree,0,0,320
  48. EntityType tree,scn
  49.  
  50. imgsize=ImageWidth(opi)
  51.  
  52. temp=WriteFile("temperary.tmp")
  53. WriteLine(temp,";Use the replace tool in Blitz3D to replace 'replc' with the tree")
  54. WriteLine(temp,"Global imgsize="+imgsize)
  55.  
  56. SetBuffer FrontBuffer()
  57. For gx=0 To imgsize
  58.         For gy=0 To imgsize
  59.                 DrawImage(opi,0,0)
  60.                 GetColor gx,gy
  61.                 clrr=ColorRed():clrg=ColorGreen():clrb=ColorBlue()
  62.                 posx=gx*scales
  63.                 posy=(TerrainSize(land)*scales)-(gy*scales)
  64.                 If clrr=0 And clrg=255 And clrb=0
  65.                         trees=CopyEntity(tree)
  66.                         ScaleEntity trees,4,25,4
  67.                         EntityColor trees,0,0,320
  68.                         EntityType trees,scn
  69.                         PositionEntity trees,posx,TerrainHeight(land,posx,posy)+50,posy,1
  70.                         WriteLine(temp,"tree=CopyEntity(replc)")
  71.                         WriteLine(temp,"PositionEntity tree,"+posx+",TerrainHeight(land,"+posx+","+posy+"),"+posy+",1")
  72.                 EndIf
  73.                 If gx<100 Then ltimer$="|||||"
  74.                 If gx>100 And gx<150 Then ltimer$="||||||||||"
  75.                 If gx>150 And gx<200 Then ltimer$="|||||||||||||||"
  76.                 If gx>200 And gx<250 Then ltimer$="||||||||||||||||||||"
  77.                 If gx>250 And gx<300 Then ltimer$="|||||||||||||||||||||||||"
  78.                 If gx>300 And gx<350 Then ltimer$="||||||||||||||||||||||||||||||"
  79.                 If gx>350 And gx<400 Then ltimer$="|||||||||||||||||||||||||||||||||||"
  80.                 If gx>400 And gx<450 Then ltimer$="||||||||||||||||||||||||||||||||||||||||"
  81.                 If gx>450 And gx<500 Then ltimer$="|||||||||||||||||||||||||||||||||||||||||||||"
  82.                 If gx>500 And gx<550 Then ltimer$="|||||||||||||||||||||||||||||||||||||||||||||||||| Done"
  83.                 Text 10,575,"Image Size:"+imgsize
  84.                 Text 10,585,"Loading..."+ltimer$
  85.         Next
  86. Next
  87. SetBuffer BackBuffer()
  88. CloseFile(temp)
  89. Color 255,255,255
  90.  
  91. Collisions obj,scn,2,3
  92.  
  93. While Not KeyHit(1)
  94.         If KeyDown(203) Then TurnEntity cam,0,1,0
  95.         If KeyDown(205) Then TurnEntity cam,0,-1,0
  96.         If KeyDown(200) Then MoveEntity cam,0,0,1
  97.         If KeyDown(208) Then MoveEntity cam,0,0,-1
  98.         If KeyHit(59)
  99.                 CopyFile "temperary.tmp","OPIS.bb"
  100.         End If
  101.         UpdateWorld
  102.          TranslateEntity cam,0,-.1,0
  103.         RenderWorld
  104.         Text 10,10,"Terrain Width: "+TerrainSize(land)
  105.         Text 10,25,"Position: "+EntityX(cam,1)+","+EntityY(cam,1)+","+EntityZ(cam,1)
  106.         Text 10,40,"Terrian Height: "+TerrainHeight(land,EntityX(cam,1),EntityZ(cam,1))*512
  107.         Flip
  108. Wend
  109.  
  110. End


Comments :


Baystep Productions(Posted 1+ years ago)

 That's great stuff you got there!!! Hurray for the time saver!!!You guys don't pay much attention.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal