Mouse input window


#41

Hi Paul,

I used a much simpler setup as you, but i used the mousemove property on the rollout to return the position and set the dialog background to the bitmap. Although it simplifies things, it is not better, as I couldn’t get the mouse.state global to work over the rollout (i think you said in a previous post it only works in a viewport) So my version was to trigger it on a keyboard.controlpressed event. This didnt matter, as as soon as you put this rollout in an attribute and assign it to the modify/command panel, it no longer registers the mouse move event. Since i couldnt figure a better way of doing this until your example i was looking into writing a dotnet one. (which Ken has done brilliantly) but in the end, whatever i did is rendered non functioning when placed in an attribute inside the panel. which was why i decided to create the rollout from the character attribute opening and destroy it when the object was deselected. mooo :shrug:

i used your code as a base as i liked your setpixel method.

rollout testImgTag "Test Img Tag" width:100 height:100
  (
  	fn boxControl control:undefined width:0 height:0 pos:[0,0]=
  	(
  		if control!=undefined then
  		(
  		local curBoxControl=undefined
  		local curSliderControlX=undefined
  		local curSliderControlY=undefined
  		local boxControlItVal=[0,0]		
  		local crossCol=(color 255 0 0)
  		local circleCol=(color 0 0 100)
  		local bgCol=(color 100 100 100) 
  		local gridCol=(color 120 120 120) 
  		
  		local gridSpace=25
  			local bm=bitmap width height color:bgCol
  			for h = 0 to height by gridSpace do
  			(
  				for i = 0 to width do (setPixels bm [i,h] #(gridCol))
  			)
  			for w = 0 to width by gridSpace do
  			(
  				for i = 0 to height do (setPixels bm [w,i] #(gridCol))
  			)
  			for i = 0 to width do (setPixels bm [i,pos.y] #(crossCol))
  			for i = 0 to height do (setPixels bm [pos.x,i] #(crossCol))
  			
  			r=10
  			j=pos.x
  			k=pos.y
  			for i = 1 to 360 by 5 do
  			(
  				x=r*cos i + j
  				y=r*sin i + k
  				setPixels bm [x,y] #(circleCol)
  			)
  			
  		
  			SetDialogBitmap testImgTag bm
  			testImgTagVal=pos
  		)
  	)
  	
  	on testImgTag mousemove pos do	
  	(
  		
  		if keyboard.controlpressed do
  		(	
  		format "Mouse Position : %
" pos
  		curBoxControl=testImgTag
  		circleCol=(color 200 0 0)
  		boxControl control:curBoxControl width:curBoxControl.width height:curBoxControl.height pos:Pos
  		)
  		
  	)
  
  	on testImgTag open do
  	(
  		boxControl control:testImgTag width:testImgTag.width height:testImgTag.height pos:[testImgTag.width/2,testImgTag.height/2]
  	)
  	
  )
  createdialog testimgTag
  

anyone know how to get a mousestate into this???


#42

am going away but wanted to update with the progress on a morph slider control - will post it when i get back and can finish it off. it has a node string property so that each slider can affect various objects. this is not a great implementation between dotnet and max, but can be coded into any rollout and is good for specific scenarios. It also has a setkey event too that can be assigned to any max function, as well as all the button states to nudge+1,+5+10 and reset all within the control. I am looking on how to implement a callback to update them.

should mention that it wont be limited to just morph targets, by default the range will be 0-100 but i will add a property to change it to whatever you are doing. Im hoping it will be a fast way of adding functionality via a control without having to code each button.

I was excited to see max 2008 new node event system - it looks very promising for many things, not just dotnet control integration. anyone else used this?

will post more next week!


#43

Wow I haven’t seen Swami’s name hanging around a max forum in a very long time. Wonder what ever happened to him. Last I knew he was getting in to photography.

I’ll poke at using bitmaps to day as well but I think that I’m going to end up with the same problems.


#44

I was thinking of starting a “where is Swami?” thread. delic!!!

Sorry this has been taking so long but I’ve only been able to work on this during my train ride in and back! Just posting an update and a screenshot of the progress of the joystick user control. The colors are a bit gaudy but you get the idea! Still got a couple of bugs i want to iron out before I post the dll as I realised when it was added as an atrribute in the command panel it’s slightly too wide. Also i want to add a property to display a title of what it controls somewhere too. I have set this up with an appropriate MXS function to handle multiple morph target blending, for facial expressions and eye movements. I will also post the slider control i have been working on.

At the moment, there is a panel refresh issue with the controls. After adding them I have to click the create panel and back in order for them to be redrawn (and to be shown). anyone know what might be causing this?


#45

Pete, your screen shot looks very cool, I’m looking forward to seeing the finished version.

I’ve been working on a floating control panel. The Idea being that you can have multiple panels open at the same time for different characters in the scene.

Theres still a lot to do but you get the idea.

There’s also some improvements to the orignal mouse window, with the new dll.
Heres all the source and the new dll


#46

Hi Ken, That looks great!

At the moment i’m using a function that divides the joystick area into 4 quadrants depending on the x and y location. This can then workout which quadrant the cursor is in and blend the targets accordingly. In the future i’m sure this could be handled by the control, but im doing it in MXS for the time being. I’ve added a property to allow the user to interactively and specify a constrain to axis option - this is enabled as a property or by the two small checkbuttons on the bottom of the control.

I too think the floater is a good approach, but IMHO do like to keep character UIs in the modify panel on CA’s. However, I do like your semi-transparent overlay, and a callback could be introduced to initialize the floater to change according to different characters. I assume this is what you are doing! Sometimes we have 6 or seven characters in a scene so would need this to happen.

I am also trying to keep the control compact enough too, sacrificing a little precision in the process but good enough for most circumstances.

I will post code as soon as i have something stable, the control is fine but I just want to resolve the max implementation and give some instructions before i do.


#47

Pete, how are you creating the controls again? A custom dotNet control or using existing controls?


#48

Hi Paul,

My last screenshot is a composite dotNet control. It is formed with a label inside a panel control with some extra function buttons like reset, setkey, nudge value and constrain axis.

I couldn’t get something like this working a: in the command panel or b:with standard controls. :frowning:

however, the function for dividing the control into quadrants for morph handling is the same.


#49

It is a dotNet label? Willing to share a bit of test code just to see the direction that you are going?


#50

Absolutely! its actually using this control that allows you to lock it into the bounds of the parent container -

http://www.codeproject.com/KB/cpp/RuntimeMovableControls.aspx

I am hoping to post the code in the next few days when I iron out a couple of issues. Sorry for the delay!


#51

Ya I look forward to seeing that. Thanks


#52

Thought that I would bring this tread back from the dead.

Here is my current implimentation using “system.windows.forms.pictureBox”. Not sure that I’m going with those built in buttons, looks cool but a popUp menu is easier to use I think. This one works in the command panel and is part of a scripted modifier.


#53

Hi Paul!

Looks cool! what size are you using for those? 25x25?

I hadnt forgotten about this thread, my joystick control was almost ready to post but ive taken on some extra work that is preventing me from finishing it off. I also wanted to post a custom slider control also. so watch this space!

im liking the idea of a scripted mod and had thought about that direction too. you could have a pick button perhaps and choose the object you wanted the joystick to move and this could be stored in the #maxobject as a weak ref to the node. this would be better than before as i was trying to store the node name in the dot net control - not, on reflection the best place for it.


#54

Well I’m having to rethink this. Although I have corrected some of the issues I was seeing when using pictureBox it is slow once I added all the other joy stick controls. I’m comming up on 17 controls and I just isn’t working fast enough. I have a couple of other change I’m going to make first but I don’t think that it will help. The next option will be to have two images, one is the background and the second the target and just move it. I thought it would be cleaner to do it all in one but it isn’t happing. I also tried using the backGroundImage param and then set a target to the image param but I can’t find a way to move it. I’m using pictureBox if you have any ideas.


#55

Oh and the size is 80x80 and the large one is 160 square.


#56

Hi Paul,

Are you overriding the onpaint handler to draw the background grid or just setting the background image property? in my current implementation i’ve got a two label controls embedded in a user control, the background has a custom onpaint handler which draws according to properties on the joystick class. the actual widget that you move is a slightly rehashed moveable label control. as this inherits the label class propeties i have embedded an imagelist with the cursor appearance types. it is then simple to alter the shape of the widget. Since i am using predefined windows brushes for the grid background it is fast. I was worried about the onpaint refresh slowing it down, but it seems acceptable to me with the small test i have been doing. however, im hoping to iron out my last issues with getting feedback from the maxobject to the control and post the results.

I dont know why the picturebox is giving you slowdown issues, i reckon setting the image or backgroundimage property of a picturebox is slower than the onpaint handler of something like a label. The best i can understand it is that using the onpaint method uses a GDI+ graphics class for drawing and is much faster.

This is certainly evident in another dotnet project I have also been working on - I’ve been writing a new RAM player for sequence playback, and have been using GDI+ in order to speed things up. It is currently working about 3-4 times quicker than the one in max to cache frames.


#57

I’m not using on paint, just setting the backGroundImage and Image properties directly. I will look into the on paint and see what I get. It is slow as I’m drawing pixels but I didn’t think that it should be that slow.

I’ll let you know what I find today.


#58

I’m just reading up on the paint event, If I get this right it looks like you can determine where it paints, does this mean I can use it to position a the bitmap that I’m placing in the Image property?


#59

yes - the way the onpaint will work is you pass it the background image and it is converted to a GDI graphics via Graphics.FromImage
then, you draw whatever you want on it (there are many brushes, shapes etc to do this) and then dispose of your resources when done.

this was one example of this but there’s absolutely loads around -
http://www.bobpowell.net/modifyImage.htm

if you want to overlay a bitmap of the cursor you can do this too with a transparent color passed as the background - there is an example here -

http://www.syncfusion.com/faq/windowsforms/faq_c3c.aspx#q657q

one additional option is that you could pass the cursor postion to the onpaint event and that would allow you to draw your overlay at the correct postion. i have used this on my ram player to paint the progress of the sequence load on the bottom of the frame, replacing the need for a progressbar. you can setup a case expression to handle different paint states according to properties of the class you are using.

again, there are quite a few ways of doing this, and this may not be the best for what you are doing but it will certainly be quicker.


#60

In looking through some of that it might just work. Thanks. I will probably get to this next week now, have to deliver the first tests today work work on targets more so I’m going to have to try and speed up the UI once the client complains about it:S