Hi,
how can I scale a whole model? I need to scale it to convert from one unit to another.
Thanks,
Havard
Hi,
how can I scale a whole model? I need to scale it to convert from one unit to another.
Thanks,
Havard
There are two ways, you can scale the node or scale the geometries:
Scale node:
node.Transform.Scale *= new Vector3(0.1, 0.1, 0.1);
Scale geometries:
Geometry g = ...;
for(int i = 0; i < g.ControlPoints.Count; i++)
g.ControlPoints[i] *= new Vector4(0.1, 0.1, 0.1, 1);
In order to scale geometries in a shorthanded way, we have logged an enhancement ticket Id THREEDNET-312 in our issue tracking system. We have linked your post to this ticket and will keep you informed regarding available updates.
To scale a whole model, do you scale the RootNode, or rather scale all nodes, recursively?
I have tried both, and find this;
My workflow is
Kindly send us your source FBX and code. We will investigate and share our findings with you.
Please use the FBX I have sent you earlier, this is the one I am using.
I have only this code:
scene.Open(filenameFBX);
double ScaleFactor = 0.1;
…and then, Alternative 1:
scene.RootNode.Transform.Scale *= new util.Vector3(ScaleFactor, ScaleFactor, ScaleFactor);
Alternative 2:
ScaleNode_RECURSIVE(scene.RootNode, ScaleFactor);
private void ScaleNode_RECURSIVE(Node node, double ScaleFactor)
{
node.Transform.Scale *= new util.Vector3(ScaleFactor, ScaleFactor, ScaleFactor);
foreach (Node subnode in node.ChildNodes)
{
ScaleNode_RECURSIVE(subnode);
}
}
We have logged an investigation under the ticket ID THREEDNET-313 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.
The linked ticket ID THREEDNET-312 has been resolved and will be included in the next version 17.12 of Aspose.3D for .NET API. We will notify you once the new version is published.
In reference to the ticket ID THREEDNET-313, our product team has completed their analysis phase and come to the conclusion that it is not a bug. The most file formats do not support saving the transformation information of the Root node. In the GLTF format, the Root Node is actually a virtual concept, the GLTF file only records the child nodes of the root node that is why the scale on the root node is not working.
If you require to scale the whole scene by the node transformation information, you do not need to scale the node recursively, only scale the nodes under the root node is enough, otherwise the more deeper the entity is the more accumulated scale factor is calculated, that means if you recursively scale the whole scene hierarchy by a fixed factor 0.9, the nodes in depth 1 level will have a global scaling 0.9, and the 2nd depth level will have a 0.9 * 0.9 and the 3rd depth level will have 0.9 * 0.9 * 0.9.
This code demonstrates the scaling of scene by transformation:
[C#]
foreach (Node node in scene.RootNode.ChildNodes)
node.Transform.Scale = new Vector3(0.5);
@havarsa,
The linked ticket ID THREEDNET-304 has been resolved in the version 17.12 of Aspose.3D for .NET API, please download and try the latest version 17.12 of Aspose.3D for .NET API from NuGet gallery.
We have added two Scale members to Aspose.ThreeD.Entities.PolygonModifier class:
[C#]
// definition of members
public static void Scale(Aspose.ThreeD.Scene scene, Aspose.ThreeD.Utilities.Vector3 scale)
public static void Scale(Aspose.ThreeD.Node node, Aspose.ThreeD.Utilities.Vector3 scale)
// scale the model in huge-scene.obj by 0.01 and save it to another file:
Scene scene = new Scene("huge-scene.obj");
PolygonModifier.Scale(scene, new Vector3(0.01));
scene.Save("scaled-scene.obj", FileFormat.WavefrontOBJ);