From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/mesh__blender_8cpp-source.html | 275 ++++++++++++++++++++++++ 1 file changed, 275 insertions(+) create mode 100644 docs/doxygen/nel/mesh__blender_8cpp-source.html (limited to 'docs/doxygen/nel/mesh__blender_8cpp-source.html') diff --git a/docs/doxygen/nel/mesh__blender_8cpp-source.html b/docs/doxygen/nel/mesh__blender_8cpp-source.html new file mode 100644 index 00000000..11c6821c --- /dev/null +++ b/docs/doxygen/nel/mesh__blender_8cpp-source.html @@ -0,0 +1,275 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

mesh_blender.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000-2002 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "std3d.h"
+00027 
+00028 #include "3d/mesh_blender.h"
+00029 #include "3d/driver.h"
+00030 #include "3d/fast_floor.h"
+00031 
+00032 
+00033 namespace NL3D {
+00034 
+00035 
+00036 // ***************************************************************************
+00037 void            CMeshBlender::prepareRenderForGlobalAlpha(CMaterial &material, IDriver *drv, float globalAlpha, uint8 globalAlphaInt, bool gaDisableZWrite)
+00038 {
+00039         // Disable ZWrite??
+00040         if(gaDisableZWrite)
+00041         {
+00042                 // Backup and set new the zwrite
+00043                 _BkZWrite=material.getZWrite ();
+00044                 material.setZWrite (false);
+00045         }
+00046 
+00047         // Backup blend
+00048         _BkBlend=material.getBlend ();
+00049         material.setBlend (true);
+00050 
+00051         // Backup opacity and blend
+00052         _BkOpacity= material.getOpacity ();
+00053         _BkSrcBlend= material.getSrcBlend();
+00054         _BkDstBlend= material.getDstBlend();
+00055 
+00056         // 2 ways: if Blend Constant Color is supported or not.
+00057         if(drv->supportBlendConstantColor())
+00058         {
+00059                 // Set opacity to 255 => If AlphaTest is used, AlphaTexture will be multiplied by 1.
+00060                 material.setOpacity ( 255 );
+00061 
+00062                 // set the Blend constant Alpha.
+00063                 drv->setBlendConstantColor( CRGBA(0,0,0, globalAlphaInt) );
+00064 
+00065                 // Active Blend with Blend Constant Alpha .
+00066                 material.setSrcBlend(CMaterial::blendConstantAlpha);
+00067 
+00068                 // Don't set dest if we are in additive blend mode
+00069                 if ((_BkBlend == false) || (_BkDstBlend != CMaterial::one))
+00070                         material.setDstBlend(CMaterial::blendConstantInvAlpha);
+00071 
+00072                 // if material is Alpha Test, no-op. Keep same threshold, since Use Alpha of the BlendConstantColor
+00073                 // to do the alpha-blending.
+00074         }
+00075         // not supported, ugly way: modify Opacity, and alpha threshold
+00076         else
+00077         {
+00078                 // New opacity
+00079                 material.setOpacity (globalAlphaInt);
+00080 
+00081                 // must ensure Std Blend.
+00082                 material.setSrcBlend(CMaterial::srcalpha);
+00083 
+00084                 // Don't set dest if we are in additive blend mode
+00085                 if ((_BkBlend == false) || (_BkDstBlend != CMaterial::one))
+00086                         material.setDstBlend(CMaterial::invsrcalpha);
+00087 
+00088                 // if material is Alpha Test, must modulate AlphaTest limit to avoid Pop effects
+00089                 if(material.getAlphaTest())
+00090                 {
+00091                         _BkAlphaTestThreshold= material.getAlphaTestThreshold();
+00092                         material.setAlphaTestThreshold(_BkAlphaTestThreshold * globalAlpha);
+00093                 }
+00094         }
+00095 
+00096 }
+00097 
+00098 // ***************************************************************************
+00099 void            CMeshBlender::restoreRender(CMaterial &material, IDriver *drv, bool gaDisableZWrite)
+00100 {
+00101         // Resetup backuped zwrite
+00102         if(gaDisableZWrite)
+00103         {
+00104                 material.setZWrite (_BkZWrite);
+00105         }
+00106 
+00107         // Resetup backuped blend
+00108         material.setBlend (_BkBlend);
+00109 
+00110         // Resetup backuped opacity and blend factors
+00111         material.setOpacity (_BkOpacity);
+00112         material.setSrcBlend(_BkSrcBlend);
+00113         material.setDstBlend(_BkDstBlend);
+00114 
+00115         // 2 ways: if Blend Constant Color is supported or not.
+00116         if(drv->supportBlendConstantColor())
+00117         {
+00118                 // nop
+00119         }
+00120         else
+00121         {
+00122                 // Resetup backuped AlphaTest threshold
+00123                 if(material.getAlphaTest())
+00124                 {
+00125                         material.setAlphaTestThreshold(_BkAlphaTestThreshold);
+00126                 }
+00127         }
+00128 }
+00129 
+00130 
+00131 // ***************************************************************************
+00132 void            CMeshBlender::prepareRenderForGlobalAlphaCoarseMesh(CMaterial &material, IDriver *drv, NLMISC::CRGBA color, float globalAlpha, bool gaDisableZWrite)
+00133 {
+00134         // Don't need to bkup some values, because CoarseMesh.
+00135 
+00136         uint8   globalAlphaInt= (uint8)OptFastFloor(255 * globalAlpha);
+00137 
+00138         // Disable ZWrite??
+00139         if(gaDisableZWrite)
+00140                 material.setZWrite (false);
+00141         // Enable blend
+00142         material.setBlend (true);
+00143 
+00144         // bkup color and blend factors.
+00145         _BkupColor= material.getColor();
+00146         _BkSrcBlend= material.getSrcBlend();
+00147         _BkDstBlend= material.getDstBlend();
+00148 
+00149         // 2 ways: if Blend Constant Color is supported or not.
+00150         if(drv->supportBlendConstantColor())
+00151         {
+00152                 // Set opacity to 255 => AlphaTexture will be multiplied by 1.
+00153                 color.A= 255;
+00154                 // change color
+00155                 material.setColor ( color );
+00156 
+00157                 // set the Blend constant Alpha.
+00158                 drv->setBlendConstantColor( CRGBA(0,0,0, globalAlphaInt) );
+00159 
+00160                 // Active Blend with Blend Constant Alpha .
+00161                 material.setSrcBlend(CMaterial::blendConstantAlpha);
+00162                 material.setDstBlend(CMaterial::blendConstantInvAlpha);
+00163         }
+00164         else
+00165         {
+00166                 // Set current Alpha blend transparency (in color becausematerial is unlit)
+00167                 color.A= globalAlphaInt;
+00168                 // change color
+00169                 material.setColor ( color );
+00170 
+00171                 // Active Blend with Blend Constant Alpha .
+00172                 material.setSrcBlend(CMaterial::srcalpha);
+00173                 material.setDstBlend(CMaterial::invsrcalpha);
+00174 
+00175                 // must modulate AlphaTest limit to avoid Pop effects
+00176                 material.setAlphaTestThreshold(0.5f * globalAlpha);
+00177         }
+00178 }
+00179 
+00180 // ***************************************************************************
+00181 void            CMeshBlender::restoreRenderCoarseMesh(CMaterial &material, IDriver *drv, bool gaDisableZWrite)
+00182 {
+00183         // Resetup backuped color and blend factors
+00184         material.setColor ( _BkupColor );
+00185         material.setSrcBlend(_BkSrcBlend);
+00186         material.setDstBlend(_BkDstBlend);
+00187 
+00188         // ReEnable ZWrite??
+00189         if(gaDisableZWrite)
+00190                 material.setZWrite (true);
+00191         // Reset blend
+00192         material.setBlend (false);
+00193         
+00194         // 2 ways: if Blend Constant Color is supported or not.
+00195         if(drv->supportBlendConstantColor())
+00196         {
+00197                 // nop
+00198         }
+00199         else
+00200         {
+00201                 // reset AlphaTest limit
+00202                 material.setAlphaTestThreshold(0.5f);
+00203         }
+00204 }
+00205 
+00206 } // NL3D
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1