This is going to be a very short post experimenting with Random Node and Mask List Node.
RANDOM NODE
This Random node is very simple. It generates and spits out random number, floating value between 0-1.
The node actually has 2 inputs: Count and Seed.
- Count is HOW MANY random number(s) we want to generate as LIST
- Seed is somewhat not showing here, but Seed is important to ensure we can get a controlled/same Random sequence each time, depending on the Seed number. Go and Google Search about about Pseudo-Random and Seed. This is very common in programming and computer graphics. For us, all we need to know is that Seed has effect on our Random. Without Seed, we will always get random LIST of values each time node get updated. If we have Seed, we still get random value, but the random value will not change, unless we adjust the Seed.
When in doubt, we can always use Sverchok Viewer Text node to see the DATA we have generated.
Random.output => ViewerText.edg_pol
In our case, we are expecting a single numeric data (green colour) which we can pass into the ViewerText.edg_pol (input). By default it should create a single random number.
vertices:
None
edges:
(1) object(s)
=0= (1)
0.4588973738056037
matrixes:
None
We can have more by increasing the Count number. If we want LIST of 20 random numbers (between 0 and 1), we can just specify 20 => Count, or just adjust the parameter.
vertices:
None
polygons:
(1) object(s)
=0= (20)
0.3452710857877821
0.1959251996927931
0.616749101637486
0.9718642739239581
0.9664688406408067
0.3798277525541313
0.0980924549260125
0.5251572051427283
0.0538339051067017
0.4373704267856366
0.6565082575113961
0.7860850484911037
0.9472031123834527
0.0486644372599713
0.6069508394335287
0.5390751579694629
0.7691046984194654
0.6443680458225259
0.1883957504224623
0.1218586068312288
matrixes:
None
This simple node can be very robust in application.
Let say, those floating value number is not really useful for our usage, sometimes we really want simple round random numbers. Maybe you want:
- LIST of Random values between 0 and 50
- LIST of Random values between 5 and 25
EXAMPLE: LIST of Random values between 0 and 50
This is quite easy, we just multiply the random floating values we generated. If we normally get random floating value between 0 and 1, if we multiply the resulting values with 50, we will get random floating value between 0 and 50.
vertices:
None
polygons:
(1) object(s)
=0= (50)
12.37700385173664
46.345988218807264
8.91381413129011
42.96122140236859
8.080274648870304
45.83639547665967
12.748138902331926
34.26018287670364
38.4480903596117
34.41608517012092
31.51107933320289
19.833197259096817
18.169666461583645
33.06442162814089
1.2023448738040752
8.44917385697978
26.91009535784073
41.37562067226905
.... and so on.
However the LIST of values here is FLOATING VALUES between 0 and 50. We want round values, so we can use Float-2-Int Sverchok Node.
vertices:
None
polygons:
(1) object(s)
=0= (50)
47
34
30
46
29
32
49
15
0
10
14
31
31
0
35
11
6
... and so on.
EXAMPLE: LIST of Random values between 5 and 25
Now, this may seems a bit complicated, but it is just Math Remapping Value formula converted into Sverchok nodes.
Here, the problem is instead of generating list of numbers between 0 and 1 (default), we specifically ask for MIN and MAX number for the Random LIST generated.
There is Math formula for that, I found from here:
http://stackoverflow.com/questions/1969240/mapping-a-range-of-values-to-another
This is the solution in Python:
def translate(value, leftMin, leftMax, rightMin, rightMax):
# Figure out how 'wide' each range is
leftSpan = leftMax - leftMin
rightSpan = rightMax - rightMin
# Convert the left range into a 0-1 range (float)
valueScaled = float(value - leftMin) / float(leftSpan)
# Convert the 0-1 range into a value in the right range.
return rightMin + (valueScaled * rightSpan)
Our case is much simpler, our Original MIN and MAX is already a range between 0 and 1. All we need to do is to REMAP the RANGE into the NEW MIN and NEW MAX, which is in our case 5 and 25.
vertices:
None
polygons:
(1) object(s)
=0= (50)
19
14
11
7
12
21
21
17
8
22
6
8
6
5
6
17
13
23
21
22
Next, we will use this Random Node to randomly deleting edges of mesh.
EXAMPLE: Random Delete Edges
To randomly deleting edges of a mesh, we can use Sverchok Node Tree like below:
(Thanks to NIKITRON and LINUSY at Blender Artist Forum for this solution.)
Above, we basically get the input mesh (Grid) and pass it on to this Sverchok Node-Tree that simply deleting some edges and output the result. Very simple.
Remember in previous post how I talk about DATA inside Mesh, which is basically a collection DATA that consist of DATA for Vertices, Edges, and Polygon? If we are to randomly deleting EDGES, we simply need to modify the Edges DATA and pass it back as output.
We can use Sverchok LIST MASK node to help us with this task.
Imagine if we have LIST of total of 10 Edges. With LIST MASK, we can tell Sverchok to mask some edges. When Edge DATA in the list is masked, it will be hidden when the data is pass on as input.
Edge DATA like below:
(0, 1)
(1, 2)
(2, 3)
(3, 4)
(4, 5)
(5, 6)
(6, 7)
(7, 8)
(8, 9)
(10, 11)
Using the LIST MASK node, we can mask it using LIST of True (1) or False (0) values.
0 => (0, 1) => HIDDEN
1 => (1, 2)
1 => (2, 3)
0 => (3, 4) => HIDDEN
0 => (4, 5) => HIDDEN
0 => (5, 6) => HIDDEN
1 => (6, 7)
0 => (7, 8) => HIDDEN
1 => (8, 9)
0 => (10, 11) => HIDDEN
If we then pass the new Edge DATA, of course we are basically DELETE-ing the hidden edges.
So, let's recreate this setup step by step using Sverchok node.
STEP 001 - Get Input Object
I have my object, which is Blender default Grid mesh, it has 100 Vertices and 180 Edges.
STEP 002 - Random List of 0 or 1 (False or True)
Next, we want to create Random List + List Mask. We know that we will be dealing with total number of 180 Edges, we can supply that value into Random node. What's happening here is I am trying to adjust the Random value range so that when converted, I will be getting value that is either 0 or 1. Not between 0 and 1, but exactly either 0 or 1. 0 = False and 1 = True.
vertices:
None
data:(1) object(s)
=0= (180)
0
0
0
0
1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
0
1
STEP 003 - Use Mask List
Next, simply use the MASK LIST which takes 2 inputs: Data and Mask.
- We have our Data, which is DATA that makes 180 Edges.
- For the Mask, we simply supply DATA list that is either 0 or 1, randomly.
Any DATA index that is masked will not be passed, which means that particular edge will be deleted.
IMPORTANT: Our MASK LIST Level Lists needs to be set to 2, because our Edges original data is an array pair of 2 numbers.
STEP 004 - Bake Final Mesh
BACK TO SPIDER WEB (WIP)
Now, for our SPIDER WEB...
I am testing it on Blender default Cone. Of course this will be better if we actually create our own procedural webbing, in which we can separate RING EDGES and EDGE LOOPS. We only want to randomly delete Ring Edges.
This also kind of resembles bullet holes and cracks too actually. Or some kind of ancient maze.
Post a Comment