Sophie

Sophie

distrib > Mandriva > 10.0-com > i586 > by-pkgid > 06719cf03808e17ae6f0852ca1052dc2 > files > 611

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

<html>
<head>
<title>OgreEllipsoidEmitter.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>OgreEllipsoidEmitter.cpp</h1><a href="OgreEllipsoidEmitter_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 BoxEmitter</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="OgreEllipsoidEmitter_8h.html">OgreEllipsoidEmitter.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="OgreException_8h.html">OgreException.h</a>"</font>
00028 <font class="preprocessor">#include "<a class="code" href="OgreStringConverter_8h.html">OgreStringConverter.h</a>"</font>
00029 
00030 
00031 <font class="comment">/* Implements an Emitter whose emitting points all lie inside an ellipsoid.</font>
00032 <font class="comment">   See &lt;http://mathworld.wolfram.com/Ellipsoid.html&gt; for mathematical details.</font>
00033 <font class="comment"></font>
00034 <font class="comment">  If the lengths of two axes of an ellipsoid are the same, the figure is</font>
00035 <font class="comment">  called a 'spheroid' (depending on whether c &lt; a or c &gt; a, an 'oblate</font>
00036 <font class="comment">  spheroid' or 'prolate spheroid', respectively), and if all three are the</font>
00037 <font class="comment">  same, it is a 'sphere' (ball).</font>
00038 <font class="comment">*/</font>
00039 
00040 <font class="keyword">namespace </font>Ogre {
00041 
00042 
00043     <font class="comment">//-----------------------------------------------------------------------</font>
<a name="l00044"></a><a class="code" href="classOgre_1_1EllipsoidEmitter.html#Ogre_1_1EllipsoidEmittera0">00044</a>     EllipsoidEmitter::EllipsoidEmitter()
00045     {
00046         <a class="code" href="classOgre_1_1AreaEmitter.html#Ogre_1_1RingEmitterb1">initDefaults</a>(<font class="stringliteral">"Ellipsoid"</font>);
00047     }
00048     <font class="comment">//-----------------------------------------------------------------------</font>
<a name="l00049"></a><a class="code" href="classOgre_1_1EllipsoidEmitter.html#Ogre_1_1EllipsoidEmittera1">00049</a>     <font class="keywordtype">void</font> EllipsoidEmitter::_initParticle(<a class="code" href="classOgre_1_1Particle.html">Particle</a>* pParticle)
00050     {
00051         <a class="code" href="namespaceOgre.html#a349">Real</a> x, y, z;
00052 
00053         <font class="comment">// Call superclass</font>
00054         AreaEmitter::_initParticle(pParticle);
00055         <font class="comment">// First we create a random point inside a bounding sphere with a</font>
00056         <font class="comment">// radius of 1 (this is easy to do). The distance of the point from</font>
00057         <font class="comment">// 0,0,0 must be &lt;= 1 (== 1 means on the surface and we count this as</font>
00058         <font class="comment">// inside, too).</font>
00059 
00060         <font class="keywordflow">while</font> (true)
00061         {
00062             <font class="comment">// three random values for one random point in 3D space</font>
00063 
00064             x = Math::SymmetricRandom();
00065             y = Math::SymmetricRandom();
00066             z = Math::SymmetricRandom();
00067 
00068             <font class="comment">// the distance of x,y,z from 0,0,0 is sqrt(x*x+y*y+z*z), but</font>
00069             <font class="comment">// as usual we can omit the sqrt(), since sqrt(1) == 1 and we</font>
00070             <font class="comment">// use the 1 as boundary:</font>
00071             <font class="keywordflow">if</font> ( x*x + y*y + z*z &lt;= 1)
00072                 {
00073                         <font class="keywordflow">break</font>;          <font class="comment">// found one valid point inside</font>
00074                 }
00075         }       
00076 
00077         <font class="comment">// scale the found point to the ellipsoid's size and move it</font>
00078         <font class="comment">// relatively to the center of the emitter point</font>
00079 
00080         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> + 
00081          + 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>;
00082 
00083         <font class="comment">// Generate complex data by reference</font>
00084         <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>);
00085         <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>);
00086         <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>);
00087 
00088         <font class="comment">// Generate simpler data</font>
00089         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>();
00090         
00091     }
00092 
00093 }
00094 
00095 
</pre></div><p>
Copyright &copy; 2002-2003 by The OGRE Team<br />
Last modified Wed Jan 21 00:10:09 2004
</p>
</body>
</html>