We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2023-02-27 12:54 PM
Hello,
I have a simple block using FOR – TO – NEXT to duplicate it, is there a way to add a random texture origin to each duplicated so there is no visible texture repetitions?
Juan.
Solved! Go to Solution.
2023-02-27 06:09 PM
2023-03-07 07:00 AM - edited 2023-03-07 07:17 AM
Try this ...
Just use your surface material.
I have only offset in the 'y' direction.
And maybe turn the 'random origin' off in your surface material (mine is off).
board_width = 0.100
board_gap = 0.010
N1= CEIL(A /(board_width+board_gap))
FOR H=1 TO N1
GOSUB 20
ADDx board_width + board_gap
NEXT H
DEL TOP
END
20:
MATERIAL "Timber_Pine - vertical"
block board_width, B, ZZYZX
texture_origin_y = RND(10)
GOSUB 100
RETURN
100: !!texture mapping
VERT 0,0+texture_origin_y,0 !Origin
VERT 1,0+texture_origin_y,0 !X direction
VERT 0,1+texture_origin_y,0 !Y direction
VERT 0,0+texture_origin_y,1 !Z direction
COOR 2+256,1,2,3,4
body -1
RETURN
Barry.
2023-02-27 01:39 PM
Have you tried using COOR{3} with the origos supplied by the RND() function?
2023-02-27 02:10 PM
Somehow I have tried but I cannot wrap my head around it.
20:
block RimaA, RimaB, B
COOR{3} 2,4,
RND(0),RND(0),RND(0),
2000,2000,2000,
2000,2000,2000,
2000,2000,2000
RETURN
Juan
2023-02-27 06:09 PM
2023-02-27 08:09 PM
You can also use translation with the coor{3}
So you can have it add a random distance each next. That's how I have my wood siding accessory.
2023-02-28 02:35 AM
The format for COOR is like this.
This is what I use to adjust my tile surface in the x and y directions - not random but via a hotspot.
prism_ 5, hob_height,
0,0,15,
0,b,15,
a,b,15,
a,0,15,
0,0,-1!,
VERT 0+tile_fill_origin_x,0+tile_fill_origin_y,0 !Origin
VERT 1+tile_fill_origin_x,0+tile_fill_origin_y,0 !X direction
VERT 0+tile_fill_origin_x,1+tile_fill_origin_y,0 !Y direction
VERT 0+tile_fill_origin_x,0+tile_fill_origin_y,1 !Z direction
COOR 2+256,1,2,3,4
body -1
You will need to swap out the 'tile_fill_origin_x' & 'tile_fill_origin_y' for your randomly generated co-ordinate values, and add in something for z axis if tat is important.
RND(0) will not work.
You must specify an upper random number i.e. RND(10)
That will give you a random number between 0 and 10.
Sorry I never got around to actually sending this reply and I see others have beaten me to it.
I think there is an issue with the RND generator in that it will always give you the same sequence of 'random' numbers if used in a for next loop.
It does produce a 'random' number, but I think it is always the same 'random' number if you use the same seed (the number in brackets).
Barry.
2023-02-28 10:02 AM - edited 2023-02-28 10:02 AM
I think there is an issue with the RND generator in that it will always give you the same sequence of 'random' numbers if used in a for next loop.
It does produce a 'random' number, but I think it is always the same 'random' number if you use the same seed (the number in brackets).
This is intentional, so that successive frames in a fly-through are stable relative to eachother.
The random sequence is different for each instance of the same library part.
You can use something like this to get a random number 1..._rangemax, initialized with a seed that is set from a global variable which changes when you need changes in the sequence:(SYMB_POS_X, GLOB_FRAME_NR, GLOB_ID):
2023-02-28 03:35 PM
not saying you guys are wrong but this confuses me as this is the outcome I get using rnd in my loop.
Maybe I can't see it but even when close the planks do not seem to be the same random number
2023-03-01 05:17 PM
Interesting, but two comments:
GLOB_ID is treated as string, so you can't do mathematical operations (modulo here) on it. So you can't set _seed to GLOB_ID.
Also using rnd() inside a loop will yield different results. However changing the object will indeed not change the individual loop results.
See this example code for the 2D script: "last" is a parameter. If you change it, you will see that the discrete results stay the same, only the overall number of course changes. E.g. if the first result is "9.3781" it will always be the same. But the second row is different random.
for i=1 to last
_r = rnd(10)
text2 0, -i*0.6, _r
next i
Using SYMB_POS_X as a seed is brilliant tho. That works like a charm.
2023-03-06 11:05 AM
I know there is an answer marked as solution, but now that I dig deeper, the less clear this whole thing is.
Why the texture becomes randomly rotated if what I set is the origin of it. Maybe my question wasn't clear enough and I apologize for it.
Let's say I have some planks of a terrace deck created using BLOCK on a FOR-TO-NEXT, now if I assign a texture to that object, there will be an obvious texture tiling, what I'm going after is that each of those planks have the texture origin displaced so the texture tiling is not visible.
This is how the object looks like if I just apply a texture on it (not pretty at all):
Now, what I'm going after is that each plank has its texture moved randomly in X,Y,Z coordinates but keeping the direction so they are not rotated.
Juan.