diff options
Diffstat (limited to 'docs/doxygen/nel/ps__util_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/ps__util_8cpp-source.html | 461 |
1 files changed, 461 insertions, 0 deletions
diff --git a/docs/doxygen/nel/ps__util_8cpp-source.html b/docs/doxygen/nel/ps__util_8cpp-source.html new file mode 100644 index 00000000..669da023 --- /dev/null +++ b/docs/doxygen/nel/ps__util_8cpp-source.html @@ -0,0 +1,461 @@ +<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<HTML> +<HEAD> + <TITLE>nevrax.org : docs</TITLE> + <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>ps_util.cpp</h1><a href="ps__util_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font> +00027 +00028 +00029 <font class="preprocessor">#include "<a class="code" href="aabbox_8h.html">nel/misc/aabbox.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="matrix_8h.html">nel/misc/matrix.h</a>"</font> +00031 +00032 <font class="preprocessor">#include "<a class="code" href="ps__util_8h.html">3d/ps_util.h</a>"</font> +00033 <font class="preprocessor">#include "<a class="code" href="particle__system_8h.html">3d/particle_system.h</a>"</font> +00034 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font> +00035 <font class="preprocessor">#include "<a class="code" href="vertex__buffer_8h.html">3d/vertex_buffer.h</a>"</font> +00036 <font class="preprocessor">#include "<a class="code" href="3d_2primitive__block_8h.html">3d/primitive_block.h</a>"</font> +00037 <font class="preprocessor">#include "<a class="code" href="material_8h.html">3d/material.h</a>"</font> +00038 <font class="preprocessor">#include "<a class="code" href="nelu_8h.html">3d/nelu.h</a>"</font> +00039 <font class="preprocessor">#include "<a class="code" href="font__generator_8h.html">3d/font_generator.h</a>"</font> +00040 <font class="preprocessor">#include "<a class="code" href="font__manager_8h.html">3d/font_manager.h</a>"</font> +00041 <font class="preprocessor">#include "<a class="code" href="computed__string_8h.html">3d/computed_string.h</a>"</font> +00042 <font class="preprocessor">#include "<a class="code" href="dru_8h.html">3d/dru.h</a>"</font> +00043 <font class="preprocessor">#include "<a class="code" href="ps__located_8h.html">3d/ps_located.h</a>"</font> +00044 <font class="preprocessor">#include "<a class="code" href="ps__sound_8h.html">3d/ps_sound.h</a>"</font> +00045 +00046 <font class="preprocessor">#include "<a class="code" href="particle__system__shape_8h.html">3d/particle_system_shape.h</a>"</font> +00047 +00048 +00049 +00050 <font class="keyword">namespace </font>NL3D { +00051 +00052 +00053 <font class="keyword">using</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>; +00054 +00055 +00056 <font class="comment">//#ifdef NL_DEBUG</font> +<a name="l00057"></a><a class="code" href="structNL3D_1_1CPSUtil.html#r0">00057</a> <font class="keywordtype">bool</font> CPSUtil::_CosTableInitialized = <font class="keyword">false</font>; +<a name="l00058"></a><a class="code" href="structNL3D_1_1CPSUtil.html#r1">00058</a> <font class="keywordtype">bool</font> CPSUtil::_PerlinNoiseTableInitialized = <font class="keyword">false</font>; +00059 <font class="comment">//#endif</font> +00060 +<a name="l00061"></a><a class="code" href="structNL3D_1_1CPSUtil.html#r2">00061</a> <font class="keywordtype">float</font> CPSUtil::_CosTable[256]; +<a name="l00062"></a><a class="code" href="structNL3D_1_1CPSUtil.html#r3">00062</a> <font class="keywordtype">float</font> CPSUtil::_SinTable[256]; +<a name="l00063"></a><a class="code" href="structNL3D_1_1CPSUtil.html#r4">00063</a> <font class="keywordtype">float</font> CPSUtil::_PerlinNoiseTab[1024]; +00064 +00065 +00066 +00067 +00068 <font class="comment">//==========================================================================</font> +<a name="l00069"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d15">00069</a> <font class="keywordtype">void</font> CPSUtil::initPerlinNoiseTable(<font class="keywordtype">void</font>) +00070 { +00071 <font class="keywordflow">for</font> (uint32 k = 0; k < 1024; ++k) +00072 { +00073 <a class="code" href="structNL3D_1_1CPSUtil.html#r4">_PerlinNoiseTab</a>[k] = (rand() % 30000) / 30000.f; +00074 } +00075 <font class="comment">//#ifdef NL_DEBUG</font> +00076 <a class="code" href="structNL3D_1_1CPSUtil.html#r1">_PerlinNoiseTableInitialized</a> = <font class="keyword">true</font>; +00077 <font class="comment">//#endif</font> +00078 } +00079 +00080 <font class="comment">//==========================================================================</font> +<a name="l00081"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d13">00081</a> <font class="keywordtype">void</font> CPSUtil::initFastCosNSinTable(<font class="keywordtype">void</font>) +00082 { +00083 <font class="keywordflow">for</font> (uint32 k = 0; k < 256; k++) +00084 { +00085 <font class="keyword">const</font> <font class="keywordtype">float</font> angle = k / 256.0f * 2.0f * float(NLMISC::Pi); +00086 <a class="code" href="structNL3D_1_1CPSUtil.html#r2">_CosTable</a>[k] = (float) cos( angle ); +00087 <a class="code" href="structNL3D_1_1CPSUtil.html#r3">_SinTable</a>[k] = (float) sin( angle ); +00088 } +00089 <font class="comment">//#ifdef NL_DEBUG</font> +00090 <a class="code" href="structNL3D_1_1CPSUtil.html#r0">_CosTableInitialized</a> = <font class="keyword">true</font>; +00091 <font class="comment">//#endif</font> +00092 } +00093 +00094 <font class="comment">//==========================================================================</font> +<a name="l00095"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d0">00095</a> <font class="keywordtype">void</font> CPSUtil::registerSerialParticleSystem(<font class="keywordtype">void</font>) +00096 { +00097 <a class="code" href="class__registry_8h.html#a1">NLMISC_REGISTER_CLASS</a>(CPSLocated); +00098 <a class="code" href="class__registry_8h.html#a1">NLMISC_REGISTER_CLASS</a>(CParticleSystemShape); +00099 <a class="code" href="class__registry_8h.html#a1">NLMISC_REGISTER_CLASS</a>(CPSSound); +00100 +00101 +00102 <a class="code" href="structNL3D_1_1CPSUtil.html#f1">registerParticles</a>(); +00103 <a class="code" href="structNL3D_1_1CPSUtil.html#f0">registerForces</a>(); +00104 <a class="code" href="structNL3D_1_1CPSUtil.html#f2">registerEmitters</a>(); +00105 <a class="code" href="structNL3D_1_1CPSUtil.html#f3">registerZones</a>(); +00106 <a class="code" href="structNL3D_1_1CPSUtil.html#f4">registerAttribs</a>(); +00107 +00108 +00109 <font class="comment">// while we are here, we perform some important inits </font> +00110 <a class="code" href="structNL3D_1_1CPSUtil.html#d13">initFastCosNSinTable</a>(); <font class="comment">// init fast cosine lookup table</font> +00111 <a class="code" href="structNL3D_1_1CPSUtil.html#d15">initPerlinNoiseTable</a>(); <font class="comment">// init perlin noise table </font> +00112 } +00113 +00114 <font class="comment">//==========================================================================</font> +<a name="l00115"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d1">00115</a> <font class="keywordtype">void</font> CPSUtil::displayBBox(<a class="code" href="classNL3D_1_1IDriver.html">NL3D::IDriver</a> *driver, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CAABBox.html">NLMISC::CAABBox</a> &box, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> col <font class="comment">/* = NLMISC::CRGBA::White */</font>) +00116 { +00117 CVector max = box.<a class="code" href="classNLMISC_1_1CAABBox.html#z264_1">getMax</a>() +00118 ,<a class="code" href="bit__set_8cpp.html#a0">min</a> = box.<a class="code" href="classNLMISC_1_1CAABBox.html#z264_0">getMin</a>(); +00119 CVertexBuffer vb; +00120 vb.setVertexFormat(CVertexBuffer::PositionFlag); +00121 vb.setNumVertices(8); +00122 +00123 vb.setVertexCoord(0, <a class="code" href="bit__set_8cpp.html#a0">min</a>); +00124 vb.setVertexCoord(1, CVector(max.x, <a class="code" href="bit__set_8cpp.html#a0">min</a>.y, <a class="code" href="bit__set_8cpp.html#a0">min</a>.z)); +00125 vb.setVertexCoord(2, CVector(<a class="code" href="bit__set_8cpp.html#a0">min</a>.x, max.y, <a class="code" href="bit__set_8cpp.html#a0">min</a>.z)); +00126 vb.setVertexCoord(3, CVector(max.x, max.y, <a class="code" href="bit__set_8cpp.html#a0">min</a>.z)); +00127 vb.setVertexCoord(4, CVector(<a class="code" href="bit__set_8cpp.html#a0">min</a>.x, <a class="code" href="bit__set_8cpp.html#a0">min</a>.y, max.z)); +00128 vb.setVertexCoord(5, CVector(max.x, <a class="code" href="bit__set_8cpp.html#a0">min</a>.y, max.z)); +00129 vb.setVertexCoord(6, CVector(<a class="code" href="bit__set_8cpp.html#a0">min</a>.x, max.y, max.z)); +00130 vb.setVertexCoord(7, max); +00131 +00132 +00133 CMaterial material; +00134 +00135 material.setColor(col); +00136 material.setLighting(<font class="keyword">false</font>); +00137 material.setBlendFunc(CMaterial::one, CMaterial::one); +00138 material.setZWrite(<font class="keyword">false</font>); +00139 material.setBlend(<font class="keyword">true</font>); +00140 +00141 +00142 +00143 CPrimitiveBlock pb; +00144 pb.reserveLine(12); +00145 pb.addLine(0, 1); +00146 pb.addLine(1, 5); +00147 pb.addLine(5, 4); +00148 pb.addLine(4, 0); +00149 pb.addLine(0, 2); +00150 pb.addLine(1, 3); +00151 pb.addLine(4, 6); +00152 pb.addLine(5, 7); +00153 pb.addLine(6, 7); +00154 pb.addLine(7, 3); +00155 pb.addLine(3, 2); +00156 pb.addLine(2, 6); +00157 +00158 +00159 +00160 driver-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a>(vb); +00161 driver-><a class="code" href="classNL3D_1_1IDriver.html#a41">render</a>(pb, material); +00162 } +00163 +00164 +00165 <font class="comment">//==========================================================================</font> +<a name="l00166"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d8">00166</a> <font class="keywordtype">void</font> CPSUtil::displayArrow(IDriver *driver, <font class="keyword">const</font> CVector &start, <font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, <font class="keywordtype">float</font> size, CRGBA col1, CRGBA col2) +00167 { +00168 +00169 <font class="keyword">const</font> <font class="keywordtype">float</font> coneSize = size * 0.1f; +00170 +00171 uint32 vTab[] = { 1, 2, 4, +00172 4, 2, 3, +00173 1, 2, 0, +00174 2, 3, 0, +00175 3, 4, 0, +00176 4, 1, 0 }; +00177 +00178 CVector end = start + size * <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>; +00179 CDRU::drawLine(start, end, col1, *driver); +00180 CMatrix m; +00181 <a class="code" href="structNL3D_1_1CPSUtil.html#d10">buildSchmidtBasis</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, m); +00182 +00183 CVertexBuffer vb; +00184 vb.setVertexFormat(CVertexBuffer::PositionFlag); +00185 vb.setNumVertices(5); +00186 +00187 +00188 +00189 vb.setVertexCoord(0, end + m * CVector(0, 0, 3.0f * coneSize) ); +00190 vb.setVertexCoord(1, end + m * CVector(-coneSize, -coneSize, 0) ); +00191 vb.setVertexCoord(2, end + m * CVector(coneSize, -coneSize, 0) ); +00192 vb.setVertexCoord(3, end + m * CVector(coneSize, coneSize, 0) ); +00193 vb.setVertexCoord(4, end + m * CVector(-coneSize, coneSize, 0) ); +00194 +00195 CMaterial material; +00196 +00197 material.setColor(col2); +00198 material.setLighting(<font class="keyword">false</font>); +00199 material.setBlendFunc(CMaterial::one, CMaterial::one); +00200 material.setZWrite(<font class="keyword">false</font>); +00201 material.setBlend(<font class="keyword">true</font>); +00202 material.setDoubleSided(<font class="keyword">true</font>); +00203 +00204 driver->activeVertexBuffer(vb, 0, 5); +00205 driver->renderTriangles(material, vTab, 6); +00206 } +00207 +00208 <font class="comment">//==========================================================================</font> +<a name="l00209"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d7">00209</a> <font class="keywordtype">void</font> CPSUtil::displayBasis(IDriver *driver, <font class="keyword">const</font> CMatrix &modelMat, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &m, <font class="keywordtype">float</font> size, CFontGenerator &fg, CFontManager &fm) +00210 { +00211 CMaterial material; +00212 +00213 driver->setupModelMatrix(modelMat); +00214 +00215 +00216 +00217 <a class="code" href="structNL3D_1_1CPSUtil.html#d8">displayArrow</a>(driver, m.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>(), m.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_7">getI</a>(), size, CRGBA(127, 127, 127), CRGBA(0, 0, 80)); +00218 <a class="code" href="structNL3D_1_1CPSUtil.html#d8">displayArrow</a>(driver, m.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>(), m.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>(), size, CRGBA(127, 127, 127), CRGBA(0, 0, 80)); +00219 <a class="code" href="structNL3D_1_1CPSUtil.html#d8">displayArrow</a>(driver, m.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>(), m.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_9">getK</a>(), size, CRGBA(127, 127, 127), CRGBA(200, 0, 80)); +00220 +00221 +00222 <font class="comment">// draw the letters</font> +00223 +00224 CPSUtil::print(driver, std::string(<font class="stringliteral">"x"</font>), fg, fm, modelMat * m * CVector(1.4f * size, 0, 0), 15.0f * size); +00225 CPSUtil::print(driver, std::string(<font class="stringliteral">"y"</font>), fg, fm, modelMat * m * CVector(0, 1.4f * size, 0), 15.0f * size); +00226 CPSUtil::print(driver, std::string(<font class="stringliteral">"z"</font>), fg, fm, modelMat * m * CVector(0, 0, 1.4f * size), 15.0f * size); +00227 +00228 }; +00229 +00230 +00231 <font class="comment">//==========================================================================</font> +<a name="l00232"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d9">00232</a> <font class="keywordtype">void</font> CPSUtil::print(IDriver *driver, <font class="keyword">const</font> std::string &text, CFontGenerator &fg, CFontManager &fm, <font class="keyword">const</font> CVector &pos, <font class="keywordtype">float</font> size) +00233 { +00234 <a class="code" href="debug_8h.html#a6">nlassert</a>((&fg) && (&fm)); +00235 CComputedString cptedString; +00236 fm.computeString ( text, +00237 &fg, +00238 CRGBA(255,255,255), +00239 16, +00240 driver, +00241 cptedString); +00242 +00243 +00244 CMatrix mat = driver->getViewMatrix(); +00245 mat.setPos(CVector::Null); +00246 mat.scale(CVector(size, size, size)); +00247 mat.transpose(); +00248 mat.setPos(pos); +00249 cptedString.render3D(*driver, mat); +00250 } +00251 +00252 +00253 <font class="comment">//==========================================================================</font> +<a name="l00254"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d10">00254</a> <font class="keywordtype">void</font> CPSUtil::buildSchmidtBasis(<font class="keyword">const</font> CVector &k_, <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &result) +00255 { +00256 <font class="keyword">const</font> <font class="keywordtype">float</font> epsilon = 10E-4f; +00257 +00258 +00259 CVector k = k_; +00260 k.normalize(); +00261 CVector i; +00262 <font class="keywordflow">if</font> ((1.0f - fabsf(k * CVector::I)) > epsilon) +00263 { +00264 i = k ^ CVector::I; +00265 } +00266 <font class="keywordflow">else</font> +00267 <font class="keywordflow">if</font> ((1.0f - fabs(k * CVector::J)) > epsilon) +00268 { +00269 i = k ^ CVector::J; +00270 } +00271 <font class="keywordflow">else</font> +00272 { +00273 i = k ^ CVector::K; +00274 } +00275 +00276 i = i - (k * i) * k; +00277 i.normalize(); +00278 result.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_1">setRot</a>(i, k ^ i, k, <font class="keyword">true</font>); +00279 } +00280 +00281 +00282 <font class="comment">//==========================================================================</font> +<a name="l00283"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d2">00283</a> <font class="keywordtype">void</font> CPSUtil::displaySphere(IDriver &driver, <font class="keywordtype">float</font> radius, <font class="keyword">const</font> CVector &center, uint nbSubdiv, CRGBA color) +00284 { +00285 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, k; +00286 CVector p, p1, p2; +00287 +00288 <font class="keyword">static</font> <font class="keyword">const</font> CVector lK[] = { CVector::I, -CVector::I +00289 ,CVector::J, -CVector::J +00290 ,CVector::K, -CVector::K }; +00291 +00292 <font class="comment">/* static const CVector lI = { CVector::J, -CVector::J</font> +00293 <font class="comment"> ,CVector::K, -CVector::K</font> +00294 <font class="comment"> ,CVector::I, -CVector::I };*/</font> +00295 +00296 +00297 +00298 <font class="keywordflow">for</font> (k = 0; k < 6; ++k) +00299 { +00300 <font class="keyword">const</font> CVector &I = lK[(k + 2) % 6]; +00301 <font class="keyword">const</font> CVector &K = lK[k]; +00302 <font class="keyword">const</font> CVector J = K ^ I; +00303 +00304 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = 0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> < nbSubdiv; ++<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>) +00305 { +00306 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = 0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> < nbSubdiv; ++<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>) +00307 { +00308 p = ((2.f * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> / float(nbSubdiv) ) - 1.f) * I + ((2.f * <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> / float(nbSubdiv) ) - 1.f) * J + K; +00309 p1 = p + 2.f / float(nbSubdiv) * I; +00310 p2 = p + 2.f / float(nbSubdiv) * J; +00311 +00312 p.normalize(); +00313 p1.normalize(); +00314 p2.normalize(); +00315 +00316 p = center + radius * p; +00317 p1 = center + radius * p1; +00318 p2 = center + radius * p2; +00319 +00320 CDRU::drawLine(p, p1, color, driver); +00321 CDRU::drawLine(p, p2, color, driver); +00322 } +00323 } +00324 } +00325 } +00326 +00327 +00328 <font class="comment">//==========================================================================</font> +<a name="l00329"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d3">00329</a> <font class="keywordtype">void</font> CPSUtil::displayDisc(IDriver &driver, <font class="keywordtype">float</font> radius, <font class="keyword">const</font> CVector &center, <font class="keyword">const</font> CMatrix &mat, uint nbSubdiv, CRGBA color) +00330 { +00331 <font class="comment">// not optimized, but for edition only</font> +00332 <font class="keywordtype">float</font> thetaDelta = (float) NLMISC::Pi * 2.f / nbSubdiv; +00333 <font class="keywordtype">float</font> theta = 0.f; +00334 <font class="keyword">const</font> CVector &I = mat.getI(); +00335 <font class="keyword">const</font> CVector &J = mat.getJ(); +00336 <font class="keywordflow">for</font> (uint k = 0; k < nbSubdiv; ++k) +00337 { +00338 +00339 CDRU::drawLine(center + radius * ((<font class="keywordtype">float</font>) cos(theta) * I + (<font class="keywordtype">float</font>) sin(theta) * J) +00340 , center + radius * ((<font class="keywordtype">float</font>) cos(theta + thetaDelta) * I + (<font class="keywordtype">float</font>) sin(theta + thetaDelta) * J) +00341 , color, driver); +00342 theta += thetaDelta; +00343 } +00344 +00345 } +00346 +00347 <font class="comment">//==========================================================================</font> +<a name="l00348"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d4">00348</a> <font class="keywordtype">void</font> CPSUtil::displayCylinder(IDriver &driver, <font class="keyword">const</font> CVector &center, <font class="keyword">const</font> CMatrix &mat, <font class="keyword">const</font> CVector &dim, uint nbSubdiv, CRGBA color) +00349 { +00350 <font class="comment">// not optimized, but for edition only</font> +00351 <font class="keywordtype">float</font> thetaDelta = (float) NLMISC::Pi * 2.f / nbSubdiv; +00352 <font class="keywordtype">float</font> theta = 0.f; +00353 <font class="keyword">const</font> CVector &I = mat.getI(); +00354 <font class="keyword">const</font> CVector &J = mat.getJ(); +00355 <font class="keyword">const</font> CVector &K = mat.getK(); +00356 +00357 <font class="keywordflow">for</font> (uint k = 0; k < nbSubdiv; ++k) +00358 { +00359 +00360 CDRU::drawLine(center + dim.z * K + dim.x * cosf(theta) * I + dim.y * sinf(theta) * J +00361 , center + dim.z * K + dim.x * cosf(theta + thetaDelta) * I + dim.y * sinf(theta + thetaDelta) * J +00362 , color, driver); +00363 +00364 CDRU::drawLine(center - dim.z * K + dim.x * cosf(theta) * I + dim.y * sinf(theta) * J +00365 , center - dim.z * K + dim.x * cosf(theta + thetaDelta) * I + dim.y * sinf(theta + thetaDelta) * J +00366 , color, driver); +00367 +00368 CDRU::drawLine(center + dim.z * K + dim.x * cosf(theta) * I + dim.y * sinf(theta) * J +00369 , center - dim.z * K + dim.x * cosf(theta) * I + dim.y * sinf(theta) * J +00370 , color, driver); +00371 +00372 +00373 +00374 +00375 theta += thetaDelta; +00376 } +00377 } +00378 +00379 <font class="comment">//==========================================================================</font> +<a name="l00380"></a><a class="code" href="structNL3D_1_1CPSUtil.html#d5">00380</a> <font class="keywordtype">void</font> CPSUtil::display3DQuad(IDriver &driver, <font class="keyword">const</font> CVector &c1, <font class="keyword">const</font> CVector &c2 +00381 ,<font class="keyword">const</font> CVector &c3, <font class="keyword">const</font> CVector &c4, CRGBA color) +00382 { +00383 CDRU::drawLine(c1, c2, color, driver); +00384 CDRU::drawLine(c2, c3, color, driver); +00385 CDRU::drawLine(c3, c4, color, driver); +00386 CDRU::drawLine(c4, c1, color, driver); +00387 } +00388 +00389 +00390 +00391 +00392 } <font class="comment">// NL3D</font> +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |