Change font size
It is currently Tue Jul 23, 2019 9:36 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: geometry script (change prim parameters)
PostPosted: Sat Mar 02, 2019 8:16 am 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
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!


Top
 Profile  
 
 Post subject: Re: geometry script (change prim parameters)
PostPosted: Sat Mar 02, 2019 11:45 am 
Site Admin
User avatar

Joined: Sun Jun 27, 2010 10:34 am
Posts: 155
Location: France
use description objet name ;)

_________________
Paela Argus,
Webmanagement and maintenance servers grid, Osgrid

https://www.osgrid.org


Top
 Profile  
 
 Post subject: Re: geometry script (change prim parameters)
PostPosted: Sat Mar 02, 2019 2:27 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 220
Location: Belgium / Brussels
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! :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: geometry script (change prim parameters)
PostPosted: Sat Mar 02, 2019 6:05 pm 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 4 posts ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net