diff options
Diffstat (limited to 'docs/doxygen/nel/mesh__morpher_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/mesh__morpher_8cpp-source.html | 470 |
1 files changed, 470 insertions, 0 deletions
diff --git a/docs/doxygen/nel/mesh__morpher_8cpp-source.html b/docs/doxygen/nel/mesh__morpher_8cpp-source.html new file mode 100644 index 00000000..191888a9 --- /dev/null +++ b/docs/doxygen/nel/mesh__morpher_8cpp-source.html @@ -0,0 +1,470 @@ +<!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_morpher.cpp</h1><a href="mesh__morpher_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__morpher_8h.html">3d/mesh_morpher.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="vertex__buffer_8h.html">3d/vertex_buffer.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="vertex__buffer__hard_8h.html">3d/vertex_buffer_hard.h</a>"</font> +00031 +00032 +00033 <font class="keyword">using</font> <font class="keyword">namespace </font>std; +00034 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC; +00035 +00036 +00037 <font class="keyword">namespace </font>NL3D +00038 { +00039 +00040 <font class="comment">// ***************************************************************************</font> +<a name="l00041"></a><a class="code" href="classNL3D_1_1CBlendShape.html#a0">00041</a> <font class="keywordtype">void</font> CBlendShape::serial (<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream) +00042 { +00043 <font class="comment">// version 1 : added tangent space support</font> +00044 sint ver = f.serialVersion (1); +00045 +00046 f.serial (Name); +00047 +00048 f.serialCont (deltaPos); +00049 f.serialCont (deltaNorm); +00050 f.serialCont (deltaUV); +00051 f.serialCont (deltaCol); +00052 +00053 <font class="keywordflow">if</font> (ver >= 1) f.serialCont(deltaTgSpace); +00054 +00055 f.serialCont (VertRefs); +00056 } +00057 +00058 <font class="comment">// ***************************************************************************</font> +<a name="l00059"></a><a class="code" href="classNL3D_1_1CMeshMorpher.html#a0">00059</a> CMeshMorpher::CMeshMorpher() +00060 { +00061 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a> = NULL; +00062 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a> = NULL; +00063 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o2">_VBDstHrd</a> = NULL; +00064 +00065 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o3">_Vertices</a> = NULL; +00066 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o4">_Normals</a> = NULL; +00067 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o5">_TgSpace</a>= NULL; +00068 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o6">_SkinApplied</a>= <font class="keyword">false</font>; +00069 } +00070 +00071 <font class="comment">// ***************************************************************************</font> +<a name="l00072"></a><a class="code" href="classNL3D_1_1CMeshMorpher.html#a1">00072</a> <font class="keywordtype">void</font> CMeshMorpher::init (CVertexBuffer *vbOri, CVertexBuffer *vbDst, IVertexBufferHard *vbDstHrd, <font class="keywordtype">bool</font> hasTgSpace) +00073 { +00074 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a> = vbOri; +00075 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a> = vbDst; +00076 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o2">_VBDstHrd</a> = vbDstHrd; +00077 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o7">_UseTgSpace</a> = hasTgSpace; +00078 } +00079 +00080 <font class="comment">// ***************************************************************************</font> +<a name="l00081"></a><a class="code" href="classNL3D_1_1CMeshMorpher.html#a2">00081</a> <font class="keywordtype">void</font> CMeshMorpher::initSkinned (CVertexBuffer *vbOri, +00082 CVertexBuffer *vbDst, +00083 IVertexBufferHard *vbDstHrd, +00084 <font class="keywordtype">bool</font> hasTgSpace, +00085 std::vector<CVector> *vVertices, +00086 std::vector<CVector> *vNormals, +00087 std::vector<CVector> *vTgSpace, <font class="comment">/* NULL if none */</font> +00088 <font class="keywordtype">bool</font> bSkinApplied ) +00089 { +00090 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a> = vbOri; +00091 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a> = vbDst; +00092 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o2">_VBDstHrd</a> = vbDstHrd; +00093 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o7">_UseTgSpace</a> = hasTgSpace; +00094 +00095 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o3">_Vertices</a> = vVertices; +00096 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o4">_Normals</a> = vNormals; +00097 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o5">_TgSpace</a> = vTgSpace; +00098 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o6">_SkinApplied</a> = bSkinApplied; +00099 } +00100 +00101 <font class="comment">// ***************************************************************************</font> +<a name="l00102"></a><a class="code" href="classNL3D_1_1CMeshMorpher.html#a3">00102</a> <font class="keywordtype">void</font> CMeshMorpher::update (std::vector<CAnimatedMorph> *pBSFactor) +00103 { +00104 uint32 i, j; +00105 +00106 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a> == NULL) +00107 <font class="keywordflow">return</font>; +00108 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#m0">BlendShapes</a>.size() == 0) +00109 <font class="keywordflow">return</font>; +00110 +00111 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getNumVertices() != <a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getNumVertices()) +00112 { <font class="comment">// Because the original vertex buffer is not initialized by default</font> +00113 <font class="comment">// we must init it here (if there are some blendshapes)</font> +00114 *<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a> = *<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>; +00115 } +00116 +00117 <font class="comment">// Does the flags are reserved ?</font> +00118 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>.size() != <a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getNumVertices()) +00119 { +00120 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>.resize (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getNumVertices()); +00121 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>.size(); ++i) +00122 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] = <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u2">Modified</a>; <font class="comment">// Modified to update all</font> +00123 } +00124 +00125 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getVertexFormat() == <a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexFormat()); +00126 +00127 <font class="comment">// Cleaning with original vertex buffer</font> +00128 uint32 VBVertexSize = <a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getVertexSize(); +00129 uint8 *pOri = (uint8*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getVertexCoordPointer (); +00130 uint8 *pDst = (uint8*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexCoordPointer (); +00131 +00132 <font class="keywordflow">for</font> (i= 0; i < <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>.size(); ++i) +00133 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] >= <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u2">Modified</a>) +00134 { +00135 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] = <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u1">OriginalVBDst</a>; +00136 +00137 <font class="keywordflow">for</font>(j = 0; j < VBVertexSize; ++j) +00138 pDst[j+i*VBVertexSize] = pOri[j+i*VBVertexSize]; +00139 } +00140 +00141 uint tgSpaceStage = 0; +00142 <font class="keywordflow">if</font> (_UseTgSpace) +00143 { +00144 tgSpaceStage = <a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getNumTexCoordUsed() - 1; +00145 } +00146 +00147 <font class="comment">// Blending with blendshape</font> +00148 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CMeshMorpher.html#m0">BlendShapes</a>.size(); ++i) +00149 { +00150 CBlendShape &rBS = <a class="code" href="classNL3D_1_1CMeshMorpher.html#m0">BlendShapes</a>[i]; +00151 <font class="keywordtype">float</font> rFactor = pBSFactor->operator[](i).getFactor()/100.0f; +00152 +00153 <font class="keywordflow">if</font> (rFactor > 0.0f) +00154 <font class="keywordflow">for</font> (j = 0; j < rBS.VertRefs.size(); ++j) +00155 { +00156 uint32 vp = rBS.VertRefs[j]; +00157 +00158 <font class="comment">// Modify Pos/Norm/TgSpace.</font> +00159 <font class="comment">//------------</font> +00160 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexFormat() & CVertexBuffer::PositionFlag) +00161 <font class="keywordflow">if</font> (rBS.deltaPos.size() > 0) +00162 { +00163 CVector *pV = (CVector*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexCoordPointer (vp); +00164 *pV += rBS.deltaPos[j] * rFactor; +00165 } +00166 +00167 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexFormat() & CVertexBuffer::NormalFlag) +00168 <font class="keywordflow">if</font> (rBS.deltaNorm.size() > 0) +00169 { +00170 CVector *pV = (CVector*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getNormalCoordPointer (vp); +00171 *pV += rBS.deltaNorm[j] * rFactor; +00172 } +00173 +00174 <font class="keywordflow">if</font> (_UseTgSpace) +00175 <font class="keywordflow">if</font> (rBS.deltaTgSpace.size() > 0) +00176 { +00177 CVector *pV = (CVector*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getTexCoordPointer (vp, tgSpaceStage); +00178 *pV += rBS.deltaTgSpace[j] * rFactor; +00179 } +00180 +00181 <font class="comment">// Modify UV0 / Color</font> +00182 <font class="comment">//------------</font> +00183 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexFormat() & CVertexBuffer::TexCoord0Flag) +00184 <font class="keywordflow">if</font> (rBS.deltaUV.size() > 0) +00185 { +00186 CUV *pUV = (CUV*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getTexCoordPointer (vp); +00187 *pUV += rBS.deltaUV[j] * rFactor; +00188 } +00189 +00190 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexFormat() & CVertexBuffer::PrimaryColorFlag) +00191 <font class="keywordflow">if</font> (rBS.deltaCol.size() > 0) +00192 { +00193 CRGBA *pRGBA = (CRGBA*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getColorPointer (vp); +00194 CRGBAF rgbf(*pRGBA); +00195 rgbf.R += rBS.deltaCol[j].R * rFactor; +00196 rgbf.G += rBS.deltaCol[j].G * rFactor; +00197 rgbf.B += rBS.deltaCol[j].B * rFactor; +00198 rgbf.A += rBS.deltaCol[j].A * rFactor; +00199 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(rgbf.R, 0.0f, 1.0f); +00200 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(rgbf.G, 0.0f, 1.0f); +00201 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(rgbf.B, 0.0f, 1.0f); +00202 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(rgbf.A, 0.0f, 1.0f); +00203 *pRGBA = rgbf; +00204 } +00205 +00206 <font class="comment">// Modified</font> +00207 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[vp] = <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u2">Modified</a>; +00208 } +00209 } +00210 +00211 <font class="comment">// Copying to hardware vertex buffer if some</font> +00212 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o2">_VBDstHrd</a> != NULL) +00213 { +00214 uint8 *pDstHrd = (uint8*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o2">_VBDstHrd</a>->lock(); +00215 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>.size(); ++i) +00216 { +00217 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] != <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u0">OriginalAll</a>) <font class="comment">// Not OriginalAll ?</font> +00218 { +00219 <font class="keywordflow">for</font>(j = 0; j < VBVertexSize; ++j) +00220 pDstHrd[j+i*VBVertexSize] = pDst[j+i*VBVertexSize]; +00221 } +00222 <font class="comment">// if this vertex is original in the VBDst</font> +00223 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] == <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u1">OriginalVBDst</a>) +00224 <font class="comment">// then it is now copied into the VBHard</font> +00225 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] = <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u0">OriginalAll</a>; +00226 } +00227 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o2">_VBDstHrd</a>->unlock(); +00228 } +00229 } +00230 +00231 +00232 <font class="comment">// ***************************************************************************</font> +<a name="l00233"></a><a class="code" href="classNL3D_1_1CMeshMorpher.html#a4">00233</a> <font class="keywordtype">void</font> CMeshMorpher::updateSkinned (std::vector<CAnimatedMorph> *pBSFactor) +00234 { +00235 uint32 i, j; +00236 +00237 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a> == NULL) +00238 <font class="keywordflow">return</font>; +00239 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#m0">BlendShapes</a>.size() == 0) +00240 <font class="keywordflow">return</font>; +00241 +00242 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getNumVertices() != <a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getNumVertices()) +00243 { <font class="comment">// Because the original vertex buffer is not initialized by default</font> +00244 <font class="comment">// we must init it here (if there are some blendshapes)</font> +00245 *<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a> = *<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>; +00246 } +00247 +00248 <font class="comment">// Does the flags are reserved ?</font> +00249 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>.size() != <a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getNumVertices()) +00250 { +00251 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>.resize (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getNumVertices()); +00252 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>.size(); ++i) +00253 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] = <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u2">Modified</a>; <font class="comment">// Modified to update all</font> +00254 } +00255 +00256 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getVertexFormat() == <a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexFormat()); +00257 +00258 uint tgSpaceStage; +00259 uint tgSpaceOff = 0; +00260 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o7">_UseTgSpace</a> && <a class="code" href="classNL3D_1_1CMeshMorpher.html#o5">_TgSpace</a>) +00261 { +00262 tgSpaceStage = <a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getNumTexCoordUsed() - 1; +00263 tgSpaceOff = <a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getTexCoordOff(tgSpaceStage); +00264 } +00265 +00266 <font class="comment">// Cleaning with original vertex buffer</font> +00267 uint32 VBVertexSize = <a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getVertexSize(); +00268 uint8 *pOri = (uint8*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o0">_VBOri</a>->getVertexCoordPointer (); +00269 uint8 *pDst = (uint8*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexCoordPointer (); +00270 +00271 <font class="keywordflow">for</font> (i= 0; i < <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>.size(); ++i) +00272 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] >= <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u2">Modified</a>) +00273 { +00274 <font class="keywordflow">for</font>(j = 0; j < VBVertexSize; ++j) +00275 pDst[j+i*VBVertexSize] = pOri[j+i*VBVertexSize]; +00276 +00277 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o3">_Vertices</a> != NULL) +00278 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o3">_Vertices</a>->operator[](i) = ((CVector*)(pOri+i*VBVertexSize))[0]; +00279 +00280 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o4">_Normals</a> != NULL) +00281 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o4">_Normals</a>->operator[](i) = ((CVector*)(pOri+i*VBVertexSize))[1]; +00282 +00283 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o5">_TgSpace</a> != NULL) +00284 (*_TgSpace)[i] = * (CVector*)(pOri + i * VBVertexSize + tgSpaceOff); +00285 +00286 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] = <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u1">OriginalVBDst</a>; +00287 } +00288 +00289 <font class="comment">// Blending with blendshape</font> +00290 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CMeshMorpher.html#m0">BlendShapes</a>.size(); ++i) +00291 { +00292 CBlendShape &rBS = <a class="code" href="classNL3D_1_1CMeshMorpher.html#m0">BlendShapes</a>[i]; +00293 <font class="keywordtype">float</font> rFactor = pBSFactor->operator[](i).getFactor()/100.0f; +00294 +00295 <font class="keywordflow">if</font> (rFactor > 0.0f) +00296 <font class="keywordflow">for</font> (j = 0; j < rBS.VertRefs.size(); ++j) +00297 { +00298 uint32 vp = rBS.VertRefs[j]; +00299 +00300 <font class="comment">// Modify Pos/Norm/TgSpace.</font> +00301 <font class="comment">//------------</font> +00302 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o3">_Vertices</a> != NULL) +00303 <font class="keywordflow">if</font> (rBS.deltaPos.size() > 0) +00304 { +00305 CVector *pV = &(<a class="code" href="classNL3D_1_1CMeshMorpher.html#o3">_Vertices</a>->operator[](vp)); +00306 *pV += rBS.deltaPos[j] * rFactor; +00307 } +00308 +00309 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o4">_Normals</a> != NULL) +00310 <font class="keywordflow">if</font> (rBS.deltaNorm.size() > 0) +00311 { +00312 CVector *pV = &(<a class="code" href="classNL3D_1_1CMeshMorpher.html#o4">_Normals</a>->operator[](vp)); +00313 *pV += rBS.deltaNorm[j] * rFactor; +00314 } +00315 +00316 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o7">_UseTgSpace</a> && <a class="code" href="classNL3D_1_1CMeshMorpher.html#o5">_TgSpace</a> != NULL) +00317 <font class="keywordflow">if</font> (rBS.deltaTgSpace.size() > 0) +00318 { +00319 CVector *pV = &((*_TgSpace)[vp]); +00320 *pV += rBS.deltaTgSpace[j] * rFactor; +00321 } +00322 +00323 <font class="comment">// Modify UV0 / Color</font> +00324 <font class="comment">//------------</font> +00325 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexFormat() & CVertexBuffer::TexCoord0Flag) +00326 <font class="keywordflow">if</font> (rBS.deltaUV.size() > 0) +00327 { +00328 CUV *pUV = (CUV*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getTexCoordPointer (vp); +00329 *pUV += rBS.deltaUV[j] * rFactor; +00330 } +00331 +00332 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getVertexFormat() & CVertexBuffer::PrimaryColorFlag) +00333 <font class="keywordflow">if</font> (rBS.deltaCol.size() > 0) +00334 { +00335 CRGBA *pRGBA = (CRGBA*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o1">_VBDst</a>->getColorPointer (vp); +00336 CRGBAF rgbf(*pRGBA); +00337 rgbf.R += rBS.deltaCol[j].R * rFactor; +00338 rgbf.G += rBS.deltaCol[j].G * rFactor; +00339 rgbf.B += rBS.deltaCol[j].B * rFactor; +00340 rgbf.A += rBS.deltaCol[j].A * rFactor; +00341 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(rgbf.R, 0.0f, 1.0f); +00342 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(rgbf.G, 0.0f, 1.0f); +00343 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(rgbf.B, 0.0f, 1.0f); +00344 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(rgbf.A, 0.0f, 1.0f); +00345 *pRGBA = rgbf; +00346 } +00347 +00348 <font class="comment">// Modified</font> +00349 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[vp] = <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u2">Modified</a>; +00350 } +00351 } +00352 +00353 <font class="comment">// Do some transfert to the VBHard if exist.</font> +00354 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o2">_VBDstHrd</a> != NULL) +00355 { +00356 <font class="comment">// lock.</font> +00357 uint8 *pDstHrd = (uint8*)<a class="code" href="classNL3D_1_1CMeshMorpher.html#o2">_VBDstHrd</a>->lock(); +00358 +00359 <font class="comment">// If the skin is applied we have nothing to do </font> +00360 <font class="comment">// Because the skinning will transfert ALL the vertices of interest</font> +00361 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CMeshMorpher.html#o6">_SkinApplied</a>) +00362 { +00363 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>.size(); ++i) +00364 { +00365 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] != <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u0">OriginalAll</a>) <font class="comment">// Not OriginalAll ?</font> +00366 { +00367 <font class="comment">// We must write the whole vertex because the skinning may not copy </font> +00368 <font class="comment">// vertex and normal changes into VBHard</font> +00369 <font class="keywordflow">for</font>(j = 0; j < VBVertexSize; ++j) +00370 pDstHrd[j+i*VBVertexSize] = pDst[j+i*VBVertexSize]; +00371 } +00372 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] == <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u1">OriginalVBDst</a>) <font class="comment">// OriginalVBDst ?</font> +00373 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o8">_Flags</a>[i] = <a class="code" href="classNL3D_1_1CMeshMorpher.html#u3u0">OriginalAll</a>; <font class="comment">// So OriginalAll !</font> +00374 } +00375 } +00376 +00377 <font class="comment">// unlock.</font> +00378 <a class="code" href="classNL3D_1_1CMeshMorpher.html#o2">_VBDstHrd</a>->unlock(); +00379 } +00380 } +00381 +00382 <font class="comment">// ***************************************************************************</font> +<a name="l00383"></a><a class="code" href="classNL3D_1_1CMeshMorpher.html#a5">00383</a> <font class="keywordtype">void</font> CMeshMorpher::serial (<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream) +00384 { +00385 (void)f.serialVersion (0); +00386 +00387 f.serialCont (BlendShapes); +00388 } +00389 +00390 +00391 } <font class="comment">// NL3D</font> +00392 +00393 +00394 +00395 +00396 +00397 +00398 +00399 +00400 +00401 +</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> |