Jump to content

Light rotation to normalized vector?


shadmar
 Share

Recommended Posts

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

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

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()

  • Upvote 1

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...