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/mesh__base__instance_8cpp-source.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to 'docs/doxygen/nel/mesh__base__instance_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/mesh__base__instance_8cpp-source.html | 586 |
1 files changed, 586 insertions, 0 deletions
diff --git a/docs/doxygen/nel/mesh__base__instance_8cpp-source.html b/docs/doxygen/nel/mesh__base__instance_8cpp-source.html new file mode 100644 index 00000000..d0890cdc --- /dev/null +++ b/docs/doxygen/nel/mesh__base__instance_8cpp-source.html @@ -0,0 +1,586 @@ +<!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>mesh_base_instance.cpp</h1><a href="mesh__base__instance_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font> +00027 +00028 <font class="preprocessor">#include "<a class="code" href="mesh__base__instance_8h.html">3d/mesh_base_instance.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="mesh__base_8h.html">3d/mesh_base.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="scene_8h.html">3d/scene.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="animation_8h.html">3d/animation.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font> +00033 <font class="preprocessor">#include "<a class="code" href="anim__detail__trav_8h.html">3d/anim_detail_trav.h</a>"</font> +00034 <font class="preprocessor">#include "<a class="code" href="texture__file_8h.html">3d/texture_file.h</a>"</font> +00035 <font class="preprocessor">#include "<a class="code" href="async__texture__manager_8h.html">3d/async_texture_manager.h</a>"</font> +00036 +00037 +00038 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC; +00039 +00040 <font class="keyword">namespace </font>NL3D +00041 { +00042 +00043 +00044 <font class="comment">// ***************************************************************************</font> +<a name="l00045"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#b0">00045</a> CMeshBaseInstance::CMeshBaseInstance() +00046 { +00047 IAnimatable::resize(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z577_0s1">AnimValueLast</a>); +00048 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o3">_OwnerScene</a>= NULL; +00049 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_1">_AsyncTextureToLoadRefCount</a>= 0; +00050 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_3">_AsyncTextureMode</a>= <font class="keyword">false</font>; +00051 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_4">_AsyncTextureReady</a>= <font class="keyword">true</font>; +00052 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_2">_AsyncTextureDirty</a>= <font class="keyword">false</font>; +00053 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_6">_AsyncTextureDistance</a>= 0; +00054 +00055 <font class="comment">// I am a CMeshBaseInstance!!</font> +00056 CTransform::setIsMeshBaseInstance(<font class="keyword">true</font>); +00057 } +00058 +00059 <font class="comment">// ***************************************************************************</font> +<a name="l00060"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#b1">00060</a> CMeshBaseInstance::~CMeshBaseInstance() +00061 { +00062 <font class="comment">// If AsyncTextureMode, must disable. This ensure that async loading stop, and that no ref still exist</font> +00063 <font class="comment">// in the AsyncTextureManager</font> +00064 <font class="keywordflow">if</font>(_AsyncTextureMode) +00065 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z582_0">enableAsyncTextureMode</a>(<font class="keyword">false</font>); +00066 } +00067 +00068 +00069 <font class="comment">// ***************************************************************************</font> +<a name="l00070"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#d0">00070</a> <font class="keywordtype">void</font> CMeshBaseInstance::registerBasic() +00071 { +00072 CMOT::registerModel(<a class="code" href="namespaceNL3D.html#a140">MeshBaseInstanceId</a>, <a class="code" href="namespaceNL3D.html#a277">TransformShapeId</a>, CMeshBaseInstance::creator); +00073 CMOT::registerObs(<a class="code" href="namespaceNL3D.html#a3">AnimDetailTravId</a>, <a class="code" href="namespaceNL3D.html#a140">MeshBaseInstanceId</a>, CMeshBaseInstanceAnimDetailObs::creator); +00074 } +00075 +00076 +00077 <font class="comment">// ***************************************************************************</font> +<a name="l00078"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z577_1">00078</a> <font class="keywordtype">void</font> CMeshBaseInstance::registerToChannelMixer(CChannelMixer *chanMixer, <font class="keyword">const</font> std::string &prefix) +00079 { +00080 uint32 i; +00081 CTransformShape::registerToChannelMixer(chanMixer, prefix); +00082 +00083 <font class="comment">// Add any materials.</font> +00084 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o0">_AnimatedMaterials</a>.size(); i++) +00085 { +00086 <font class="comment">// append material matname.*</font> +00087 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o0">_AnimatedMaterials</a>[i].registerToChannelMixer(chanMixer, prefix + <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o0">_AnimatedMaterials</a>[i].getMaterialName() + <font class="stringliteral">"."</font>); +00088 } +00089 +00090 <font class="comment">// Add any morph</font> +00091 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o2">_AnimatedMorphFactor</a>.size(); i++) +00092 { +00093 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o2">_AnimatedMorphFactor</a>[i].registerToChannelMixer(chanMixer, prefix + <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o2">_AnimatedMorphFactor</a>[i].<a class="code" href="zone__lighter_8cpp.html#a11">getName</a>()); +00094 } +00095 } +00096 +00097 +00098 <font class="comment">// ***************************************************************************</font> +<a name="l00099"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z579_0">00099</a> ITrack* CMeshBaseInstance::getDefaultTrack (uint valueId) +00100 { +00101 <font class="comment">// Pointer on the CMeshBase</font> +00102 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#l0">CMeshBase</a>* pMesh=(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#l0">CMeshBase</a>*)(IShape*)<a class="code" href="classNL3D_1_1CTransformShape.html#m0">Shape</a>; +00103 +00104 <font class="comment">// Switch the value</font> +00105 <font class="keywordflow">switch</font> (valueId) +00106 { +00107 <font class="keywordflow">case</font> CTransform::PosValue: +00108 <font class="keywordflow">return</font> pMesh->getDefaultPos(); +00109 <font class="keywordflow">case</font> CTransform::RotEulerValue: +00110 <font class="keywordflow">return</font> pMesh->getDefaultRotEuler(); +00111 <font class="keywordflow">case</font> CTransform::RotQuatValue: +00112 <font class="keywordflow">return</font> pMesh->getDefaultRotQuat(); +00113 <font class="keywordflow">case</font> CTransform::ScaleValue: +00114 <font class="keywordflow">return</font> pMesh->getDefaultScale(); +00115 <font class="keywordflow">case</font> CTransform::PivotValue: +00116 <font class="keywordflow">return</font> pMesh->getDefaultPivot(); +00117 <font class="keywordflow">default</font>: +00118 <font class="comment">// Problem, new values ?</font> +00119 <a class="code" href="debug_8h.html#a12">nlstop</a>; +00120 }; +00121 <font class="keywordflow">return</font> NULL; +00122 } +00123 +00124 +00125 <font class="comment">// ***************************************************************************</font> +<a name="l00126"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z580_0">00126</a> uint32 CMeshBaseInstance::getNbLightMap() +00127 { +00128 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#l0">CMeshBase</a>* pMesh=(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#l0">CMeshBase</a>*)(IShape*)<a class="code" href="classNL3D_1_1CTransformShape.html#m0">Shape</a>; +00129 <font class="keywordflow">return</font> pMesh->_LightInfos.size(); +00130 } +00131 +00132 <font class="comment">// ***************************************************************************</font> +<a name="l00133"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z580_1">00133</a> <font class="keywordtype">void</font> CMeshBaseInstance::getLightMapName( uint32 nLightMapNb, std::string &LightMapName ) +00134 { +00135 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#l0">CMeshBase</a>* pMesh=(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#l0">CMeshBase</a>*)(IShape*)<a class="code" href="classNL3D_1_1CTransformShape.html#m0">Shape</a>; +00136 <font class="keywordflow">if</font>( nLightMapNb >= pMesh->_LightInfos.size() ) +00137 <font class="keywordflow">return</font>; +00138 CMeshBase::TLightInfoMap::iterator itMap = pMesh->_LightInfos.begin(); +00139 <font class="keywordflow">for</font>( uint32 i = 0; i < nLightMapNb; ++i ) ++itMap; +00140 LightMapName = itMap->first; +00141 } +00142 +00143 <font class="comment">// ***************************************************************************</font> +<a name="l00144"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z580_2">00144</a> <font class="keywordtype">void</font> CMeshBaseInstance::setLightMapFactor( <font class="keyword">const</font> std::string &LightMapName, CRGBA Factor ) +00145 { +00146 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#l0">CMeshBase</a>* pMesh=(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#l0">CMeshBase</a>*)(IShape*)<a class="code" href="classNL3D_1_1CTransformShape.html#m0">Shape</a>; +00147 CMeshBase::TLightInfoMap::iterator itMap = pMesh->_LightInfos.find( LightMapName ); +00148 <font class="keywordflow">if</font>( itMap == pMesh->_LightInfos.end() ) +00149 <font class="keywordflow">return</font>; +00150 CMeshBase::CLightInfoMapList::iterator itList = itMap->second.begin(); +00151 uint32 nNbElt = itMap->second.size(); +00152 <font class="keywordflow">for</font>( uint32 i = 0; i < nNbElt; ++i ) +00153 { +00154 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>[itList->nMatNb].setLightMapFactor( itList->nStageNb, Factor ); +00155 ++itList; +00156 } +00157 } +00158 +00159 <font class="comment">// ***************************************************************************</font> +<a name="l00160"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z581_0">00160</a> uint32 CMeshBaseInstance::getNbBlendShape() +00161 { +00162 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o2">_AnimatedMorphFactor</a>.size(); +00163 } +00164 +00165 <font class="comment">// ***************************************************************************</font> +<a name="l00166"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z581_1">00166</a> <font class="keywordtype">void</font> CMeshBaseInstance::getBlendShapeName (uint32 nBlendShapeNb, std::string &BlendShapeName ) +00167 { +00168 <font class="keywordflow">if</font> (nBlendShapeNb >= <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o2">_AnimatedMorphFactor</a>.size()) +00169 <font class="keywordflow">return</font>; +00170 BlendShapeName = <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o2">_AnimatedMorphFactor</a>[nBlendShapeNb].getName(); +00171 } +00172 +00173 <font class="comment">// ***************************************************************************</font> +<a name="l00174"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z581_2">00174</a> <font class="keywordtype">void</font> CMeshBaseInstance::setBlendShapeFactor (<font class="keyword">const</font> std::string &BlendShapeName, <font class="keywordtype">float</font> rFactor) +00175 { +00176 <font class="keywordflow">for</font> (uint32 i = 0; i < <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o2">_AnimatedMorphFactor</a>.size(); ++i) +00177 <font class="keywordflow">if</font> (BlendShapeName == <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o2">_AnimatedMorphFactor</a>[i].getName()) +00178 { +00179 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o2">_AnimatedMorphFactor</a>[i].setFactor (rFactor); +00180 } +00181 } +00182 +00183 +00184 <font class="comment">// ***************************************************************************</font> +<a name="l00185"></a><a class="code" href="classNL3D_1_1CMeshBaseInstanceAnimDetailObs.html#a0">00185</a> <font class="keywordtype">void</font> CMeshBaseInstanceAnimDetailObs::traverse(IObs *caller) +00186 { +00187 +00188 CMeshBaseInstance *mi = (CMeshBaseInstance*)<a class="code" href="classNL3D_1_1IObs.html#m0">Model</a>; +00189 CMeshBase *mb = NLMISC::safe_cast<CMeshBase *>((IShape *) mi->Shape); +00190 +00191 <font class="comment">// if the base instance uses automatic animations, we must also setup the date of the channel mixer controlling this object</font> +00192 <font class="keywordflow">if</font> (mb->getAutoAnim()) +00193 { +00194 <font class="comment">// setup the channel mixer date</font> +00195 CChannelMixer *chanMix = mi->getChannelMixer(); +00196 <font class="keywordflow">if</font> (chanMix) +00197 { +00198 ITravScene *ts = NLMISC::safe_cast<ITravScene *>(Trav); +00199 <a class="code" href="debug_8h.html#a6">nlassert</a>(ts->Scene); +00200 <font class="keyword">const</font> CAnimation *anim = chanMix->getSlotAnimation(0); +00204 <font class="keywordflow">if</font> (anim) +00205 { +00206 <font class="keywordtype">float</font> animLenght = anim->getEndTime() - anim->getBeginTime(); +00207 <font class="keywordflow">if</font> (animLenght > 0) +00208 { +00209 <font class="keywordtype">float</font> currTime = (TAnimationTime) ts->Scene->getCurrentTime(); +00210 <font class="keywordtype">float</font> startTime = (uint) (currTime / animLenght) * animLenght; +00211 <font class="comment">// Set the channel mixer date using the global date of the scene</font> +00212 chanMix->setSlotTime(0, anim->getBeginTime() + currTime - startTime); +00213 } +00214 <font class="keywordflow">else</font> +00215 { +00216 chanMix->setSlotTime(0, anim->getBeginTime()); +00217 } +00218 +00223 chanMix->eval(<font class="keyword">false</font>); +00224 } +00225 } +00226 } +00227 +00228 CTransformAnimDetailObs::traverse(caller); +00229 +00230 +00231 <font class="comment">// update animated materials.</font> +00232 <font class="comment">// test if animated materials must be updated.</font> +00233 <font class="keywordflow">if</font>(mi->IAnimatable::isTouched(CMeshBaseInstance::OwnerBit)) +00234 { +00235 <font class="comment">// must test / update all AnimatedMaterials.</font> +00236 <font class="keywordflow">for</font>(uint i=0;i<mi->_AnimatedMaterials.size();i++) +00237 { +00238 <font class="comment">// This test and update the pointed material.</font> +00239 mi->_AnimatedMaterials[i].update(); +00240 } +00241 +00242 mi->IAnimatable::clearFlag(CMeshBaseInstance::OwnerBit); +00243 } +00244 +00245 <font class="comment">// Lightmap automatic animation</font> +00246 <font class="keywordflow">for</font>( uint i = 0; i < mi->_AnimatedLightmap.size(); ++i ) +00247 { +00248 <font class="keyword">const</font> <font class="keywordtype">char</font> *LightGroupName = strchr( mi->_AnimatedLightmap[i]->getName().c_str(), <font class="charliteral">'.'</font> )+1; +00249 mi->setLightMapFactor( LightGroupName, +00250 mi->_AnimatedLightmap[i]->getFactor() ); +00251 } +00252 } +00253 +00254 +00255 <font class="comment">// ***************************************************************************</font> +<a name="l00256"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#a3">00256</a> <font class="keywordtype">void</font> CMeshBaseInstance::selectTextureSet(uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>) +00257 { +00258 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CTransformShape.html#m0">Shape</a>); +00259 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#l0">CMeshBase</a> *mb = NLMISC::safe_cast<CMeshBase *>((IShape *) <a class="code" href="classNL3D_1_1CTransformShape.html#m0">Shape</a>); +00260 <font class="keyword">const</font> uint numMat = mb->getNbMaterial(); +00261 <a class="code" href="debug_8h.html#a6">nlassert</a>(numMat == <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>.size()); +00262 <font class="comment">// see which material are selectable</font> +00263 <font class="keywordflow">for</font>(uint k = 0; k < numMat; ++k) +00264 { +00265 CMaterial &mat = mb->getMaterial(k); +00266 <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> < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>; ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>) +00267 { +00268 <font class="keywordflow">if</font> (mat.getTexture(<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>) && mat.getTexture(l)->isSelectable()) +00269 { +00270 <font class="comment">// use a smartPtr so the textFile will be released if just used to set the name for AsyncTextures.</font> +00271 CSmartPtr<ITexture> texNSV= mat.getTexture(l)->buildNonSelectableVersion(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>); +00272 +00273 <font class="comment">// std case: just replace the texture.</font> +00274 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_3">_AsyncTextureMode</a>) +00275 { +00276 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>[k].setTexture(<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>, texNSV); +00277 } +00278 <font class="comment">// Async case</font> +00279 <font class="keywordflow">else</font> +00280 { +00281 <font class="comment">// If texture file, must copy the texture name</font> +00282 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[k].IsTextureFile[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>]) +00283 { +00284 CTextureFile *textFile= safe_cast<CTextureFile*>((ITexture*)texNSV); +00285 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[k].TextureNames[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>]= textFile->getFileName(); +00286 } +00287 <font class="comment">// else replace the texture.</font> +00288 <font class="keywordflow">else</font> +00289 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>[k].setTexture(<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>, texNSV); +00290 } +00291 } +00292 } +00293 } +00294 +00295 <font class="comment">// Flag the instance as AsyncTextureDirty if in this mode</font> +00296 <font class="keywordflow">if</font>(_AsyncTextureMode) +00297 { +00298 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z582_6">setAsyncTextureDirty</a>(<font class="keyword">true</font>); +00299 } +00300 } +00301 +00302 +00303 <font class="comment">// ***************************************************************************</font> +<a name="l00304"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#a0">00304</a> <font class="keywordtype">void</font> CMeshBaseInstance::setAnimatedLightmap (CAnimatedLightmap *alm) +00305 { +00306 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o1">_AnimatedLightmap</a>.push_back( alm ); +00307 <font class="comment">// Must be traversed in AnimDetail, even if no channel mixer registered</font> +00308 CTransform::setIsForceAnimDetail(<font class="keyword">true</font>); +00309 } +00310 +00311 +00312 <font class="comment">// ***************************************************************************</font> +<a name="l00313"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z578_0">00313</a> uint CMeshBaseInstance::getNumMaterial ()<font class="keyword"> const</font> +00314 <font class="keyword"></font>{ +00315 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>.size (); +00316 } +00317 +00318 +00319 <font class="comment">// ***************************************************************************</font> +<a name="l00320"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z578_1">00320</a> <font class="keyword">const</font> CMaterial *CMeshBaseInstance::getMaterial (uint materialId)<font class="keyword"> const</font> +00321 <font class="keyword"></font>{ +00322 <font class="keywordflow">return</font> &(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>[materialId]); +00323 } +00324 +00325 +00326 <font class="comment">// ***************************************************************************</font> +<a name="l00327"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z578_2">00327</a> CMaterial *CMeshBaseInstance::getMaterial (uint materialId) +00328 { +00329 <font class="keywordflow">return</font> &(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>[materialId]); +00330 } +00331 +00332 +00333 <font class="comment">// ***************************************************************************</font> +00334 <font class="comment">// ***************************************************************************</font> +00335 <font class="comment">// Async texture loading</font> +00336 <font class="comment">// ***************************************************************************</font> +00337 <font class="comment">// ***************************************************************************</font> +00338 +00339 +00340 <font class="comment">// ***************************************************************************</font> +<a name="l00341"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z582_0">00341</a> <font class="keywordtype">void</font> CMeshBaseInstance::enableAsyncTextureMode(<font class="keywordtype">bool</font> enable) +00342 { +00343 <font class="comment">// if same, no-op.</font> +00344 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_3">_AsyncTextureMode</a>==enable) +00345 <font class="keywordflow">return</font>; +00346 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_3">_AsyncTextureMode</a>= enable; +00347 +00348 <font class="comment">// if comes to async texture mode, must prepare AsyncTexturing</font> +00349 <font class="keywordflow">if</font>(_AsyncTextureMode) +00350 { +00351 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_4">_AsyncTextureReady</a>= <font class="keyword">true</font>; +00352 +00353 <font class="comment">// For all TextureFiles in material</font> +00354 <font class="keywordflow">for</font>(uint i=0;i<<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>.size();i++) +00355 { +00356 <font class="keywordflow">for</font>(uint stage=0;stage<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>;stage++) +00357 { +00358 <font class="comment">// test if really a CTextureFile</font> +00359 CTextureFile *text= dynamic_cast<CTextureFile*>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>[i].getTexture(stage)); +00360 <font class="keywordflow">if</font>(text) +00361 { +00362 <font class="comment">// Must setup the AsyncTextures</font> +00363 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[i].IsTextureFile[stage]= <font class="keyword">true</font>; +00364 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[i].TextureNames[stage]= text->getFileName(); +00365 <font class="comment">// Now, must copy the textureFile, to Avoid writing in CMeshBase TextureFile descriptor !!!</font> +00366 CTextureFile *tf = <font class="keyword">new</font> CTextureFile(*text); +00367 <font class="comment">// setup a dummy texture => Instance won't block rendering because texture not yet ready</font> +00368 tf->setFileName(<font class="stringliteral">"blank.tga"</font>); +00369 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>[i].setTexture(stage, tf); +00370 } +00371 <font class="keywordflow">else</font> +00372 { +00373 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[i].IsTextureFile[stage]= <font class="keyword">false</font>; +00374 } +00375 } +00376 } +00377 +00378 <font class="comment">// For convenience, flag the instance as Dirty.</font> +00379 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z582_6">setAsyncTextureDirty</a>(<font class="keyword">true</font>); +00380 } +00381 <font class="comment">// else, AsyncTextureMode disabled</font> +00382 <font class="keywordflow">else</font> +00383 { +00384 <font class="comment">// first, must stop and release all textures in the async manager.</font> +00385 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_0">releaseCurrentAsyncTextures</a>(); +00386 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_1">_AsyncTextureToLoadRefCount</a>==0); +00387 <font class="comment">// clear the array => ensure good work if enableAsyncTextureMode(true) is made later</font> +00388 <a class="code" href="namespaceNLMISC.html#a222">contReset</a>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>); +00389 +00390 <font class="comment">// For all TextureFiles in material, copy User setup from AsyncTextures, to real fileName</font> +00391 <font class="keywordflow">for</font>(uint i=0;i<<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>.size();i++) +00392 { +00393 <font class="keywordflow">for</font>(uint stage=0;stage<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>;stage++) +00394 { +00395 <font class="comment">// if an async texture file</font> +00396 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[i].IsTextureFile[stage]) +00397 { +00398 <font class="comment">// copy the texture name into the texture file.</font> +00399 CTextureFile *text= safe_cast<CTextureFile*>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>[i].getTexture(stage)); +00400 text->setFileName(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[i].TextureNames[stage]); +00401 <font class="comment">// clear string space</font> +00402 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[i].TextureNames[stage].clear(); +00403 } +00404 } +00405 } +00406 } +00407 } +00408 +00409 +00410 <font class="comment">// ***************************************************************************</font> +<a name="l00411"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z582_2">00411</a> <font class="keywordtype">void</font> CMeshBaseInstance::startAsyncTextureLoading() +00412 { +00413 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z582_1">getAsyncTextureMode</a>()) +00414 <font class="keywordflow">return</font>; +00415 +00416 <font class="comment">// If the async texutre manager is not setuped in the scene, abort.</font> +00417 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_7">CAsyncTextureManager</a> *asyncTextMgr= <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o3">_OwnerScene</a>->getAsyncTextureManager(); +00418 <font class="keywordflow">if</font>(!asyncTextMgr) +00419 <font class="keywordflow">return</font>; +00420 +00421 uint i; +00422 +00423 +00424 <font class="comment">/* for all new texture names to load, add them to the manager</font> +00425 <font class="comment"> NB: done first before release because of RefCount Management (in case of same texture name).</font> +00426 <font class="comment"> */</font> +00427 <font class="keywordflow">for</font>(i=0;i<<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>.size();i++) +00428 { +00429 <font class="keywordflow">for</font>(uint stage=0;stage<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>;stage++) +00430 { +00431 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[i].IsTextureFile[stage]) +00432 { +00433 uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>; +00434 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= asyncTextMgr->addTextureRef(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[i].TextureNames[stage], <font class="keyword">this</font>); +00435 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>[i].TextIds[stage]= <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>; +00436 } +00437 } +00438 } +00439 +00440 <font class="comment">/* For all old textures (0 for the first time...), release them.</font> +00441 <font class="comment"> */</font> +00442 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_0">releaseCurrentAsyncTextures</a>(); +00443 +00444 <font class="comment">// OK! bkup the setup</font> +00445 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>= <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m1">AsyncTextures</a>; +00446 +00447 <font class="comment">// texture async is not ready.</font> +00448 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_4">_AsyncTextureReady</a>= <font class="keyword">false</font>; +00449 } +00450 +00451 <font class="comment">// ***************************************************************************</font> +<a name="l00452"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_0">00452</a> <font class="keywordtype">void</font> CMeshBaseInstance::releaseCurrentAsyncTextures() +00453 { +00454 <font class="comment">// If the async texutre manager is not setuped in the scene, abort.</font> +00455 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_7">CAsyncTextureManager</a> *asyncTextMgr= <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#o3">_OwnerScene</a>->getAsyncTextureManager(); +00456 <font class="keywordflow">if</font>(!asyncTextMgr) +00457 <font class="keywordflow">return</font>; +00458 +00459 <font class="comment">// release all texture in the manager</font> +00460 <font class="keywordflow">for</font>(uint i=0;i<<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>.size();i++) +00461 { +00462 <font class="keywordflow">for</font>(uint stage=0;stage<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>;stage++) +00463 { +00464 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>[i].IsTextureFile[stage]) +00465 { +00466 asyncTextMgr->releaseTexture(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>[i].TextIds[stage], <font class="keyword">this</font>); +00467 } +00468 } +00469 } +00470 } +00471 +00472 <font class="comment">// ***************************************************************************</font> +<a name="l00473"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z582_3">00473</a> <font class="keywordtype">bool</font> CMeshBaseInstance::isAsyncTextureReady() +00474 { +00475 <font class="comment">// if ok, just quit</font> +00476 <font class="keywordflow">if</font>(_AsyncTextureReady) +00477 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00478 +00479 <font class="comment">// test if async loading ended</font> +00480 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_1">_AsyncTextureToLoadRefCount</a>==0) +00481 { +00482 <font class="comment">// must copy all fileNames into the actual Texture Files. Those are the valid ones now!</font> +00483 <font class="keywordflow">for</font>(uint i=0;i<<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>.size();i++) +00484 { +00485 <font class="keywordflow">for</font>(uint stage=0;stage<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>;stage++) +00486 { +00487 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>[i].IsTextureFile[stage]) +00488 { +00489 <font class="comment">// copy the texture name into the texture file.</font> +00490 CTextureFile *text= safe_cast<CTextureFile*>(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#m0">Materials</a>[i].getTexture(stage)); +00491 <font class="comment">// Since the texture is really uploaded in the driver, the true driver Texture Id will</font> +00492 <font class="comment">// be bound to this texture.</font> +00493 text->setFileName(<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>[i].TextureNames[stage]); +00494 <font class="comment">/* Since driver setup will only occurs when object become visible, it is a good idea to release</font> +00495 <font class="comment"> Old driver info, because it may points to old driver texture data (eg: old shared textureFile).</font> +00496 <font class="comment"> thus doing so release VRAM Texture Memory</font> +00497 <font class="comment"> */</font> +00498 text->releaseDriverSetup(); +00499 } +00500 } +00501 } +00502 +00503 <font class="comment">// Ok, we are now ready.</font> +00504 <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_4">_AsyncTextureReady</a>= <font class="keyword">true</font>; +00505 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00506 } +00507 <font class="keywordflow">else</font> +00508 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00509 } +00510 +00511 +00512 <font class="comment">// ***************************************************************************</font> +<a name="l00513"></a><a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z582_8">00513</a> sint CMeshBaseInstance::getAsyncTextureId(uint matId, uint stage)<font class="keyword"> const</font> +00514 <font class="keyword"></font>{ +00515 <font class="keywordflow">if</font>(matId>=<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>.size()) +00516 <font class="keywordflow">return</font> -1; +00517 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>[matId].isTextureFile(stage)) +00518 <font class="keywordflow">return</font> -1; +00519 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CMeshBaseInstance.html#z583_5">_CurrentAsyncTextures</a>[matId].TextIds[stage]; +00520 } +00521 +00522 +00523 +00524 } <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> |