Jump to content

Maths trigonometry problems scripting RezObject()


VirtualKitten
 Share

You are about to reply to a thread that has been inactive for 1068 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

@Quistessa thank you for the two above scripts kisses .  Interestingly the second script returns and odd vector <7.29654,1950339.00000,-2.14450> which makes no sense in pos3. The first ray one onlly brings back one entry which is wrong not floor my think is sitting on. This was my error and was not returning correct link and vectors was zero, 

Edited by VirtualKitten
Link to comment
Share on other sites

Hi @Quistessa, this is what i tried:

Floor is about 2.5m below fire ball. So results are a bit strange idk i welcome any suggestions.

Output:

13:32] Fire Emitter: pos: <6.36630, 0.06990, 0.35550>
[13:32] Fire Emitter: rot: <-0.63915, 0.63915, -0.30247, 0.30247>
[13:32] Fire Emitter: 00000000-0000-0000-0000-000000000000<6.366303, -0.973062, 0.355502>1
[13:32] Fire Emitter: Floor: <7.29654, 1950839.00000, -2.14450>
 

 

float _llGetBoundaryUsingCastRay(vector pos , rotation rot, float distance, float width){
     list ray=[];
     
     llOwnerSay("pos: "+(string)pos);
     llOwnerSay("rot: "+(string)rot);
     //  http://wiki.secondlife.com/wiki/LlGetLinkPrimitiveParams
       if(distance== 0 ) distance  = 10; //ray length.
       vector displacement = llRot2Fwd(rot) * distance; // llRot2Fwd gives you the red vector you would see while editing the object with with the move checkbox and local coordinates turned on. see related functions llRot2Up,llRot2Left
       ray = llCastRay(pos,pos+displacement,[RC_REJECT_TYPES,(RC_REJECT_AGENTS|RC_REJECT_PHYSICAL),RC_MAX_HITS,5]);
      
       vector floor = llList2Vector(ray,1);
      
      
      llOwnerSay((string)ray);
      return floor.z;
}
integer check_for_prim(string name)
{
    integer i = llGetNumberOfPrims();
    for (; i >= 0; --i)
    {
        if (llGetLinkName(i) == name)
        {
            return i;
        }
    }
    return -1;
}

vector _llGetFloor(vector pos , rotation rot, float distance, float width){
       float height = 5.0; // height above ground, or equivalently, how tall your thing is.
       vector displacement = llRot2Fwd(rot);
       displacement *= ((-height)/displacement.z) ; // scale by a factor such that the z coordinate is negative height.

        vector pos2 = pos+displacement; // the point on the 'ground' that would be hit by a ray cast from pos along its local x axis.

        float p = 0.5; // percentage (ranging from 0 (at pos1) to 1 (at pos2)) of the way along the line from pos to pos2.
        vector pos3 = pos*(1-p) + pos2*(p); // a weighted sum of the 2 points.
return pos3;
}



_RezBall(float radial) //Offset in meters.
{
    //This will rez the object at (offset) meters in front of the root.
    integer link = check_for_prim("Fire Emitter");
    //llOwnerSay("link:"+(string)link);
    list l = llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);  
    rotation emitRot = (rotation) llList2String(l,1);  
    vector emitPos = llList2Vector(l,0);
     float hieght = _llGetBoundaryUsingCastRay(emitPos , emitRot,50.0, 1.25);   
     vector floor  = _llGetFloor(emitPos , emitRot,50.0, 1.25);  
     llOwnerSay("Floor: "+(string)floor);
     vector rezOffset =  <0.0,-radial*2,-hieght>; 
     //radial*rootRot to get the correct offset relative to the root (accounting for rotation) then add the region coords.
    llRezObject("Fireball(llDie)", emitPos + (rezOffset*llGetRot()), ZERO_VECTOR, ZERO_ROTATION, 0);


}

 

Edited by VirtualKitten
Link to comment
Share on other sites

8 hours ago, Quistessa said:

vector displacement = llRot2Fwd(rot) * distance; // l

I'm not quite sure why you're suggesting that? The fire emitter is* aligned such that the Z-axis is perfectly aligned for the direction the ray needs to take to find what is going to be ignited.

