[Closed] Mouse input window
Spinner Controls…
http://forums.cgsociety.org/attachment.php?attachmentid=120992&stc=1
I’ve created this face rigging tool (above) which allows the user to pose a bunch of bones, the dial up that pose using a spinner. The poses can be blended together and what you end with is something like a morph controller interface.
What I’d like to do is replace the spinners (which only accept input on 1 axis) to a mouse input window (which accepts inputs on 2 axis) (see below). Ie click and drag the dot around the white box. This would be a much nicer interface for animators, and would allow me to cram more poses onto one control.
This kind of windowed control does not exist in maxscript. I believe it’s possible to do this kind of thing with activeX but I’ve no experience in creating them. Can anyone point me in the right direction i.e. could I create such a control using say flash and embed it a max dialog?
(I know i could create this kind of control using shapes and wire-parameters but I really want to keep all the animation controls in a floating dialog box…)
If people are interested theres a version of the script on my site.
Mouse input control
http://forums.cgsociety.org/attachment.php?attachmentid=120993&stc=1
I have no experience with dot net controls, so the answer may lie there, but you can do this in maxScript using a custom bitmap. Look at the how to… develop a bitmap painting tool. I’ve done something similar in the past, but abandoned it in favor of real max objects that float in front of the face. Yes, the spinners suck (we even tried scripted manipulators which were worse). The advantage to using boxes was that you could use the basic max functionality like selecting multiple objects at once and dragging or using the transform type-in or using the align tool.
Thanks focomoso. I went throught the tutorial and I’ve come up with this test control. Interestingly (although I’ve yet to try it out) using this method it would be possible to load up the control with different functions if ‘control’, ‘alt’ , or ‘shift’ are pressed whilst moving the mouse…
Just left click and drag in the window
try(destroyDialog TestRoll)catch()
Rollout TestRoll "test"
(
local size = 200
Label lblX
Label lblY
Label lblK
Label lblCross "+" pos: [(size/2)-3,(size/2)-7]
Local followMouse = false
fn moveCross pos =
(
p = [pos.x-3,pos.y-7]
lblCross.pos = p
)
fn reportXY pos =
(
lblX.text = pos.x as string
lblY.text = pos.Y as string
lblk.text = if keyboard.controlPressed then "ctrl" else ""
moveCross pos
)
on TestRoll lbuttondown pos do
(
followMouse = true
setSysCur #select
reportXY pos
)
on TestRoll lbuttonup pos do followMouse = false
on testRoll mousemove pos do
(
if followMouse do reportXY pos
)
on TestRoll Rbuttondown pos do
(
followMouse = false
)
)
createDialog TestRoll 200 200
my max is tied up in a big render right now, but I’ll give this a shot tonight.
I’ve written my own mouse control in c#.
It has many advantages over using the Maxscript only method I posted previously
You can grab the dll from my site
http://www.designimage.co.uk/Max/files/MouseControl/AnimControl.dll
I’ll keep it upto date as i make changes
Put the AnimControl.dll in your scripts directory
The sample code shows various methods to use the control.
Eventually I’ll write a maxscript rollout to manage multiple floating Mouse windows
fn MyPos a b =
(
format "pos: %, %
" b.x b.y
)
assemblyFileName = ((getdir #scripts) as string + "/AnimControl.dll")
-- Load the class library created
dotnet.LoadAssembly assemblyFileName
hForm = dotNetObject "AnimControl.MouseWindow"
dotNet.addEventHandler hForm "PosEvent" MyPos
hForm.show()
hform.ctrl.SetX 0 0 --sets the x position of the cross in the window
hform.ctrl.SetY 0 0 --sets the y position of the cross in the window
It’s a cool control. I tried to use it in a rollout as a dotNetControl but I didn’t succeed.
Does this control is a regular .NET custom control or just a .NET form ?
A custom control is the best solution because we can use it in a MAXScript rollout and it will be integrated in Max in a more consistent manner.
At the moment it’s a dot Net form, because thats what i wanted for my design.
I think it would be pretty easy to make it into a custom control. I was thinking of doing it when I get time after my current project.
I could give you the C# code … but it’s my first time with C# so its a bit messy… and probally neads a bit of a rewrite first.
You can also use the imgTag for this. It has several event handlers that can be called and you can supply an image that you can track under the mouse if you are a bit clever with it.
I put together an example for you
try(destroyDialog testImgTag)catch()
rollout testImgTag "Test Img Tag" width:220
(
local currentControl=undefined
imgTag mouseTracker "MouseTracker" \
height:200 width:200 bitMap:undefined
timer mouseTime interval:200
fn createBitMap control:undefined width:0 height:0 pos:[0,0]=
(
if control!=undefined then
(
crossCol=(color 255 0 0)
bm=bitmap width height color:(color 255 255 255)
for i = 0 to width do (setPixels bm [i,pos.y] #(crossCol))
for i = 0 to height do (setPixels bm [pos.x,i] #(crossCol))
control.bitmap=bm
)
)
on mouseTracker lbuttondown pos flag do (currentControl=mouseTracker)
on mouseTracker lbuttonup pos flag do (currentControl=undefined;gc light:true)
on mouseTracker mouseout do (currentControl=undefined;gc light:true)
on mouseTime tick do
(
if currentControl!=undefined then
(
newPos=(mouse.pos-(GetDialogPos testImgTag)-currentControl.pos+[0,58])
createBitMap control:currentControl width:currentControl.width height:currentControl.height pos:newPos
)
)
on testImgTag open do
(
createBitMap control:mouseTracker width:mouseTracker.width height:mouseTracker.height
)
)
createDialog testImgTag