Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 622 for code/branches/FICN/src


Ignore:
Timestamp:
Dec 18, 2007, 6:03:54 PM (16 years ago)
Author:
landauf
Message:

added some randomly generated (rotating) asteroids

Location:
code/branches/FICN/src/orxonox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/orxonox/Main.cc

    r618 r622  
    123123      orx->start();
    124124#else
     125/*
     126for (int i = 0; i < 500; i++)
     127{
     128int x = rand() % 40000 - 20000;
     129int y = rand() % 40000 - 20000;
     130int z = rand() % 40000 - 20000;
     131
     132int scale = rand() % 100 + 20;
     133
     134int version = rand() % 6 + 1;
     135
     136float rotx = float(rand()) / RAND_MAX;
     137float roty = float(rand()) / RAND_MAX;
     138float rotz = float(rand()) / RAND_MAX;
     139
     140int axis = rand() % 3 + 1;
     141
     142if (axis == 1)
     143  rotx = 0;
     144if (axis == 2)
     145  roty = 0;
     146if (axis == 3)
     147  rotz = 0;
     148
     149int rotation = rand() % 40 + 10;
     150
     151//    <Model position="1000,1500,0" scale="50" mesh="ast1.mesh" rotationAxis="0,1.25,0" rotationRate="70" />
     152std::cout << "    <Model position=\"" << x << "," << y << "," << z << "\" scale=\"" << scale << "\" mesh=\"ast" << version << ".mesh\" rotationAxis=\"" << rotx << "," << roty << "," << rotz << "\" rotationRate=\"" << rotation << "\" />" << std::endl;
     153
     154
     155}
     156*/
    125157      orx->init(argc, argv, "");
    126158      orx->start();
  • code/branches/FICN/src/orxonox/objects/Model.cc

    r614 r622  
    2525        WorldEntity::loadParams(xmlElem);
    2626
    27         if (xmlElem->Attribute("mesh"))
    28         {
    29                 std::string src = xmlElem->Attribute("mesh");
    30                 this->mesh_.setMesh(src);
    31                     this->attachObject(this->mesh_.getEntity());
     27        if (xmlElem->Attribute("mesh"))
     28        {
     29            std::string src = xmlElem->Attribute("mesh");
     30            this->mesh_.setMesh(src);
     31            this->attachObject(this->mesh_.getEntity());
    3232        }
    3333
  • code/branches/FICN/src/orxonox/objects/WorldEntity.cc

    r614 r622  
    8282        BaseObject::loadParams(xmlElem);
    8383
    84         if (xmlElem->Attribute("name"))
    85         {
    86                 this->setName(xmlElem->Attribute("mesh"));
    87         }
     84        if (xmlElem->Attribute("name"))
     85        {
     86            this->setName(xmlElem->Attribute("mesh"));
     87        }
    8888
    89         if (xmlElem->Attribute("position"))
    90         {
    91                 std::vector<std::string> pos = tokenize(xmlElem->Attribute("position"),",");
    92                 float x, y, z;
    93                 String2Number<float>(x, pos[0]);
    94                 String2Number<float>(y, pos[1]);
    95                 String2Number<float>(z, pos[2]);
    96                 this->setPosition(x, y, z);
    97         }
     89        if (xmlElem->Attribute("position"))
     90        {
     91            std::vector<std::string> pos = tokenize(xmlElem->Attribute("position"),",");
     92            float x, y, z;
     93            String2Number<float>(x, pos[0]);
     94            String2Number<float>(y, pos[1]);
     95            String2Number<float>(z, pos[2]);
     96            this->setPosition(x, y, z);
     97        }
    9898
    99         if (xmlElem->Attribute("direction"))
    100         {
    101                 std::vector<std::string> pos = tokenize(xmlElem->Attribute("direction"),",");
    102                 float x, y, z;
    103                 String2Number<float>(x, pos[0]);
    104                 String2Number<float>(y, pos[1]);
    105                 String2Number<float>(z, pos[2]);
    106                 this->setDirection(x, y, z);
    107         }
     99        if (xmlElem->Attribute("direction"))
     100        {
     101            std::vector<std::string> pos = tokenize(xmlElem->Attribute("direction"),",");
     102            float x, y, z;
     103            String2Number<float>(x, pos[0]);
     104            String2Number<float>(y, pos[1]);
     105            String2Number<float>(z, pos[2]);
     106            this->setDirection(x, y, z);
     107        }
    108108
    109109        if (xmlElem->Attribute("yaw") || xmlElem->Attribute("pitch") || xmlElem->Attribute("roll"))
     
    124124        }
    125125
    126         if (xmlElem->Attribute("scale"))
    127         {
    128                     std::string scaleStr = xmlElem->Attribute("scale");
    129                     float scale;
    130                     String2Number<float>(scale, scaleStr);
    131                     this->setScale(scale);
    132         }
     126        if (xmlElem->Attribute("scale"))
     127        {
     128            std::string scaleStr = xmlElem->Attribute("scale");
     129            float scale;
     130            String2Number<float>(scale, scaleStr);
     131            this->setScale(scale);
     132        }
     133
     134        if (xmlElem->Attribute("rotationAxis"))
     135        {
     136            std::vector<std::string> pos = tokenize(xmlElem->Attribute("rotationAxis"),",");
     137            float x, y, z;
     138            String2Number<float>(x, pos[0]);
     139            String2Number<float>(y, pos[1]);
     140            String2Number<float>(z, pos[2]);
     141            this->setRotationAxis(x, y, z);
     142        }
     143
     144        if (xmlElem->Attribute("rotationRate"))
     145        {
     146            float rotationRate;
     147            String2Number<float>(rotationRate, xmlElem->Attribute("rotationRate"));
     148            this->setRotationRate(Degree(rotationRate));
     149            if (rotationRate != 0)
     150                this->setStatic(false);
     151        }
     152
    133153    }
    134154
  • code/branches/FICN/src/orxonox/objects/WorldEntity.h

    r589 r622  
    123123          { return this->node_->getOrientation(); }
    124124
     125      inline void setStatic(bool bStatic)
     126          { this->bStatic_ = bStatic; }
     127      inline bool isStatic()
     128          { return this->bStatic_; }
     129
    125130    protected:
    126131      void registerAllVariables();
Note: See TracChangeset for help on using the changeset viewer.