Professional Documents
Culture Documents
Emitter: check
Timer: check
Particles: check
Particle Control… not yet.
Let’s try to get a little more control on the way in which the particle sprays by controlling the random
distribution.
Drag a new slider and call this rndSpray (for random spray) with domain parameters (0 .0 to 180.0)
Create an input on the VB component called rndSpray and give this a Double hint.
Connect the rndSpray slider to the rndSpray input as such:
Now we want to create a rotation domain of 180 degrees (which would be a range from -90 to 90).
Rnd * 180
We are actually after a domain of (-90 to 90) so we subtract 90 from the random generation.
Rnd * 180 - 90
(in this case we don’t need to block the Rnd*180 as VB processes in a sequential manner) this provides
a domain of (-90 to 90)
As RhinoCommon uses radian rotation (rather than degrees) we need to convert this from our degrees to
radians. We can build a function for this to simplify the code.
degToRad(rndRot)
If we want to produce a randomly distributed start vector, we can use the vector3d.Rotate operation on
the newly creates vec – we can pass the degToRad function for the angle parameter:
vec.Rotate(degToRad(rndRot), Vector3d.ZAxis)
Done. So when we run the particle test, it should now control the random distribution of spray.
Open the VB component and we need to add one more line below the vec.Rotate in order to control the
initial direction.
vec.Rotate(degToRad(dir), Vector3d.ZAxis)
As velocity only relies on distance per second, we should really be referencing the timer values as well as
a distance variable. At this point we can just use a slider to represent a units/second calculation with a
static internal variable representing our timer click - later we will include our one internal timer (based on
Giulio Piacentino’s code) and can more accurately simulate m/s calculations.
Now the script allows for spray distribution and direction. The entire code should now read as follows:
If(run) Then
Dim vec As New Vector3d(1, 0, 0)
vec.Rotate(degToRad(dir), Vector3d.ZAxis)
vec.Rotate(degToRad(rndRot), Vector3d.ZAxis)
vecList.Add(vec)
End Sub
Spatial Modifiers
We can move onto developing our own spatial modifier. Spatial modifiers can be seen as forces that
may affect the particle within the system.
Firstly we’ll look at introducing an attraction node. For this we can use a simple point distance logic
between attraction node centre and particle. Rather than jam two additional inputs into the VB
component, we should start to think about economizing our stream data. Below illustrates a more
intuitive direction in stream management, where a reduction of inputs for each component can clarify the
system’s organizational logic. In further tutorials we will explore writing your own classes in Visual Studio.
VS development allows for the implementation of custom Grasshopper components – a great advantage
of this meant that you can provide default settings for component inputs (meaning that you don’t always
need to plug streams in order for the component to work).
Let’s create a new input to ‘particle engine’ called ‘modifier’ and give it a List Access (remember we are
now going to use the ‘modifier data’ list to obtain the specific modifier variables).
Connect the ‘modifier data’ to the ‘modifier’ input.
Currently there’s no visual feedback for what data the attractor contains. If we are applying a point
distance logic force we could represent this range by including a circle boundary. Using a simple XY / XZ
/ YZ Plane component and circle component it should give some visual cue to how the modifier operates.
Canvas view
As we have the ‘modifier’ data as a list, we can refer to each list item as a specific parameter within the
‘particle engine’
Speed Input
Num per Cycle