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/cloud_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/cloud_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/cloud_8cpp-source.html | 830 |
1 files changed, 830 insertions, 0 deletions
diff --git a/docs/doxygen/nel/cloud_8cpp-source.html b/docs/doxygen/nel/cloud_8cpp-source.html new file mode 100644 index 00000000..6faa8c63 --- /dev/null +++ b/docs/doxygen/nel/cloud_8cpp-source.html @@ -0,0 +1,830 @@ +<!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>cloud.cpp</h1><a href="cloud_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2002 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 <font class="preprocessor">#include "<a class="code" href="material_8h.html">3d/material.h</a>"</font> +00028 <font class="preprocessor">#include "<a class="code" href="cloud_8h.html">cloud.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="cloud__scape_8h.html">cloud_scape.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="noise__3d_8h.html">noise_3d.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="scissor_8h.html">nel/3d/scissor.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="viewport_8h.html">nel/3d/viewport.h</a>"</font> +00033 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font> +00034 +00035 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC; +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_1CCloud.html#a0">00041</a> CCloud::CCloud (CCloudScape *pCloudScape) +00042 { +00043 <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a> = pCloudScape; +00044 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a> = <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_Driver; +00045 <a class="code" href="classNL3D_1_1CCloud.html#m4">CloudPower</a> = 255; <font class="comment">// Max Power</font> +00046 <a class="code" href="classNL3D_1_1CCloud.html#m6">LastCloudPower</a> = 255; +00047 <a class="code" href="classNL3D_1_1CCloud.html#m5">CloudDistAtt</a> = 0; +00048 <a class="code" href="classNL3D_1_1CCloud.html#m2">CloudDiffuse</a> = CRGBA(255,255,255,255); +00049 <a class="code" href="classNL3D_1_1CCloud.html#m3">CloudAmbient</a> = CRGBA(120,140,160,255); +00050 <a class="code" href="classNL3D_1_1CCloud.html#o22">_WaitState</a> = 0; +00051 <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a> = 0; +00052 <a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a> = 0; +00053 <a class="code" href="classNL3D_1_1CCloud.html#o10">_UStart</a> = <a class="code" href="classNL3D_1_1CCloud.html#o11">_VStart</a> = <a class="code" href="classNL3D_1_1CCloud.html#o12">_WStart</a> = NULL; +00054 } +00055 +00056 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +<a name="l00057"></a><a class="code" href="classNL3D_1_1CCloud.html#a1">00057</a> CCloud::~CCloud() +00058 { +00059 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CCloud.html#o10">_UStart</a>; +00060 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CCloud.html#o11">_VStart</a>; +00061 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CCloud.html#o12">_WStart</a>; +00062 } +00063 +00064 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +<a name="l00065"></a><a class="code" href="classNL3D_1_1CCloud.html#a2">00065</a> <font class="keywordtype">void</font> CCloud::init (uint32 nVoxelW, uint32 nVoxelH, uint32 nVoxelD, <font class="keywordtype">float</font> rBaseFreq, uint32 nNbOctave) +00066 { +00067 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#o10">_UStart</a> != NULL) +00068 <font class="keywordflow">return</font>; +00069 +00070 <a class="code" href="classNL3D_1_1CCloud.html#o8">_BaseFreq</a> = rBaseFreq; +00071 <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a> = 0; +00072 <a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a> = 0; +00073 +00074 <a class="code" href="classNL3D_1_1CCloud.html#o9">_NbOctave</a> = nNbOctave; +00075 <a class="code" href="classNL3D_1_1CCloud.html#o10">_UStart</a> = <font class="keyword">new</font> <font class="keywordtype">double</font>[<a class="code" href="classNL3D_1_1CCloud.html#o9">_NbOctave</a>]; +00076 <a class="code" href="classNL3D_1_1CCloud.html#o11">_VStart</a> = <font class="keyword">new</font> <font class="keywordtype">double</font>[<a class="code" href="classNL3D_1_1CCloud.html#o9">_NbOctave</a>]; +00077 <a class="code" href="classNL3D_1_1CCloud.html#o12">_WStart</a> = <font class="keyword">new</font> <font class="keywordtype">double</font>[<a class="code" href="classNL3D_1_1CCloud.html#o9">_NbOctave</a>]; +00078 +00079 uint32 i; +00080 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CCloud.html#o9">_NbOctave</a>; ++i) +00081 { +00082 <a class="code" href="classNL3D_1_1CCloud.html#o10">_UStart</a>[i] = ((double)rand())/RAND_MAX; +00083 <a class="code" href="classNL3D_1_1CCloud.html#o11">_VStart</a>[i] = ((double)rand())/RAND_MAX; +00084 <a class="code" href="classNL3D_1_1CCloud.html#o12">_WStart</a>[i] = ((double)rand())/RAND_MAX; +00085 } +00086 +00087 <a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a> = <a class="code" href="namespaceNLMISC.html#a223">raiseToNextPowerOf2</a> (nVoxelW); +00088 <a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a> = <a class="code" href="namespaceNLMISC.html#a223">raiseToNextPowerOf2</a> (nVoxelH); +00089 <a class="code" href="classNL3D_1_1CCloud.html#o2">_Depth</a> = <a class="code" href="namespaceNLMISC.html#a223">raiseToNextPowerOf2</a> (nVoxelD); +00090 uint32 vdpo2 = <a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(<a class="code" href="classNL3D_1_1CCloud.html#o2">_Depth</a>); +00091 <a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a> = 1 << (vdpo2 / 2); +00092 <font class="keywordflow">if</font> ((vdpo2 & 1) != 0) +00093 <a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a> = 2 << (vdpo2 / 2); +00094 <font class="keywordflow">else</font> +00095 <a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a> = 1 << (vdpo2 / 2); +00096 +00097 <a class="code" href="classNL3D_1_1CCloud.html#o17">_MemBill</a> = NULL; +00098 <a class="code" href="classNL3D_1_1CCloud.html#o20">_MemOldBill</a> = NULL; +00099 +00100 <font class="keywordtype">float</font> scale = 20.0f + 10.0f*((float)rand())/RAND_MAX;; +00101 <a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = scale * <a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>/<a class="code" href="classNL3D_1_1CCloud.html#o2">_Depth</a>; +00102 scale = 20.0f + 10.0f*((float)rand())/RAND_MAX;; +00103 <a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = scale * <a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>/<a class="code" href="classNL3D_1_1CCloud.html#o2">_Depth</a>; +00104 scale = 20.0f + 10.0f*((float)rand())/RAND_MAX;; +00105 <a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = scale * <a class="code" href="classNL3D_1_1CCloud.html#o2">_Depth</a>/<a class="code" href="classNL3D_1_1CCloud.html#o2">_Depth</a>; +00106 +00107 } +00108 +00109 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +<a name="l00110"></a><a class="code" href="classNL3D_1_1CCloud.html#a3">00110</a> <font class="keywordtype">void</font> CCloud::generate (CNoise3d &noise) +00111 { +00112 <font class="keywordtype">float</font> dU, dV, dW; +00113 uint32 nOct; +00114 CQuadUV qc; +00115 +00116 <font class="comment">// Setup the matrices view&model, viewport and frustum</font> +00117 <a class="code" href="classNL3D_1_1CCloud.html#c0">setMode2D</a> (); +00118 +00119 <font class="comment">// Clear background</font> +00120 CVertexBuffer &rVB = <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_VertexBuffer; +00121 uint32 nVSize = rVB.getVertexSize (); +00122 CVector *pVertices = (CVector*)rVB.getVertexCoordPointer (0); +00123 *pVertices = CVector(0.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00124 *pVertices = CVector((<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>*<a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>,0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00125 *pVertices = CVector((<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>*<a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>,(<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>*<a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>,0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00126 *pVertices = CVector(0.0f, (<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>*<a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>,0.0f); +00127 <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatClear.setColor (CRGBA(0,0,0,0)); +00128 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (rVB); +00129 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (<a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatClear, 0, 1); +00130 +00131 <font class="comment">// Create cloud from noise</font> +00132 <font class="keywordflow">for</font> (nOct = 0; nOct < <a class="code" href="classNL3D_1_1CCloud.html#o9">_NbOctave</a>; ++nOct) +00133 { +00134 dU = (<a class="code" href="classNL3D_1_1CCloud.html#o8">_BaseFreq</a>*((float)<a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>)/noise.getWidth())*(1<<nOct); +00135 dV = (<a class="code" href="classNL3D_1_1CCloud.html#o8">_BaseFreq</a>*((float)<a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>)/noise.getHeight())*(1<<nOct); +00136 dW = (<a class="code" href="classNL3D_1_1CCloud.html#o8">_BaseFreq</a>*((float)<a class="code" href="classNL3D_1_1CCloud.html#o2">_Depth</a>)/noise.getDepth())*(1<<nOct); +00137 +00138 +00139 noise.renderGrid (<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>, <a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>, <a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>, <a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>, +00140 (<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o10">_UStart</a>[nOct], (<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o11">_VStart</a>[nOct], (<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o12">_WStart</a>[nOct], dU, dV, dW, +00141 1.0f/(2<<nOct)); +00142 +00143 <font class="comment">/* This is the same thing as a renderGrid which is optimized to do that </font> +00144 <font class="comment"> qc.Uv0 = CUV((float)_UStart[nOct], (float)_VStart[nOct]);</font> +00145 <font class="comment"> qc.Uv1 = CUV((float)_UStart[nOct]+dU, (float)_VStart[nOct]);</font> +00146 <font class="comment"> qc.Uv2 = CUV((float)_UStart[nOct]+dU, (float)_VStart[nOct]+dV);</font> +00147 <font class="comment"> qc.Uv3 = CUV((float)_UStart[nOct], (float)_VStart[nOct]+dV);</font> +00148 <font class="comment"> uint32 i,j;</font> +00149 <font class="comment"> for (j = 0; j < _NbH; ++j)</font> +00150 <font class="comment"> {</font> +00151 <font class="comment"> for (i = 0; i < _NbW; ++i)</font> +00152 <font class="comment"> {</font> +00153 <font class="comment"> qc.V0 = CVector((float)i*_Width, (float)j*_Height, 0.0f);</font> +00154 <font class="comment"> qc.V1 = CVector((float)(i+1)*_Width, (float)j*_Height, 0.0f);</font> +00155 <font class="comment"> qc.V2 = CVector((float)(i+1)*_Width, (float)(j+1)*_Height, 0.0f);</font> +00156 <font class="comment"> qc.V3 = CVector((float)i*_Width, (float)(j+1)*_Height, 0.0f);</font> +00157 <font class="comment"> noise.render (qc, (float)_WStart[nOct]+dW*(i+(float)j*_NbW)/(((float)_NbW)*_NbH), 1.0f/(2<<nOct));</font> +00158 <font class="comment"> }</font> +00159 <font class="comment"> }*/</font> +00160 noise.flush (); +00161 } +00162 +00163 <font class="comment">// Apply attenuation texture (not needed to resetup position again (done when clearing to black))</font> +00164 CUV *pUV = (CUV*)rVB.getTexCoordPointer (0, 0); +00165 pUV->U = 0.0f; pUV->V = 0.0f; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00166 pUV->U = 1.0f; pUV->V = 0.0f; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00167 pUV->U = 1.0f; pUV->V = 1.0f; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00168 pUV->U = 0.0f; pUV->V = 1.0f; +00169 uint8 colpow = (uint8)(255-(((uint32)<a class="code" href="classNL3D_1_1CCloud.html#m4">CloudPower</a>*(255-(uint32)<a class="code" href="classNL3D_1_1CCloud.html#m5">CloudDistAtt</a>)) / 255)); +00170 <a class="code" href="classNL3D_1_1CCloud.html#o15">_CloudTexClamp</a>->ToClamp.setColor (CRGBA(255, 255, 255, colpow)); +00171 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (rVB); +00172 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (<a class="code" href="classNL3D_1_1CCloud.html#o15">_CloudTexClamp</a>->ToClamp, 0, 1); +00173 +00174 <font class="comment">// We have generated to the screen the texture cloud so now copy from screen to the texture</font> +00175 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a61">copyFrameBufferToTexture</a> (<a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->Tex, 0, 0, 0, 0, 0, <a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>*<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>, <a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>*<a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>); +00176 +00177 <a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->Tex->setFilterMode (ITexture::Nearest, ITexture::NearestMipMapOff); +00178 } +00179 +00180 +00181 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +<a name="l00182"></a><a class="code" href="classNL3D_1_1CCloud.html#a4">00182</a> <font class="keywordtype">void</font> CCloud::light () +00183 { +00184 uint32 i, j; +00185 +00186 <font class="comment">// Setup the matrices view&model, viewport and frustum</font> +00187 <a class="code" href="classNL3D_1_1CCloud.html#c0">setMode2D</a> (); +00188 +00189 <font class="comment">// Destination position for lighting accumulation buffer from (0, 0) size (_Width, _Height)</font> +00190 CVertexBuffer &rVB = <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_VertexBuffer; +00191 uint32 nVSize = rVB.getVertexSize (); +00192 CVector *pVertices = (CVector*)rVB.getVertexCoordPointer (0); +00193 *pVertices = CVector((<font class="keywordtype">float</font>)0.0f, (<font class="keywordtype">float</font>)0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00194 *pVertices = CVector((<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>, (<font class="keywordtype">float</font>)0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00195 *pVertices = CVector((<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>, (<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00196 *pVertices = CVector((<font class="keywordtype">float</font>)0.0f, (<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>, 0.0f); +00197 +00198 <font class="comment">// Clear the screen accumulatorfor lighting</font> +00199 <a class="code" href="classNL3D_1_1CCloud.html#m2">CloudDiffuse</a>.<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a> = 255; +00200 <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatClear.setColor (<a class="code" href="classNL3D_1_1CCloud.html#m2">CloudDiffuse</a>); +00201 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (rVB); +00202 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (<a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatClear, 0, 1); +00203 +00204 CUV *pUV; +00205 <font class="comment">// Lighting : render the alpha of one layer into rgb of the screen</font> +00206 <font class="keywordtype">float</font> oneOverNbW = 1.0f/<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>; +00207 <font class="keywordtype">float</font> oneOverNbH = 1.0f/<a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>; +00208 uint32 previ, prevj; +00209 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (rVB); +00210 <font class="keywordflow">for</font> (j = 0; j < <a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>; ++j) +00211 { +00212 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>; ++i) +00213 { +00214 <font class="comment">// Add the alpha of the previous layer into the RGB of the destination</font> +00215 <font class="keywordflow">if</font> ((i+j) > 0) +00216 { +00217 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a14">setColorMask</a> (<font class="keyword">true</font>, <font class="keyword">true</font>, <font class="keyword">true</font>, <font class="keyword">false</font>); +00218 pUV = (CUV*)rVB.getTexCoordPointer (0, 0); +00219 pUV->U = previ*oneOverNbW; pUV->V = prevj*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00220 pUV->U = (previ+1)*oneOverNbW; pUV->V = prevj*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00221 pUV->U = (previ+1)*oneOverNbW; pUV->V = (prevj+1)*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00222 pUV->U = previ*oneOverNbW; pUV->V = (prevj+1)*oneOverNbH; +00223 +00224 <a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->ToLight.setBlend (<font class="keyword">true</font>); +00225 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (<a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->ToLight, 0, 1); +00226 } +00227 <font class="comment">// Replace the alpha of the destination by the alpha of the current layer</font> +00228 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a14">setColorMask</a> (<font class="keyword">false</font>, <font class="keyword">false</font>, <font class="keyword">false</font>, <font class="keyword">true</font>); +00229 +00230 pUV = (CUV*)rVB.getTexCoordPointer (0, 0); +00231 pUV->U = i*oneOverNbW; pUV->V = j*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00232 pUV->U = (i+1)*oneOverNbW; pUV->V = j*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00233 pUV->U = (i+1)*oneOverNbW; pUV->V = (j+1)*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00234 pUV->U = i*oneOverNbW; pUV->V = (j+1)*oneOverNbH; +00235 +00236 <a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->ToLight.setBlend (<font class="keyword">false</font>); +00237 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (<a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->ToLight, 0, 1); +00238 +00239 <font class="comment">// Copy from accumulator to the texture</font> +00240 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a61">copyFrameBufferToTexture</a>(<a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->Tex, 0, i*<a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>, j*<a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>, 0, 0, <a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>, <a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>); +00241 previ = i; +00242 prevj = j; +00243 } +00244 } +00245 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a14">setColorMask</a> (<font class="keyword">true</font>, <font class="keyword">true</font>, <font class="keyword">true</font>, <font class="keyword">true</font>); +00246 +00247 <a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->Tex->setFilterMode (ITexture::Linear, ITexture::LinearMipMapOff); +00248 } +00249 +00250 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +<a name="l00251"></a><a class="code" href="classNL3D_1_1CCloud.html#a5">00251</a> <font class="keywordtype">void</font> CCloud::reset (<a class="code" href="classNL3D_1_1CCamera.html">NL3D::CCamera</a> *pViewer) +00252 { +00253 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a> != 4) +00254 { +00255 <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a> = 4; +00256 <a class="code" href="classNL3D_1_1CCloud.html#o17">_MemBill</a> = <font class="keyword">new</font> uint8[4*<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>*<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>]; +00257 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a> = <font class="keyword">new</font> CTextureMem (<a class="code" href="classNL3D_1_1CCloud.html#o17">_MemBill</a>, 4*<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>*<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>, <font class="keyword">true</font>, <font class="keyword">false</font>, <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>, <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>); +00258 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>->setWrapS (ITexture::Clamp); +00259 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>->setWrapT (ITexture::Clamp); +00260 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>->setFilterMode (ITexture::Linear, ITexture::LinearMipMapOff); +00261 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>->generate(); +00262 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>->setReleasable (<font class="keyword">false</font>); +00263 } +00264 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a> != 4) +00265 { +00266 <a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a> = 4; +00267 <a class="code" href="classNL3D_1_1CCloud.html#o20">_MemOldBill</a> = <font class="keyword">new</font> uint8[4*<a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a>*<a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a>]; +00268 <a class="code" href="classNL3D_1_1CCloud.html#o21">_TexOldBill</a> = <font class="keyword">new</font> CTextureMem (<a class="code" href="classNL3D_1_1CCloud.html#o20">_MemOldBill</a>, 4*<a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a>*<a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a>, <font class="keyword">true</font>, <font class="keyword">false</font>, <a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a>, <a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a>); +00269 <a class="code" href="classNL3D_1_1CCloud.html#o21">_TexOldBill</a>->setWrapS (ITexture::Clamp); +00270 <a class="code" href="classNL3D_1_1CCloud.html#o21">_TexOldBill</a>->setWrapT (ITexture::Clamp); +00271 <a class="code" href="classNL3D_1_1CCloud.html#o21">_TexOldBill</a>->setFilterMode (ITexture::Linear, ITexture::LinearMipMapOff); +00272 <a class="code" href="classNL3D_1_1CCloud.html#o21">_TexOldBill</a>->generate(); +00273 <a class="code" href="classNL3D_1_1CCloud.html#o21">_TexOldBill</a>->setReleasable (<font class="keyword">false</font>); +00274 } +00275 <a class="code" href="classNL3D_1_1CCloud.html#c0">setMode2D</a> (); +00276 +00277 <font class="comment">// Clear background</font> +00278 CVertexBuffer &rVB = <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_VertexBuffer; +00279 uint32 nVSize = rVB.getVertexSize (); +00280 CVector *pVertices = (CVector*)rVB.getVertexCoordPointer (0); +00281 *pVertices = CVector(0.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00282 *pVertices = CVector(5.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00283 *pVertices = CVector(5.0f, 5.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00284 *pVertices = CVector(0.0f, 5.0f, 0.0f); +00285 <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatClear.setColor (CRGBA(0,0,0,0)); +00286 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (rVB); +00287 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (<a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatClear, 0, 1); +00288 +00289 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a61">copyFrameBufferToTexture</a> (<a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>, 0, 0, 0, 0, 0, 4, 4); +00290 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a61">copyFrameBufferToTexture</a> (<a class="code" href="classNL3D_1_1CCloud.html#o21">_TexOldBill</a>, 0, 0, 0, 0, 0, 4, 4); +00291 +00292 <font class="comment">// CMatrix CamMat = pViewer->getMatrix();</font> +00293 <font class="comment">// CVector Viewer = CamMat.getPos();</font> +00294 CVector Viewer = CVector(0,0,0); +00295 CVector Center = CVector (<a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>/2, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>/2, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>/2); +00296 CVector Size = <a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>; +00297 CVector I, J, K; +00298 <font class="keywordtype">float</font> Left, Right, Top, Bottom, Near, Far; +00299 +00300 <a class="code" href="classNL3D_1_1CCloud.html#c1">calcBill</a> (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far); +00301 +00302 <a class="code" href="classNL3D_1_1CCloud.html#o25">_BillOldCenter</a> = <a class="code" href="classNL3D_1_1CCloud.html#o24">_BillCenter</a>; +00303 <a class="code" href="classNL3D_1_1CCloud.html#o23">_BillViewer</a> = Viewer; +00304 <a class="code" href="classNL3D_1_1CCloud.html#o24">_BillCenter</a> = Center; +00305 +00306 <a class="code" href="classNL3D_1_1CCloud.html#c1">calcBill</a> (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far); +00307 +00308 <a class="code" href="classNL3D_1_1CCloud.html#o25">_BillOldCenter</a> = <a class="code" href="classNL3D_1_1CCloud.html#o24">_BillCenter</a>; +00309 <a class="code" href="classNL3D_1_1CCloud.html#o23">_BillViewer</a> = Viewer; +00310 <a class="code" href="classNL3D_1_1CCloud.html#o24">_BillCenter</a> = Center; +00311 +00312 } +00313 +00314 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +<a name="l00315"></a><a class="code" href="classNL3D_1_1CCloud.html#a6">00315</a> <font class="keywordtype">void</font> CCloud::anim (<font class="keywordtype">double</font> dt, <font class="keywordtype">double</font> dt2) +00316 { +00317 <font class="keywordflow">for</font> (uint32 nOct = 0; nOct < <a class="code" href="classNL3D_1_1CCloud.html#o9">_NbOctave</a>; ++nOct) +00318 { +00319 <a class="code" href="classNL3D_1_1CCloud.html#o10">_UStart</a>[nOct] += dt*(1<<nOct) / 5000.0; +00320 <a class="code" href="classNL3D_1_1CCloud.html#o11">_VStart</a>[nOct] += dt*(1<<nOct) / 5000.0; +00321 <a class="code" href="classNL3D_1_1CCloud.html#o12">_WStart</a>[nOct] += dt*(1<<nOct) / 5000.0; +00322 } +00323 <font class="comment">//_Pos.x += dt2;</font> +00324 <font class="comment">//Time += dt2;</font> +00325 } +00326 +00327 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +<a name="l00328"></a><a class="code" href="classNL3D_1_1CCloud.html#a7">00328</a> <font class="keywordtype">void</font> CCloud::disp () +00329 { +00330 CQuadUV qc; +00331 qc.Uv0 = CUV(0.0f, 0.0f); +00332 qc.Uv1 = CUV(1.0f, 0.0f); +00333 qc.Uv2 = CUV(1.0f, 1.0f); +00334 qc.Uv3 = CUV(0.0f, 1.0f); +00335 +00337 CScissor <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>; +00338 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>.initFullScreen(); +00339 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a52">setupScissor</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>); +00340 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a51">setupViewport</a> (CViewport()); +00341 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a23">setFrustum</a> (0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, <font class="keyword">false</font>); +00342 CVector I(1,0,0); +00343 CVector J(0,0,1); +00344 CVector K(0,-1,0); +00345 CMatrix ViewMatrix; +00346 ViewMatrix.identity(); +00347 ViewMatrix.setRot(I,J,K, <font class="keyword">true</font>); +00348 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a24">setupViewMatrix</a>(ViewMatrix); +00349 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a26">setupModelMatrix</a>(CMatrix::Identity); +00351 +00352 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>*<a class="code" href="classNL3D_1_1CCloud.html#o0">_Width</a>; +00353 uint32 h = <a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>*<a class="code" href="classNL3D_1_1CCloud.html#o1">_Height</a>; +00354 uint32 i = 0; +00355 qc.V0 = CVector(0.0f/800.0f, 0.0f/600.0f, 0.0f); +00356 qc.V1 = CVector(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>/800.0f, 0.0f/600.0f, 0.0f); +00357 qc.V2 = CVector(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>/800.0f, h/600.0f, 0.0f); +00358 qc.V3 = CVector(0.0f/800.0f, h/600.0f, 0.0f); +00359 <font class="keyword">static</font> CMaterial *dispMat = NULL; +00360 <font class="keywordflow">if</font> (dispMat == NULL) +00361 { +00362 dispMat = <font class="keyword">new</font> CMaterial; +00363 dispMat->initUnlit(); +00364 dispMat->setTexture(0, <a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->Tex); +00365 dispMat->texEnvOpRGB(0, CMaterial::Replace); +00366 <font class="comment">//dispMat->texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcAlpha);</font> +00367 dispMat->texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor); +00368 dispMat->setZFunc(CMaterial::always); +00369 dispMat->setZWrite(<font class="keyword">false</font>); +00370 dispMat->setDoubleSided(<font class="keyword">true</font>); +00371 dispMat->setBlend (<font class="keyword">false</font>); +00372 } +00373 +00374 CVertexBuffer &rVB = <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_VertexBuffer; +00375 rVB.setVertexCoord (0, qc.V0); +00376 rVB.setVertexCoord (1, qc.V1); +00377 rVB.setVertexCoord (2, qc.V2); +00378 rVB.setVertexCoord (3, qc.V3); +00379 rVB.setTexCoord (0, 0, qc.Uv0); +00380 rVB.setTexCoord (1, 0, qc.Uv1); +00381 rVB.setTexCoord (2, 0, qc.Uv2); +00382 rVB.setTexCoord (3, 0, qc.Uv3); +00383 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (rVB); +00384 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (*dispMat, 0, 1); +00385 } +00386 +00387 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +<a name="l00388"></a><a class="code" href="classNL3D_1_1CCloud.html#a8">00388</a> <font class="keywordtype">void</font> CCloud::dispXYZ (CMaterial *pMat) +00389 { +00390 CQuadUV qc; +00391 uint32 i,j; +00392 +00393 <font class="keywordtype">float</font> oneOverNbW = 1.0f / <a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>; +00394 <font class="keywordtype">float</font> oneOverNbH = 1.0f / <a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>; +00395 <font class="keywordtype">float</font> oneOverNbWNbH = 1.0f / (<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>*<a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>); +00396 CVertexBuffer &rVB = <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_VertexBuffer; +00397 uint32 nVSize = rVB.getVertexSize (); +00398 CVector *pVertices; +00399 CUV *pUV; +00400 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (rVB); +00401 +00402 <font class="keywordflow">if</font> (pMat == NULL) +00403 <font class="keywordflow">return</font>; +00404 +00405 <font class="keywordflow">for</font> (j = 0; j < <a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>; ++j) +00406 { +00407 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>; ++i) +00408 { +00409 uint32 d = i+j*<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>; +00410 +00411 pVertices = (CVector*)rVB.getVertexCoordPointer (0); +00412 *pVertices = CVector(<a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>*(<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>*<a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>-d)*oneOverNbWNbH); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00413 *pVertices = CVector(<a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>*(<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>*<a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>-d)*oneOverNbWNbH); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00414 *pVertices = CVector(<a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>*(<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>*<a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>-d)*oneOverNbWNbH); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00415 *pVertices = CVector(<a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>*(<a class="code" href="classNL3D_1_1CCloud.html#o3">_NbW</a>*<a class="code" href="classNL3D_1_1CCloud.html#o4">_NbH</a>-d)*oneOverNbWNbH); +00416 +00417 pUV = (CUV*)rVB.getTexCoordPointer (0, 0); +00418 pUV->U = i*oneOverNbW; pUV->V = j*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00419 pUV->U = (i+1)*oneOverNbW; pUV->V = j*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00420 pUV->U = (i+1)*oneOverNbW; pUV->V = (j+1)*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00421 pUV->U = i*oneOverNbW; pUV->V = (j+1)*oneOverNbH; +00422 +00423 pUV = (CUV*)rVB.getTexCoordPointer (0, 1); +00424 pUV->U = i*oneOverNbW; pUV->V = j*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00425 pUV->U = (i+1)*oneOverNbW; pUV->V = j*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00426 pUV->U = (i+1)*oneOverNbW; pUV->V = (j+1)*oneOverNbH; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00427 pUV->U = i*oneOverNbW; pUV->V = (j+1)*oneOverNbH; +00428 +00429 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (*pMat, 0, 1); +00430 } +00431 } +00432 } +00433 +00434 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +00435 <font class="comment">// in ; viewer, center</font> +00436 <font class="comment">// out I,J,K, left,right,top,bottom,near,far</font> +<a name="l00437"></a><a class="code" href="classNL3D_1_1CCloud.html#c1">00437</a> <font class="keywordtype">void</font> CCloud::calcBill (<font class="keyword">const</font> CVector &Viewer, <font class="keyword">const</font> CVector &Center, <font class="keyword">const</font> CVector &Size, CVector &I, CVector &J, CVector &K, +00438 <font class="keywordtype">float</font> &Left, <font class="keywordtype">float</font> &Right, <font class="keywordtype">float</font> &Top, <font class="keywordtype">float</font> &Bottom, <font class="keywordtype">float</font> &Near, <font class="keywordtype">float</font> &Far) +00439 { +00440 CVector ViewDir = Center - Viewer; +00441 <font class="keywordtype">float</font> ViewDist = ViewDir.norm(); +00442 ViewDir.normalize(); +00443 +00444 Left = 1000.0f; +00445 Right = -1000.0f; +00446 Top = -1000.0f; +00447 Bottom = 1000.0f; +00448 Near = 1000.0f; +00449 Far = -1000.0f; +00450 +00451 <font class="keywordflow">if</font> (fabsf(Center.y-Viewer.y) > fabsf(Center.z-Viewer.z)) +00452 { +00453 K.set(0, 0, 1); +00454 J= ViewDir; +00455 I= J^K; +00456 K= I^J; +00457 } +00458 <font class="keywordflow">else</font> +00459 { +00460 K.set(0, 1, 0); +00461 J= ViewDir; +00462 I= J^K; +00463 K= I^J; +00464 } +00465 I.normalize(); +00466 J.normalize(); +00467 K.normalize(); +00468 +00469 CMatrix mat; +00470 mat.identity(); +00471 mat.setRot(I,J,K, <font class="keyword">true</font>); +00472 mat.setPos(CVector(Viewer.x, Viewer.y, Viewer.z)); +00473 mat.invert(); +00474 +00475 uint32 i, j, k; +00476 <font class="keywordflow">for</font> (i = 0; i < 2; ++i) +00477 <font class="keywordflow">for</font> (j = 0; j < 2; ++j) +00478 <font class="keywordflow">for</font> (k = 0; k < 2; ++k) +00479 { +00480 CVector <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>; +00481 <font class="keywordflow">if</font> (i == 0) <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x = Center.x-Size.x/2; <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x = Center.x+Size.x/2; +00482 <font class="keywordflow">if</font> (j == 0) <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y = Center.y-Size.y/2; <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y = Center.y+Size.y/2; +00483 <font class="keywordflow">if</font> (k == 0) <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z = Center.z-Size.z/2; <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z = Center.z+Size.z/2; +00484 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = mat.mulPoint(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); +00485 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y < Near) Near = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y; +00486 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y > Far) Far = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y; +00487 } +00488 +00489 <font class="keywordflow">for</font> (i = 0; i < 2; ++i) +00490 <font class="keywordflow">for</font> (j = 0; j < 2; ++j) +00491 <font class="keywordflow">for</font> (k = 0; k < 2; ++k) +00492 { +00493 CVector <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>; +00494 <font class="keywordflow">if</font> (i == 0) <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x = Center.x-Size.x/2; <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x = Center.x+Size.x/2; +00495 <font class="keywordflow">if</font> (j == 0) <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y = Center.y-Size.y/2; <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y = Center.y+Size.y/2; +00496 <font class="keywordflow">if</font> (k == 0) <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z = Center.z-Size.z/2; <font class="keywordflow">else</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z = Center.z+Size.z/2; +00497 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = mat.mulPoint(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); +00498 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x / (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y/Near); +00499 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z / (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.y/Near); +00500 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x < Left) Left = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x; +00501 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x > Right) Right = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.x; +00502 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z < Bottom) Bottom = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00503 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z > Top) Top = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.z; +00504 } +00505 } +00506 +00507 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +00508 <font class="comment">// Create the billboard (in the screen at pos (NbW*Width, 0)</font> +<a name="l00509"></a><a class="code" href="classNL3D_1_1CCloud.html#a9">00509</a> <font class="keywordtype">void</font> CCloud::genBill (CCamera *pCam, uint32 nBillSize) +00510 { +00511 uint32 sizeTMP = <a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a>; +00512 uint8 *MemTMP = <a class="code" href="classNL3D_1_1CCloud.html#o20">_MemOldBill</a>; +00513 CSmartPtr<CTextureMem> TexTMP = <a class="code" href="classNL3D_1_1CCloud.html#o21">_TexOldBill</a>; +00514 +00515 <a class="code" href="classNL3D_1_1CCloud.html#o19">_OldBillSize</a> = <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>; +00516 <a class="code" href="classNL3D_1_1CCloud.html#o20">_MemOldBill</a> = <a class="code" href="classNL3D_1_1CCloud.html#o17">_MemBill</a>; +00517 <a class="code" href="classNL3D_1_1CCloud.html#o21">_TexOldBill</a> = <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>; +00518 <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a> = sizeTMP; +00519 <a class="code" href="classNL3D_1_1CCloud.html#o17">_MemBill</a> = MemTMP; +00520 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a> = TexTMP; +00521 +00522 <font class="comment">// Check the new size of the billboard</font> +00523 <font class="keywordflow">if</font> (nBillSize != <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>) +00524 { +00525 <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a> = nBillSize; +00526 <a class="code" href="classNL3D_1_1CCloud.html#o17">_MemBill</a> = <font class="keyword">new</font> uint8[4*<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>*<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>]; +00527 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a> = <font class="keyword">new</font> CTextureMem (<a class="code" href="classNL3D_1_1CCloud.html#o17">_MemBill</a>, 4*<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>*<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>, <font class="keyword">true</font>, <font class="keyword">false</font>, <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>, <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>); +00528 <font class="comment">//for (i = 0; i < 4*_BillSize*_BillSize; ++i) _MemBill[i] = (uint8)i;</font> +00529 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>->setWrapS (ITexture::Clamp); +00530 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>->setWrapT (ITexture::Clamp); +00531 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>->setFilterMode (ITexture::Linear, ITexture::LinearMipMapOff); +00532 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>->setReleasable (<font class="keyword">false</font>); +00533 <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>->generate(); +00534 } +00535 +00536 CViewport viewport, viewportOLD; +00537 viewportOLD.initFullScreen(); +00538 uint32 nScreenW, nScreenH; +00539 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a56">getWindowSize</a> (nScreenW, nScreenH); +00540 viewport.init(0.0f, 0.0f, ((<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>+1)/((<font class="keywordtype">float</font>)nScreenW), ((<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>+1)/((<font class="keywordtype">float</font>)nScreenH)); +00541 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a51">setupViewport</a> (viewport); +00542 +00543 <font class="comment">//CMatrix CamMat = pCam->getMatrix();</font> +00544 <font class="comment">//CVector Viewer = CamMat.getPos();</font> +00545 CVector Viewer = CVector (0,0,0); +00546 CVector Center = CVector (<a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>/2, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>/2, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>/2); +00547 CVector Size = <a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>; +00548 CVector I, J, K; +00549 <font class="keywordtype">float</font> Left, Right, Top, Bottom, Near, Far; +00550 +00551 <a class="code" href="classNL3D_1_1CCloud.html#c1">calcBill</a> (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far); +00552 +00553 CMatrix mat; +00554 mat.identity(); +00555 mat.setRot(I,J,K, <font class="keyword">true</font>); +00556 mat.setPos(CVector(Viewer.x, Viewer.y, Viewer.z)); +00557 mat.invert(); +00558 +00559 <font class="comment">// Clear background for cloud creation</font> +00560 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a23">setFrustum</a>(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, <font class="keyword">false</font>); +00561 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a24">setupViewMatrix</a> (CMatrix::Identity); +00562 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a26">setupModelMatrix</a> (CMatrix::Identity); +00563 +00564 CVertexBuffer &rVB = <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_VertexBuffer; +00565 uint32 nVSize = rVB.getVertexSize (); +00566 CVector *pVertices = (CVector*)rVB.getVertexCoordPointer (0); +00567 *pVertices = CVector(0.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00568 *pVertices = CVector(1.0f, 0.0f, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00569 *pVertices = CVector(1.0f, 0.0f, 1.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00570 *pVertices = CVector(0.0f, 0.0f, 1.0f); +00571 +00572 <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatClear.setColor (CRGBA(0,0,0,0)); +00573 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (rVB); +00574 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (<a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatClear, 0, 1); +00575 +00576 <font class="comment">// Render </font> +00577 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a23">setFrustum</a>(Left, Right, Bottom, Top, Near, Far); +00578 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a24">setupViewMatrix</a>(mat); +00579 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a26">setupModelMatrix</a> (CMatrix::Identity); +00580 +00581 <a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->ToBill.setColor (<a class="code" href="classNL3D_1_1CCloud.html#m3">CloudAmbient</a>); +00582 <a class="code" href="classNL3D_1_1CCloud.html#a8">dispXYZ</a> (&<a class="code" href="classNL3D_1_1CCloud.html#o14">_CloudTexTmp</a>->ToBill); +00583 +00584 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a61">copyFrameBufferToTexture</a> (<a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>, 0, 0, 0, 0, 0, <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>, <a class="code" href="classNL3D_1_1CCloud.html#o16">_BillSize</a>); +00585 +00586 <font class="comment">// This is the end of render to texture like so reset all stuff</font> +00587 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a51">setupViewport</a> (viewportOLD); +00588 +00589 <a class="code" href="classNL3D_1_1CCloud.html#o25">_BillOldCenter</a> = <a class="code" href="classNL3D_1_1CCloud.html#o24">_BillCenter</a>; +00590 <a class="code" href="classNL3D_1_1CCloud.html#o23">_BillViewer</a> = Viewer; +00591 <a class="code" href="classNL3D_1_1CCloud.html#o24">_BillCenter</a> = Center; +00592 +00593 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#o22">_WaitState</a> > 0) +00594 <a class="code" href="classNL3D_1_1CCloud.html#o22">_WaitState</a> = <a class="code" href="classNL3D_1_1CCloud.html#o22">_WaitState</a> - 1; +00595 +00596 <a class="code" href="classNL3D_1_1CCloud.html#o7">_LastX</a> = <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>; +00597 } +00598 +00599 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +<a name="l00600"></a><a class="code" href="classNL3D_1_1CCloud.html#a10">00600</a> <font class="keywordtype">void</font> CCloud::dispBill (CCamera *pCam) +00601 { +00602 <font class="comment">// CMatrix CamMat = pCam->getMatrix();</font> +00603 <font class="comment">// CVector Viewer = CamMat.getPos();</font> +00604 CVector Viewer = CVector (0,0,0); +00605 CVector Center = CVector (<a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>/2, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>/2, <a class="code" href="classNL3D_1_1CCloud.html#o6">_Pos</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>+<a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a>/2); +00606 CVector Size = <a class="code" href="classNL3D_1_1CCloud.html#o5">_Size</a>; +00607 +00608 <font class="comment">// Prepare vertices.</font> +00609 CQuadUV qc; +00610 +00611 CVector I, J, K; +00612 <font class="keywordtype">float</font> Left, Right, Top, Bottom, Near, Far; +00613 +00614 <font class="keywordflow">if</font> ((<a class="code" href="classNL3D_1_1CCloud.html#o17">_MemBill</a> == NULL) || (<a class="code" href="classNL3D_1_1CCloud.html#o20">_MemOldBill</a> == NULL)) +00615 <font class="keywordflow">return</font>; +00616 +00617 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#o22">_WaitState</a> > 0) +00618 <font class="keywordflow">return</font>; +00619 +00620 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#m0">Time</a> > <a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a>) +00621 <a class="code" href="classNL3D_1_1CCloud.html#m0">Time</a> = <a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a>; +00622 +00623 <font class="comment">// take old computed bill.</font> +00624 Viewer= <a class="code" href="classNL3D_1_1CCloud.html#o23">_BillViewer</a>; +00625 <font class="comment">/* Center= _BillCenter*((float)(Trans)/(float)TransTotal) +</font> +00626 <font class="comment"> _BillOldCenter*((float)(TransTotal-Trans)/(float)TransTotal);</font> +00627 <font class="comment"></font> +00628 <font class="comment"> calcBill (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far);</font> +00629 <font class="comment"></font> +00630 <font class="comment"></font> +00631 <font class="comment"> CVector lct = Viewer + J*Near;</font> +00632 <font class="comment"> qc.V0 = lct + I*Left + K*Bottom;</font> +00633 <font class="comment"> qc.V1 = lct + I*Right + K*Bottom;</font> +00634 <font class="comment"> qc.V2 = lct + I*Right + K*Top;</font> +00635 <font class="comment"> qc.V3 = lct + I*Left + K*Top;*/</font> +00636 +00637 Center= <a class="code" href="classNL3D_1_1CCloud.html#o24">_BillCenter</a>; +00638 <a class="code" href="classNL3D_1_1CCloud.html#c1">calcBill</a> (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far); +00639 CVector lct = Viewer + J*Near; +00640 CQuadUV qc0; +00641 qc0.V0 = lct + I*Left + K*Bottom; +00642 qc0.V1 = lct + I*Right + K*Bottom; +00643 qc0.V2 = lct + I*Right + K*Top; +00644 qc0.V3 = lct + I*Left + K*Top; +00645 +00646 Center= <a class="code" href="classNL3D_1_1CCloud.html#o25">_BillOldCenter</a>; +00647 <a class="code" href="classNL3D_1_1CCloud.html#c1">calcBill</a> (Viewer, Center, Size, I, J, K, Left, Right, Top, Bottom, Near, Far); +00648 lct = Viewer + J*Near; +00649 CQuadUV qc1; +00650 qc1.V0 = lct + I*Left + K*Bottom; +00651 qc1.V1 = lct + I*Right + K*Bottom; +00652 qc1.V2 = lct + I*Right + K*Top; +00653 qc1.V3 = lct + I*Left + K*Top; +00654 +00655 <font class="keywordtype">float</font> a0= ((float)(Time)/(float)<a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a>); +00656 <font class="keywordtype">float</font> a1= (float)(<a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a>-<a class="code" href="classNL3D_1_1CCloud.html#m0">Time</a>)/(float)<a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a>; +00657 qc.V0= qc0.V0*a0 + qc1.V0*a1; +00658 qc.V1= qc0.V1*a0 + qc1.V1*a1; +00659 qc.V2= qc0.V2*a0 + qc1.V2*a1; +00660 qc.V3= qc0.V3*a0 + qc1.V3*a1; +00661 +00662 qc.Uv0 = CUV(0, 0); +00663 qc.Uv1 = CUV(1, 0); +00664 qc.Uv2 = CUV(1, 1); +00665 qc.Uv3 = CUV(0, 1); +00666 +00667 <font class="comment">// Display TexBill with intensity : Trans / TransTotal</font> +00668 <font class="comment">// and TexOldBill with intensity : (TransTotal-Trans) / TransTotal</font> +00669 +00670 <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatBill.setTexture (0, <a class="code" href="classNL3D_1_1CCloud.html#o21">_TexOldBill</a>); +00671 <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatBill.setTexture (1, <a class="code" href="classNL3D_1_1CCloud.html#o18">_TexBill</a>); +00672 <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatBill.setColor (CRGBA(255, 255, 255, (uint8)(255*((<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#m0">Time</a>/(<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a>)))); +00673 CVertexBuffer &rVB = <a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_VertexBuffer; +00674 uint32 nVSize = rVB.getVertexSize (); +00675 CVector *pVertices = (CVector*)rVB.getVertexCoordPointer (0); +00676 *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00677 *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00678 *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize ); +00679 *pVertices = qc.V3; +00680 +00681 CUV *pUV = (CUV*)rVB.getTexCoordPointer (0, 0); +00682 pUV->U = 0; pUV->V = 0; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00683 pUV->U = 1; pUV->V = 0; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00684 pUV->U = 1; pUV->V = 1; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00685 pUV->U = 0; pUV->V = 1; +00686 +00687 pUV = (CUV*)rVB.getTexCoordPointer (0, 1); +00688 pUV->U = 0; pUV->V = 0; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00689 pUV->U = 1; pUV->V = 0; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00690 pUV->U = 1; pUV->V = 1; pUV = (CUV*)( ((uint8*)pUV) + nVSize ); +00691 pUV->U = 0; pUV->V = 1; +00692 +00693 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (rVB); +00694 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (<a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->_MatBill, 0, 1); +00695 +00696 <font class="comment">//nlinfo ("ok");</font> +00697 +00698 +00699 <font class="comment">// Debug</font> +00700 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#o13">_CloudScape</a>->isDebugQuadEnabled()) +00701 { +00702 <font class="keyword">static</font> CMaterial *mTmp = NULL; +00703 <font class="keywordflow">if</font> (mTmp == NULL) +00704 { +00705 mTmp = <font class="keyword">new</font> CMaterial(); +00706 mTmp->setBlend(<font class="keyword">false</font>); +00707 mTmp->setDoubleSided(<font class="keyword">true</font>); +00708 } +00709 <font class="comment">/*if (_BillSize <= 4)</font> +00710 <font class="comment"> mTmp->setColor(CRGBA(0,127,0,255));</font> +00711 <font class="comment"> else if (_BillSize == 8)</font> +00712 <font class="comment"> mTmp->setColor(CRGBA(0,255,0,255));</font> +00713 <font class="comment"> else if (_BillSize == 16)</font> +00714 <font class="comment"> mTmp->setColor(CRGBA(127,255,0,255));</font> +00715 <font class="comment"> else if (_BillSize == 32)</font> +00716 <font class="comment"> mTmp->setColor(CRGBA(255,255,0,255));</font> +00717 <font class="comment"> else if (_BillSize == 64)</font> +00718 <font class="comment"> mTmp->setColor(CRGBA(255,127,0,255));</font> +00719 <font class="comment"> else if (_BillSize == 128)</font> +00720 <font class="comment"> mTmp->setColor(CRGBA(255,0,0,255));</font> +00721 <font class="comment"> else if (_BillSize == 256)</font> +00722 <font class="comment"> mTmp->setColor(CRGBA(127,0,0,255));*/</font> +00723 +00724 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a> <= 4) +00725 mTmp->setColor(CRGBA(0,127,0,255)); +00726 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a> <= 8) +00727 mTmp->setColor(CRGBA(0,255,0,255)); +00728 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a> <= 12) +00729 mTmp->setColor(CRGBA(127,255,0,255)); +00730 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a> <= 16) +00731 mTmp->setColor(CRGBA(255,255,0,255)); +00732 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CCloud.html#m1">FuturTime</a> <= 20) +00733 mTmp->setColor(CRGBA(255,127,0,255)); +00734 <font class="keywordflow">else</font> +00735 mTmp->setColor(CRGBA(255,0,0,255)); +00736 +00737 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a63">setPolygonMode</a>(IDriver::Line); +00738 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (*mTmp, 0, 1); +00739 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a63">setPolygonMode</a>(IDriver::Filled); +00740 } +00741 +00742 } +00743 +00744 <font class="comment">// ------------------------------------------------------------------------------------------------</font> +<a name="l00745"></a><a class="code" href="classNL3D_1_1CCloud.html#c0">00745</a> <font class="keywordtype">void</font> CCloud::setMode2D () +00746 { +00747 CVector I(1,0,0), J(0,0,1), K(0,-1,0); +00748 CMatrix ViewMatrix; +00749 ViewMatrix.identity (); +00750 ViewMatrix.setRot (I,J,K, <font class="keyword">true</font>); +00751 CScissor Scissor; +00752 Scissor.initFullScreen(); +00753 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a52">setupScissor</a> (Scissor); +00754 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a51">setupViewport</a> (CViewport()); +00755 uint32 nScreenW, nScreenH; +00756 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a56">getWindowSize</a> (nScreenW, nScreenH); +00757 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a23">setFrustum</a> (0, (<font class="keywordtype">float</font>)nScreenW, 0, (<font class="keywordtype">float</font>)nScreenH, -1, 1, <font class="keyword">false</font>); +00758 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a24">setupViewMatrix</a> (ViewMatrix); +00759 <a class="code" href="classNL3D_1_1CCloud.html#o26">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a26">setupModelMatrix</a> (CMatrix::Identity); +00760 } +00761 +00762 } <font class="comment">// namespace NL3D</font> +00763 +</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> |