Hi Guys,
I´m trying to create a light via a LUA script, that points in view direction (like a flashlight). Doesn´t sound that hard and I got it working with a primitive cylinder, but a light with a projector texture seems to be rotated at start.
I get the direction via System.GetViewCameraDir() and set the slot tranformation.
I tried VecRotateMinus90_Z(lightDirection) an different other vec math, but nothing worked for me so far, to get the rotation work right. Means I can move the the light from right to left, but if I move the mouse up, it only rotates the lightbeam.
Here´s the Code:
Code:
...
lightDirection = System.GetViewCameraDir();
VecRotateMinus90_Z(lightDirection);
self:SetSlotWorldTM(self.lightBeamSlot, lightPosition, lightDirection);
local lightProperties = {
radius = 6,
...
}
self:LoadLight(self.lightBeamSlot, lightProperties);
self:DrawSlot(self.lightBeamSlot, 1);
Any help or ideas concerning that matter would be great.