Jump to content
  • Advertisement
Sign in to follow this  

How do I create a correct scale matrix for a cone model as a spot light?

This topic is 2569 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a spot light that I wish to render by using a cone model (height 1.0 by diameter 1.0). The model (in world space) should fill the bounding frustum created from the light's view and projection matrices.

In the picture below, the model is shown in green and the light's frustum is drawn as a wire frame in white.


I am creating the world matrix for the model as follows:

// Invert light's view matrix to get its world matrix
Matrix worldMatrix = Matrix.Invert(View);

// Scale the world matrix
//float tan = (float)Math.Atan(angle);
float tan = (float)Math.Tan(angle);
Matrix lightMatrix = Matrix.CreateScale(100f * tan, 100f, 100f * tan) * worldMatrix; // 100f = Light Range

The scale matrix is incorrect but the world matrix follows the frustum as it moves around. Where have I gone wrong in creating the scaling matrix?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!