osgrid.org
https://forums.osgrid.org/

geometry script (change prim parameters)
https://forums.osgrid.org/viewtopic.php?f=5&t=6325
Page 1 of 1

Author:  marshall genord [ Sat Mar 02, 2019 8:16 am ]
Post subject:  geometry script (change prim parameters)

Hi again!
I would like to make a script that visualizes various geometrical shapes in a circle,
for example angles and fraction numbers.

I've made a script that makes a cylinder change its size into a certain percentage of its original size,
by doing a path cut, through a listen-event.

For example, a cylinder which is changed into 25% of its original size
would require a path cut of 0.75.
As an angle, the new shape would have a 90° angle.

My script looks as follows:
{L_CODE}:
default
{
state_entry()
{
llListen(0,"", NULL_KEY, "");
    }
    listen(integer channel, string name, key id, string message)
    {
            if (message == "25") {
            llSetPrimitiveParams([PRIM_TYPE,
                        PRIM_TYPE_CYLINDER,
                            PRIM_HOLE_DEFAULT,  // hole_shape
                            <0.75, 1.0, 0.0>,   // cut
                            0.0,                // hollow
                            <0.0, 0.0, 0.0>,    // twist
                            <1.0, 1.0, 0.0>,    // top_size
                            <0.0, 0.0, 0.0>     // top_Shear
                      ]);
                    }
}
}

This works as it is.

The only downside is that I have to adjust the script for every single size I want to visualize by hand.
For example, If I want a 50%-sized cylinder, I have to change the 0.75 path-cut in the script by hand into 0.5.
For a 75%-sized cylinder, I have to change the path-cut in the script by hand into 0.25, and so on.

I would like to change the script so that any typed-in number
is automatically translated into the respective path cut.

For example, if I simply write "62", the cylinder should automatically be changed into 62% of its size
(which means a path cut of 0.38).
If I write, e.g., "63", it should be given a path cut of 0.37.
At, e.g., "54.5" (if that's possible), it should be given a path cut of 0.455 and so on.

Is there a way to do this?
Thanks!

Author:  paela argus [ Sat Mar 02, 2019 11:45 am ]
Post subject:  Re: geometry script (change prim parameters)

use description objet name ;)

Author:  dj phil [ Sat Mar 02, 2019 2:27 pm ]
Post subject:  Re: geometry script (change prim parameters)

Yeah, hi again :)
{L_CODE}:
// Cylinder Cutting v0.1 by djphil (CC-BY-NC-SA 4.0)

default
{
    state_entry()
    {
        llListen(PUBLIC_CHANNEL, "", NULL_KEY, "");
    }
   
    listen(integer channel, string name, key id, string message)
    {
        message = llStringTrim(message, STRING_TRIM);
        if (llJsonValueType(message, []) != JSON_NUMBER) return;

        float cut = 100.0 - (float)message;
        cut = cut * 0.01;
        if (cut < 0.0) cut = 0.0;
        if (cut > 1.0) cut = 1.0;

        llSetLinkPrimitiveParamsFast(LINK_THIS, [
            PRIM_TYPE, PRIM_TYPE_CYLINDER,
            PRIM_HOLE_DEFAULT,  // hole_shape
            <cut, 1.0, 0.0>,    // cut
            0.0,                // hollow
            <0.0, 0.0, 0.0>,    // twist
            <1.0, 1.0, 0.0>,    // top_size
            <0.0, 0.0, 0.0>     // top_Shear
        ]);
    }
}
Usage: say a integer or a float number between 0.0 and 100.0
Note: Cutting is ignored if the message isn't a number.
Some reading @ Typecast.

Enjoy! :)

Author:  marshall genord [ Sat Mar 02, 2019 6:05 pm ]
Post subject:  Re: geometry script (change prim parameters)

Thanks again, mate.
I just tested it.
It works like a charm.
I knew you could do this. :D
This is amazing.
My students will have a lot of fun with this.
Thank you so much!
Cheers!

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/