(Unless the build has since changed, but I doubt it, because particles can only be fired out along the Z axis)

Link to comment
Share on other sites

Would not llGetPos(),llGetPos() + <0.0, 0.0, 10.0>*llGetRot() also work for the  CastRay vectors to scan for 10 metres along the line of the particles? I'm thinking that since the goal is to rez something at a position calculated by that combination it would make sense to scan using that as well?

 

(I'm not sure what the maximum range of a dragon's blast is but I suspect anything over 10 metres is going to be outlawed by some sort of Geneva Convention)

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

I'm not sure I've fully understood you, are you saying "yes, Prof has described what I want to do but I'm struggling to do it because the whole animesh object has to be aligned along the X-axis" ? If so...

It doesn't matter about the model or the fact that animesh has to be x-facing, you have an emitter child prim that can do everything needed: it is facing the right way:

The line within it "llGetPos() + <vector>*llGetRot()" will always produce a position ahead of the emitter and downwards no matter which way the root is oriented. This is because they are getting WORLD position and rotation values, not CHILD. The script obviously has to be in that child prim and hence addressed by a link message but this won't be affected by animesh or root rotation.

All you have to do is establish "vector" which has to have a Z-component which is the distance from the emitter child to the first object or ground along that vector.

You could cast a ray and get that Z-length, or....

you could rez a fireball at the emitter which then moves along that direction vector until it collides with something, anything, and erupts into flames. (Actually,this would be a very impressive effect).

I'll repeat something I suggested earlier: step away from the dragon and build a small test harness from prims. It has a root prim and it has a child emitter prim. Get the flame particles emitting in the right direction, then play with ray-casts, then get the fireball working, so you can understand the particular problem without getting distracted by animesh, it's just adding to the confusion and making you look in the wrong areas.

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

Let me try to put this problem to rest once and for all: I present Puff, a magic dragon, who came about due to a lone DeHavilland Mosquito straying off course during WW2 and crossing into the City of the Autumn Stars, where it fell in love with a dragon and because most of it was composed of living tissue (plywood), an offspring was produced.

 

BombsAway.png.25d0fc10bfe837029313a640c21a191f.png

Puff is linked with the root prim a path-cut prim, so the root centre is right at the very tip of the tail, at the opposite end to the head.

Inside Puff's mouth is a white prim containing a script and a red glowing sphere. The white prim is rotated so that it's up-Z-axis points ahead and down by a few degrees.

When Puff's white prim is touched, it ray-casts along it's up-Z-axis and returns a list of targets hit, or else nowt.

Just behind the (Sounds like Twit but with an A) in a hat's heels is a red glowing sphere. This was launched by Puff when the white prim was touched with the linkset rotated zero degrees around the (root) Z axis.

In front of the (Sounds like Twit but with an A) in a hat is another red glowing prim, slightly to his left, launched by Puff when the white prim was touched after the linkset was rotated 30 degrees around the (root) Z axis.

Continuing to rotate Puff around the Z axis and fire would produce a ring of glowing spheres, tilting Puff up or down would move that ring further out or close in.

And here is the script do accomplish that. It is very simple, and I hope demonstrates the simplicity of using a rotation times a vector to save any amount of Pythagorean plotting, Euclidiean equations or Trignonemtric trickery.

// check the pos and rot of a child prim
// Raycast to determine where the Child's Z axis meets a target
//
// NOTE FOR llRezObject! 
//    "Silently fails to rez inventory (to have it's geometric center at pos) if pos is too far from the geometric center of the object trying to rez inventory"
//
// let us assume that means more than 10 metres away
// The child prim must contain an object named rezObject

key owner;

integer debug = 1;

vector rootPos;
rotation rootRot;
vector rootAngle;

getRootDetails()
{
    rootPos = llGetRootPosition();
    rootRot = llGetRootRotation();
    rootAngle = llRot2Euler(rootRot)*RAD_TO_DEG;
}

