1: 2015-02-26 (木) 22:16:24 iseki  |
現: 2015-02-26 (木) 22:16:41 iseki  |
| *** llLookAt() by Janus Dugong [#wb1da18a] | | *** llLookAt() by Janus Dugong [#wb1da18a] |
| + | |
| public void llLookAt(LSL_Vector target, double strength, double damping) | | public void llLookAt(LSL_Vector target, double strength, double damping) |
| { | | { |
| // Determine where we are looking from | | // Determine where we are looking from |
| LSL_Vector from = llGetPos(); | | LSL_Vector from = llGetPos(); |
| + | |
| // normalized direction to target | | // normalized direction to target |
| LSL_Vector dir = llVecNorm(target - from); | | LSL_Vector dir = llVecNorm(target - from); |
| + | |
| // Janus Dugong & Fumi.Hax | | // Janus Dugong & Fumi.Hax |
| if (LSL_Vector.Mag(dir)<=0.0) return; | | if (LSL_Vector.Mag(dir)<=0.0) return; |
| LSL_Rotation rot_pth = llEuler2Rot(vec_pth); | | LSL_Rotation rot_pth = llEuler2Rot(vec_pth); |
| LSL_Rotation rot = rot_pth * rot_yaw; | | LSL_Rotation rot = rot_pth * rot_yaw; |
| + | |
| // Per discussion with Melanie, for non-physical objects llLookAt appears to simply | | // Per discussion with Melanie, for non-physical objects llLookAt appears to simply |
| // set the rotation of the object, copy that behavior | | // set the rotation of the object, copy that behavior |
| PhysicsActor pa = m_host.PhysActor; | | PhysicsActor pa = m_host.PhysActor; |
| + | |
| if (strength == 0 || pa == null || !pa.IsPhysical) | | if (strength == 0 || pa == null || !pa.IsPhysical) |
| { | | { |