Jump to content
You are about to reply to a thread that has been inactive for 4235 days.

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

Recommended Posts

Posted

Hi All,

 

In a menu, I'm trying to be able to get and adjust the Horiz & Vert Face Repeats!  So far, here is what I've done:

 

vector scale_vector = llGetTextureScale(0);

(string)scale_vector

Results:  <0.50000, 0.30000, 0.00000>

 

OR

 

vector repeats;

list params = llGetPrimitiveParams([PRIM_TEXTURE,0]);

repeats = llList2Vector(params, 1);
llOwnerSay((string)params);

Results:

5748decc-f629-461c-9a36-a35a221fe21f<0.300000, 0.200000, 0.000000><0.000000, 0.000000, 0.000000>0.000000

 

--------------------------------------------------------------------------

 

My question(s)?  

 

1)  Is it possible to get "either" Horiz or Vert parameters separetly?

 

2) Is it possible to increase/decrease Horiz or Vert seperately?

 

3) While using llScaleTexture((float)repeats_u, (float)repeats_v, ALL_SIDES);

I am able to change the values, but just "SET" the values!  If the prim already has existing values, how can I first get the current values (such as i did above), and adjust those numbers up or down individually?

 

Thanks in advance.....  :-)

 

 

Posted

Each element of a vector can be accessed individually by appending .x, .y, or .z to the variable name.

So...

vector repeats;list params = llGetPrimitiveParams([PRIM_TEXTURE,0]);repeats = llList2Vector(params, 1);repeats = <0.5, repeats.y, repeats.z>;llSetPrimitiveParams([ PRIM_TEXTURE, 0, llList2String(params, 0), repeats, llList2Vector(params, 2), llList2Float(params, 3) ]

should work. I think.

Posted


joeyblueyes wrote:

Hi All,

 

In a menu, I'm trying to be able to get and adjust the Horiz & Vert Face Repeats!  So far, here is what I've done:

 

vector scale_vector = llGetTextureScale(0);

(string)
scale_vector

Results:  <0.50000, 0.30000, 0.00000>

 

OR

 

vector repeats;

list params = llGetPrimitiveParams([PRIM_TEXTURE,0]);

repeats = llLis
t2Vector
(
params
,
1
);

llOwnerSay((string)params);

Results:

5748decc-f629-461c-9a36-a35a221fe21f<0.300000, 0.200000, 0.000000><0.000000, 0.000000, 0.000000>0.000000

 

--------------------------------------------------------------------------

 

My question(s)?  

 

1)  Is it possible to get "either" Horiz or Vert parameters separately?

 

2) Is it possible to increase/decrease Horiz or Vert separately?

 

3) While using llScaleTexture((float)repeats_u, (float)repeats_v, ALL_SIDES);

I am able to change the values, but just "SET" the values!  If the prim already has existing values, how can I first get the current values (such as i did above), and adjust those numbers up or down individually?

 

Thanks in advance.....  :-)

 

 

If all you plan to do is change the repeats of the texture, then it would be preferable to use your first choice, llGetTextureScale, avoiding the overhead of dealing with lists. However, if there's a chance that you may at some point decide to change other parameters as well, such as the offset or rotation, it may make more sense to use your second choice, llGetPrimitiveParams, avoiding having to modify your code very much to accommodate that. Alright?

 

1.) Both choices return the horizontal and vertical repeats in a vector, but you can access them each separately. The first number in the vector (known as the "x component") is for horizontal(U), the second (the "y component") is vertical(V) and the third ("z component") is unused in this case so it will always be 0.0.  So, to access each separately, you'd have:

 

// these variables should be global, since you'll need them before// calling llDialog (to show current values in your menu)// and again within your listen() event, when you'll be setting the new // values according to the menu choices madefloat U; // variable to hold horizontal repeatsfloat V; // variable to hold vertical repeatsvector repeats; // using this for the variable name in both examples to avoid confusion// Use this line of code (within state_entry of default) if all you // ever plan to do is change repeatsrepeats = llGetTextureScale(0); // was "scale_vector" in your first example// OR use this if you're to change more than just the repeatslist params = llGetPrimitiveParams([PRIM_TEXTURE,0]);repeats = llList2Vector(params, 1);// in both cases you'll now pull the horizontal and vertical repeats // out using the followingU = repeats.x; // the ".x" suffix accesses the first, "x", component of any vectorV = repeats.y; // And we ignore repeats.z, since it is unused in this case

 

2.) Within your listen() event and in response to whatever menu choice is made, you'd simply subtract or add to the U (horizontal) or V (vertical) variable. Then you'd plug the new values in using:

 

