Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX SDK / Python SDK : usage of KFbxGeometryConverter ?
  RSS 2.0 ATOM  

Python SDK : usage of KFbxGeometryConverter ?
Rate this thread
 
64267
 
Permlink of this thread  
avatar
  • Location: Saarbruecken
  • Total Posts: 10
  • Joined: 17 February 2007 02:20 AM

Hi,

I need to use the KFbxGeometryConverter.TriangulateInPlace method within a Python Script, but I fail at this point. This is my first Python project, my language skills are low.

I tried:

if pNode.GetNodeAttribute().GetAttributeType() == KFbxNodeAttribute.eMESH:
   
geomConv KFbxGeometryConverter
   geomConv
.TriangulateInPlacepNode )

And get this error:

geomConv.TriangulateInPlacepNode )
TypeErrorKFbxGeometryConverter.TriangulateInPlace(): first argument of unbound method must have type 'KFbxGeometryConverter'

According to the docs of KFbxGeometryConverter ( http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/SDKRef/a00130.html ) which are only available for c++ I need to construct the Converter with a Pointer to a KFbxSdkManager : KFbxGeometryConverter (KFbxSdkManager *pManager)

I tried this as well:

if pNode.GetNodeAttribute().GetAttributeType() == KFbxNodeAttribute.eMESH:
   
sdkManager KFbxSdkManager
   geomConv 
KFbxGeometryConvertersdkManager )
   
geomConv.TriangulateInPlacepNode )

And get this error:

geomConv KFbxGeometryConvertersdkManager )
TypeErrorKFbxGeometryConverter(): arguments did not match any overloaded call:
  
overload 1argument 1 has unexpected type 'sip.wrappertype'
  
overload 2argument 1 has unexpected type 'sip.wrappertype'

How do I use the Converter properly ?

Cheers, searching for the Pivot of my Soul, PP !



Cheers, searching for the Pivot of my Soul, PP !!!

Replies: 0
avatar

Hello Peter, you can use it like this:

geomConv KFbxGeometryConverter(pSdkManager)
KFbxGeometryConverter.TriangulateInPlace(geomConvpNode)

But in my test TriangulateInPlace does not work properly, so I tried to use TriangulateMesh, which did triangulate my mesh correctly.



Jiayang Xu
Maya Data Platform
Autodesk

Replies: 0
avatar

Hi Jiayang, thanks for your reply.

What type is your pSdkManager, and how do you construct it ?

geomConv KFbxGeometryConverter(pSdkManager)

Constructing a KFbxGeometryConverter doesn’t work for me with simply a KFbxSdkManager. This sip.wrapper type ( pointer to KFbxSdkManager ? ) is required, but how do I create one ?

That’s bad news.

Jiayang Xu 08 February 2012 05:22 PM

But in my test TriangulateInPlace does not work properly, so I tried to use TriangulateMesh, which did triangulate my mesh correctly.

Will have to export skinned/morphed, possibly non triangulated, meshes into a triangles-only engine.

Cheers, searching for the Pivot of my Soul, PP !



Cheers, searching for the Pivot of my Soul, PP !!!

Replies: 2
/userdata/avatar/vx3501hqr_small.jpg

Hi Peter, you can create the sdkmanager like this:
import FbxCommon
from fbx import *

# Prepare the FBX SDK.
(lSdkManager, lScene) = FbxCommon.InitializeSdkObjects()

Please do take a look at the examples attached in the FbxPythonSDK, they show most of the basic usage of python fbx.

Author: Jiayang Xu

Replied: 09 February 2012 06:58 PM  
/userdata/avatar/vx3501hqr_small.jpg

And it is actually not that bad, you can always call TriangulateMesh, TriangulateNurbs or TriangulatePatch as necessary, it doesn’t matter the mesh is skinned or morphed, as long as it is a mesh/nurbs/patch, you can triangulate it.

Author: Jiayang Xu

Replied: 09 February 2012 07:42 PM  
avatar

Hi Jiayang Xu,

sorry for the late response but other stuff came in.

And it is actually not that bad, you can always call TriangulateMesh, TriangulateNurbs or TriangulatePatch as necessary, it doesn’t matter the mesh is skinned or morphed, as long as it is a mesh/nurbs/patch, you can triangulate it.

Here I disagree, as I can see TriangulateMesh does create a pure mesh copy, but does not copy morphtargets, skin, skin weigth information, texture and material attachement. Now all this data must be copied too and the origin of the copy is not required after Triangulation.

TriangulateInPlace is really not working, this is a bug, should be reported and fixed. TriangulateMesh is no suiteable substitute.

Cheers, searching for the Pivot of my Soul, PP !



Cheers, searching for the Pivot of my Soul, PP !!!

Replies: 0
avatar

Hi Peter,
Yes you are right, TriangulateInPlace will take care of more things than TriangulateMesh.

It seems last time I did not use TriangulateInPlace properly, that’s why I stated it did not work.
After a double check I succeed to use TrangulateInPlace to triangulate my mesh, please check the attached python sample file, please copy it under the installation path of FbxPythonSdk, in my case it is C:\Program Files\Autodesk\FBX\FbxPythonSdk\2012.2\examples\Python\ExportScene01 and run it to get TriangulateTest.fbx.
I also attached the fbx files I generated without any triangulation, by use TiangulateMesh and TriangulateInPlace.You can see in TriangulateTest_NoTriangulate.fbx the cube is not triangulated, but in both TriangulateTest_TriangulateMesh.fbx and TriangulateTest_TriangulateInPlace.fbx, the cube is triangulated successfully.

Please let me know does it work for you.



Jiayang Xu
Maya Data Platform
Autodesk

Attachment Attachment
Replies: 0
avatar

Hi Jiayang Xu,

thanks for your help, now it works :-)
I tried to triangulate the mesh, and not the node itself in the first place.

Anyway, there is a litle bug in your code, line 64, where you use the Triangulate in place method, even though it might work for you, as you don’t use lMesh after the triangulation

geomConv KFbxGeometryConverter(pSdkManager)
lMesh KFbxGeometryConverter.TriangulateInPlace(geomConvlCubeNode)

the method returns a status bool, so I guess you don’t want to (re)bind this to lMesh. Here is my working code:

geomConv KFbxGeometryConverter(pSdkManager)
status KFbxGeometryConverter.TriangulateInPlace(geomConvlCubeNode)
if 
status 
    
lMesh lCubeNode.GetNodeAttribute()

Reassigning lMesh after triangulation is necessary, even if lMesh had a valid handle before the triangulation, otherwise ( my ) python crashes.

Cheers, searching for the Pivot of my Soul, PP !!!



Cheers, searching for the Pivot of my Soul, PP !!!

Replies: 1
/userdata/avatar/vx3501hqr_small.jpg

Oops, sorry for that mistake.
I simply copy the line from the TriangulateMesh line and did not check return value.
Nice to know it works for you.

Author: Jiayang Xu

Replied: 08 March 2012 01:24 PM