PDA

View Full Version : Precise Particle placement


darknight007
10-31-2008, 06:55 PM
Hi everyone. I have a shot where hundreds of particles and land on certain targets. My biggest problem is getting the particles to land on a each target ONCE and never having another particle land in that same position again. I have setup a very simple test scene using find target and lock/bond to get the particles to travel and land on the targets, but the problem is the overlapping issue. There are 3 targets and 3 particles. each particle to a specific target and not one target being left out....lonely target :( The find target operator has simple options like closest pivot, closest surface etc to help guide the targets but not what i'm looking for. I have a feeling script vector/integer could. anyway what do you guys think? I've attached an image, hope it helps.

Bobo
10-31-2008, 07:52 PM
You can use script channels to control the Find Target mesh index and/or position to target.
Just write the data to the Integer and/or Vector channels using a Script Operator and switch FindTarget to use them. You can also provide an absolute world space position via the Script Vector channel if you are not using any mesh targets in the FindTarget.

Obviously, this assumes you know how to write Script Operators...

darknight007
10-31-2008, 07:57 PM
Thank you Bobo. I know very little scripting but am on my journey to learn. I certainly would appreciate some help writing the script for the operator. I had a feeling this would require some code, and I am up for the challenge. If anyone can help me I would really appreciate it. Thanks

Bobo
10-31-2008, 08:23 PM
Thank you Bobo. I know very little scripting but am on my journey to learn. I certainly would appreciate some help writing the script for the operator. I had a feeling this would require some code, and I am up for the challenge. If anyone can help me I would really appreciate it. Thanks

Take a look at the "particleVector Sample Script" topic in the MAXScript reference. It shows how to send all particles to a single vertex of a mesh.

Also see the "particleInteger Sample Script" which shows how to specify the target index from the mesh list of the Find_Target operator using the Integer channel.

This will give you a starting point.
If I find time later today or tomorrow, I might post a real-world example

darknight007
10-31-2008, 08:25 PM
Thank you Bobo! u rock

Bobo
11-01-2008, 06:36 AM
Ok, here are some examples (http://www.scriptspot.com/bobo/max2008/ParticlesToTargets_max2008.zip) of what can be done (Max 2008 files):

v001. The first file shows a simple scene with 5 boxes and one PFlow system. 5 particles are being emitted on frame 5. A Find Target operator sends the 5 particles to the 5 boxes. The targeting is controlled by the Script Integer channel set in the Script Operator where we just grab the ID of the particle (its birth index) and send it to the corresponding target from the Mesh list.

Note that if you have more than 5 particles, all particle IDs will be clamped to the last mesh index, so 6, 7, 8 etc. will all go to box 5!

v002. To avoid this, we can use the MOD function in the Script Operator and send particles to boxes again and again. The expression (1+mod pCont.particleID 5) will send the first particle to box 2, the second to box 3 and so on, while particle 5 will go to box 1. Then particle 6 will go to box 2 again and so on with any number of particles. The number 5 in the Script Operator could be replaced with $Find_Target_01.target_Objects.count to take the number of targets automatically and adapt as you add or remove targets, but that is not really a big deal.

Note that all particles go to the SURFACE of the boxes, not to their pivot points, because Mesh Targets generally use a Random Point or the Closest Point on surface.

v003. To avoid this, we can enable the Point: By Script Vector option and provide a point in OBJECT SPACE of the target mesh to target. Since the value [0,0,0] means the Pivot Point in object space (assuming the pivot has not been offset), we just write [0,0,0] into the Vector channel and all particles will go to the base of the boxes' meshes.

Note that the Pivot Point of a box is at the base, not in the center!

v004. To target the center, we can switch to WORLD space and provide absolute target positions with our Script Operator. To do this, we just switch the Find Target to ICON mode, while keeping the 5 boxes on the list. In the Script Operator, we feed the .center property of each box taken from the list of the Find Target into the particleVector channel of each particle and our particles fly to the centers of the boxes. This will automatically take care of any animation of the targets since our Script Operator is constantly updating the target values (try animating the boxes to see), but to get it updating correctly when rendering, we have to specify the correct evaluation time as AT TIME context, otherwise .center would be taken from the first rendered frame.

v005. An alternative method would be to use both the Integer and Vector channels to provide a center in object space. In this simple case, we know the boxes have a size of 50x50x50 units, so we just provide a value of [0,0,25] to target the center instead of the base. We enable the MESH mode of the Find Target and tell each particle which box to use and where in that box to go. If we rotate a box, the point is in object space so the center is still correct even after object-level transformations...

v006. We can of course target ANY point in object space, so in this file I took the first vertex of the object's mesh and dumped it into the particleVector channel. Since we are still working in object space, it is transformed correctly by the box' node and PFlow gets the right world space point to fly to, even if the box is animated. This might not take animated mesh deformations into account though, but using world space coordinates would help in that respect.

v007. Once again we switch the Find Target to ICON mode to avoid the internal object to world space conversion, and in the Script Operator use snapshotAsMesh instead of .mesh to access the world space state of the geometry. We also have to provide a time context based on the operator's current time, otherwise it would work in the viewport but not in the renderer! We read the 6th vertex and dump its current position into the particleVector channel. Then we delete the value. This will take into account even Space Warps as snapshotAsMesh gets the mesh on top of the stack after all OSMs, transforms and WSMs.

This covers most of what you need to know about targeting points on meshes with PFlow Find Target and Script Operators.

darknight007
11-01-2008, 06:43 PM
Bobo you are a master and a teacher. i will study the examples and break them down. I think this will definitely work and I can proceed with the shot and more importantly I can overcome this limit in the future. Many thanks and truly appreciated !!

darknight007
11-06-2008, 02:33 PM
an example

CGTalk Moderation
11-06-2008, 02:33 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.