Notifications
Clear all

[Closed] Floating animation interface idea

Howdy people.

Im toying with the idea of creating a floating interface to control the animation of an object. Now ive had a quick tinker and just created a spinner in an interface that would move the z value of a dummy up and down.

 
 spn1.startval = 0
 
 spn1startval = 0
 rollout ch1panel "spinnertest"
 megaloop = 1
 
 if megaloop = 1 then 
 (spn1.value=_A_Rig_de_root.pos.x)
 
 
 (
 spinner spn1 "" width:40 range:[-200,10000,0] pos:[15,10]
 
 	on spn1 changed val do 
 	(
 	
 	spn1newval = spn1.value
 	
 	if spn1newval < 0.1 and spn1newval > -0.1 do 
 		(move $dummy01 [0,0,0])
 		
 	if spn1newval  > spn1startval do 
 		(move $dummy01 [0,0,0.1])
 		
 	if spn1newval < spn1startval do 
 		(move $dummy01 [0,0,-0.1])
 	
 	spn1startval = spn1newval 
 	(
 
 )
 )
 
 )
 
 myfloater = (newRolloutFloater "spinnertest" 195 100
 )
 
 addRollout ch1panel myfloater
 
  

Now ok that can move and object for me but is there any way that i can get the spinner value to update when i change the keyframe so that it shows an accurate value for the z axis of the dummy and would it be posible to show that that value is keyed on the current frame.

Cheers

Rob

7 Replies

You can create a link between the spinner and controller by setting the spinner’s ‘controller’ property:

spinner spn1 "" controller:$Dummy01.position.controller[3].controller

This assumes the dummy has a PositionXYZ controller.

Edit: Forgot to add, set the .setKeyBrackets property to true to have the spinner show the red brackets on keyframes.

Martijn

ok cool that does the job thanks.

On another point I want to have prefix name that can change once and then replicated throught the script. So

character_name = John_

select $ character_name dummy01

but i dont know the correct format of inserting the charcter_name varible into a selection of an object.

If I understood you correctly,
you don’t need the object name, you can store the node itself in a variable.
Example:


(
local newObject = $Dummy01
print newObject.name
select newObject
)

I have scripts that builds a rig for me and i want to work on an interface for it.
So lets say one spinner in the interface controls the x rotation of John_Bone_upperarm, but then i create a Jane character so on her rig that X rotation i want to control is on Jane_Bone_upperarm.

So in in Character Johns interface there would be a bunch of controls for all the bone and Janes interface and rig is the same the only difference is that they have a different prefix charcter name on each object.

So i was to be able to set the prefix name once and then have it placed in all the parts of the script that need the prefix name.

eg

Prefix name = John

select $ prefix name _bone_upperarm

so i can select John_bone_upperarm

or if i change prefix name to Jane it will select Jane_bone_upperarm

So if now I understood you correct, what I think you should do is
you should have an interface that lets you select a character name out
of a name list (like a dropDownList for instance).
Then you need a function that finds the correct object for every controller.


  rollout roTest "Test"
  (
  -- Local Variable Declerations
  ------------------------------------------
  
  	local upperArmL = undefined
  	local upperArmR = undefined
  	
  -- User Interface
  ------------------------------------------
  
  	dropDownList ddlNames "Characters:" items:#("John","Jane")
  	
  -- Functions
  ------------------------------------------
  	
  	fn getObj prefix name =
  	(
  		local obj = undefined
  		for i in objects do (
  			if i.name == prefix + name then obj = i
  		)
  		obj
  	)
  	
  	fn openDialog =
  	(
  		createDialog roTest width:200
  	)
  	
  	fn init =
  	(
  		upperArmL = getObj ddlNames.selected "_bone_upperarm_L"
  		upperArmR = getObj ddlNames.selected "_bone_upperarm_R"
  	)
  
  -- Event Handlers
  ------------------------------------------
  
  	on ddlNames selected itm do init()
  	on roTest open do init()
  
  ) -- end of rollout
  roTest.openDialog()
  

But if you are working with large scenes, the init function can get pretty slow.
So to make it faster you can save your objects in an array and another array for the
name and then write the getObj function to work with array values so that you would
cover all of the objects in one loop.

In this case I would also suggest to organize everything in a struct.

To find a scene object by name, use getNodeByName. Check the manual for more info about this function.

Martijn

Thanks Magicm just had a look at getNodeByName. and i can uses that for what i want to do.

Also thanks TzMtN for the input.

Cheers

Rob