PDA

View Full Version : how to use image sequence in 2D container


djorzgul
01-05-2007, 10:31 AM
-hello to all,
I would like to use an image sequence in 2D container (it is a short black and white animation I did)... I manage to do the thing I wanted with one frame, but I don't know how/if it is possible/ to do the same thing with a sequence.
Any guidance will be more than appreciated :)

----edited&merged posts-----

I found the answer on maya wiki (http://www.tokeru.com/twiki/bin/view/Main/MayaFluids)
by mr. Duncan :) himself

Here is a little expression that gets the alpha from a file texture node "file1" and adds this every frame to the fluid node "fluidShape1". It samples the file node based on the fluid resolution. If you want it to use an image sequence, simply turn on "useImageSequence" on the file texture node. To use color instead of alpha you can use RGB instead of A in the colorAtPoint call. Then in the loop you need to get the r,g and b values from the array, incrementing the index after each.

Duncan



int $nx = fluidShape1.resolutionW;
int $ny = fluidShape1.resolutionH;

int $i, $j;
float $colorArray[] = `colorAtPoint -o A -su $nx -sv $ny file1`;
int $index = 0;
for( $i = 0; $i < $nx; $i++ ){
for( $j = 0; $j < $ny; $j++ ){
setFluidAttr -at "density" -ad -fv ($colorArray[$index]) -xi $i -yi $j fluidShape1;
$index++;
}

BUT, for some reason I get errors every time I try to execute the expression.
Since the explanation is pretty straightforward maybe I am missing something else.
I tried both on square container /default one, and on the one I adjusted to my needs [720x360 is the size in container properties]

my workflow was like this:

1. I make 2D fluid container
2. I make one file texture node and load the 49frames sequence [white figure on black]
3. I try to execute the script so I connect the sequence with container but all I get is this error:

// Error: int $nx = fluidShape1.resolutionW; //
// Error: Invalid use of Maya object "fluidShape1.resolutionW". //
// Error: int $ny = fluidShape1.resolutionH; //
// Error: Invalid use of Maya object "fluidShape1.resolutionH". //
// Error: //
// Error: Syntax error //

So,
I am not very experienced with expressions so I am missing something for sure...

I'd appreciate if someone help me with this.

djorzgul
01-05-2007, 12:09 PM
-------------------

djorzgul
01-05-2007, 12:16 PM
------------------------

cosku
01-06-2007, 08:37 AM
You were missing the last curly-bracket, and getAttr's.



int $nx = `getAttr fluidShape1.resolutionW`;
int $ny = `getAttr fluidShape1.resolutionH`;

int $i, $j;
float $colorArray[] = `colorAtPoint -o A -su $nx -sv $ny file1`;
int $index = 0;
for( $i = 0; $i < $nx; $i++ ){
for( $j = 0; $j < $ny; $j++ ){
setFluidAttr -at "density" -ad -fv ($colorArray[$index]) -xi $i -yi $j fluidShape1;
$index++;
}
};

djorzgul
01-06-2007, 08:51 AM
:applause:
ah...
thank you so much...

it makes all the connections now. however there is something I don't get right. I can see the first frame only, and there is no reading of other ones. I checked the file node and sequence reading is ok... also there were no erros when I executed the script.
... and still it is just one image/1st frame

cosku
01-06-2007, 06:38 PM
If you run the script through the Script Editor, it only runs once.
You need to put it in an expression to actually be evaluated every frame.

Go to Window-Animation Editors-Expression Editor,
Paste the code into Expression area, and hit Create.

djorzgul
01-06-2007, 07:17 PM
:thumbsup:
well, it is one very simple tip, but you just made my day.
thank you very, very much...

Stimpy
01-09-2007, 05:01 PM
just what i was looking for... atm i have to put some filmed objects on fire, and this works out just fine. i was just wondering, is there any way to change the scale of the fluid? right now the flames always end up far too huge for my object, and the usual stuff i did of scaling the container or the emitter somehow doesnt work... anyone have an idea ???

here a quick test pic of what i got so far: http://i3.tinypic.com/48rnng9.jpg
flames itself look lovely from the motion and all, its just they are overall 3 times too big. any solution to this ?

CGTalk Moderation
01-09-2007, 05:01 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.