hoknamahn Posted February 16, 2006 Share Posted February 16, 2006 I need to rotate the point normals on arbitrary angles. There is a vector type angle parameter (each component of that vector is intend for it's own rotation axis). First of all I need to change the space from object to "normal", right? How to do it? Can I use obj2world->world2texture space change functions? Any suggestions? Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted February 16, 2006 Share Posted February 16, 2006 Hi Hok, What is the context? Are we talking about Shading? SOPs?, COPs?... each context will have a slightly different approach (mainly due to the availability of surface derivatives). Quote Link to comment Share on other sites More sharing options...
hoknamahn Posted February 16, 2006 Author Share Posted February 16, 2006 Hi, Mario! SOP context. I want to create artful normals as initial velocities for the particles. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted February 16, 2006 Share Posted February 16, 2006 Would combing them work for you or do you need very specific control? Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted February 16, 2006 Share Posted February 16, 2006 OK. For SOPs, the bare-bones basic approach would go something like this: // Basic N rotation (Euler) in SOPs // -------------------------------- // Build local coordinate system vector basis_z = normalize(N); vector up = {0,1,0}; if(abs(dot(basis_z,up))>.98) up = {0,0,1}; vector basis_x = normalize(cross(basis_z,up)); vector basis_y = normalize(cross(basis_x,basis_z)); // Rotate -- assumes "rot" is your vector of rotation values in degrees vector Kr = radians(rot); matrix mr = rotate(ident(),Kr.x,basis_x); mr = rotate(mr,Kr.y,basis_y); mr = rotate(mr,Kr.z,basis_z); // Modify N N = normalize(N*(matrix3)mr); That's with a fixed "XYZ" order, but you can extend it to parameterize the order as per the transform SOP of course. Many times you'll need to align the frame to some attribute (like texture UVs for example), in which case you'd need to get a gradient of the attribute to build your frame against. But the above is the basic approach (with a hard-coded "up"). Quote Link to comment Share on other sites More sharing options...
Visual Cortex Lab Posted February 16, 2006 Share Posted February 16, 2006 dunno if this fits here, if not i'll open a new thread... btw... Last night i was trying to get a Particle SOP in "Modify geometry" mode to ... break my object.. so each polygon were emitting a particle which then was "grabbing" it (facet with unique points first) and make each polygon falls down ... the problem was that the orientation of the polygon was wrong.. I menaged to have the best result by aliging the normal but then the "plane" of each polygon was rotated.. so the object looked already "broken" right at frame one.. sadly i didnt took any screeshot but if you have any advices to reach such effect they are really welcomed...or if this is not clear enought I'll take screeshots of a new scene. cheers. Quote Link to comment Share on other sites More sharing options...
aracid Posted February 16, 2006 Share Posted February 16, 2006 hey try adding a point sop and say ADD normal (default) just before u send it into the facetSOP then under ur source in pops make sure that the number of points matches the number of nprims in ur sop going into ur pop network, and make the emission type - prim center (ordered) hope this helps Quote Link to comment Share on other sites More sharing options...
hoknamahn Posted February 16, 2006 Author Share Posted February 16, 2006 sibarrick Would combing them work for you or do you need very specific control? Yes, I need a superbupermegacontrol Mario Oh man you really Atskiy Sotona! I'll modify your code a little bit and then will be completely happy Thanks a lot! Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted February 16, 2006 Share Posted February 16, 2006 Thanks a lot! You're very welcome, but... I give up, what does Atskiy Sotona mean?! Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted February 17, 2006 Share Posted February 17, 2006 Hey! I was just playing around with this code, and it occurred to me that there *is* one approach to building the local basis (in the absence of a reference direction like an "up" or a dPdu or the like) that is guaranteed to vary smoothly across all orientations of N -- it still suffers from the two singularities that cause the infamous "flip", but at least has the (possibly useful) characteristic that the "flip" is spread over the whole angular range instead of happening all at once at the limits... I really don't know how useful this might be (if at all), but I thought I'd put it out there for discussion... here's the same code as above, except that instead of deriving the binormal from an arbitrary "up" reference, it derives it from the normal itself (and is therefore different for each N, but changes smoothly) // Euler Rotation *without* an "up" // ----------------------------------- // Build local coordinate system vector basis_z = normalize(N); vector basis_x = normalize(set( basis_z.z-basis_z.y, basis_z.x-basis_z.z, basis_z.y-basis_z.x ) ); vector basis_y = normalize(cross(basis_x,basis_z)); // Rotate -- assumes "rot" is your vector of rotation values in degrees vector Kr = radians(rot+{0,0,-45}); matrix3 mr = rotate(matrix3(ident()),Kr.x,basis_x); mr = rotate(mr,Kr.y,basis_y); mr = rotate(mr,Kr.z,basis_z); // Modify N N = normalize(N*mr); Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted February 17, 2006 Share Posted February 17, 2006 Huh! It turns out that the previous approach ("binormal-from-N") gives an almost identical result (save for an offset) to the dihedral method that I mentioned in the other thread about the extrude sop. Pretty surprising (to me at least)... and it's much cheaper to compute than building the matrix. Here's the dihedral approach -- in this case the angles are relative to the canonical XYZ vectors instead of something built on the face of a poly, but the overall distribution of orientations would be the same in either case -- and they look like a match to the "binormal-from-N" approach. // Euler Rotation using dihedral angles // ------------------------------------ // Dihedral from cononical "up" vector n = normalize(N), y = {0,1,0}; matrix3 md = length2(abs(n)-y)<0.001 ? matrix3(ident()) : dihedral(y,n); // Build local coordinate system vector basis_x = {1,0,0}*md; vector basis_y = y*md; vector basis_z = {0,0,1}*md; // Rotate -- assumes "rot" is your vector of rotation values in degrees vector Kr = radians(rot); matrix3 mr = rotate(matrix3(ident()),Kr.x,basis_x); mr = rotate(mr,Kr.y,basis_y); mr = rotate(mr,Kr.z,basis_z); // Modify N N = normalize(N*mr); Anyhooo.... I should go to bed... Quote Link to comment Share on other sites More sharing options...
hoknamahn Posted February 17, 2006 Author Share Posted February 17, 2006 Huh, so much info! Thanks, Mario Atskiy Sotona is a phrase from some russian slang and mean in this case something like "Smart Guy" Quote Link to comment Share on other sites More sharing options...
MADjestic Posted February 17, 2006 Share Posted February 17, 2006 Huh, so much info!Thanks, Mario Atskiy Sotona is a phrase from some russian slang and mean in this case something like "Smart Guy" 24803[/snapback] Sotona - sounds like Satan and in fact that's what it means =) As for Atskiy - it's a genetive from Ad, that means Hell. So it can be literaly translated as "Infernal Satan" or something As for connotation - it is both ironical, elevative and strongly approving of someone's outstanding aptitude. NB. Sorry, Hoknamahn - I didn't mean to correct you - just wanted Mario to get that feeling from this russian expression that you and I get when we use it Quote Link to comment Share on other sites More sharing options...
hoknamahn Posted February 17, 2006 Author Share Posted February 17, 2006 Sotona - sounds like Satan and in fact that's what it means =) As for Atskiy - it's a genetive from Ad, that means Hell. So it can be literaly translated as "Infernal Satan" or something As for connotation - it is both ironical, elevative and strongly approving of someone's outstanding aptitude. NB. Sorry, Hoknamahn - I didn't mean to correct you - just wanted Mario to get that feeling from this russian expression that you and I get when we use it 24804[/snapback] You can explain that better than me Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted February 17, 2006 Share Posted February 17, 2006 So it can be literaly translated as "Infernal Satan" or something Heheh... well, every now and then I try to look satanic to my kids, but they're just not buying it for some reason (maybe I should try yelling at them in Russian!)... kids these days Thanks for the compliment! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.