CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 10-14-2003, 09:24 PM   #1
skellybobbly
Frequenter
 
skellybobbly's Avatar
portfolio
Jonathan Baker
Animator
United Kingdom
 
Join Date: Oct 2002
Posts: 204
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-15-2003, 07:46 PM   #2
Reality3D
Veteran
portfolio
Borja Morales
QA & Support Engineer
Fabric Software
Madrid, España
 
Join Date: Dec 2001
Posts: 679
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-15-2003 at 10:19 PM.
 
Old 10-15-2003, 09:31 PM   #3
skellybobbly
Frequenter
 
skellybobbly's Avatar
portfolio
Jonathan Baker
Animator
United Kingdom
 
Join Date: Oct 2002
Posts: 204
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-16-2003, 02:10 PM   #4
fabman
Anywhere but here..
 
fabman's Avatar
portfolio
Fabian
choqueiro!
from hell
somewhere, España
 
Join Date: Aug 2002
Posts: 201
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-16-2003, 03:52 PM   #5
Reality3D
Veteran
portfolio
Borja Morales
QA & Support Engineer
Fabric Software
Madrid, España
 
Join Date: Dec 2001
Posts: 679
fabman, using dependsOn $objectname you solve the realtime update problem
__________________
Borja Morales
r3D
 
Old 10-16-2003, 07:36 PM   #6
fabman
Anywhere but here..
 
fabman's Avatar
portfolio
Fabian
choqueiro!
from hell
somewhere, España
 
Join Date: Aug 2002
Posts: 201
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-20-2003, 08:46 AM   #7
skellybobbly
Frequenter
 
skellybobbly's Avatar
portfolio
Jonathan Baker
Animator
United Kingdom
 
Join Date: Oct 2002
Posts: 204
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-20-2003, 10:54 PM   #8
Reality3D
Veteran
portfolio
Borja Morales
QA & Support Engineer
Fabric Software
Madrid, España
 
Join Date: Dec 2001
Posts: 679
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-20-2003 at 11:12 PM.
 
Old 10-21-2003, 08:30 AM   #9
skellybobbly
Frequenter
 
skellybobbly's Avatar
portfolio
Jonathan Baker
Animator
United Kingdom
 
Join Date: Oct 2002
Posts: 204
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-16-2006, 09:00 AM   #10
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 04:28 PM.


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