Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 24, 2016, 4:01:11 PM (8 years ago)
Author:
ooguz
Message:

Waypointarrow und Waypoint Klassen

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/QuestGuide_HS16/src/orxonox/worldentities/Waypoint.cc

    r11237 r11243  
    1313    {
    1414        RegisterObject(Waypoint);
    15 
    16         this->setPriority(Priority::VeryLow);
    17 
    18         this->registerVariables();
     15        model = new Model(this->getContext());
     16        model->setMeshSource("cube.mesh");  // Name of the arrow file for now bottle
     17        model->setScale(3);
     18        //model->setOrientation(Vector3(0,0,-1));
     19        model->setPosition(this->getPosition());        // this is wrong, it has to be triggered
    1920    }
    2021
     
    2425
    2526
     27     WorldEntity::setDirection
     28     WorldEntity::getPosition()
     29     setOrientation()
     30
     31
    2632    void Waypoint::XMLPort(Element& xmlelement, XMLPort::Mode mode){
    2733        SUPER(Waypoint, XMLPort, xmlelement, mode); // From the SpaceShip.cc file
    28 
    29 
    3034        //XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode); // TRY ADDING THE WAYPOINT ARROW LIKE AN ENGINE
    3135 
     
    3438
    3539
    36 
    37     void Waypoint::registerVariables()
    38     {
    39         // Ugly const casts, but are valid because position and orientation are not actually const
    40         registerVariable(const_cast<Vector3&>(this->getPosition()), \
    41             VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
    42         registerVariable(const_cast<Quaternion&>(this->getOrientation()),
    43             VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
    44     }
    45 
    46 
    47 
    48     void Waypoint::setOrientation(const Quaternion& orientation)
    49     {
    50         if (this->addedToPhysicalWorld())
    51         {
    52             orxout(internal_warning) << "Attempting to change the orientation of a StaticEntity at physics run time. Ignoring change." << endl;
    53             return;
    54         }
    55         if (this->isStatic())
    56         {
    57             btTransform transf = this->physicalBody_->getWorldTransform();
    58             transf.setRotation(btQuaternion(orientation.x, orientation.y, orientation.z, orientation.w));
    59             this->physicalBody_->setWorldTransform(transf);
    60         }
    61 
    62         this->node_->setOrientation(orientation);
    63  
    64     }
    65 
    66     Vector3 Waypoint::toAimPosition(RadarViewable* target) const
    67     {
    68         Vector3 wePosition = HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition();
    69         Vector3 targetPosition = target->getRVWorldPosition();
    70         Vector3 targetSpeed = target->getRVVelocity();
    71 
    72         return getPredictedPosition(wePosition, this->currentMunitionSpeed_, targetPosition, targetSpeed);
    73     }
    74 
    75 /*
    76     bool StaticEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const
    77     {
    78         if (type == WorldEntity::CollisionType::Kinematic || type == WorldEntity::CollisionType::Dynamic)
    79         {
    80             orxout(internal_warning) << "Cannot tell a StaticEntity to have kinematic or dynamic collision type! Ignoring." << endl;
    81             assert(false); // Only in debug mode
    82             return false;
    83         }
    84         else
    85             return true;
    86     }
    87 */
    88     void Waypoint::setWorldTransform(const btTransform& worldTrans)
    89     {
    90         OrxAssert(false, "Setting world transform of a StaticEntity, which is CF_STATIC!");
    91     }
    92 
    93     void Waypoint::getWorldTransform(btTransform& worldTrans) const
    94     {
    95         worldTrans.setOrigin(btVector3(node_->getPosition().x, node_->getPosition().y, node_->getPosition().z));
    96         worldTrans.setRotation(btQuaternion(node_->getOrientation().x, node_->getOrientation().y, node_->getOrientation().z, node_->getOrientation().w));
    97     }
    9840}
    99 
    100 
    101 const Pawn* pawnPtr = orxonox_cast<const Pawn*>(it->first->getWorldEntity());
    102 
    103 if (pawnPtr) {
    104    float position = pawnPtr->getPosition();
Note: See TracChangeset for help on using the changeset viewer.