Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Scale A node Using FBX SDK python or C+

1 REPLY 1
SOLVED
Reply
Message 1 of 2
andrestronic12
535 Views, 1 Reply

How to Scale A node Using FBX SDK python or C+

Hi comunity.

 

In this moment I'm Working in a project using Fbx Files for get mesh for my Game Engine, after I need to draw this Mesh. For now I can get the mesh, the vertices and spaces points and draw normality but I need to scaling this meshes before drawing, I know, I can make that, Multiply the matrix or spaces Points by a Scaling MAtrix. but reading the python classes, FBxNode Class have LclScaling.Set(fbxDouble3) here is and example using cubeMan in python

 

Sorry for my english but please Try to help me

 

 

 

import fbx
import sys
import numpy as np
filepath = 'cubeMan.fbx'
manager = fbx.FbxManager.Create()
importer = fbx.FbxImporter.Create(manager, 'myImporter')
status = importer.Initialize( filepath )

list = []
if status == False:
    print('FbxImporter initialization failed.')
    print('Error: %s' % importer.GetLastErrorString())
    sys.exit()


scene = fbx.FbxScene.Create( manager, 'myScene' )
importer.Import(scene)
importer.Destroy()
a = scene.GetNodeCount()


for i in range(0, a):
    b = scene.GetNode(i)#Obtengo los nodos del archivo FBX
    print(b.GetName())#Imprimo cada uno de los nodos


#Scaling Here doesn't work
t = fbx.FbxDouble3(0.5, 0.5, 0.5)
b = scene.GetNode(1)
b.LclScaling.Set(t)
f = b.GetGeometry()
print(f.GetControlPointAt(0))

c = scene.GetGeometry(0)#Obtengo la geometria de la malla 0
c.GetPolygonVertices()#De esta maneta obtengo los vertices, la triangulacion de la malla
for i in range(0, c.GetControlPointsCount()):#Obtengo los puntos en el espacio de la malla
        list1 = []
        q = c.GetControlPointAt(i)#obtengo XYZ el vector fbx4
        list1.append(q[0])
        list1.append(q[1])
        list1.append(q[2])
        list.append(list1)
n = np.array(list, np.float32)
print(n)

 

 

  in the line 28 to 32 I get the first node, after I scale by fbx.double3(0.5, 0.5, 0.5), inmediatily I print the new values but when I get the geometry of that node the values is the same of the original values, Values no change.

 

Please I need to do that, I'm trying this for too many days I can't do that Need help. sorry for my english is not my first language

Tags (4)
1 REPLY 1
Message 2 of 2

Hi.

 

if anyone needs to make this here is an example.

 

* Get the parent or child Node from scene 

b = scene.GetNode(1)

* Active transformation

b.ScalingActive.Set(1)

 *Apply transformation

px = fbx.FbxDouble3(0.5, 0.5, 0.5)
b.LclScaling.Set(px)

 *Get the Node's Matrix transformation

TransforMatrix = fbx.FbxMatrix(b.EvaluateGlobalTransform())

*When you get the matrix tranformation you can Multiply the mesh Space Vectors for the Matrix transformation 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report