Jump to content

Set Child Prim To Location Of None Attached Prim


TonyBowlin
 Share

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

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

Recommended Posts

Ok so the idea here is I have a vehicle that is sending out these values for the fuel pump to use to set the fuel pump's handle position and rotation to line up with the vehicle when using the pump.

This is what the car is sending to the pump.


vector pos=llGetPos()+nozzle_pos*llGetRot();
rotation rot=nozzle_rot*llGetRot();
float nx = pos.x;
float ny = pos.y;
float nz = pos.z;
llWhisper(993029418,"AUDA|RETU|"+(string)galLimit+"|"+(string)nx+"|"+(string)ny+"|"+(string)nz+"|"+(string)rot);

 

Here is what the pump script is receiving. 

 

listen(integer channel, string name, key id, string message)
    {
        list dat=llParseString2List(message,["|"],[]);

        if (llList2String(dat,1)=="RETU")
        {
            galFilled=(float)llList2String(dat,2);
            carrot = (rotation)llList2String(dat,6);

            float carnx = llList2Float(dat,3) ;
            float carny = llList2Float(dat,4) ;
            float carnz = llList2Float(dat,5) ;

            //vector carpos= <carnx,carny,carnz>*carrot;
            vector carpos= <carnx,carny,carnz>;
            llOwnerSay( "car's pos "+(string)carpos);

            vector mypos = llGetPos();
            float myposx = mypos.x;
            float myposy = mypos.y;
            float myposz = mypos.z;
            vector mypostest = <mypos.x,mypos.y,mypos.z>;
            llOwnerSay( "mypostest "+(string)mypostest);

            vector newnoz = mypostest-carpos;

            llOwnerSay( "FINAL NOZZLE POS,"+(string)newnoz);
            llSetLinkPrimitiveParamsFast(link1,[PRIM_POSITION, newnoz]);//Here is the fuel pump's handle, it is the child prim of the pump

        }
    }

 

For the life of me I can't seem to understand the rotation part. the fuel pump's handle or link1 in this case will only move to the correct spot if the vehicle and pump are rotation in the same one and only direction globally at <0,0,180>. I haven't even begun to start on matching the link one's rotation with that of the vehicle as I'm still stuck on matching positions.

I are broke brain on this one. =\

Edited by TonyBowlin
Link to comment
Share on other sites

Positions and rotations are always kinda messy.

But one easy thing to remember is that if you have a relative position (a link in your linkset) and you want to know where it exists in world coordinates, you can:

vector world_coordinates = relative_position / root_rotation;

The same works with local/world rotations. Getting back to local coordinates is just doing the reverse:

vector local_coordinages = world_position * root_rotation;

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1238 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...