Skip to content

Commit 9cad10a

Browse files
authored
Merge pull request #437 from unitALG/v2.0
V2.0 - Edits for com.unity.formats.fbx only
2 parents 0f596e0 + 40a089a commit 9cad10a

16 files changed

+776
-674
lines changed

Packages/com.autodesk.fbx/Documentation~/com.autodesk.fbx.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# About the FBX SDK C# Bindings package
1+
# FBX SDK C# Bindings
22

33
__Version__: 2.0.0-preview
44

5-
The FBX SDK C# Bindings provide access from Unity C# scripts to a subset of the Autodesk FBX SDK, version 2018.1.
5+
The FBX SDK C# Bindings package provides access to a subset of the Autodesk® FBX® SDK, version 2018.1 from Unity C# scripts.
66

7-
The Autodesk® FBX® SDK is a free, easy-to-use, C++ software development platform and API toolkit that allows application and content vendors to transfer existing content into the FBX format with minimal effort.
7+
The Autodesk® FBX® SDK is a C++ software development platform and API toolkit that is free and easy-to-use. It allows application and content vendors to transfer existing content into the FBX format with minimal effort.
88

9-
The FBX SDK C# Bindings support the FBX Exporters package. The subset or the API that is exposed is geared towards exporting; import is not guaranteed to be possible yet.
9+
> ***Note:*** The FBX SDK C# Bindings package exposes only a subset of the API. That subset enables exporter tools, such as the [FBX Exporter](https://docs.unity3d.com/Packages/com.autodesk.fbx@latest) package. Using the FBX SDK C# Bindings package for importing is not recommended. See [Known issues](#issues) below for more information.
1010
1111
## Requirements
1212

@@ -21,15 +21,25 @@ The FBX SDK C# Bindings package contains:
2121
* C# bindings
2222
* Compiled binaries for MacOS and Windows that include the FBX SDK
2323

24-
## Known Issues
24+
## Known issues
2525

26-
* In this version, you cannot downcast the C# objects, which limits the use of the bindings for an importer. For example, if the FBX SDK declares in C++ that it will return an FbxDeformer, on the C++ side if you happen to know it is in fact an FbxSkinDeformer you could safely cast the deformer to a skin deformer. However, on the C# side, this is not permitted.
27-
* While there are guards against some common errors, it is possible to crash Unity by writing C# code that directs the FBX SDK to perform invalid operations. For example, if you have an FbxProperty in C# and you delete the FbxNode that contains the property, if you try to use the FbxProperty, that will have undefined behaviour which may include crashing the Unity Editor. Make sure to read the editor log if you have unexplained crashes when writing FBX SDK C# code.
28-
* The FBX SDK C# Bindings package is not supported if you build using the IL2CPP backend.
26+
### Importing
2927

30-
## API Documentation
28+
In this version, you cannot downcast the C# objects, which limits the use of the bindings for an importer. For example, if the FBX SDK declares in C++ that it will return an `FbxDeformer`, you could safely cast the deformer to a skin deformer on the C++ side if you happen to know it is an `FbxSkinDeformer`. However, on the C# side, this is not permitted.
3129

32-
There is no API documentation in the preview package. Refer to the <a href="http://help.autodesk.com/view/FBX/2018/ENU/">Autodesk FBX SDK API documentation</a>.
30+
### Invalid operations
31+
32+
While there are guards against some common errors, it is possible to crash Unity by writing C# code that directs the FBX SDK to perform invalid operations. For example, if you have an `FbxProperty` in C# and you delete the `FbxNode` that contains the property, using the `FbxProperty` may produce undefined behavior This may even include crashing the Unity Editor. Make sure to read the editor log if you have unexplained crashes when writing FBX SDK C# code.
33+
34+
### IL2CPP backend
35+
36+
The FBX SDK C# Bindings package is not supported if you build using the IL2CPP backend.
37+
38+
39+
40+
## API documentation
41+
42+
There is no API documentation in the preview package. See the <a href="http://help.autodesk.com/cloudhelp/2018/ENU/FBX-Developer-Help/cpp_ref/annotated.html">Autodesk® FBX® SDK API documentation</a>.
3343

