Creating a spot light

I am trying to create a spotlight to highlight a area on my floor

 Private Sub RenderFloor()
        Dim m As Mesh = Mesh.Box(mDevice, 20.0F, 0.1F, 20.0F)
        Dim mtrl As Material = New Material
        mtrl.Ambient = System.Drawing.Color.Gray
        mtrl.Diffuse = mtrl.Ambient
        mDevice.Material = mtrl
        mDevice.Transform.World = Matrix.Identity
    End Sub

so it's creating it at 0,0,0

my camera position is currently set as 0,20,20 with my target being 0,0,0

With mDevice.Lights(0)
                .Type = LightType.Spot
                .Ambient = System.Drawing.Color.White
                .Diffuse = System.Drawing.Color.White
                .Attenuation0 = 1.0F
                .Falloff = 1.0F
                .Range = 50.0F
                .InnerConeAngle = 0.5F
                .OuterConeAngle = 1.0F
                .Position = New Vector3(0.0F, 20.0F, 20.0F)
                .Direction = New Vector3(0.0F, 0.0F, 0.0F)
                .Enabled = True
            End With

would this not set the spot light to be above my floor, and pointing at it?

i really don't have a clue why this doesn't work, any help would be appreciated.

thank you
Who is Participating?
davebytesConnect With a Mentor Commented:
I assume this is direct3d under VB?  I'll try to remember my VB (and my D3D!)...

first, I think your light position wants to be (0, 20, 0), and your direction wants to be (0, -1, 0).  That is, if the floor is at (0,0,0), and is 20 units x and z, the light wants to be 20 units up in Y only, and the direction of the light needs to be pointing down along Y.

second, note that you won't get a nice falloff/corona if the box created is 6 quads -- hardware lighting will only light at the vertices, so you need a box that is a reasonably fine mesh for each face in order to pick up on the lighting 'shifts' across each face.

sileacanAuthor Commented:
this is managed direct3d under yes.

thanks for the tip of the spotlight.

as for the floor i have created, i should avoid using a mesh and draw one out manually with a vertexbuffer to get better results?

i am going to award you full points as you have answered my original question, just curious on the way it lights it up now that you have mentioned it.. I'll try both methods out myself and see how it goes.

thanks alot, i'm sure i'll be awarding you more points in the near future!
I don't know the Mesh object interface. If there's a way to tell it to tessellate edges to some level, certainly easy to use.  Otherwise, yeah, just create a vb with a tessellated quad.

All Courses

From novice to tech pro — start learning today.