Change font size
It is currently Wed Jul 18, 2018 4:43 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 8 posts ]
Author Message
 Post subject: Problem with these 2 scripts.
PostPosted: Wed Jul 04, 2018 11:39 pm 
Furious Typer

Joined: Tue Oct 28, 2008 4:53 pm
Posts: 166
Ok, this is what these 2 scripts should do, 1st the 'Main' script goes into a prim called Master,,, the 2nd script go into another prim called 'Slave',,, and by touching the 'Slave' the 'Slave' will auto align it's self with the 'Master' face to face, but it seems the llSetRegionPos and llSetRot, don't do anything,,,,,I'm sure the calculations are correct, and now I'm stuck.

{L_CODE}:
//PLACE IN MASTER OBJECT TO READ SLAVE OBJECT'S OFFSET AND ROTATION IN RELATION TO MASTER OBJECT

integer iChannel = -67341870;
integer cChannel = -27465144;

list objDetails;

default
{
    state_entry()
    {
        llListen(iChannel, "","","");
    }

    listen(integer channel, string name, key id, string message)
    {
        list temp = llGetObjectDetails(id, [OBJECT_POS,OBJECT_ROT]);//Read region position and rotation of child object
        vector vMyPos = llGetPos();//Main object's position
        rotation rMyRot = llGetRot();//Main object's rotation
        vector vChildPos = llList2Vector(temp, 0);//Child object's position
        rotation rChildRot = llList2Rot(temp, 1);//Child object's rotation

        vector vOffset = (vChildPos - vMyPos)/rMyRot; //calculate how far the child object is from the main object, discounting the main object's rotation
        //that is, the offset when the main object is rotated at <0.0,0.0,0.0>
        rChildRot = rChildRot / rMyRot;//calculate the child object's rotation when the main object is rotated at  <0.0,0.0,0.0>
        objDetails = [vOffset, rChildRot];
        string objSend = llDumpList2String(objDetails,"|"); // Convert to a string ready for sending to the slave prim.
        llRegionSay(cChannel, objSend); // Send the Slave offset and rotation to the Slave.

    }
}

and Now the 2nd script:-
{L_CODE}:
//PLACE THIS IN THE CHILD OBJECT TO MAKE IT MOVE INTO THE DESIRED POSITION AND ROTATION IN RELATION TO THE MAIN OBJECT
integer iChannel = -67341870;
integer cChannel = -27465144;

list objDetails;

rotation rRot; // = <0.0, 0.0, -1.0, 0.0>;//fill in desired rotation here, rotation provided by the Master prim
vector vOffset; // = <1.0,0.0,0.0>;//fill in desired offset here, offset provided by the Master prim.

default
{
    state_entry()
    {
        llListen(iChannel, "","","");
        llListen(cChannel, "","","");
    }

    touch_start(integer num_detected)
    {
        llRegionSay(iChannel,"boo");   
    }

    listen(integer channel, string name, key id, string message)
    {
        list temp = llGetObjectDetails(id,[OBJECT_POS,OBJECT_ROT]);
        vector vObjectPos = llList2Vector(temp, 0);//read target object's position
        rotation rObjectRot = llList2Rot(temp,1);//and rotation
//        vector vTargetPos = vObjectPos + vOffset * rObjectRot;//calculate the target position, using the target object's frame of rotational reference, not the region's (i.e. relative to the target object)
//        rotation rTargetRot = rRot * rObjectRot;//calculate the child object's desired rotation, using the target object's frame of rotational reference
        if (channel == cChannel)
        {
            objDetails = llParseString2List(message,["|"],[]); // Convert the incoming text back into a list.
            vOffset = llList2Vector(objDetails, 0); // Separate the offset from the list.
            rRot = llList2Rot(objDetails, 1); // Separate the rotation from the list.

// Prepare this slave prim for movement and rotation.
            vector vTargetPos = vObjectPos + vOffset * rObjectRot;
            rotation rTargetRot = rRot * rObjectRot;
            llSay(0, (string)vOffset);
            llSay(0, (string)rRot);
//            llSay(0, llList2String(objDetails, 0));
//            llSay(0, llList2String(objDetails, 1));
            llSetRegionPos(vTargetPos);//move to the target position
            llSetRot(rTargetRot);//and rotate to face in appropriate direction
        }
    }
}


Any help would be appreciated.


Top
 Profile  
 
 Post subject: Re: Problem with these 2 scripts.
PostPosted: Thu Jul 05, 2018 11:04 am 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 129
Location: Belgium / Brussels
This script combination should make you happy! :)
{L_CODE}:
// Prim Align (Master) v0.1 by djphil (CC-BY-NC-SA 4.0)

integer canal = -67341870;

default
{
    state_entry()
    {
        llListen(canal, "", "", "");
    }

    touch_start(integer n)
    {
        llRegionSay(canal, "PING");   
    }

    listen(integer channel, string name, key uuid, string message)
    {
        if (channel == canal && message == "PONG")
        {
            list buffer = llGetObjectDetails(uuid, [OBJECT_POS, OBJECT_ROT]);
            vector my_pos = llGetPos();

            llSetLinkPrimitiveParamsFast(LINK_THIS, [
                PRIM_POSITION, my_pos - (my_pos - llList2Vector(buffer, 0)),
                PRIM_ROTATION, llList2Rot(buffer, 1)
            ]);
        }
    }
}
{L_CODE}:
// Prim Align (Slave) v0.1 by djphil (CC-BY-NC-SA 4.0)

integer canal = -67341870;

default
{
    state_entry()
    {
        llListen(canal, "", "", "");
    }

    listen(integer channel, string name, key uuid, string message)
    {
        if (channel == canal && message == "PING")
        {
            llRegionSayTo(uuid, canal, "PONG");
        }
    }
}
Enjoy! :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Last edited by dj phil on Thu Jul 05, 2018 12:12 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Problem with these 2 scripts.
PostPosted: Thu Jul 05, 2018 12:03 pm 
Furious Typer

Joined: Tue Oct 28, 2008 4:53 pm
Posts: 166
It seems your slave script isn't the one that's doing the moving, it looks like the master is the one that moves to the slave, not the other way round, also, the prims don't align face to face, the slave prim literally occupies the same location as the master prim

Have a look at this small screen vid of what I'm looking for.

https://www.dropbox.com/s/gt52u67yjpf1v3n/Auto-Align.avi?dl=0

Touching the face of one of the objects highlights it to enable the aligning,,, then touching the face of the other object which auto aligns them,,,,, basically it works like the faux rezzers but without rezzing anything.

The video shows the first object being the object that the other object aligns to.


Top
 Profile  
 
 Post subject: Re: Problem with these 2 scripts.
PostPosted: Thu Jul 05, 2018 12:19 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 129
Location: Belgium / Brussels
If you want the opposite, you move the movements part in the other script.
{L_CODE}:
// Prim Align (Master) v0.2 by djphil (CC-BY-NC-SA 4.0)

default
{
    touch_start(integer n)
    {
        llRegionSay(-67341870, "PING");   
    }
}
{L_CODE}:
// Prim Align (Slave) v0.2 by djphil (CC-BY-NC-SA 4.0)

integer canal = -67341870;

default
{
    state_entry()
    {
        llListen(canal, "", "", "");
    }

    listen(integer channel, string name, key uuid, string message)
    {
        if (channel == canal && message == "PING")
        {
            list buffer = llGetObjectDetails(uuid, [OBJECT_POS, OBJECT_ROT]);
            vector my_pos = llGetPos();

            llSetLinkPrimitiveParamsFast(LINK_THIS, [
                PRIM_POSITION, my_pos - (my_pos - llList2Vector(buffer, 0)),
                PRIM_ROTATION, llList2Rot(buffer, 1)
            ]);
        }
    }
}
Enjoy! :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: Problem with these 2 scripts.
PostPosted: Thu Jul 05, 2018 2:17 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 129
Location: Belgium / Brussels
More sweet :P
{L_CODE}:
// Prim Align (Slave) v0.3 by djphil (CC-BY-NC-SA 4.0)

integer canal = -67341870;

default
{
    state_entry()
    {
        llSetLinkPrimitiveParamsFast(LINK_THIS, [
            PRIM_PHYSICS_SHAPE_TYPE,
            PRIM_PHYSICS_SHAPE_CONVEX
        ]);

        llListen(canal, "", "", "");
    }

    listen(integer channel, string name, key uuid, string message)
    {
        if (channel == canal && message == "PING")
        {
            list buffer = llGetObjectDetails(uuid, [OBJECT_POS, OBJECT_ROT]);
            vector my_pos = llGetPos();

            llSetLinkPrimitiveParamsFast(LINK_THIS, [
                PRIM_ROTATION, llList2Rot(buffer, 1)
            ]);

            llSetKeyframedMotion([
                llList2Vector(buffer, 0) - my_pos, ZERO_ROTATION, 1.0
            ], [KFM_MODE, KFM_FORWARD]);
        }
    }
}
Enjoy! :P

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: Problem with these 2 scripts.
PostPosted: Thu Jul 05, 2018 5:39 pm 
Furious Typer

Joined: Tue Oct 28, 2008 4:53 pm
Posts: 166
Thanks it's getting there, but there's still one problem,,,,,,when the object to be aligned is moving it still occupies the same location as the object being aligned to, the alignment needs an offset so that whatever prim is being moved to align, it stops when it reaches the other prim, as if to create a line of prims end to end, I'm not sure how to calulate the offset being that prims can be any size, and that the offset can change according to size.


Top
 Profile  
 
 Post subject: Re: Problem with these 2 scripts.
PostPosted: Thu Jul 05, 2018 11:04 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 129
Location: Belgium / Brussels
This one use osGetPrimitiveParams :!:
{L_CODE}:
// Prim Align (Slave) v0.4 by djphil (CC-BY-NC-SA 4.0)

integer canal = -67341870;

default
{
    state_entry()
    {
        llListen(canal, "", "", "");
    }

    listen(integer channel, string name, key uuid, string message)
    {
        if (channel == canal && message == "PING")
        {
            list buffer = osGetPrimitiveParams(uuid, [PRIM_POSITION, PRIM_ROTATION, PRIM_SIZE]);
            vector offset = (llGetScale() + llList2Vector(buffer, 2)) * 0.5;
            vector my_pos = llGetPos();

            llSetLinkPrimitiveParamsFast(LINK_THIS, [
                PRIM_POSITION, my_pos - (my_pos - llList2Vector(buffer, 0)) + (<offset.x, 0.0, 0.0> * llGetRot()),
                PRIM_ROTATION, llList2Rot(buffer, 1)
            ]);
        }
    }
}
Enjoy! :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Last edited by dj phil on Thu Jul 05, 2018 11:56 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Problem with these 2 scripts.
PostPosted: Thu Jul 05, 2018 11:07 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 129
Location: Belgium / Brussels
And the sweet version :P
{L_CODE}:
// Prim Align (Slave) v0.5 by djphil (CC-BY-NC-SA 4.0)

integer canal = -67341870;

default
{
    state_entry()
    {
        llSetLinkPrimitiveParamsFast(LINK_THIS, [
            PRIM_PHYSICS_SHAPE_TYPE,
            PRIM_PHYSICS_SHAPE_CONVEX
        ]);

        llListen(canal, "", "", "");
    }

    listen(integer channel, string name, key uuid, string message)
    {
        if (channel == canal && message == "PING")
        {
            list buffer = osGetPrimitiveParams(uuid, [PRIM_POSITION, PRIM_ROTATION, PRIM_SIZE]);
            vector offset = (llGetScale() + llList2Vector(buffer, 2)) * 0.5;
            vector my_pos = llGetPos();

            llSetLinkPrimitiveParamsFast(LINK_THIS, [
                PRIM_ROTATION, llList2Rot(buffer, 1)
            ]);

            llSetKeyframedMotion([
                llList2Vector(buffer, 0) - my_pos + (<offset.x, 0.0, 0.0> * llGetRot()), ZERO_ROTATION, 1.0
            ], [KFM_MODE, KFM_FORWARD]);
        }
    }
}
Enjoy! :P

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 8 posts ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net