PDA

View Full Version : Scripted manipulators questions.


JHN
11-10-2009, 11:34 AM
Hi guys, (especially waves at Bobo)

After watching some great tutorials by Bobo on manipulators, I decided to use them for my next project as "turbo" helper objects, using the manip mode for different types of operations on the manipulator.

One problem I'm running into is that when I select a manipulator and want to focus on it (pressing Z) if centers the view as if nothing was selected, I have created a gizmoMesh and shape in the updateGizmos handler, so there is geometry in the viewport, and the pivot is also somewhere away from the grid.

Another problem I have is with updating shapes


local giz = manip.makeCircle [0,0,0] ringSize 24
giz.transform (matrix3 1)
this.addGizmoShape giz flags (orange/255.) (blue/255.)


The "ringSize" variable is defined in the paramblock and can be changed with a spinner. Now updating it results in 2 rings, one with the original size and one with the changed size. Why? Probably I'm doing something wrong, but I have a "this.clearGizmos()" defined straight below the handler...

-Johan

Polimeno
11-10-2009, 11:48 AM
are you using it inside on updateGizmo handler ? e.g


on updateGizmos do
(
this.clearGizmos()
..... rest of your code....
)


maybe if you post more of your code could be better to help.

http://forums.cgsociety.org/showpost.php?p=6187848&postcount=10

JHN
11-10-2009, 12:10 PM
Yes, that's how I'm doing it. I'm desecting Bobo's scripts that come with the tutorials.

I did fix the double drawing, I did not declare the flags properly... which are a real strange concept in maxscript... why do you need to declare it like they are global variables, but they seem to only exist in the manip scope....

Still the focusing problem exists and I'm very afraid it's not something that can be fixed...

-Johan

Polimeno
11-10-2009, 12:21 PM
could you post some screen of the problem ?

JHN
11-10-2009, 01:06 PM
Yes,

Here's a stripped down version. Evaluate, in helpers\JHN FaceManip.
Place it anywhere in the scene and focus on it, you'll see you can't.


plugin simpleManipulator JHN_FaceManipulator
name:"FaceManip"
classID:#(0x42ba540e, 0x53e5cf50)
category:"JHN"
(
fn getMe = (for o in (refs.dependentNodes this) where isKindOf o JHN_FaceManipulator collect o)[1]

parameters main rollout:paramRollout
(
ringSize type:#float animatable:true default:2.0 ui:spnSize
)

rollout paramRollout "Setup"
(

group "temp"
(
spinner spnSize "Size"
)
)

on canManipulate target return isKindOf target JHN_FaceManipulator

tool create
(
on mousePoint click do
case click of
(
1:
(
theTM = matrix3 1
theTM.row4 = gridPoint
nodeTM = theTM

#stop
)
2: #stop
)
on mouseMove click do
(
case click of
(
2: (

)
)
)
)

on updateGizmos do
(
this.clearGizmos()

local flags = gizmoActiveViewportOnly
local flags2 = gizmoUseScreenSpace + gizmoActiveViewportOnly + GizmoDontHitTest

local giz = manip.makeCircle [0,0,0] ringSize 24
-- giz.transform (matrix3 1)
giz.transform (transMatrix [0,0,ringSize])
this.addGizmoShape giz flags (orange/255.) (blue/255.)

local gizSphere = manip.makeSphere [0,0,0] ringSize 24
-- gizSphere.transform (transMatrix [0,0,ringSize])
this.addGizmoMesh gizSphere flags (orange/255.) (blue/255.)

this.addGizmoText ("hello") [0,0,0] flags (yellow/255.) (blue/255.)

return "Click to reset"
)

on mouseMove m which do
(

)

on mouseDown m which do
(

)
)


Attached the file, if any line break offs occur on the forum.

Also I see the double drawing occuring again too, do you? You have to be in manipulate mode.

Thanks,
-Johan

denisT
11-10-2009, 02:35 PM
to fix double-drawing add the piece of code to updateGizmo:


...
on updateGizmos do
(
if (target != undefined) do
(
this.ringSize = target.ringSize
)
...
)

JHN
11-10-2009, 03:09 PM
Ah yes, I see how that makes sense, manipulate is some sort of global mode for everything that can manipulate, the manip object has to check if it's him that's being manipulated, so we have to pass the values from the target to the self params.

Now if I could only focus/center on the object, I'd be very happy!

-Johan

Polimeno
11-10-2009, 03:42 PM
Now if I could only focus/center on the object, I'd be very happy!

-Johan

unfortunately i have the same problem here...
canīt say why this thing happen, but would be great if anyone could tell us the workaround...

JHN
11-10-2009, 04:14 PM
Yes, I'm suspecting it's inherit to a scripted manipulator, all other examples I have found and tested behave the same. I think it's a design issue spawned by the idea that most manipulators would live in screenspace instead of 3dspace... preferably we should have a switch/property to set it's behaviour.

Thanks,

-Johan

denisT
11-10-2009, 05:13 PM
Scripted manipulators were designed to support manipulations of parameters of other nodes.

The extents of a manipulator is ignored by default when performing a zoom extents.



There is a workaround. You can write "helper" plugin extending for example "point" helper (you can set all display parameters of the point to OFF to make its gizmo invisible). The manipulator will manipulate only your class changing scale of the node to fit bbox of the manipulator. If you set invisible for the manipulator to ON it will not be visible as a node in the scene. But the "helper" will be visible and it will react to zoom properly. Also you can lock scale parameters for the node to protect them from editing using max UI (it stays editable with using other scripts)

JHN
11-11-2009, 09:03 PM
Hi Denis,

Yeah I already came to the same conclusion and have converted my manipulator to a plugin extending and hiding a dummy object. And maybe I will use the manipulator to add extra functionality to it.
What attracted me was the simple way you can make a custom geometry object for a manipulator. With a scripted plugin it has to be a mesh and it won't show up shaded, only wireframe, but the zoom extends are more important. Also if I want to transform the mesh I have to rebuild it... which in manipulators was sooo easy to do, I'm not that strong on mesh manipulation.

So most parts work as I want now, so thanks!

-Johan

Wheiraucher
11-13-2009, 11:44 AM
dumb question, but where can i watch/download/buy the Bobo masterclass on scripted manipulators???

JHN
11-13-2009, 12:01 PM
If you're on subscription, you can find them in the training materials. Otherwise, I don't think they're available anywhere...

-Johan

Wheiraucher
11-13-2009, 12:11 PM
you mean the 3dsmax subscription? yeah i don't have that. And there's no other ressource?

CGTalk Moderation
11-13-2009, 12:11 PM
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.