|
Chicken Rosca
Registered User
Join date: 21 Jun 2007
Posts: 30
|
10-01-2007 23:49
Hi all,
Suppose I have a 128 X 128 texture in Second Life. I divide it into four parts, and I put one fruit picture in each part. For example, I put a picture of an apple on top left, a picture of a banana on top right, a picture of peach on bottom left, and a picture of lemon on bottom right. So each part is 64 X 64. See this if you don't understand:
__________ |____|____| |____|____|
What I try to explain is just like that, although it doesn't look like a square. OK, now it's the time I explain my question.
I have a cube. I want to display one fruit each time. So its texture is always 1/4 of the 128 X 128 texture. And I can choose which fruit picture to display. I want to know how can I do it.
Thanks in advance!
_____________________
I am a chicken that can not fly high...
|
|
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
|
10-02-2007 04:45
You'll be looking to use llSetTexture, and your repeat will be <0.5,0.5,0> and offset of <-0.25,0.25,0> (top left), <0.25,0.25,0> (top right), <-0.25,-0.25,0> (bottom left) and <0.25,-0.25,0> (bottom right).
...I think.
_____________________
www.nandnerd.info http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
10-02-2007 09:52
Looks close enought to me...
|
|
Chicken Rosca
Registered User
Join date: 21 Jun 2007
Posts: 30
|
10-03-2007 19:54
From: nand Nerd You'll be looking to use llSetTexture, and your repeat will be <0.5,0.5,0> and offset of <-0.25,0.25,0> (top left), <0.25,0.25,0> (top right), <-0.25,-0.25,0> (bottom left) and <0.25,-0.25,0> (bottom right).
...I think. Thank you for your answer, but would you mind telling me how you calculated it? I mean, if I have another texture, how can I know the repeat and the offset? Thanks.
_____________________
I am a chicken that can not fly high...
|
|
Larrie Lane
Registered User
Join date: 9 Feb 2007
Posts: 667
|
10-03-2007 20:41
From: Chicken Rosca Thank you for your answer, but would you mind telling me how you calculated it? I mean, if I have another texture, how can I know the repeat and the offset? For the offset figures you have to think of your example as 1 whole picture but in your example in the picture there are 4 equal squares. Firstly if you repeat the picture per face Horizontally or Vertically you will have your whole picture as the option describe repeated, so in simple terms more than 1 picture. Back to the whole picture on the prim, under the texture menu at the bottom are the offset values. so if you use these settings: Horizontal 0.250 that will move your texture a quarter left Horizontal -0.250 this will move it quarter right The same applies to vertical but then it would go up or down. It is very simple mathematics because 0.250 is a quarter of 1 and 1 is your whole picture. 0.500 is a half of 1 so that would move your texture move half way. You would need to know the offset values first so that these could be added to the script. In your case the offset values are simple to work out but more complexed textures would have to be applied to the prim to find their values first and then added to the script. Unless there is an additional script of course that can work out those settings but I do not know of one.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
10-04-2007 07:21
the formula for each cell's offset is... index/base - .5(base-1)/base or the whole vector... gX = # of collumns gY = # of rows
pX = picture(cell) collumn (0 based index) pY = picture(cell) row (0 based index) <pX / gX - (0.5 * (gX-1) / gX), pY / gY - (0.5 * (gY-1) / gY), 0 > and the repeats are always <1/gX, 1/gY, 0.0> using that formula you could even parse a textures name if it had say 2x5 in it... and dynamically set the offsets and repeats CAVEAT: all cells must have the matching widths, and matching heights (height does not have to match width just other heights)
|