MayaCam Exporter - Update - Changed name and have it working

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

MayaCam Exporter - Update - Changed name and have it working

Post by 7feet »

Okay, kdiddy, I think I got something for you (and anyone else who might find it useful). I downloaded a copy of the Maya personal learning edition, but haven't had a chance to install it yet. Maybe after work, but since I don't know the program, anyone who wants to be a guinea pig, have at it!

So, the file format for strictly camera import is dead simple. These were based on code for exporting 3DS and XSI camera's into Maya, but mostly because they were the only place I could find that I could suss out the proper format. So the basics I'm sure are fine. The only things I'm not sure about is how Moho's numbers relate to Maya's. The aperture sizes and aspect ratios are perfectly straightforward. I also defaulted it to a 1:1 (square) pixel aspect ratio, and a Field of View based on the horizontal angle. I could be wrong on that , could really be verticle or diagonal in Moho, LM will have to chime in on that one. Just in case, I allowed for a scaling factor to be input to compensate.

Different programs look at their rotations in different ways. For example, the XSI camera numbers have to be +90 degrees in X, -180 in Y to come up right in Maya. Right now there are input boxes to put in adjustments, in 90 degree increments to compensate during testing. Once those numbers are nailed down, they can go away.

There is also a place to input a scaling factor for the camera position. Since Moho isn't using real world numbers for distances, lord only knows what that is supposed to be. That's probably the only adjustment that'll have to stay in a final version.

Shouldn't be too hard to nail down the numbers. Also, not having a file infront of me, I wasn't sure how many significant digits Maya wan't to see for different parameters, so I just capped 'em off at 4 decimal places. Let me know how it works, if I don't get to it first. Also, I put in a default camera name of MohoCam. If you think it would be better to add a way to name the camera, I'll throw it in.

MayaCam.lua

--Brian
Last edited by 7feet on Mon Dec 06, 2004 3:46 pm, edited 1 time in total.
User avatar
kdiddy13
Posts: 381
Joined: Tue Aug 03, 2004 10:26 pm
Location: New Zealand
Contact:

Post by kdiddy13 »

OOooooh. I can't wait to try it! I'll give it a shot either during my lunch break or when I get home.

I'm really impressed. Less than a day after requesting it! If you're not careful I may begin requesting more things.

Thanks,
Kurt
________
WEED VAPORIZER
Last edited by kdiddy13 on Mon Mar 07, 2011 4:55 am, edited 1 time in total.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

One other thing that might cause a problem is the fact that the info for each frame is <TAB> delimeted. There was only 1 tab each parameter in the scripts I looked at, but I used 2 because the output looked awful. That means either it just doesn't matter if it's layout is ugly, or I'm using way more significant digits than is really necessary. We'll see. And feel free to request away. If I find it possibly useful (and not to mind-bending) I'll probably do it.

--Brian
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Well, by golly, I tested it out and it works just fine. But I forgot to include the .MEL for the importer. I also made a few minor tweaks to the script.

MayaCam V1.1 w/ importer

Invoke the importer in Maya by typing "MohoCam" in the script box. I made a small mod to the importer to make it Maya 6 compatible, it's originally by Michele Sandroni. I'll whip up the Maya to Moho version as soon as I get the chance.

--Brian
Last edited by 7feet on Mon Dec 06, 2004 3:47 pm, edited 1 time in total.
User avatar
kdiddy13
Posts: 381
Joined: Tue Aug 03, 2004 10:26 pm
Location: New Zealand
Contact:

Post by kdiddy13 »

Hey 7Feet,

I've been playing with the Maya Import (and anxiously awaiting the Maya2Moho version). I've come across a minor problem. When I bring the camera into Maya, the animation comes over fine, but the lens information doesn't.

1) No animation on the lens or Angle of View (no zoom animation comes over)
2) The Camera Aspect comes in at 320x240 (Which seems to be based on the project size). This throws off the Angle of View info by quite a bit. The default camera in Maya uses 1.417 x 0.945. I'm guessing that distilling it down to a smaller ratio would fix it up properly, as this number represents the size of the film back in inches (1.417x0.945 being 35mm). In actuallity, typically I'd want this number to remain at default, changing it as needed.

I hope this information helps. Let me know if you need me to be more specific.

All that being said, just being able to bring the camera information into Maya really rocks! You, my friend, are awesome!

Kurt
________
Vaporizer affiliate program
Last edited by kdiddy13 on Mon Mar 07, 2011 4:56 am, edited 1 time in total.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