snort()
{
    vector myPos = llGetPos();
    rotation myRot = llGetRot();
    vector myAngle = llRot2Euler(myRot) * RAD_TO_DEG;
    vector rezAt;
    getRootDetails();

    if( debug) llOwnerSay("My pos = " + (string) myPos + " my Angle = " + (string) myAngle + " root pos = " + (string) rootPos + " root angle = " + (string) rootAngle);

    // now determine a possible collision object along the Z-axis of the emitter prim

    list targets = llCastRay(myPos, myPos + <0.0, 0.0, 32.0> * myRot, [RC_DETECT_PHANTOM, TRUE]);
    if( debug) llOwnerSay("Raycast got " + llDumpList2String(targets, ",") );

    integer iiMax = llGetListLength(targets);
    integer hits = llList2Integer(targets, iiMax-1);
    iiMax -=1; // move back from the result count to the last returned pair
    integer ii;
    list targetDetails;

    if( hits > 0)
    {
        for( ii = 0; ii < iiMax; ii+=2)
         {
            targetDetails = llGetObjectDetails(llList2Key(targets, ii), [OBJECT_NAME, OBJECT_POS]);
            string targetName = llList2String(targetDetails, 0);
            vector targetPos = llList2Vector(targetDetails, 1);
            rezAt = llList2Vector(targets, ii+1);    // See the caveat regarding silently failing at too great a distance
            if( debug) llOwnerSay("Found " + targetName + " (" + (string) targetPos + ") " + " at " + (string) rezAt );
            llRezObject("rezObject", rezAt, ZERO_VECTOR, ZERO_ROTATION, 0);
        }
    }
    else llOwnerSay("Fire at what?");
}

default
{
    state_entry()
    {
        owner = llGetOwner();
        llWhisper(0, "turn the root prim and touch me");
    }
    touch_start(integer touches)
    {
        snort();
    }
    link_message(integer sender, integer num, string msg, key id)
    {
        if( msg == "Fire One!")
        {
            snort();
            llMessageLinked(sender, 0, "Roger Skipper!", NULL_KEY);
        }
    }
}

In order to be fully functional for your purposes it does require one little addition: having established a target, use llVecDist to determine if the position is within the limiting distance of llRezObject and hold your fire if it's out of range.

 

 

Edited by Profaitchikenz Haiku
  • Haha 1
  • Confused 1
Link to comment
Share on other sites

I tried @Profaitchikenz Haiku thank you for sharing the script of your workings, its very kind of you  , but got Raycast got 0.  I am not sure why you got return was you in skybox ?  I haven't tried it on ground yet. I put the mouse  from the mouse organ back to bed and fell asleep  like Bagpus.

Edited by VirtualKitten
Link to comment
Share on other sites

It works on land (note that it got a null key because it hit terrain).

[04:38]  emitter: My pos = <19.04506, 125.34560, 22.74044> my Angle = <-102.00000, 0.00000, 90.00000>
[04:38]  emitter: Raycast got 00000000-0000-0000-0000-000000000000,<19.045060, 130.423000, 21.661200>,1
[04:38]  emitter: Hits 1
[04:38]  emitter: Found a target at <19.04506, 130.42300, 21.66120>
[04:38]  emitter: Rezz at <19.04506, 130.42300, 21.66120> distance 5.190856

If your dragon is large enough that the rayCast distance from the emitter to the ground exceeds the length of the raycast vector then you won't get any hits. Also, if you try to breath on water, you won't get any hit (from the surface anyway.). Try increasing the length of the rayCast vector until you get a hit?

I simplified the script after posting it because a lot of the diagnostics in it are for my learning about llCastRay, I'd never used it before. Here is a much simpler version. Notice I've set the length of the ray-cast vector to be 12 metres since you (probably) wont be able to get llRezObject to work beyond that, unless the limiting distance is the linkset distance, not the lSetPos 10-metre limit.

// Use the region pos and rot of a child prim with
// Raycast to determine where the Child's Z axis meets a target
//
// NOTE Wiki says "Silently fails to rez inventory (to have it's geometric center at pos) if pos is too far from the geometric center of the object trying to rez inventory"
//
// let us assume that means more than 10 metres away
// The child prim must contain an object named rezObject

key owner;

integer debug = 1;

