[4728] | 1 | /* |
---|
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[4179] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[5357] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PHYSICS |
---|
[1853] | 17 | |
---|
[4179] | 18 | #include "field.h" |
---|
[1853] | 19 | |
---|
[4394] | 20 | #include "physics_engine.h" |
---|
| 21 | |
---|
[4728] | 22 | #include "factory.h" |
---|
| 23 | #include "load_param.h" |
---|
[1856] | 24 | using namespace std; |
---|
[1853] | 25 | |
---|
[3245] | 26 | /** |
---|
[4836] | 27 | * standard constructor |
---|
[3245] | 28 | */ |
---|
[4728] | 29 | Field::Field () |
---|
[3365] | 30 | { |
---|
[4728] | 31 | this->init(); |
---|
[3365] | 32 | } |
---|
[1853] | 33 | |
---|
[4728] | 34 | /** |
---|
[4836] | 35 | * standard deconstructor |
---|
[1853] | 36 | |
---|
[3245] | 37 | */ |
---|
[4728] | 38 | Field::~Field () |
---|
[3543] | 39 | { |
---|
[4394] | 40 | PhysicsEngine::getInstance()->removeField(this); |
---|
[3543] | 41 | } |
---|
[4179] | 42 | |
---|
[4728] | 43 | /** |
---|
| 44 | \brief initializes a Field |
---|
| 45 | */ |
---|
[4746] | 46 | void Field::init() |
---|
[4728] | 47 | { |
---|
| 48 | this->setClassID(CL_FIELD, "Field"); |
---|
| 49 | this->setMagnitude(1); |
---|
| 50 | this->setAttenuation(0); |
---|
[4179] | 51 | |
---|
[4728] | 52 | PhysicsEngine::getInstance()->addField(this); |
---|
| 53 | } |
---|
| 54 | |
---|
[4179] | 55 | /** |
---|
[4836] | 56 | * @param root The XML-element to load settings from |
---|
[4728] | 57 | */ |
---|
| 58 | void Field::loadParams(const TiXmlElement* root) |
---|
| 59 | { |
---|
| 60 | static_cast<PNode*>(this)->loadParams(root); |
---|
| 61 | |
---|
| 62 | LoadParam<Field>(root, "magnitude", this, &Field::setMagnitude) |
---|
| 63 | .describe("sets the magnitude of this Field"); |
---|
| 64 | |
---|
| 65 | LoadParam<Field>(root, "attenuation", this, &Field::setAttenuation) |
---|
| 66 | .describe("sets the attenuation of this Field."); |
---|
| 67 | |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | /** |
---|
[4836] | 71 | * @param magnitude the magnitude of the Field. |
---|
[4179] | 72 | */ |
---|
[4728] | 73 | void Field::setMagnitude(float magnitude) |
---|
[4179] | 74 | { |
---|
| 75 | this->magnitude = magnitude; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | /** |
---|
[4836] | 79 | * @param attenuation The attenuation of the Field (the bigger the smaller the region of influence) |
---|
[4179] | 80 | */ |
---|
[4728] | 81 | void Field::setAttenuation(float attenuation) |
---|
[4179] | 82 | { |
---|
| 83 | this->attenuation = attenuation; |
---|
| 84 | } |
---|