I am trying to manipulate the control points of a mesh. However, trying to set the control points with new X,Y,Z,W data (to override the existing data) fails. The control point still holds its original values.
Code i use :
For C = 0 To Ms.ControlPoints.Count - 1
Dim x As Double = Ms.ControlPoints.Item(C).x - Xshift
Dim y As Double = Ms.ControlPoints.Item(C).y - Yshift
Dim z As Double = Ms.ControlPoints.Item(C).z
Dim w As Double = Ms.ControlPoints.Item(C).w
Ms.ControlPoints.Item(C).Set(x, y, z, w)
Next
A workaround is create a new list of vector4 , and use the following code, the coordinates gets updated but I have to create the list in memory (which has slow performance) :
Would you please share your source and generated files, if any, so that we may investigate further. Before sharing requested data, please ensure using Aspose.3D for .NET 19.9 in your environment.
This is the code i am using, just use an standard fbx :
Dim scene As Scene = New Scene()
Dim FBXname As String = "test.fbx"
scene.Open(FBXname)
Dim a As Node = scene.RootNode
For Each cnode As Node In a.ChildNodes
Dim Ms As Entities.Mesh = cnode.Entity
Dim BB As Utilities.BoundingBox = Ms.GetBoundingBox()
Dim Min As Utilities.Vector3 = BB.Minimum
Dim Max As Utilities.Vector3 = BB.Maximum
Dim Xshift As Double = Math.Truncate((Max.x + Min.x) / 2)
Dim Yshift As Double = Math.Truncate((Max.y + Min.y) / 2)
For C = 0 To Ms.ControlPoints.Count - 1
Dim x As Double = Ms.ControlPoints.Item(C).x - Xshift
Dim y As Double = Ms.ControlPoints.Item(C).y - Yshift
Dim z As Double = Ms.ControlPoints.Item(C).z
Dim w As Double = Ms.ControlPoints.Item(C).w
Ms.ControlPoints.Item(C).Set(x, y, z, w)
Next
Next
Dim FBXExportname As String = "export.fbx"
scene.Save(FBXExportname, FileFormat.FBX7500ASCII)
Please note that Ms.ControlPoints.Item(C) returns a struct, which is passed by value, any modifications are performed on stack, so Set is not working in this scenario (Just modified a temporary variable on stack), use the following code to modify the Control Points:
For C = 0 To Ms.ControlPoints.Count - 1
Dim v = Ms.ControlPoints.Item(C)
v.x -= Xshift
v.y -= Yshift
Ms.ControlPoints.Item(C) = v
Next
We hope this will be helpful. Please feel free to contact us if you need any further assistance.