2
0
Эх сурвалжийг харах

Fixed bug when no blender instance is running and exporting produces default settings only. i.e. updated parameters but exported model produced is in default parameters.

Signed-off-by: Jason Dela Cruz <[email protected]>
Jason Dela Cruz 2 жил өмнө
parent
commit
64a9758a42

+ 3 - 1
Gems/O3DE/GeomNodes/Code/Source/Editor/Components/EditorGeomNodesComponent.cpp

@@ -256,7 +256,9 @@ namespace GeomNodes
     {
         if (!m_workInProgress)
         {
-            m_instance->RequestExport(m_controller->GenerateFBXPath(), m_currentObject);
+			m_instance->RequestExport(m_paramContext.m_group
+				.GetGroup(m_currentObject.c_str())->GetProperties()
+                , m_currentObject, m_controller->GenerateFBXPath());
             SetWorkInProgress(true);
         }
     }

+ 11 - 8
Gems/O3DE/GeomNodes/Code/Source/Editor/Systems/GNInstance.cpp

@@ -109,7 +109,6 @@ namespace GeomNodes
                 {
                     "%s": [ %s ],
                     "%s": "%s",
-                    "Frame": 0,
                     "ParamUpdate": true
                 }
             )JSON"
@@ -155,21 +154,25 @@ namespace GeomNodes
 		SendIPCMsg(msg);
     }
 
-    void GNInstance::RequestExport(const AZStd::string& fbxPath, const AZStd::string& objectName)
+    void GNInstance::RequestExport(const AZStd::string& params, const AZStd::string& objectName, const AZStd::string& fbxPath)
     {
 		auto msg = AZStd::string::format(
 			R"JSON(
                     {
                         "%s": true,
+                        "%s": [ %s ],
                         "%s": "%s",
                         "%s": "%s"
                     }
-                    )JSON",
-			Field::Export,
-			Field::Object,
-			objectName.c_str(),
-			Field::FBXPath,
-			fbxPath.c_str());
+                    )JSON"
+			, Field::Export
+			, Field::Params
+			, params.c_str()
+            , Field::Object
+            , objectName.c_str()
+            , Field::FBXPath
+            , fbxPath.c_str()
+			);
 		SendIPCMsg(msg);
     }
 

+ 1 - 1
Gems/O3DE/GeomNodes/Code/Source/Editor/Systems/GNInstance.h

@@ -27,7 +27,7 @@ namespace GeomNodes
         void SendHeartbeat();
         void RequestObjectParams();
         void CloseMap(AZ::u64 mapId);
-        void RequestExport(const AZStd::string& fbxPath, const AZStd::string& objectName);
+        void RequestExport(const AZStd::string& params, const AZStd::string& objectName, const AZStd::string& fbxPath);
 
     private:
         AZStd::unique_ptr<AzFramework::ProcessWatcher> m_blenderProcessWatcher = nullptr;

+ 3 - 10
Gems/O3DE/GeomNodes/External/Scripts/messages.py

@@ -38,17 +38,8 @@ def update_geometry_node_params(geometry_nodes_obj, new_params: dict):
             GN[params['Id']] = float(params['Value'])
         elif params['Type'] == 'BOOLEAN':
             GN[params['Id']] = bool(params['Value'])
-        # elif params['Type'] == 'MESH':
-        #     GN[params['Id']] = params['Object']
-        # elif params['Type'] == 'COLLECTION':
-        #     GN[params['Id']] = params['Collection']            
         elif params['Type'] == 'STRING':
             GN[params['Id']] = str(params['Value'])
-        # elif params['Type'] == 'IMAGE' or params['Type'] == 'TEXTURE':
-        #     GN[params['Id']] = params['Tex']
-        # elif params['Type'] == 'RGBA':
-        #     vect = params['Value'][0]
-        #     GN[params['Id']][:] = [vect['R'], vect['G'], vect['B'], vect['A']]
 
     for obj in bpy.data.objects:
         if obj.data and obj.type == "MESH":
@@ -99,7 +90,9 @@ def poll_for_messages():
                 elif 'Export' in msg_dict:
                     error_msg = ""
                     try:
-                        fbx_exporter.fbx_file_exporter(msg_dict['Object'], msg_dict['FBXPath'], False)
+                        # update the geometry nodes first. The request might happened when there's no running blender instance.
+                        object_name = update_gn_in_blender(msg_dict)
+                        fbx_exporter.fbx_file_exporter(object_name, msg_dict['FBXPath'], False)
                     except Exception as e:
                         error_msg = str(e)
                         if hasattr(e, 'message'):

+ 5 - 0
Gems/O3DE/GeomNodes/README.md

@@ -5,3 +5,8 @@
 This gem enables the user to use Blender's Geometry Nodes in O3DE.
 
 ![GN-Example-1](https://user-images.githubusercontent.com/874957/225318592-5594db51-335e-4ba4-9b31-943bf0104b97.gif)
+
+## Test files
+https://paveloliva.gumroad.com/l/buildify
+
+https://www.blender.org/download/demo-files/#geometry-nodes