##################################################
Adding or Removing Children from a Transform Shape
##################################################

A shape hierarchy is built using a transform shape created using the ``CID_REDTransformShape``. See :doc:`/tasks/ta_ca/ta_ca_scenegraph/tk_creating_and_destroying_shapes`. Then, the following code can be used to manipulate the list of children of a shape from the ``RED::ITransformShape`` interface:

.. code:: cpp

    // Creating a transform shape:
    RED::Object* transform = RED::Factory::CreateInstance( CID_REDTransformShape );
    if( !transform )
        RC_TEST( RED_ALLOC_FAILURE );

    // Accessing the needed interface to manipulate the shape list of children:
    RED::ITransformShape* itransform = transform->As< RED::ITransformShape >();

    // Add a 'meshA' shape. Here we don't update our scene graph bounding spheres:
    RC_TEST( itransform->AddChild( meshA, RED_SHP_DAG_NO_UPDATE, iresmgr->GetState() ) );

    // Remove 'meshB' shape, and update the bounding spheres in the shape hierarchy to adapt to changes:
    RC_TEST( itransform->RemoveChild( meshB, RED_SHP_DAG_UPDATE, iresmgr->GetState() ) );

Note that for performance reasons, ``RED::ITransformShape::AddChild`` does not prevent duplicate insertion of the same child twice or more. A given child should be added once. Adding the same child shape several times is an error that can cause unpredictible engine behaviors. 