Exporting Camera data via FBX

Started by mash, August 26, 2013, 07:11:15 PM

Previous topic - Next topic

mash

Hi. I'm trying to export the terrain and camera data to Maya.
I exported the terrain using the micromesh exporter as an .obj file.
That came into Maya ok.
I then exported the camera data as FBX using both the export tab in the camera Panel
And the File>export FBX.
When I brought the camera data in Maya the camera is in the wrong postion.
The animation is baked in but the position is off to the the right by quite a bit.
Is there a step I'm missing somewhere?

Also in the File>export FBX what should the "convert meteres to:" and scale factor be set to when exporting to Maya or Modo?
Thanks,

jo

Hi,

What version of TG are you using?

You should be able to leave the "Convert to metres" and "Scale factor" settings to their defaults. The importing application should handle the conversion appropriately.

There is an FBX reference here in case you haven't seen it:

http://www.planetside.co.uk/wiki/index.php?title=FBX_Reference

Regards,

Jo

mash

TG3 build 3.0.07.0

This is what I'm getting in Maya 2012

[attachimg=1]

Just to double check I key framed the camera and rendered a two frame animation with the micro exporter on.
Then exported the Camera as FBX.
The scene is a default scene with the default procedural terrain.
Camera position is

xyz: 695.288, 78.2192, 1480.27
xyz: -3.46049, -10.6185, 0


jo

Hi mash,

Could you please email me the TG project and the FBX file? My email address is:

jomeder@planetside.co.uk

Regards,

Jo


jo

Hi mash,

Looking at the FBX file the camera position is matching the position in TG. I tried importing it into a couple of apps and it also seems correct. What are the camera position coordinates in Maya?

I wonder if the problem is that the imported geometry is shifted somehow. Maybe the scaling is off? I think the OBJ would be written in metres but I think Maya works in centimetres by default. The geometry may need scaling up by 100 if you're using cm. You could also try exporting the terrain as FBX, which should do the right thing with units and conversion. Just use .fbx as the filename extension in the micro exporter instead of .obj.

Regards,

Jo

Kadri


Jo i think this should not be a guessing and documentation reading thing.
TG3 should have in the "Save as type" place all the formats it can save+export listed .
In some places you click open files and there is again only "all files" only option.
With all formats listed it would be great especially for new users.
I don't remember all other import,export,save,open places but this should be standard by now.

It is better as some years ago, but there are still some places like this left.

jo

Hi Kadri,

I absolutely agree with you. This has long been on my list things to improve once TG3 was released. Would have liked to do it sooner.

Regards,

Jo

digitalguru

Hi Mash,

try my script for Maya - it's designed to do exactly what you are trying to do

http://www.creativecrash.com/maya/script/terraman

mash

Hi, I haven't been able to test the FBX file in Maya. Every time I try to load it Maya just hangs at 80%.
I did try the script provided by Digital Guru.
Thanks for that it works great.
The only thing I can't figure out is getting the camera gate resolutions to match.
[attachimg=1]
[attachimg=2]
Both cameras have the same resolution 840x450 and aspect ratio. 1.7778
Is there something I'm missing?

Also can I ask what you had to do in your script to get the camera position to match?
Just in case I have to do something similar in another 3d program?
Thanks.


digitalguru

#10
can you send me your test scenes? I'll have a look

maya - ascii scene
terragen scene
micro or obj terrain

which way did you export the camera? - from terragen to maya I'm guessing - the script should be pretty fool proof from Maya to Terragen but the mismatch might come from the film aperture in the Terragen camera

"Also can I ask what you had to do in your script to get the camera position to match?"

there's a fair bit of code in the script to get that working :

essentially the script:
creates a locator and sets it's rotation order to the order a terragen camera defaults at (ZXY)
then postion and rotation constrains the locator to the camera
bakes the locator into world space (sets a keyframe per frame)
queries the maya camera for the vertical field of view (as the terragen cam uses that as a default)
then collects all those keyframes for translation (from the locator)
and field of view (from the camera) and write them to a .chan file




