PDA

View Full Version : Paint Effects tree deflection?


Bonedaddy
06-28-2003, 12:10 AM
Howdy all,

I have been learning Paint Effects for use in a short shot, simulating an entirely CG POV walkthrough of a dense forest to a clearing with a decrepit old church.
I have got my trees where I want them, but the director has said he doesn't want overly unnatural camera movements -- if it's going through a forest, the branches should get pushed apart slightly. I've been experimenting with control curves, and what I have so far is an oval surrounding my camera at all times that will attract the trees and push them around the sides of the camera (along the path. Unfortunately, this only seems to be getting the main trunk and not the branches, as there are plenty of leaves and twigs still obscuring view.
I think perhaps some of this is because I have checked "Branch after twigs" under tubes->growth->twigs. Any ideas?

Bonedaddy
06-29-2003, 07:17 AM
Anybody know anywhere I could go to find an answer, even?

anakinskywalker
06-29-2003, 09:46 AM
I dunno .. you could try rendering one or two branches seperately. Map them on a Nurb surface and then bend the Nurb surface as your camera comes close... Not very realistic .. but my director had no problems with that :p (Its another matter that I convinced him that there was no other way this could be done)

Duncan
06-29-2003, 10:29 PM
I think you may be better off using repulsion rather than attraction. Make your curve very small( a point essentially ) and group it to your camera(you could use a deg 1 curve with only two points). Now make the curveAttract on your brush some large negative value, say -10. The control curve essentially now acts as a repulsive point force. Now adjust the curveMax dist to create a bubble within which the trees are pushed away.

It could also be that the branchAfterTwigs changed your simulation to require a stronger curve force to bend the branches the same amount.


Duncan

stormman88
06-29-2003, 11:33 PM
I come from china!!I learn the MAYA!!

gmask
06-30-2003, 12:00 AM
Originally posted by stormman88
I come from china!!I learn the MAYA!!

That is nice, you are nice, please be nice and ask a question in your own thread ;-) :shame:

stormman88
06-30-2003, 12:08 AM
thank you!!it is good idea.:)```
```come to here for the first time .it is strangeness!!
:)

gmask
06-30-2003, 12:10 AM
Originally posted by stormman88
thank you!!it is good idea.:)```
```come to here for the first time .it is strangeness!!
:)

I figured that out .. generally speaking you should ask a question or show something if you want to have a chat.

stormman88
06-30-2003, 12:19 AM
now ,i know ,thank you!!~~~
``

Bonedaddy
06-30-2003, 07:22 AM
I tried it, and it's not really producing the results I need. I want just the branches/twigs/leaves in front of the camera to move, not the trunk. However, to get it to actually move those, I have to set the repulsion so high it bends the trunks, which is no good. Any ideas? I'm willing to MEL script something, just a bit unfamiliar with how a lot of this works.

Duncan
06-30-2003, 10:55 PM
Ok. Try the following:
Copy "paintCollideFunc.mel" from the paint effects script area in the maya location to your local scripts directory and rename both the file and the internal function to something like "myCameraCollide.mel".

Now modify the function to position the collide sphere at your camera location:

$spherePos = `getAttr persp1.translate`;

To use the function type the name of the function in the runTime func field on your brush. It will then be called everytime a pfx segment is computed for that brush.

You can find out if the current segment being acted upon is a branch, leaf or twig by looking at the passed in parameter "$tubeType".
For example, to avoid pushing branches put the following at the beginning of the function:

if( $tubeType == 0 ){
$tubes[0] = 0;
return( $tubes );
}

You may wish modify it to push the tubes with more or less based on the distance to the camera, rather than being a hard edged bubble. You could then have different push amounts for leaves and branches.

If you don't want to create a runtimeFunction you can vary the relative amounts leaves/twigs/branches are affected by forces( such as curve attract, random and gravity) by changing the segments/leafSegments and adjusting leaf and twig stiffness attributes. However this is tricky and will generally affect your tree shape.

Duncan

Duncan
06-30-2003, 10:58 PM
Also note that you can use the variable "$branchDepth" to distinguish between the primary trunk or the higher up branches.
Duncan

Bonedaddy
07-02-2003, 06:22 AM
Duncan, you are my hero. I'm going to get more comfortable with MEL and mess around with that for awhile, but before that, I'm going to go get some goats and sacrifice them to you. Thank you.

Bonedaddy
07-03-2003, 08:29 AM
Okay,

I've got the script working okay, the only problem is that it is only executed when the brush is computed -- which needs to be every frame, and is not. How can I change this? Where should I look to?

Bonedaddy
07-03-2003, 08:41 AM
To clarify:

What I have been doing, for test purposes, is creating an actual sphere to represent the area of effect. Every time the script is called, I set mySphere's translateX, translateY, and translateZ to my camera's. I have tested this using playblast, but while the camera moves, the sphere does not.

Duncan
07-03-2003, 04:47 PM
Ah, I see the problem.. Paint effects in Maya5.0 now caches the tubes, so it thinks they are not changing. The tubes won't be regenerated and the script won't be called. To force them to regenerate you need to animate something on the brush.. keyframe something or make the turbulence slightly non-zero(turbulenceSpeed must also be non-zero).

Note that it is wasteful to call setAttr on your sphere inside the script, as it is call for every segment of every tube, although I assume you were just testing the script evaluation.


Duncan

Bonedaddy
07-03-2003, 05:56 PM
That did it! Much better than the ugly hack I was putting together, involving setting the runTimefunc every frame (only thing I could find to refresh it). It is working great now, and I am running some tests on it.
Out of curiosity, when would the best time have been to set mySphere's transform, if not inside the function? I agree that it is wasteful, but I'm not sure where else I could put it.
Thanks a million!

Duncan
07-03-2003, 07:24 PM
You can simply create an expression or simpler yet, a direct connection:
connectAttr persp1.translate sphereShape1.translate

Duncan

CGTalk Moderation
01-15-2006, 12:00 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.