Wow. Almost Ten months of inactivity and two posts within a few hours!
So, recently I finished up a first pass on a GUI idea I've had for a while (though it's mainly a 'picker' at the moment).
I initially did a few prototypes using maxscript, with the dot net wrappers, and also plain c# winforms. However, I could not, easily, achieve some key features I wanted. Or, lets say, they were messier to manage when implementing these features.
Mainly I wanted the ability to pan and zoom around. Scale and pan functionality would allow me to really fill a gui 'page' with lots of stuff. From there the user can zoom and focus in to the area they are interested in, fingers for example. Out of the 3, WPF definitely handled 'transforming' ui elements the best.
I also wanted to be able to create and edit gui layouts inside the tool window, being able to lay out new button and edit existing ones as needed, even by an animator.
So here's what I ended up with:
So, recently I finished up a first pass on a GUI idea I've had for a while (though it's mainly a 'picker' at the moment).
I initially did a few prototypes using maxscript, with the dot net wrappers, and also plain c# winforms. However, I could not, easily, achieve some key features I wanted. Or, lets say, they were messier to manage when implementing these features.
Mainly I wanted the ability to pan and zoom around. Scale and pan functionality would allow me to really fill a gui 'page' with lots of stuff. From there the user can zoom and focus in to the area they are interested in, fingers for example. Out of the 3, WPF definitely handled 'transforming' ui elements the best.
I also wanted to be able to create and edit gui layouts inside the tool window, being able to lay out new button and edit existing ones as needed, even by an animator.
So here's what I ended up with:
In the video I'm using a default Cat Ape rig as an example, then creating and associating nodes with the gui form.
To achieve this I used WPF for the window and buttons layout code. In fact it is all done in c#, using the .Net api to handle the Max node selections and some callbacks.
WPF uses lovely vector graphics to draw its ui elements so the implementation of my zoom functionality works pretty well, other than the background image looking pixelated when zoomed right in!
For the 'Editing Mode' I had to implement a custom property on a class inherited from a Canvas. I had originally tried to manipulate an InkCanvas to my will, as it already has an 'Editing Mode' and the ability to move and manipulate child UI Elements. However, there were some drawing and selection issues with that that didn't fit what I wanted.
I was dubious about the complexity on managing a 'state' like this across the drawing elements manually, as this was my first forray into WPF. It worked out pretty well in the end. Implementing it this way allowed me to control the mode changes with all the granularity I needed, and it wasn't that much work.
Again, I used the .Net api for the selection, callbacks and all max scene needs. I did, originally, plan on using maxscript for the max side stuff and exposing events through c#, then hooking them up on the other end, as outlined in this document. However, that code looked a bit messy, management wise, and didn't look like it would scale well. I really wanted to keep it all together and clean.
After some searching, digging and trial and error I managed to get what I needed from max's .Net dll's.
Now, it should be noted I am not doing anything fancy with the .Net API here. Mostly, I'm re-cursing the scene tree, grabbed from the Autodesk.Max.IInterface13.COREInterface13 instance, and collecting the IINodes I need. Once I have the IINodes selecting and deselecting becomes very easy.
It was a huge win to have everything in one project and codebase!
To achieve this I used WPF for the window and buttons layout code. In fact it is all done in c#, using the .Net api to handle the Max node selections and some callbacks.
WPF uses lovely vector graphics to draw its ui elements so the implementation of my zoom functionality works pretty well, other than the background image looking pixelated when zoomed right in!
For the 'Editing Mode' I had to implement a custom property on a class inherited from a Canvas. I had originally tried to manipulate an InkCanvas to my will, as it already has an 'Editing Mode' and the ability to move and manipulate child UI Elements. However, there were some drawing and selection issues with that that didn't fit what I wanted.
I was dubious about the complexity on managing a 'state' like this across the drawing elements manually, as this was my first forray into WPF. It worked out pretty well in the end. Implementing it this way allowed me to control the mode changes with all the granularity I needed, and it wasn't that much work.
Again, I used the .Net api for the selection, callbacks and all max scene needs. I did, originally, plan on using maxscript for the max side stuff and exposing events through c#, then hooking them up on the other end, as outlined in this document. However, that code looked a bit messy, management wise, and didn't look like it would scale well. I really wanted to keep it all together and clean.
After some searching, digging and trial and error I managed to get what I needed from max's .Net dll's.
Now, it should be noted I am not doing anything fancy with the .Net API here. Mostly, I'm re-cursing the scene tree, grabbed from the Autodesk.Max.IInterface13.COREInterface13 instance, and collecting the IINodes I need. Once I have the IINodes selecting and deselecting becomes very easy.
It was a huge win to have everything in one project and codebase!
I inherited the ui elements I needed from basic WPF classes; buttons, canvas, tabs, etc, in to custom classes that simply add some properties and methods that store IINodes and manage the lists of IINodes.
I also implemented selection and file open callbacks to refresh and validate the nodes in the classes as needed.
I created two 'types' of buttons the user can add to the gui, seen in the video. The first is a 'Selector', that is associated with a single node via name, and the second is an 'Executor' button, that can select multiple nodes and also run basic maxscript commands via string. This allows me to be able to create the selection buttons and have 'selection set' and tools buttons.
I use WPF Adorners in Editing Mode to manipulate the with and height of the buttons, relative to their parent canvas. Adorners were a little tricky to get my mushy brain around, as it's basically an invisible layer on top of the ui element, and you have use the 'thumbs' in the Adorner system to drive what you want. However, once you get used to it (or as in my case got a really good example from the net and re-work it to my needs) it makes sense and really didnt need too much maintenance.
Any 'gui layout' can be saved to loaded from xml files, that simply describe the buttons, tab and properties.
Again this is Pretty first pass stuff. There are lots of things I'd like to add to this in the future, sliders to manipulate properties and auto generate rig buttons to name a couple. For now the foundation is in and working really well.
Also, it was really nice to use c# for a while. Damn nice language.
I also implemented selection and file open callbacks to refresh and validate the nodes in the classes as needed.
I created two 'types' of buttons the user can add to the gui, seen in the video. The first is a 'Selector', that is associated with a single node via name, and the second is an 'Executor' button, that can select multiple nodes and also run basic maxscript commands via string. This allows me to be able to create the selection buttons and have 'selection set' and tools buttons.
I use WPF Adorners in Editing Mode to manipulate the with and height of the buttons, relative to their parent canvas. Adorners were a little tricky to get my mushy brain around, as it's basically an invisible layer on top of the ui element, and you have use the 'thumbs' in the Adorner system to drive what you want. However, once you get used to it (or as in my case got a really good example from the net and re-work it to my needs) it makes sense and really didnt need too much maintenance.
Any 'gui layout' can be saved to loaded from xml files, that simply describe the buttons, tab and properties.
Again this is Pretty first pass stuff. There are lots of things I'd like to add to this in the future, sliders to manipulate properties and auto generate rig buttons to name a couple. For now the foundation is in and working really well.
Also, it was really nice to use c# for a while. Damn nice language.