If you need to set the position of particles once (in an INIT script for example), use that code:
num_particles = 100
vp = gh_vertex_pool.create(num_particles)
for i=0, num_particles-1 do
local x = ...
local y = ...
local z = ...
gh_vertex_pool.vertex_set_position(vp, i, x, y, z, 1)
end
You can also use gh_vertex_pool.vertex_set_position() in a FRAME script.
If you need to update the position more frequently (FRAME script), you can update the position of particles in GPU memory with GPU mapping:
num_particles = 100
vp = gh_vertex_pool.create(num_particles)
gh_vertex_pool.vb_map(vp)
for i=0, num_particles-1 do
local x = ...
local y = ...
local z = ...
gh_vertex_pool.vb_set_vertex_position(vp, i, x, y, z, 1)
end
gh_vertex_pool.vb_unmap(vp)
Both methods work in an INIT or FRAME script.