Maya makes holes in the particle swarm

Source: Internet
Author: User
Tags expression

Maya's particle system, the particle system is different from the other objective, in addition to its macroscopic position change, scaling, rotation, almost impossible as ploy and nurbs, like the details of fine tuning, imagine a more than 100,000 of the particle swarm, to turn it into what it looks like, I think no one can have such patience, fortunately in Maya there are two ways to control the transformation, the first is very commonly used fields (force field) and goal, using fields can transform the particle in the space of the individual position, speed and so on, But to get control of the particle system completely is to use expression + goal. The next thing I'm going to talk about is using this method to gouge out a sphere in each volume particle swarm.

First, let's get some ideas straight.

Distance formula, assuming that there are two objects a,b distributed in three-dimensional space, their space coordinates are a (X1,Y1,Z1), B (X2,Y2,Z2), their distance d relationship is d = [(X1-X2) ^2+ (y1-y2) ^2+ (Z1-Z2) ^2]^ (1/2) (" ^ "for times),

Start Maya, press F4 into Dynamics mode, select particles => particle tools, press resest tools, restore to the initial state, check "Create particle Grid", in work Spaces (top) in the upper right corner of the point, the lower left corner point, which will define the particle's coverage, not too open, unless you have a super fast machine, press the INSERT key, using the mouse M-key in the left,side to ensure that two points are not in the same line (vertical, horizontal), A cube-shaped particle swarm will appear in the Enter,workspace, and our aim is to dig a hole in the middle of him. Create a ball, create a locator, use the constrain =>point function in animation to establish a relationship between ball and locator, we move the locator sphere should be moved, if not get this effect undo, Change ball and locator selection order, select ball, press SHIFT to select particle execution particles => goal Option,uncheck "uns transform as Goal,set goal weight 0.99, press creat. Select the particles into the attributes=>particlesshape1=> conserve = 0,gaol smoothness = 3,nurbssphereshape1 = 0.9. The animation particles will focus on the surface of the sphere, but the result is that the particles inside the sphere are concentrated to the surface of the sphere, while others remain motionless, placing the locator at the center of the particle swarm into the Windows => Animation editors Express Write the following expression:

vector $position = particleShape1.worldPosition;
if(($position.x-nurbsSphere1.translateX)*($position.x-nurbsSphere1.translateX)+($position.y-nurbsSphere1.translateY)*($position.y-nurbsSphere1.translateY)+($position.z-nurbsSphere1.translateZ)* ($position.z-nurbsSphere1.translateZ)<= makeNurbSphere1.radius)
particleShape1.goalPP = 1;
else
particleShape1.goalPP = 0;

Now let me explain the expression above:

Line 1 uses to divide the coordinate data of each particle into 3 ordinary floating-point values (XYZ), $position. x = x, and so on;

Line 2 is a judgment operation, the position of each particle to the ball center is not small and or equal to the radius of the sphere, see formula, of course, also use POW directly to obtain the square value;

Line 3 is so goal for each condition of the particles set up 1 of the role is 100% traction;

Line 4 in addition;

Line 5 Then the effect of 0 on the goal of each condition is that it does not work.

Play the animation to see the particles inside the sphere focused on the surface of the sphere.

Goal achieved.

Finish the tutorial.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.