snort()
{
    vector myPos = llGetPos();
    rotation myRot = llGetRot();
    vector myAngle = llRot2Euler(myRot) * RAD_TO_DEG;
    vector rezAt;

    if( debug) llOwnerSay("My pos = " + (string) myPos + " my Angle = " + (string) myAngle);

    // now determine a possible collision object along the Z-axis of the emitter prim

    list targets = llCastRay(myPos, myPos + <0.0, 0.0, 12.0> * myRot, [RC_DETECT_PHANTOM, TRUE]);
    if( debug) llOwnerSay("Raycast got " + llDumpList2String(targets, ",") );

    integer iiMax = llGetListLength(targets);
    integer hits = llList2Integer(targets, iiMax - 1);
    if( debug) llOwnerSay("Hits " + (string) hits);
    iiMax -=1; // move back from the result count to the last returned pair
    integer ii;

    if( hits > 0)
    {
        for( ii = 0; ii < iiMax; ii+=2)
        {
            rezAt = llList2Vector(targets, ii+1);
            if( debug) llOwnerSay("Found a target at " + (string) rezAt );
            if( llVecDist(myPos, rezAt) <= 10.0)
            {
                if( debug) llOwnerSay("Rezz at " + (string) rezAt + " distance " + (string) llVecDist(myPos, rezAt) );
                llRezObject("rezObject", rezAt, ZERO_VECTOR, ZERO_ROTATION, 0);
            }
            else // it's too far away to rez at
            {
                llOwnerSay("Out of range " + (string) llVecDist(myPos, rezAt) );
            }
        }
    }
}

default
{
    state_entry()
    {
        owner = llGetOwner();
        llWhisper(0, "turn the root prim and touch me");
    }
    touch_start(integer touches)
    {
        snort();
    }
    link_message(integer sender, integer num, string msg, key id)
    {
        if( msg == "Fire One!")
        {
            snort();
            llMessageLinked(sender, 0, "Roger Skipper!", NULL_KEY);
        }
    }
}

 

 

 

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

I have 

 

_RezBall(float radial) //Offset in meters.
{
    //This will rez the object at (offset) meters in front of the root.
    integer link = check_for_prim("Fire Emitter");
    //llOwnerSay("link:"+(string)link);
    list l = llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);  
    rotation emitRot = (rotation) llList2String(l,1);  
    vector emitPos = llList2Vector(l,0);
    vector rezAt;
    getRootDetails();
    
    list targets = llCastRay(emitPos, emitPos + <0.0, 0.0, 32.0> * emitRot, [RC_DETECT_PHANTOM, TRUE]);
    if( _debug) llOwnerSay("Raycast got " + llDumpList2String(targets, ",") );
    if(llGetListLength(targets) > 0 ){ 
    
         integer iiMax = llGetListLength(targets);
         integer hits = llList2Integer(targets, iiMax-1);
         iiMax -=1; // move back from the result count to the last returned pair
         integer ii;
         list targetDetails;
         if( hits > 0)
         {
              for( ii = 0; ii < iiMax; ii+=2)
              {
                    targetDetails = llGetObjectDetails(llList2Key(targets, ii), [OBJECT_NAME, OBJECT_POS]);
                    string targetName = llList2String(targetDetails, 0);
                    vector targetPos = llList2Vector(targetDetails, 1);
                    rezAt = llList2Vector(targets, ii+1);    // See the caveat regarding silently failing at too great a distance
                    if(_debug) llOwnerSay("Found " + targetName + " (" + (string) targetPos + ") " + " at " + (string) rezAt );
                    llRezObject("Fireball(llDie)", rezAt, ZERO_VECTOR, ZERO_ROTATION, 0);
               }
         }
    } else {
         
//This will rez the object at (offset) meters in front of the root.

          vector v_rootPos = llGetPos(); //Info about the root prim

         rotation r_rootRot = llGetRot();

         vector finPos = v_rootPos + (<radial,0,0>*r_rootRot);

         //radial*rootRot to get the correct offset relative to the root (accounting for rotation) then add the region coords.

             llRezObject("fireball",finPos,ZERO_VECTOR,r_rootRot,0);

}
    }
    
 }

 

