November 25, 2020, 08:04:07 AM

Author Topic: [bb] 3D fileexplorer by OJay [ 1+ years ago ]  (Read 719 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] 3D fileexplorer by OJay [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : 3D fileexplorer
Author : OJay
Posted : 1+ years ago

Description : this is a simple 3D fileexplorer i found some time ago in the codearchives. however, i couldn't found it anymore so i repost this now.

original author unknown. if it was you, tell us!


Code :
Code: BlitzBasic
  1. ; 3D File-Explorer
  2.  
  3. Graphics3D 640,480,16,2
  4. SetBuffer BackBuffer()
  5.  
  6. Global gw#=GraphicsWidth()
  7. Global gh#=GraphicsHeight()
  8. MoveMouse gw/2,gh/2
  9.  
  10. cam=CreateCamera()
  11. Global uni=CreateSphere(7,cam)
  12. MoveEntity cam,0,2,-6
  13. li=CreateLight()
  14. RotateEntity li,80,30,30
  15. ScaleEntity uni,100,100,100
  16. FlipMesh uni
  17. EntityOrder uni,1
  18. texname$="space.jpg"
  19. If FileType(texname$)=0
  20. unitex=CreateTexture(128,128)
  21. SetBuffer TextureBuffer(unitex)
  22. For i=0 To 10000
  23.   Color Rand(255), Rand(255), Rand(255)
  24.   Plot  Rand(128), Rand(128)
  25. Next
  26. SetBuffer BackBuffer()
  27. Else
  28. unitex=LoadTexture(texname$)
  29. EndIf
  30. EntityTexture uni,unitex
  31.  
  32. Global fls#=25000 ;max 25000 Files in one Folder
  33. Dim fb_icon(fls),fb_name$(fls),fb_type(fls),fb_tex(fls),fb_sel(fls)
  34.  
  35. Global rheight#=4 ; x space between icons
  36. Global rwidth#=5  ; y space between icons
  37. Global fperline#=3 ; number of icon columns
  38.  
  39. Global iconw#=2.0 ; icon scaling
  40. Global iconh#=1.0
  41. Global icond#=.5
  42. Global stexx#=1.0 ; texure scaling
  43. Global stexy#=2.0
  44. ClearTextureFilters
  45.  
  46. font=LoadFont("Tahoma",17)
  47. SetFont font
  48.  
  49.  
  50. mx100#=(gw/2)*.9
  51. my100#=(gh/2)*.9
  52. Global camxi#=5
  53. Global camyi#=0
  54. Global camzi#=-9.2
  55. Global camx#=camxi#
  56. Global camy#=camyi#
  57. Global camz#=camzi#
  58.  
  59. RefreshDir()
  60.  
  61. ; -------------------------------------------MAIN-------------------------------------------
  62. While KeyDown(1)=0
  63. mx#=MouseX()
  64. my#=MouseY()
  65.  
  66. If my<my100
  67.   If camy<1
  68.    sty#=((my100-my)/150)^2
  69.    camy=camy+sty
  70.    If camy>1 Then camy=1
  71.   EndIf
  72. EndIf
  73. If my>gh-my100
  74.   If camy>(0-(Floor(fls/fperline)*rheight))
  75.    sty#=((my100-(gh-my))/150)^2
  76.    camy=camy-sty
  77.    If camy<(0-(Floor(fls/fperline)*rheight)) Then camy=(0-(Floor(fls/fperline)*rheight))
  78.   EndIf
  79. EndIf
  80.  
  81. If mx>gw-mx100
  82.   If camx<(fperline)*rwidth
  83.    stx#=(mx100-(gw-mx))/500
  84.    camx=camx+stx
  85.    If camx>(fperline)*rwidth Then camx=(fperline)*rwidth
  86.   EndIf
  87. EndIf
  88. If mx<mx100
  89.   If camx>-rwidth
  90.    stx#=(mx100-mx)/500
  91.    camx=camx-stx
  92.    If camx<-rwidth Then camx=-rwidth
  93.   EndIf
  94. EndIf
  95.  
  96. If MouseHit(1)
  97.   oldmhitt=mhitt
  98.   mhitt=MilliSecs()
  99.   If (mhitt-oldmhitt)<300 Then
  100.    ; -----------------------------is dooubleclick!
  101.    p=CameraPick(cam,mx,my)
  102.    If p<>0
  103.     picked_i=-1
  104.     For i=0 To fls
  105.      If fb_icon(i)=p
  106.       picked_i=i
  107.       Exit
  108.      EndIf
  109.     Next
  110.     If picked_i>-1
  111.     For roro=0 To 1000
  112.      dx#=(EntityX(fb_icon(picked_i),1)-EntityX(cam))/10.0;-EntityX(cam)
  113.      dy#=(EntityY(fb_icon(picked_i),1)-EntityY(cam))/10.0;-EntityY(cam)
  114.      dz#=(EntityZ(fb_icon(picked_i),1)-EntityZ(cam))/10.0;-EntityZ(cam)
  115.      PositionEntity cam,EntityX(cam,1)+dx,EntityY(cam,1)+dy,EntityZ(cam,1)+dz,1
  116.      TurnEntity uni,.1,.1,.1
  117.      RenderWorld()
  118.      PathInfo()
  119.      Flip
  120.      If dx<.1 And dy<.1 And dz<.1 Then Exit
  121.     Next
  122.     placebo=CopyEntity(fb_icon(picked_i))
  123. ;    FreeEntity fb_icon(picked_i)
  124.     If fb_type(picked_i)=2
  125.      ChangeDir(fb_name$(picked_i))
  126.     EndIf
  127.     EntityParent placebo,cam
  128.     camx#=camxi#
  129.     camy#=camyi#
  130.     camz#=camzi#
  131.     MoveMouse gw/2,gh/2
  132.     PositionEntity cam,camx,camy,camz,1
  133.    
  134.     If Instr(fb_name$(picked_i),".")<>0 And fb_name$(picked_i)<>".." And fb_type(picked_i)=1
  135.      ; check Media Type and probably do something (some examples)
  136.      ext$=Right$(fb_name$(picked_i), Len(fb_name$(picked_i))-Instr(fb_name$(picked_i),"."))
  137. ;Print
  138. ;Color 255,0,0
  139. ;     Print ext$
  140. ;     WaitKey()
  141.      Select Upper$(ext$)
  142.       Case "TXT"
  143.        ExecFile "notepad.exe "+fb_name$(picked_i)
  144.       Case "EXE"
  145.        ExecFile fb_name$(picked_i)
  146.       Case "HTM",".HTML"
  147.        ExecFile fb_name$(picked_i)
  148.       Case "BB"
  149.        ExecFile fb_name$(picked_i)
  150.      End Select
  151.     EndIf
  152.  
  153.     RemoveAll()
  154.     RefreshDir()
  155.  
  156.  
  157.     For al#=1.0 To 0.0 Step -.05
  158.      EntityAlpha placebo,al#
  159.      TurnEntity uni,.1,.1,.1
  160.      RenderWorld()
  161.      PathInfo()
  162.      Flip
  163.     Next
  164.     FreeEntity placebo
  165.     EndIf
  166.    EndIf    
  167.    Goto done
  168.   Else
  169.    ; -----------------------------is single click
  170.    p=CameraPick(cam,mx,my)
  171.    If p<>0
  172.     picked_i=-1
  173.     For i=0 To fls
  174.      If fb_icon(i)=p
  175.       picked_i=i
  176.       Exit
  177.      EndIf
  178.     Next
  179.     If picked_i>-1
  180.      For i=0 To fls
  181.       If fb_sel(i)<>0
  182.        If i<>picked_i
  183.         fb_sel(i)=0
  184.         EntityColor fb_icon(i),255,255,255
  185.        EndIf
  186.       EndIf
  187.      Next
  188.      fb_sel(picked_i)=fb_sel(picked_i)Xor 1
  189.      If fb_sel(picked_i)=1
  190.       EntityColor fb_icon(picked_i),75,75,255
  191.      Else
  192.       EntityColor fb_icon(picked_i),255,255,255
  193.      EndIf
  194.     EndIf
  195.    EndIf
  196.   EndIf
  197.   .done
  198. EndIf
  199.  
  200.  
  201. If KeyDown(200)
  202.   camz=camz+.1
  203. EndIf
  204. If KeyDown(208)
  205.   camz=camz-.1
  206. EndIf
  207. PositionEntity cam,camx,camy,camz,1
  208. TurnEntity uni,.1,.1,.1
  209. RenderWorld()
  210. PathInfo()
  211. Flip
  212. Wend
  213. ;--------------------------------------------eo main ------------------------------------
  214.  
  215. End
  216.  
  217. Function RefreshDir()
  218.  
  219.  
  220. ; Define what folder to start with ...
  221. folder$=CurrentDir$()
  222. myDir=ReadDir(folder$)
  223. fls=0
  224. Repeat
  225. fb_name$(fls)=NextFile$(myDir)
  226. If fb_name$(fls)<>"."
  227.   If fb_name$(fls)="" Then Exit
  228.    folder2$=folder$
  229.    If Right$(folder2$,1)<>""
  230.     folder2$=folder2$+""
  231.    EndIf
  232.    If FileType(folder2$+fb_name$(fls)) = 2 Then
  233.     fb_type(fls)=2
  234.    Else
  235.     fb_type(fls)=1
  236.    End If
  237.   fls=fls+1
  238. EndIf
  239. Forever
  240. CloseDir myDir
  241. fls=fls-1
  242.  
  243.  
  244.  
  245.  
  246.  
  247. ;fls#=Rand(10,100)
  248. ;Dim fb_icon(fls),fb_name$(fls),fb_type(fls),fb_tex(fls),fb_sel(fls)
  249.  
  250. For i=0 To fls
  251. fb_icon(i)=CreateCube()
  252. y=Floor(i/fperline)
  253. x=i-(y*fperline)
  254. PositionEntity fb_icon(i),x*rwidth,-(y*rheight),0
  255. fb_tex(i)=CreateTexture(128,128)
  256. SetBuffer TextureBuffer(fb_tex(i))
  257. If fb_type(i)=2
  258.   Color 127,127,0
  259.   Rect 0,0,256,256,1
  260. Else
  261.   Color 127,127,127
  262.   Rect 0,0,256,256,1
  263. EndIf
  264. If StringWidth(fb_name$(i))<=126
  265. Color 255,255,255
  266. Text 64,0,fb_name$(i),1,0
  267. Color 0,0,0
  268. Text 65,1,fb_name$(i),1,0
  269. Else
  270. lin$=""
  271. wchar=1
  272. ycount=0
  273. While wchar<=Len(fb_name$(i))
  274.   While StringWidth(lin$)<=122 And wchar<=Len(fb_name$(i))
  275.    lin$=lin$+Mid$(fb_name$(i),wchar,1)
  276.    wchar=wchar+1
  277.   Wend
  278.   If wchar<Len(fb_name$(i))
  279.    lin$=Left$(lin$,Len(lin$)-1)
  280.    wchar=wchar-1
  281.   EndIf
  282.   Color 255,255,255
  283.   Text 64,0+ycount*StringHeight(fb_name$(i)),lin$,1,0
  284.   Color 0,0,0
  285.   Text 65,1+ycount*StringHeight(fb_name$(i)),lin$,1,0
  286.   lin$=""
  287.   ycount=ycount+1
  288. Wend
  289. EndIf
  290. SetBuffer BackBuffer()
  291. ScaleTexture fb_tex(i),stexx,stexy
  292. EntityTexture fb_icon(i),fb_tex(i)
  293. EntityPickMode fb_icon(i),2
  294. ScaleEntity fb_icon(i),iconw,iconh,icond
  295. EntityFX fb_icon(i),16
  296. fb_sel(i)=0
  297. Next
  298.  
  299. End Function
  300.  
  301. Function RemoveAll()
  302. For i=0 To fls
  303.   FreeEntity fb_icon(i)
  304.   FreeTexture fb_tex(i)
  305. Next
  306. End Function
  307.  
  308. Function PathInfo()
  309. Color 127,127,127
  310. Text 0,0,CurrentDir$()
  311. Color 255,255,255
  312. Text 1,1,CurrentDir$()
  313. End Function


Comments :


John Blackledge(Posted 1+ years ago)

 I really like this!


degac(Posted 1+ years ago)

 never seen before! incredible!thanks for re-posting...a milestone I think


Perturbatio(Posted 1+ years ago)

 Just a thought, if it was there before but it isn't now, that could be because they never wanted it declared as public domain.


big10p(Posted 1+ years ago)

 Dunno. There's been a few peeps who have left in a huff and taken all there code arc entries with them. This entry is nice but hardly rocket science.


OJay(Posted 1+ years ago)

 <div class="quote"> ...because they never wanted it declared as public domain. </div>then he/she/it could have left a comment in the source...but there isn't. its really the original code, i haven't changed or deleted even one line...be that as it may i've posted it just because someone asked about something like that.so, just sit back and enjoy :)


Blitzplotter(Posted 1+ years ago)

 A very good example of how powerful Blitz is.  I have been a fan of Blitz since it's initial development on the Amiga.  Well done to Mark Sibly and his team.


jfk EO-11110(Posted 1+ years ago)

 It was me. Posted on a german Blitz forum some years ago (blitzforum.de). Their forum then crashed fulminantely one day and the entire content including their code archive was lost. OJay, remember? (I was named "norc").It's ok, use it.


Ked(Posted 1+ years ago)

 Really cool... I once tried to make a 2D version something similar to this but it went horribly wrong....


Blitz3dCoder(Posted 1+ years ago)

 THIS IS SWEET!


Danny(Posted 1+ years ago)

 iPhone eat your heart out! LOL :D


Darkseid2.0(Posted 1+ years ago)

 With a little more development, this could become a new trend in file browsing. I love this it's awesome beyond belief.


Guy Fawkes(Posted 1+ years ago)

 It's already happened. Lol. It's called Three.js :P


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal