Poseballs in sync?

Creating scripts
User avatar
Koshari Mahana
Posts: 358
Joined: Fri Feb 06, 2015 8:14 am
Has thanked: 279 times
Been thanked: 498 times
Contact:

Poseballs in sync?

Post by Koshari Mahana »

.
I'm trying to make a dance ring (balls going around in a circle) and I have everything made, it rotates fine and the poseballs have their animations in them but how do I make the dancers in sync? It seems like I had something like that working in SL many years ago but I just can't remember how to do it now. Thanks for any help.
.
Last edited by Koshari Mahana on Wed Apr 19, 2023 9:37 am, edited 1 time in total.
These users thanked the author Koshari Mahana for the post:
Ilan Tochner
Image
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
User avatar
Ilan Tochner
Posts: 6518
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4968 times
Been thanked: 4469 times
Contact:

Re: Pose ball in sync?

Post by Ilan Tochner »

Hi Koshari,

For the spinning of the ball please make sure to make it Phantom and use object properties and not a script that constantly updates the object's rotation. See: https://wiki.secondlife.com/wiki/LlTargetOmega
User avatar
Koshari Mahana
Posts: 358
Joined: Fri Feb 06, 2015 8:14 am
Has thanked: 279 times
Been thanked: 498 times
Contact:

Re: Pose ball in sync?

Post by Koshari Mahana »

Thanks, Ilan. It's been phantom, I make nearly everything phantom whether it moves or not (unless it's a wall or a floor). The simple rotation script is in the root prim so there shouldn't be a problem since it's phantom.

I don't know what you mean by "... use object properties and not a script..."
Ilan Tochner wrote:
Wed Apr 19, 2023 8:24 am
Hi Koshari,

For the spinning of the ball please make sure to make it Phantom and use object properties and not a script that constantly updates the object's rotation. See: https://wiki.secondlife.com/wiki/LlTargetOmega
Image
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
User avatar
Ilan Tochner
Posts: 6518
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4968 times
Been thanked: 4469 times
Contact:

Re: Poseballs in sync?

Post by Ilan Tochner »

Use the function I linked to that sets the object's property once instead of using a script that changes the object's rotation once every X time.
These users thanked the author Ilan Tochner for the post:
Koshari Mahana
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1142 times

Re: Poseballs in sync?

Post by Graham Mills »

Via phind.com (no time to check it). Re-query to see linked resources.
write a script in lsl for opensim that triggers an animation in two linked poseballs and then synchronises them

Code: Select all

// Define the animation name
string ANIM_NAME = "my_animation";

// Define the channel number for the animation
integer ANIM_CHANNEL = 1;

// Define the time it takes for the animation to play
float ANIM_TIME = 2.0;

// Define the linked poseball numbers
integer POSEBALL_1 = 1;
integer POSEBALL_2 = 2;

// Define the synchronization delay
float SYNC_DELAY = 0.5;

// Declare the functions that will play and synchronize the animation
play_animation() {
    llMessageLinked(LINK_SET, ANIM_CHANNEL, ANIM_NAME, "");
}

synchronize_animation() {
    llSleep(SYNC_DELAY);
    llMessageLinked(LINK_SET, ANIM_CHANNEL, "sync", "");
}

// Declare the touch event function that will trigger the animation
default
{
    touch_start(integer total_number)
    {
        // Play the animation on the first poseball
        llSetLinkPrimitiveParamsFast(POSEBALL_1, [PRIM_ANIM, ANIM_NAME, ANIM_CHANNEL, ANIM_TIME, 0.0]);
        
        // Play the animation on the second poseball
        llSetLinkPrimitiveParamsFast(POSEBALL_2, [PRIM_ANIM, ANIM_NAME, ANIM_CHANNEL, ANIM_TIME, 0.0]);
        
        // Send a message to synchronize the animation
        synchronize_animation();
    }
}

Update: I can see a few problems with the above.
Last edited by Graham Mills on Wed Apr 19, 2023 7:06 pm, edited 1 time in total.
These users thanked the author Graham Mills for the post (total 2):
Ilan TochnerKoshari Mahana
User avatar
Koshari Mahana
Posts: 358
Joined: Fri Feb 06, 2015 8:14 am
Has thanked: 279 times
Been thanked: 498 times
Contact:

Re: Poseballs in sync?

Post by Koshari Mahana »

.

Thanks, Grahm! I'll give it a try. :)
.
Graham Mills wrote:
Wed Apr 19, 2023 10:43 am
Via phind.com (no time to check it). Re-query to see linked resources.
write a script in lsl for opensim that triggers an animation in two linked poseballs and then synchronises them

Code: Select all

// Define the animation name
string ANIM_NAME = "my_animation";

// Define the channel number for the animation
integer ANIM_CHANNEL = 1;

// Define the time it takes for the animation to play
float ANIM_TIME = 2.0;

// Define the linked poseball numbers
integer POSEBALL_1 = 1;
integer POSEBALL_2 = 2;

// Define the synchronization delay
float SYNC_DELAY = 0.5;

// Declare the functions that will play and synchronize the animation
play_animation() {
    llMessageLinked(LINK_SET, ANIM_CHANNEL, ANIM_NAME, "");
}

synchronize_animation() {
    llSleep(SYNC_DELAY);
    llMessageLinked(LINK_SET, ANIM_CHANNEL, "sync", "");
}

// Declare the touch event function that will trigger the animation
default
{
    touch_start(integer total_number)
    {
        // Play the animation on the first poseball
        llSetLinkPrimitiveParamsFast(POSEBALL_1, [PRIM_ANIM, ANIM_NAME, ANIM_CHANNEL, ANIM_TIME, 0.0]);
        
        // Play the animation on the second poseball
        llSetLinkPrimitiveParamsFast(POSEBALL_2, [PRIM_ANIM, ANIM_NAME, ANIM_CHANNEL, ANIM_TIME, 0.0]);
        
        // Send a message to synchronize the animation
        synchronize_animation();
    }
}

Image
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1142 times

Re: Poseballs in sync?

Post by Graham Mills »

A slightly more complex query to get round a couple of issues. Again, no idea whether it works but it phind.com does at least provide its reasoning and sources.
write a script in lsl for opensim that triggers an animation in two linked poseballs and then synchronises them. Check that the avatars give permission to be animated.

Code: Select all

// Define the animation name
string animation_name = "my_animation_name";

// Define the permission request message
string permission_request = "May I animate you?";

// Define the synchronization time
float sync_time = 2.0;

// Define the poseballs
integer poseball1 = 1;
integer poseball2 = 2;

// Define the avatars
key avatar1;
key avatar2;

default
{
    state_entry()
    {
        // Set the poseballs to be physical
        llSetStatus(STATUS_PHYSICS, TRUE);

        // Set the poseballs to be phantom
        llSetStatus(STATUS_PHANTOM, TRUE);

        // Set the poseballs to be linked
        llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_LINK_TARGET, poseball2]);

        // Reset the poseballs' animations
        llStopAnimation(animation_name);
    }

    touch_start(integer total_number)
    {
        // Get the key of the avatar that touched the poseball
        key touched_avatar = llDetectedKey(0);

        // Check if the avatar has given permission to be animated
        if (llDetectedName(0) == touched_avatar && llDetectedType(0) & AGENT && touched_avatar != llGetOwner())
        {
            llRequestPermissions(touched_avatar, PERMISSION_TRIGGER_ANIMATION);
        }
    }

    run_time_permissions(integer permission)
    {
        // Check if the avatar has granted permission to be animated
        if (permission & PERMISSION_TRIGGER_ANIMATION)
        {
            // Get the key of the avatar that granted permission
            key granted_avatar = llGetPermissionsKey();

            // Check if this is the first avatar to grant permission
            if (avatar1 == NULL_KEY)
            {
                // Set the first avatar as the granted avatar
                avatar1 = granted_avatar;

                // Start the animation for the first poseball
                llStartAnimation(animation_name);

                // Sit the first avatar on the first poseball
                llSitTarget(<0.0, 0.0, 0.0>, ZERO_ROTATION);
            }
            // Check if this is the second avatar to grant permission
            else if (avatar2 == NULL_KEY)
            {
                // Set the second avatar as the granted avatar
                avatar2 = granted_avatar;

                // Start the animation for the second poseball
                llStartAnimation(animation_name);

                // Sit the second avatar on the second poseball
                llSitTarget(<0.0, 0.0, 0.0>, ZERO_ROTATION);

                // Synchronize the poseballs after the specified time
                llSetTimerEvent(sync_time);
            }
        }
    }

    timer()
    {
        // Unlink the poseballs
        llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_LINK_TARGET, LINK_THIS]);

        // Reset the avatars' keys
        avatar1 = NULL_KEY;
        avatar2 = NULL_KEY;

        // Stop the timer event
        llSetTimerEvent(0.0);
    }
}

These users thanked the author Graham Mills for the post:
Koshari Mahana
User avatar
Koshari Mahana
Posts: 358
Joined: Fri Feb 06, 2015 8:14 am
Has thanked: 279 times
Been thanked: 498 times
Contact:

Re: Poseballs in sync?

Post by Koshari Mahana »

.
Thank you so much! I wonder if this means I need to name the poseballs "poseball1" "poseball2" etc... or if that's just the script referring to them?
.
Graham Mills wrote:
Wed Apr 19, 2023 7:14 pm
A slightly more complex query to get round a couple of issues. Again, no idea whether it works but it phind.com does at least provide its reasoning and sources.
write a script in lsl for opensim that triggers an animation in two linked poseballs and then synchronises them. Check that the avatars give permission to be animated.

Code: Select all

// Define the animation name
string animation_name = "my_animation_name";

// Define the permission request message
string permission_request = "May I animate you?";

// Define the synchronization time
float sync_time = 2.0;

// Define the poseballs
integer poseball1 = 1;
integer poseball2 = 2;

// Define the avatars
key avatar1;
key avatar2;

default
{
    state_entry()
    {
        // Set the poseballs to be physical
        llSetStatus(STATUS_PHYSICS, TRUE);

        // Set the poseballs to be phantom
        llSetStatus(STATUS_PHANTOM, TRUE);

        // Set the poseballs to be linked
        llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_LINK_TARGET, poseball2]);

        // Reset the poseballs' animations
        llStopAnimation(animation_name);
    }

    touch_start(integer total_number)
    {
        // Get the key of the avatar that touched the poseball
        key touched_avatar = llDetectedKey(0);

        // Check if the avatar has given permission to be animated
        if (llDetectedName(0) == touched_avatar && llDetectedType(0) & AGENT && touched_avatar != llGetOwner())
        {
            llRequestPermissions(touched_avatar, PERMISSION_TRIGGER_ANIMATION);
        }
    }

    run_time_permissions(integer permission)
    {
        // Check if the avatar has granted permission to be animated
        if (permission & PERMISSION_TRIGGER_ANIMATION)
        {
            // Get the key of the avatar that granted permission
            key granted_avatar = llGetPermissionsKey();

            // Check if this is the first avatar to grant permission
            if (avatar1 == NULL_KEY)
            {
                // Set the first avatar as the granted avatar
                avatar1 = granted_avatar;

                // Start the animation for the first poseball
                llStartAnimation(animation_name);

                // Sit the first avatar on the first poseball
                llSitTarget(<0.0, 0.0, 0.0>, ZERO_ROTATION);
            }
            // Check if this is the second avatar to grant permission
            else if (avatar2 == NULL_KEY)
            {
                // Set the second avatar as the granted avatar
                avatar2 = granted_avatar;

                // Start the animation for the second poseball
                llStartAnimation(animation_name);

                // Sit the second avatar on the second poseball
                llSitTarget(<0.0, 0.0, 0.0>, ZERO_ROTATION);

                // Synchronize the poseballs after the specified time
                llSetTimerEvent(sync_time);
            }
        }
    }

    timer()
    {
        // Unlink the poseballs
        llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_LINK_TARGET, LINK_THIS]);

        // Reset the avatars' keys
        avatar1 = NULL_KEY;
        avatar2 = NULL_KEY;

        // Stop the timer event
        llSetTimerEvent(0.0);
    }
}

Image
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1142 times

Re: Poseballs in sync?

Post by Graham Mills »

poseball2 as below is simply a reference to the integer link number.

llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_LINK_TARGET, poseball2]);

Could you otherwise use something like PMAC? https://github.com/uriesk/pmac
User avatar
Koshari Mahana
Posts: 358
Joined: Fri Feb 06, 2015 8:14 am
Has thanked: 279 times
Been thanked: 498 times
Contact:

Re: Poseballs in sync?

Post by Koshari Mahana »

Yes, let me check that. I tried both of the scripts above and I guess I don't know how to use them. ie: do the avatars sit on the poseballs, do they click on the root rotating prim, do they click on the first avatar etc... I remember in SL I had meditation cushions that I made and all I remember is having them linked to the root prim and they all just were in sync, I don't remember doing anything special (that doesn't mean I didn't. Thanks again, I'll try the link you sent.

Graham Mills wrote:
Wed Apr 19, 2023 7:34 pm
poseball2 as below is simply a reference to the integer link number.

llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_LINK_TARGET, poseball2]);

Could you otherwise use something like PMAC? https://github.com/uriesk/pmac
Image
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
Post Reply