Skip to content

Commit 1ce2686

Browse files
committed
fix so review exports export set
Also, make sure that we are able to find the bounds when framing the camera
1 parent 80fd2f8 commit 1ce2686

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

Assets/FbxExporters/Editor/ReviewLastSavedModel.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,24 @@ private static Object LoadModel (string fbxFileName)
112112
return modelGO as Object;
113113
}
114114

115+
private static Bounds GetRendererBounds(GameObject modelGO)
116+
{
117+
var renderers = modelGO.GetComponentsInChildren<Renderer> ();
118+
if (renderers.Length > 0) {
119+
var bounds = renderers [0].bounds;
120+
for (int i = 1; i < renderers.Length; i++) {
121+
bounds.Encapsulate (renderers [i].bounds);
122+
}
123+
return bounds;
124+
}
125+
return new Bounds ();
126+
}
127+
115128
private static void FrameCameraOnModel(GameObject modelGO)
116129
{
117130
// Set so camera frames model
118131
// Note: this code assumes the model is at 0,0,0
119-
Vector3 boundsSize = modelGO.GetComponent<Renderer>().bounds.size;
132+
Vector3 boundsSize = GetRendererBounds(modelGO).size;
120133
float distance = Mathf.Max(boundsSize.x, boundsSize.y, boundsSize.z);
121134
distance /= (2.0f * Mathf.Tan(0.5f * Camera.main.fieldOfView * Mathf.Deg2Rad));
122135
Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, -distance * 2.0f);

Assets/Integrations/Autodesk/maya2017/scripts/unityOneClick/commands.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,19 @@ def doIt(self, args):
222222
return
223223

224224
# make sure the GamePipeline and fbxmaya plugins are loaded
225-
if self.loadDependencies():
226-
# save fbx to Assets/_safe_to_delete/
227-
savePath = unityTempSavePath
228-
maya.cmds.sysFile(savePath, makeDir=True)
229-
savePath = savePath + "/TurnTableModel.fbx"
230-
maya.mel.eval(r'file -force -options "" -typ "FBX export" -pr -es "{0}"'.format(savePath));
225+
if not self.loadDependencies():
226+
return
227+
228+
# select the export set for export, if it exists,
229+
# otherwise take what is currently selected
230+
if self.setExists(self._exportSet):
231+
maya.cmds.select(self._exportSet, r=True, ne=True)
232+
233+
# save fbx to Assets/_safe_to_delete/
234+
savePath = unityTempSavePath
235+
maya.cmds.sysFile(savePath, makeDir=True)
236+
savePath = savePath + "/TurnTableModel.fbx"
237+
maya.mel.eval(r'file -force -options "" -typ "FBX export" -pr -es "{0}"'.format(savePath));
231238

232239
if maya.cmds.about(macOS=True):
233240
# Use 'open -a' to bring app to front if it has already been started.

0 commit comments

Comments
 (0)