mash

Hi, Ok I sent you a PM with my email address.
yes I went from TG3 to maya.
Exported the terrain using the micro .obj exporter and then exported the camera data as a Chan file.
Then used your script to import the Obj and created a default camera and applied the chan file to it.

digitalguru

#12
I see what's going on -

The camera you exported the chan file from in Terragen is set to Use horizontal fov in the Perspective tab. If you render out two separate .chan files from Terragen, one with the camera set to Horizontal fov and another set to Vertical fov and open the files in a text editor you'll see all the values are exactly the same. The last value in each row is the fov and it's 42.1034 - which is the vertical fov of the camera. The .chan export from Terragen is a bit screwy in this respect. (It also doesn't export any animated changes in fov - I flagged this with Matt.)

So, if you re-render the Terragen scene with Use vertical fov selected and check it against the Maya render, they will match. Your original micro export geo will be clipped at the sides, as you exported that with the horizontal fov checked - if you re-export with verttical settings, it will fill the frame.

When you open up a new scene in Terragen and check the import tab, you'll see the default is Import vertical FOV, which is how I set the script so you don't have to change any values when importing from Maya to Terragen.

If you check out the edited Terragen scene file, I imported the camera you had set up in Maya back into Terragen via a .chan file, which imports correctly. If you look at the horizontal and vertical fovs for that that camera they're the same (42.10) so all is good.

I personally wouldn't bake directly from the render camera anyway, the geo gets clipped beyond the camera frustum, so you might be missing shadows from something off camera on your CG elements in Maya. Also, from your camera you can only see terrain about 30km away, but the micro exporter was clipping to infinity, so you could actually see the curvature of the planet in the obj file, making a very large file.

I'd set up another camera, make it orthographic and point it straight down over the part of the terrain you want to use.

That's my preferred way of working with the script, I made it so I could make a terrain in Terragen, do an ortho projection and bring it into Maya, then set up the camera with Mayas more extensive toolset for animating cameras, then bring it back into Terragen.

Also if you check your original terrain .obj in Maya - region select a single vertex you'll find 2, 4 or even 8 dupicate vertices. That's why the micro exported terrains are so huge. Maya doesn't really like merging vertices on complex geo like this at all, and forget about trying to clip bits of the mesh off if you want to - takes forever.

I found a free prog called Meshlab which is very good and fast at cleaning up these meshes:

http://meshlab.sourceforge.net/ -

Open it up and drag your mesh into the window and select Filters/Cleaning and Repairing/Remove Duplicated Vertex - check the difference in the vertex count at the bottom of the display. Do the same for faces.

Now you you have a cleaner mesh at about quarter of the size...

Hope this helps.

Edit: Just reading the posts by Jo and Kadri - there is a mismatch in units when importing .obj via the micro exporter into Maya. That's why I wrote the script to automate all that, with the script you can import files from Terragen .obj, World Machine and Geo Control and they will all line up. You can even choose a master scale to work at and any camera animation you create will import back into Terragen in the right place.

mash

Thanks I re-exported the terrain using the Vertical FOV and it worked great.

Do you think you will ever update the script top include Lights?
I can move the Sunlight from TG3 to Maya and the Maya physical sun to TG3 using FBX.
It's not difficult just a few convoluted steps and I thought there might be a more streamlined method.
Thanks,

digitalguru

#14
QuoteThanks I re-exported the terrain using the Vertical FOV and it worked great.

glad it worked!

QuoteDo you think you will ever update the script top include Lights?

that's a good idea, though usually all I do is import the Terragen Sun into Maya and since it's directional, position doesn't matter. Should be pretty simple to create an FBX import that scales according to the master scale set in the script.

For now, if you export from Terragen and you're working to the 1:100 scale in the script - export your light changing only the Scale Factor to 0.01

You can export lights form Maya using the Chan export and import them into Lightsources or Spotlights (which have a chan function)