⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objects.cpp

📁 robocup 3d, a 3d base team similar to UvA 2d
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***********************************************************************************                            In the name of Almighty                            **                                                                               **           Objects.cpp : Robocup 3D Soccer Simulation Team Zigorat             **                     (This team was previously named Gcyrus)                   **                                                                               **  Date: 03/20/2007                                                             **  Author: Mahdi Hamdarsi                                                       **  Comments: This file contains Objects definition which represent soccer       **            players, flags, etc.                                               **                                                                               ***********************************************************************************//*! \file Objects.cpp<pre><b>File:</b>          Objects.cpp<b>Project:</b>       Robocup Soccer Simulation Team: Zigorat<b>Authors:</b>       Mahdi Hamdarsi<b>Created:</b>       03/20/2007<b>Last Revision:</b> $ID$<b>Contents:</b>      This file contains Objects definition which represent soccer               players, flags, etc.<hr size=2><h2><b>Changes</b></h2><b>Date</b>             <b>Author</b>          <b>Comment</b>03/20/2007       Mahdi           Initial version created</pre>*/#include "Objects.h"#include <iostream>using namespace std;/*****************************************************************************//********************   CLASS OBJECT  ****************************************//*****************************************************************************//*! This constructor creates an object, all variables are initialized by   default (illegal) values    */Object::Object(){}/*! This destructor destroys an object, all variables are freed and deleted     by this routine*/Object::~Object(){}/*! This method returns the global position of this object. The time of this    information is related to the time returned by the last time this object     was seen, but is not checked.    \return global position of this object */VecPosition Object::getPosition() const{  return m_Position;}/*! This method sets the global position of the object upon the information     recieved from server.    \param newPos new global position    \return bool indicating whether the values were set */void Object::setPosition(VecPosition newPos){  m_Position = newPos;}/*! This method returns the last time object was seen    \return Time last iem object was seen */Time Object::getTimeLastSeen() const{  return m_TimeLastSeen; }/*! This method sets the time that object was last seen through a see message    \param time Time that object is seen    \return bool Indicating update was successfull */bool Object::setTimeLastSeen( Time time ){  m_TimeLastSeen = time;  return true;}/*****************************************************************************//********************   CLASS FLAGOBJECT  ************************************//*****************************************************************************//*! This is the constructor for he FlagObject, Nothing     important to do here */FlagObject::FlagObject():Object(){}/*! This is destructor of the FlagObject, Does Nothing.*/FlagObject::~FlagObject(){}/*! This method get the flag name and returns the name    \return string Indicating name of flag */ObjectT FlagObject::getID() const{  return m_ID;}/*! This method sets the flag name.    \param newID new flag name    \return bool indicating whether the values were set */bool FlagObject::setID( ObjectT newID ){  m_ID = newID;  return true;}/*****************************************************************************//********************* CLASS DynamicObject ***********************************//*****************************************************************************//*! This is the constructor for DynamicObject. A DynamicObject is created with    all the variables initialized by default values */DynamicObject::DynamicObject(): Object(){    m_IsFirstPosition = true;    m_IsFirstVelocity = true;}/*! This is the destructor for DynamicObject.*/DynamicObject::~DynamicObject( ){}/*! This method sets the global position of the object upon the information     recieved from server.    \param pos new global position    \return bool indicating whether the values were set */void DynamicObject::setPosition(VecPosition pos){  if( m_IsFirstPosition )  {    m_Position        = pos;    m_Accelaration    = VecPosition(0, 0, 0);    m_Velocity        = VecPosition(0, 0, 0);    m_IsFirstPosition = false;  }  else  {    VecPosition NewVelocity = pos - m_Position;    if( m_IsFirstVelocity )    {      m_Accelaration    = VecPosition(0, 0, 0);      m_IsFirstVelocity = false;    }    else    {      m_Accelaration = NewVelocity - m_Velocity;    }    m_Velocity = NewVelocity;    m_Position = pos;  }}/*! This method returns the velocity of the object,     velocity is computed in the worldmodel    \return VecPosition Indicating the velocity of the dynamic object*/VecPosition DynamicObject::getVelocity() const{  return m_Velocity;}/*! This method returns the acceleration of the object,     acceleration is computed in world model.    \return VecPosition Indicating the acceleration of the dynamic object*/VecPosition DynamicObject::getAccelaration() const{  return m_Accelaration;}/*****************************************************************************//********************* CLASS BallObject **************************************//*****************************************************************************//*! This is the constructor for a BallObject. It does nothing except    initializing the class. */BallObject::BallObject() : DynamicObject(){}/*! This is the destructor for a BallObject. It does nothing except    finalizing the class. */BallObject::~BallObject(){}/*! This method sets the radius of the ball. The radius can not be     issued until server sends the information in init process, cause    the value possibly changes.    \param value value of the radius of ball    \return bool to make sure the assignment is done */bool BallObject::setRadius( double value ){  m_Radius = value;  return true;}/*! This method return the raius of ball.    \return double The radius of ball sent by the server*/double BallObject::getRadius( ) const{  return m_Radius;}/*! This method sets the mass of the ball. The mass can not be     issued until server sends the information in init process,    cause the value possibly changes.    \param value value of the mass of ball    \return bool to make sure the assignment is done */bool BallObject::setMass( double value ){  m_Mass = value;  return true;}/*! This method return the mass of ball.    \return double The mass of ball sent by the server */double BallObject::getMass( ) const{  return m_Mass;}/*****************************************************************************//********************* CLASS PLAYEROBJECT ************************************//*****************************************************************************//*! This is the constructor for PlayerObject. A PlayerObject is created with    all variables initialized to default values */PlayerObject::PlayerObject( ) :DynamicObject( ){}/*! This is the destructor for PlayerObject. Frees PlayerObject and    associated objects */PlayerObject::~ PlayerObject( ){}/*! This method gets the players number which is recieved from the server    within a see message.    \return int Number of player in game*/int PlayerObject::getNumber( ) const{  return m_Number;}/*! This method sets the players number which is recieved from the server    within a see message.    \param newNum Number for the player    \return bool Indicating wheather update was successfull*/bool PlayerObject::setNumber( int newNum ){  m_Number = newNum;  return true;}/*! This method returns the current direction of player    \return AngDeg current direction of player */AngDeg PlayerObject::getDirection() const{  return m_Direction;}/*! This method sets he current direction of the player to the given    value specified    \param ang New angle of the player    \return bool Indicating wheather update was succesful */bool PlayerObject::setDirection(AngDeg ang){  m_Direction = ang;  return true;}/*! This method gets the team side of player which is recieved from     the server within a see message.    \return SideT Side of player in game*/SideT PlayerObject::getTeamSide( ) const{  return m_TeamSide;}/*! This method sets the team side of the player which comes with a     messge from the server.    \param newSide The side of player    \return bool indicating wheather update was successfull*/bool PlayerObject::setTeamSide( SideT newSide ){  m_TeamSide = newSide;  return true;}/*****************************************************************************//********************* CLASS AGENTOBJECT *************************************//*****************************************************************************//*! This is the constructor for the class AgentObject and initializes the    variables with the AgentObject. This the class that contains information    about the agent itself. */AgentObject::AgentObject( ) :PlayerObject( ){  m_Number     = 0;  m_Battery    = 100;  m_Temprature = 23;  m_Mass       = 75;}/*! This is the destructor of AgentObject. Currently does nothing.*/AgentObject::~AgentObject( ){}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -