bool    ObjectRenderer::Configure(const pXmlTree tree){

    bDrawObject         = true;
    bUseDefaultColor    = false;
    bUseTransparency    = false;
    SET_COLOR4(mDefaultColor, 0.7,0.7,0.7,1.0);

    bDrawCom            = false;
    SET_COLOR4(mComColor, 1.0,1.0,0.0,1.0);

    bDrawRef            = true;
    mRefSize 			= 0.04;

    if(tree!=NULL){
        pXmlTree stree;
        float *array;

        mRefSize = tree->Get("RefSize",0.0f);
        bDrawRef = (mRefSize>0.0001);

        if((stree = tree->Find("Com"))!=NULL){
                 if(stree->GetArray("Color",&array)==3){   COPY_COLOR3(mComColor,array);}
            else if(stree->GetArray("Color",&array)==4){   COPY_COLOR4(mComColor,array);}
            else                                        {  SET_COLOR4 (mComColor,1,1,0,1);}
            bDrawCom = true;
        }else{
            bDrawCom = false;
        }

        if((stree = tree->Find("Color"))!=NULL){
                 if(tree->GetArray("Color",&array)==3){   COPY_COLOR3(mDefaultColor,array);}
            else if(tree->GetArray("Color",&array)==4){   COPY_COLOR4(mDefaultColor,array);}
            else                                       {  SET_COLOR4 (mDefaultColor,0.7,0.7,0.7,1);}
            bUseDefaultColor = true;
        }else{
            bUseDefaultColor = false;
        }
        bUseTransparency = tree->Get("CurrTransparency",false);

    }
    return true;
}
bool  ObjectRenderer::Load(const pXmlTree tree){
    if(tree==NULL) return false;

    gLOG.SetCurrentEntry("ObjectRenderer");
    gLOG.Append("Setting up BBoxShape for object: %s",tree->GetData().c_str());
    gLOG.SetDeltaIndent(2);

    pXmlTree bbox = tree->Find("BBoxShape");
    if(bbox!=NULL){
        pXmlTreeList tmpList = bbox->GetSubTrees();
        for(unsigned int i=0;i<tmpList->size();i++){
            pShapeStruct shape = LoadShape(tmpList->at(i));
            if(shape!=NULL) mBBoxShapes.push_back(shape);
        }
    }else{
        gLOG.SetDeltaIndent(2);
        gLOG.Append("Warning: No <BBoxShape> found");
        gLOG.SetDeltaIndent(-2);
    }
    gLOG.SetDeltaIndent(-2);

    gLOG.Append("Setting up GfxShape for object: %s",tree->GetData().c_str());
    gLOG.SetDeltaIndent(2);

    pXmlTree gfx = tree->Find("GfxShape");
    if(gfx!=NULL){
        pXmlTreeList tmpList = gfx->GetSubTrees();
        for(unsigned int i=0;i<tmpList->size();i++){
            pShapeStruct shape = LoadShape(tmpList->at(i));
            if(shape!=NULL) mShapes.push_back(shape);
        }
    }else{
        gLOG.SetDeltaIndent(2);
        gLOG.Append("Warning: No <GfxShape> found");
        gLOG.SetDeltaIndent(-2);
    }
    gLOG.SetDeltaIndent(-2);
    return true;
}
示例#3
0
bool Link::Load(const pXmlTree tree){

  if(tree==NULL) return false;
  if(tree->GetName()!="Link") return false;

    WorldObject::Load(tree);

  //REALTYPE *array;
  /*
    mName = tree->GetData();
    tree->GetArray("CenterOfMass",&array);
    mCenterOfMass.Set(array);
    tree->GetArray("InertiaMatrix",&array);
    mInertia.mInertiaMoment.Set(array);

//#ifdef WAM_BADREF_CORRECTION
  if(tree->Find("RotorInertia")){
    Matrix dd(3,3);
    Matrix3 dd3;
    Vector d;
    d = Vector(array,tree->GetArray("RotorInertia",&array));
    dd.Diag(d);
    dd3.Set(dd.Array());
    mInertia.mInertiaMoment += dd3;
  }
//#endif

  mInertia.mMass = tree->Get("Mass",0.0);;
  mCenterOfMass.Mult(mInertia.mMass,mInertia.mLinearMoment);
  mInertia.mCenterOfMass = mCenterOfMass;
    */
  mJoint = JointConstructor::Create(tree->Find("Joint"));
  if(mJoint!=NULL)
    mJoint->SetChildLink(this);
  return true;
}