controling Springs (global xSpringArray) ??

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
  06 June 2008
controling Springs (global xSpringArray) ??

iīm tring to collect all springs in the scene to make quick changes using ONe Float :

 rollout Make_sp "Ctrl Springs" width:120 height:300 
   
  (
  spinner spMass "mass:" range:[0,100,0] offset:[-20,5,0] fieldwidth:60 type:#integer
  spinner spDrag "drag:" range:[0,10,0] offset:[-20,5,0] fieldwidth:60 type:#integer
  spinner spX "X_effect:" range:[0,100,0] offset:[-20,5,0] fieldwidth:60 type:#integer
  spinner spY "Y_effect:" range:[0,100,0] offset:[-20,5,0] fieldwidth:60 type:#integer
  spinner spZ "Z_effect:" range:[0,100,0] offset:[-20,5,0] fieldwidth:60 type:#integer
  
  		on spMass changed val do
  		(
  			global xSpringArray = getClassInstances SpringPositionController
  			xSpringArray.setMass (spMass)
  		)
  		
  		on spDrag changed val do
  		(
  			global xSpringArray = getClassInstances SpringPositionController
  			xSpringArray.setDrag (spDrag)
  		)
  
  		on spX changed val do
  		(
  			global xSpringArray = getClassInstances SpringPositionController
  			xSpringArray.x_effect = spX
  		)
  		on spY changed val do
  		(
  			global xSpringArray = getClassInstances SpringPositionController
  			xSpringArray.y_effect = spY
  		)
  
  		on spZ changed val do
  		(
  			global xSpringArray = getClassInstances SpringPositionController
  			xSpringArray.z_effect = spZ
  		)
  
  )
  Make_springsFloater  = newRolloutFloater "Springs" 210 220 
  addRollout Make_sp Make_springsFloater
  


error :
>> MAXScript Rollout Handler Exception: -- Unable to convert: SpinnerControl:spY to type: Float <<


anyone have a better idea ?

please,
help...
__________________
Website
Twitter
Facebook
Google+
 
  06 June 2008
just a better idea

i think itīs better to play with numbers first and after that you hit the button to make changes :


     rollout TS "Springs" width:200 height:100
   (
   label LabS "Springs:" offset:[-30,0,0] width:96 height:16
   button BtnOn "On" offset:[-20,-20,0] width:30 height:20
   button BtnOff "Off" offset:[15,-25,0] width:30 height:20
   editText edtStatus "" offset:[120,-20,0] fieldwidth:50 readOnly:on
   button btn1 "Ajust Now" offset:[0,0,0] width:176 height:23
   	spinner spDrag "Drag:" range:[0,10,0] offset:[0,2,0] fieldwidth:50 type:#integer
   	spinner spMass "Mass:" range:[0,2000,0] offset:[0,2,0] fieldwidth:50 type:#integer
   	spinner spX "X_effect:" range:[0,100,0] offset:[0,2,0] fieldwidth:50 type:#integer
   	spinner spY "Y_effect:" range:[0,100,0] offset:[0,2,0] fieldwidth:50 type:#integer
   	spinner spZ "Z_effect:" range:[0,100,0] offset:[0,2,0] fieldwidth:50 type:#integer
   
   on BtnOn pressed do
   	(
   	global xSpringArray = getClass SpringPositionController
   	xSpringArray.Steps = 2
   	btnON.enabled = off
   	btnOff.enabled = on
   	edtStatus.text = "On"
   	)
   on BtnOff pressed do
   	(
   	global xSpringArray = getClass SpringPositionController
   	xSpringArray.Steps = 0
   	btnOff.enabled = off
   	btnon.enabled = on
   	edtStatus.text = "Off"
   	)
   --on btn1 pressed do -- here some problem
   --	(
   
   on spMass changed val do
   		(
   		global xSpringArray = getClass SpringPositionController
   		xSpringArray.setMass (spMass)
   		)
   		
   on spDrag changed val do
   		(
   		global xSpringArray = getClass SpringPositionController
   		xSpringArray.setDrag (spDrag)
   		)
   
   on spX changed val do
   		(
   		global xSpringArray = getClass SpringPositionController
   		xSpringArray.x_effect = spX
   		)
   on spY changed val do
   		(
   		global xSpringArray = getClass SpringPositionController
   		xSpringArray.y_effect = spY
   		)
   
   on spZ changed val do
   		(
   		global xSpringArray = getClass SpringPositionController
   		xSpringArray.z_effect = spZ
   		)
   --	)
   )
   TSFloater = newRolloutFloater "Springs" 210 120
   addRollout TS TSFloater
   
