void PlaneMoveManipulator::onCreate(const PlaneMoveManipulator* source)
{
    // Skip direct parent, don't want the default geometry creation
    Transform::onCreate(source);

    SimpleMaterialUnrecPtr pMat = SimpleMaterial::create();
    pMat->setDiffuse(Color3f(.5, .5, .5));
    pMat->setLit    (false              );
    setMaterialX(pMat);

    pMat = SimpleMaterial::create();
    pMat->setDiffuse(Color3f(0, 1, 0));
    pMat->setLit    (false           );
    LineChunkUnrecPtr lc = LineChunk::create();
    lc->setWidth(3);
    pMat->addChunk(lc);
    setMaterialY(pMat);

    pMat = SimpleMaterial::create();
    pMat->setDiffuse(Color3f(0., 0., 1.));
    pMat->setLit    (true               );
    setMaterialZ(pMat);

//    SimpleMaterial *simpleMat;
//    Geometry       *geo;

    setExternalUpdateHandler(NULL);

    // add a name attachment
    NameUnrecPtr nameN = Name::create();
    nameN->editFieldPtr()->setValue("XYManipulator");
    addAttachment(nameN);

    // make the axis line. Not really a handle, but easier to manage this way.
       
    GeoBuilder b;
    
    b.vertex(Pnt3f(0,0,0));
    b.vertex(Pnt3f(0,getLength()[1],0));
    
    b.line(0, 1);
    
    GeometryUnrecPtr g = b.getGeometry();
    
    g->setMaterial(getMaterialY());
    
    NodeUnrecPtr pNode = makeNodeFor(g);
    setTransYNode(pNode);

    // make the plane handle

    pNode = Node::create();
    setTransXNode(pNode);

    g = makePlaneGeo(getLength()[0] / 2.f, getLength()[2] / 2.f, 1, 1);
    g->setMaterial(getMaterialX());   
    pNode = makeNodeFor(g);
    
    OSG::ComponentTransformUnrecPtr transHandleXC = ComponentTransform::create();

    setHandleXNode(pNode);

    getTransXNode()->setCore (transHandleXC   );
    getTransXNode()->addChild(getHandleXNode());

    transHandleXC->setTranslation(Vec3f(0, getLength()[1], 0));
    transHandleXC->setRotation   (Quaternion(Vec3f(1, 0, 0), osgDegree2Rad(90)));

    //
    // make the rotate handle

    pNode = Node::create();
    setTransZNode(pNode);

    g = makeCylinderGeo(0.05f, 0.1f, 16, true, true, true);
    g->setMaterial(getMaterialZ());   
    pNode = makeNodeFor(g);
    
    OSG::ComponentTransformUnrecPtr transHandleZC = ComponentTransform::create();

    setHandleZNode(pNode);

    getTransZNode()->setCore (transHandleZC   );
    getTransZNode()->addChild(getHandleZNode());

    transHandleZC->setTranslation(Vec3f(0, getLength()[1], 0));

    commitChanges();
}
void Manipulator::onCreate(const Manipulator* source)
{
    Inherited::onCreate(source);

    SimpleMaterialUnrecPtr pMat;

//    SimpleMaterial *simpleMat;
    Geometry       *geo;

    setExternalUpdateHandler(NULL);

    // add a name attachment
    NameUnrecPtr nameN = Name::create();
    nameN->editFieldPtr()->setValue("XManipulator");
    addAttachment(nameN);

    // make the axis lines
    NodeUnrecPtr pNode = makeCoordAxis(getLength()[0], 2.0, false);
    setAxisLinesN(pNode);

    // make the red x-axis transform and handle

    pNode = Node::create();
    setTransXNode(pNode);
    OSG::ComponentTransformUnrecPtr transHandleXC = ComponentTransform::create();

    pNode = makeHandleGeo();
    setHandleXNode(pNode);
    pMat = SimpleMaterial::create();
    setMaterialX  (pMat );

    getTransXNode()->setCore (transHandleXC   );
    getTransXNode()->addChild(getHandleXNode());

    transHandleXC->setTranslation(Vec3f(getLength()[0], 0, 0)                   );
    transHandleXC->setRotation   (Quaternion(Vec3f(0, 0, 1), osgDegree2Rad(-90)));

    pMat->setDiffuse(Color3f(1, 0, 0));
    pMat->setLit    (true            );

    geo = dynamic_cast<Geometry *>(getHandleXNode()->getCore());
    geo->setMaterial(pMat);

    //
    // make the green y-axis transform and handle

    pNode = Node::create();
    setTransYNode(pNode);
    OSG::ComponentTransformUnrecPtr transHandleYC = ComponentTransform::create();
    pNode = makeHandleGeo();
    setHandleYNode(pNode);
    pMat = SimpleMaterial::create();
    setMaterialY(pMat);

    getTransYNode()->setCore (transHandleYC   );
    getTransYNode()->addChild(getHandleYNode());

    transHandleYC->setTranslation(Vec3f(0, getLength()[1], 0)                    );
//    transHandleYC->setRotation   ( Quaternion(Vec3f(0, 0, 1), osgDegree2Rad(-90)));

    pMat->setDiffuse(Color3f(0, 1, 0));
    pMat->setLit    (true            );

    geo = dynamic_cast<Geometry *>(getHandleYNode()->getCore());
    geo->setMaterial(pMat);

    //
    // make the blue z-axis transform and handle

    pNode = Node::create();
    setTransZNode(pNode);
    OSG::ComponentTransformUnrecPtr transHandleZC = ComponentTransform::create();
    pNode = makeHandleGeo();
    setHandleZNode(pNode);
    pMat = SimpleMaterial::create();
    setMaterialZ  (pMat);

    getTransZNode()->setCore (transHandleZC   );
    getTransZNode()->addChild(getHandleZNode());

    transHandleZC->setTranslation(Vec3f(0, 0, getLength()[2])                  );
    transHandleZC->setRotation   (Quaternion(Vec3f(1, 0, 0), osgDegree2Rad(90)));

    pMat->setDiffuse(Color3f(0, 0, 1));
    pMat->setLit    (true            );

    geo = dynamic_cast<Geometry *>(getHandleZNode()->getCore());
    geo->setMaterial(pMat);

    //
    // make the yellow pivot transform and handle

    pNode = Node::create();
    setPivotNode(pNode);
    OSG::ComponentTransformUnrecPtr transHandlePivotC = ComponentTransform::create();
    pNode = makeSphere(2, 0.05f);
    setHandlePNode(pNode);
    pMat = SimpleMaterial::create();
    setMaterialPivot  (pMat);

    getPivotNode()->setCore (transHandlePivotC   );
    getPivotNode()->addChild(getHandlePNode());

    transHandlePivotC->setTranslation(Vec3f(0, 0, 0));

    pMat->setDiffuse(Color3f(1, 1, 0));
    pMat->setLit    (true            );

    geo = dynamic_cast<Geometry *>(getHandlePNode()->getCore());
    geo->setMaterial(pMat);

    if (!getEnablePivot())
    {
        getPivotNode()->setTravMask(0x0);
    }

    commitChanges();
}