Sign in to follow this  

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this