12 December 2010 Crimsonfox New Member   portfolio Thomas Stafford, United Kingdom Surface Follow problem I've got this on roll open do ( (when transform \$b changes id:#shipMove do ( if chk1.checked == true then ( posPos = [\$b.pos.x, \$b.pos.y, \$b.pos.z + 1000] Uray = ray posPOS [0,0,-1] IUray = intersectRay \$p Uray if IUray == undefined then ( print "bleh" ) else ( \$b.pos = IUray.pos norm = -IURAY.dir rightVector = normalize(cross IUray.dir Norm) upVector = normalize(cross rightVector Norm) q = matrix3 rightVector upVector Norm [0,0,0] rotate \$b q.rotation print q.rotation ) ) ) when transform \$p changes id:#surfaceMove do ( if chk1.checked == true then ( posPos = [\$b.pos.x, \$b.pos.y, \$b.pos.z + 1000] Uray = ray posPos [0,0,-1] IUray = intersectRay \$p Uray if IUray == undefined then ( print "bleh" ) else( \$b.pos = IUray.pos norm = -IURAY.dir rightVector = normalize(cross IUray.dir Norm) upVector = normalize(cross rightVector Norm) q = matrix3 rightVector upVector Norm [0,0,0] rotate \$b q.rotation print q.rotation ) ) ) on roll close do ( deleteAllChangeHandlers id:#shipMove deleteAllChangeHandlers id:#surfaceMove ) Problem is it doesn't do the same thing. \$b is the box I want to move along the surface \$p being the surface. I want it to move along the surface when either are moved. It does it fine when \$b is moved just not \$p, the rotation seems to be rotating the opposite way. any help would be great, cheers. share quote
 12 December 2010 MatanH GameDev & TechArt   portfolio Matan Halberstadt Game Developer & Tech Artist OneHamsa Tel-Aviv, Israel could you give us a working example so that we can experiment on? __________________ Home: http://cargocollective.com/matan Work: https://onehamsa.com share quote
 12 December 2010 JHN maxscript/c# lover   Johan Boekhoven Technical Artist Freelance TD/Generalist Netherlands skinwrap a nurbs surface to the water and use a surfaceDeform on a small plane, then an null with an attachment constraint to the plane and add some controls to animate over the U an V. -Johan __________________ Online: LinkedIn share quote
 12 December 2010 batigolnguyen PRO portfolio Batigol Nguyen Rolling Ant Graphic HCM, Viet Nam Hi crimsonfox, Please follow this: 1. rotate function will accumulate all rotation value --> you should set the rotation matrix directly 2. You should define the direction vector to [1,0,0] (it is upvector in your code) 3. You should move the setting position of b after setting rotation Hope this helps, --Batigol on roll open do ( when transform \$b changes id:#shipMove do ( if (chk1.checked == true) then ( Uray = ray [\$b.pos.x, \$b.pos.y, \$b.pos.z + 1000] [0,0,-1] IUray = intersectRay \$p Uray if IUray == undefined then ( print "bleh") else ( norm = IURAY.dir rightVector = normalize (cross [1,0,0] norm ) upVector = normalize (cross rightVector norm) --q = matrix3 rightVector upVector Norm [0,0,0] q = matrix3 upVector rightVector norm \$b.pos --rotate \$b (q.rotation) \$b.rotation = q.rotation \$b.pos = IUray.pos --print q.rotation ) ) ) share quote
 12 December 2010 batigolnguyen PRO portfolio Batigol Nguyen Rolling Ant Graphic HCM, Viet Nam on roll open do ( when transform \$b changes id:#shipMove do ( if (chk1.checked == true) then ( Uray = ray [\$b.pos.x, \$b.pos.y, \$b.pos.z + 1000] [0,0,-1] IUray = intersectRay \$p Uray if IUray == undefined then ( print "bleh") else ( norm = IURAY.dir rightVector = normalize (cross [1,0,0] norm ) upVector = normalize (cross rightVector norm) --q = matrix3 rightVector upVector Norm [0,0,0] q = matrix3 upVector rightVector norm \$b.pos --rotate \$b (q.rotation) \$b.rotation = q.rotation \$b.pos = IUray.pos --print q.rotation ) ) ) share quote
 12 December 2010 batigolnguyen PRO portfolio Batigol Nguyen Rolling Ant Graphic HCM, Viet Nam Try this one, I made some modification and it worked on my pc on roll open do ( when transform \$b changes id:#shipMove do ( if (chk1.checked == true) then ( Uray = ray [\$b.pos.x, \$b.pos.y, \$b.pos.z + 1000] [0,0,-1] IUray = intersectRay \$p Uray if IUray == undefined then ( print "bleh") else ( norm = IURAY.dir rightVector = normalize (cross [1,0,0] norm ) upVector = normalize (cross rightVector norm) --q = matrix3 rightVector upVector Norm [0,0,0] q = matrix3 upVector rightVector norm \$b.pos --rotate \$b (q.rotation) \$b.rotation = q.rotation \$b.pos = IUray.pos --print q.rotation ) ) ) __________________ YM & SkypeID: quangngainthk http://rollingant.com share quote
 12 December 2010 CGTalk Moderation Expert Thread automatically closed 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. __________________ CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.