ThrusterMotor.cpp

Go to the documentation of this file.
00001 /*************************************************************************
00002  *                                                                       *
00003  * Open Physics Abstraction Layer                                        *
00004  * Copyright (C) 2004-2005                                               *
00005  * Alan Fischer  alan.fischer@gmail.com                                  *
00006  * Andres Reinot  andres@reinot.com                                      *
00007  * Tyler Streeter  tylerstreeter@gmail.com                               *
00008  * All rights reserved.                                                  *
00009  * Web: opal.sourceforge.net                                             *
00010  *                                                                       *
00011  * This library is free software; you can redistribute it and/or         *
00012  * modify it under the terms of EITHER:                                  *
00013  *   (1) The GNU Lesser General Public License as published by the Free  *
00014  *       Software Foundation; either version 2.1 of the License, or (at  *
00015  *       your option) any later version. The text of the GNU Lesser      *
00016  *       General Public License is included with this library in the     *
00017  *       file license-LGPL.txt.                                          *
00018  *   (2) The BSD-style license that is included with this library in     *
00019  *       the file license-BSD.txt.                                       *
00020  *                                                                       *
00021  * This library is distributed in the hope that it will be useful,       *
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00024  * license-LGPL.txt and license-BSD.txt for more details.                *
00025  *                                                                       *
00026  *************************************************************************/
00027 
00028 #include "ThrusterMotor.h"
00029 #include "Solid.h"
00030 #include "Joint.h"
00031 
00032 namespace opal
00033 {
00034         ThrusterMotor::ThrusterMotor()
00035         : Motor()
00036         {
00037                 // "mData" will be initialized in its own constructor.
00038         }
00039 
00040         ThrusterMotor::~ThrusterMotor()
00041         {
00042         }
00043 
00044         //void ThrusterMotor::init(Solid* solid)
00045         //{
00046         //      Motor::init();
00047         //      mSolid = solid;
00048         //}
00049 
00050         void ThrusterMotor::init(const ThrusterMotorData& data)
00051         {
00052                 Motor::init();
00053                 mData = data;
00054                 mData.force.singleStep = true;
00055         }
00056 
00057         const ThrusterMotorData& ThrusterMotor::getData()const
00058         {
00059                 return mData;
00060         }
00061 
00062         MotorType ThrusterMotor::getType()const
00063         {
00064                 return mData.getType();
00065         }
00066 
00067         void ThrusterMotor::setName(const std::string& name)
00068         {
00069                 mData.name = name;
00070         }
00071 
00072         const std::string& ThrusterMotor::getName()const
00073         {
00074                 return mData.name;
00075         }
00076 
00077         bool ThrusterMotor::isEnabled()const
00078         {
00079                 return mData.enabled;
00080         }
00081 
00082         void ThrusterMotor::setEnabled(bool e)
00083         {
00084                 //if (!mInitCalled)
00085                 //{
00086                 //      return;
00087                 //}
00088 
00089                 mData.enabled = e;
00090         }
00091 
00092         void ThrusterMotor::internal_update()
00093         {
00094                 if (mData.enabled && mData.solid)
00095                 {
00096                         mData.solid->addForce(mData.force);
00097                 }
00098         }
00099 
00100         void ThrusterMotor::setForce(const Force& f)
00101         {
00102                 mData.force = f;
00103                 mData.force.singleStep = true;
00104         }
00105 
00106         const Force& ThrusterMotor::getForce()const
00107         {
00108                 return mData.force;
00109         }
00110 
00111         bool ThrusterMotor::internal_dependsOnSolid(Solid* s)
00112         {
00113                 if (s == mData.solid)
00114                 {
00115                         return true;
00116                 }
00117                 else
00118                 {
00119                         return false;
00120                 }
00121         }
00122 }

Generated on Tue May 16 17:49:52 2006 for OPAL by  doxygen 1.4.6-NO