Notifications
Clear all

[Closed] Scale/Rotate a child around the parents pivot point???

I’ve narrowed it down to the fact that its the second on…do thats causing the problem…I get the error on the second one, no matter which one it is…I’ve tried swapping them…

Weird…


try(destroyDialog testAlign)catch()
(
local tmSpace = undefined
local objSpace = undefined

rollout testAlign
(
pickbutton pickPivot "Pick Pivot" autodisplay:true
Spinner rotX "X:" range:[-180,180,0]
on pickPivot picked obj do
(
tmSpace = selection[1].transform * inverse obj.transform
objSpace = obj
)
on rotX changed val do
	if tmSpace != undefined do
		selection[1].transform = tmSpace * ((eulerangles val 0 0) as matrix3) * objSpace.transform
)
createDialog testAlign
)

Figured it out…It was the rollout not having a name in quotes…I gave it a string name and it worked…dang…

I’m having a hard time understanding which pieces your referring to in your description…Tried to adapt your script to handled arbitrary point scaling as well, and its doing nothing Sorry…what am I missing?


try(destroyDialog testAlign)catch()
(
local tmRotSpace = undefined
local tmSpace = undefined
local objSpace = undefined

rollout testAlign "Test Rotation"
(
pickbutton pickPivot "Pick Pivot" autodisplay:true
Spinner rotX "X:" range:[-180,180,0]
Spinner rotScale "Scale:" range:[0, 1, 1]
on pickPivot picked obj do
(
tmRotSpace = selection[1].transform * inverse obj.transform
tmSpace = obj.transform * selection[1].transform
objSpace = obj
)
on rotX changed val do
	if tmRotSpace != undefined do
		selection[1].transform = tmRotSpace * ((eulerangles val 0 0) as matrix3) * objSpace.transform
)
on rotScale changed val do
	if tmSpace != undefined do
		selection[1].transform = tmSpace * (objSpace.transform * val)
createDialog testAlign
)

 eek

an example:

[size=1]

[color=#0000ff][size=2]

[color=#fffffe]try(destroyDialog testAlign)catch()

rollout testAlign “testAlign”
(
local theObj = undefined
local theTarget = undefined
local theTm = undefined

pickButton pickObj “Pick Object” width:135 across:2
pickButton pickTarget “Pick Target” width:135
editText debug “Transform Stored: ” align:#left
spinner scaleTrans “Scale Transform” range:[-100,100,1.0] type:#float width:100 align:#left

on pickObj picked obj do
(
theObj = obj
pickObj.text = obj.name
)

on pickTarget picked obj do
(
[indent]if theObj != undefined do
(
theTm = theObj.transform * inverse obj.transform
theTarget = obj
pickTarget.text = obj.name
debug.text = theTarget as string
)
)
[/indent]

on scaleTrans changed val do
(
theObj.pos = (theTm * theTarget.transform).pos * val + theTarget.pos
)

)

createDialog testAlign 300 100

[/color][/size][/color][/size]

Ohhh…I see what thats doing…The rotate script is exactly what I’m looking for, but the scale one is only scaling the transform, its not scaling the geometry itself…

the actual geometry should also be shrinking, but relative to the targets pivot point…Its kinda hard to explain I guess. Its kinda like what happens when you create a sphere, and scale it on its own pivot, it shrinks in place…but if you go in and move the sphere’s pivot point, and then scale it, its going to shrink the same amount but its going to shrink towards that pivot point as well. Know what I mean? I’m thinking at some point in this script, once a transform difference is determined, an actual geometry scaling is going to need to occur.

Here’s what I’m doing to geometry.


tmesh = snapshotAsMesh allobj[i]

if ScaleConv.state == true then
(
	scale tmesh [.0254,.0254,.0254]
)
if RotXNeg90.state == true then
(
	rotate tmesh (eulerangles -90 0 0)
)

This works great because all my geometry has a pivot point of 0,0,0…but the manual pivots I’m placing also need to be scaled (and rotated) as if their pivots were 0,0,0…BUT their actual pivot point should go with them…so the final pivot point of the manual pivot helper should be its location after the scale and rotate around the 0,0,0…Confusing I know.

 eek

You’ll then need to scale the verts positionally relative to the objects pivot relative to its space.

theObjVerts = #()

for v = 1 to theObj.verts.count do
(
append theObjVerts (theObj.verts[v].pos – theObj.transform.pos)
)

on scalTrans changed val do
(
for v = 1 to theObjVerts.count do
(
theObj.verts[v].pos = theObj.pos + (theObjVerts[v] * val)
)
)

something like this.

Thanks much eek! I’ve gotten it to do what I need now You’re awesome!

Page 2 / 2