December 03, 2020, 08:45:16 PM

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

Offline BlitzBot

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

Description : Probably not useful for Games but nice looking in Demos etc.

Code :
Code: BlitzBasic
  1. ; Glass FX by norc of CSP
  2. Graphics3D 640,480,16,2
  3. SetBuffer BackBuffer()
  4.  
  5. ; -----------------create a scene---------------------
  6. Global camera=CreateCamera()
  7. MoveEntity camera,0,5,-50
  8. li=CreateLight()
  9. RotateEntity li,45,45,45
  10. ter=CreateCube()
  11. ScaleEntity ter,50,50,50
  12. tertex=CreateTexture(128,128)
  13. Color 0,255,0
  14. SetBuffer TextureBuffer(tertex)
  15. For j=0 To 15
  16.  For i=0 To 15
  17.   Rect i*16,0,5,128
  18.   Rect 0,j*16,128,5
  19.  Next
  20. Next
  21. Color 255,0,0
  22. Text 0,64,"Hello world",0,1
  23. SetBuffer BackBuffer()
  24. FlipMesh ter
  25. EntityTexture ter,tertex
  26.  
  27. For i=0 To 15
  28.  cube=CreateCube()
  29.  If Rand(100)>50
  30.   PositionEntity cube,49,Rand(-49,49),Rand(-49,49)
  31.  Else
  32.   PositionEntity cube,Rand(-49,49),Rand(-49,49),49
  33.  EndIf
  34.  EntityColor cube,Rand(255),Rand(255),Rand(255)
  35.  ScaleEntity cube,Rnd(2,10),Rnd(2,10),Rnd(2,10)
  36.  RotateEntity cube,Rand(360),Rand(360),Rand(360),1
  37.  EntityParent cube,ter
  38. Next
  39. TurnEntity ter,0,45,0
  40. ; ----------------eo scene----------------
  41.  
  42.  
  43.  
  44. Global glass_o=CreateSphere(12)
  45. Global glass_i=CreateSphere(12)
  46. ScaleEntity glass_o,15,15,15
  47. ScaleEntity glass_i,13.5,13.5,13.5
  48. FlipMesh glass_o
  49. ;EntityFX glass_i,1
  50. ;EntityFX glass_o,1
  51.  
  52.  
  53. Global texs=256 ; glass texture size
  54. Global tex2=CreateTexture(texs,texs,9) ; use Bit 256 here - something's wrong with my machine...
  55. EntityTexture glass_i,tex2
  56. EntityTexture glass_o,tex2
  57. ;probably add enviroment mapping on the outter hull (using texture index 1 and FX 16 or as a seperate Mesh)
  58. EntityParent glass_o,glass_i
  59.  
  60. ;-------------
  61. While KeyDown(1)=0
  62.  a#=a#+2 Mod 360
  63.  PositionEntity glass_i,Cos(a#)*15,Sin(a#)*15,0,1
  64.  mapglass()
  65.  RenderWorld()
  66.  Flip
  67. Wend
  68. End
  69. ; -----------
  70.  
  71. Function mapglass()
  72.  oro#=EntityRoll(camera,1)
  73.  oya#=EntityYaw(camera,1)
  74.  opi#=EntityPitch(camera,1)
  75.  ox#=EntityX(camera,1)
  76.  oy#=EntityY(camera,1)
  77.  oz#=EntityZ(camera,1)
  78.  CameraZoom camera,1.1 ; check it out
  79.  PointEntity camera,glass_i
  80.  PositionEntity camera,EntityX(glass_i,1),EntityY(glass_i,1),EntityZ(glass_i,1),1
  81.  CameraViewport camera,0,0,texs,texs
  82.  HideEntity glass_i
  83.  HideEntity glass_o
  84.  RenderWorld()
  85.  CopyRect 0,0,texs,texs,0,0,BackBuffer(),TextureBuffer(tex2)
  86.  ShowEntity glass_i
  87.  ShowEntity glass_o
  88.  CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight()
  89.  PositionEntity camera,ox,oy,oz,1
  90.  RotateEntity camera,opi,oya,oro,1
  91.  CameraZoom camera,1.0
  92. End Function


Comments :


Clyde(Posted 1+ years ago)

 Cheers for a great effect dude :)


puki(Posted 1+ years ago)

 Did "jfk" just release this?  I've had this for yonks.  The reason I mention this is I have just noticed that the code archives don't show the submission date for the intial code.  This needs fixing (in my opinion).


Filax(Posted 1+ years ago)

 A little update :)
Code: [Select]
; Glass FX by norc modified by filax
Graphics3D 640,480,16,2
SetBuffer BackBuffer()

Type Effect_Glass
Field Camera
Field EntityIn
Field EntityOut
Field Scale#
Field Border#
Field Glass
Field Reflect
End Type

