Jump to content
zhyravetsky

how to rotate particles in houdini 13 (dops)

Recommended Posts

I’m learning to use vex in the Pop Torque based on expressions I use in the Rotate POP.

 

-In the angle parameter, I put the following expression: if (  $NUMHIT == 0,    fit01(rand($ID),$T * 40, $T * 720),     fit01(rand($ID), $T * 1000,$T * -120))

-In the axis parameters of Rotate POP, I would put $VX and $VZ of the particles in each respective value.

 

I’d like to know if this is the proper vex form for the above. I've been having trouble finding the vex variable for particle velocity so I guessed:

 

amount = amount;

if (i@hitnum == 0);{                                                                                             

    amount = fit01(rand(@id),@Time * 40, @Time * 720);

}else{

    amount = fit01(rand(@id),@Time * 1000, @Time * -120);   

}

axisx = v@vel.x;

axisz = v@vel.z;

Edited by venator11387
  • Like 2

Share this post


Link to post
Share on other sites

Here is the code now and I keep getting an error, which is attached below. Bit of a noob at what's going on.

 

amount = amount;
if (@hitnum == 0) {
    amount = fit01(rand(i@id),@Time * 40, @Time * 720);
}
if (@hitnum == 0) {
    amount = fit01(rand(i@id),@Time * 1000, @Time * -120);    
}
@axisx = v@v.x;
@axisz = v@v.z;

post-9028-0-82040800-1390455008_thumb.jp

Share this post


Link to post
Share on other sites

That's because in VEXpressions, you can't use @ for setting parameters. So in your case, you need to use this:

 

axis.x = @v.x;
axis.z = @v.z;
Edited by magneto
  • Like 1

Share this post


Link to post
Share on other sites

Thank you, one more simple thing. I'm trying to stop the amount based on velocity, but it doesn't work because of this syntax prompt for the bolded. I've tried various ways based on the "Using VEX expressions" guide with no luck.

 

Implicit cast from vector to float. Use explicit cast instead. 

 

if (@v <= .3){
    amount = 0;  
}
Edited by venator11387

Share this post


Link to post
Share on other sites

@v is a vector

.3 is a float

 

what you want to do is compare speed to threshold, not the velocity vector, so you need to get the length of v vector

length(@v) <= .3

Share this post


Link to post
Share on other sites

Thanks, I was able to make the syntax work, but I’m still unable to get the effect working right. Whatever expression line is acting first on the particles, it seems they stay affected by it despite the other lines I put in the code.  Attached below is the scene.

TorqueRotate_Test.hipnc

Share this post


Link to post
Share on other sites

I'm not sure you understand what POP Torque  does

it's not setting rotation of the particles, but spinning force

so setting amount on POP Torque to 0 will not set particles rotation to 0 not even make it to stop, it will simply not introduce any more spinning force on that particle

that means that the particle will still remain spinning at constant speed unless there is something else affecting it (like POP Drag Spin or any custom nodes)

 

so if you want the particle to stop spinning when the speed is below threshold just

remove that if condition from POP Torque

and add POP Wrangle node with following:

if (length(@v) <= .1){
    v@w = 0;    
}

w is angular/spinning velocity so if you set it to 0, no more spinning will occur and particle will stay at it's current rotation

 

if you want however reset it's rotation enter the following instead:

if (length(@v) <= .1 || @age<=@TimeInc) {
    p@orient = {0,0,0,1};    
}

Share this post


Link to post
Share on other sites

since POPs are about simulation, it makes sense to affect rotation by introducing rotational force (torque

 

but for explicitly setting rotation I would use POP VOP or POP Wrangle to manipulate orient attribute directly (as showed above), you can even build "POP Rotate" or "POP Orient" very easily with them so that it does exactly what you need 

 

you can have a look at POP Lookat, it modifies orient and torque inside, it may give you some inspiration

Share this post


Link to post
Share on other sites

It was a little funny there is a pop drag spin, but not a pop spin .. so I made one. It puts spin on particles, just use a birth group to put spin on the first born frame. There are features for randomization :ph34r:. It can be followed by a pop drag spin.

popspin_v01.otl

Edited by andrewlowell
  • Like 2

Share this post


Link to post
Share on other sites

It was a little funny there is a pop drag spin, but not a pop spin .. so I made one. It puts spin on particles, just use a birth group to put spin on the first born frame. There are features for randomization :ph34r:. It can be followed by a pop drag spin.

 

 Strange with that pop drag spin without the spin.  Thanks Andrew :D 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×