Script Controller

Script Controller

dg3duy
Collaborator Collaborator
910 Views
4 Replies
Message 1 of 5

Script Controller

dg3duy
Collaborator
Collaborator

How do I include it in the variable thegroup??
in the video I make it work because I know what its full name is.

 

group $'*Character_FFD_*' name:(uniquename "Character_Group_FFD_" + "_" +edtDummyName.text) 
 theOne.modifiers[#FFD_2x2x2].Lattice_Transform.controller = transform_script ()

    s =  transform_script ()
    thegroup= $Character_Group_FFD_001_
    		
     s.AddNode "group" thegroup
    		
     str  = stringstream ""
    format "theOne = $% \n" object
    format "inverse group.transform * group.transform" to: str
    		
     s.script = str
    $.modifiers[#FFD_2x2x2].Lattice_Transform.controller = s

controller.gif

0 Likes
Accepted solutions (1)
911 Views
4 Replies
Replies (4)
Message 2 of 5

denisT.MaxDoctor
Advisor
Advisor

No. It won’t work this way. Show the whole code ... What you show as a code, excluding a little part left from mine, does not make sense.

0 Likes
Message 3 of 5

dg3duy
Collaborator
Collaborator
menu_windows = newRolloutFloater "FFD Tool" 180 120
cui.RegisterDialogBar menu_windows  style:#(#cui_dock_all, #cui_floatable, #cui_handles)


rollout ffdDummiesRollout "" width:162 height:120
(
	button btnGo "Create" pos:[8,70] width:144 height:20
	pickbutton btnPickSubject "Pick object" pos:[8,20] width:144 height:20 toolTip:"Choose Object with FFD modifier" autoDisplay:true
	edittext edtDummyName "Name" pos:[8,45] width:144 height:16
	label lbl3 "Object with FFD modifier" pos:[20,0] width:144 height:20 align:#center
	on btnGo pressed do
	(
	
	theOne = btnPickSubject.object
	theMod = undefined
	if (theOne != undefined) then
	(
		for imod = 1 to theOne.modifiers.count do
		(
			mm = theOne.modifiers[imod]
			if isKindOf mm FFD_2x2x2 then theMod = mm
			if isKindOf mm FFD_3x3x3 then theMod = mm
			if isKindOf mm FFD_4x4x4 then theMod = mm
			if isKindOf mm FFDBox   then theMod = mm
			if isKindOf mm FFDCyl   then theMod = mm
		)
	)
	if (theMod == undefined) then
	(
		MessageBox "Pick an object with an FFD modifier first."
		return 0
	)
	
	oldRange  = animationRange
	animationRange = interval 0 10000	
	animateAll theMod
	n = 1
	while isProperty theMod ("control_point_" + n as string) do
	(
		controls = #()
		controls[n] = point3_script()
		posNow = getProperty theMod ("control_point_" + n as string)
		setPropertyController theMod ("control_point_" + n as string) controls[n]
		
		dummies = #()
		dummies[n] = point()
		
		boxmin = getModContextBBoxMin theOne theMod
		boxlen = (getModContextBBoxMax theOne theMod) - boxmin
		posLoc = boxmin + posNow*boxLen
		posGlob = posLoc * theOne.transform
		--format "moving to:%\nh" posGlob
		
		dummies[n].pos = posGlob
		dummies[n].name = uniquename ("Character_FFD_" + edtDummyName.text + "_")
	
		controls[n].AddNode "theOne" theOne
		controls[n].AddNode "theDummy" dummies[n]
		


		

		
		
		st  = stringstream ""
		format "theDummy = $% \n" dummies[n]
		format "theOne = $% \n" theOne
		format "theMod = theOne.modifiers[1]\n" to: st
		--format "dependsOn theDummy\n" to:st
		format "posGlob = theDummy.pos\n" to:st
		format "posLoc  = posGlob * (inverse theOne.transform)\n" to:st
		format "boxMin = getModContextBBoxMin theOne theMod\n" to:st
		format "boxLen = (getModContextBBoxMax theOne theMod) - boxmin\n" to:st
		format "posBox  = (posLoc - boxMin) / boxLen\n" to:st
		
		--print st
		
		controls[n].script = st
		

		n += 1

		
	)
	animationrange = oldrange
	group $'*Character_FFD_*' name:(uniquename "Character_Group_FFD_" + "_" +edtDummyName.text) 
    --theOne.modifiers[1].Lattice_Transform.controller = transform_script ()

	)
)

addRollout ffdDummiesRollout menu_windows
delete objects
s = geosphere radius:10 wirecolor:green
p = point size:40 wirecolor:yellow

m = FFD_2x2x2()
addmodifier s m

c = m.Lattice_Transform.controller = transform_script()
c.addtarget "target" p.controller
c.addobject "node" (NodeTransformMonitor node:s)
c.setexpression "target * inverse node.transform\n"

Your code DenisT works very well assigning it to an object but I can't make it work in a group

0 Likes
Message 4 of 5

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

Thanks for the code. (BTW it looks good).

 

Now about the mxs Group.

Group is a thing, not a node. Technically the Group is a collection of nodes combined by special rules. There are a root node there (head), and its children (members). Head and member are nodes.
So when we say "to put group" into a variable, we should say about putting all members of Group as an array, or a head as a node.

 

delete objects 

pp = #()
for z = -1 to 1 by 2 do
	for y = -1 to 1 by 2 do
		for x = -1 to 1 by 2 do append pp (point name:(uniquename #p numdigits:1) size:20 pos:(10*[x,y,z]) wirecolor:yellow)
	
gr = group pp name:"eight_points"

mm = for node in gr where isgroupmember node collect node	
hh = for node in gr where isgrouphead node collect node	
gh = for node in gr where isgrouphead node do exit with node	

(	
	format "\n"	

	format "(pp) source nodes:\n\t%\n" (for p in pp collect p.name)
	format "(gr) group nodes:\n\t%\n" (for n in gr collect n.name)
	format "(mm) group memebers:\n\t%\n" (for m in mm collect m.name)
	format "(hh) group heads:\n\t%\n" (for h in hh collect h.name)

	format "\n"	

	format "\(gr) group head:\n\t\t%\n" gr
	format "\thead children:\n\t\t%\n" (for n in gr.children collect n)
)	

gr - is the grouphead node variable  

it’s the same as $eight_points

Message 5 of 5

dg3duy
Collaborator
Collaborator

It’s the answer I was looking for, Group is a thing, not a node!

With this information I have the free way to move forward,Thank you! DenisT

0 Likes