Notifications
Clear all

[Closed] beziear curve_based obj position's key

hi
there was a show-reel ( https://vimeo.com/17662541 ) in which a car move in X and Y axis and in each turns body knows how to steer (like a beziar curve)

there was a tutorial on creating a beziare curve based on the 3 vector (3 obj and their position).


  
  b=box()
  at time 5 animate on b.pos = [0,0,0]
  at time 30 animate on b.pos = [100,0,0]
  at time 60 animate on b.pos = [100,100,0]--this is the first turn
  at time 90 animate on b.pos = [200,100,0]--this is the second turn
  
  

now i like to know can we use the value of these keys or position of the box at specified keys as vector and create the beziar curve at each turns and create our car steering, beside here we have 2 turns how to write the script in which at each box’s turns the body of a car has a auto steering
any idea or suggestions.

Thanks in advance

5 Replies

check this thread –> http://forums.cgsociety.org/showthread.php?f=98&t=1107342&highlight=wheel

at the end i show there a snippet for making a “wheel-chair”

what you have done there was ” Auto wheel rotation “
here i like to get “Auto steering ” not rotation
l do my best to convey my idea


  
  delete objects
  
  C=Cone name:"Car_Body" height:70 radius1:12 radius2:0 pos:[-100,-70.,0] wirecolor:(color 90 150 220)
  C2 =teapot name:"Path_body"  radius:18  pos:[-160,-70,0] wirecolor:(color 250 220 0)
  M = box name:"Mover" width:10 length:10 height:10 pos:[-70,-70,0] wirecolor:red
  C3= circle name:"beziear_like_arc" radius:220 pos:[-115,150,0] wirecolor:green
  M_shadow = box name:"Car_Body_in beziear move" width:5 length:5 height:20 pos:[-70,-70.,0] wirecolor:green
  
  
  
  
  select C3
  max hide selection 
  M_shadow.pos.controller = Path_Constraint path:C3
  DD=M_shadow.pos.controller
  deleteKeys dd #allKeys
  M_shadow.pos.controller.percent = 78
  DDD=M_shadow.pos.controller.percent
  
  M.showTrajectory = on
  at time 5 animate on M.pos = [-70,-70,0]
  at time 30 animate on M.pos = [100,-70,0]
  at time 60 animate on M.pos = [100,100,0]--this is the first turn
  at time 90 animate on M.pos = [200,100,0]--this is the second turn
  
  M_shadow.showTrajectory = on
  at time 0 animate on M_shadow.pos.controller.percent = 78
  at time 5 animate on M_shadow.pos.controller.percent = 78
  at time 60 animate on M_shadow.pos.controller.percent = 96
  
   
  Animate on
  (
  	for t in 1 to 100  by 1 do
  	(
  		at time t
  		(
  			Dirvector2 = (M.pos - (at time (t-1 )(M.pos)))
  			C2.dir = Dirvector2--teapot						
  			C.dir = Dirvector2
  			C.pos = m.pos
  
  		)
  	)
  )	  
  
  	  
  
  

here the red box move without rotation we assume this as car’s CNT
the cone which we assume the body of car “Car_Body” rotate on red box transition but not in a real world rotation
the green box “Car_Body_in beziear move” ( no beziear move using path con to show what i’m looking for)
the green box’s movement is what i am looking for, i mean the beziear movement of Red Box at frame 0 to 60
there are two turns i need on beziear turn based on red box move

what im looking for is getting the red box position as vector (or red box keys as vector) then normalize these vectors to get a curve like rotation, whenever
the red box changes its direction.
in a nut shell cone move like green box

1 Reply
(@denist)
Joined: 10 months ago

Posts: 0

you probably couldn’t understand what this snippet is about…

here the beziear curve (created by Enrique Rosales) which i want to append with the second script


    
    p1= circle name:"p1" radius:20 pos:[-65,-65,0] wirecolor:green	
    p2= circle name:"p2" radius:10 pos:[100,-62,0] wirecolor:green	
    p3= circle name:"p3" radius:10 pos:[100,100,0] wirecolor:green	
    T2 =teapot name:"B_C"  radius:18  pos:[-65,-65,0] wirecolor:(color 250 220 0)
    
    
    p1=$p1.pos
    p2=$p2.pos
    p3=$p3.pos
    
    initialframe= 0
    finalframe =100
    
    vector_01 = (p2 - p1)
    vector_02 = (p3 - p2)
    
    Animate on
    (
    	for t in initialframe to finalframe  by 1 do
    	(
    		at time t
    		(
    			p4 = ((normalize vector_01) * (((length vector_01) /finalframe)*t)) + p1
    			p5 = ((normalize vector_02) * (((length vector_02) /finalframe)*t)) + p2
    			vector_03 = (p5 - p4)			
    			T2.pos = ((normalize vector_03) * (((length vector_03) /finalframe)*t)) + p4	
    		)
    	)
    
    )
    
    
in this way we need p1p2p3 as vector,i dont want this, i like to get the beziear result but in this second way here if im no wrong we take red box  pos as vector.but the box turns in its place not in a curvy way

    
    B= box name:"body_Helper" length:40 width:40 Height:10 pos:[-65,-65,0] wirecolor:red
    
    at time 5 animate on b.pos = [-65,-65,0]	
    at time 30 animate on b.pos =[100,-62,0]
    at time 60 animate on b.pos =[100,100,0]
    at time 120 animate on b.pos =[200,100,0]
    
    
    animate on
    for i = 0 to 120 do
    (
    
    p1 = at time i B.pos
    p2 = at time (i-10) b.pos
    if p1 != p2 do
    (
    x=normalize (p2-p1)
    z=[0,0,-1]
    y=normalize (cross z x)
    myMatrix = (matrix3 y x z p1)
    v1 = b.pos - b.dir
    vect = normalize v1	
    at time i in coordsys (transmatrix b.pos) b.rotation=inverse(myMatrix.rotation)
    
    )
    )
    
    
is it possible with the second way getting the first part result, if it is we should take the y axis as p3 how should i do this if it is not what should i try.

Thanks in advance

At the first time i look at the result of THE page and thought, that was not the solution
now looking it again

i try to get what you did, consider a maxscript beginner understanding:

1_you add a costume attribue to rotation controller (i saw paul neal use this method, to store node to overcome depends on failure) you add timeAngle type:#point3
when we want to use this attribue we must say (( this.timeAngle…)) But i didn’t understand WHY you use it?

2_you add p0 and p1 with tick offset 0 and 160 i guess it means at the 0 pos of parent and 160 head pos of parent ,in my script if i want to use your method i should use your
p0 and p1 as vector (in position script) in my script as(p1 p2)

But
A_how about the Y axis the Red box once goes Y axis once goes the opposite of previous one
B_in the above script both scrips work on time i mean (… finalframe)*t ) and ( at time i ) what should id use instead of time in script controller i just familiar to //at time (currenttime… \
C_does solution has sth to do with left or right handed matrix Or we shuold find the cos of the vectors i mean p1 and p3 or better to say p0 and Y axis

Thanks anyway