Function Proc_CreateGlassSphere(Camera,Scale#,Border#,ReflectMap$)
F.Effect_Glass=New Effect_Glass
FCamera=Camera
FEntityIn=CreateSphere(30)
FEntityOut=CreateSphere(20)
FScale#=Scale#
FBorder#=Border#

FGlass=CreateTexture(128,128)
FReflect=LoadTexture(ReflectMap$,64)

ScaleEntity FEntityIn,FScale#-FBorder#,FScale#-FBorder#,FScale#-FBorder#
ScaleEntity FEntityOut,FScale#,FScale#,FScale#

EntityTexture FEntityIn,FGlass,0,0
EntityTexture FEntityOut,FGlass,0,0

EntityTexture FEntityIn,FReflect,0,1
EntityTexture FEntityOut,FReflect,0,1

TextureBlend FReflect,3

FlipMesh FEntityOut

EntityShininess FEntityIn,1
EntityShininess FEntityOut,1

EntityParent FEntityOut,FEntityIn

Return FEntityIn
End Function

Function Proc_UpdateGlassSphere()
For F.Effect_Glass=Each Effect_Glass
Obj_Roll#=EntityRoll(FCamera,1)
Obj_Yaw#=EntityYaw(FCamera,1)
  Obj_Pitch#=EntityPitch(FCamera,1)
  Obj_Px#=EntityX(FCamera,1)
  Obj_Py#=EntityY(FCamera,1)
  Obj_Pz#=EntityZ(FCamera,1)

CameraZoom FCamera,1.3 ; check it out
  PointEntity FCamera,FEntityIn
  PositionEntity FCamera,EntityX(FEntityIn,1),EntityY(FEntityIn,1),EntityZ(FEntityIn,1),1
 
  CameraViewport camera,0,0,TextureWidth(FGlass),TextureHeight(FGlass)
  HideEntity FEntityIn
  HideEntity FEntityOut

  RenderWorld()

CopyRect 0,0,TextureWidth(FGlass),TextureHeight(FGlass),0,0,BackBuffer(),TextureBuffer(FGlass)

ShowEntity FEntityIn
  ShowEntity FEntityOut
  CameraViewport FCamera,0,0,GraphicsWidth(),GraphicsHeight()
  PositionEntity FCamera,Obj_Px,Obj_Py,Obj_Pz,1
  RotateEntity FCamera,Obj_Pitch,Obj_Yaw,Obj_Roll,1
  CameraZoom FCamera,1.0
Next
End Function

; -----------------create a scene---------------------
Global camera=CreateCamera()
MoveEntity camera,0,5,-50
li1=CreateLight(2)
PositionEntity li1,-45,45,-45
LightRange li1,100

li2=CreateLight(2)
PositionEntity li2,45,-45,45
LightRange li2,100

ter=CreateCube()
ScaleEntity ter,50,50,50
tertex=CreateTexture(128,128)
Color 0,255,0
SetBuffer TextureBuffer(tertex)
For j=0 To 15
 For i=0 To 15
  Rect i*16,0,5,128
  Rect 0,j*16,128,5
 Next
Next
Color 255,0,0
Text 0,64,"Hello world",0,1
SetBuffer BackBuffer()
FlipMesh ter
EntityTexture ter,tertex

For i=0 To 15
 cube=CreateCube()
 If Rand(100)>50
  PositionEntity cube,49,Rand(-49,49),Rand(-49,49)
 Else
  PositionEntity cube,Rand(-49,49),Rand(-49,49),49
 EndIf
 EntityColor cube,Rand(255),Rand(255),Rand(255)
 ScaleEntity cube,Rnd(2,10),Rnd(2,10),Rnd(2,10)
 RotateEntity cube,Rand(360),Rand(360),Rand(360),1
 EntityParent cube,ter
Next
TurnEntity ter,0,45,0


MyMesh1=Proc_CreateGlassSphere(Camera,15,1,"C:FilouDemo CodingDatas-SyncronizBackground 01.jpg")
MyMesh2=Proc_CreateGlassSphere(Camera,15,1,"C:FilouDemo CodingDatas-SyncronizBackground 02.jpg")

;-------------
While KeyDown(1)=0
 a#=a#+2 Mod 360

 PositionEntity MyMesh1,Cos(a#)*15,Sin(a#)*15,Cos(a#)*15,1
 PositionEntity MyMesh2,-Cos(a#)*15,-Sin(a#)*15,-Cos(a#)*15,1
;PositionTexture tex3 ,0,a#/160
;RotateTexture tex3 ,a#/13


 Proc_UpdateGlassSphere()
 
 RenderWorld()
 Flip
Wend
End



RemiD(Posted 1+ years ago)

 @jfk>>very nice effect !


Dan(Posted 1+ years ago)

 I havent sleept very well, last night, so i thought it was a new effect, but on a closer look:
Code: [Select]
Filax (Posted 11 years ago)
Code: [Select]
RemiD (Posted 11 hours ago)
)yeah, its a nice code, and runs at <a href="
" target="_blank">ludicrous speed[/url], when flip is set to false [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal