PDA

View Full Version : instance facing (rotation)


mickna
04-27-2007, 04:18 PM
Hi there!

Sorry, I searched the forum and can't find an answer for my problem....

What I wanna do:
- A Room (cube) with every side of this room is made with buttons (eg 10 buttons a row and 10 buttons a line)
- after a while the buttons lift of like a swarm an building a new room (eg a speher)

Ok, I setup a Polycube (as room)
Made particles
Polycube is goal
instancing the particles with the buttons

No big deal....
However, now all buttons are facing to the same direction :(
The should be parallel to each side of the Room (to build the wall)
I have no idea how to rotate the buttons in habit of the normals from the room (cube, sphere).....


Any idea?!
Thx & take care,
mickna

vfortin
04-27-2007, 05:01 PM
Hi mickna,

In a recent version of Maya, they implemented some new features for goals from which you can get the target normal. I guess that would be a good start.

For the math, I'm not very good at that but I think you could take your particle's rotation X for example and linstep toward the normal X. Doing that for each rotation component as the particle approach the goal should orient it in the right direction.

I'm sure there's a better way for doing that, maybe with a matrix-interpolation-thign.

Anyone?

mickna
04-27-2007, 05:12 PM
Hi vfortin!

Thx for your Replay.....
Jep, I have Maya 8.5 and see a lot of rotation Options for the ParticleShape. However I tried a few and don't get any result.

"maybe with a matrix-interpolation-thign"
Wahhhh! That's my problem ;)
I just wanna yell "I'm creative!" to hide my ignorance with Mel, Math and matrix-interpolation-derivative-double integral-things *lol*

vfortin
04-27-2007, 05:44 PM
Haha well my technique obviously involves some scripting... unfortunately.
But it should be doable... I'll give it a shot as soon as I have time.
I'll probably stand corrected by then by some bilinear-matrix-logarithmic-lovers out there ;)

vfortin
04-27-2007, 09:39 PM
Ok just to follow up a bit on this...
GoalWorldNormal0PP works very well. If you pipe it directly in the rotation input (particleShape>Instancer>Rotation Options), your instances will follow the surface normal properly.

I'll figure out the rest later, it's friday already ;)

Vincent

vfortin
05-02-2007, 12:37 PM
Well for the records, it seems that the procedure for interpolating rotations isn't that trivial.
The trick is to convert rotations to a unit quaternion and then do a slerp (spherical linear interpolation) on it. However I can't find these commands in the MEL reference, only in the API.

Starrider
05-02-2007, 12:50 PM
thats it ...

MVector vResult;
MVector vn0, vn1;
MVector v2;

double dL0 = v0.length();
double dL1 = vTarget.length();

vn0 = v0.normal();
vn1 = vTarget.normal();

double dot = vn0*vn1;
double theta_0 = acos(dot);
double theta = theta_0 * dWeight;

v2 = vn1 - vn0 * dot;
v2 = v2.normal();

vResult = vn0 * cos(theta) + v2 * sin(theta);
vResult *= ((dL0*dWeight) + (dL1*dWeight))

return vResult;

it's api code but i think it should also be possible in mel!
have fun!

mickna
05-02-2007, 03:08 PM
@vfortin:
Thx for your time!
After three days thinking, try & error (error was the only success) I did it now quick & dirty. Now I have only to build up a room (cube). So I took every side and definied it as a goal. Means six emiters, six planes, emiter01 -> goal plane01 and so on.....
This works for me now. However, I'd like to know the answer.....


@Starrider:
Thank U!
Api? I've heard about it *smile*
Mel is a challenge for me.
API is a miracle for me....
Anyway - thx also for your time!
May one day, I know what this lines means.....

CGTalk Moderation
05-02-2007, 03:08 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.