llScaleTexture (U, V, 0); // not ALL_SIDES unless you want to change the// entire prim and not just side "0", which is all you've queried for before// OR use the following if you've decided to change offsets or rotation as well as repeatsllSetPrimitiveParams([ PRIM_TEXTURE, ... Parameter list as given at http://wiki.secondlife.com/wiki/LlSetPrimitiveParams ... ]);

 In either case, you'll need to update the repeats variable to reflect the change being made using:

repeats = <U, V, 0.0>;

 

 

as well as rotation and offset variables in the event those are changing as well.

3.) That's, hopefully, clear in the above examples. It's a three step process; get the current values, determine what needs changing and then set the new values. And, even though only one may be changed, you still must deal with both in the vector format. OK?

 

However, if you have further questions or need clarification on anything, do ask. The only dumb question is the one not asked.

Posted

Sorry for my delay in getting back...  Thank you all so much for your help and examples.....  Seems I was mainly missing the .x & .y

 

LepreKhaun, thank you so much for the detail as well!  I will be also be adjusting Offset & rotation, so seems like the list format will be best....  If Repeats uses .x & .y, then what would rotation and offset call?

 

Thanks again...

 

Posted

When in doubt, read the wiki. If you look at the parameter list for PRIM_TEXTURE in the wiki entry for llSetLinkPrimitiveParamsFast, you'll find that offsets are supplied in a vector with X and Y ranging from -1.0 to 1.0, the same as when you change them "manually" in world.  The last parameter in the list is rotation, a float in radians. 

Posted


joeyblueyes wrote:

Sorry for my delay in getting back...  Thank you all so much for your help and examples.....  Seems I was mainly missing the .x & .y

 

LepreKhaun, thank you so much for the detail as well!  I will be also be adjusting Offset & rotation, so seems like the list format will be best....  If Repeats uses .x & .y, then what would rotation and offset call?

 

Thanks again...

Giving some thought to your question and reviewing others you have raised in your posting history, I have become aware of what the problem is here: You apparently are trying to move too fast into coding,

 

No biggie really, I'm certain everyone does this at first, becoming too focused on completing a program before taking the necessary time to understand the basic building blocks one uses in its construction. But this approach will not only add time to the writing of a program (as you waste a number of hours trying hit-or-miss blind guesses to try to jimmy everything into working order) but it also leads to unnecessary frustration which may cause you to give it all up entirely.

 

Rolig says "When in doubt, read the wiki" which is very good advice but, at this point for you, reading isn't enough- you must study the wiki. Not only is everything there but the knowledge is presented in a way that a complete understanding of it all is possible.

 

Allow me to show you how you can study the wiki and increase your coding skills.

 

In your original posting in this thread, you used "list params = llGetPrimitiveParams([PRIM_TEXTURE,0]);"Let us open the wiki page for llGetPrimitiveParams ( http://wiki.secondlife.com/wiki/LlGetPrimitiveParams ) and I'll try to show how this must be studied for full benefit.

 

First of all, you'll see at the top "Function: list llGetPrimitiveParams( list params );", which tells you that it is a Linden Scripting Library Function that expects a list and returns a list.. But, here's where the study part comes in!  Before going any further down that page, be certain you know and understand each of the underlined words in that phrase, which are (in this case) Function and list. They are underlined because they a links to pages in the wiki that define those terms and, to understand the basic building blocks, you must follow those links down and study the material there until it is completely understood before proceeding further.

 

And when you go to http://wiki.secondlife.com/wiki/List you're going to be confronted not only with a lengthy page of explanation regarding lists but a great number of underlined links throughout it. And they should be opened and studied as well as any new links found as you go deeper down the rabbit hole. And, frankly, it may take a week before you surface again. But, it will be a week well spent!

 

I say that because not only do you need a thorough understanding of lists to use llGetPrimitiveParams and llSetPrimitiveParams properly but lists are everywhere in lsl, being the closest we have to the arrays that are offered in more civilized sophisticated programming languages. There's simply no getting away from lists. And reading about them once won't help; you have to learn to manipulate them, access their elements, convert them into other forms, etc. A week spent mastering what lists are about will, in the long run, save months of frustration while you agonize over your own or some other's code trying to pinpoint something.

 

Besides, once you have studied lists, you won't have to again! It's a one time chore that may, at the most, require a little brush up every once in awhile. And, when you first encounter vector, you'll find a short, concise definition of it that shows you how to access the elements within it using the .x, .y and .z suffix notation. And, after a few minutes of study at  http://wiki.secondlife.com/wiki/Vector , everytime you encounter a vector in code, you'll know what that's about.

 

Anyway, there really is no substitution for study and the wiki is written in a way to aid you if you so choose. I encourage you to do so since you seem serious about learning programming and have some great ideas to implement. Stick with it and if something you encounter needs clarification, someone here will be glad to help.

You are about to reply to a thread that has been inactive for 4235 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
×
×
  • Create New...