Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickup3/src/modules/pickup/DroppedItem.cc @ 6420

Last change on this file since 6420 was 6419, checked in by rgrieder, 14 years ago

Merged pickup2 into pickup3.

  • Property svn:eol-style set to native
File size: 3.4 KB
RevLine 
[3079]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 *      Daniel 'Huty' Haggenmueller
24 *   Co-authors:
25 *      ...
26 *
27 */
28
[2917]29#include "DroppedItem.h"
30
[3196]31#include "util/Math.h"
32#include "core/CoreIncludes.h"
33#include "core/Executor.h"
[2917]34#include "BaseItem.h"
[5737]35#include "graphics/Billboard.h"
36#include "graphics/Model.h"
[5735]37#include "worldentities/pawns/Pawn.h"
[2917]38
39namespace orxonox
40{
[5953]41    CreateFactory(DroppedItem); //TODO: This isn't needed, is it?
[2917]42
[5947]43    /**
44    @brief
45        Constructor. Registers object and sets default values.
46    */
[5953]47    DroppedItem::DroppedItem(BaseObject* creator) : PickupSpawner(creator)
[2917]48    {
49        RegisterObject(DroppedItem);
[5953]50    }
[2917]51
[5953]52    DroppedItem::DroppedItem(BaseObject* creator, BaseItem* item, float triggerDistance, float respawnTime, int maxSpawnedItems) : PickupSpawner(creator, item, triggerDistance, respawnTime, maxSpawnedItems)
53    {
54        RegisterObject(DroppedItem);
55        this->item_ = item;
[2917]56    }
[5947]57
58    /**
59    @brief
60        Default destructor.
61    */
[2917]62    DroppedItem::~DroppedItem()
63    {
[5947]64       
[2917]65    }
[5947]66
[5953]67    BaseItem* DroppedItem::getItem(void)
[2917]68    {
[5953]69        return this->item_;
[2917]70    }
[5947]71
72    /**
73    @brief
74       
75    */
76    //TODO: Comment.
77    //Each pickup should have a XML template where the Model and Billboard, and so on, is specified.
78    /*static*/ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)
[2917]79    {
[5953]80        //TODO: triggerDistance?
81        float triggerDistance = 20.0;
82        DroppedItem* droppedItem = new DroppedItem(item, item, triggerDistance, 0, 1);
83       
84        //TODO: Do this somehwere else?
[2917]85        Model* model = new Model(item);
86        Billboard* billboard = new Billboard(item);
[3079]87
[2917]88        model->setMeshSource("sphere.mesh");
89        model->setScale(3.0f);
90
91        billboard->setMaterial("Examples/Flare");
92        billboard->setColour(flareColour);
93        billboard->setScale(0.5f);
94
[5953]95        droppedItem->setPosition(position);
96        droppedItem->attach(model);
97        droppedItem->attach(billboard);
[2917]98
[6419]99        COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << ',' << position.y << ',' << position.z << ")." << std::endl;
[2917]100
[5953]101        return droppedItem;
[2917]102    }
[5947]103
104    /**
105    @brief
106
107    */
108    //TODO: See one function above.
[2917]109    DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour, float timeToLive)
110    {
111        Vector3 after = pawn->getPosition() + pawn->getOrientation() * Vector3(0.0f, 0.0f, 50.0f);
112        return DroppedItem::createDefaultDrop(item, after, flareColour, timeToLive);
113    }
114}
Note: See TracBrowser for help on using the repository browser.