Surface Follow problem

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 12 December 2010   #1
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.
 
Old 12 December 2010   #2
could you give us a working example so that we can experiment on?
 
Old 12 December 2010   #3
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
 
Old 12 December 2010   #4
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
				)
			)
		)
 
Old 12 December 2010   #5

	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
				)
			)
		)
 
Old 12 December 2010   #6
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
 
Old 12 December 2010   #7
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.
 
Thread Closed share thread



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 vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 11:04 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.