source: OGRE/trunk/ogrenew/PlugIns/ParticleFX/src/OgreAreaEmitter.cpp @ 692

Revision 692, 6.4 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright ) 2002 Tels <http://bloodgate.com> Based on OgrreBoxEmitter
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#include "OgreAreaEmitter.h"
26#include "OgreParticle.h"
27#include "OgreQuaternion.h"
28#include "OgreException.h"
29#include "OgreStringConverter.h"
30
31
32
33namespace Ogre {
34
35    // Instatiate statics
36    AreaEmitter::CmdWidth AreaEmitter::msWidthCmd;
37    AreaEmitter::CmdHeight AreaEmitter::msHeightCmd;
38    AreaEmitter::CmdDepth AreaEmitter::msDepthCmd;
39
40    //-----------------------------------------------------------------------
41    bool AreaEmitter::initDefaults(const String& t)
42    {
43        // called by the constructor as initDefaults("Type")
44
45        // Defaults
46        mDirection = Vector3::UNIT_Z;
47        mUp = Vector3::UNIT_Y;
48        setSize(100,100,100);
49        mType = t;
50
51        // Set up parameters
52        if (createParamDictionary(mType + "Emitter"))
53        {
54
55            addBaseParameters();
56            ParamDictionary* dict = getParamDictionary();
57
58            // Custom params
59            dict->addParameter(ParameterDef("width",
60                "Width of the shape in world coordinates.",
61                PT_REAL),&msWidthCmd);
62            dict->addParameter(ParameterDef("height",
63                "Height of the shape in world coordinates.",
64                PT_REAL),&msHeightCmd);
65            dict->addParameter(ParameterDef("depth",
66                "Depth of the shape in world coordinates.",
67                PT_REAL),&msDepthCmd);
68            return true;
69
70        }
71        return false;
72    }
73
74    //-----------------------------------------------------------------------
75    unsigned short AreaEmitter::_getEmissionCount(Real timeElapsed)
76    {
77        // Use basic constant emission
78        return genConstantEmissionCount(timeElapsed);
79    }
80    //-----------------------------------------------------------------------
81    void AreaEmitter::setDirection( const Vector3& direction )
82    {
83        ParticleEmitter::setDirection( direction );
84
85        // Update the ranges
86        genAreaAxes();
87
88       
89    }
90    //-----------------------------------------------------------------------
91    void AreaEmitter::setSize(const Vector3& size)
92    {
93        mSize = size;
94        genAreaAxes();
95    }
96    //-----------------------------------------------------------------------
97    void AreaEmitter::setSize(Real x, Real y, Real z)
98    {
99        mSize.x = x;
100        mSize.y = y;
101        mSize.z = z;
102        genAreaAxes();
103    }
104    //-----------------------------------------------------------------------
105    void AreaEmitter::setWidth(Real width)
106    {
107        mSize.x = width;
108        genAreaAxes();
109    }
110    //-----------------------------------------------------------------------
111    Real AreaEmitter::getWidth(void) const
112    {
113        return mSize.x;
114    }
115    //-----------------------------------------------------------------------
116    void AreaEmitter::setHeight(Real height)
117    {
118        mSize.y = height;
119        genAreaAxes();
120    }
121    //-----------------------------------------------------------------------
122    Real AreaEmitter::getHeight(void) const
123    {
124        return mSize.y;
125    }
126    //-----------------------------------------------------------------------
127    void AreaEmitter::setDepth(Real depth)
128    {
129        mSize.z = depth;
130        genAreaAxes();
131    }
132    //-----------------------------------------------------------------------
133    Real AreaEmitter::getDepth(void) const
134    {
135        return mSize.z;
136    }
137    //-----------------------------------------------------------------------
138    void AreaEmitter::genAreaAxes(void)
139    {
140        Vector3 mLeft = mUp.crossProduct(mDirection);
141
142        mXRange = mLeft * (mSize.x * 0.5f);
143        mYRange = mUp * (mSize.y * 0.5f);
144        mZRange = mDirection * (mSize.z * 0.5f);
145    }
146
147    //-----------------------------------------------------------------------
148    // Command objects
149    //-----------------------------------------------------------------------
150    //-----------------------------------------------------------------------
151    String AreaEmitter::CmdWidth::doGet(const void* target) const
152    {
153        return StringConverter::toString(
154            static_cast<const AreaEmitter*>(target)->getWidth() );
155    }
156    void AreaEmitter::CmdWidth::doSet(void* target, const String& val)
157    {
158        static_cast<AreaEmitter*>(target)->setWidth(StringConverter::parseReal(val));
159    }
160    //-----------------------------------------------------------------------
161    String AreaEmitter::CmdHeight::doGet(const void* target) const
162    {
163        return StringConverter::toString(
164            static_cast<const AreaEmitter*>(target)->getHeight() );
165    }
166    void AreaEmitter::CmdHeight::doSet(void* target, const String& val)
167    {
168        static_cast<AreaEmitter*>(target)->setHeight(StringConverter::parseReal(val));
169    }
170    //-----------------------------------------------------------------------
171    String AreaEmitter::CmdDepth::doGet(const void* target) const
172    {
173        return StringConverter::toString(
174            static_cast<const AreaEmitter*>(target)->getDepth() );
175    }
176    void AreaEmitter::CmdDepth::doSet(void* target, const String& val)
177    {
178        static_cast<AreaEmitter*>(target)->setDepth(StringConverter::parseReal(val));
179    }
180
181
182
183}
184
185
Note: See TracBrowser for help on using the repository browser.