Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


creating a flashlight in XNA


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
5 replies to this topic

#1 CaptCanada   Members   -  Reputation: 224

Like
0Likes
Like

Posted 30 January 2013 - 09:24 AM

Hi all

 

I have finished reading the XNA Game Studio 2nd Edition and, having read the chapter covering lighting systems, I am having trouble figuring out how to create a "basic" flashlight in XNA 3.1 (though I am currently reading Learning XNA 4.0) right now.

 

 I have tried tweaking the code and have been able to make the light used in the chapter example bright and dimmer, but haven't been able to dim the ambient light nor been able to "focus" the light into a beam shape.

 

I am currently coding using XNA 4.0 and VC# 2010.

 

Thanks for helping this old gamer/programmer!

 

 


Better to try and fail than to fail by not trying.

Sponsor:

#2 WavyVirus   Members   -  Reputation: 735

Like
0Likes
Like

Posted 30 January 2013 - 09:52 AM

Can you be more specific about your game? For a start, is this 2D or 3D?

#3 CaptCanada   Members   -  Reputation: 224

Like
0Likes
Like

Posted 30 January 2013 - 10:52 AM

This is not for a game persay, just tweaking the code found in the book. I was trying to change it so that the light used in the example is more focues like a flashlight beam. I don't have access to the code used in the chapter at the moment, but can post it as soon as practicle.

 

The code is 3D as the author has created a camera system and is demonstarting the use of lighting by having a light follow the movement of the camera.


Better to try and fail than to fail by not trying.

#4 Gavin Williams   Members   -  Reputation: 711

Like
0Likes
Like

Posted 31 January 2013 - 01:16 PM

So a spotlight ?



#5 CaptCanada   Members   -  Reputation: 224

Like
0Likes
Like

Posted 31 January 2013 - 01:39 PM

Ya, I guess spotlight would be the best way to describe it.

 

Something similiar to the flashlight effect in say Slenderman or any other of the horror-survial-at-night genre of games.


Better to try and fail than to fail by not trying.

#6 Gavin Williams   Members   -  Reputation: 711

Like
0Likes
Like

Posted 01 February 2013 - 06:39 AM

Basically it's just a spot-light, you can do more fancy texture projections or more complex lighting equations to give interesting variations..

 

Compute the dot product of the light-pixel vector and the light-target vector. Then you can use that to produce a light-cone.






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