December 04, 2020, 11:04:16 AM

Author Topic: [bb] MediaView Enhanced by superqix [ 1+ years ago ]  (Read 618 times)

Offline BlitzBot

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

Description : Attached is a new version of the MediaView that I enhanced with B3D support, spot and ambient light control, zoom in and out, Mesh Width, Height, and Depth data and some Windows XP fixes for Drag and Drop.  Plus this version doesn't scale the model, so what you see (size wise) is what you get.

Code :
Code: BlitzBasic
  1. ;Blitz media viewer.
  2. ;
  3. ;Create executable in 'bin'
  4.  
  5. AppTitle CommandLine$()
  6. fil$=Trim$(Replace(Lower$( CommandLine$()),Chr$(34),Chr$(32)))
  7.  
  8.  
  9. index=Instr( fil$,"." )
  10. If index>0 ext$=Mid$( fil$,index+1 )
  11.  
  12. Select ext$
  13. Case "x","3ds","b3d"
  14.         ShowModel( fil$,False )
  15. Case "md2"
  16.         ShowModel( fil$,True )
  17. Case "bmp","jpg","png","pcx","tga","iff"
  18.         ShowImage( fil$ )
  19. Case "wav"
  20.         ShowSound( fil$ )
  21. Case "mp3","mid","mod","x3m","xm","it"
  22.         ShowMusic( fil$ )
  23. Default
  24.         RuntimeError "Unknown File Extension ("+ext$+")"
  25. End Select
  26.  
  27. End
  28.  
  29. Function ShowModel( fil$,md2 )
  30.         If Windowed3D()
  31.                 Graphics3D 512,384,0,2
  32.         Else
  33.                 Graphics3D 640,480,0,1
  34.         EndIf
  35.         If md2
  36.                 model=LoadMD2( fil$ )
  37. ;               If model ScaleEntity model,.025,.025,.025
  38.         Else
  39.                 model=LoadMesh( fil$ )
  40. ;               If model FitMesh model,-1,-1,-1,2,2,2,True
  41.         EndIf
  42.         If model=0 RuntimeError "Unable to load 3D mesh:"+fil$
  43.         sc=CountSurfaces(model)
  44.         For k=1 To sc
  45.                 vc=vc+CountVertices( GetSurface( model,k ) )
  46.                 tc=tc+CountTriangles( GetSurface( model,k ) )
  47.         Next
  48.         camera=CreateCamera()
  49.         CameraClsColor camera,0,0,64
  50.         CameraRange camera,.01,10
  51.         xr#=0:yr#=0:z#=2.1
  52.         light=CreateLight()
  53.         TurnEntity light,45,45,0
  54.         bright = 255
  55.         abright = 128
  56.         Repeat
  57.                 RotateEntity model,xr,yr,0
  58.                 PositionEntity model,0,0,z
  59.                 If bright > 255 Then bright = 255
  60.                 If bright < -255 Then bright = -255
  61.                 LightColor light,bright,bright,bright
  62.                 If abright > 255 Then abright = 255
  63.                 If abright < 0 Then abright = 0
  64.                 AmbientLight abright,abright,abright
  65.                 UpdateWorld
  66.                 RenderWorld
  67.         Text 10,10,"Triangles: "+tc+" Vertices: "+vc+" Surfaces: "+sc
  68.           Text 10,22,"Point Light (-/+): "+bright
  69.           Text 10,34,"Ambient Light ([/]): "+abright
  70.                 Text 10,46,"Mesh Width: "+MeshWidth(model)
  71.                 Text 10,58,"Mesh Height: "+MeshHeight(model)
  72.                 Text 10,70,"Mesh Depth: "+MeshDepth(model)
  73.                 Text 10,82,"Zoom (a/z): "+z
  74.                 Flip
  75.                 key=False
  76.                 Repeat
  77.                         If KeyHit(1) End
  78.                         If KeyDown(200) xr=xr-3:key=True
  79.                         If KeyDown(208) xr=xr+3:key=True
  80.                         If KeyDown(203) yr=yr+3:key=True
  81.                         If KeyDown(205) yr=yr-3:key=True
  82.                         If KeyDown( 30) z=z-.1:key=True
  83.                         If KeyDown( 44) z=z+.1:key=True
  84.                         If KeyDown( 12) bright=bright-1:key=True
  85.                         If KeyDown( 13) bright=bright+1:key=True                       
  86.                         If KeyDown( 26) abright=abright-1:key=True
  87.                         If KeyDown( 27) abright=abright+1:key=True     
  88.                         If Not key WaitKey
  89.                 Until key
  90.         Forever
  91. End Function
  92.  
  93. Function ShowImage( fil$ )
  94.         Graphics 400,300,0,2
  95.         SetBuffer BackBuffer()
  96.         image=LoadImage( fil$ )
  97.         If image=0 RuntimeError "Unable to load image:"+fil$
  98.         MidHandle image
  99.         x=200:y=150:t=4
  100.         Repeat
  101.                 Cls
  102.                 DrawImage image,x,y
  103.                 Flip
  104.                 key=False
  105.                 Repeat
  106.                         If KeyHit(1) End
  107.                         If KeyDown(200) y=y-t:key=True
  108.                         If KeyDown(208) y=y+t:key=True
  109.                         If KeyDown(203) x=x-t:key=True
  110.                         If KeyDown(205) x=x+t:key=True
  111.                         If Not key WaitKey
  112.                 Until key
  113.         Forever
  114. End Function
  115.  
  116. Function ShowSound( fil$ )
  117.         sound=LoadSound( fil$ )
  118.         If sound=0 RuntimeError "Unable to load sound:"+fil$
  119.         Repeat
  120.                 PlaySound sound
  121.                 WaitKey
  122.                 If KeyHit(1) End
  123.         Forever
  124. End Function
  125.  
  126. Function ShowMusic( fil$ )
  127.         music=PlayMusic( fil$ )
  128.         If music=0 RuntimeError "Unable to play music: "+fil$
  129.         WaitKey
  130. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal