|
| 11 Aug 2012 05:57 PM |
| How do I make a script that can tell if the player's camera is pointing at the sun, or in a particular direction? |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 11 Aug 2012 06:01 PM |
Use the dot product of the sun direction and camera.CoordinateFrame.lookVector
|
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 06:04 PM |
@su8; What do you mean?
☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☜☆☞▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞ - Candymaniac, a highly reactive substance. |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 06:07 PM |
| Basicly (I know its a long shot :D), I was inspired by the New Crysis 3 engine to create lense flare, and I'm trying to make a function that checks to see if your camera angle is within a certain range from the angle of the sun, so I can make a gui lense flare. |
|
|
| Report Abuse |
|
|
|
| 11 Aug 2012 09:05 PM |
sun is party of the skybox boi so check into that you will have to find a location and * falls asleep in bore *. |
|
|
| Report Abuse |
|
|
L3GabeL4
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 808 |
|
|
| 11 Aug 2012 09:06 PM |
| The sun is located at 0x and 0.1y. |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 11 Aug 2012 10:00 PM |
local isLookingAtSun = (workspace.Camera.CoordinateFrame.lookVector - game.Lighting:GetSunDirection()).magnitude < 0.5 then
print(isLookingAtSun) --> true if true, false if false |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 11 Aug 2012 10:05 PM |
Also...
1 = Full view (of screen) 0.5 = Half view 0.25 = Quarter view
So, when playing with your radius, use a scale of 0 - 1. Meant to suggest this in my last post. |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 11 Aug 2012 10:09 PM |
| Thought this was Scripting Helpers. Should post in that forum next time you have a rbx.lua code related question. |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 05:23 AM |
i think its something liek
trigonometricThingie=camera.CoordinateFrame.lookVector:Dot(sundirection)
if trigonometricThingie>0 then print("IT BURRRNNNSNSSSS") end
im not sure if camera.CoordinateFrame has the camera direction (you might need to calculate it from the coordinateframe and focus or something if coordframe only has the position...)
and idk how to get sun direction but i assume its some method of lighting |
|
|
| Report Abuse |
|
|
RA2lover
|
  |
| Joined: 09 Nov 2008 |
| Total Posts: 1254 |
|
|
| 12 Aug 2012 07:16 AM |
| it's a method of lightning. |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 12:02 PM |
Ok I made a quick lens-flare effect for all of you if you want to use. It's open-sourced and can be found in my models. I used nate's method with a few of my own to avoid the lens flare effect from working at night time.
☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☜☆☞▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞ - Candymaniac, a highly reactive substance. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 12 Aug 2012 12:09 PM |
I've seen a real lens flare effect before on ROBLOX.
You have to project positions onto the screen from the 'World' view or whatnot. |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 12:11 PM |
@Quenty; I think oysi made one with that method.
☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☜☆☞▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞ - Candymaniac, a highly reactive substance. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 12 Aug 2012 04:20 PM |
Ayy, don't judge. I don't care what code the OP uses. There are multiple ways of doing this and I just did it one of the ways.
Big whoop. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 12 Aug 2012 04:38 PM |
| I didn't take it offensively :o? |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 04:40 PM |
@Oysi; If I did it your way then I'll be able to have that multiple flares effect?
☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☜☆☞▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞ - Candymaniac, a highly reactive substance. |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 05:00 PM |
| Oysi, your function works, except it makes the glare happen looking the excat opposite direction of the sun. How can I fix this? |
|
|
| Report Abuse |
|
|
Tom11255
|
  |
| Joined: 09 Nov 2010 |
| Total Posts: 365 |
|
|
| 12 Aug 2012 05:01 PM |
| Im thinking you mean SKYBOX. |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 05:03 PM |
| Never mind, it works great, I messed up the inequality. I will publish for free use when complete. |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 05:16 PM |
| Finished it. I will post a link when its done moderating! Thanks again! |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2012 05:25 PM |
Rubiks, you might want to make it so that the intensity is defined by the ratio at how close the camera is to the sun, so you can make the intensity much more smooth, not by pre-defined variables.
☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☜☆☞▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞ - Candymaniac, a highly reactive substance. |
|
|
| Report Abuse |
|
|