Jump to content
Sign in to follow this  
Guest

Move a color rectangle on a box prim

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

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

Recommended Posts

I am looking on pointers on how I could achieve the following

On a single box shaped prim I want to be able to color specific parts of that prim when a event occurs. I am struggling with identifying the function that would take in X Y coordinates of the prim and  set the color to the one I want.

I am looking to avoid an option of creating smaller rectangle shaped prims and linking them all together because the prim count will be too large and unmanageable

Any pointers on how I could do this

Share this post


Link to post
Share on other sites

You can only colour a complete face of a prim if you're using the color property. The alternatives I see are:

  • different prims (you already discarted that)
  • different textures with different colour combinations (or one with different sets of colour combinations that you move around on the prim - but again: one texture per face at a time)
  • if you used shared media, you could use different web based means to change the colouring of the triangle

Share this post


Link to post
Share on other sites

Shared media still won't be seen by people using V1 viewers, at least for a while, so I'd opt for Darkie's second choice. Make up a set of textures that have rectangular subareas colored differently on each. Then swap them on the display face of your prim as necessary.  To minimize rezz time, you can store all textures on other prim faces in your linkset and color them black so they are effectively hidden.  A person within sight range of the linkset will thus preload all textures and will only see the one currently on the display face.

Share this post


Link to post
Share on other sites

Thanks for the reply, I like to know a little more about the texture option. Here is what I am trying to achieve . I am creating a calendar where when a user  put in an activity (say using the chat channel) example Monday 10:00 - 11:00 Meeting . On the calendar I want to put a color block from 10:00 11:00 MOnday. I decided that I would  Creat and image for the calendar that overlay a transparent prim that could set different colors or textures. What functions should I be looking at?

Share this post


Link to post
Share on other sites

You may want to rethink your design,  It would take an enormous number of textures or several highly complex textures that are moved around to cover all combinations of 1 hour blocks in a 30 day month. Using a few more prims,may be worth while.  For example you could break it down into 1 day on a prim and using xyzzy to block out certain hours on each day.   xyzzy  would give you 10 blocks per day.

 

http://wiki.secondlife.com/wiki/XyzzyText

 

- Clarke

 

 

Share this post


Link to post
Share on other sites

I think the solution is to use llDetectedTouchST to detect where on the prim's face you've touched it and then use llSetLinkPrimitiveParamsFast to move a small child prim to that position to highlight it.

You'd need to figure out a formula to tell the child prim where to go so it centres itself on the box you've touched rather than the actual position, of course.  I'm not very good at calculating that sort of thing, and I'm too tired to try to figure it out (the details would depend on how you're dividing the texture up anyway), but maybe someone else could assist there.   

But I think llDetectedTouchST and llSetLinkPrimitiveParamsFast are, between them, going to hold the key to your problem.

Share this post


Link to post
Share on other sites

Not a bad idea, but why not use llDetectedTouchPos, which would give you the position in region coordinates exactly and then just use either llSetPos or llSetLinkPrimitiveParamsFast ([PRIM_POSITION])?  You'd have to make the appropriate adjustments to local position coordinates and, as you say, adjust to the middle of the square instead of the touched spot. 

Share this post


Link to post
Share on other sites

I have used the following to let certain letters appear on a box. It has one texture with all letters on it divided in rows and columns. Perhaps you can use the same principle for your colored rectangle make a texture with your somewhere in the middle.


Suppose you have one texture with the letters of the alphabet on it, divided in seven rows of four letters. Like this:

A B C D
E F G H
I J K L
M N O P
Q R S T
U V W X
Y Z , .

When you want to show just one letter of the alphabet onto the sides of a prim, you will have to do some math to calculate the offsets you need.
The function i like to share has an index as input. This index is (in this case) the number of the letter of the alphabet you like to share. So when you want to share the "A" the index is 1.
So the first row is indexed by 1..4, the second row by 5..8, and so on.
It will work for any horizontal and vertical division set by the variables HOR and VER.

integer HOR = 4;
integer VER = 7;
showLetter(integer index) { // index out of [1,28] in this case
       llScaleTexture(1.0/HOR,1.0/VER,ALL_SIDES);
       integer xN = (index-1) % HOR;
       integer yN = (index-1) / HOR;
       float xOffset = -0.5 + 0.5/HOR + (float) xN / (float) HOR;
       float yOffset = 0.5 -0.5/VER - (float) yN / (float) VER;
       llOffsetTexture(xOffset, yOffset,ALL_SIDES);
And to get the a location on a grid at the texture (like above 4 columns, 7 rows) where someone touched the texture I use the following function:

integer cell(vector pos, list xyDimension) {
   integer divsX=llList2Integer(xyDimension,0);
   integer divsY=llList2Integer(xyDimension,1);
   return llFloor(pos.x * divsX) + divsX * llFloor((1-pos.y) * divsY) + 1;
like:
   touch_start(integer num) {
       vector pos = llDetectedTouchST(0);
       integer numberOnGrid = cell(pos,[4,3]);
llSay(0, "position"+ (string) numberOnGrid + "touched.");
}

Share this post


Link to post
Share on other sites

I had llDetectedTouchST on the brain because I'd been using it for something.   You're right, of course; llDetectedTouchPos would give you the region position exactly.    

Though, come to think of it, I've got a feeling llDetectedTouchST might be useful, too, when you're trying to figure out which cell was touched, so you know how  to centre the child prim.  

A friend of mine made something like this that he showed me recently -- if I can find him, I'll ask him how he centered the child prim.

Share this post


Link to post
Share on other sites

Hello all,

Ihave got it to the point where I know which cell I have to place the child prim but I am struggling with finding the center of that cell. 

Here is what I did

for my purposed I need to calendar only for 5 days and divided into 24 segments/day that is half hour blocks.

I was able to create a grid with 5 columns and 24 rows. I can even get the cell number I clicked on. Now to exactly center the prim I decided that I would determine the region coordinates of the lower left corner of that prim( here is where I am having trouble) and then add offsets to it which is predetermined and stored in a list.

I am not able to get the region coordinate of the lower left hand corner of my prim. How would I do it?

Is this the best way to do what I am trying to achieve?

Share this post


Link to post
Share on other sites


meghana Engineer wrote:

Hello all,

Ihave got it to the point where I know which cell I have to place the child prim but I am struggling with finding the center of that cell. 

Here is what I did

for my purposed I need to calendar only for 5 days and divided into 24 segments/day that is half hour blocks.

I was able to create a grid with 5 columns and 24 rows. I can even get the cell number I clicked on. Now to exactly center the prim I decided that I would determine the region coordinates of the lower left corner of that prim( here is where I am having trouble) and then add offsets to it which is predetermined and stored in a list.

I am not able to get the region coordinate of the lower left hand corner of my prim. How would I do it?

Is this the best way to do what I am trying to achieve?

You can always get the position vector for a spot you toch by asking for llDetectedTouchPos.  That's easy. When I want to know whether someone has clicked within a square area on a prim, though, I just ask

vector Pos = llDetectedTouchST(0);

if (Pos.x > 0.2 && Pos.x < 0.3 && Pos.y > 0.0 && Pos.y < 0.2) // User has touched somewhere in a box bounded by <0.2,0.0> and <0.3,0.2>

Share this post


Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 3293 days.

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...