Skip to content

Commit 1a1e915

Browse files
committed
code review fixes
- added runtime doc
1 parent 0255eff commit 1a1e915

File tree

1 file changed

+84
-2
lines changed

1 file changed

+84
-2
lines changed

Packages/com.unity.formats.fbx/Documentation~/com.unity.formats.fbx.md

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ The FBX Exporter exports the following objects:
8585
* Game Cameras are exported using the sensor back settings for 35mm TV Projection (width = 0.816 inches, height = 0.612 inches). These camera attributes are also exported:
8686
* Projection type (perspective/orthographic)
8787
* Aspect ratio
88-
* Aperture Width and Height (shown as "Sensor Size" in Unity, in milimiters. The height is set to 0.612 inches, and the width is relative to the aspect ratio)
88+
* Aperture Width and Height (shown as "Sensor Size" in Unity, in millimeters. The height is set to 0.612 inches, and the width is relative to the aspect ratio)
8989
* Focal length
9090
* Vertical field of view. The default aperture mode is vertical.
9191
* Near and far clipping plane
92-
* Physical Cameras (cameras for which the "Physical Camera" checkbox is enabled.
92+
* Physical Cameras (cameras for which the "Physical Camera" checkbox is enabled.)
9393
* Lens Shift
9494
* Focal Length
9595
* Lights of type *Directional*, *Spot* , *Point*, and *Area*; also the following light attributes:
@@ -152,6 +152,22 @@ The FBX Exporter exports the following objects:
152152
* Aim Vector (Aim Constraint)
153153
* Blendshapes
154154

155+
## Cameras
156+
157+
Game Cameras (Physical Camera unchecked) are exported using the sensor back settings for 35mm TV Projection which has an Aperture Width of 0.816 inches and Aperture Height of 0.612 inches.
158+
159+
On export the Aperture Width is calculated using this sensor back relative to the Camera Aspect Ratio for example:
160+
161+
* Full 1024 4:3 (1024x768)
162+
* Aspect Ratio 4:3
163+
* Aperture Width = 0.612 * (1024/768)
164+
165+
The Focal Length (for game cameras) will be derived from the vertical FOV and the sensor back settings (Aperture Width and Aperture Height). The aperture mode will be set to Vertical using the default FBX setting for ApertureMode.
166+
167+
Film Resolution Gate is set to Horizontal so that the importing software will fit the resolution gate horizontally within the film gate.
168+
169+
The Near & Far clipping plane has a range of 30 cm to 600000 cm.
170+
155171

156172
## Export Options window
157173

@@ -567,3 +583,69 @@ public static void ExportGameObjects(Object[] objects)
567583
// ModelExporter.ExportObjects to export a single game object
568584
}
569585
```
586+
587+
## Runtime
588+
589+
The FBX SDK bindings can be executed during gameplay allowing import/export at runtime. Currently a custom importer/exporter needs to be written in order to do so, as the FBX exporter is editor only.
590+
591+
Basic Exporter:
592+
593+
```
594+
using Autodesk.Fbx;
595+
using UnityEngine;
596+
using UnityEditor;
597+
598+
protected void ExportScene (string fileName)
599+
{
600+
using(FbxManager fbxManager = FbxManager.Create ()){
601+
// configure IO settings.
602+
fbxManager.SetIOSettings (FbxIOSettings.Create (fbxManager, Globals.IOSROOT));
603+
604+
// Export the scene
605+
using (FbxExporter exporter = FbxExporter.Create (fbxManager, "myExporter")) {
606+
607+
// Initialize the exporter.
608+
bool status = exporter.Initialize (fileName, -1, fbxManager.GetIOSettings ());
609+
610+
// Create a new scene to export
611+
FbxScene scene = FbxScene.Create (fbxManager, "myScene");
612+
613+
// Export the scene to the file.
614+
exporter.Export (scene);
615+
}
616+
}
617+
}
618+
```
619+
620+
Basic Importer:
621+
622+
```
623+
using Autodesk.Fbx;
624+
using UnityEngine;
625+
using UnityEditor;
626+
627+
protected void ImportScene (string fileName)
628+
{
629+
using(FbxManager fbxManager = FbxManager.Create ()){
630+
// configure IO settings.
631+
fbxManager.SetIOSettings (FbxIOSettings.Create (fbxManager, Globals.IOSROOT));
632+
633+
// Import the scene to make sure file is valid
634+
using (FbxImporter importer = FbxImporter.Create (fbxManager, "myImporter")) {
635+
636+
// Initialize the importer.
637+
bool status = importer.Initialize (fileName, -1, fbxManager.GetIOSettings ());
638+
639+
// Create a new scene so it can be populated by the imported file.
640+
FbxScene scene = FbxScene.Create (fbxManager, "myScene");
641+
642+
// Import the contents of the file into the scene.
643+
importer.Import (scene);
644+
}
645+
}
646+
}
647+
```
648+
649+
### Limitations
650+
651+
* IL2CPP is not supported

0 commit comments

Comments
 (0)