shadmar Posted July 24, 2014 Share Posted July 24, 2014 If I want the sunlights rotation converted into a direction vector, how can I do this in lua? Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 24, 2014 Share Posted July 24, 2014 (edited) Something like this I believe: entity:GetQuaternion() * Vec3(0,0,1) *Edit Unless the GetQuaternion is not exposed in lua. Edited July 24, 2014 by Aggror Quote Link to comment Share on other sites More sharing options...
Charrua Posted July 24, 2014 Share Posted July 24, 2014 i used this to use an entity rotation and transform it to a normalized rotation, perhaps is very indirect, but seems to work guess there should be a simpler mathematical way, but still unknown for me. hope that helps: if self.usepivotpin then local pvtTemp = Pivot:Create() --get ent rotation, to set hinge pin if pvtTemp ~= nil then pvtTemp:SetRotation(self.entity:GetRotation()) pvtTemp:Move(0,0,1) --transform from euler angles to 0..1 axis coords ... a vector of lenght one: nomarized local rot = pvtTemp:GetPosition(false) self.pin.x = rot.x self.pin.y = rot.y self.pin.z = rot.z --System:Print("pin: " .. self.pin.x .. ", " .. self.pin.y .. ", " .. self.pin.z) pvtTemp:Release() end end i used to set hinge joint pin, btw Quote Paren el mundo!, me quiero bajar. Link to comment Share on other sites More sharing options...
shadmar Posted July 24, 2014 Author Share Posted July 24, 2014 Thanks both. virtual Quat GetQuaternion(const bool global=false);//lua seem exposed in the header, I will test. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
shadmar Posted July 24, 2014 Author Share Posted July 24, 2014 Attributes (x,y,z,w) are not exposed in the Quat class. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 24, 2014 Share Posted July 24, 2014 So it returns the quat but without having acces to xyzw. I honestly dont know how to do it without de quaternion. Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 24, 2014 Share Posted July 24, 2014 what does the uniform 'lightdirection' in the directionallight shader return? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted July 25, 2014 Share Posted July 25, 2014 Transform:Vector(0,0,1,light,nil) And to go the other way: Entity::AlignToVector(): http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entityaligntovector-r166 All the heavy math has been worked out for you, including alignment along any axis, an optional roll value, and gradual interpolation. OR You can just access the third row of the 4x4 matrix directly: dir = Vec3(light.mat.k.x,light.mat.k.y,light.mat.k.z):Normalize() 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
shadmar Posted July 25, 2014 Author Share Posted July 25, 2014 Thanks! dir = Vec3(light.mat.k.x,light.mat.k.y,light.mat.k.z):Normalize() is accurate and just what was needed! Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
shadmar Posted July 25, 2014 Author Share Posted July 25, 2014 It works : http://steamcommunity.com/sharedfiles/filedetails/?id=291076598 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.