James, please do, I’m now somewhat comfortable with winforms/c#, I can make some custom controls. But when I was searching for ways to make controls, I keep hitting this forums and blogs saying wpf is so much more flexible and extensible. If you could make a primer that is somewhat max/mxs oriented, that would be awesome!
-Johan
P.s. here’s some code I use in my viewport pos to fusion motion exporter, it also compensates for the non square pixel.
fn bakeData obj = (
pX = stringStream ""
pY = stringStream ""
sX = gw.getWinSizeX() as float -- Get WinSize X
sY = gw.getWinSizeY() as float -- Get WinSize X
rPA = renderPixelAspect -- Get Render Pixel Aspect
rX = RenderWidth as float -- Get Render Pixels X
rY = RenderHeight as float -- Get Render Pixels Y
rY = rY * ( 1 / rPA ) -- Correct for aspect ratio
ratio = 1
rratio = ( sX / rX ) / (sY / rY) -- Get Ratio
if rratio >= 1. then ( -- If Ratio is bigger than 1 then
ratio = sY / rY -- Use Y ratio for calculations
) else (
ratio = sX / rX -- Else use X ratio for calculations
) -- end if
xMin = ( sX - ( rX * ratio ) ) / 2 -- Get x minimum value
yMin = ( sY - ( rY * ratio ) ) / 2 -- Get y minimum value
ct = animationRange.end as integer / TicksPerFrame -- Animation range end as integer
-- gw.setTransform (matrix3 1) -- Set gw View transform to zero
with redraw on
for i = 0 to ct do
(
--p = gw.TransPoint ( at time i obj.position ) -- Get 3D point in 2D screenspace
slidertime = i -- Move viewport cause of moving cams
gw.setTransform (matrix3 1) -- Set gw View transform to zero
p = gw.TransPoint ( obj.position ) -- Get 3D point in 2D screenspace
x = ( p.x - xMin ) / ( sX - ( xMin * 2) ) -- Convert View space to Render space for X
y = 1 - ( p.y - yMin ) / ( sY - ( yMin * 2 ) ) -- idem for Y
format "% %
" ( i as float ) x to:pX
format "% %
" ( i as float ) y to:pY
) -- end for
#(pX,pY)
)
Wouhou! That is outstanding stuff, i like how you approach the problem !
This must have been a lot of work no ? but it was worth it
The editor seems to be very intuitive to create the interface .
I would love to use it Do you plan to share this plugin in the future ?
thanks again for the feedback and suggestions.
Can you change properties in mass ? (eg. select three buttons and change their colors)
Sorry, missed this question – This is the great thing about using the property grid – you can change all at the same time. The control colours pallette on the lfet of the UI works on the selection also.
Joel, Johan –
I might need a bit more help understanding the 3d object.transform.position to 2d render [x.y] position, im not quite as tasty with the maths as you two!
I had a try at implementing your ideas and code into the assembly but i must have done something wrong – The results were close but not where i hoped. I was assuming the points generated between 0-1 were a kind of ratio multiplier for the renderheight and width, but I may have been barking up the wrong tree. Im just not familiar with the camera transform methods you kindly wrote in your earlier posts, despite your great attempts to comment them!
edit- i was just looking into bobo’s vertex renderer topic in the help, This seems to work well in a perspective view, but not for cameras, I guess thats what all the extra tomfoolery is about.
help me obi-wan!
P.s James – Very much look forward to reading any WPF insight, that would certainly go to the top of my favourites. It appears to me that my selection framework would be a great project to port over to WPF, all the moving/resizing code is built into the the inkcanvas! I’ve been reading up for a while, trying to make the jump from WinForms to WPF.
Definitely let me know if you have any WPF questions. I’m no expert by any means, but I’ve gotten pretty comfortable with it in the past couple of months. BTW, are you using Linq to serialize your xml data? If not, you should look into it.
Hi james,
Much appreciated. I didnt use Linq, instead opting for the XMLSerlializer class, passing it a custom xml class to serialize the data. Like i said in the article, I was sure i was just scratching the surface in terms of what you can do with it! Thanks for the tip and i’ll read up on it.
I just had another look at my code and it doesn’t seem to be working… I think that I have confused ortho and perspective projection and written some crazy hybrid code that doesn’t even work… When I get some more time I’ll have another look at it. My theory is that it shouldn’t be much more complicated than some basic trig. Haven’t looked too hard at Johan’s code but since he’s had success with using it to exporting stuff to fusion I’d say that’s your best bet
Hi Joel,
thanks, I’ve got the great bobo’s vertex renderer code almost doing what i want, shouldn’t be too much to sort this.
I have worked a bunch with the 3D to render view code as well, I could dig that up for you Pete if you want.
I’m not sure that I’m following with the serializing of XML, just what is this doing for you?
I’m wondering if we need to rethink what we are doing as well here at PEN, problem is I want it to be able to run on 2010 so I guess I’m out of luck with WPF on this front.
James, I hope you don’t mind but I posted a news item on my site that points to yours for the tutorial you posted about WPF. Thanks for that, it will get me started on it.
hi Paul,
Cheers, I’d appreciate if you can add any pointers that could help me from your work!
Again, im probably not using serliazation to it’s fullest, Im not sure I understand the full picture as it seems that there are lots of different ways of writing to XML. Perhaps someone who knows can elaborate.
For me, it seems a simpler way of organising it within in a user control in VS. I simply create a my serlializer class from the design surface in my user control (as i wrote in the article), and pass that class to the XMLserlializer – it handles what data from the dotnetobject is written to the xml. It simplified things considerably, as i could use the same class to deserialize when it came to building the interface. Form what i could see, its just a different way of doing things!
James might be able to clarify, but i dont think windows forms are dead just yet, WPF introduces an exciting possibility for functionality that is difficult to achieve without coding in winforms, and since custom stuff for 3dsmax is just that, its exciting to think you can build some task-centric controls for an 3d program, not making do with the standard ones. It would be good to get the jump on this before there’s too much to take on. I dont know about anyone else, but it always seems that this industry doesn’t stop for a second.
I’m no expert by any means, but I’m finding that I’m able to create new tools much more quickly using WPF than I did when using straight .Net and MaxScript, and that the result is more user-friendly and customizable. And I think that there two equally important reasons, 1) WPF itself is built with the idea of creating powerful, but easy to use and visually appealing tools at the heart of it, so things like binding your UI elements directly to the underlying data is super easy, and 2) I’m starting to code directly in C# using Visual Studio and then loading the dll in Max and hosting the tool in a window or rollout, instead of creating everything in MaxScript. Both of those have taken a couple months to really get comfortable with, and I still have more to learn, but I can see my productivity as a tools developer increasing rapidly.
Of course, this doesn’t apply to more simple things like when you just need a rollout with some buttons, but for anything requiring a more complicated UI, this is the way to go.
BTW, Pete, I really like how you always focus on making your tools really easy to use. Awesome job.