If you could post a file with only some camera moves, and maybe a simple target cube for an object so I could recognize it and filter it out of the file, I'll try and hack out the problems. In the meantime, if I get the chance over the turkeyday, I'll throw in some multipliers for the aspect so y'all can play with them and tell me what's needed. In my one reasonably proper test the camera movement looked good but the camera itself did look pretty funky. Is it looking for numbers that relate to an actual camera (or, like, film plane)? Don't have a clue how to relate real world numbers to what Moho does. Maybe someone can try setting the resolution on the Project Setttings to maybe 3 x 4 pixels, and then see, relatively, what Maya thinks of it. That'll give me a ballpark until I can bust out some code, something to ponder, if you will. My new machine has a fast processor but the memory is way too low and Maya makes it have a stroke pretty quick, so it's hard to test myself. Gimme some data! If ya ain't got a place to post it, send it to the email below. I don't use it for anything else.

Once I have the numbers down, the Maya2Moho bit should be a snap. I haven't tried it, but if Michele's Maya camera export script uses the same format (don't see why not), I expect a cakewalk. Okay, that would be the thing. Use Michele's export script on something you think is reasonable and send me that. Either the Xsi or 3Ds export. Prefer the Xsi, that looked a little more straight forward, banging out the code-wise. I dunno what they expect, but from what I could tell what they export is mathematically compatible with Maya, so that'd be a start.

--Brian
User avatar
kdiddy13
Posts: 381
Joined: Tue Aug 03, 2004 10:26 pm
Location: New Zealand
Contact:

Post by kdiddy13 »

I'll probably be able to get you a couple of files over the next couple of days (Turkey Day and all may set me back a bit). I shouldn't have a problem posting them online for you to download. I'll try to render a quick movie to go along with it so that you can visually error check the import.

As for the Camera Aspect, I'm guessing that Moho's camera, since it doesn't have lens information and only uses Angle of view, doesn't have any real connection to a real world camera (Lost Marble, jump in here any time). What might be a useful dialogue for the Moho2Maya dialogue, would be to give a number of presets for the Camera Aspect (35mm, 16mm, etc.). 35mm is typically the standard/default while working in Maya (it's what it defaults to and everyone is mostly used to). If someone needs to change it in Maya to a non-standard number, that option is always available to them. I can look up these numbers if you're interested in adding such a dialogue.

Basically, I'd either give a number of defaults for the Camera Aspect or just set it to the 35mm default. As for why the camera's zoom doesn't animate properly? Not sure. This may be related to the Camera Aspect ratio being so far out of the range of what Maya expects to see, it's unable to animate the Angle of View (it give error messages if you try to adjust the Angle of View while the Aspect Ratio is set to an absurd number). I'll take a look at this in the Mel script.

I am very curious to see what importing a Maya camera to Moho will look like. With out translational scaling (which, BTW seems to work great!) Moho's animation takes place in a relatively very small space.
________
Kitchen Measures
Last edited by kdiddy13 on Mon Mar 07, 2011 4:56 am, edited 1 time in total.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Lordy, that was a strange trip. I think I have it figured now. Problem 1, Moho displays the Field of View in degrees, but it thinks in radians, and I forgot to compensate for that. Also, it turns out to be the inverse of the radians that translates to degrees. But wait - then I had to multiply the degrees result by the astounding fudge factor of 1.0471975511966 to get the numbers to come out just right. I fixed that and added a scaling input for the aperture sizes. That was just too wierd.

Okay, kdiddy, that was for the part that that you were really talking about when you said aspect, its the Aperture Size. If you are going for 35mm, that would be 24mm wide, height proportional by the Aspect ratio. I still don't know how nice they are going to talk together, but you have all the adjustment factors possible and I fixed the Field of view thing.

MohoCamV1.2.zip

The bit that I had to drop out of the importer script was a variable for focal length. The importer was written for Maya 5, and Maya 6 wouldn't run the script with it in there. Theres a way to determine focal length by using the aperture size and FOV, so Maya must do that inside. Unless I've done something terribly wrong. Hope not. One mo' time...

--Brian

UPDATE: Urf, I need to go through the MEL command reference and make an importer that works properly. Oh, well, right after I stuff myself silly. Later, all.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

All about the numbers...

Post by 7feet »

So, the entire problem asn't really with the code, but with the size of the numbers for the Aperture Size that was initially getting exported, which were way too huge without scaling for Maya to handle initially. I threw in a default initial scaling on the aperture size to make it 1/100th the size of the project dimensions. That sends out numbers that are reasonable compatible with Maya's standard film gate sizes. I also added a default scaling of 10x for the translation distances, anything smaller doesn't hardly move at all, but you will likely want to make it higher. Both of these scaleings are hard coded, the number entry boxes work as before.

Also, right off the bat, if you use the other importer and exporter scripts over at Motionblur.it you can import the Moho cameras into 3DS and XSI, or swap between them and Maya. I'm working on the Moho importer, that shouldn't take too long.

Because Moho doesn't really work on real world units, I'm going to figure that any cameras that are imported back into Moho were originally exported from Moho. That should help keep the numbers straight.

Anyway--Oh, yeah, I changed the name so everythings consistent, and because it's basically a generic camera format. Also, if anyone knows it, it shouldn't be too hard to work out an importer for After Effects. That would be handy. If you look at the text in a .CC file, you can see the infornation is pretty straightforward. Invoke the Mel with either the original function name (ms_CameraImport) or the duplicate function I put in, MohoCam.

MohoCam V 1.3 w/ exporter

--Brian
User avatar
kdiddy13
Posts: 381
Joined: Tue Aug 03, 2004 10:26 pm
Location: New Zealand
Contact:

Post by kdiddy13 »

Excellent! I'll try it out later this week.

One question, have you found any sort of relation or "scale" value for the size of the camera in Moho as compared to Maya. Sorry, it's early so I'm having trouble formulating my sentences. The reason I ask is, one of the things I was hoping to use this for was live action sequences that have been matchmoved.

Given that Moho apparently takes place in a very small world space when compared to Maya, being able to scale my camera by a set amount would be very helpful. Basically, if you come up with any numbers that seem to work, if you could post them as well, that would be swell. If I'm not making sense, let me know and I'll try to explain myself better after I wake up. :)

Thanks again for your charitable hard work. I really do appreciate it alot.

Kdiddy
________
Ultimate fighters
Last edited by kdiddy13 on Mon Mar 07, 2011 4:58 am, edited 1 time in total.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

I'll figure something out. What are the numbers in Maya, centimeters? Probably the easiest way to do it is to keep the aspect ratio at a standard 4:3 (e.g 640x480, 800x600) which is also compatible with fullframe 35mm. In the numbers being sent, its an aspect ratio of 1.3333333.

Now, as far as translations go, with the camera set at it's defaults and relating to a layer not translated in Z, the project width is 2.6666666 units, the project height is 2 ( or both double the aspect ratio). So, as it stands with the all the default settings in Moho and the current defaults in the Exporter, Maya would think that a box drawn in Moho (on a layer not translated in Z) that filled the frame exactly would be 20 centimeters high. If you turn on the grid in Moho, and set the spacing to 24 (why 24? Dunno, except that it works.) and each line in the grid will represent 1 centimeter.

So, if you set the Camera Position Scaling to 10, the grid represents 10 centimeters per square. At 100, 1 meter, etc. That should work fine, but one never knows. Let me know how it works out.

--Brian
User avatar
kdiddy13
Posts: 381
Joined: Tue Aug 03, 2004 10:26 pm
Location: New Zealand
Contact:

Post by kdiddy13 »

Yup, the default measurements are in centimeters. Although, many places I've worked just use them as a default unit (treating them as feet or whatever they needed). It is after all a virtual, arbitrary measurement. So, using them as Maya default units would probably be the easiest way to go (people can convert with standard conversions as necessary).

I agree, leaving the camera aspect ratio at 1.33333 would be fine, again, converting in Maya isn't really a big deal as long as you remember you need to.

Thanks for the numbers, I'll try it out as soon as I can.

Kdiddy
________
BMW R1150GS
Last edited by kdiddy13 on Mon Mar 07, 2011 4:59 am, edited 1 time in total.
User avatar
BA
Posts: 196
Joined: Tue Mar 08, 2005 7:28 pm
Location: Griddleville
Contact:

Post by BA »

what would you need to do this with MAX and how would you make it work?
Create cartoon characters and comics in minutes: www.bitstrips.com
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

BA - I never tried it with Max but, but as far as I can tell, you shouldn't need to do a damn thing to make it work. Except, because Moho's scale (and size "units") are arbitrary, adjust the camera exports scaleing factor. Once again, go to www.Motionblur.it to get the latest version of the converter scripts. He says the scripts are tested for Max 5, maybe for more recent versions the Max import and export scripts would have to be tweaked, but I ain't even goin' there.

However, since I might maybe have some time and wanted to diddle with this again, I will definitely write the script to import the camera back into Moho momentarily. It's not hard, I just had to focus on more arbitrary and senseless things, like eating, for a bit.

So, we come back to the scale. So a way to check it fast. Draw a box in Moho, say one that is 1x1 "unit" square. Render it out and import the image into Max (at the origin would be a good place to start). Then do perverse things to the camera. Export a video from Moho, as well as the camera data from the script. Import the camera data into Max, and then compare and contrast the image you get from the Max camera with the Moho render. If it's messed up somehow, scale and rotate the camera export data until its, uh, not. It should work pretty directly, but as there are some bit's of the Max imporster script code that look like conversion tweaks for XSI and Maya, mebbe there's something a little screwy. But follow the formulae and a bit of scaling in the script should get you something recognizable pretty quick.

Hope that helps. As always. But if it's bollocks, I'll see what I can do.
User avatar
BA
Posts: 196
Joined: Tue Mar 08, 2005 7:28 pm
Location: Griddleville
Contact:

Post by BA »

thanks Brian, I look forward to trying this out. I'll let you know how it goes.
Create cartoon characters and comics in minutes: www.bitstrips.com
Post Reply