04 April 2012, 11:39 PM
the position of the single default light in the max scene, the camera space one, never found anything in mxs so I had been poking around in the sdk looking at retrieving the ID3D9GraphicsWindow which I did, then using GetLights() function to get an array of directx lights, but it always returned an empty array. So playing around I saw from one of the examples that you could get the DirectX device ptr and from that use the device call GetLight() on light 0. Joy of joys there it was. so I jot down positions & directions for various viewport positions. A bit of head scratching and brain ache the following mxs snippet will generate the transform for the light in both perspective & user.
tm = inverse (getViewTM());
tm.translation = [0,0,0];
tm = matrixFromNormal ([0.25,0.433013,0.866025] * tm);
tm.translation = tm.row3 * 100000.0;
i did have it as a closer direct light but its actually a very distant omni (though they both give the same result) and a very slight correction on the direction values.
edit: for completion...
the two default light set up (max in dx units, what ever they are) is
omnilight1.pos = [-900000,-1e+006,1.5e+006]
omnilight2.pos = [900000,1e+006,-1.5e+006]
edit: I guessing the direction is generated with something like...
[ 0.5 * sin 30 ,0.5 * cos 30, cos 30]