AB4D Forum

Full Version: Change the transform of a child object
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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:

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;