diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/ps__mesh_8cpp-source.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/ps__mesh_8cpp-source.html | 2144 |
1 files changed, 2144 insertions, 0 deletions
diff --git a/docs/doxygen/nel/ps__mesh_8cpp-source.html b/docs/doxygen/nel/ps__mesh_8cpp-source.html new file mode 100644 index 00000000..705a5db9 --- /dev/null +++ b/docs/doxygen/nel/ps__mesh_8cpp-source.html @@ -0,0 +1,2144 @@ +<!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_mesh.cpp</h1><a href="ps__mesh_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2000, 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 <font class="preprocessor">#include "<a class="code" href="ps__mesh_8h.html">3d/ps_mesh.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="ps__macro_8h.html">3d/ps_macro.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="shape_8h.html">3d/shape.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="mesh_8h.html">3d/mesh.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="transform__shape_8h.html">3d/transform_shape.h</a>"</font> +00033 <font class="preprocessor">#include "<a class="code" href="shape__bank_8h.html">3d/shape_bank.h</a>"</font> +00034 <font class="preprocessor">#include "<a class="code" href="texture__mem_8h.html">3d/texture_mem.h</a>"</font> +00035 <font class="preprocessor">#include "<a class="code" href="scene_8h.html">3d/scene.h</a>"</font> +00036 <font class="preprocessor">#include "<a class="code" href="ps__located_8h.html">3d/ps_located.h</a>"</font> +00037 <font class="preprocessor">#include "<a class="code" href="particle__system_8h.html">3d/particle_system.h</a>"</font> +00038 <font class="preprocessor">#include "<a class="code" href="particle__system__shape_8h.html">3d/particle_system_shape.h</a>"</font> +00039 <font class="preprocessor">#include "<a class="code" href="ps__iterator_8h.html">3d/ps_iterator.h</a>"</font> +00040 <font class="preprocessor">#include "<a class="code" href="stream_8h.html">nel/misc/stream.h</a>"</font> +00041 <font class="preprocessor">#include "<a class="code" href="path_8h.html">nel/misc/path.h</a>"</font> +00042 +00043 <font class="preprocessor">#include <memory></font> +00044 +00045 +00046 +00047 +00048 +00049 <font class="keyword">namespace </font>NL3D +00050 { +00051 +00053 <font class="comment">// static members //</font> +00055 <font class="comment"></font> +00056 +00057 +00058 +00059 CPSConstraintMesh::CMeshDisplayShare CPSConstraintMesh::_MeshDisplayShare(16); +<a name="l00060"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#q1">00060</a> CVertexBuffer CPSConstraintMesh::_PreRotatedMeshVB; <font class="comment">// mesh has no normals</font> +<a name="l00061"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#q2">00061</a> CVertexBuffer CPSConstraintMesh::_PreRotatedMeshVBWithNormal; <font class="comment">// mesh has normals</font> +00062 +00063 +00064 +00065 <font class="comment">// this produce a random unit vector</font> +00066 <font class="keyword">static</font> CVector <a class="code" href="namespaceNL3D.html#a421">MakeRandomUnitVect</a>(<font class="keywordtype">void</font>) +00067 { +00068 CVector <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>((<font class="keywordtype">float</font>) ((rand() % 20000) - 10000) +00069 ,(<font class="keywordtype">float</font>) ((rand() % 20000) - 10000) +00070 ,(<font class="keywordtype">float</font>) ((rand() % 20000) - 10000) +00071 ); +00072 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.normalize(); +00073 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>; +00074 } +00075 +00076 +00078 <font class="comment">// CPSMesh implementation //</font> +00080 <font class="comment"></font> +00081 +00082 <font class="comment">//====================================================================================</font> +00083 +00084 +00085 +00086 +00087 <font class="keyword">const</font> std::string <a class="code" href="namespaceNL3D.html#a428">DummyShapeName</a>(<font class="stringliteral">"dummy mesh shape"</font>); +00088 +00092 <font class="keyword">static</font> CMesh *<a class="code" href="namespaceNL3D.html#a429">CreateDummyShape</a>(<font class="keywordtype">void</font>) +00093 { +00094 CMesh::CMeshBuild mb; +00095 CMeshBase::CMeshBaseBuild mbb; +00096 +00097 mb.VertexFlags = CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag; +00098 mb.Vertices.push_back(CVector(-.5f, -.5f, -.5f)); +00099 mb.Vertices.push_back(CVector(.5f, -.5f, -.5f)); +00100 mb.Vertices.push_back(CVector(.5f, -.5f, .5f)); +00101 mb.Vertices.push_back(CVector(-.5f, -.5f, .5f)); +00102 +00103 mb.Vertices.push_back(CVector(-.5f, .5f, -.5f)); +00104 mb.Vertices.push_back(CVector(.5f, .5f, -.5f)); +00105 mb.Vertices.push_back(CVector(.5f, .5f, .5f)); +00106 mb.Vertices.push_back(CVector(-.5f, .5f, .5f)); +00107 +00108 <font class="comment">// index for each face</font> +00109 uint32 tab[] = { 4, 1, 0, +00110 4, 5, 1, +00111 5, 2, 1, +00112 5, 6, 2, +00113 6, 3, 2, +00114 6, 7, 3, +00115 7, 0, 3, +00116 7, 4, 0, +00117 7, 5, 4, +00118 7, 6, 5, +00119 2, 0, 1, +00120 2, 3, 0 +00121 }; +00122 +00123 <font class="keywordflow">for</font> (uint k = 0; k < 6; ++k) +00124 { +00125 CMesh::CFace f; +00126 f.Corner[0].Vertex = tab[6 * k]; +00127 f.Corner[0].Uvws[0] = <a class="code" href="classNLMISC_1_1CUVW.html">NLMISC::CUVW</a>(0, 0, 0); +00128 +00129 f.Corner[1].Vertex = tab[6 * k + 1]; +00130 f.Corner[1].Uvws[0] = <a class="code" href="classNLMISC_1_1CUVW.html">NLMISC::CUVW</a>(1, 1, 0); +00131 +00132 f.Corner[2].Vertex = tab[6 * k + 2]; +00133 f.Corner[2].Uvws[0] = <a class="code" href="classNLMISC_1_1CUVW.html">NLMISC::CUVW</a>(0, 1, 0); +00134 +00135 f.MaterialId = 0; +00136 +00137 mb.Faces.push_back(f); +00138 +00139 f.Corner[0].Vertex = tab[6 * k + 3]; +00140 f.Corner[0].Uvws[0] = <a class="code" href="classNLMISC_1_1CUVW.html">NLMISC::CUVW</a>(0, 0, 0); +00141 +00142 f.Corner[1].Vertex = tab[6 * k + 4]; +00143 f.Corner[1].Uvws[0] = <a class="code" href="classNLMISC_1_1CUVW.html">NLMISC::CUVW</a>(1, 0, 0); +00144 +00145 f.Corner[2].Vertex = tab[6 * k + 5]; +00146 f.Corner[2].Uvws[0] = <a class="code" href="classNLMISC_1_1CUVW.html">NLMISC::CUVW</a>(1, 1, 0); +00147 +00148 f.MaterialId = 0; +00149 mb.Faces.push_back(f); +00150 } +00151 +00152 CMaterial mat; +00153 CTextureMem *tex = <font class="keyword">new</font> CTextureMem; +00154 tex->makeDummy(); +00155 mat.setTexture(0, tex); +00156 mat.setLighting(<font class="keyword">false</font>); +00157 mat.setColor(CRGBA::White); +00158 mbb.Materials.push_back(mat); +00159 CMesh *m = <font class="keyword">new</font> CMesh; +00160 m->build(mbb, mb); +00161 <font class="keywordflow">return</font> m; +00162 } +00163 +00164 +00165 <font class="comment">//====================================================================================</font> +<a name="l00166"></a><a class="code" href="classNL3D_1_1CPSMesh.html#a3">00166</a> <font class="keywordtype">void</font> CPSMesh::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream) +00167 { +00168 (void)f.serialVersion(3); +00169 CPSParticle::serial(f); +00170 CPSSizedParticle::serialSizeScheme(f); +00171 CPSRotated3DPlaneParticle::serialPlaneBasisScheme(f); +00172 CPSRotated2DParticle::serialAngle2DScheme(f); +00173 f.serial(_Shape); +00174 <font class="keywordflow">if</font> (f.isReading()) +00175 { +00176 invalidate(); +00177 } +00178 } +00179 +00180 +00181 <font class="comment">//====================================================================================</font> +<a name="l00182"></a><a class="code" href="classNL3D_1_1CPSMesh.html#a9">00182</a> uint32 CPSMesh::getMaxNumFaces(<font class="keywordtype">void</font>)<font class="keyword"> const</font> +00183 <font class="keyword"></font>{ +00185 <font class="keywordflow">return</font> 0; +00186 } +00187 +00188 <font class="comment">//====================================================================================</font> +<a name="l00189"></a><a class="code" href="classNL3D_1_1CPSMesh.html#a7">00189</a> <font class="keywordtype">bool</font> CPSMesh::hasTransparentFaces(<font class="keywordtype">void</font>) +00190 { +00192 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00193 } +00194 +00195 <font class="comment">//====================================================================================</font> +<a name="l00196"></a><a class="code" href="classNL3D_1_1CPSMesh.html#a8">00196</a> <font class="keywordtype">bool</font> CPSMesh::hasOpaqueFaces(<font class="keywordtype">void</font>) +00197 { +00199 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00200 } +00201 +00202 <font class="comment">//====================================================================================</font> +<a name="l00203"></a><a class="code" href="classNL3D_1_1CPSMesh.html#b0">00203</a> <font class="keywordtype">void</font> CPSMesh::newElement(CPSLocated *emitterLocated, uint32 emitterIndex) +00204 { +00205 <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#b1">newPlaneBasisElement</a>(emitterLocated, emitterIndex); +00206 <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#b1">newAngle2DElement</a>(emitterLocated, emitterIndex); +00207 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b1">newSizeElement</a>(emitterLocated, emitterIndex); +00208 +00209 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>); +00210 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()); +00211 +00212 CScene *scene = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getScene(); +00213 <a class="code" href="debug_8h.html#a6">nlassert</a>(scene); <font class="comment">// the setScene method of the particle system should have been called</font> +00214 <font class="comment">//CTransformShape *instance = _Shape->createInstance(*scene);</font> +00215 +00216 CTransformShape *instance = scene->createInstance(<a class="code" href="classNL3D_1_1CPSMesh.html#n0">_Shape</a>); +00217 +00218 <font class="keywordflow">if</font> (!instance) +00219 { +00220 +00221 <font class="comment">// mesh not found ...</font> +00222 IShape *is = <a class="code" href="namespaceNL3D.html#a429">CreateDummyShape</a>(); +00223 scene->getShapeBank()->add(<a class="code" href="namespaceNL3D.html#a428">DummyShapeName</a>, is); +00224 instance = scene->createInstance(<a class="code" href="namespaceNL3D.html#a428">DummyShapeName</a>); +00225 <a class="code" href="debug_8h.html#a6">nlassert</a>(instance); +00226 } +00227 +00228 +00229 instance->setTransformMode(CTransform::DirectMatrix); +00230 +00231 instance->hide(); <font class="comment">// the object hasn't the right matrix yet so we hide it. It'll be shown once it is computed</font> +00232 <a class="code" href="debug_8h.html#a6">nlassert</a>(instance); +00233 +00234 <a class="code" href="classNL3D_1_1CPSMesh.html#n1">_Instances</a>.insert(instance); +00235 } +00236 +00237 <font class="comment">//==================================================================================== </font> +<a name="l00238"></a><a class="code" href="classNL3D_1_1CPSMesh.html#b1">00238</a> <font class="keywordtype">void</font> CPSMesh::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) +00239 { +00240 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b2">deleteSizeElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +00241 <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#b2">deleteAngle2DElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +00242 <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#b2">deletePlaneBasisElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +00243 +00244 <font class="comment">// check wether CTransformShape have been instanciated</font> +00245 <font class="keywordflow">if</font> (_Invalidated) <font class="keywordflow">return</font>; +00246 +00247 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>); +00248 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()); +00249 +00250 CScene *scene = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getScene(); +00251 <a class="code" href="debug_8h.html#a6">nlassert</a>(scene); <font class="comment">// the setScene method of the particle system should have been called</font> +00252 +00253 scene->deleteInstance(<a class="code" href="classNL3D_1_1CPSMesh.html#n1">_Instances</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>]); +00254 <a class="code" href="classNL3D_1_1CPSMesh.html#n1">_Instances</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +00255 } +00256 +00257 <font class="comment">//====================================================================================</font> +<a name="l00258"></a><a class="code" href="classNL3D_1_1CPSMesh.html#b2">00258</a> <font class="keywordtype">void</font> CPSMesh::step(<a class="code" href="namespaceNL3D.html#a484">TPSProcessPass</a> pass, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> realEt) +00259 { +00260 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a169">PSSolidRender</a>) +00261 { +00262 <a class="code" href="classNL3D_1_1CPSMesh.html#b3">updatePos</a>(); +00263 } +00264 <font class="keywordflow">else</font> +00265 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a171">PSToolRender</a>) <font class="comment">// edition mode only</font> +00266 { +00267 <a class="code" href="classNL3D_1_1CPSParticle.html#a8">showTool</a>(); +00268 } +00269 +00270 } +00271 +00272 <font class="comment">//====================================================================================</font> +<a name="l00273"></a><a class="code" href="classNL3D_1_1CPSMesh.html#b3">00273</a> <font class="keywordtype">void</font> CPSMesh::updatePos() +00274 { +00275 <font class="keyword">const</font> uint MeshBufSize = 512; +00276 PARTICLES_CHECK_MEM; +00277 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>); +00278 <font class="keyword">const</font> uint32 size = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize(); +00279 <font class="keywordflow">if</font> (!size) <font class="keywordflow">return</font>; +00280 +00281 +00282 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->incrementNbDrawnParticles(size); <font class="comment">// for benchmark purpose </font> +00283 +00284 +00285 <font class="keywordflow">if</font> (_Invalidated) +00286 { +00287 <font class="comment">// need to rebuild all the transform shapes</font> +00288 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>); +00289 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()); +00290 +00291 CScene *scene = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getScene(); +00292 <a class="code" href="debug_8h.html#a6">nlassert</a>(scene); <font class="comment">// the setScene method of the particle system should have been called</font> +00293 +00294 +00295 <a class="code" href="classNL3D_1_1CPSMesh.html#b4">resize</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getMaxSize()); +00296 +00297 <font class="keywordflow">for</font> (uint k = 0; k < size; ++k) +00298 { +00299 CTransformShape *instance = scene->createInstance(<a class="code" href="classNL3D_1_1CPSMesh.html#n0">_Shape</a>); +00300 instance->setTransformMode(CTransform::DirectMatrix); +00301 instance->hide(); +00302 <a class="code" href="classNL3D_1_1CPSMesh.html#n1">_Instances</a>.insert(instance); +00303 } +00304 +00305 <a class="code" href="classNL3D_1_1CPSMesh.html#n2">_Invalidated</a> = <font class="keyword">false</font>; +00306 } +00307 +00308 <font class="keywordtype">float</font> sizes[MeshBufSize]; +00309 <font class="keywordtype">float</font> angles[MeshBufSize]; +00310 <font class="keyword">static</font> CPlaneBasis planeBasis[MeshBufSize]; +00311 +00312 uint32 leftToDo = size, toProcess; +00313 +00314 +00315 <font class="keywordtype">float</font> *ptCurrSize; +00316 <font class="keyword">const</font> uint ptCurrSizeIncrement = <a class="code" href="classNL3D_1_1CPSSizedParticle.html#n1">_SizeScheme</a> ? 1 : 0; +00317 +00318 <font class="keywordtype">float</font> *ptCurrAngle; +00319 <font class="keyword">const</font> uint ptCurrAngleIncrement = <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#n1">_Angle2DScheme</a> ? 1 : 0; +00320 +00321 CPlaneBasis *ptBasis; +00322 <font class="keyword">const</font> uint ptCurrPlaneBasisIncrement = <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#n0">_PlaneBasisScheme</a> ? 1 : 0; +00323 +00324 TPSAttribVector::const_iterator posIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().begin(), endPosIt; +00325 +00326 +00327 TInstanceCont::iterator instanceIt = <a class="code" href="classNL3D_1_1CPSMesh.html#n1">_Instances</a>.begin(); +00328 +00329 <font class="keywordflow">do</font> +00330 { +00331 toProcess = leftToDo < MeshBufSize ? leftToDo : MeshBufSize; +00332 +00333 <font class="keywordflow">if</font> (_SizeScheme) +00334 { +00335 ptCurrSize = (<font class="keywordtype">float</font> *) (<a class="code" href="classNL3D_1_1CPSSizedParticle.html#n1">_SizeScheme</a>->make(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, size - leftToDo, &sizes[0], <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>)); +00336 } +00337 <font class="keywordflow">else</font> +00338 { +00339 ptCurrSize =& <a class="code" href="classNL3D_1_1CPSSizedParticle.html#n0">_ParticleSize</a>; +00340 } +00341 +00342 <font class="keywordflow">if</font> (_Angle2DScheme) +00343 { +00344 ptCurrAngle = (<font class="keywordtype">float</font> *) (<a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#n1">_Angle2DScheme</a>->make(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, size - leftToDo, &angles[0], <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>)); +00345 } +00346 <font class="keywordflow">else</font> +00347 { +00348 ptCurrAngle =& <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#n0">_Angle2D</a>; +00349 } +00350 +00351 +00352 <font class="keywordflow">if</font> (_PlaneBasisScheme) +00353 { +00354 ptBasis = (CPlaneBasis *) (<a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#n0">_PlaneBasisScheme</a>->make(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, size - leftToDo, &planeBasis[0], <font class="keyword">sizeof</font>(CPlaneBasis), toProcess, <font class="keyword">true</font>)); +00355 } +00356 <font class="keywordflow">else</font> +00357 { +00358 ptBasis = &<a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#n1">_PlaneBasis</a>; +00359 } +00360 +00361 endPosIt = posIt + toProcess; +00362 CMatrix mat, tmat; +00363 +00364 <font class="comment">// the matrix used to get in the right basis</font> +00365 <font class="keyword">const</font> CMatrix &transfo = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->isInSystemBasis() ? <font class="comment">/*_Owner->getOwner()->*/</font><a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a15">getSysMat</a>() : CMatrix::Identity; +00366 <font class="keywordflow">do</font> +00367 { +00368 (*instanceIt)->show(); +00369 +00370 tmat.identity(); +00371 mat.identity(); +00372 +00373 tmat.translate(*posIt); +00374 +00375 +00376 +00377 mat.setRot( ptBasis->X * CPSUtil::getCos((sint32) *ptCurrAngle) + ptBasis->Y * CPSUtil::getSin((sint32) *ptCurrAngle) +00378 , ptBasis->X * CPSUtil::getCos((sint32) *ptCurrAngle + 64) + ptBasis->Y * CPSUtil::getSin((sint32) *ptCurrAngle + 64) +00379 , ptBasis->X ^ ptBasis->Y +00380 ); +00381 +00382 mat.scale(*ptCurrSize); +00383 +00384 (*instanceIt)->setMatrix(transfo * tmat * mat); +00385 +00386 ++instanceIt; +00387 ++posIt; +00388 ptCurrSize += ptCurrSizeIncrement; +00389 ptCurrAngle += ptCurrAngleIncrement; +00390 ptBasis += ptCurrPlaneBasisIncrement; +00391 } +00392 <font class="keywordflow">while</font> (posIt != endPosIt); +00393 leftToDo -= toProcess; +00394 } +00395 <font class="keywordflow">while</font> (leftToDo); +00396 +00397 PARTICLES_CHECK_MEM; +00398 } +00399 +00400 <font class="comment">//====================================================================================</font> +<a name="l00401"></a><a class="code" href="classNL3D_1_1CPSMesh.html#b4">00401</a> <font class="keywordtype">void</font> CPSMesh::resize(uint32 size) +00402 { +00403 <a class="code" href="debug_8h.html#a6">nlassert</a>(size < (1 << 16)); +00404 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b3">resizeSize</a>(size); +00405 <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#b3">resizeAngle2D</a>(size); +00406 <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#b3">resizePlaneBasis</a>(size); +00407 <a class="code" href="classNL3D_1_1CPSMesh.html#n1">_Instances</a>.resize(size); +00408 } +00409 +00410 +00411 <font class="comment">//====================================================================================</font> +<a name="l00412"></a><a class="code" href="classNL3D_1_1CPSMesh.html#a4">00412</a> CPSMesh::~CPSMesh() +00413 { +00414 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> && <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()) +00415 { +00416 CScene *scene = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getScene(); +00417 <a class="code" href="debug_8h.html#a6">nlassert</a>(scene); <font class="comment">// the setScene method of the particle system should have been called</font> +00418 +00419 <font class="keywordflow">for</font> (TInstanceCont::iterator it = <a class="code" href="classNL3D_1_1CPSMesh.html#n1">_Instances</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSMesh.html#n1">_Instances</a>.end(); ++it) +00420 { +00421 scene->deleteInstance(*it); +00422 } +00423 } +00424 } +00425 +00427 <font class="comment">// CPSConstraintMesh implementation //</font> +00429 <font class="comment"></font> +00431 <font class="comment">static uint getMeshNumTri(const CMesh &m)</font> +00432 { +00433 uint numFaces = 0; +00434 <font class="keywordflow">for</font> (uint k = 0; k < m.getNbMatrixBlock(); ++k) +00435 { +00436 <font class="keywordflow">for</font> (uint <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> < m.getNbRdrPass(k); ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>) +00437 { +00438 <font class="keyword">const</font> CPrimitiveBlock pb = m.getRdrPassPrimitiveBlock(k, <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>); +00439 numFaces += (pb.getNumLine() << 1) + pb.getNumTri() + (pb.getNumQuad() << 1); +00440 +00441 } +00442 } +00443 <font class="keywordflow">return</font> numFaces; +00444 } +00445 +00446 +00447 <font class="comment">//====================================================================================</font> +00449 <font class="comment">static void CheckForOpaqueAndTransparentFacesInMesh(const CMesh &m, bool &hasTransparentFaces, bool &hasOpaqueFaces)</font> +00450 { +00451 hasTransparentFaces = <font class="keyword">false</font>; +00452 hasOpaqueFaces = <font class="keyword">false</font>; +00453 +00454 <font class="keywordflow">for</font> (uint k = 0; k < m.getNbRdrPass(0); ++k) +00455 { +00456 <font class="keyword">const</font> CMaterial &currMat = m.getMaterial(m.getRdrPassMaterial(0, k)); +00457 <font class="keywordflow">if</font> (!currMat.getZWrite()) +00458 { +00459 hasTransparentFaces = <font class="keyword">true</font>; +00460 } +00461 <font class="keywordflow">else</font> <font class="comment">// z-buffer write or no blending -> the face is opaque</font> +00462 { +00463 hasOpaqueFaces = <font class="keyword">true</font>; +00464 } +00465 } +00466 } +00467 +00468 +00469 +<a name="l00475"></a><a class="code" href="classNL3D_1_1CPSConstraintMeshHelper.html">00475</a> <font class="keyword">class </font>CPSConstraintMeshHelper +00476 { +00477 <font class="keyword">public</font>: +00478 <font class="keyword">template</font> <<font class="keyword">class</font> T> +<a name="l00479"></a><a class="code" href="classNL3D_1_1CPSConstraintMeshHelper.html#d0">00479</a> <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="classNL3D_1_1CPSConstraintMeshHelper.html#d0">drawMeshs</a>(T posIt, CPSConstraintMesh &m, uint size, uint32 srcStep, <font class="keywordtype">bool</font> opaque) +00480 { +00481 CMesh &mesh = * NLMISC::safe_cast<CMesh *>((IShape *) m._Shapes[0]); +00482 <font class="keyword">const</font> CVertexBuffer &modelVb = mesh.getVertexBuffer(); +00483 +00484 <font class="comment">// size for model vertices</font> +00485 <font class="keyword">const</font> uint inVSize = modelVb.getVertexSize(); <font class="comment">// vertex size </font> +00486 +00487 <font class="comment">// driver setup</font> +00488 IDriver *driver = m.getDriver(); +00489 m.setupDriverModelMatrix(); +00490 +00491 <font class="comment">// buffer to compute sizes</font> +00492 <font class="keywordtype">float</font> sizes[<a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>]; +00493 +00494 <font class="keywordtype">float</font> *ptCurrSize; +00495 uint ptCurrSizeIncrement = m._SizeScheme ? 1 : 0; +00496 +00497 T endPosIt; +00498 uint leftToDo = size, toProcess; +00499 +00501 CPSConstraintMesh::CMeshDisplay &md= m._MeshDisplayShare.getMeshDisplay(m._Shapes[0], modelVb.getVertexFormat() +00502 | (m._ColorScheme ? CVertexBuffer::PrimaryColorFlag : 0)); +00503 +00504 m.setupRenderPasses((<font class="keywordtype">float</font>) m._Owner->getOwner()->getSystemDate() - m._GlobalAnimDate, md.RdrPasses, opaque); +00505 +00506 CVertexBuffer &outVb = md.VB; +00507 <font class="keyword">const</font> uint outVSize = outVb.getVertexSize(); +00508 +00509 driver->activeVertexBuffer(outVb); +00510 +00511 <font class="comment">// we don't have precomputed mesh there ... so each mesh must be transformed, which is the worst case </font> +00512 CPlaneBasis planeBasis[<a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>]; +00513 CPlaneBasis *ptBasis; +00514 uint ptBasisIncrement = m._PlaneBasisScheme ? 1 : 0; +00515 +00516 <font class="keyword">const</font> uint nbVerticesInSource = modelVb.getNumVertices(); +00517 +00518 sint inNormalOff=0; +00519 sint outNormalOff=0; +00520 <font class="keywordflow">if</font> (modelVb.getVertexFormat() & CVertexBuffer::NormalFlag) +00521 { +00522 inNormalOff = modelVb.getNormalOff(); +00523 outNormalOff = outVb.getNormalOff(); +00524 } +00525 +00526 <font class="keywordflow">do</font> +00527 { +00528 uint8 *outVertex = (uint8 *) outVb.getVertexCoordPointer(); +00529 +00530 toProcess = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(leftToDo, <a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>); +00531 +00532 <font class="keywordflow">if</font> (m._SizeScheme) +00533 { +00534 ptCurrSize = (<font class="keywordtype">float</font> *) (m._SizeScheme->make(m._Owner, size -leftToDo, &sizes[0], <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep)); +00535 } +00536 <font class="keywordflow">else</font> +00537 { +00538 ptCurrSize = &m._ParticleSize; +00539 } +00540 +00541 <font class="keywordflow">if</font> (m._PlaneBasisScheme) +00542 { +00543 ptBasis = (CPlaneBasis *) (m._PlaneBasisScheme->make(m._Owner, size -leftToDo, &planeBasis[0], <font class="keyword">sizeof</font>(CPlaneBasis), toProcess, <font class="keyword">true</font>, srcStep)); +00544 } +00545 <font class="keywordflow">else</font> +00546 { +00547 ptBasis = &m._PlaneBasis; +00548 } +00549 +00550 +00551 endPosIt = posIt + toProcess; +00552 <font class="comment">// transfo matrix & scaled transfo matrix;</font> +00553 CMatrix M, sM; +00554 +00555 +00556 <font class="keywordflow">if</font> (m._Shapes.size() == 1) +00557 { +00559 <font class="keywordflow">do</font> +00560 { +00561 +00562 uint8 *inVertex = (uint8 *) modelVb.getVertexCoordPointer(); +00563 uint k = nbVerticesInSource; +00564 +00565 <font class="comment">// do we need a normal ?</font> +00566 <font class="keywordflow">if</font> (modelVb.getVertexFormat() & CVertexBuffer::NormalFlag) +00567 { +00568 M.identity(); +00569 M.setRot(ptBasis->X, ptBasis->Y, ptBasis->X ^ ptBasis->Y); +00570 sM = M; +00571 sM.scale(*ptCurrSize); +00572 +00573 <font class="comment">// offset of normals in the prerotated mesh </font> +00574 <font class="keywordflow">do</font> +00575 { +00576 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(modelVb, inVertex); +00577 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(outVb, outVertex); +00578 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(modelVb, inVertex + inNormalOff); +00579 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(outVb, outVertex + outNormalOff); +00580 +00581 <font class="comment">// translate and resize the vertex (relatively to the mesh origin)</font> +00582 *(CVector *) outVertex = *posIt + sM * *(CVector *) inVertex; +00583 <font class="comment">// copy the normal</font> +00584 *(CVector *) (outVertex + outNormalOff) = M * *(CVector *) (inVertex + inNormalOff); +00585 +00586 +00587 inVertex += inVSize; +00588 outVertex += outVSize; +00589 } +00590 <font class="keywordflow">while</font> (--k); +00591 } +00592 <font class="keywordflow">else</font> +00593 { +00594 <font class="comment">// no normal to transform</font> +00595 sM.identity(); +00596 sM.setRot(ptBasis->X, ptBasis->Y, ptBasis->X ^ ptBasis->Y); +00597 sM.scale(*ptCurrSize); +00598 +00599 <font class="keywordflow">do</font> +00600 { +00601 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(modelVb, inVertex); +00602 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(outVb, outVertex); +00603 +00604 <font class="comment">// translate and resize the vertex (relatively to the mesh origin)</font> +00605 *(CVector *) outVertex = *posIt + sM * *(CVector *) inVertex; +00606 +00607 inVertex += inVSize; +00608 outVertex += outVSize; +00609 } +00610 <font class="keywordflow">while</font> (--k); +00611 } +00612 +00613 +00614 ++posIt; +00615 ptCurrSize += ptCurrSizeIncrement; +00616 ptBasis += ptBasisIncrement; +00617 } +00618 <font class="keywordflow">while</font> (posIt != endPosIt); +00619 } +00620 <font class="keywordflow">else</font> +00621 { +00622 <font class="comment">// morphed case</font> +00623 +00624 <font class="comment">// first, compute the morph value for each mesh</font> +00625 <font class="keywordtype">float</font> morphValues[<a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>]; +00626 <font class="keywordtype">float</font> *currMorphValue; +00627 uint morphValueIncr; +00628 +00629 <font class="keywordflow">if</font> (m._MorphScheme) <font class="comment">// variable case</font> +00630 { +00631 currMorphValue = (<font class="keywordtype">float</font> *) m._MorphScheme->make(m._Owner, size - leftToDo, &morphValues[0], <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep); +00632 morphValueIncr = 1; +00633 } +00634 <font class="keywordflow">else</font> +00635 { +00636 currMorphValue = &m._MorphValue; +00637 morphValueIncr = 0; +00638 } +00639 +00640 <font class="keywordflow">do</font> +00641 { +00642 <font class="keyword">const</font> uint numShapes = m._Shapes.size(); +00643 <font class="keyword">const</font> uint8 *m0, *m1; +00644 <font class="keywordtype">float</font> lambda; +00645 <font class="keywordtype">float</font> opLambda; +00646 <font class="keyword">const</font> CVertexBuffer *inVB0, *inVB1; +00647 <font class="keywordflow">if</font> (*currMorphValue >= numShapes - 1) +00648 { +00649 lambda = 0.f; +00650 opLambda = 1.f; +00651 inVB0 = inVB1 = &NLMISC::safe_cast<CMesh *>((IShape *) m._Shapes[numShapes - 1])->getVertexBuffer(); +00652 } +00653 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*currMorphValue <= 0) +00654 { +00655 lambda = 0.f; +00656 opLambda = 1.f; +00657 inVB0 = inVB1 = &NLMISC::safe_cast<CMesh *>((IShape *) m._Shapes[0])->getVertexBuffer(); +00658 } +00659 <font class="keywordflow">else</font> +00660 { +00661 uint iMeshIndex = (uint) *currMorphValue; +00662 lambda = *currMorphValue - iMeshIndex; +00663 opLambda = 1.f - lambda; +00664 inVB0 = &NLMISC::safe_cast<CMesh *>((IShape *) m._Shapes[iMeshIndex])->getVertexBuffer(); +00665 inVB1 = &NLMISC::safe_cast<CMesh *>((IShape *) m._Shapes[iMeshIndex + 1])->getVertexBuffer(); +00666 } +00667 +00668 m0 = (uint8 *) inVB0->getVertexCoordPointer(); +00669 m1 = (uint8 *) inVB1->getVertexCoordPointer(); +00670 +00671 +00672 uint k = nbVerticesInSource; +00673 <font class="comment">// do we need a normal ?</font> +00674 <font class="keywordflow">if</font> (modelVb.getVertexFormat() & CVertexBuffer::NormalFlag) +00675 { +00676 M.identity(); +00677 M.setRot(ptBasis->X, ptBasis->Y, ptBasis->X ^ ptBasis->Y); +00678 sM = M; +00679 sM.scale(*ptCurrSize); +00680 +00681 <font class="comment">// offset of normals in the prerotated mesh </font> +00682 <font class="keywordflow">do</font> +00683 { +00684 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>((*inVB0), m0); +00685 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>((*inVB1), m1); +00686 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>((*inVB0), m0 + inNormalOff); +00687 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>((*inVB1), m1 + inNormalOff); +00688 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(outVb, outVertex); +00689 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(outVb, outVertex + outNormalOff); +00690 +00691 <font class="comment">// morph, and transform the vertex</font> +00692 *(CVector *) outVertex = *posIt + sM * (opLambda * *(CVector *) m0 + lambda * *(CVector *) m1); +00693 <font class="comment">// morph, and transform the normal</font> +00694 *(CVector *) (outVertex + outNormalOff) = M * (opLambda * *(CVector *) (m0 + inNormalOff) +00695 + lambda * *(CVector *) (m1 + inNormalOff)).normed(); +00696 +00697 +00698 m0 += inVSize; +00699 m1 += inVSize; +00700 outVertex += outVSize; +00701 } +00702 <font class="keywordflow">while</font> (--k); +00703 } +00704 <font class="keywordflow">else</font> +00705 { +00706 <font class="comment">// no normal to transform</font> +00707 sM.identity(); +00708 sM.setRot(ptBasis->X, ptBasis->Y, ptBasis->X ^ ptBasis->Y); +00709 sM.scale(*ptCurrSize); +00710 +00711 <font class="keywordflow">do</font> +00712 { +00713 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>((*inVB0), m0); +00714 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>((*inVB1), m1); +00715 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(outVb, outVertex); +00716 <font class="comment">// morph, and transform the vertex</font> +00717 *(CVector *) outVertex = *posIt + sM * (opLambda * *(CVector *) m0 + opLambda * *(CVector *) m1); +00718 +00719 m0 += inVSize; +00720 m1 += inVSize; +00721 outVertex += outVSize; +00722 } +00723 <font class="keywordflow">while</font> (--k); +00724 } +00725 +00726 +00727 ++posIt; +00728 ptCurrSize += ptCurrSizeIncrement; +00729 ptBasis += ptBasisIncrement; +00730 currMorphValue += morphValueIncr; +00731 } +00732 <font class="keywordflow">while</font> (posIt != endPosIt); +00733 } +00734 +00735 <font class="comment">// compute colors if needed</font> +00736 <font class="keywordflow">if</font> (m._ColorScheme) +00737 { +00738 m.computeColors(outVb, modelVb, size - leftToDo, toProcess, srcStep); +00739 } +00740 +00741 <font class="comment">// render meshs</font> +00742 m.doRenderPasses(driver, toProcess, md.RdrPasses, opaque); +00743 leftToDo -= toProcess; +00744 +00745 } +00746 <font class="keywordflow">while</font> (leftToDo); +00747 } +00748 +00749 +00750 <font class="keyword">template</font> <<font class="keyword">class</font> T, <font class="keyword">class</font> U> +<a name="l00751"></a><a class="code" href="classNL3D_1_1CPSConstraintMeshHelper.html#d1">00751</a> <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="classNL3D_1_1CPSConstraintMeshHelper.html#d1">drawPrerotatedMeshs</a>(T posIt, +00752 U indexIt, +00753 CPSConstraintMesh &m, +00754 uint size, +00755 uint32 srcStep, +00756 <font class="keywordtype">bool</font> opaque, +00757 <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime) +00758 { +00759 <font class="comment">// get the vb from the original mesh</font> +00760 CMesh &mesh = * NLMISC::safe_cast<CMesh *>((IShape *) m._Shapes[0]); +00761 <font class="keyword">const</font> CVertexBuffer &modelVb = mesh.getVertexBuffer(); +00762 +00764 CVertexBuffer &prerotVb = m.makePrerotatedVb(modelVb, ellapsedTime); +00765 +00766 <font class="comment">// driver setup</font> +00767 IDriver *driver = m.getDriver(); +00768 m.setupDriverModelMatrix(); +00769 +00770 <font class="comment">// renderPasses setup</font> +00771 <a class="code" href="debug_8h.html#a6">nlassert</a>(m._Owner) +00772 +00773 <font class="comment">// storage for sizes of meshs</font> +00774 <font class="keywordtype">float</font> sizes[<a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>]; +00775 +00776 <font class="comment">// point the size for the current mesh</font> +00777 <font class="keywordtype">float</font> *ptCurrSize; +00778 uint ptCurrSizeIncrement = m._SizeScheme ? 1 : 0; +00779 +00780 T endPosIt; +00781 uint leftToDo = size, toProcess; +00782 <font class="keyword">const</font> uint nbVerticesInSource = modelVb.getNumVertices(); +00783 +00784 +00785 +00786 <font class="comment">// size of a complete prerotated model</font> +00787 <font class="keyword">const</font> uint prerotatedModelSize = prerotVb.getVertexSize() * modelVb.getNumVertices(); +00788 +00790 CPSConstraintMesh::CMeshDisplay &md = m._MeshDisplayShare.getMeshDisplay(m._Shapes[0], modelVb.getVertexFormat() +00791 | (m._ColorScheme ? CVertexBuffer::PrimaryColorFlag : 0)); +00792 +00793 +00794 m.setupRenderPasses((<font class="keywordtype">float</font>) m._Owner->getOwner()->getSystemDate() - m._GlobalAnimDate, md.RdrPasses, opaque); +00795 +00796 CVertexBuffer &outVb = md.VB; +00797 +00798 driver->activeVertexBuffer(outVb); +00799 +00800 +00801 <font class="comment">// size of vertices in prerotated model</font> +00802 <font class="keyword">const</font> uint inVSize = prerotVb.getVertexSize(); +00803 +00804 <font class="comment">// size ofr vertices in dest vb</font> +00805 <font class="keyword">const</font> uint outVSize = outVb.getVertexSize(); +00806 +00807 <font class="comment">// offset of normals in vertices of the prerotated model, and source model </font> +00808 uint normalOff=0; +00809 uint pNormalOff=0; +00810 <font class="keywordflow">if</font> (prerotVb.getVertexFormat() & CVertexBuffer::NormalFlag) +00811 { +00812 normalOff = outVb.getNormalOff(); +00813 pNormalOff = prerotVb.getNormalOff(); +00814 } +00815 +00816 <font class="keywordflow">do</font> +00817 { +00818 toProcess = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(leftToDo, <a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>); +00819 +00820 <font class="keywordflow">if</font> (m._SizeScheme) +00821 { +00822 <font class="comment">// compute size</font> +00823 ptCurrSize = (<font class="keywordtype">float</font> *) (m._SizeScheme->make(m._Owner, size - leftToDo, &sizes[0], <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep)); +00824 } +00825 <font class="keywordflow">else</font> +00826 { +00827 <font class="comment">// pointer on constant size</font> +00828 ptCurrSize = &m._ParticleSize; +00829 } +00830 +00831 endPosIt = posIt + toProcess; +00832 uint8 *outVertex = (uint8 *) outVb.getVertexCoordPointer(); +00834 <font class="keywordflow">do</font> +00835 { +00836 uint8 *inVertex = (uint8 *) prerotVb.getVertexCoordPointer() + prerotatedModelSize * *indexIt; <font class="comment">// prerotated vertex </font> +00837 uint k = nbVerticesInSource; +00838 +00839 <font class="keywordflow">if</font> (prerotVb.getVertexFormat() & CVertexBuffer::NormalFlag) <font class="comment">// has it a normal ?</font> +00840 { +00841 <font class="keywordflow">do</font> +00842 { +00843 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(outVb, outVertex); +00844 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(prerotVb, inVertex); +00845 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(outVb, outVertex + normalOff); +00846 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(prerotVb, inVertex + pNormalOff); +00847 +00848 +00849 <font class="comment">// translate and resize the vertex (relatively to the mesh origin)</font> +00850 *(CVector *) outVertex = *posIt + *ptCurrSize * *(CVector *) inVertex; +00851 <font class="comment">// copy the normal</font> +00852 *(CVector *) (outVertex + normalOff ) = *(CVector *) (inVertex + pNormalOff); +00853 inVertex += inVSize; +00854 outVertex += outVSize; +00855 } +00856 <font class="keywordflow">while</font> (--k); +00857 } +00858 <font class="keywordflow">else</font> +00859 { +00860 <font class="keywordflow">do</font> +00861 { +00862 <font class="comment">// translate and resize the vertex (relatively to the mesh origin)</font> +00863 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(outVb, outVertex); +00864 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(prerotVb, inVertex); +00865 *(CVector *) outVertex = *posIt + *ptCurrSize * *(CVector *) inVertex; +00866 inVertex += inVSize; +00867 outVertex += outVSize; +00868 } +00869 <font class="keywordflow">while</font> (--k); +00870 } +00871 +00872 ++indexIt; +00873 ++posIt; +00874 ptCurrSize += ptCurrSizeIncrement; +00875 } +00876 <font class="keywordflow">while</font> (posIt != endPosIt); +00877 +00878 <font class="comment">// compute colors if needed</font> +00879 <font class="keywordflow">if</font> (m._ColorScheme) +00880 { +00881 m.computeColors(outVb, modelVb, size - leftToDo, toProcess, srcStep); +00882 } +00883 +00884 +00886 m.doRenderPasses(driver, toProcess, md.RdrPasses, opaque); +00887 leftToDo -= toProcess; +00888 +00889 } +00890 <font class="keywordflow">while</font> (leftToDo); +00891 PARTICLES_CHECK_MEM +00892 } +00893 }; +00894 +<a name="l00895"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a0">00895</a> CPSConstraintMesh::CPSConstraintMesh() : _NumFaces(0), +00896 _ModelBank(NULL), +00897 _ModulatedStages(0), +00898 _Touched(1), +00899 _VertexColorLightingForced(false), +00900 _GlobalAnimationEnabled(0), +00901 _ReinitGlobalAnimTimeOnNewElement(0), +00902 _MorphValue(0), +00903 _MorphScheme(NULL) +00904 { +00905 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n3">_Name</a> = std::string(<font class="stringliteral">"ConstraintMesh"</font>); +00906 } +00907 +00908 <font class="comment">//====================================================================================</font> +<a name="l00909"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a21">00909</a> uint32 CPSConstraintMesh::getMaxNumFaces(<font class="keywordtype">void</font>)<font class="keyword"> const</font> +00910 <font class="keyword"></font>{ +00911 <font class="comment">// nlassert(_ModelVb);</font> +00912 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n2">_NumFaces</a> * <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getMaxSize(); +00913 +00914 } +00915 +00916 +00917 <font class="comment">//====================================================================================</font> +<a name="l00918"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a19">00918</a> <font class="keywordtype">bool</font> CPSConstraintMesh::hasTransparentFaces(<font class="keywordtype">void</font>) +00919 { +00920 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n9">_Touched</a>) <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n10">_HasTransparentFaces</a> != 0; +00922 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b10">update</a>(); +00923 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n10">_HasTransparentFaces</a> != 0; +00924 } +00925 +00926 <font class="comment">//====================================================================================</font> +<a name="l00927"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a20">00927</a> <font class="keywordtype">bool</font> CPSConstraintMesh::hasOpaqueFaces(<font class="keywordtype">void</font>) +00928 { +00929 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n9">_Touched</a>) <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n11">_HasOpaqueFaces</a> != 0; +00930 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b10">update</a>(); +00931 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n11">_HasOpaqueFaces</a> != 0; +00932 } +00933 +00934 <font class="comment">//====================================================================================</font> +<a name="l00935"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a2">00935</a> <font class="keywordtype">void</font> CPSConstraintMesh::setShape(<font class="keyword">const</font> std::string &meshFileName) +00936 { +00937 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.resize(1); +00938 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[0] = meshFileName; +00939 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n9">_Touched</a> = 1; +00940 } +00941 +00942 +00943 <font class="comment">//===========================================================================</font> +<a name="l00944"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a3">00944</a> std::string CPSConstraintMesh::getShape(<font class="keywordtype">void</font>)<font class="keyword"> const</font> +00945 <font class="keyword"></font>{ +00946 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.size() == 1); +00947 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[0]; +00948 } +00949 +00950 <font class="comment">//====================================================================================</font> +<a name="l00951"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a4">00951</a> <font class="keywordtype">void</font> CPSConstraintMesh::setShapes(<font class="keyword">const</font> std::string *shapesNames, uint numShapes) +00952 { +00953 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.resize(numShapes); +00954 std::copy(shapesNames, shapesNames + numShapes, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.begin()); +00955 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n9">_Touched</a> = 1; +00956 } +00957 +00958 <font class="comment">//====================================================================================</font> +<a name="l00959"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a7">00959</a> uint CPSConstraintMesh::getNumShapes()<font class="keyword"> const</font> +00960 <font class="keyword"></font>{ +00961 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.size(); +00962 } +00963 +00964 <font class="comment">//====================================================================================</font> +<a name="l00965"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a8">00965</a> <font class="keywordtype">void</font> CPSConstraintMesh::getShapesNames(std::string *shapesNames)<font class="keyword"> const</font> +00966 <font class="keyword"></font>{ +00967 std::copy(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.begin(), <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.end(), shapesNames); +00968 } +00969 +00970 +00971 +00972 <font class="comment">//====================================================================================</font> +<a name="l00973"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a5">00973</a> <font class="keywordtype">void</font> CPSConstraintMesh::setShape(uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> std::string &shapeName) +00974 { +00975 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> < <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.size()); +00976 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = shapeName; +00977 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n9">_Touched</a> = 1; +00978 } +00979 +00980 +00981 <font class="comment">//====================================================================================</font> +<a name="l00982"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a6">00982</a> <font class="keyword">const</font> std::string &CPSConstraintMesh::getShape(uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font> +00983 <font class="keyword"></font>{ +00984 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> < <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.size()); +00985 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>]; +00986 } +00987 +00988 +00989 +00990 <font class="comment">//====================================================================================</font> +<a name="l00991"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a9">00991</a> <font class="keywordtype">void</font> CPSConstraintMesh::setMorphValue(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>) +00992 { +00993 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>; +00994 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a> = NULL; +00995 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_0">_MorphValue</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>; +00996 } +00997 +00998 +00999 <font class="comment">//====================================================================================</font> +<a name="l01000"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a10">01000</a> <font class="keywordtype">float</font> CPSConstraintMesh::getMorphValue()<font class="keyword"> const</font> +01001 <font class="keyword"></font>{ +01002 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_0">_MorphValue</a>; +01003 } +01004 +01005 <font class="comment">//====================================================================================</font> +<a name="l01006"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a11">01006</a> <font class="keywordtype">void</font> CPSConstraintMesh::setMorphScheme(CPSAttribMaker<float> *scheme) +01007 { +01008 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>; +01009 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a> = scheme; +01010 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>->hasMemory()) <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>->resize(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getMaxSize(), <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize()); +01011 } +01012 +01013 <font class="comment">//====================================================================================</font> +<a name="l01014"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a12">01014</a> CPSAttribMaker<float> *CPSConstraintMesh::getMorphScheme() +01015 { +01016 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>; +01017 } +01018 +01019 <font class="comment">//====================================================================================</font> +<a name="l01020"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a13">01020</a> <font class="keyword">const</font> CPSAttribMaker<float> *CPSConstraintMesh::getMorphScheme()<font class="keyword"> const</font> +01021 <font class="keyword"></font>{ +01022 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>; +01023 } +01024 +01025 +01026 <font class="comment">//====================================================================================</font> +01027 <font class="keyword">static</font> IShape *<a class="code" href="namespaceNL3D.html#a432">GetDummyShapeFromBank</a>(CShapeBank &sb) +01028 { +01029 <font class="keyword">static</font> <font class="keyword">const</font> std::string dummyMeshName(<font class="stringliteral">"dummy constraint mesh shape"</font>); +01030 <font class="keywordflow">if</font> (sb.isPresent(dummyMeshName) == CShapeBank::Present) +01031 { +01032 <font class="keywordflow">return</font> sb.addRef(dummyMeshName); +01033 } +01034 <font class="keywordflow">else</font> +01035 { +01036 <font class="comment">// no dummy shape created -> add one to the bank</font> +01037 IShape *is = <a class="code" href="namespaceNL3D.html#a429">CreateDummyShape</a>(); +01038 sb.add(std::string(<font class="stringliteral">"dummy constraint mesh shape"</font>), is); +01039 <font class="keywordflow">return</font> is; +01040 } +01041 } +01042 +01043 <font class="comment">//====================================================================================</font> +<a name="l01044"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b10">01044</a> <font class="keywordtype">bool</font> CPSConstraintMesh::update(<font class="keywordtype">void</font>) +01045 { +01046 <font class="keywordtype">bool</font> ok = <font class="keyword">true</font>; +01047 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n9">_Touched</a>) <font class="keywordflow">return</font> ok; +01048 +01049 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b16">clean</a>(); +01050 +01051 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getScene()); +01052 +01053 CScene *scene = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getScene(); +01054 CShapeBank *sb = scene->getShapeBank(); +01055 IShape *is; +01056 +01057 +01058 uint32 vFormat=0; +01059 uint numVerts=0; +01060 +01061 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.size() == 0) +01062 { +01063 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.resize(1); +01064 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[0] = <a class="code" href="namespaceNL3D.html#a428">DummyShapeName</a>; +01065 } +01066 +01067 +01068 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>.resize(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.size()); +01069 <font class="keywordflow">for</font> (uint k = 0; k < <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>.size(); ++k) +01070 { +01071 <font class="keywordflow">if</font> (sb->isPresent(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[k]) == CShapeBank::Present) +01072 { +01073 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>[k] = sb->addRef(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[k]); +01074 +01076 <font class="keyword">const</font> CMesh &m = * NLMISC::safe_cast<CMesh *>((IShape *) <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>[k]); <font class="comment">// only mesh shape's can be used with this class!</font> +01077 <font class="keywordflow">if</font> (k == 0) +01078 { +01079 vFormat = m.getVertexBuffer().getVertexFormat(); +01080 numVerts = m.getVertexBuffer().getNumVertices(); +01081 } +01082 <font class="keywordflow">else</font> +01083 { +01084 <font class="keywordflow">if</font> (vFormat != m.getVertexBuffer().getVertexFormat() +01085 || numVerts != m.getVertexBuffer().getNumVertices()) +01086 { +01087 ok = <font class="keyword">false</font>; +01088 } +01089 } +01090 } +01091 <font class="keywordflow">else</font> +01092 { +01093 <font class="keywordflow">try</font> +01094 { +01095 sb->load(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[k]); +01096 } +01097 <font class="keywordflow">catch</font> (<a class="code" href="structNLMISC_1_1EPathNotFound.html">NLMISC::EPathNotFound</a> &) +01098 { +01099 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"mesh not found : %s; used as a constraint mesh particle"</font>, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[k].c_str()); +01100 <font class="comment">// shape not found, so not present in the shape bank -> we create a dummy shape</font> +01101 } +01102 +01103 <font class="keywordflow">if</font> (sb->isPresent(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[k]) != CShapeBank::Present) +01104 { +01105 ok = <font class="keyword">false</font>; +01106 } +01107 <font class="keywordflow">else</font> +01108 { +01109 is = sb->addRef(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[k]); +01110 <font class="keywordflow">if</font> (!dynamic_cast<CMesh *>(is)) <font class="comment">// is it a mesh</font> +01111 { +01112 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Tried to bind a shape that is not a mesh to a mesh particle : %s"</font>, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[k].c_str()); +01113 sb->release(is); +01114 ok = <font class="keyword">false</font>; +01115 } +01116 <font class="keywordflow">else</font> +01117 { +01118 <font class="keyword">const</font> CMesh &m = * NLMISC::safe_cast<CMesh *>(is); +01120 <font class="keywordflow">if</font> (m.getVertexBuffer().getNumVertices() > <a class="code" href="namespaceNL3D.html#a211">ConstraintMeshMaxNumVerts</a>) +01121 { +01122 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Tried to bind a mesh that has more than %d vertices to a particle mesh: %s"</font>, (<font class="keywordtype">int</font>) <a class="code" href="namespaceNL3D.html#a211">ConstraintMeshMaxNumVerts</a>, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n0">_MeshShapeFileName</a>[k].c_str()); +01123 sb->release(is); +01124 ok = <font class="keyword">false</font>; +01125 } +01126 <font class="keywordflow">else</font> +01127 { +01128 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>[k] = is; +01130 <font class="keyword">const</font> CMesh &m = * NLMISC::safe_cast<CMesh *>((IShape *) <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>[k]); <font class="comment">// only mesh shape's can be used with this class!</font> +01131 <font class="keywordflow">if</font> (k == 0) +01132 { +01133 vFormat = m.getVertexBuffer().getVertexFormat(); +01134 numVerts = m.getVertexBuffer().getNumVertices(); +01135 } +01136 <font class="keywordflow">else</font> +01137 { +01138 <font class="keywordflow">if</font> (vFormat != m.getVertexBuffer().getVertexFormat() +01139 || numVerts != m.getVertexBuffer().getNumVertices()) +01140 { +01141 ok = <font class="keyword">false</font>; +01142 } +01143 } +01144 } +01145 } +01146 } +01147 } +01148 +01149 <font class="keywordflow">if</font> (!ok) +01150 { +01151 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b7">releaseShapes</a>(); +01152 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>.resize(1); +01153 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>[0] = <a class="code" href="namespaceNL3D.html#a432">GetDummyShapeFromBank</a>(*sb); +01154 <font class="keywordflow">break</font>; +01155 } +01156 } +01157 +01158 +01159 <font class="keyword">const</font> CMesh &m = * NLMISC::safe_cast<CMesh *>((IShape *) <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>[0]); <font class="comment">// only mesh shape's can be used with this class!</font> +01160 +01162 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n2">_NumFaces</a> = <a class="code" href="namespaceNL3D.html#a430">getMeshNumTri</a>(m); +01163 <a class="code" href="classNL3D_1_1CPSParticle.html#b0">notifyOwnerMaxNumFacesChanged</a>(); +01164 +01166 <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a19">hasTransparentFaces</a>, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a20">hasOpaqueFaces</a>; +01167 <a class="code" href="namespaceNL3D.html#a431">CheckForOpaqueAndTransparentFacesInMesh</a>(m, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a19">hasTransparentFaces</a>, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a20">hasOpaqueFaces</a>); +01168 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n10">_HasTransparentFaces</a> = <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a19">hasTransparentFaces</a>; +01169 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n11">_HasOpaqueFaces</a> = <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a20">hasOpaqueFaces</a>; +01170 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n3">_ModelBank</a> = sb; +01171 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n16">_GlobalAnimDate</a> = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()->getSystemDate(); +01172 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n9">_Touched</a> = 0; +01173 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>.size() > 0); +01174 +01175 <font class="preprocessor"> #ifdef NL_DEBUG</font> +01176 <font class="preprocessor"></font> <font class="keywordflow">for</font> (uint j = 0; j < <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>.size(); ++j) +01177 { +01178 <a class="code" href="debug_8h.html#a6">nlassert</a>(dynamic_cast<CMesh *>((IShape *) <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>[j])); +01179 } +01180 <font class="preprocessor"> #endif</font> +01181 <font class="preprocessor"></font> +01182 <font class="keywordflow">return</font> ok; +01183 +01184 } +01185 +01186 +01187 +01188 <font class="comment">//====================================================================================</font> +<a name="l01189"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a14">01189</a> <font class="keywordtype">void</font> CPSConstraintMesh::hintRotateTheSame(uint32 nbConfiguration, +01190 <font class="keywordtype">float</font> minAngularVelocity, +01191 <font class="keywordtype">float</font> maxAngularVelocity +01192 ) +01193 { +01194 <a class="code" href="debug_8h.html#a6">nlassert</a>(nbConfiguration <= <a class="code" href="namespaceNL3D.html#a213">ConstraintMeshMaxNumPrerotatedModels</a>); +01195 +01196 <font class="comment">// TODO : avoid code duplication with CPSFace ...</font> +01197 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n4">_MinAngularVelocity</a> = minAngularVelocity; +01198 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n5">_MaxAngularVelocity</a> = maxAngularVelocity; +01199 +01200 +01201 +01202 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>.resize(nbConfiguration); +01203 +01204 <font class="keywordflow">if</font> (nbConfiguration) +01205 { +01206 <font class="comment">// each precomp basis is created randomly;</font> +01207 <font class="keywordflow">for</font> (uint k = 0; k < nbConfiguration; ++k) +01208 { +01209 CVector <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = <a class="code" href="namespaceNL3D.html#a421">MakeRandomUnitVect</a>(); +01210 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>[k].Basis = CPlaneBasis(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); +01211 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>[k].Axis = <a class="code" href="namespaceNL3D.html#a421">MakeRandomUnitVect</a>(); +01212 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>[k].AngularVelocity = minAngularVelocity +01213 + (rand() % 20000) / 20000.f * (maxAngularVelocity - minAngularVelocity); +01214 +01215 } +01216 +01217 <font class="comment">// we need to do this because nbConfs may have changed</font> +01218 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b15">fillIndexesInPrecompBasis</a>(); +01219 } +01220 } +01221 +01222 +01223 <font class="comment">//====================================================================================</font> +<a name="l01224"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b15">01224</a> <font class="keywordtype">void</font> CPSConstraintMesh::fillIndexesInPrecompBasis(<font class="keywordtype">void</font>) +01225 { +01226 <font class="comment">// TODO : avoid code duplication with CPSFace ...</font> +01227 <font class="keyword">const</font> uint32 nbConf = <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>.size(); +01228 <font class="keywordflow">if</font> (_Owner) +01229 { +01230 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n7">_IndexInPrecompBasis</a>.resize( <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getMaxSize() ); +01231 } +01232 <font class="keywordflow">for</font> (std::vector<uint32>::iterator it = <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n7">_IndexInPrecompBasis</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n7">_IndexInPrecompBasis</a>.end(); ++it) +01233 { +01234 *it = rand() % nbConf; +01235 } +01236 } +01237 +01238 <font class="comment">//==================================================================================== </font> +<a name="l01240"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a17">01240</a> <font class="comment">void CPSConstraintMesh::serial(NLMISC::IStream &f) throw(NLMISC::EStream)</font> +01241 { +01242 +01243 sint ver = f.serialVersion(4); +01244 <font class="keywordflow">if</font> (f.isReading()) +01245 { +01246 clean(); +01247 } +01248 +01249 CPSParticle::serial(f); +01250 CPSSizedParticle::serialSizeScheme(f); +01251 CPSRotated3DPlaneParticle::serialPlaneBasisScheme(f); +01252 +01253 <font class="comment">// prerotations ...</font> +01254 +01255 <font class="keywordflow">if</font> (f.isReading()) +01256 { +01257 uint32 nbConfigurations; +01258 f.serial(nbConfigurations); +01259 <font class="keywordflow">if</font> (nbConfigurations) +01260 { +01261 f.serial(_MinAngularVelocity, _MaxAngularVelocity); +01262 } +01263 hintRotateTheSame(nbConfigurations, _MinAngularVelocity, _MaxAngularVelocity); +01264 } +01265 <font class="keywordflow">else</font> +01266 { +01267 uint32 nbConfigurations = _PrecompBasis.size(); +01268 f.serial(nbConfigurations); +01269 <font class="keywordflow">if</font> (nbConfigurations) +01270 { +01271 f.serial(_MinAngularVelocity, _MaxAngularVelocity); +01272 } +01273 } +01274 +01275 <font class="comment">// saves the model file name, or an empty string if nothing has been set </font> +01276 <font class="keyword">static</font> std::string emptyStr; +01277 +01278 <font class="keywordflow">if</font> (ver < 4) <font class="comment">// early version : no morphing support</font> +01279 { +01280 <font class="keywordflow">if</font> (!f.isReading()) +01281 { +01282 <font class="keywordflow">if</font> (_MeshShapeFileName.size() > 0) +01283 { +01284 f.serial(_MeshShapeFileName[0]); +01285 } +01286 <font class="keywordflow">else</font> +01287 { +01288 f.serial(emptyStr); +01289 } +01290 } +01291 <font class="keywordflow">else</font> +01292 { +01293 _MeshShapeFileName.resize(1); +01294 f.serial(_MeshShapeFileName[0]); +01295 _Touched = <font class="keyword">true</font>; +01296 } +01297 } +01298 +01299 <font class="keywordflow">if</font> (ver > 1) +01300 { +01301 CPSColoredParticle::serialColorScheme(f); +01302 f.serial(_ModulatedStages); +01303 <font class="keywordflow">if</font> (f.isReading()) +01304 { +01305 <font class="keywordtype">bool</font> vcEnabled; +01306 f.serial(vcEnabled); +01307 _VertexColorLightingForced = vcEnabled; +01308 } +01309 <font class="keywordflow">else</font> +01310 { +01311 <font class="keywordtype">bool</font> vcEnabled = (_VertexColorLightingForced != 0); +01312 f.serial(vcEnabled); +01313 } +01314 } +01315 +01316 <font class="keywordflow">if</font> (ver > 2) <font class="comment">// texture animation</font> +01317 { +01318 <font class="keywordflow">if</font> (f.isReading()) +01319 { +01320 <font class="keywordtype">bool</font> gaEnabled; +01321 f.serial(gaEnabled); +01322 _GlobalAnimationEnabled = gaEnabled; +01323 <font class="keywordflow">if</font> (gaEnabled) +01324 { +01325 PGlobalTexAnims newPtr(<font class="keyword">new</font> CGlobalTexAnims); <font class="comment">// create new</font> +01326 std::swap(_GlobalTexAnims, newPtr); <font class="comment">// replace old</font> +01327 f.serial(*_GlobalTexAnims); +01328 } +01329 +01330 <font class="keywordtype">bool</font> rgt; +01331 f.serial(rgt); +01332 _ReinitGlobalAnimTimeOnNewElement = rgt; +01333 } +01334 <font class="keywordflow">else</font> +01335 { +01336 <font class="keywordtype">bool</font> gaEnabled = (_GlobalAnimationEnabled != 0); +01337 f.serial(gaEnabled); +01338 <font class="keywordflow">if</font> (gaEnabled) +01339 { +01340 f.serial(*_GlobalTexAnims); +01341 } +01342 +01343 <font class="keywordtype">bool</font> rgt = _ReinitGlobalAnimTimeOnNewElement != 0; +01344 f.serial(rgt); +01345 } +01346 } +01347 +01348 <font class="keywordflow">if</font> (ver > 3) <font class="comment">// mesh morphing</font> +01349 { +01350 f.serialCont(_MeshShapeFileName); +01351 <font class="keywordtype">bool</font> useScheme; +01352 <font class="keywordflow">if</font> (f.isReading()) +01353 { +01354 <font class="keyword">delete</font> _MorphScheme; +01355 } +01356 <font class="keywordflow">else</font> +01357 { +01358 useScheme = _MorphScheme != NULL; +01359 } +01360 f.serial(useScheme); +01361 <font class="keywordflow">if</font> (useScheme) +01362 { +01363 f.serialPolyPtr(_MorphScheme); +01364 } +01365 <font class="keywordflow">else</font> +01366 { +01367 f.serial(_MorphValue); +01368 } +01369 } +01370 } +01371 +01372 <font class="comment">//====================================================================================</font> +<a name="l01373"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a1">01373</a> CPSConstraintMesh::~CPSConstraintMesh() +01374 { +01375 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b16">clean</a>(); +01376 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>; +01377 } +01378 +01379 +01380 +01381 <font class="comment">//====================================================================================</font> +<a name="l01382"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b7">01382</a> <font class="keywordtype">void</font> CPSConstraintMesh::releaseShapes() +01383 { +01384 <font class="keywordflow">for</font> (TShapeVect::iterator it = <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>.end(); ++it) +01385 { +01386 <font class="keywordflow">if</font> (*it) +01387 { +01388 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n3">_ModelBank</a>->release(*it); +01389 } +01390 } +01391 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>.clear(); +01392 } +01393 +01394 <font class="comment">//====================================================================================</font> +<a name="l01395"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b16">01395</a> <font class="keywordtype">void</font> CPSConstraintMesh::clean(<font class="keywordtype">void</font>) +01396 { +01397 <font class="keywordflow">if</font> (_ModelBank) +01398 { +01399 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b7">releaseShapes</a>(); +01400 } +01401 } +01402 +01403 +01404 <font class="comment">//====================================================================================</font> +<a name="l01405"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b11">01405</a> CVertexBuffer &CPSConstraintMesh::makePrerotatedVb(<font class="keyword">const</font> CVertexBuffer &inVb, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime) +01406 { +01407 <font class="comment">// get a VB that has positions and eventually normals</font> +01408 CVertexBuffer &prerotatedVb = inVb.getVertexFormat() & CVertexBuffer::NormalFlag ? <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#q2">_PreRotatedMeshVBWithNormal</a> : <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#q1">_PreRotatedMeshVB</a>; +01409 +01410 <font class="comment">// size of vertices for source VB</font> +01411 <font class="keyword">const</font> uint vSize = inVb.getVertexSize(); +01412 +01413 <font class="comment">// size for vertices in prerotated model</font> +01414 <font class="keyword">const</font> uint vpSize = prerotatedVb.getVertexSize(); +01415 +01416 +01417 <font class="comment">// offset of normals in vertices of the prerotated model, and source model </font> +01418 uint normalOff=0; +01419 uint pNormalOff=0; +01420 <font class="keywordflow">if</font> (prerotatedVb.getVertexFormat() & CVertexBuffer::NormalFlag) +01421 { +01422 normalOff = inVb.getNormalOff(); +01423 pNormalOff = prerotatedVb.getNormalOff(); +01424 } +01425 +01426 <font class="keyword">const</font> uint nbVerticesInSource = inVb.getNumVertices(); +01427 +01428 +01429 <font class="comment">// rotate basis</font> +01430 <font class="comment">// and compute the set of prerotated meshs that will then duplicated (with scale and translation) to create the Vb of what must be drawn</font> +01431 uint8 *outVertex = (uint8 *) prerotatedVb.getVertexCoordPointer(); +01432 <font class="keywordflow">for</font> (std::vector< CPlaneBasisPair >::iterator it = <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>.end(); ++it) +01433 { +01434 <font class="comment">// not optimized at all, but this will apply to very few elements anyway...</font> +01435 CMatrix mat; +01436 mat.rotate(CQuat(it->Axis, ellapsedTime * it->AngularVelocity)); +01437 CVector n = mat * it->Basis.getNormal(); +01438 it->Basis = CPlaneBasis(n); +01439 +01440 mat.identity(); +01441 mat.setRot(it->Basis.X, it->Basis.Y, it->Basis.X ^ it->Basis.Y); +01442 +01443 uint8 *inVertex = (uint8 *) inVb.getVertexCoordPointer(); +01444 +01445 uint k = nbVerticesInSource; +01446 +01447 <font class="comment">// check wether we need to rotate normals as well...</font> +01448 <font class="keywordflow">if</font> (inVb.getVertexFormat() & CVertexBuffer::NormalFlag) +01449 { +01450 +01451 <font class="keywordflow">do</font> +01452 { +01453 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(inVb, inVertex); +01454 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(inVb, inVertex + normalOff); +01455 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(prerotatedVb, outVertex); +01456 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(prerotatedVb, outVertex + pNormalOff); +01457 +01458 * (CVector *) outVertex = mat.mulVector(* (CVector *) inVertex); +01459 * (CVector *) (outVertex + normalOff) = mat.mulVector(* (CVector *) (inVertex + pNormalOff) ); +01460 outVertex += vpSize; +01461 inVertex += vSize; +01462 +01463 } +01464 <font class="keywordflow">while</font> (--k); +01465 } +01466 <font class="keywordflow">else</font> +01467 { +01468 <font class="comment">// no normal included</font> +01469 <font class="keywordflow">do</font> +01470 { +01471 +01472 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(prerotatedVb, outVertex); +01473 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(inVb, inVertex); +01474 +01475 * (CVector *) outVertex = mat.mulVector(* (CVector *) inVertex); +01476 outVertex += vpSize; +01477 inVertex += vSize; +01478 } +01479 <font class="keywordflow">while</font> (--k); +01480 +01481 } +01482 } +01483 <font class="keywordflow">return</font> prerotatedVb; +01484 } +01485 +01486 +01487 <font class="comment">//====================================================================================</font> +<a name="l01488"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">01488</a> <font class="keywordtype">void</font> CPSConstraintMesh::step(<a class="code" href="namespaceNL3D.html#a484">TPSProcessPass</a> pass, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> realEt) +01489 { +01490 <font class="keywordflow">if</font> ( +01491 (pass == <a class="code" href="namespaceNL3D.html#a484a170">PSBlendRender</a> && <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a19">hasTransparentFaces</a>()) +01492 || (pass == <a class="code" href="namespaceNL3D.html#a484a169">PSSolidRender</a> && <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a20">hasOpaqueFaces</a>()) +01493 ) +01494 { +01495 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b5">draw</a>(pass == <a class="code" href="namespaceNL3D.html#a484a169">PSSolidRender</a>, ellapsedTime); +01496 } +01497 <font class="keywordflow">else</font> +01498 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a171">PSToolRender</a>) <font class="comment">// edition mode only</font> +01499 { +01500 <a class="code" href="classNL3D_1_1CPSParticle.html#a8">showTool</a>(); +01501 } +01502 } +01503 +01504 <font class="comment">//====================================================================================</font> +<a name="l01505"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b5">01505</a> <font class="keywordtype">void</font> CPSConstraintMesh::draw(<font class="keywordtype">bool</font> opaque, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime) +01506 { +01507 PARTICLES_CHECK_MEM; +01508 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>); +01509 +01510 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b10">update</a>(); <font class="comment">// update mesh datas if needed</font> +01511 uint32 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a>; +01512 uint numToProcess; +01513 <a class="code" href="classNL3D_1_1CPSParticle.html#b4">computeSrcStep</a>(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a>, numToProcess); +01514 <font class="keywordflow">if</font> (!numToProcess) <font class="keywordflow">return</font>; +01515 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->incrementNbDrawnParticles(numToProcess); <font class="comment">// for benchmark purpose </font> +01516 +01517 +01518 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>.size() == 0) +01519 { +01520 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a> == (1 << 16)) +01521 { +01522 CPSConstraintMeshHelper::drawMeshs(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().begin(), +01523 *<font class="keyword">this</font>, +01524 numToProcess, +01525 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a>, +01526 opaque +01527 ); +01528 } +01529 <font class="keywordflow">else</font> +01530 { +01531 CPSConstraintMeshHelper::drawMeshs(<a class="code" href="namespaceNL3D.html#a199">TIteratorVectStep1616</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().begin(), 0, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a>), +01532 *<font class="keyword">this</font>, +01533 numToProcess, +01534 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a>, +01535 opaque +01536 ); +01537 } +01538 } +01539 <font class="keywordflow">else</font> +01540 { +01541 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a> == (1 << 16)) +01542 { +01543 CPSConstraintMeshHelper::drawPrerotatedMeshs(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().begin(), +01544 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n7">_IndexInPrecompBasis</a>.begin(), +01545 *<font class="keyword">this</font>, +01546 numToProcess, +01547 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a>, +01548 opaque, +01549 ellapsedTime +01550 ); +01551 } +01552 <font class="keywordflow">else</font> +01553 { +01554 <font class="keyword">typedef</font> CAdvance1616Iterator<std::vector<uint32>::const_iterator, uint32> TIndexIterator; +01555 CPSConstraintMeshHelper::drawPrerotatedMeshs(<a class="code" href="namespaceNL3D.html#a199">TIteratorVectStep1616</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().begin(), 0, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a>), +01556 TIndexIterator(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n7">_IndexInPrecompBasis</a>.begin(), 0, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a>), +01557 *<font class="keyword">this</font>, +01558 numToProcess, +01559 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b4">step</a>, +01560 opaque, +01561 ellapsedTime +01562 ); +01563 } +01564 } +01565 +01566 +01567 } +01568 +01569 <font class="comment">//====================================================================================</font> +01570 <font class="comment">// Private func used to force modulation on a material and to store the preious state</font> +01571 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a433">ForceMaterialModulation</a>(CMaterial &destMat, CMaterial &srcMat, uint8 modulatedStages) +01572 { +01573 <font class="keywordflow">for</font> (uint k = 0; k < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>; ++k) +01574 { +01575 <font class="keywordflow">if</font> (modulatedStages & (1 << k)) +01576 { +01577 destMat.texEnvArg0RGB(k, CMaterial::Previous, CMaterial::SrcColor); +01578 destMat.texEnvArg0Alpha(k, CMaterial::Previous, CMaterial::SrcAlpha); +01579 destMat.texEnvArg1RGB(k, CMaterial::Constant, CMaterial::SrcColor); +01580 destMat.texEnvArg1Alpha(k, CMaterial::Constant, CMaterial::SrcAlpha); +01581 destMat.texEnvOpRGB(k, CMaterial::Modulate); +01582 destMat.texEnvOpAlpha(k, CMaterial::Modulate); +01583 } +01584 <font class="keywordflow">else</font> <font class="comment">// restore from source material</font> +01585 { +01586 destMat.setTexEnvMode(k, srcMat.getTexEnvMode(k)); +01587 } +01588 } +01589 } +01590 +01591 +01592 <font class="comment">//====================================================================================</font> +01593 <font class="keywordtype">void</font> CPSConstraintMesh::setupRenderPasses(<font class="keywordtype">float</font> date, TRdrPassSet &rdrPasses, <font class="keywordtype">bool</font> opaque) +01594 { +01595 <font class="comment">// render meshs : we process each rendering pass</font> +01596 <font class="keywordflow">for</font> (TRdrPassSet::iterator rdrPassIt = rdrPasses.begin() +01597 ; rdrPassIt != rdrPasses.end(); ++rdrPassIt) +01598 { +01599 +01600 CMaterial &Mat = rdrPassIt->Mat; +01601 CMaterial &SourceMat = rdrPassIt->SourceMat; +01602 +01603 +01605 <font class="keywordflow">if</font> ((opaque && Mat.getZWrite()) || (!opaque && ! Mat.getZWrite())) +01606 { +01607 +01608 +01609 <font class="comment">// has to setup material constant color ?</font> +01610 <font class="comment">// global color not supported for mesh</font> +01611 <font class="comment">/* CParticleSystem &ps = *(_Owner->getOwner());</font> +01612 <font class="comment"> if (!_ColorScheme) </font> +01613 <font class="comment"> { </font> +01614 <font class="comment"> NLMISC::CRGBA col;</font> +01615 <font class="comment"> col.modulateFromColor(SourceMat.getColor(), _Color);</font> +01616 <font class="comment"> if (ps.getColorAttenuationScheme() == NULL)</font> +01617 <font class="comment"> {</font> +01618 <font class="comment"> col.modulateFromColor(col, ps.getGlobalColor());</font> +01619 <font class="comment"> }</font> +01620 <font class="comment"> Mat.setColor(col); </font> +01621 <font class="comment"> }</font> +01622 <font class="comment"> else</font> +01623 <font class="comment"> { </font> +01624 <font class="comment"> Mat.setColor(ps.getGlobalColor());</font> +01625 <font class="comment"> }*/</font> +01626 +01628 <a class="code" href="namespaceNL3D.html#a433">ForceMaterialModulation</a>(Mat, SourceMat, <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n8">_ModulatedStages</a>); +01629 +01631 <font class="keywordtype">bool</font> forceVertexcolorLighting = <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n12">_VertexColorLightingForced</a> != 0 ? <font class="keyword">true</font> : SourceMat.getLightedVertexColor(); +01632 <font class="keywordflow">if</font> (forceVertexcolorLighting != Mat.getLightedVertexColor()) <font class="comment">// avoid to touch mat if not needed</font> +01633 { +01634 Mat.setLightedVertexColor(forceVertexcolorLighting); +01635 } +01636 +01638 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n13">_GlobalAnimationEnabled</a> != 0) +01639 { +01640 <font class="keywordflow">for</font> (uint k = 0; k < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>; ++k) +01641 { +01642 <font class="keywordflow">if</font> (Mat.getTexture(k) != NULL) +01643 { +01644 Mat.enableUserTexMat(k, <font class="keyword">true</font>); +01645 CMatrix mat; +01646 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n15">_GlobalTexAnims</a>->Anims[k].buildMatrix(date, mat); +01647 Mat.setUserTexMat(k ,mat); +01648 } +01649 } +01650 } +01651 } +01652 } +01653 +01654 } +01655 +01656 <font class="comment">//====================================================================================</font> +<a name="l01657"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b14">01657</a> <font class="keywordtype">void</font> CPSConstraintMesh::doRenderPasses(IDriver *driver, uint numObj, TRdrPassSet &rdrPasses, <font class="keywordtype">bool</font> opaque) +01658 { +01659 <font class="comment">// render meshs : we process each rendering pass</font> +01660 <font class="keywordflow">for</font> (TRdrPassSet::iterator rdrPassIt = rdrPasses.begin() +01661 ; rdrPassIt != rdrPasses.end(); ++rdrPassIt) +01662 { +01663 CMaterial &Mat = rdrPassIt->Mat; +01664 <font class="keywordflow">if</font> ((opaque && Mat.getZWrite()) || (!opaque && ! Mat.getZWrite())) +01665 { +01667 rdrPassIt->Pb.setNumTri(rdrPassIt->Pb.capacityTri() * numObj / <a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>); +01668 rdrPassIt->Pb.setNumQuad(rdrPassIt->Pb.capacityQuad() * numObj / <a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>); +01669 rdrPassIt->Pb.setNumLine(rdrPassIt->Pb.capacityLine() * numObj / <a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>); +01670 +01672 driver->render(rdrPassIt->Pb, rdrPassIt->Mat); +01673 } +01674 } +01675 +01676 } +01677 +01678 +01679 <font class="comment">//====================================================================================</font> +<a name="l01680"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b8">01680</a> <font class="keywordtype">void</font> CPSConstraintMesh::computeColors(CVertexBuffer &outVB, <font class="keyword">const</font> CVertexBuffer &inVB, uint startIndex, uint toProcess, uint32 srcStep) +01681 { +01682 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a>); +01683 <font class="comment">// there are 2 case : 1 - the source mesh has colors, which are modulated with the current color</font> +01684 <font class="comment">// 2 - the source mesh has no colors : colors are directly copied into the dest vb</font> +01685 +01686 <font class="keywordflow">if</font> (inVB.getVertexFormat() & CVertexBuffer::PrimaryColorFlag) <font class="comment">// case 1</font> +01687 { +01688 <font class="comment">// TODO: optimisation : avoid to duplicate colors...</font> +01689 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a>->makeN(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, startIndex, outVB.getColorPointer(), outVB.getVertexSize(), toProcess, inVB.getNumVertices(), srcStep); +01690 <font class="comment">// modulate from the source mesh</font> +01691 uint8 *vDest = (uint8 *) outVB.getColorPointer(); +01692 uint8 *vSrc = (uint8 *) inVB.getColorPointer(); +01693 <font class="keyword">const</font> uint vSize = outVB.getVertexSize(); +01694 <font class="keyword">const</font> uint numVerts = inVB.getNumVertices(); +01695 uint meshSize = vSize * numVerts; +01696 <font class="keywordflow">for</font> (uint k = 0; k < toProcess; ++k) +01697 { +01698 <a class="code" href="classNLMISC_1_1CRGBA.html#z322_1">NLMISC::CRGBA::modulateColors</a>((CRGBA *) vDest, (CRGBA *) vSrc, (CRGBA *) vDest, numVerts, vSize, vSize); +01699 vDest += meshSize; +01700 } +01701 } +01702 <font class="keywordflow">else</font> <font class="comment">// case 2</font> +01703 { +01704 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a>->makeN(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, startIndex, outVB.getColorPointer(), outVB.getVertexSize(), toProcess, inVB.getNumVertices(), srcStep); +01705 } +01706 } +01707 +01708 +01709 <font class="comment">//====================================================================================</font> +<a name="l01710"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b2">01710</a> <font class="keywordtype">void</font> CPSConstraintMesh::newElement(CPSLocated *emitterLocated, uint32 emitterIndex) +01711 { +01712 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b1">newSizeElement</a>(emitterLocated, emitterIndex); +01713 <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#b1">newPlaneBasisElement</a>(emitterLocated, emitterIndex); +01714 <font class="comment">// TODO : avoid code cuplication with CPSFace ...</font> +01715 <font class="keyword">const</font> uint32 nbConf = <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>.size(); +01716 <font class="keywordflow">if</font> (nbConf) <font class="comment">// do we use precomputed basis ?</font> +01717 { +01718 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n7">_IndexInPrecompBasis</a>[<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getNewElementIndex()] = rand() % nbConf; +01719 } +01720 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b2">newColorElement</a>(emitterLocated, emitterIndex); +01721 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n13">_GlobalAnimationEnabled</a> && <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n14">_ReinitGlobalAnimTimeOnNewElement</a>) +01722 { +01723 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n16">_GlobalAnimDate</a> = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()->getSystemDate(); +01724 } +01725 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a> && <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>->hasMemory()) <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>->newElement(emitterLocated, emitterIndex); +01726 } +01727 +01728 <font class="comment">//==================================================================================== </font> +<a name="l01729"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b3">01729</a> <font class="keywordtype">void</font> CPSConstraintMesh::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) +01730 { +01731 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b2">deleteSizeElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +01732 <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#b2">deletePlaneBasisElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +01733 <font class="comment">// TODO : avoid code cuplication with CPSFace ...</font> +01734 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>.size()) <font class="comment">// do we use precomputed basis ?</font> +01735 { +01736 <font class="comment">// replace ourself by the last element...</font> +01737 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n7">_IndexInPrecompBasis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n7">_IndexInPrecompBasis</a>[<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize() - 1]; +01738 } +01739 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b3">deleteColorElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +01740 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a> && <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>->hasMemory()) <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>->deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +01741 } +01742 +01743 <font class="comment">//====================================================================================</font> +<a name="l01744"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b9">01744</a> <font class="keywordtype">void</font> CPSConstraintMesh::resize(uint32 size) +01745 { +01746 <a class="code" href="debug_8h.html#a6">nlassert</a>(size < (1 << 16)); +01747 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b3">resizeSize</a>(size); +01748 <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#b3">resizePlaneBasis</a>(size); +01749 <font class="comment">// TODO : avoid code cuplication with CPSFace ...</font> +01750 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n6">_PrecompBasis</a>.size()) <font class="comment">// do we use precomputed basis ?</font> +01751 { +01752 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n7">_IndexInPrecompBasis</a>.resize(size); +01753 } +01754 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b4">resizeColor</a>(size); +01755 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a> && <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>->hasMemory()) <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z723_1">_MorphScheme</a>->resize(size, <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize()); +01756 } +01757 +01758 <font class="comment">//====================================================================================</font> +<a name="l01759"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b1">01759</a> <font class="keywordtype">void</font> CPSConstraintMesh::updateMatAndVbForColor(<font class="keywordtype">void</font>) +01760 { +01761 <font class="comment">// nothing to do for us...</font> +01762 } +01763 +01764 <font class="comment">//====================================================================================</font> +<a name="l01765"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a22">01765</a> <font class="keywordtype">void</font> CPSConstraintMesh::forceStageModulationByColor(uint stage, <font class="keywordtype">bool</font> force) +01766 { +01767 <a class="code" href="debug_8h.html#a6">nlassert</a>(stage < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>); +01768 <font class="keywordflow">if</font> (force) +01769 { +01770 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n8">_ModulatedStages</a> |= 1 << stage; +01771 } +01772 <font class="keywordflow">else</font> +01773 { +01774 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n8">_ModulatedStages</a> &= ~(1 << stage); +01775 } +01776 } +01777 +01778 <font class="comment">//====================================================================================</font> +<a name="l01779"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#a23">01779</a> <font class="keywordtype">bool</font> CPSConstraintMesh::isStageModulationForced(uint stage)<font class="keyword"> const</font> +01780 <font class="keyword"></font>{ +01781 <a class="code" href="debug_8h.html#a6">nlassert</a>(stage < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>); +01782 <font class="keywordflow">return</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n8">_ModulatedStages</a> & (1 << stage)) != 0; +01783 } +01784 +01785 <font class="comment">//====================================================================================</font> +01786 +01792 <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a434">DuplicatePrimitiveBlock</a>(<font class="keyword">const</font> CPrimitiveBlock &srcBlock, CPrimitiveBlock &destBlock, uint nbReplicate, uint vertOffset) +01793 { +01794 PARTICLES_CHECK_MEM; +01795 +01796 <font class="comment">// this must be update each time a new primitive is added</font> +01797 +01798 <font class="comment">// loop counters, and index of the current primitive in the dest pb</font> +01799 uint k, <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>; +01800 +01801 <font class="comment">// the current vertex offset.</font> +01802 uint currVertOffset; +01803 +01804 +01805 <font class="comment">// duplicate triangles</font> +01806 uint numTri = srcBlock.getNumTri(); +01807 destBlock.reserveTri(numTri * nbReplicate); +01808 +01809 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = 0; +01810 currVertOffset = 0; +01811 +01812 <font class="keyword">const</font> uint32 *triPtr = srcBlock.getTriPointer(); +01813 <font class="keyword">const</font> uint32 *currTriPtr; <font class="comment">// current Tri</font> +01814 <font class="keywordflow">for</font> (k = 0; k < nbReplicate; ++k) +01815 { +01816 currTriPtr = triPtr; +01817 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> < numTri; ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>) +01818 { +01819 destBlock.setTri(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, currTriPtr[0] + currVertOffset, currTriPtr[1] + currVertOffset, currTriPtr[2] + currVertOffset); +01820 currTriPtr += 3; +01821 ++ <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>; +01822 } +01823 currVertOffset += vertOffset; +01824 } +01825 +01826 +01827 <font class="comment">// duplicate quads</font> +01828 uint numQuad = srcBlock.getNumQuad(); +01829 destBlock.reserveQuad(numQuad * nbReplicate); +01830 +01831 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = 0; +01832 currVertOffset = 0; +01833 +01834 <font class="keyword">const</font> uint32 *QuadPtr = srcBlock.getQuadPointer(); +01835 <font class="keyword">const</font> uint32 *currQuadPtr; <font class="comment">// current Quad</font> +01836 <font class="keywordflow">for</font> (k = 0; k < nbReplicate; ++k) +01837 { +01838 currQuadPtr = QuadPtr; +01839 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> < numQuad; ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>) +01840 { +01841 destBlock.setQuad(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, currQuadPtr[0] + currVertOffset, currQuadPtr[1] + currVertOffset, currQuadPtr[2] + currVertOffset, currQuadPtr[3] + currVertOffset); +01842 currQuadPtr += 4; +01843 ++ <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>; +01844 } +01845 currVertOffset += vertOffset; +01846 } +01847 +01848 <font class="comment">// duplicate lines</font> +01849 uint numLine = srcBlock.getNumLine(); +01850 destBlock.reserveLine(numLine * nbReplicate); +01851 +01852 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = 0; +01853 currVertOffset = 0; +01854 +01855 <font class="keyword">const</font> uint32 *LinePtr = srcBlock.getLinePointer(); +01856 <font class="keyword">const</font> uint32 *currLinePtr; <font class="comment">// current Line</font> +01857 <font class="keywordflow">for</font> (k = 0; k < nbReplicate; ++k) +01858 { +01859 currLinePtr = LinePtr; +01860 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> < numLine; ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>) +01861 { +01862 destBlock.setLine(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, currLinePtr[0] + currVertOffset, currLinePtr[1] + currVertOffset); +01863 currLinePtr += 4; +01864 ++ <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>; +01865 } +01866 currVertOffset += vertOffset; +01867 } +01868 +01869 +01870 <font class="comment">// TODO quad / strips duplication : (unimplemented in primitive blocks for now)</font> +01871 +01872 PARTICLES_CHECK_MEM; +01873 } +01874 +01875 <font class="comment">//====================================================================================</font> +<a name="l01876"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#d0">01876</a> <font class="keywordtype">void</font> CPSConstraintMesh::initPrerotVB() +01877 { +01878 <font class="comment">// position, no normals</font> +01879 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#q1">_PreRotatedMeshVB</a>.setVertexFormat(CVertexBuffer::PositionFlag); +01880 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#q1">_PreRotatedMeshVB</a>.setNumVertices(<a class="code" href="namespaceNL3D.html#a213">ConstraintMeshMaxNumPrerotatedModels</a> * <a class="code" href="namespaceNL3D.html#a211">ConstraintMeshMaxNumVerts</a>); +01881 +01882 <font class="comment">// position & normals</font> +01883 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#q2">_PreRotatedMeshVBWithNormal</a>.setVertexFormat(CVertexBuffer::PositionFlag | CVertexBuffer::NormalFlag); +01884 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#q2">_PreRotatedMeshVBWithNormal</a>.setNumVertices(<a class="code" href="namespaceNL3D.html#a213">ConstraintMeshMaxNumPrerotatedModels</a> * <a class="code" href="namespaceNL3D.html#a211">ConstraintMeshMaxNumVerts</a>); +01885 } +01886 +01887 <font class="comment">//====================================================================================</font> +<a name="l01888"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#a2">01888</a> CPSConstraintMesh::CMeshDisplay &CPSConstraintMesh::CMeshDisplayShare::getMeshDisplay(IShape *shape, uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>) +01889 { +01890 CKey key; +01891 key.Shape = shape; +01892 key.Format = <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>; +01893 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n2">MDMap</a>.count(key)) <font class="comment">// already exists ?</font> +01894 { +01895 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n2">MDMap</a>[key]); +01896 <font class="keywordflow">return</font> *<a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n2">MDMap</a>[key]; +01897 } +01898 <font class="keywordflow">else</font> +01899 { +01900 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n1">MDQueue</a>.size() == <a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n0">_MaxNumMD</a>) <font class="comment">// is there room left?</font> +01901 { +01902 <font class="comment">// no, destroy the least recent entry</font> +01903 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n2">MDMap</a>.count(<a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n1">MDQueue</a>.front())); <font class="comment">// make sure it is also in the map</font> +01904 <a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n2">MDMap</a>.erase(<a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n1">MDQueue</a>.front()); +01905 <a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n1">MDQueue</a>.pop(); +01906 } +01907 std::auto_ptr<CMeshDisplay> MD(<font class="keyword">new</font> CMeshDisplay); +01908 +01909 <font class="comment">// setup rdr passes & primitive blocks</font> +01910 <a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#e0">buildRdrPassSet</a>(MD->RdrPasses, shape); +01911 +01912 <font class="comment">// setup vb</font> +01913 <a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#e1">buildVB</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>, MD->VB, shape); +01914 +01915 <a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n1">MDQueue</a>.push(key); +01916 <a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n2">MDMap</a>[key] = MD.get(); +01917 <font class="keywordflow">return</font> *(MD.release()); +01918 } +01919 } +01920 +01921 +01922 <font class="comment">//====================================================================================</font> +<a name="l01923"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#a1">01923</a> CPSConstraintMesh::CMeshDisplayShare::~CMeshDisplayShare() +01924 { +01925 <font class="keywordflow">for</font> (TMDMap::iterator it = <a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n2">MDMap</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#n2">MDMap</a>.end(); ++it) +01926 { +01927 <font class="keyword">delete</font> it->second; +01928 } +01929 } +01930 +01931 <font class="comment">//====================================================================================</font> +<a name="l01932"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#e0">01932</a> <font class="keywordtype">void</font> CPSConstraintMesh::CMeshDisplayShare::buildRdrPassSet(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#t0">TRdrPassSet</a> &dest, <font class="keyword">const</font> IShape *shape) +01933 { +01934 <font class="keyword">const</font> CMesh &m = *NLMISC::safe_cast<const CMesh *>(shape); +01935 <font class="comment">// we don't support skinning for mesh particles, so there must be only one matrix block </font> +01936 <a class="code" href="debug_8h.html#a6">nlassert</a>(m.getNbMatrixBlock() == 1); <font class="comment">// SKINNING UNSUPPORTED</font> +01937 +01938 dest.resize(m.getNbRdrPass(0)); +01939 <font class="keyword">const</font> CVertexBuffer &srcVb = m.getVertexBuffer(); +01940 +01941 <font class="keywordflow">for</font> (uint k = 0; k < m.getNbRdrPass(0); ++k) +01942 { +01943 dest[k].Mat = m.getMaterial(m.getRdrPassMaterial(0, k)); +01944 dest[k].SourceMat = dest[k].Mat; +01945 <a class="code" href="namespaceNL3D.html#a434">DuplicatePrimitiveBlock</a>(m.getRdrPassPrimitiveBlock(0, k), dest[k].Pb, <a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>, srcVb.getNumVertices() ); +01946 } +01947 } +01948 +01949 <font class="comment">//====================================================================================</font> +<a name="l01950"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#e1">01950</a> <font class="keywordtype">void</font> CPSConstraintMesh::CMeshDisplayShare::buildVB(uint32 destFormat, CVertexBuffer &dest, <font class="keyword">const</font> IShape *shape) +01951 { +01953 <a class="code" href="debug_8h.html#a6">nlassert</a>(shape); +01954 <font class="keyword">const</font> CMesh &m = *NLMISC::safe_cast<const CMesh *>(shape); +01955 <font class="keyword">const</font> CVertexBuffer &meshVb = m.getVertexBuffer(); +01956 <a class="code" href="debug_8h.html#a6">nlassert</a>(destFormat == meshVb.getVertexFormat() || destFormat == (meshVb.getVertexFormat() | (uint32) CVertexBuffer::PrimaryColorFlag) ); +01957 dest.setVertexFormat(destFormat); +01958 dest.setNumVertices(<a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a> * meshVb.getNumVertices()); +01959 +01960 uint8 *outPtr = (uint8 *) dest.getVertexCoordPointer(); +01961 uint8 *inPtr = (uint8 *) meshVb.getVertexCoordPointer(); +01962 uint meshSize = dest.getVertexSize() * meshVb.getNumVertices(); +01963 +01964 <font class="keywordflow">if</font> (destFormat == meshVb.getVertexFormat()) <font class="comment">// no color added</font> +01965 { +01966 <font class="keywordflow">for</font> (uint k = 0; k < <a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>; ++k) +01967 { +01968 ::memcpy((<font class="keywordtype">void</font> *) (outPtr + k * meshSize), (<font class="keywordtype">void</font> *) inPtr, meshSize); +01969 } +01970 } +01971 <font class="keywordflow">else</font> <font class="comment">// color added, but not available in src </font> +01972 { +01973 sint colorOff = dest.getColorOff(); +01974 uint inVSize = meshVb.getVertexSize(); +01975 uint outVSize = dest.getVertexSize(); +01976 <font class="keywordflow">for</font> (uint k = 0; k < <a class="code" href="namespaceNL3D.html#a212">ConstraintMeshBufSize</a>; ++k) +01977 { +01978 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = 0; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> < meshVb.getNumVertices(); ++<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>) +01979 { +01980 <font class="comment">// copy until color</font> +01981 ::memcpy((<font class="keywordtype">void</font> *) (outPtr + k * meshSize + <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> * outVSize), (<font class="keywordtype">void</font> *) (inPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> * inVSize), colorOff); +01982 <font class="comment">// copy datas after color</font> +01983 ::memcpy((<font class="keywordtype">void</font> *) (outPtr + k * meshSize + <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> * outVSize + colorOff + <font class="keyword">sizeof</font>(uint8[4])), (<font class="keywordtype">void</font> *) (inPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> * inVSize + colorOff), inVSize - colorOff); +01984 } +01985 } +01986 } +01987 } +01988 +01989 <font class="comment">//=====================================================================================</font> +<a name="l01990"></a><a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare_1_1CKey.html#a0">01990</a> CPSConstraintMesh::CMeshDisplayShare::CKey::~CKey() +01991 { +01992 } +01993 +01994 <font class="comment">//===================================================================================== </font> +<a name="l01995"></a><a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CGlobalTexAnim.html#a0">01995</a> CPSConstraintMesh::CGlobalTexAnim::CGlobalTexAnim() : TransSpeed(NLMISC::CVector2f::Null), +01996 TransAccel(NLMISC::CVector2f::Null), +01997 ScaleStart(1 ,1), +01998 ScaleSpeed(NLMISC::CVector2f::Null), +01999 ScaleAccel(NLMISC::CVector2f::Null), +02000 WRotSpeed(0), +02001 WRotAccel(0) +02002 { +02003 } +02004 +02005 <font class="comment">//=====================================================================================</font> +<a name="l02006"></a><a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CGlobalTexAnim.html#a1">02006</a> <font class="keywordtype">void</font> CPSConstraintMesh::CGlobalTexAnim::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream) +02007 { +02008 f.serialVersion(0); +02009 f.serial(TransSpeed, TransAccel, ScaleStart, ScaleSpeed, ScaleAccel); +02010 f.serial(WRotSpeed, WRotAccel); +02011 } +02012 +02013 <font class="comment">//=====================================================================================</font> +02014 <font class="keywordtype">void</font> CPSConstraintMesh::CGlobalTexAnim::buildMatrix(<font class="keywordtype">float</font> &date, <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &dest) +02015 { +02016 <font class="keywordtype">float</font> fDate = (float) date; +02017 <font class="keywordtype">float</font> halfDateSquared = 0.5f * fDate * fDate; +02018 <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> pos = fDate * <a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CGlobalTexAnim.html#m0">TransSpeed</a> + halfDateSquared * fDate * <a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CGlobalTexAnim.html#m1">TransAccel</a>; +02019 <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> scale = <a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CGlobalTexAnim.html#m2">ScaleStart</a> + fDate * <a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CGlobalTexAnim.html#m3">ScaleSpeed</a> + halfDateSquared * fDate * <a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CGlobalTexAnim.html#m4">ScaleAccel</a>; +02020 <font class="keywordtype">float</font> rot = fDate * <a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CGlobalTexAnim.html#m5">WRotSpeed</a> + halfDateSquared * <a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CGlobalTexAnim.html#m6">WRotAccel</a>; +02021 +02022 +02023 <font class="keywordtype">float</font> fCos, fSin; +02024 <font class="keywordflow">if</font> (rot != 0.f) +02025 { +02026 fCos = ::cosf(- rot); +02027 fSin = ::sinf(- rot); +02028 } +02029 <font class="keywordflow">else</font> +02030 { +02031 fCos = 1.f; +02032 fSin = 0.f; +02033 } +02034 +02035 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> I(fCos, fSin, 0); +02036 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> J(-fSin, fCos, 0); +02037 dest.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_1">setRot</a>(scale.<a class="code" href="classNLMISC_1_1CVector2f.html#m0">x</a> * I, scale.<a class="code" href="classNLMISC_1_1CVector2f.html#m1">y</a> * J, <a class="code" href="classNLMISC_1_1CVector.html#p3">NLMISC::CVector::K</a>); +02038 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> center(-0.5f, -0.5f, 0.f); +02039 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>(pos.<a class="code" href="classNLMISC_1_1CVector2f.html#m0">x</a>, pos.<a class="code" href="classNLMISC_1_1CVector2f.html#m1">y</a>, 0); +02040 dest.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_6">setPos</a>(t + dest.<a class="code" href="classNLMISC_1_1CMatrix.html#z294_0">mulVector</a>(center) - center); +02041 } +02042 +02043 <font class="comment">//=====================================================================================</font> +<a name="l02044"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z722_0">02044</a> <font class="keywordtype">void</font> CPSConstraintMesh::setGlobalTexAnim(uint stage, <font class="keyword">const</font> CGlobalTexAnim &properties) +02045 { +02046 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n13">_GlobalAnimationEnabled</a> != 0); +02047 <a class="code" href="debug_8h.html#a6">nlassert</a>(stage < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>); +02048 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n15">_GlobalTexAnims</a>.get()); +02049 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n15">_GlobalTexAnims</a>->Anims[stage] = properties; +02050 } +02051 +02052 <font class="comment">//=====================================================================================</font> +<a name="l02053"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z722_1">02053</a> <font class="keyword">const</font> CPSConstraintMesh::CGlobalTexAnim &CPSConstraintMesh::getGlobalTexAnim(uint stage)<font class="keyword"> const</font> +02054 <font class="keyword"></font>{ +02055 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n13">_GlobalAnimationEnabled</a> != 0); +02056 <a class="code" href="debug_8h.html#a6">nlassert</a>(stage < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>); +02057 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n15">_GlobalTexAnims</a>.get()); +02058 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n15">_GlobalTexAnims</a>->Anims[stage]; +02059 } +02060 +02061 +02062 <font class="comment">//=====================================================================================</font> +<a name="l02063"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z721_2">02063</a> CPSConstraintMesh::TTexAnimType CPSConstraintMesh::getTexAnimType()<font class="keyword"> const</font> +02064 <font class="keyword"></font>{ +02065 <font class="keywordflow">return</font> (TTexAnimType) (<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n13">_GlobalAnimationEnabled</a> != 0 ? <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z721_0s1">GlobalAnim</a> : <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z721_0s0">NoAnim</a>); +02066 } +02067 +02068 <font class="comment">//=====================================================================================</font> +<a name="l02069"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z721_1">02069</a> <font class="keywordtype">void</font> CPSConstraintMesh::setTexAnimType(TTexAnimType <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>) +02070 { +02071 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> < <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z721_0s2">Last</a>); +02072 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z721_2">getTexAnimType</a>()) <font class="keywordflow">return</font>; <font class="comment">// does the type of animation change ?</font> +02073 <font class="keywordflow">switch</font> (type) +02074 { +02075 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z721_0s0">NoAnim</a>: +02076 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n15">_GlobalTexAnims</a>.reset(); +02077 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b12">restoreMaterials</a>(); +02078 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n13">_GlobalAnimationEnabled</a> = 0; +02079 <font class="keywordflow">break</font>; +02080 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#z721_0s1">GlobalAnim</a>: +02081 { +02082 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#t4">PGlobalTexAnims</a> newPtr(<font class="keyword">new</font> CGlobalTexAnims); +02083 std::swap(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n15">_GlobalTexAnims</a>, newPtr); +02084 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n13">_GlobalAnimationEnabled</a> = 1; +02085 } +02086 <font class="keywordflow">break</font>; +02087 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>; +02088 } +02089 } +02090 +02091 <font class="comment">//=====================================================================================</font> +<a name="l02092"></a><a class="code" href="structNL3D_1_1CPSConstraintMesh_1_1CGlobalTexAnims.html#a0">02092</a> <font class="keywordtype">void</font> CPSConstraintMesh::CGlobalTexAnims::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream) +02093 { +02094 f.serialVersion(0); +02095 <font class="keywordflow">for</font> (uint k = 0; k < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>; ++k) +02096 { +02097 f.serial(Anims[k]); +02098 } +02099 } +02100 +02101 <font class="comment">//=====================================================================================</font> +<a name="l02102"></a><a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b12">02102</a> <font class="keywordtype">void</font> CPSConstraintMesh::restoreMaterials() +02103 { +02104 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#b10">update</a>(); +02105 CMesh &mesh = * NLMISC::safe_cast<CMesh *>((IShape *) <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>[0]); +02106 <font class="keyword">const</font> CVertexBuffer &modelVb = mesh.getVertexBuffer(); +02107 CMeshDisplay &md= <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#q0">_MeshDisplayShare</a>.<a class="code" href="classNL3D_1_1CPSConstraintMesh_1_1CMeshDisplayShare.html#a2">getMeshDisplay</a>(<a class="code" href="classNL3D_1_1CPSConstraintMesh.html#n1">_Shapes</a>[0], modelVb.getVertexFormat() +02108 | (<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> ? CVertexBuffer::PrimaryColorFlag : 0)); +02109 +02110 <a class="code" href="classNL3D_1_1CPSConstraintMesh.html#t0">TRdrPassSet</a> rdrPasses = md.RdrPasses; +02111 <font class="comment">// render meshs : we process each rendering pass</font> +02112 <font class="keywordflow">for</font> (TRdrPassSet::iterator rdrPassIt = rdrPasses.begin() +02113 ; rdrPassIt != rdrPasses.end(); ++rdrPassIt) +02114 { +02115 rdrPassIt->Mat = rdrPassIt->SourceMat; +02116 } +02117 } +02118 +02119 } <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> |