I wonder if there is another method to place it when llCastRay fails like in sky box or other reason at 101m

Edited by VirtualKitten
Link to comment
Share on other sites

I should add this else code doesn't work either

 

} else {
        // Try an alternative method.
           //This will rez the object at (offset) meters in front of the root.
           list l = llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);  
          vector v_rootPos =(vector) llList2String(l,0); 
          rotation r_rootRot = (rotation) llList2String(l,1); 
          vector finPos = v_rootPos + (<radial,0,0>*r_rootRot);

          //radial*rootRot to get the correct offset relative to the root (accounting for rotation) then add the region coords.

          llRezObject("Fireball(llDie)",finPos,ZERO_VECTOR,r_rootRot,0);
    }
    

Edited by VirtualKitten
Link to comment
Share on other sites

[03:49] Fire Emitter: Raycast got 0
[03:49] Fire Emitter: Got Here
[03:49] Fire Emitter: Manual Pos got <184.50000, 2903.67900, -1954.64200>Manual Pos got <-0.63915, 0.63915, -0.30247, 0.30247>

2903 is under my skybox

location of emiter: <199.88788, 42.57153, 3498.52100> and rot <236.70000, 359.64999, 0.45001>

root loc  <199.95439, 36.27785, 3497.49805> and rot <6.04999, 0.54999, 90.00000>

 

but it rezes no object

from 

    } else {
        // Try an alternative method.
           //This will rez the object at (offset) meters in front of the root.
           list l = llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);  
          vector v_Pos =(vector) llList2String(l,0); 
          rotation r_Rot = (rotation) llList2String(l,1); 
          vector finPos = (v_Pos + (<radial,0,0>*r_Rot)+llGetPos())*llGetRot();

          //radial*rootRot to get the correct offset relative to the root (accounting for rotation) then add the region coords.
          llOwnerSay("Got Here");
          if( _debug) llOwnerSay("Manual Pos got " + (string)finPos  +  "Manual Pos got " + (string)r_Rot);
          llRezObject("Fireball(llDie)",finPos,ZERO_VECTOR,r_Rot,0);
    }
   

Edited by VirtualKitten
Link to comment
Share on other sites

You have a real mish-mash there of several different techniques, but as far as I can see you are trying to do all this from the root prim. There are three chunks of code in three posts, I don't know what the significance of the blue text is in the first, but I also think trying to do a side-by-side comparison of three variants is counterproductive.

My suggestion is to do the rezzing from within the emitter child prim, using the simplified script I posted above. You can forget about the root position or rotation and just concentrate on where the emitter prim is.

It might be possible to do all this from the root prim but it's more work. I've shown you a method to do this from within the child prim, if you really must do everything from a single script in the root I would suggest you get the child prim method working first and use that to give you comparison figures of positions and rotations which you then use as the guidelines for adding the similar functionality to the root prim's script.

Link to comment
Share on other sites

[06:17] Fire Emitter: Raycast got 0
[06:17] Fire Emitter: Rotation: <179.99990, 50.65000, 90.00005> , size: <6.55973, 3.06752, 1.72104>
[06:17] Fire Emitter: Root.z:3498.521000Local.z:0.355501
[06:17] Fire Emitter: Angle: 50.650000, Hieght: 2.076540, XHoriz:5.131605
[06:17] Fire Emitter: Manual Pos got <199.88790, 47.70318, 3496.44400>Manual Rot got <-0.63915, 0.63915, -0.30247, 0.30247>
[06:17] Fire Emitter: Manual RootPos got <199.88790, 42.57158, 3498.52100>Manual RootRot got <-0.88015, 0.00184, 0.00448, 0.47467>

