Use a simple script to achieve powder pile | Maya nParticle简单脚本实现粒子堆叠


Youtube

Maya nParticle only calculates friction/stickness between particles and rigid bodies, not friction is encountered between particles. My guess is the algorithm complexity is too high. Anyway there is two relative easy ways to fake the effect, according to my searching.

想要用一个一包糖粒堆在物体(对又是它..)上的片段,发现Maya的nParticle只计算粒子和Rigid body的摩擦力不计算粒子和粒子间的摩擦力(想来是算法复杂度太高了),所以不管怎么搞最终都会摊成大烧饼,并且还会不停的抽搐.. 查了下大概有两个相对简单的方法

1. hold particles with a invisible rigid body. 2. Use RealFlow, which seems to have much more handy control over particles

I’m not happy with either. 1 is lame. 2 too much trouble, have to get hang of another environment. If I must do scripting, I choose to learn mel.

So the algorithm is:

It’s unlikely to mess with friction as I guessed above. I tried to modify per particle mass to let them stuck in the space. Yea that works but they tend to be headbutted by other particles and flying around.. for science. Later I googled out it’s possible to control force field per particle, with attribute named “Field name”_”option name”. That is to say adding attribute “gravityField1_magnitude” to nParticle2 will grant you control over per particle gravity from the field.

On creation:

[php]
global int $freezeCap=5; //be completely frozen after the cap rounds
global int $gravityPP=500;
global float $dragPP=100;
global float $accelerationTrigger=15; //the speed parameter to trigger ‘I’m free again!", which leads to free droping.
global int $n[100000]; //how many times have the particle been locked
global int $preVel[100000]; //velocity of last frame
global int $locked[100000];

nParticleShape4.dragField1_magnitude=0;
nParticleShape4.gravityField1_magnitude=$gravityPP;

global int $init=1;
if($init==1) {
int $i;
for($i=0;$i<100000;$i++) {
$n[$i]=0;
$locked[$i]=0;
}
$init=0;
}
[/php]

Before dynamics:
[php]
int $id=nParticleShape4.particleId;
float $vel=abs(nParticleShape4.velocity);

//print("nParticleShape2.velocity "+$nParticleShape2.velocity+"\n");

if($vel>$preVel[$id]+$accelerationTrigger) {
$n[$id]=0;
nParticleShape4.dragField1_magnitude=0; //If it’s free again, unlock and erase record
}
else {
$freezeFact=$n[$id]/$freezeCap; //progress bar of locking
if($freezeFact>1)
$freezeFact=1;
$n[$id]+=1;
nParticleShape4.dragField1_magnitude=$freezeFact*$dragPP; //increase drag force depending on locking level
nParticleShape4.gravityField1_magnitude=$gravityPP*(1-$freezeFact)*(1-$freezeFact); //parabola is better according to experiment
nParticleShape4.velocity=<<0,0,0>>;
}

$preVel[$id]=nParticleShape4.velocity;
[/php]

The script is not bad to me.. adjustable parameters are handy. Time efficiency is acceptable (as a former ACMer, I can confirm this is O(n), can’t be better). 20 million particles * 100 frames cost my i7 half an hour. Not perfect but enough for bragging.
1. 弄个透明的动画的rigid body来把粒子圈起来。 2. 用RealFlow,我只用RealFlow模拟水,但是显然那它对粒子的控制比Maya厉害得多。

两个方法我都不高兴,1太不屌爆,2太麻烦,要做很多熟悉另一个环境的工作,且要写脚本,所以不如来学下mel。下了本书叫Maya Python — for Games and Film,翻了一百页发现Python在Maya上基本是庞大的workflow中工程师为了其他人方便写的maya程序,并且也要有mel基础,不是我要的。

总之,思路是:

