CGTalk > Software > Autodesk Maya > Maya Dynamics
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 08-30-2013, 04:18 PM   #1
jhealyvfx
Scout
portfolio
Jason Healy
Freelance Artist
Columbus, United%2BStates
 
Join Date: Jul 2011
Posts: 26
Integer not Adding up

I have been messing with this runtime code for a while now so I am hoping someone here can help figure this out with me.

I am running a particle simulation that uses a goal of "1" and jumps from one curve to the next to write out a word in particles. I am trying to use this set of code in order to process the iterations. However, right now I have to key the goals on and off when the goalU hits 1.

What I want to do is automatically switch the goal Active off or on given what letter it should be on. However every time the total is processed to 1 it resets to 0 when it should add 1 to its total. It will only be 1 for the one frame that the goalU is above 1 then resets.

I hope that makes sense.
Code:
$go = primary_particleShape.goalU; int $total = 0; primary_particleShape.goalU += .01; if(primary_particleShape.goalU > 1){ primary_particleShape.goalU = 0; $total += 1; } print ($go + "\n"); print ($total + "\n");

:::PLAYBLAST :::
Playblast

Last edited by jhealyvfx : 08-31-2013 at 12:20 AM.
 
Old 08-30-2013, 08:29 PM   #2
capt chuck
Frequenter
 
capt chuck's Avatar
 
Join Date: Dec 2003
Posts: 109
I don't know anything about Maya scripting/programming but from my experience in other programs I'm guessing it's because you are initialing total = 0 local to that code snippet. My guess is that this code gets executed every frame so when the conditions are met total only would be 1 for a a brief amount of time which is what you're seeing. You don't have a similar problem with the $go variable, since it is set to what must be a scene reference.
__________________
Rendering with Pixels
 
Old 09-02-2013, 01:15 AM   #3
haggi
Expert
3d freelancer
 
Join Date: Apr 2004
Posts: 975
Thats correct, your total is a local variable and is recreated for every evaluation step.
This approach would not work anyway because your total would be global for all particles, but I think you will need different values for them.

Instead of the local variable, simply use a per particle attribute.
__________________
www.renderwiki.com - www.openmaya.net
 
Old 09-02-2013, 06:17 AM   #4
jhealyvfx
Scout
portfolio
Jason Healy
Freelance Artist
Columbus, United%2BStates
 
Join Date: Jul 2011
Posts: 26
Ok, I'll have to look into that.
Thank you guys for the help.
 
Old 09-03-2013, 05:50 PM   #5
mandark1011
Expert
 
mandark1011's Avatar
portfolio
Michael Lemon
Fx Artist
Canada
 
Join Date: Apr 2003
Posts: 1,042
another and very stable approach to this is to use the built in goalWeightPP.

basically make every letter a goal at the same time, add the appropriate number of goalWeightPP atts from the add attribute particle tab, then control goalWeightPP in your expression to make your particle object jump from one letter to another.
__________________
Showreel
RnD
 
Old 09-03-2013, 09:28 PM   #6
jhealyvfx
Scout
portfolio
Jason Healy
Freelance Artist
Columbus, United%2BStates
 
Join Date: Jul 2011
Posts: 26
I like this idea. I was looking at those attributes before, but I couldn't wrap my head around it. I think I understand the concept now though. Thanks
 
Old 09-03-2013, 09:28 PM   #7
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:57 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.