Jump to content

Mesh linkset resizer creates visible seams


ayamashi
 Share

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

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

Recommended Posts

Hi,

I  modified this script into my llDialog menu https://community.secondlife.com/forums/topic/32596-basic-resizer/

Mostly by copy pasting this part

float fabsizeX;
float rezsizeX;
vector rs;
float listenTimeout=1800.0; // seconds
integer listenHandle;



integer dimTest( vector vr )
{
    return !( vr.x<0.01 || vr.y<0.01 || vr.z<0.01 || vr.x>64.0 || vr.y>64.0 || vr.z>64.0 );
}

primloop( float scal )
{
    integer primindx;
    integer validDim=TRUE;
    list primP;

    if (llGetNumberOfPrims()<2) validDim = validDim && dimTest( scal*llGetScale());
    else
    for ( primindx = 1; primindx <= llGetNumberOfPrims(); primindx++ )
    {
        primP = llGetLinkPrimitiveParams( primindx, [PRIM_SIZE]);
        validDim = validDim && dimTest( scal*llList2Vector( primP, 0 ));
    }

    if ( validDim )
    {
        if (llGetNumberOfPrims()<2) llSetScale( scal*llGetScale()); // not linked prim
        else
        for ( primindx = 1; primindx <= llGetNumberOfPrims(); primindx++ )
        {
            primP = llGetLinkPrimitiveParams( primindx, [PRIM_SIZE, PRIM_POSITION]);
            vector primScale = scal*llList2Vector( primP, 0 );
            vector primPos = scal*(llList2Vector( primP, 1 )-llGetPos());
            if ( primindx == 1 ) llSetLinkPrimitiveParamsFast( primindx, [PRIM_SIZE, primScale]);
            else llSetLinkPrimitiveParamsFast( primindx, [PRIM_SIZE, primScale, PRIM_POSITION, primPos/llGetRootRotation()]);
        }
    }
    else llOwnerSay("No resize! Out of limit sizes are not accepted");
}
      default
{
    state_entry()
    {
        rs = llGetScale();
        fabsizeX = rs.x;
        rezsizeX = fabsizeX;
        llOwnerSay("Size at buy is set to Current size");
    }
    on_rez( integer p)
    {
        rs = llGetScale();
        rezsizeX = rs.x;
    }

and in the listen event created only buttons for +Size and -Size

listen(integer channel, string name, key id, string message)
{
	if (message == "+Size");
	{
		primloop(1.2);
	}

	if (message == "-Size");
	{

		primloop(1.0/1.2);
	}

Well, it works..but when I select +Size it creates visible seams on my object where the meshes touch. My object is 4 separate objects uploaded as 1 linkset with 5th plane in the middle for the button. I put the script inside the button plane, made sure its its root prim.

If I press the +Size only once the seams are there but not very visible. But if I press +Size multiple times, then -Size then +Size the seams get obvious.

It seems to me that the link set objects are not resized accurately and it creates the seams. One time the seam overlaps, one time theres a gap between left and right side, or top and bottom side.

Is this something to do with the script? Should I use a different one? Theres a *Bosh* resizer script but I want the resize menu inside my Dialog menu not a separate script.

Or is it something to do with my mesh? I apply all transforms->set origin to geometry when exporting from Blender.

When I manually resize my object in world  there are no seams.

Thanks!

Link to comment
Share on other sites

Floating point numbers used to represent position and size are inherently imprecise. Your scaler will rescale an already rescaled linkset every time, so the imprecision compounds quickly.

A more stable implementation would save the sizes and positions of each prim at 1x scale at start, then do the calculations based on those to get directly to the desired scale, with only one precision-losing operation.

  • Like 1
Link to comment
Share on other sites

7 hours ago, Frionil Fang said:

Floating point numbers used to represent position and size are inherently imprecise. Your scaler will rescale an already rescaled linkset every time, so the imprecision compounds quickly.

A more stable implementation would save the sizes and positions of each prim at 1x scale at start, then do the calculations based on those to get directly to the desired scale, with only one precision-losing operation.

Thanks for the reply!

How difficult is this to achieve for an almost complete scripting newbie?

Unfortunately I am not that experienced in scripting so I am thinking whether I should make the mesh MOD so people can resize it themselves or hire a scripter.

Link to comment
Share on other sites

Just now, ayamashi said:

Unfortunately I am not that experienced in scripting so I am thinking whether I should make the mesh MOD so people can resize it themselves or hire a scripter.

Making it mod would probably be the easiest option, although the in-world scaling tools might have a similar issue.

Also your script seems to predate the introduction of the LSL function https://wiki.secondlife.com/wiki/LlScaleByFactor

  • Like 1
Link to comment
Share on other sites

8 minutes ago, Quistess Alpha said:

Making it mod would probably be the easiest option, although the in-world scaling tools might have a similar issue.

Also your script seems to predate the introduction of the LSL function https://wiki.secondlife.com/wiki/LlScaleByFactor

I just tried the llScaleByFactor and it seems it does not create any seams even when I repeatedly scale up and down.

I dont see any potential problems with it mentioned in the wiki. Can I assume I can use this without problems? Will it fail to rescale properly for example if the sim is laggy?

 

Link to comment
Share on other sites

2 hours ago, ayamashi said:

I dont see any potential problems with it mentioned in the wiki. Can I assume I can use this without problems? Will it fail to rescale properly for example if the sim is laggy?

 

best to test these things on as many regions as we can ourselves. So we can have some empirical evidence that our thing works as we expect it too

Link to comment
Share on other sites

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