1 | /* |
---|
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. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Benjamin Grauer |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PHYSICS |
---|
17 | |
---|
18 | #include "field.h" |
---|
19 | |
---|
20 | #include "physics_engine.h" |
---|
21 | |
---|
22 | #include "factory.h" |
---|
23 | #include "load_param.h" |
---|
24 | using namespace std; |
---|
25 | |
---|
26 | /** |
---|
27 | * standard constructor |
---|
28 | */ |
---|
29 | Field::Field () |
---|
30 | { |
---|
31 | this->init(); |
---|
32 | } |
---|
33 | |
---|
34 | /** |
---|
35 | * standard deconstructor |
---|
36 | |
---|
37 | */ |
---|
38 | Field::~Field () |
---|
39 | { |
---|
40 | PhysicsEngine::getInstance()->removeField(this); |
---|
41 | } |
---|
42 | |
---|
43 | /** |
---|
44 | \brief initializes a Field |
---|
45 | */ |
---|
46 | void Field::init() |
---|
47 | { |
---|
48 | this->setClassID(CL_FIELD, "Field"); |
---|
49 | this->setMagnitude(1); |
---|
50 | this->setAttenuation(0); |
---|
51 | |
---|
52 | PhysicsEngine::getInstance()->addField(this); |
---|
53 | } |
---|
54 | |
---|
55 | /** |
---|
56 | * @param root The XML-element to load settings from |
---|
57 | */ |
---|
58 | void Field::loadParams(const TiXmlElement* root) |
---|
59 | { |
---|
60 | static_cast<PNode*>(this)->loadParams(root); |
---|
61 | |
---|
62 | LoadParam(root, "magnitude", this, Field, setMagnitude) |
---|
63 | .describe("sets the magnitude of this Field") |
---|
64 | ->defaultValues(1, 1); |
---|
65 | |
---|
66 | LoadParam(root, "attenuation", this, Field, setAttenuation) |
---|
67 | .describe("sets the attenuation of this Field."); |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | /** |
---|
72 | * @param magnitude the magnitude of the Field. |
---|
73 | */ |
---|
74 | void Field::setMagnitude(float magnitude) |
---|
75 | { |
---|
76 | this->magnitude = magnitude; |
---|
77 | } |
---|
78 | |
---|
79 | /** |
---|
80 | * @param attenuation The attenuation of the Field (the bigger the smaller the region of influence) |
---|
81 | */ |
---|
82 | void Field::setAttenuation(float attenuation) |
---|
83 | { |
---|
84 | this->attenuation = attenuation; |
---|
85 | } |
---|