Jump to content

  • Log In with Google      Sign In   
  • Create Account

Dynamically hiding walls that block the camera


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Breadcrumb   Members   -  Reputation: 107

Like
1Likes
Like

Posted 01 August 2012 - 10:10 AM

I'm looking for a solution to dynamically hiding walls that block the camera's view of the main character.

My game has just one character, and the camera is always fixed on them, and the character moves around the scene by themselves, but the player can swing the camera around (a bit like in The Sims).


I've seen games that have walls that dynamically drop or fade when a character moves behind them, but I have no idea where to begin with this.

I'm quite happy to try out a few ideas, I just thought I'd check whether there any commonly known techniques for this.
Thanks :)

Sponsor:

#2 Radikalizm   Crossbones+   -  Reputation: 2885

Like
2Likes
Like

Posted 01 August 2012 - 10:25 AM

Doing a raycast from your camera to your character could solve this.
You simply cast a ray from your camera position to your character position and hide all objects which intersect with your ray. I don't know whether this will be effective enough for what you want, but it's a start

I gets all your texture budgets!


#3 JWalsh   Moderators   -  Reputation: 463

Like
7Likes
Like

Posted 01 August 2012 - 11:14 AM

This can be done in a couple of different ways.

1. You can do as Radikalizm stated above. You can cast a ray or some kind of bounding volume into your scene that encompasses your character model. Any models or meshes that intersect this primitive can then be disabled during draw call, or drawn with a special alpha shader that causes it to be partially transparent.

2. If you want to avoid doing any kind of ray casting and/or collision detection a more naive method is to transform your on-screen objects into screen space. Then, any object which are within a certain radius from the center of the screen can be alpha blended. This can be done on a per-vertex basis (hiding certain primitives), or even on a per-pixel basis. In truth, since you know your character is always within the 1/4 middle of the screen, you can just add code to your pixel shader to return a fully transparent pixel if the pixel coordinate is in the inner circle of the screen.

3. And yet a third way is to leverage the stencil buffer. Either using a circular stencil, or the character model as a stencil itself, you can either prevent the drawing of pixels which are over the stencil, or instead draw a red shape where your stencil is. This has the effect of not hiding objects in the foreground, but instead making it obvious where your character is behind the object. If I recall correctly, this was done very well in Torchlight.

Cheers and Good Luck!
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints

#4 mhagain   Crossbones+   -  Reputation: 7979

Like
1Likes
Like

Posted 01 August 2012 - 06:41 PM

This is just an occlusion problem, but subtly reversed. Instead of figuring which objects are blocked, you need to figure which objects block; based on that, and if you already have occlusion code, you should be able to use that to derive the necessary info.

Another method may be to define a "frustum" (in quotes to make it clear that this isn't a vew frustum we're talking about here) from the corners of character's bounding box to the camera position, which makes it a frustum culling problem. Objects which intersect or are inside this frustum will block the character.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS