Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

1000 for how do I convert llLookat to l100lEuler2Rot

RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
12-21-2005 10:05
Reposting this with cash in the title to bad editing isn't possible on titles of threads in the scripting forum.
Trying to get an atachment to point at the closest av near me
this is one of those usefull bits of code a lot of people could use
who want to use prim eyes on there av's.
also figured I'd make the eyeball have 2 pupils one pointed each way so even if the person closest to me is behind me i'll still have pupils pretty clever huh?

CODE

float interval = 2;
integer range = 20;

default
{
state_entry()
{
llSensorRemove();
llSensorRepeat("","",AGENT,range,PI,interval);
// llSensor(0,AGENT,ACTIVE,20,45);
}
sensor(integer n) {
integer i;
vector pos;
pos = llDetectedPos(i);
rotation rot;
// llSay(0,(string)pos);
rot = llEuler2Rot(pos *<0,0,0,1>); // this part isn't working
llSetLocalRot(rot);
// llSay(0,(string)rot);
}
}}

From: someone
Oasis Perun:you are multiplying a Euler by a Rot here ::rot = llEuler2Rot(pos *<0,0,0,1>;); // this part isn't working. try.. and i cant test this right now
rot = llEuler2Rot(pos)*<0,0,0,1>; // Try this

nope still not pointing at me but does move when I move but already had that.
From: someone
Nexus Nash: RacerX, i'm guessing you want the object to lookat the avatar. What I usually use is simply the position vector from the llDetectedPos(). Also llLookAt() is centered on the Z axis, it points the Z axis towards the target.

Ya but I couldn't get look at to work when attached. So far no winners. Nexus read the thread before posting your add. Well maybe my basic script is flawed, But if I replaced the llSetLocalRot with llLookAt(pos,2,1); it works, But not when attached, Maybe the llUeller is a bad plan, Anyway, Help me make my eyes look at stuff, If you have a better idea please share.
_____________________
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
12-21-2005 10:23
I have a function posted on the wiki's llLookAt page that should help you.

Edit:
Here it is:
CODE

// AXIS_* constants, represent the unit vector 1 unit on the specified axis.
vector AXIS_UP = <0,0,1>;
vector AXIS_LEFT = <0,1,0>;
vector AXIS_FWD = <1,0,0>;

// getRotToPointAxisAt()
// Gets the rotation to point the specified axis at the specified position.
// @param axis The axis to point. Easiest to just use an AXIS_* constant.
// @param target The target, in region-local coordinates, to point the axis at.
// @return The rotation necessary to point axis at target.
// Created by Ope Rand, modifyed by Christopher Omega
rotation getRotToPointAxisAt(vector axis, vector target) {
return llGetRot() * llRotBetween(axis * llGetRot(), target - llGetPos());
}


Try llSetRot or llSetLocalRot(getRotToPointAxisAt(AXIS_UP, target));
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
12-21-2005 11:27
use the function Christopher suggests (it should work), though animations will make it inaccurate.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
12-21-2005 13:24
CODE

float interval = 2;
integer range = 20;

default
{
state_entry()
{
llSensorRemove();
llSensorRepeat("","",AGENT,range,PI,interval);
}

sensor(integer n)
{
// Assumes the eyeball's forward vector is <1.0, 0.0, 0.0>
rotation rot = llRotBetween(<1.0, 0.0, 0.0>, llVecNorm(llDetectedPos() - llGetRootPosition()));
llSetLocalRot(rot / llGetRootRotation());
}
}


Truthfully I dunno if this will work. I'm at work and can't sign on to sl. It should be close though.
_____________________
RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
12-22-2005 12:28
yes seems impossible though your av can have eyes that look at stuff whats going on you don't have access to the same thing from in game. The animations of turning your head or bending over or any of a number of animations make it very inacurate at best. Connection points seem to have there own rotation. NM
_____________________