想要计算摩擦力显然是不现实的,说过了。我先通过改质量的途径让粒子满足条件时失去质量以停在原地不受重力影响,停是能停住但是会被别的particle撞飞.. 非常科学。后来查到可以使用 <力场名>_<属性名> 的方式控制Per Particle的行为,即,给nParticle2添加名为gravityField1_magnitude的attribute程序就会使用它来控制它受到重力场1的magnitude。然后通过DragField让particle稳定。我在注释里详细说。

粒子生成时脚本:

[php]
global int $freezeCap=5; //be completely frozen after the cap rounds
global int $gravityPP=500;
global float $dragPP=100;
global float $accelerationTrigger=15; //the speed parameter to trigger ‘I’m free again!", which leads to free droping.
global int $n[100000]; //how many times have the particle been locked
global int $preVel[100000]; //velocity of last frame
global int $locked[100000];

nParticleShape4.dragField1_magnitude=0;
nParticleShape4.gravityField1_magnitude=$gravityPP;

global int $init=1;
if($init==1) {
int $i;
for($i=0;$i<100000;$i++) {
$n[$i]=0;
$locked[$i]=0;
}
$init=0;
}
[/php]

动态前的脚本:

[php]
int $id=nParticleShape4.particleId;
float $vel=abs(nParticleShape4.velocity);

//print("nParticleShape2.velocity "+$nParticleShape2.velocity+"\n");

if($vel>$preVel[$id]+$accelerationTrigger) {
$n[$id]=0;
nParticleShape4.dragField1_magnitude=0; //If it’s free again, unlock and erase record
}
else {
$freezeFact=$n[$id]/$freezeCap; //progress bar of locking
if($freezeFact>1)
$freezeFact=1;
$n[$id]+=1;
nParticleShape4.dragField1_magnitude=$freezeFact*$dragPP; //increase drag force depending on locking level
nParticleShape4.gravityField1_magnitude=$gravityPP*(1-$freezeFact)*(1-$freezeFact); //parabola is better according to experiment
nParticleShape4.velocity=<<0,0,0>>;
}

$preVel[$id]=nParticleShape4.velocity;
[/php]

个人感觉这个还不错,有很多参数可以控制,效率也还行(前ACMer表示这个就是O(n)..不能再低了),200万粒子100帧i7跑半个小时。显然不完美,蒙人没问题。

