Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / how do you do lens flare

Author
Message
ClearCoder
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 22nd Jul 2003 23:26
basiclly what it says above

cheers
clear coder
Newbie Now; Expert Later
Current project:The Sorus
http://us.f1.yahoofs.com/users/8e2ce249/bc/logo.jpg?bc6XVw.ALSzFxXyM[/img]
Robin
22
Years of Service
User Offline
Joined: 22nd Feb 2003
Location: United Kingdom
Posted: 24th Jul 2003 13:16
hmmm...id like to know this too. its something like making an object with several textured plains, positioning it at the sun and pointing it at the player. i'd also like to know how to make a sun in the sky
robin


http://www.thegameszone.tk
[email protected]
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Jul 2003 13:48
It depends on how you want to handle it - you could do it quite quickly with sprites.

Firstly, position an object at the light source, hidden, that's assuming your light source isn't already an object that you can use. You need to calculate the screen position of the light source, then the middle of the screen. Now you have the 2 coordinates, work out the 'insert complicated maths term' using x1-x2 and y1-y2, so you get the difference between them. Now, you can use this difference and multiply it between 0.0 and 2.0 to get the locations of your lens flare sprites.

So:
Position the object at the light source.
Store the screen location (if it's in the screen). [scx#,scy#]
Calculate the centre of the screen. [midx#,midy#]
Calculate the difference. [dx#,dy#]
Then, using something like:

img=1
spriteno=1
For step#=0.2 to 1.8 step 0.4
Sprite spriteno,midx#+(dx#*step#),midy#+(dy#*step#),img
inc spriteno,1
inc img,1
next step#

Now, doing this with plains is a little more tricky, because you need 3 dimensions, but if you calculate the light source XYZ location and the camera location, you can get the differences in the same way, and multiply them in the same way to get the lens positions. You would have to scale the plains so they were the right size, but no doubt there is an easier way to do it in 3D that I haven't figured out.


Van-B

My cats breath smells of cat food.
kevil
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 24th Jul 2003 15:59
Use the lock object on command . Then you can move it like in 2d. The problem with sprites is that you can't ghost them in DBC.

Kevil

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Jul 2003 16:39
Ahhh! - you mean if you lock an object to the camera it won't matter what angle it's pointing at .

I'll have a go tonight and see if I can make a little code demo (and post it here of course).

Cheers Kevil, never really messed around with locked objects. Typical that I come along trying to tell someone how to do it and end up being told myself!


Van-B

My cats breath smells of cat food.

Login to post a reply

Server time is: 2025-05-19 19:19:48
Your offset time is: 2025-05-19 19:19:48