Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core3/src/orxonox/objects/ParticleProjectile.cc @ 1676

Last change on this file since 1676 was 1676, checked in by landauf, 16 years ago

a first test-version of my super-macro
tested with a testfunction in Projectile, just shoot to test
no idea if this works on other compilers (namely MSVC)

  • Property svn:eol-style set to native
File size: 5.1 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30#include "ParticleProjectile.h"
31
32#include "SpaceShip.h"
33#include "core/CoreIncludes.h"
34#include "core/ConfigValueIncludes.h"
35//#include "util/FastDelegate.h"
36//using namespace fastdelegate;
37
38namespace orxonox
39{
40    CreateFactory(ParticleProjectile);
41
42    struct FunctionPointerViewer
43    {
44        void* ptr1_;
45        void* ptr2_;
46
47        void view()
48        {
49            std::cout << ptr1_ << "." << ptr2_ << std::endl;
50        }
51    };
52
53    union FunctionPointerViewer1
54    {
55        FunctionPointerViewer viewer_;
56        void (Projectile::*function_) ();
57    };
58
59    union FunctionPointerViewer2
60    {
61        FunctionPointerViewer viewer_;
62        void (BillboardProjectile::*function_) ();
63    };
64
65    union FunctionPointerViewer3
66    {
67        FunctionPointerViewer viewer_;
68        void (ParticleProjectile::*function_) ();
69    };
70
71    ParticleProjectile::ParticleProjectile(SpaceShip* owner) : BillboardProjectile(owner)
72    {
73        RegisterObject(ParticleProjectile);
74
75        if (this->owner_)
76        {
77            this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal);
78            this->particles_->addToSceneNode(this->getNode());
79            this->particles_->getAllEmitters()->setDirection(-this->owner_->getInitialDir());
80            this->particles_->setKeepParticlesInLocalSpace(true);
81        }
82        else
83        {
84            this->particles_ = 0;
85        }
86
87        this->setConfigValues();
88/*
89        FunctionPointerViewer1 fpw1;
90        fpw1.function_ = &Projectile::testfunction;
91        FunctionPointerViewer2 fpw2;
92        fpw2.function_ = &BillboardProjectile::testfunction;
93        FunctionPointerViewer3 fpw3;
94        fpw3.function_ = &ParticleProjectile::testfunction;
95
96        std::cout << sizeof(void (Projectile::*) ()) << std::endl;
97        fpw1.viewer_.view();
98        fpw2.viewer_.view();
99        fpw3.viewer_.view();
100
101        {
102            std::cout << "1:" << std::endl;
103            FastDelegate0<> delegate1(this, &ParticleProjectile::testfunction);
104            delegate1();
105            FastDelegate0<> delegate2((BillboardProjectile*)this, &BillboardProjectile::testfunction);
106            delegate2();
107            FastDelegate0<> delegate3(this, &Projectile::testfunction);
108            delegate3();
109        }
110        {
111            std::cout << "2:" << std::endl;
112            BillboardProjectile temp;
113//            FastDelegate0<> delegate1(&temp, &ParticleProjectile::testfunction);
114//            delegate1();
115            FastDelegate0<> delegate2(&temp, &BillboardProjectile::testfunction);
116            delegate2();
117            FastDelegate0<> delegate3(&temp, &Projectile::testfunction);
118            delegate3();
119        }
120        std::cout << "done" << std::endl;
121
122        std::cout << "0:" << std::endl;
123        this->Projectile::testfunction();
124        this->BillboardProjectile::testfunction();
125        this->ParticleProjectile::testfunction();
126        this->testfunction();
127
128        std::cout << "1:" << std::endl;
129        (this->*fpw1.function_)();
130        std::cout << "2:" << std::endl;
131        (this->*fpw2.function_)();
132        std::cout << "3:" << std::endl;
133        (this->*fpw3.function_)();
134        std::cout << "done" << std::endl;
135*/
136        std::cout << "c:\n";
137        SUPER(ParticleProjectile, testfunction);
138        std::cout << "d:\n";
139
140        std::cout << "e:\n";
141        this->testfunction();
142        std::cout << "f:\n";
143
144//        (*((ClassIdentifier<SuperDummy>*)this->getIdentifier())->superFunctionCaller_testfunction_)(this);
145    }
146
147    ParticleProjectile::~ParticleProjectile()
148    {
149        if (this->isInitialized() && this->particles_)
150            delete this->particles_;
151    }
152
153    void ParticleProjectile::setConfigValues()
154    {
155        SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback((Projectile*)this, &ParticleProjectile::speedChanged);
156    }
157
158    void ParticleProjectile::changedVisibility()
159    {
160        BillboardProjectile::changedVisibility();
161        this->particles_->setEnabled(this->isVisible());
162    }
163
164    void ParticleProjectile::testfunction() { SUPER(ParticleProjectile, testfunction); std::cout << "3 -> " << std::endl; }
165}
Note: See TracBrowser for help on using the repository browser.