Jump to content

Child prims points toward root prim


Recommended Posts

default
{   state_entry()
    {   integer link = llGetNumberOfPrims();
        do{ vector X = -llVecNorm(llList2Vector(llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL]),0));
            vector Y = llVecNorm(<0,0,1>%X);
            vector Z = llVecNorm(X%Y);
            llSetLinkPrimitiveParamsFast(link,[PRIM_ROT_LOCAL,llAxes2Rot(X,Y,Z)]);
        }while(--link>1);
    }
}

note to self: vecNorms are actually required for accurate results.

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

1 hour ago, sunil Treves said:

That information was very helpful. Is it also possible for linked prims to face towards its adjust / next linked prim same on X axis and not the root prim?

You can make each linked prim's x-axis face any which way you like, you just need to set X to a normalized vector indicating the direction (in local coordinates). Conveniently for the above example, the local position of a linked prim is a vector pointing from the root to the prim. A vector pointing from one linked prim to another would be the difference in their positions.

Link to comment
Share on other sites

2 minutes ago, sunil Treves said:

may i have an code example?

This (section of the) forum is more for discussing general ideas and methodologies for how to do things, not for asking people to write a complete script for you.

I feel a bit crass saying this, but you really ought to learn to script it yourself, or pay someone else to do it for you (for which you might try the 'wanted' or 'in-world employment' sub-sections of the forum).

Link to comment
Share on other sites

Thanks

 

Apologies if i didn’t explain myself clearly as i didn’t request a complete script but an example for the maths you stated for the difference between there positions.
 

Even a wiki page would do however I can search myself based on ur suggestion. Also, I’m trying to learn the complex system around rotation and been looking for correct direction using this form

9 hours ago, Quistess Alpha said:

You can make each linked prim's x-axis face any which way you like, you just need to set X to a normalized vector indicating the direction (in local coordinates). Conveniently for the above example, the local position of a linked prim is a vector pointing from the root to the prim. A vector pointing from one linked prim to another would be the difference in their positions.

 

Have a good day ahead.

Edited by sunil Treves
Link to comment
Share on other sites

41 minutes ago, sunil Treves said:

Even a wiki page would do.

llGetLinkPrimitiveParams PRIM_POS_LOCAL

vector posA = llList2Vector(llGetLinkPrimitiveParams(linkA,[PRIM_POS_LOCAL]),0);
vector posB = llList2Vector(llGetLinkPrimitiveParams(linkB,[PRIM_POS_LOCAL]),0);
vector difference = posA-posB;

The difference between 2 things isn't exactly rocket science?

ETA: while I'm posting wiki links: https://en.wikipedia.org/wiki/Cross_product

Right_hand_rule_cross_product.svg

More usefully, crossing 2 of these axes in counter-clockwise order gives you the third: Thumb%pointer=middle; pointer%middle=thumb; middle%thumb=pointer

Edited by Quistess Alpha
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...