in 

 } else {
        // Try an alternative method.
           //This will rez the object at (offset) meters in front of the root.
          list l = llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);  
          vector v_Pos =(vector) llList2String(l,0); 
          rotation r_Rot = (rotation) llList2String(l,1); 
          vector  a1 = llRot2Euler(r_Rot); a1 *= RAD_TO_DEG;
          float angle_top = a1.y; // y is z in this model
          vector size = llList2Vector(llGetLinkPrimitiveParams(0,[PRIM_SIZE]),0)/2;
          
          llOwnerSay("Rotation: " +(string)a1+" , size: "+(string)size);
          pos = llGetPos();
          llOwnerSay("Root.z:" + (string)pos.z + "Local.z:" + (string)v_Pos.z);
          float zhieght =  v_Pos.z+(size.z) ;
          float Xhoriz =llTan(PI_BY_TWO-angle_top)*zhieght;
          llOwnerSay("Angle: "+(string)angle_top + ", Hieght: "+(string)zhieght+", XHoriz:"+(string) Xhoriz);
          pos = llGetPos();
          pos.y += (Xhoriz) -0.25; // minus half size of emitter ball
          pos.z -=zhieght;
         
          vector finPos = (v_Pos + (<radial,0,0>*r_Rot)-llGetPos())*llGetRot();
           finPos = pos;
          //radial*rootRot to get the correct offset relative to the root (accounting for rotation) then add the region coords.
          
          if( _debug) llOwnerSay("Manual Pos got " + (string)finPos  +  "Manual Rot got " + (string)r_Rot);
          if( _debug) llOwnerSay("Manual RootPos got " + (string)llGetPos()  +  "Manual RootRot got " + (string)llGetRot());
          llRezObject("Fireball(llDie)",finPos,ZERO_VECTOR,r_Rot*llGetRot(),0);
    }

Works current direction

38b82c4b2a1cee29ac6773e04eee1275.png

25cad6dd51159fbafb77ba3df6e02295.png

 

 

Edited by VirtualKitten
Link to comment
Share on other sites

24 minutes ago, VirtualKitten said:

vector  a1 = llRot2Euler(r_Rot); a1 *= RAD_TO_DEG;
          float angle_top = a1.y; // y is z in this model
          vector size = llList2Vector(llGetLinkPrimitiveParams(0,[PRIM_SIZE]),0)/2;
          
          llOwnerSay("Rotation: " +(string)a1+" , size: "+(string)size);
          pos = llGetPos();
          llOwnerSay("Root.z:" + (string)pos.z + "Local.z:" + (string)v_Pos.z);
          float zhieght =  v_Pos.z+(size.z) ;
          float Xhoriz =llTan(PI_BY_TWO-angle_top)*zhieght;
          llOwnerSay("Angle: "+(string)angle_top + ", Hieght: "+(string)zhieght+", XHoriz:"+(string) Xhoriz);

in the above, a1 is converted to degrees, (a1 *= RAD_TO_DEG)

angle_top is therefore in degrees, (a1.y)

llTan(PI_BY_TWO-angle_top) is trying to get the tangent of a value in radians - a value in degrees.

This is back at the starting point, after three pages.

And it's not the best solution, because as you've said 

18 minutes ago, VirtualKitten said:

However it does not work when dragon rotated

And that's why I showed you how to do it all from within the emitter prim, when it will do it when the dragon is rotated. The emitter child always knows where it is within the region and where it is pointing within the region using llGetPos() and llGetRot(), and you do not need to resort to spherical trig to solve it

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

It also doesn't work if its not on ground pseudo ground sky box tree or anything  it hits :( gosh this is hard to accomplish. Idk what best solution is your doesnt work at all in sky box pseudo land, tree or only on ground  i think you ray cannot be working correctly.

bb42767b74cde837cab58e92384bd2c2.png

 

I have 

