MAXSCRIPT ISSUE - DISTANCE

MAXSCRIPT ISSUE - DISTANCE

richardvillagaray
Participant Participant
1,743 Views
8 Replies
Message 1 of 9

MAXSCRIPT ISSUE - DISTANCE

richardvillagaray
Participant
Participant

I have a little query:

I want to make a Maxscript that does the following:

Point001 is a fixed point.

The Pointt002 is a point, from which I can animate its position, it must have 2 controls
1) look at, so that you always look at Point001.
2) script so that it has a minimum distance between Point001 and Point002 = 0, or a maximum distance = 1000 (or whatever value I set), it cannot be further away. It is more or less like a constraints.

 

Box001, is any object, which I link to Point002

 

 

THANKS SO MUCH

0 Likes
Accepted solutions (1)
1,744 Views
8 Replies
Replies (8)
Message 2 of 9

istan
Advisor
Advisor

why are you crying in your title ?

you have to specify more details:

a) which axis of point2 you want to align for the "look-at" constraint?

b) what you mean with minimum *OR* maximum distance? shall it be fixed to a certain distance to point1 or shall it be floatable within a certain range?

0 Likes
Message 3 of 9

denisT.MaxDoctor
Advisor
Advisor

there is my question too:

Is Point2 free to move ? (it means the position controller is limited just by distance to the target)

0 Likes
Message 4 of 9

richardvillagaray
Participant
Participant

a) Yes. The "look at" has the same axis for the Point002. It turns out that in the animation the object will always be looking at Point001.

 

b) Yes. The distance between Point001 and Point002 will be variable; the variation will go from a  range; zero (0) to 1000 (maximum).But the position within the range I will do it manually. The script will present a restriction not to be able to move the object to a value farther than 1000..

 

What happens is that I am going to animate many objects and I need that script.

 

 

thanks a lot

 

 

 

0 Likes
Message 5 of 9

richardvillagaray
Participant
Participant

Yes. Point002 is free to move, I will move it manually during animation, but the script will present the restriction.
The manual movement range will be between zero (0) and maximum value (1000).


And Point002 will always be watching Point001; that will be with the "look at" control.

0 Likes
Message 6 of 9

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

I would do it this way:

delete objects
with redraw off, animate off
(
	t = dummy name:#target boxsize:[20,20,20]
	m = point name:#master size:20 box:on cross:on axistripod:on wirecolor:red pos:[200,0,200] 
	s = point name:#source size:10 box:off cross:on axistripod:off wirecolor:orange
		
	cc = m.rotation.controller = lookAt_constraint()
	cc.appendtarget t 100

	cs = s.transform.controller = transform_script()
	cs.addnode #master m
	cs.addnode #target t
	cs.addconstant #distlimit 200
	cs.setexpression \
	@"d = amin distlimit (distance master target) 
	tm = master.transform
	tm.pos = normalize (master.pos - target.pos) * d + target.pos
	tm"	
	
	s
)

 

the #source node is a constraint (100%) and can't be animated by itself, but can be used as "attach" point or a source of transform. The animation should be done by #target and #master nodes.

   

 

Message 7 of 9

denisT.MaxDoctor
Advisor
Advisor

there are several reasons to do it this way instead of creating a "semi-constrained" #source node. My two reasons:
1) everything should be simple
2) have smooth animation curves for interpolation

Message 8 of 9

richardvillagaray
Participant
Participant

Thanks Dennis...... you are the best.

I like your code, it´s useful....

 

see you soon

 

 

 

 

0 Likes
Message 9 of 9

richardvillagaray
Participant
Participant
useful....is what i was looking for
0 Likes