Jump to content

Rotation problem with LookAt within a VOPSOP


Recommended Posts

Hi there,

My rotations go to infinity at parts of my path-animation (with a path that's created by Creep'ing a point on a surface).

I can't seem to figure it out, any ideas on how I can fix this?

The Copy SOP seems to work around this when you feed it "N" and "up", but I want to use VOPSOPs to feed my rotation data elsewhere.

Thanks,

post-3820-130260215861_thumb.gif

post-3820-130260216945_thumb.gif

lookAt_rotation_infinity.hip

Link to comment
Share on other sites

Don't have much time now to do a file but if I was you I'd use N from the track, then get v, cross and normalize them and you have a frame (maybe not orthogonal but that should be fixable). Then you can always put that into matrix form and get transform information from it wherever you need it.

Edited by Macha
Link to comment
Share on other sites

Many ways to do this. I hacked away at your file adding a CHOP solution to calculating first the distance traveled and then chopping this up in to number of rotations (circumference of your tire) and then multiplying it by 360 degrees per rotation.

I changed the playback options. Turned off integer playback and changed the step to 0.02 or something like that so you can see that the inter-frame rotations are smack on.

I don't "care" how you calculate the rotations, it's the distance traveled that you need.

CHOPs can calculate distance. In the attached file I put my Distance CHOP asset (IMHO should be in the release) in there for you to use.

POPs calculates a distance attribute you can use. In my travels it is pretty much 100% what you get from the Distance CHOP. This is a simulation where the distance is accumulated so this opens up SOP Solvers in DOPs and more. Knock yourself out with the number of ways you can do it in there.

You are using the Creep SOP to place the point. If and this is a big if the surface is evenly parametrized you can use this value but I wouldn't. It takes quite a bit of effort to do this with Polygons. If the track were NURBS you might have a better chance at this but with the banking, forget about it.

You can build trail curves with a trail SOP then Measure SOP add perimeter attribute for length then transfer the last point length attribute to the point as distance traveled. I consider Trail to be a form of simulation where it needs to fetch the position from previous frames therefore it needs to evaluate all that. Semantics at this point...

I said there are lots of ways to calculate distance traveled which is what you need. CHOPs, VOPs, Expressions for the rotation logic? Whatever turns your crank. Simple trig.

Given that you are looking at most 40 cars on the race track (NASCAR...) then that's 40*4=160 rotations to calculate, CHOPs could do this in real time. The file I attached will easily scale to this. Just feed in more points and see for yourself how it handles this.

lookAt_rotation_infinity_jw.hip0.hip

Link to comment
Share on other sites

Hey Jeff,

This file is great! Thanks a lot,

I was faking tire rotations to spin something like 360*1000 times, I'll do them accurately now as this solves really fast.

My original question though was to mimic the behavior of what the Copy SOP did for me (and for you in your .hip), orienting the

tire (or my camera) to the track. When we feed the "N" (direction) and "up" (track-normal) to the Copy SOP, it orients the object

to the track for free.

I want to achieve this behavior in a VOPSOP, assigning a rotation value (for orientation) to the animating points.

Any ideas? :)

(I want to export Position+Rotation data for a changing number of cars, that's why I'm calculating the orientation in a VOPSOP and grabbing

that data in CHOPs. It'd be nice to let the Copy SOP handle the final rotations, but I don't know how I can grab those rotations for an unknown

number of objects in CHOPs. For a single object I use the Object CHOP, but for X-count of objects, I'm lost.)

Sanostol: Ah, hmm.. Any ideas on what I can do to calculate continuous XYZ rotation values with a LookAt-style behaviour?

Edited by cosku
Link to comment
Share on other sites

The Copy SOP uses a quaternion vector4 "rot" attribute to do rotates if it is present on the template points along with the normal (velocity) and up vector. You can take the calculated degrees of rotation (please convert to rads with DegToRad VOP) out of CHOPs and build a quaternion rotation out of this in VOPs then you don't have to do the copy stamp I did. :(

I feel ashamed. I am now guilty of my own "abuse of Copy Stamping" rules... To be fair I am very busy this morning and did the 10 second thing vs the 1 minute thing.

Link to comment
Share on other sites

Hi there,

Ah yeah, makes sense.

In the end though, all I want is to have XYZ rotation values that I can export to a txt-file.

So the quaternion that I find, I can't use.

The only way I thought I could achieve getting Euler rotations was to: Use Look-At VOP to get find the rotation matrix,

extract Euler rotations, dump that to an attribute and then dump out to a txt file (through CHOPs).

This *almost* works great, except that the rotations flip at times. Sanostol mentioned that converting a matrix to

euler rotations will never be continuous.

Argh. But there has to be a way right?

Edited by cosku
Link to comment
Share on other sites

OK I think I see what's going on.

I'm wishing for the XYZ rotations need to be additive, like going 0,360,720 etc on each tour, but extracting them from a matrix each frame flips somewhere in the middle and keeps the values between -360,360 (or -250,90 in my graph).

Due to the per-frame nature of SOPs, I feel like this is impossible, sigh.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...