Programming & Scripting

View unanswered posts | View active topics


Post a new topicPost a reply
Previous topic | Next topic 

User avatar   Beginner BeginnerMember since: 26.10.2011, 14:14Posts: 13 Likes: 0
 

 Post Topic: [LUA script] rotate entity (light) in viewDirection in 3rdP.
PostPosted 26.06.2012, 11:42 
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.

User avatar   Beginner BeginnerMember since: 26.10.2011, 14:14Posts: 13 Likes: 0
 

 Post Topic: Re: [LUA script] rotate entity (light) in viewDirection in 3
PostPosted 28.06.2012, 12:31 
here two images to clarify the problem.

No one any idea regarding this?
Attachments:

ViewLight02.jpg
ViewLight01.jpg