Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


How to know if an object is blocking my view of a light
jorgeas80 Offline
Junior Member

Posts: 21
Threads: 7
Joined: Jan 2014
Reputation: 0
#1
How to know if an object is blocking my view of a light

I know how to get the objects that are affected by a light and if they cast shadows. But I need to know if an object is blocking my view of a light. For example, if I'm in a room with a light, but I have a column in front of me, hiding the light.

Is there any method that calculates this kind of scenario?

Many thanks in advance
03-17-2014, 11:23 AM
Website Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: How to know if an object is blocking my view of a light

This is how I interpreted your question. If I am wrong, I apologise.

Well, the most obvious thing is that if a solid object is between you and a light, you get a shadow.

[Image: 28.105.3.1.GIF]

Where the light source is, try creating a spotlight which points off in a certain direction or interest, with cast shadows set to on. If light passes through the static_objects (I think static objects, and some entities cast shadows), the shadow will be created for you.

Bear in mind though, that your room, although it does not have a global light source, a well lit room will produce little to no shadow.

This is where shadow is used incorrectly, because the room is too bright for the shadows (Notably the candlestick near the back wall should compensate for that wall shadow above it):
[Image: P05sg4C.jpg]
Source: Helena

This one is used correctly. Little light coming in from the window and the boundaries of the light can be defined, but the gobo (found in spotlight settings) is there and shows the window frames in a shadowed form.
[Image: 3951328DF271B1BE8CBA3C207A440CB1A73C0742]
Source: Screenshot Criticism Thread

Discord: Romulator#0001
[Image: 3f6f01a904.png]
03-17-2014, 11:36 AM
Find
jorgeas80 Offline
Junior Member

Posts: 21
Threads: 7
Joined: Jan 2014
Reputation: 0
#3
RE: How to know if an object is blocking my view of a light

Many thanks for your response. I think I'm close to the solution. Let me put things more clear here.

I have a lighting device (aka lamp) connected with Penumbra: Overture via HPL1Engine. I mean, I can turn it on and off using C++ code, and even pick the color of the light (RGB). So, when I approach a light (like a candle), I turn my lamp on. When I go away from it, I turn it off. When the player uses his glowstick or flashlight, I turn my lamp on with green or white color. Etc.

I think you get the point: Light in the game --> My lamp.

I'm facing the last problem: objects blocking the light. So, if I'm close to a light in the game, I want my lamp to be turned on. But if an object is between me (the camera) and light, I want to turn off my lamp. Classic example is when I'm approaching a light (lamp turned on) but I run behind a column: the lamp is momentarily turned off.

So, in general, if I'm in the range of a light but I get objects blocking my view of it (a column, a wall, an enemy... anything), I want to detect that, to turn my lamp off. Reading your comment, I may use the fact that I know the list of static and dynamic casters associated with a Light3D object, but not sure about how, or if it's the better approach.
03-17-2014, 11:55 AM
Website Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#4
RE: How to know if an object is blocking my view of a light

Ahh yes. I am silly, HPL1 engine Tongue

I do not think that there is necessarily code for it actually :c Never worked in HPL1, and I don't think you can compare yourself to the distance seperating you from one object to another, and hence, the light source, unless you screw around with some core codes, but I wouldn't know when to start.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
03-17-2014, 11:58 AM
Find
jorgeas80 Offline
Junior Member

Posts: 21
Threads: 7
Joined: Jan 2014
Reputation: 0
#5
RE: How to know if an object is blocking my view of a light

Yep, I'm actually touching the core. Basically, Light3D and Renderer3D classes. All my little changes have worked, so far. I just need to solve this last problem. I think I'm close...

Thanks for your responses!
03-17-2014, 12:19 PM
Website Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#6
RE: How to know if an object is blocking my view of a light

Actually, I just had a think, does Penumbra incorporate a "night vision" function per se? Like, when you get in a darker environment the screen compensates by creating a different form of vision to allow you to see clearer?

If so, you may be able to adjust the settings related to that, being able to detect when your in a darker situation (behind a pillar/wall etc) so that the lamp does not activate?

The only other thing I can think of is if you can detect that you are within a Script area boundary, and if so, don't turn on the lamp, which can be checked constantly every, say, 10th's of a second?

Just some suggestions. Would be a bit messy, but that's all I can think of right now Smile

Discord: Romulator#0001
[Image: 3f6f01a904.png]
03-17-2014, 12:56 PM
Find
jorgeas80 Offline
Junior Member

Posts: 21
Threads: 7
Joined: Jan 2014
Reputation: 0
#7
RE: How to know if an object is blocking my view of a light

Yes, Penumbra has the "night vision" function, but just when I hit Left Ctrl (crouch). That could be a thing...

But I think I need something more generic. For example, if I'm behind a wall, and at the other side of the wall there's a light point, my lamp turns on, because I'm within the range of that light. Regardless the room I'm in it's totally dark of not. I Need to detect the wall between me and the light.

About the script area boundary, I'm not following you. I guess a script area is some part of the game where something happens (and raises a script). Can't see the relation between that fact and the lights.
03-17-2014, 02:34 PM
Website Find




Users browsing this thread: 1 Guest(s)