7,383 thoughts on “Use a simple script to achieve powder pile | Maya nParticle简单脚本实现粒子堆叠

  1. situs dewasa

    We are a group of volunteers and starting a new scheme
    in our community. Your web site offered us with valuable info to work on. You’ve
    done an impressive job and our whole community will be grateful
    to you.

    Reply
  2. Adriene

    Toller Beitrag. Eine Menge konkrete Hinweise.
    Vielen Dank für den Beitrag. Ich komme bestimmt wieder
    vorbei.
    Du hast recht – die Sache der Raumgestaltung wird oft herausfordernd.
    Endlich mal Klartext.
    Aufrichtig nützlich. Ich war schon nach ähnlichen Tipps lange gesucht.
    Danke!

    Also visit my site – Adriene

    Reply
  3. pepek gratis

    I know this website gives quality dependent articles and additional data, is there
    any other web page which offers these things in quality?

    Reply
  4. interior jakarta

    wonderful put up, very informative. I’m wondering why the other specialists of this sector don’t understand this.

    You must continue your writing. I’m sure, you’ve a huge readers’ base already!

    Reply
  5. bangun rumah jogja

    I feel that is one of the so much vital info for me. And i’m happy
    reading your article. However want to remark on some common issues, The web site
    taste is ideal, the articles is really great : D.
    Good process, cheers

    Reply
  6. 백링크

    When I originally commented I clicked the “Notify me when new comments are added” checkbox
    and now each time a comment is added I get several
    e-mails with the same comment. Is there any way you can remove people from that service?
    Bless you!

    Reply
  7. og真人视讯

    I know this if off topic but I’m looking into
    starting my own blog and was wondering what all is required to get setup?
    I’m assuming having a blog like yours would
    cost a pretty penny? I’m not very internet smart so I’m not 100% certain. Any tips or advice would be greatly appreciated.
    Many thanks

    Reply
  8. Syreeta

    Naprawdę dobry artykuł. Wiele wartościowych inspiracji.
    Super że dzielisz się wiedzą. Na pewno tu wrócę.
    Trafnie napisane – sprawa doboru mebli bywa wymagająca.
    Dobrze, że ktoś to wyjaśnia.
    Szczerze inspirujące. Szukałem czegoś takiego już jakiś czas.
    Pozdrawiam!

    Also visit my site – Syreeta

    Reply
  9. Bev

    Rzeczowy artykuł. Mnóstwo przydatnych informacji.

    Dziękuję za podzielenie się. Czekam na więcej.

    Masz rację – kwestia urządzania wnętrz bywa wymagająca.
    Przydatne podejście.
    Bardzo przydatne. Szukałem czegoś takiego właśnie tego.
    Super robota!

    Here is my web site … Bev

    Reply
  10. ib maths tuitions in bangalore

    OMT’s holistic strategy supports not јust skills yet pleasure іn mathematics, motivating pupils tօ accept thе subject and radiate in tһeir exams.

    Join our small-grouρ on-site classes in Singapore foг tailored guidance іn a nurturing environment thаt constructs strong fundamental
    math skills.

    Ꮲrovided that mathematics plays an essential role іn Singapore’s economic advancement and
    progress, purchasing specialized math tuition equips trainees ԝith thе analytical skills needed to
    grow іn a competitive landscape.

    With PSLE math concerns օften including real-w᧐rld applications, tuition supplies targeted practice tо develop critical thinking abilities vital
    fоr һigh scores.

    Structure confidence ᴠia regular tuition support is essential, as Օ Levels can be difficult, ɑnd сertain trainees
    perform ƅetter under pressure.

    Planning fоr tһe unpredictability of A Level questions, tuition establishes adaptive analytical techniques
    fߋr real-tіmе test circumstances.

    Eventually, OMT’ѕ unique proprietary curriculum matches tһe Singapore MOE educational program ƅy fostering independent thinkers
    outfitted for lifelong mathematical success.

    OMT’ѕe-learning reduces mathematics anxiousness lor, maкing you a lοt more positive
    аnd causing hiɡher examination marks.

    Singapore’s meritocratic sʏstem rewards һigh achievers, makіng math tuition a strategic investment fоr examination prominence.

    Feel free tߋ visit mу website – ib maths tuitions in bangalore

    Reply
  11. CSCE

    As a trusted search engine optimization service supplier, Oxygen tailors its methods to fulfill your business’s wants.
    We provide SEO web advertising and marketing services that combine seamlessly into your overall advertising strategy.
    Research exhibits corporations utilizing SEO can count on a 14.6% close fee for inbound leads.
    Our dedicated workforce utilizes this knowledge-driven method
    to craft solutions that enhance your search rankings and enhance
    conversions. As a trusted search engine optimization service supplier, Oxygen tailors its methods to fulfill your business’s needs.
    We provide SEO web advertising providers that combine seamlessly into your total marketing strategy.
    Research reveals corporations utilizing SEO can anticipate a 14.6% close fee for inbound leads.
    Our devoted workforce makes use of this information-driven method to craft solutions that improve your search rankings and enhance conversions.
    Understanding what an SEO service supplier is is essential for achievement.
    At Oxygen, we not solely outline it but in addition exemplify it.

    We are amongst the perfect SEO optimization companies,
    offering a spread of providers from SEO website optimization to SEO
    promotion services.

    Reply
  12. SITUS BODONG

    Hello there, You’ve done a great job. I will definitely digg it and personally suggest
    to my friends. I’m confident they will be benefited from this website.

    Reply
  13. Terastal Fest ex

    I have to thank you for the efforts you’ve put in penning this website.
    I’m hoping to see the same high-grade content by you in the future as well.
    In fact, your creative writing abilities has
    motivated me to get my very own website now 😉

    Reply
  14. VSTAR Universe

    Pretty great post. I just stumbled upon your weblog and wanted to say
    that I have really loved browsing your weblog posts. In any case I’ll be subscribing for your feed and
    I am hoping you write once more soon!

    Reply
  15. 1Gmoli.com

    Excellent way of telling, and fastidious piece of writing
    to obtain data on the topic of my presentation focus,
    which i am going to deliver in academy.

    Reply
  16. No deposit bonus casinos

    Hey there, I think your website might be having browser compatibility issues.
    When I look at your blog in Chrome, it looks fine but when opening in Internet Explorer, it
    has some overlapping. I just wanted to give you
    a quick heads up! Other then that, amazing blog!

    Reply
  17. Ronny

    Pretty nice post. I just stumbled upon your blog and wished to
    say that I’ve really enjoyed surfing around your blog posts.

    In any case I’ll be subscribing to your feed and I hope you write again very soon!

    Reply
  18. Kandi

    Świetny artykuł. Dużo przydatnych inspiracji. Dzięki za
    ten materiał. Na pewno tu wrócę.
    Trafnie napisane – sprawa wystroju bywa wymagająca.
    Przydatne podejście.
    Szczerze pomocne. Szukałam takich informacji od dawna.
    Super robota!

    Feel free to surf to my web-site … Kandi

    Reply
  19. Star Birth

    I’m impressed, I have to admit. Rarely do I come across a blog that’s equally educative and interesting,
    and let me tell you, you’ve hit the nail on the head.
    The issue is something that too few people are speaking intelligently about.
    I’m very happy that I found this during my hunt for something relating
    to this.

    Reply
  20. найти БДСМ партнера екатеринбург

    Для знакомства «знакомства для
    взрослых в Твери» полезно указать свои интересы для новых впечатлений.
    После выбора анкеты отправьте ненавязчивое приглашение к разговору,
    а дальше общайтесь бережно и без неловкости.

    понятная анкета помогает быстрее перейти к содержательному разговору.

    Перед личной встречей оставляйте собеседнику пространство
    для спокойного ответа. Используйте поиск
    по интересам: структура сайта делает первый шаг проще и понятнее.
    После просмотра профиля начните разговор без сложных формальностей и
    продолжайте разговор комфортно и осознанно.
    добавьте фотографию и краткое описание, если тема
    «знакомства для взрослых в
    Твери» подходит вам для новых впечатлений.

    найти БДСМ партнера екатеринбург

    Reply
  21. Arron

    OMT’sself-paced e-learning systеm permits students tߋ explore mathematics
    at tһeir οwn rhythm, transforming strrss іnto fascination and motivating excellent exam efficiency.

    Experience versatile knowing anytime, ɑnywhere througһ OMT’s tһorough online e-learning platform, including unrestricted access tо video lessons and interactive quizzes.

    Іn Singapore’ѕ extensive education syѕtem, where mathematics іs compulsory and tаkes іn aroᥙnd 1600 hours of curriculum time in primary ɑnd secondary schools,
    math tuition ƅecomes impoгtant to hеlp trainees build а strong foundation fоr
    lifelong success.

    Tuition in primary math is crucial fоr PSLE preparation, аs it presents sophisticated strategies fօr handling non-routine problems thɑt stump many prospects.

    Secondary school math tuition іѕ crucial foг O Levels as
    іt enhancess mastery of algebraic control, а core component tһat regularly ѕhows up in examination concerns.

    Tuition іn junior college math furnishes trainees
    ԝith analytical techniques and likelihood models neсessary fоr analyzing data-driven concerns
    in A Level documents.

    What mаkes OMT stick оut is its tailored syllabus tһаt straightens with MOE ѡhile
    incorporating АI-driven adaptive understanding to fit
    private requirements.

    Ӏn-depth solutions supplied on tһe internet leh, teaching уoս hⲟw to solve issues properly fⲟr far Ьetter qualities.

    Singapore parents invest іn math tuition to ensure theіr children meet the high assumptions оf thе education ѕystem
    fоr exam success.

    Ѕtop by my page … secondary maths tuition centre east (Arron)

    Reply
  22. kasyno online

    While this issue can vexed most people, my thought is that there has to be a middle or common ground that we all can find. I do value that you’ve added pertinent and sound commentary here though. Thank you!

    Reply
  23. Best online casino

    Hello, i think that i saw you visited my website thus i came to “return the favor”.I
    am attempting to find things to improve my web site!I suppose its ok to
    use some of your ideas!!

    Reply
  24. link slot mudah login

    Howdy! This is my first visit to your blog! We are a group
    of volunteers and starting a new initiative in a community in the same niche.
    Your blog provided us beneficial information to work on.
    You have done a wonderful job!

    Reply
  25. Augustus

    Hallo, ich habe nach Informationen zum Einrichten gesucht und ich möchte sagen, dass das Thema hervorragend beschrieben ist. Ich gestalte gerade mein Zuhause neu zu gestalten und jeder Ratschlag hilft mir weiter. Grüße an die Forengemeinde.
    Gutes Thema. Meiner Meinung nach die Raumgestaltung eine enorme Rolle spielt. Gut Ding will Weile haben.

    Reply
  26. ship

    Rules 3, 4, 5, and 6 cover the most important principles in the punctuation of ordinary sentences;
    they should be so thoroughly mastered that their application becomes
    second nature. 7. A participial phrase at the beginning
    of a sentence must refer to the grammatical subject.
    Walking slowly down the road, he saw a woman accompanied by two
    children. The word walking refers to the subject of the sentence, not to the woman. He saw a woman accompanied by two children, walking slowly
    down the road. Participial phrases preceded by a conjunction or by a preposition, nouns in apposition, adjectives, and adjective phrases come under the same rule if they begin the sentence.
    Sentences violating this rule are often ludicrous. Being
    in a dilapidated condition, I was able to buy the house very cheap.

    Wondering irresolutely what to do next, the clock struck
    twelve. 8. Make the paragraph the unit of composition: one paragraph to each topic.

    If the subject on which you are writing is of slight extent, or if you intend to treat it very briefly, there may be no need of subdividing it into topics.

    Reply
  27. slot depo 5k

    This is very interesting, You are a very skilled blogger.

    I have joined your rss feed and look forward to
    seeking more of your magnificent post. Also, I have shared your site in my social networks!

    Reply
  28. HORSE GELATIN TRICK FOR MEN

    I believe what you published was very logical.
    But, what about this? what if you added a little information? I ain’t suggesting your information is not solid, but suppose you
    added a title that grabbed a person’s attention? I
    mean Use a simple script to achieve powder pile | Maya nParticle简单脚本实现粒子堆叠 | Asher.GG is a
    little boring. You might look at Yahoo’s front page and note how
    they write post titles to grab viewers interested.
    You might add a video or a picture or two to
    grab readers excited about what you’ve got to say.
    In my opinion, it might make your blog a little livelier.

    Reply
  29. Trendytech.pl

    Hej, natknąłem się na ten temat i muszę przyznać, że temat jest świetnie opisany. Sam właśnie teraz urządzam mieszkanie i takie porady bardzo się przydają. Miłego dnia wszystkim.
    Dobry temat. Z mojego doświadczenia dobór mebli naprawdę robi różnicę. Warto poświęcić temu czas.

    Reply
  30. ea88 com

    Terrific work! That is the type of information that are meant to be shared
    around the web. Shame on the seek engines for no longer positioning this post upper!
    Come on over and talk over with my site . Thank you =)

    Reply
  31. go8

    A person necessarily help to make severely posts I’d state.

    That is the very first time I frequented your web page and up
    to now? I surprised with the research you made to make this particular put up incredible.
    Fantastic activity!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *