Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Useful Subroutines llLookAt_any_axis  

llLookAt_any_axis

llLookAt_any_axis

Category: Useful Subroutines
By : LSL Wiki
Created: 2010-02-01 Edited: 2010-02-01
Worlds: Second Life

the Zip file

Download all files for llLookAt_any_axis
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. llLookAt_any_axis_1.lsl
1 // AXIS_* constants, represent the unit vector 1 unit on the specified axis.
2 vector AXIS_UP = <0,0,1>;
3 vector AXIS_LEFT = <0,1,0>;
4 vector AXIS_FWD = <1,0,0>;
5
6 // getRotToPointAxisAt()
7 // Gets the rotation to point the specified axis at the specified position.
8 // @param axis The axis to point. Easiest to just use an AXIS_* constant.
9 // @param target The target, in region-local coordinates, to point the axis at.
10 // @return The rotation necessary to point axis at target.
11 // Created by Ope Rand, modifyed by Christopher Omega
12 rotation getRotToPointAxisAt(vector axis, vector target) {
13 return llGetRot() * llRotBetween(axis * llGetRot(), target - llGetPos());
14 }
15
16 // Strength and damping are values used to control how llRotLookAt and llLookAt move, these values are tunable.
17 float strength = 1.0;
18 float damping = 1.0;
19
20 default {
21 state_entry() {
22 vector target = <10, 20, 30>; // A vector to look at.
23
24 // These two lines are equivalent, and point the up (Z) axis at the target:
25 llRotLookAt(getRotToPointAxisAt(AXIS_UP, target), strength, damping);
26 llLookAt(target, strength, damping);
27
28 // This line points the fwd (X) axis at the target:
29 llRotLookAt(getRotToPointAxisAt(AXIS_FWD, target), strength, damping);
30
31 // This line points the left (Y) axis at the target:
32 llRotLookAt(getRotToPointAxisAt(AXIS_LEFT, target), strength, damping);
33 }
34 }

Back to the Best Free Tools in Second Life and OpenSim.