3444
The bindings are in the `Autodesk.Fbx` namespace:
3545

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* [FBX Exporter](index)
2+
* [Exporting FBX files from Unity](exporting)
3+
* [Converting GameObjects to Linked Prefabs](prefabs)
4+
* [Integrating Unity with 3D modeling software](integration)
5+
* [Setting FBX Export options](options)
6+
* [Developer's guide](devguide)

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

Lines changed: 0 additions & 652 deletions
This file was deleted.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Developer’s Guide
2+
3+
As a developer you have access to the FBX Exporter from C# scripting. You can use the basic API by providing a single GameObject or a list of GameObjects. Note that default export settings are used for exporting the GameObjects to the FBX file.
4+
5+
You can call the FBX Exporter from C# using methods found in the [**UnityEditor.Formats.Fbx.Exporter** ](../api/UnityEditor.Formats.Fbx.Exporter.html) namespace, for example:
6+
7+
```
8+
using System.IO;
9+
using UnityEngine;
10+
using UnityEditor;
11+
using UnityEditor.Formats.Fbx.Exporter;
12+
13+
public static void ExportGameObjects(Object[] objects)
14+
{
15+
string filePath = Path.Combine(Application.dataPath, "MyGame.fbx");
16+
ModelExporter.ExportObjects(filePath, objects);
17+
18+
// ModelExporter.ExportObject can be used instead of
19+
// ModelExporter.ExportObjects to export a single game object
20+
}
21+
```
22+
23+
## Runtime
24+
25+
The FBX SDK bindings can be executed during gameplay allowing import and export at runtime. Currently a custom importer/exporter needs to be written in order to do so, as the FBX Exporter is Editor only.
26+
27+
### Basic Exporter:
28+
29+
```
30+
using Autodesk.Fbx;
31+
using UnityEngine;
32+
using UnityEditor;
33+
34+
protected void ExportScene (string fileName)
35+
{
36+
using(FbxManager fbxManager = FbxManager.Create ()){
37+
// configure IO settings.
38+
fbxManager.SetIOSettings (FbxIOSettings.Create (fbxManager, Globals.IOSROOT));
39+
40+
// Export the scene
41+
using (FbxExporter exporter = FbxExporter.Create (fbxManager, "myExporter")) {
42+
43+
// Initialize the exporter.
44+
bool status = exporter.Initialize (fileName, -1, fbxManager.GetIOSettings ());
45+
46+
// Create a new scene to export
47+
FbxScene scene = FbxScene.Create (fbxManager, "myScene");
48+
49+
// Export the scene to the file.
50+
exporter.Export (scene);
51+
}
52+
}
53+
}
54+
```
55+
56+
### Basic Importer:
57+
58+
```
59+
using Autodesk.Fbx;
60+
using UnityEngine;
61+
using UnityEditor;
62+
63+
protected void ImportScene (string fileName)
64+
{
65+
using(FbxManager fbxManager = FbxManager.Create ()){
66+
// configure IO settings.
67+
fbxManager.SetIOSettings (FbxIOSettings.Create (fbxManager, Globals.IOSROOT));
68+
69+
// Import the scene to make sure file is valid
70+
using (FbxImporter importer = FbxImporter.Create (fbxManager, "myImporter")) {
71+
72+
// Initialize the importer.
73+
bool status = importer.Initialize (fileName, -1, fbxManager.GetIOSettings ());
74+
75+
// Create a new scene so it can be populated by the imported file.
76+
FbxScene scene = FbxScene.Create (fbxManager, "myScene");
77+
78+
// Import the contents of the file into the scene.
79+
importer.Import (scene);
80+
}
81+
}
82+
}
83+
```
84+
85+
### Limitations
86+
87+
* IL2CPP is not supported
88+
* Only 64 bit Windows and MacOS standalone player builds are supported
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
# Exporting FBX files from Unity
2+
3+
Use __Export To FBX__ (menu: __GameObject__ > __Export To FBX__) to manually export GameObject hierarchies to an FBX file. The FBX Exporter exports selected objects and their descendants to a single FBX file. However, if you select both a parent and a descendant, only the parent’s hierarchy is exported.
4+
5+
The FBX Exporter exports the following objects:
6+
7+
* GameObject hierarchies and their transforms
8+
* [Meshes](#meshes)
9+
* SkinnedMeshRenderers with the following exceptions:
10+
* Humanoid rigs are not supported
11+
* Meshes in bone hierarchies are not supported
12+
* Materials as Phong if the material has specular; Lambert in all other cases
13+
* Textures
14+
* [Cameras](#cameras)
15+
* [Lights](#lights)
16+
* [Contraints](#constraints)
17+
* [Animation](#animation)
18+
* Blendshapes
19+
20+
21+
22+
<a name="meshes"></a>
23+
24+
## Mesh support
25+
26+
The FBX Exporter exports multiple copies of the same Mesh as instances. The FBX Exporter also exports the following mesh attributes:
27+
28+
- Normals
29+
- Binormals
30+
- Tangents
31+
- Vertex Colors
32+
- All 8 Mesh UVs, if present
33+
- Quads or Triangles
34+
35+
36+
37+
<a name="cameras"></a>
38+
39+
## Cameras
40+
41+
The FBX Exporter exports both Game Cameras and Physical Cameras.
42+
43+
> ***Note:*** In Unity's Inspector, a Camera's **Physical Camera** property determines whether it is a *Physical Camera* or a *Game Camera*.
44+
45+
### Physical Cameras
46+
47+
The FBX Exporter exports Physical Cameras, including these properties:
48+
49+
- **Focal Length**
50+
- **Lens Shift**
51+
52+
### Game Cameras
53+
54+
On export, the FBX Exporter sets the **Aperture Height** to 0.612 inches, and calculates the **Aperture Width** using this sensor back relative to the Camera's Aspect Ratio. For example:
55+
56+
* Full 1024 4:3 (1024x768)
57+
* Aspect Ratio 4:3
58+
* Aperture Width = 0.612 * (1024/768)
59+
60+
The Aperture Width and Height values appear in Unity's Inspector as the **Sensor Size** property in millimeters.
61+
62+
The FBX Exporter derives the **Focal Length** from the vertical Field of View (FOV) and the sensor back settings (Aperture Width and Aperture Height). The FBX Exporter uses the default FBX setting for Aperture Mode: Vertical.
63+
64+
**Film Resolution Gate** is set to Horizontal so that the importing software fits the resolution gate horizontally within the film gate.
65+
66+
The **Near & Far** Clipping Plane values have a range of 30 cm to 600000 cm.
67+
68+
In addition, the **Projection** type (perspective/orthographic) and **Aspect Ratio** are also exported.
69+
70+
71+
72+
<a name="lights"></a>
73+
74+
## Lights
75+
76+
The FBX Exporter exports Lights of type *Directional*, *Spot* , *Point*, and *Area*.
77+
78+
It also exports the following Light attributes:
79+
80+
- Spot Angle (for Spot lights)
81+
82+
- Color
83+
84+
- Intensity
85+
86+
- Range
87+
88+
- Shadows (either On or Off)
89+
90+
91+
92+
<a name="constraints"></a>
93+
94+
## Constraints
95+
96+
The FBX Exporter exports these types of Constraints:
97+
98+
- [Rotation](#cns_rotation)
99+
- [Aim](#cns_aim)
100+
- [Position](#cns_position)
101+
- [Scale](#cns_scale)
102+
- [Parent](#cns_parent)
103+
104+
In addition, the FBX Exporter also exports the following attributes for all Constraint types:
105+
106+
- Sources
107+
- Source Weight
108+
- Weight
109+
- Active
110+
111+
<a name="cns_rotation"></a>
112+
113+
### Rotation
114+
115+
The FBX Exporter exports the following attributes for the Rotation Constraint type:
116+
117+
- Affected axes (X,Y,Z)
118+
- Rotation Offset
119+
- Rest Rotation
120+
121+
<a name="cns_aim"></a>
122+
123+
### Aim
124+
125+
The FBX Exporter exports the following attributes for the Rotation Constraint type:
126+
127+
- Affected axes (X,Y,Z)
128+
129+
- Rotation Offset
130+
- Rest Rotation
131+
- World Up Type
132+
- World Up Object
133+
- World Up Vector
134+
- Up Vector
135+
- Aim Vector
136+
137+
<a name="cns_position"></a>
138+
139+
### Position
140+
141+
The FBX Exporter exports the following attributes for the Position Constraint type:
142+
143+
- Affected axes (X,Y,Z)
144+
- Translation Offset
145+
- Rest Translation
146+
147+
<a name="cns_scale"></a>
148+
149+
### Scale
150+
151+
The FBX Exporter exports the following attributes for the Scale Constraint type:
152+
153+
- Affected axes (X,Y,Z)
154+
- Scale Offset
155+
- Rest Scale
156+
157+
<a name="cns_parent"></a>
158+
159+
### Parent
160+
161+
The FBX Exporter exports the following attributes for the Parent Constraint type:
162+
163+
- Source Translation Offset (animated)
164+
- Source Rotation Offset (animated)
165+
- Affect Rotation Axes
166+
- Affect Translation Axes
167+
- Rest Translation
168+
- Rest Rotation
169+
170+
171+
172+
<a name="animation"></a>
173+
174+
## Animation
175+
176+
The FBX Exporter exports Legacy and Generic Animation from Animation and Animator components, or from a Timeline clip.
177+
178+
In addition, it also exports the following animated attributes:
179+
180+
- Transforms
181+
- Lights:
182+
- Intensity
183+
- Spot Angle (for Spot lights)
184+
- Color
185+
- Cameras:
186+
- Field of View
187+
- Constraints:
188+
- Weight
189+
- Source Weight
190+
- Translation Offset (Position Constraint)
191+
- Rotation Offset (Rotation Constraint and Aim Constraint)
192+
- Scale Offset (Scale Constraint)
193+
- Source Translation Offset (Parent Constraint)
194+
- Source Rotation Offset (Parent Constraint)
195+
- World Up Vector (Aim Constraint)
196+
- Up Vector (Aim Constraint)
197+
- Aim Vector (Aim Constraint)
198+
199+
200+
201+
## Export Options window
202+
203+
When exporting an FBX file, the following Export Options window opens, displaying options for specifying what gets exported.
204+
205+
![Export Options window](images/FBXExporter_ExportOptionsWindow.png)
206+
207+
208+
### Export Options Properties
209+
210+
| Property: | Function: |
211+
| :------------------------ | :----------------------------------------------------------- |
212+
| __Export Name__ | Specify the name of the FBX file to export. |
213+
| __Export Path__ | Specify the location where the FBX Exporter will save the FBX file. |
214+
| __Source__ | Transfer the transform animation from this object to the __Destination__ transform. <br/><br/>**Notes:**<br/> - __Source__ must be an ancestor of __Destination__<br/> - __Source__ may be an ancestor of the selected object. |
215+
| __Destination__ | Which object to transfer the transform animation to.<br/><br/>This object receives the transform animation on objects between __Source__ and __Destination__ as well as the animation on the Source itself. |
216+
| __Export Format__ | Select the format to use in the FBX file (ASCII or Binary). |
217+
| __Include__ | Choose whether to export both Models and Animation, only Models, or only Animations. |
218+
| __LOD level__ | For level of detail (LOD) groups, choose the desired level of detail to export (all, highest, or lowest). <br/><br/>**Notes:** - The FBX Exporter ignores LODs outside of selected hierarchy.<br/> - The FBX Exporter does not filter out objects that are used as LODs and doesn't export them if they aren’t direct descendants of their respective LOD Group |
219+
| __Object(s) Position__ | Choose whether to reset the exported objects to world center, or keep world transforms during export.<br/><br/>If you select multiple objects for export, and you choose __Local Centered__ from this drop-down menu, the FBX Exporter centers objects around a shared root while keeping their relative placement unchanged. |
220+
| __Animated Skinned Mesh__ | Check this option to export animation on objects with skinned meshes.<br/><br/>If unchecked, the FBX Exporter does not export animation on skinned meshes. |
221+
| __Compatible Naming__ | Check this option to control renaming the GameObject and Materials during export. <br/><br/>The FBX Exporter ensures compatible naming with Autodesk® Maya® and Autodesk® Maya LT™ to avoid unexpected name changes between Unity and Autodesk® Maya® and Autodesk® Maya LT™. During export the FBX Exporter replaces characters in Unity names as follows:<br/> - Replaces invalid characters with underscores ("_"). Invalid characters are all non-alphanumeric characters, except for the colon (":").<br/> - Adds an underscore ("_") to names that begin with a number.<br/> - Replaces diacritics. For example, replaces "é" with “e”.<br/><br/>For FBX Model filenames, the FBX Exporter ensures that names do not contain invalid characters for the file system. The set of invalid characters may differ between file systems.<br/><br/>**Note:** If you have a Material with a space in its name, the space is replaced with an underscore ("_"). This results in a new Material being created when it is imported. For example, the Material named "Default Material" is exported as "Default_Material" and is created as a new Material when it is imported. If you want the exported Material to match an existing Material in the scene, you must manually rename the Material before exporting. |
222+
| __Export Unrendered__ | Check this option to export meshes that either don't have a renderer component, or that have a disabled renderer component. For example, a simplified mesh used as a Mesh collider. |
223+
224+
225+
226+
## Exporting animation from the Timeline
227+
228+
In order to export an animation clip from the timeline, in the Timeline editor select the desired clip, then from the top menu select __GameObject__ > __Export Selected Timeline Clip__.
229+
230+
231+
## Exporting with relevant system units
232+
233+
The FBX Exporter exports in centimeter units (cm) with the Mesh set to real world meter (m) scale. For example, if vertex[0] is at [1, 1, 1] m., it is converted to [100, 100, 100] cm.
234+
235+
In Autodesk® 3ds Max®, it is recommended to set the system units to centimeters to avoid any scaling on Model import and export.
236+
237+
There are no specific import options to adjust between Unity and Autodesk® Maya® and Autodesk® Maya LT™. When working in Autodesk® Maya® and Autodesk® Maya LT™, you can set the working units to meters if you prefer.
238+
239+
For example, when working with large models in Autodesk® Maya® and Autodesk® Maya LT™, to ensure that the models clip to meters, adjust the scale of the near and far clipping planes for all cameras by 100x. In addition, you should scale lights by 100x so that objects display in the viewport.
240+
241+
## Known issues
242+
243+
* Bind pose of animated skinned mesh is lost on export. For example, if you export an animated skinned mesh from Unity and import it into Autodesk® Maya® and Autodesk® Maya LT™ you will not be able to set the character into the bind pose using the **Rigging** > **Skin** > **Go to Bind Pose** command.
244+
245+
* Animated skinned meshes may not export with the correct skinning if they are not in the bind pose on export (that is, not being previewed in the Animation or Timeline windows, and the original Rig's FBX must not contain animation)
246+
247+
* For skinned meshes all bones must be descendants of the root bone. For example, if the root bone is "hips" and the right leg for the same skinned mesh is not a descendant of hips, export will fail.
248+
Binary file not shown.
-64 KB
Loading
-58.8 KB
Loading
-60.6 KB
Loading
Binary file not shown.

0 commit comments

Comments
 (0)