_RezBall(float radial) //Offset in meters.
{
    //This will rez the object at (offset) meters in front of the root.
    integer link = check_for_prim("Fire Emitter");
    //llOwnerSay("link:"+(string)link);
    list l = llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);  
    rotation emitRot = (rotation) llList2String(l,1);  
    vector emitPos = llList2Vector(l,0);
    vector rezAt;
    getRootDetails();
    
    list targets = llCastRay(emitPos, emitPos + <0.0, 0.0, 32.0> * emitRot, [RC_DETECT_PHANTOM, TRUE]);
    if( _debug) llOwnerSay("Raycast got " + llDumpList2String(targets, ",") );
    
    
         integer iiMax = llGetListLength(targets);
         integer hits = llList2Integer(targets, iiMax-1);
    if(hits > 0 ) {
         iiMax -=1; // move back from the result count to the last returned pair
         integer ii;
         list targetDetails;
         if( hits > 0)
         {
              for( ii = 0; ii < iiMax; ii+=2)
              {
                    targetDetails = llGetObjectDetails(llList2Key(targets, ii), [OBJECT_NAME, OBJECT_POS]);
                    string targetName = llList2String(targetDetails, 0);
                    vector targetPos = llList2Vector(targetDetails, 1);
                    rezAt = llList2Vector(targets, ii+1);    // See the caveat regarding silently failing at too great a distance
                    if(_debug) llOwnerSay("Found " + targetName + " (" + (string) targetPos + ") " + " at " + (string) rezAt );
                    llRezObject("Fireball(llDie)", rezAt, ZERO_VECTOR, ZERO_ROTATION, 0);
               }
         }
    } else {
        // Try an alternative method.
           //This will rez the object at (offset) meters in front of the root.
          list l = llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);  
          vector v_Pos =(vector) llList2String(l,0); 
          rotation r_Rot = (rotation) llList2String(l,1); 
          vector  a1 = llRot2Euler(r_Rot); a1 *= RAD_TO_DEG;
          float angle_top = a1.y; // y is z in this model
          vector size = llList2Vector(llGetLinkPrimitiveParams(0,[PRIM_SIZE]),0)/2;
          
          llOwnerSay("Rotation: " +(string)a1+" , size: "+(string)size);
          pos = llGetPos();
          llOwnerSay("Root.z:" + (string)pos.z + "Local.z:" + (string)v_Pos.z);
          float zhieght =  v_Pos.z+(size.z) ;
          float Xhoriz =llTan(PI_BY_TWO-angle_top)*zhieght;
          llOwnerSay("Angle: "+(string)angle_top + ", Hieght: "+(string)zhieght+", XHoriz:"+(string) Xhoriz);
          pos = llGetPos();
          pos.y += (Xhoriz)-.25;
          pos.z -=zhieght;
         
          vector finPos = (v_Pos + (<radial,0,0>*r_Rot)-llGetPos())*llGetRot();
           finPos = pos;
          //radial*rootRot to get the correct offset relative to the root (accounting for rotation) then add the region coords.
          
          if( _debug) llOwnerSay("Manual Pos got " + (string)finPos  +  "Manual Rot got " + (string)r_Rot);
          if( _debug) llOwnerSay("Manual RootPos got " + (string)llGetPos()  +  "Manual RootRot got " + (string)llGetRot());
          llRezObject("Fireball(llDie)",finPos,ZERO_VECTOR,r_Rot*llGetRot(),0);
 }

Edited by VirtualKitten
Link to comment
Share on other sites

There is no point in your pursuing a trig solution until you can master the art of using radians for functions that must be given inputs in radians, not degrees. Until then, I suggest you adopt the simplt method of using rotations to operate on vectors where you do not need to do anything other than Pos1 + (vector*rotation).

Link to comment
Share on other sites

Well your version doesn't work it doesn't detect the land near my house at all let alone trees  so is unworkable as the llcastray returns 0   Sorry I already tried it and sadly gave nothing. So had to go back to drawing board with what had worked so far as nothing else I had been showed had worked or rezed the fire ball on the ground psuedo ground sky box tree or anything of any structure in lsl

.

 

Edited by VirtualKitten
Link to comment
Share on other sites

2 minutes ago, VirtualKitten said:

let alone trees 

If they're sculpts then the hitbox that llCastRay works on is nothing like the visible shape, and they (and possibly many mesh trees) will most likely be set phantom to allow avatars to move.

When you say my script doesn't work, what are you testing it in? How far away from it is the land near your house?

Link to comment
Share on other sites

I tried it returns 0 list empty no results from ray cast  on everything up here . you can get height from return values prints llGetPos() prod idk why your cast ray doesn't work has had not much luck with them in past . Come see for yourself I have 30mins before work

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1068 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...