Esempio n. 1
0
bool World::Load(pXmlTree tree){
    if(tree==NULL) return false;

    Free();
    pXmlTreeList  tmpTreeList;
    string        str;

    gLOG.SetCurrentEntry("World");
    gLOG.Append("Loading World: %s",tree->GetData().c_str());
    gLOG.SetDeltaIndent(2);
    tmpTreeList = tree->GetSubTrees();

    for(unsigned int i=0;i<tmpTreeList->size();i++){
        if(tmpTreeList->at(i)->GetName()=="Object"){
            pWorldObject obj = new WorldObject();
            if(obj->Load(tmpTreeList->at(i))){
                AddObject(obj,true);
            }
        }else if(tmpTreeList->at(i)->GetName()=="FixJoint"){
            WorldObjectLink* link = new WorldObjectLink(tmpTreeList->at(i)->Get("ObjectA",string("")),
                                                        tmpTreeList->at(i)->Get("ObjectB",string("")));
            mObjectLinks.push_back(link);
        }

    }
    gLOG.SetDeltaIndent(-2);
    return true;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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;
}
Esempio n. 4
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;
}
Esempio n. 5
0
void ModuleInterface::SetOptionTree(pXmlTree tree){
    if(mOptionTree) delete mOptionTree; mOptionTree = NULL;
    if(tree!=NULL)
        mOptionTree = tree->Clone();
}