object limits..can it be done.

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 10 October 2003   #1
object limits..can it be done.

Hi All,

I'm trying to set up limits for the movement of an object.

Eg. -5 to 5 on X and -5 to 5 on Y.
I need to be able to freely move the object within the area mentioned above but have it so the object cannot move outside of the -5 to 5 ranges.

Is this possible? I'm really struggling to find a way to do this.


Cheers for any help


Jon
 
Old 10 October 2003   #2
Hello blowtorch:

Yes, it's possible. You only need a position script controller where you constrain the object to that region.

Problem 1:Max doesn't allow selfreference in script controllers. So you need to fool it.
For example you can create a dummy, apply a position script controller to it and then do the constraint check. Something like this

If($objectname.pos.x>5) then $objectname.x=5
If($objectname.pos.x<-5) then $objectname.pos.x=-5
If($objectname.pos.y>5) then $objectname.pos.y=5
If($objectname.pos.y<-5) then $objectname.posy=-5
[-123.188, 0, 0.483092]

The $objectname object is the object you want to constraint. The last line is the dummy position that appeared when entering at first to the properties of the script controller. Don't touch it

Problem2:The constraint is not reflected in real time, only when you move the slidertime. To solve this you need the
dependsOn $objectname directive placed in the firstline to to enable interactive update.

Check the .max (max 5)
Attached Files
File Type: zip test.zip (8.8 KB, 18 views)
__________________
Borja Morales
r3D

Last edited by Reality3D : 10 October 2003 at 10:19 PM.
 
Old 10 October 2003   #3
Hi Reality3D

You are a star

That problem has been bugging me for days and everyone I spoke to seemed to think it couldn't be done.

Thanks for that. I owe you one.


Cheers



Jon
 
Old 10 October 2003   #4
Question

Reality, do you know if the realtime update could be implemented maybe with a callback asociated to the dummy position?.
__________________
Mathematics, rightly viewed, possesses not only truth, but supreme beauty - a beauty cold and austere, like that of sculpture.
 
Old 10 October 2003   #5
fabman, using dependsOn $objectname you solve the realtime update problem
__________________
Borja Morales
r3D
 
Old 10 October 2003   #6
Okidoki

Yep, reality, I saw that on your first post, but it was just me thinking if it was posible to do it through any other way... thanx again.
__________________
Mathematics, rightly viewed, possesses not only truth, but supreme beauty - a beauty cold and austere, like that of sculpture.
 
Old 10 October 2003   #7
Hi Reality,

Is there a way to get the constraints to act at a local level?

I'd like to link the 'constrained' object(sphere01 in your test) so I can freely position it elsewhere. Then have the constraints work when I move sphere01 directly.

Cheers


Jon
 
Old 10 October 2003   #8
It's possible, of course. It would be very easy using selfrerence, but as said you cannot(in max 6 this seems to work). So you have to indicate in some manner the base position where the distances will be calculated. From a nonscripter point of view the easiest way is using another helper(let's say a point) and put it in the base position you need.
Then alter the position script of the dummy with:

dependsOn $sphere01 $point01
If($point01.pos.x - $sphere01.pos.x >30) then $sphere01.pos.x=$point01.pos.x-30
Else If($point01.pos.x - $sphere01.pos.x <-30) then $sphere01.pos.x=$point01.pos.x+30
If($point01.pos.y - $sphere01.pos.y >30) then $sphere01.pos.y=$point01.pos.y-30
Else If($point01.pos.y - $sphere01.pos.y <-30) then $sphere01.pos.y=$point01.pos.y+30
[-123.188, 0, 0.483092]

I should have put those else with the other day example, but somewhat forgot it (if the first condition happens, sure the second won't, so no need to test it). You get the distances between the sphere and point and act consecuently. Tell us If you don't understand something

By the way, I remember when scripted the first example that the constraint was in real time(when the object arrived to one of the frontiers, it simply stopped). I reloaded the file I attached and saw that the gizmo stopped at the frontier but the object could go forward(when the click is finished the object returns to the gizmo position). Maybe I have touched something I shouldn't hehe

->Edit:Oh, i found the problem of the real time thing. I deactivated by accidentthe dual planes option of Viewport configuration.8) Now it works ok again
Attached Files
File Type: zip test1.zip (9.6 KB, 11 views)
__________________
Borja Morales
r3D

Last edited by Reality3D : 10 October 2003 at 11:12 PM.
 
Old 10 October 2003   #9
Hi Reality,

Thanks once again.
I've been looking at a prerelease of Max6 and noticed the 'Local this' they have added.

Which will be very useful but I don't know when we are upgrading to 6 yet.


Cheers



Jon
 
Old 01 January 2006   #10
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 05:51 PM.


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