Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 15, 2008, 5:44:55 PM (16 years ago)
Author:
scheusso
Message:

merged changes from input & camera & network branch into trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/WorldEntity.cc

    r1209 r1293  
    4545    unsigned int WorldEntity::worldEntityCounter_s = 0;
    4646
    47     WorldEntity::WorldEntity()
     47    WorldEntity::WorldEntity() :
     48      velocity_    (0, 0, 0),
     49      acceleration_(0, 0, 0),
     50      rotationAxis_(0, 1, 0),
     51      rotationRate_(0),
     52      momentum_    (0),
     53      node_        (0),
     54      bStatic_     (true)
    4855    {
    4956        RegisterObject(WorldEntity);
    50 
    51         //create();
    52 
    53         this->bStatic_ = true;
    54         this->velocity_ = Vector3(0, 0, 0);
    55         this->acceleration_ = Vector3(0, 0, 0);
    56         this->rotationAxis_ = Vector3(0, 1, 0);
    57         this->rotationRate_ = 0;
    58         this->momentum_ = 0;
    5957
    6058        if (GraphicsEngine::getSingleton().getSceneManager())
     
    6765          registerAllVariables();
    6866        }
    69         else
    70         {
    71           this->node_ = 0;
    72         }
    7367    }
     68   
    7469
    7570    WorldEntity::~WorldEntity()
    7671    {
     72      // just to make sure we clean out all scene nodes
     73      if(this->getNode())
     74        this->getNode()->removeAndDestroyAllChildren();
    7775    }
    7876
     
    8179        if (!this->bStatic_)
    8280        {
     81//             COUT(4) << "acceleration: " << this->acceleration_ << " velocity: " << this->velocity_ << std::endl;
    8382            this->velocity_ += (dt * this->acceleration_);
    8483            this->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
     
    9493        BaseObject::loadParams(xmlElem);
    9594        create();
    96 /*
    97         if (xmlElem->Attribute("position"))
    98         {
    99             std::vector<std::string> pos = tokenize(xmlElem->Attribute("position"),",");
    100             float x, y, z;
    101             String2Number<float>(x, pos[0]);
    102             String2Number<float>(y, pos[1]);
    103             String2Number<float>(z, pos[2]);
    104             this->setPosition(x, y, z);
    105         }
    106 
    107         if (xmlElem->Attribute("direction"))
    108         {
    109             std::vector<std::string> pos = tokenize(xmlElem->Attribute("direction"),",");
    110             float x, y, z;
    111             String2Number<float>(x, pos[0]);
    112             String2Number<float>(y, pos[1]);
    113             String2Number<float>(z, pos[2]);
    114             this->setDirection(x, y, z);
    115         }
    116 
    117         if (xmlElem->Attribute("yaw") || xmlElem->Attribute("pitch") || xmlElem->Attribute("roll"))
    118         {
    119             float yaw = 0.0, pitch = 0.0, roll = 0.0;
    120             if (xmlElem->Attribute("yaw"))
    121                 String2Number<float>(yaw,xmlElem->Attribute("yaw"));
    122 
    123             if (xmlElem->Attribute("pitch"))
    124                 String2Number<float>(pitch,xmlElem->Attribute("pitch"));
    125 
    126             if (xmlElem->Attribute("roll"))
    127                 String2Number<float>(roll,xmlElem->Attribute("roll"));
    128 
    129             this->yaw(Degree(yaw));
    130             this->pitch(Degree(pitch));
    131             this->roll(Degree(roll));
    132         }
    133 
    134         if (xmlElem->Attribute("scale"))
    135         {
    136             std::string scaleStr = xmlElem->Attribute("scale");
    137             float scale;
    138             String2Number<float>(scale, scaleStr);
    139             this->setScale(scale);
    140         }
    141 
    142         if (xmlElem->Attribute("rotationAxis"))
    143         {
    144             std::vector<std::string> pos = tokenize(xmlElem->Attribute("rotationAxis"),",");
    145             float x, y, z;
    146             String2Number<float>(x, pos[0]);
    147             String2Number<float>(y, pos[1]);
    148             String2Number<float>(z, pos[2]);
    149             this->setRotationAxis(x, y, z);
    150         }
    151 
    152         if (xmlElem->Attribute("rotationRate"))
    153         {
    154             float rotationRate;
    155             String2Number<float>(rotationRate, xmlElem->Attribute("rotationRate"));
    156             this->setRotationRate(Degree(rotationRate));
    157             if (rotationRate != 0)
    158                 this->setStatic(false);
    159         }
    160 
    161         create();
    162 */
    16395    }
     96   
    16497
    16598    void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll)
     
    188121
    189122        XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true);
     123       
     124        WorldEntity::create();
    190125    }
    191126
     
    194129    {
    195130      // register coordinates
    196       registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA);
    197       registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA);
    198       registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA);
     131      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3);
     132      registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA, 0x3);
     133      registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA, 0x3);
    199134      // register orientation
    200       registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA);
    201       registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA);
    202       registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA);
    203       registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA);
    204       // not needed at the moment, because we don't have prediction yet
     135      registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA, 0x3);
     136      registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA, 0x3);
     137      registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA, 0x3);
     138      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3);
    205139      // register velocity_
    206       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA);
    207       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA);
    208       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA);
    209       // register rotationAxis/rate
    210       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA);
    211       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA);
    212       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA);
    213       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);
     140//       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
     141//       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
     142//       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
     143//       // register rotationAxis/rate
     144//       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
     145//       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
     146//       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
     147//       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
     148      // register scale of node
     149      registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3);
     150      registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA, 0x3);
     151      registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA, 0x3);
     152      //register staticity
     153      registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
     154      //register acceleration
     155      // register velocity_
     156//       registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);
     157//       registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);
     158//       registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);
    214159    }
    215160
Note: See TracChangeset for help on using the changeset viewer.