some problems:

1- donīt know how to implement script to the AJUST button.....

2- spinners doesnīt work either....


3- from Help:
<float>getMass()
<void>setMass <float>mass

<float>
getDrag()
<void>setDrag <float>drag


little test :

     $.pos.controller.spring.controller.setMass 800
     $.pos.controller.spring.controller.setdrag 8
    
     Listener
     OK
     OK
     



 for i = 1 to (selection.count) do
 		(
 		Sel = selection
 		seL.pos.controller.spring.controller.setMass 400
 		seL.pos.controller.spring.controller.setdrag 4
 		seL.pos.controller.spring.controller.x_effect = 70
 		seL.pos.controller.spring.controller.y_effect = 70
 		seL.pos.controller.spring.controller.z_effect = 70
 		seL.pos.controller.spring.controller.steps = 1
 		)
 


*
far as i know, even looking in wire parameter, tracks bar, controller window, etc,
you canīt accsess options like [i]"MASS, DRAG, STEPS, ABS/RELATIVE"
........
( correct me if iīm wrong)....

help, PLEASE.
__________________
Website
Twitter
Facebook
Google+

Last edited by Polimeno : 06 June 2008 at 07:50 PM.
 
  06 June 2008
Here is a good start for you,
I took your general idea, which is a good one by the way,
and built a demo for it in a few minutes, I hope this is ok..

    try destroyDialog springsControl catch ()
    rollout springsControl "Sphere Test"
    (
    -- Local Variable Declerations
    ------------------------------------------
    	
    	local sprArr = #()
    
    -- User Interface
    ------------------------------------------
    	
    	editText etNumSprings "" readOnly:on
    	spinner spDrag "Drag:" range:[0,10,0] align:#right fieldwidth:50 type:#integer
    	checkButton cbOnOff "Turn OFF" checked:on
    	
    -- Functions
    ------------------------------------------
    	
    	fn updateUI =
    	(
    		sprArr = getClassInstances SpringPositionController
    		local n = sprArr.count
    		etNumSprings.text = (n as string) + " Springs found"
    		if n > 0 then (
    			spDrag.value = sprArr[1].spring.getDrag()
    			cbOnOff.checked = sprArr[1].steps != 0
    			cbOnOff.text = if cbOnOff.checked then "Turn OFF" else "Turn ON" 
    		)
    	)
    	
    	fn setDrag val =
    	(
    		for s in sprArr do (
    			s.spring.setDrag val
    		)
    	)
    	
    	fn turnOnOff state =
    	(
    		for s in sprArr do (
    			s.steps = if state then 2 else 0
    		)
    		updateUI()
    	)
    	
    	fn openDialog =
    	(
    		createDialog springsControl width:130
    	)
    	
    	fn init =
    	(
    		updateUI()
    	)
    
    	fn done =
    	(
    		-- cleanup code
    		gc light:true
    	)
    
    -- Event Handlers
    ------------------------------------------
    	
    	on spDrag changed val do setDrag val
    	on cbOnOff changed state do turnOnOff state
    	
    	on springsControl open do init()
    	on springsControl close do done()
    
    ) -- end of rollout
    
    springsControl.openDialog()
    


In the same way, you can add the rest of the buttons you need.
but I would suggest building a tablet (using Active X or Dot net or what ever)
showing all of the springs in the scene, so that you can choose which springs to adjust, and have subs for Iterations, Drag, Mass etc..

Last edited by MatanH : 06 June 2008 at 09:16 PM.
 
  06 June 2008
really cool !

testing it :

 
 try destroyDialog springsControl catch ()
   rollout springsControl "Spring Ctrl"
   (
   -- Local Variable Declerations
   ------------------------------------------
 
 	  local sprArr = #()
   
   -- User Interface
   ------------------------------------------
 	  
 	  editText etNumSprings "" offset:[-10,0,0] fieldwidth:120 readOnly:on
 	  spinner spDrag "Drag:" range:[0,10,0] align:#right fieldwidth:50 type:#integer
 	  spinner spMass "Mass:" range:[0,1000,0] align:#right fieldwidth:50 type:#integer
 	  spinner spX "X_effect:" range:[0,100,0] align:#right fieldwidth:50 type:#integer
 --	  spinner spY "Y_effect:" range:[0,100,0] align:#right fieldwidth:50 type:#integer
   --	spinner spZ "Z_effect:" range:[0,100,0] align:#right fieldwidth:50 type:#integer
 	  checkButton cbOnOff "Turn OFF" checked:on tooltip: "On/Off Springs"
 	  
   -- Functions
   ------------------------------------------
 	  
 	  fn updateUI =
 	  (
 		  sprArr = getClassInstances SpringPositionController
 		  local n = sprArr.count
 		  etNumSprings.text = (n as string) + " Springs found"
 		  if n > 0 then 
 		(
 			  spDrag.value = sprArr[1].spring.getDrag()
 			spMass.value = sprArr[1].spring.getMass()
 			------------------------------------------------ MY PROBLEM
 			spX.value = sprArr[1].spring.x_effect
 			------------------------------------------------ MY PROBLEM
 			cbOnOff.checked = sprArr[1].steps != 0
 			  cbOnOff.text = if cbOnOff.checked then "Turn OFF" else "Turn ON" 
 		  )
 	  )
 	  
 	  fn setDrag val =
 	  (
 		  for s in sprArr do 
 		(
 		  s.spring.setDrag val
 		  )
 	  )
 	
 	fn setMass val =
 	(
 		for s in sprArr do
 		(
 		s.spring.setMass val
 		)
 	)
 
 ------------------------------------------------ MY PROBLEM
 	fn Xeff val =
 	(
 		for s in sprArr do
 		(
 		s.spring.x_effect
 		)
 	)
 
 ------------------------------------------------ MY PROBLEM
 
 
 	  fn turnOnOff state =
 	  (
 		  for s in sprArr do (
 			  s.steps = if state then 2 else 0
 		  )
 		  updateUI()
 	  )
 	  
 	  fn openDialog =
 	  (
 		  createDialog springsControl width:130
 	  )
 	  
 	  fn init =
 	  (
 		  updateUI()
 	  )
   
 	  fn done =
 	  (
 		  -- cleanup code
 		  gc light:true
 	  )
   
   -- Event Handlers
   ------------------------------------------
 	  
 	  on spDrag changed val do setDrag val
 	on spMass changed val do setMass val
 	  on cbOnOff changed state do turnOnOff state
 	------------------------------------------------ MY PROBLEM
 	on spX changed val do Xeff val
 	------------------------------------------------ MY PROBLEM
 	on springsControl open do init()
 	  on springsControl close do done()
   
   ) -- end of rollout
   
   springsControl.openDialog()
   
 



but iīm having troubles with spinners, i donīt know how deal with it......

error :
>> MAXScript Rollout Handler Exception: -- Unknown property: "x_effect" in <MixinInterface:Spring> <<
__________________
Website
Twitter
Facebook
Google+
 
  06 June 2008
if you look in the maxscript help file you will see that parameters like
Steps, x_effect, y_effect, z_effect and position are available directly on the controller
so in your rollout you can access them by calling one of the controllers inside the
sprArr array and adding them afterwards, like in this example:
sprArr[1].y_effect = 1

Other parameters of the spring cannot be accessed directly but can be changed using
functions that are available in an interface called Spring.
So to access them you need to add the spring interface between the controller and the function, like so:
sprArr[1].spring.setMass 5

As you can see, I haven't added the '=' sign in between the function and the value 5
because its just like calling any other function in maxScript where you declare the function
name first and then add the parameters if there are any or a () if there are none.

Hope this is clear enough,
Matan.
 
  06 June 2008
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 07:41 PM.


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