Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > media > contrib > by-pkgid > 06719cf03808e17ae6f0852ca1052dc2 > files > 461

libogre1-devel-0.13.0-1mdk.i586.rpm

<html>
<head>
<title>OgreCylinderEmitter.cpp Source File - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<link type="text/css" rel="stylesheet" href="style.css">
</head>

<body>
<!-- Generated by Doxygen 1.2.16 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>OgreCylinderEmitter.cpp</h1><a href="OgreCylinderEmitter_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/*</font>
00002 <font class="comment">-----------------------------------------------------------------------------</font>
00003 <font class="comment">This source file is part of OGRE</font>
00004 <font class="comment">    (Object-oriented Graphics Rendering Engine)</font>
00005 <font class="comment">For the latest info, see http://www.ogre3d.org/</font>
00006 <font class="comment"></font>
00007 <font class="comment">Copyright ) 2002 Tels &lt;http://bloodgate.com&gt; based on EllipsoidEmitter</font>
00008 <font class="comment">Also see acknowledgements in Readme.html</font>
00009 <font class="comment"></font>
00010 <font class="comment">This program is free software; you can redistribute it and/or modify it under</font>
00011 <font class="comment">the terms of the GNU Lesser General Public License as published by the Free Software</font>
00012 <font class="comment">Foundation; either version 2 of the License, or (at your option) any later</font>
00013 <font class="comment">version.</font>
00014 <font class="comment"></font>
00015 <font class="comment">This program is distributed in the hope that it will be useful, but WITHOUT</font>
00016 <font class="comment">ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</font>
00017 <font class="comment">FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</font>
00018 <font class="comment"></font>
00019 <font class="comment">You should have received a copy of the GNU Lesser General Public License along with</font>
00020 <font class="comment">this program; if not, write to the Free Software Foundation, Inc., 59 Temple</font>
00021 <font class="comment">Place - Suite 330, Boston, MA 02111-1307, USA, or go to</font>
00022 <font class="comment">http://www.gnu.org/copyleft/lesser.txt.</font>
00023 <font class="comment">-----------------------------------------------------------------------------</font>
00024 <font class="comment">*/</font>
00025 <font class="preprocessor">#include "<a class="code" href="OgreCylinderEmitter_8h.html">OgreCylinderEmitter.h</a>"</font>
00026 <font class="preprocessor">#include "<a class="code" href="OgreParticle_8h.html">OgreParticle.h</a>"</font>
00027 <font class="preprocessor">#include "<a class="code" href="OgreQuaternion_8h.html">OgreQuaternion.h</a>"</font>
00028 <font class="preprocessor">#include "<a class="code" href="OgreException_8h.html">OgreException.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="OgreStringConverter_8h.html">OgreStringConverter.h</a>"</font>
00030 
00031 
00032 <font class="comment">/* Implements an Emitter whose emitting points all lie inside a cylinder.</font>
00033 <font class="comment">*/</font>
00034 
00035 <font class="keyword">namespace </font>Ogre {
00036 
00037 
00038     <font class="comment">//-----------------------------------------------------------------------</font>
<a name="l00039"></a><a class="code" href="classOgre_1_1CylinderEmitter.html#Ogre_1_1CylinderEmittera0">00039</a>     CylinderEmitter::CylinderEmitter()
00040     {
00041         <a class="code" href="classOgre_1_1AreaEmitter.html#Ogre_1_1RingEmitterb1">initDefaults</a>(<font class="stringliteral">"Cylinder"</font>);
00042     }
00043     <font class="comment">//-----------------------------------------------------------------------</font>
<a name="l00044"></a><a class="code" href="classOgre_1_1CylinderEmitter.html#Ogre_1_1CylinderEmittera1">00044</a>     <font class="keywordtype">void</font> CylinderEmitter::_initParticle(<a class="code" href="classOgre_1_1Particle.html">Particle</a>* pParticle)
00045     {
00046         <a class="code" href="namespaceOgre.html#a349">Real</a> x, y, z;
00047 
00048         <font class="comment">// Call superclass</font>
00049         AreaEmitter::_initParticle(pParticle);
00050 
00051         <font class="comment">// First we create a random point inside a bounding cylinder with a</font>
00052         <font class="comment">// radius and height of 1 (this is easy to do). The distance of the</font>
00053         <font class="comment">// point from 0,0,0 must be &lt;= 1 (== 1 means on the surface and we</font>
00054         <font class="comment">// count this as inside, too).</font>
00055 
00056         <font class="keywordflow">while</font> (true)
00057         {
00058 <font class="comment">/* ClearSpace not yet implemeted</font>
00059 <font class="comment"></font>
00060 <font class="comment">*/</font>
00061                 <font class="comment">// three random values for one random point in 3D space</font>
00062                 x = Math::SymmetricRandom();
00063                 y = Math::SymmetricRandom();
00064                 z = Math::SymmetricRandom();
00065 
00066                 <font class="comment">// the distance of x,y from 0,0 is sqrt(x*x+y*y), but</font>
00067                 <font class="comment">// as usual we can omit the sqrt(), since sqrt(1) == 1 and we</font>
00068                 <font class="comment">// use the 1 as boundary. z is not taken into account, since</font>
00069                 <font class="comment">// all values in the z-direction are inside the cylinder:</font>
00070                 <font class="keywordflow">if</font> ( x*x + y*y &lt;= 1)
00071                 {
00072                         <font class="keywordflow">break</font>;          <font class="comment">// found one valid point inside</font>
00073                 }
00074         }       
00075 
00076         <font class="comment">// scale the found point to the cylinder's size and move it</font>
00077         <font class="comment">// relatively to the center of the emitter point</font>
00078 
00079         pParticle-&gt;<a class="code" href="classOgre_1_1Billboard.html#Ogre_1_1Particlem3">mPosition</a> = <a class="code" href="classOgre_1_1ParticleEmitter.html#Ogre_1_1RingEmittern6">mPosition</a> + 
00080          + x * <a class="code" href="classOgre_1_1AreaEmitter.html#Ogre_1_1RingEmittern3">mXRange</a> + y * <a class="code" href="classOgre_1_1AreaEmitter.html#Ogre_1_1RingEmittern4">mYRange</a> + z * <a class="code" href="classOgre_1_1AreaEmitter.html#Ogre_1_1RingEmittern5">mZRange</a>;
00081 
00082         <font class="comment">// Generate complex data by reference</font>
00083         <a class="code" href="classOgre_1_1ParticleEmitter.html#Ogre_1_1RingEmitterb5">genEmissionColour</a>(pParticle-&gt;<a class="code" href="classOgre_1_1Billboard.html#Ogre_1_1Particlem6">mColour</a>);
00084         <a class="code" href="classOgre_1_1ParticleEmitter.html#Ogre_1_1RingEmitterb2">genEmissionDirection</a>(pParticle-&gt;<a class="code" href="classOgre_1_1Billboard.html#Ogre_1_1Particlem4">mDirection</a>);
00085         <a class="code" href="classOgre_1_1ParticleEmitter.html#Ogre_1_1RingEmitterb3">genEmissionVelocity</a>(pParticle-&gt;<a class="code" href="classOgre_1_1Billboard.html#Ogre_1_1Particlem4">mDirection</a>);
00086 
00087         <font class="comment">// Generate simpler data</font>
00088         pParticle-&gt;<a class="code" href="classOgre_1_1Particle.html#Ogre_1_1Particlem0">mTimeToLive</a> = pParticle-&gt;<a class="code" href="classOgre_1_1Particle.html#Ogre_1_1Particlem1">mTotalTimeToLive</a> = <a class="code" href="classOgre_1_1ParticleEmitter.html#Ogre_1_1RingEmitterb4">genEmissionTTL</a>();
00089         
00090     }
00091 
00092 }
00093 
00094 
</pre></div><p>
Copyright &copy; 2002-2003 by The OGRE Team<br />
Last modified Wed Jan 21 00:10:05 2004
</p>
</body>
</html>