PDA

View Full Version : Lightning script



Macros The Black
13-03-2009, 12:47
-------------------------------------------------------Lightning v1-----------------------------------------------------------

Firstly this is the first script i have written on my own without help and all criticism (good and bad) is most welcome.

"One must accept criticism in all its forms , For only then will ones knowledge grow"


I have been working on a script to create lightning using %GL_LINE_STRIP and vertex coordinates.
Not very complex at the moment but i will post script so you can see what i have created so far.
The lightning works alright but i need to sort out timing issues.
Currently you can call a lightning bolt by pressing 2 but it is still under development so it doesnt work properly yet.
The biggest trouble is that it creates more than one lightning bolt.
I know this is something to do with how i have made the lightning.
When it is called i want just one bolt but i have to spend more time to get this right.
The final script will have the lightning being called at random start positions at cloud level and targeting random position on the ground or terrain.

Anyway if you mess around with this script please post the modifications you make so everyone can benefit

ErosOlmi
13-03-2009, 14:03
Very nice !

Here my hints (but please consider I'm not a graphic or OpenGl/TBGL expert :oops: )

it is not needed to include
#INCLUDE "%APP_INCLUDEPATH%\thinbasic_gl.inc"
#INCLUDE "%APP_INCLUDEPATH%\thinbasic_glu.inc"
unless you want to directly call OpenGL functions or you need OpenGL equates. I think TBGL has already all of the needed functions and equates defined
#MINVERSION 1.6.0.10
I suppose you just copied that line from an old script. #MINVERSION statement is used to be able to stop execution of a script if thinBasic version is less than the one indicated by #MINVERSION statement. This command was developed because we update thinBasic quite often adding new command and functionalities. If developer uses a function or a feature present only starting from one version, it is good to indicate it. So maybe now you can indicate #MINVERSION 1.7.7
lightning is fired only once the first time "2" is pressed. Maybe by choice. Otherwise put "Effect=0" just after "PostProcess_Render_Glow(2, 18, 255,255,255)"


Ciao
Eros

Petr Schreiber
13-03-2009, 15:06
Hi,

very nice script.

I did few modifications to your code - lighting is cached to display list as white, plus postprocessed with sort of blue glow.

TBGL_GetWindowKeyOnce prevents "holding 2" from generating lightnings when you hold key, it is launched only when you press the key.


Petr

P.S. Little hint to consider, not implemented in code below - RND(a,b) returns integer number between a and b, while RNDF returns floating point number between a and b - more variety.

peter
13-03-2009, 17:07
Hi,

Lighting_B script is not running here.
i have only a black window!

Petr Schreiber
13-03-2009, 17:19
Peter,

did you tried to press key "2" ?
Can you tell me what is your graphic card?
Does it help when you change PostProcess_Init( 255, 512 ) to PostProcess_Init( 1, 4 ) ?

Thanks,
Petr

peter
13-03-2009, 17:45
Excuse me!
i did not hit the 2, a shame not exact to look.
it's running now !
Peter.

Petr Schreiber
13-03-2009, 17:46
No problem,

thank you :)


Petr