Forums Gallery Downloads LOGIN |REGISTER

[LUA script] rotate entity (light) in viewDirection in 3rdP.

Please use this forum for questions on C++, Lua, XML, and any other languages used in CryENGINE development.


 

User avatar
ArcaneLynx
Just getting started
Just getting started
 
Posts: 13
Member since: 26.10.2011, 14:14
Likes: 0

[LUA script] rotate entity (light) in viewDirection in 3rdP.

Postby ArcaneLynx » 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: Select all
...
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
ArcaneLynx
Just getting started
Just getting started
 
Posts: 13
Member since: 26.10.2011, 14:14
Likes: 0

Re: [LUA script] rotate entity (light) in viewDirection in 3

Postby ArcaneLynx » 28.06.2012, 12:31

here two images to clarify the problem.

No one any idea regarding this?
Attachments
ViewLight02.jpg
correct light direction, but "wrong" rotation -> using VecRotateMinus90_Z(lightDirection)
ViewLight01.jpg
correct light rotation, but wrong direction


 
Connect and collaborate with CRYENGINE developers in the official Forums.
Visit the Gallery to share what you have created and be inspired by what others are creating with CRYENGINE.
Community