Hi;
I can't get lighting to work with the dec2005 sdk.
I created a simple cube mesh in maya, exported it, and loaded it into my project. But it shows up dim and faint - in fact the only light that seems to be showing is the ambient light.
Here is my light code:
Device.RenderState.Lighting =
TrueDevice.Lights(0).Type = LightType.Directional
Device.Lights(0).Diffuse = Color.White
Device.Lights(0).Direction = New Vector3(0, 0, 1)
Device.Lights(0).Enabled = True
Device.RenderState.Ambient = Color.FromArgb(&H202020)
(Note that the lights().commit function no longer exists, even though a lot of examples mention it as being required !!! I have references in my project to directx, direct3d and direct3dx, all of them the 1.0.2902 versions.)
I loaded the cube into mesh viewer, and it displays perfectly. But it only shows faintly (IE lit by the small ambient value) in my program!
I've examined the cube.x file with notepad and yes, the normals are there and are perfect!
Can anyone help me out It's driving me crazy, as I write this it's 6:39 am and I've been up all night for the third night in a row (Sleeping during the day!)
Jamie

Lighting problem with Dec2005 SDK?
dbagurus
Briedis
Found the problem(s)
(a) One of my function variables is called "positon". I then use the assignment
me.position=position
So the position is assigned to itself. There's no compiler error or warnigns - I better watch this in future. An interesting error.
(b) There seems to be a problem with the decsdk Maya exporter plugin. It exports the models successfully, and a look at the text file shows normals, but my mesh laoder seems unable to make them work. Using meh.computenormals generates an unknown exception, even if I supply the adjacency information.
I switched to milkshape3d, created a model, and imported it perfectly first time!
So I think I'll stick to milkshape for now. Has anyone else noted anything weird about mesh normals exported from maya 7 using the latest plugin
rvn
If you have the full version of visual studio try turning on Code Analysis in the project options. I think it will catch the self assignment thing.
I'm not sure about Maya exporter - you might be better off asking inthe modelling forums on gamedev.net
Darren Wang
Well I've narrowed the problem down ... if I display a simple mesh.teapot at the same time, the light works fine. So the problem must lie in my mesh loading code.
Public
Class Jmesh Private Msh As Mesh Private ExtendedMaterial() As ExtendedMaterial Private Materials() Private Textures() Public Position As Vector3 Public Orientation As Matrix Sub New(ByVal FileName As String, ByVal Positon As Vector3, ByVal Yaw As Single, ByVal Pitch As Single, ByVal Roll As Single) Me.Position = Position Me.Orientation = Matrix.RotationYawPitchRoll(Geometry.DegreeToRadian(Yaw), Geometry.DegreeToRadian(Pitch), Geometry.DegreeToRadian(Roll))Msh = Mesh.FromFile(FileName, MeshFlags.Managed, Device, ExtendedMaterial)
If ExtendedMaterial IsNot Nothing And ExtendedMaterial.Length <> 0 Then ReDim Materials(ExtendedMaterial.GetUpperBound(0)) ReDim Textures(ExtendedMaterial.GetUpperBound(0)) Dim Index As Integer For Index = 0 To ExtendedMaterial.GetUpperBound(0)Materials(Index) = ExtendedMaterial(Index).Material3D
If ExtendedMaterial(Index).TextureFilename <> "" ThenTextures(Index) = TextureLoader.FromFile(Device, ExtendedMaterial(Index).TextureFilename)
End If Next End If End Sub Sub Draw() Static Index As IntegerDevice.Transform.World = Orientation * Matrix.Translation(Position)
For Index = 0 To Materials.GetUpperBound(0)Device.Material = Materials(Index)
Device.SetTexture(0, Textures(Index))
Msh.DrawSubset(Index)
NextTriangleCount += Msh.NumberFaces
End SubEnd
Class