AB4D Forum
Change the transform of a child object - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9)
+--- Thread: Change the transform of a child object (/showthread.php?tid=3970)



Change the transform of a child object - cedricmelancon - 04-06-2016

I have a OBJ model that has five nodes (a vehicle with four wheels). I would like to rotate the wheels according to the velocity of the vehicle. Is there a way with the PowerToys to access these transforms or it's only the global transform that is available?

Thank you


RE: Change the transform of a child object - abenedik - 04-06-2016

OBJ files do not support model transformations. Therefore your model (and its sub-parts) were loaded without any transformation.

But all WPF 3D objects have a Transform property that you can use to animate your object.

For example if you have the following structure:

Model3DGroup:
1x GeometryModel3D ("CarBody")
4x GeometryModel3D ("CarWheels")

You can set TranslateTransform3D to the Model3DGroup's Transform to move the car.
You can set RotateTransform3D to wheels GeometryModel3D to rotate the wheels - you can use the AxisAngleRotation3D object for rotation - it takes a rotation axis and an angle.

Note that if your OBJ file sets names for models, you can get the objects by names with using the ReaderObj's NamedObjects dictionary (Dictionary<string, Model3D>) - for example:

var objImporter = new Ab3d.ReaderObj();
var wpf3DModel = objImporter.ReadModel3D("fileName.obj");

var leftWheel = objImporter.NamedObjects["LeftWheel"] as GeometryModel3D;