November 28, 2020, 02:27:33 PM

### Author Topic: [bb] Geometric based per-entity glow by Rob [ 1+ years ago ]  (Read 548 times)

#### BlitzBot

• Jr. Member
• Posts: 1
##### [bb] Geometric based per-entity glow by Rob [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : Geometric based per-entity glow
Author : Rob
Posted : 1+ years ago

Description : This routine can be optimised quite a bit. It was designed this way for immediate ease-of-use.

It creates many copies of a mesh to achieve the desired effect. You can pre-copy to obtain a speedup, you can expand/contract the vertices for a more accurate scaling (neccesary - see rob.p's toon code and robins mesh code). You can also use it as the basis for more recipe ideas.

Code :
Code: BlitzBasic
1. ;GEOMETRIC GLOW TEST - Rob Cummings
3.
4.
5. ;KEEPS TRACK OF ENTITIES
6. Type entlist
7.         Field ent
8. End Type
9.
10.
11. Graphics3D 1024,768,32,2
12. AmbientLight(10,10,20)
13. light=CreateLight()
14. PositionEntity light,-500,5000,2000
15. LightColor light,200,200,200
16. RotateEntity light,45,45,0
17.
18. camera = CreateCamera()
19.
20. ob1 = CreateCylinder()
21. PositionEntity ob1,0,1,7
22. EntityColor ob1,0,0,255
23. EntityFX ob1,1
25.
26. ob2 = CreateCone()
27. PositionEntity ob2,-4,1,7
28. EntityColor ob2,0,255,0
29. EntityFX ob2,1
31.
32. ob3 = CreateSphere()
33. PositionEntity ob3,4,1,7
34. EntityColor ob3,255,255,255
36.
37. column = CreateCylinder()
38. ScaleEntity column,2,100,2
39. PositionEntity column,50,0,100
40. EntityColor column,255,0,0
41. EntityFX column,1
43.
44.
45. While Not KeyHit(1)
46.         TurnEntity ob1,1,1,1
47.         TurnEntity ob2,1,1,1
48.         TurnEntity ob3,1,1,1
49.         TurnEntity column,1,1,1
50.         UpdateWorld
51.         RenderWorld
52.
53.         EntityGlow(camera,ob1,4,.2,50,50,255)
54.         EntityGlow(camera,ob2,3,.05,50,255,50)
55.         EntityGlow(camera,ob3,2,.05,255,255,0)
56.
57.
58.         Flip
59. Wend
60. End
61.
62.
63. Function EntityGlow(eg_cam,eg_ent,eg_glowsteps=1,eg_glowsize#=.1,eg_r=-1,eg_g=-1,eg_b=-1)
64.         hideworld()
65.         eg_pivot=CreatePivot()
66.         For eg_i=eg_glowsteps To 1 Step -1
67.                 eg_glowent=CopyMesh(eg_ent)
68.                 ShowEntity eg_glowent
69.                 PositionEntity eg_glowent,EntityX(eg_ent),EntityY(eg_ent),EntityZ(eg_ent)
70.                 RotateEntity eg_glowent,EntityPitch(eg_ent),EntityYaw(eg_ent),EntityRoll(eg_ent)
71.                 EntityFX eg_glowent,1
72.                 EntityBlend eg_glowent,3 ;optional
73.                 ScaleMesh eg_glowent,1+eg_glowsize*eg_i,1+eg_glowsize*eg_i,1+eg_glowsize*eg_i
74.                 EntityAlpha eg_glowent,0.1
75.                 EntityParent eg_glowent,eg_pivot
76.                 If (eg_r+eg_g+eg_b)>0 EntityColor eg_glowent,eg_r,eg_g,eg_b
77.         Next
78.         CameraClsMode eg_cam,0,0:RenderWorld:CameraClsMode eg_cam,1,1
79.         For i=1 To CountChildren(eg_pivot):FreeEntity GetChild(eg_pivot,i):Next
80.         FreeEntity eg_pivot
81.         showworld()
82. End Function
83.
84.
85. ;HOUSEKEEPING FUNCTIONS
86.
88.         e.entlist=New entlist
89.         eent=ent
90. End Function
91. Function HideWorld()
92.         For e.entlist=Each entlist
93.                 HideEntity eent
94.         Next
95. End Function
96. Function ShowWorld()
97.         For e.entlist=Each entlist
98.                 ShowEntity eent
99.         Next
100. End Function
101. Function DeleteEnt(ent)
102.         For e.entlist=Each entlist
103.                 If eent=ent
104.                         Delete e
105.                         Exit
106.                 EndIf
107.         Next
108. End Function
109. Function ClearEntList()
110.                 Delete Each entlist
111. End Function