# 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  

tile_far_bank.cpp

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 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/tile_far_bank.h"
00029 
00030 using namespace NLMISC;
00031 
00032 namespace NL3D {
00033 
00034 
00035 // ***************************************************************************
00036 // ***************************************************************************
00037 // CTileFarBank::CTileFar.
00038 // ***************************************************************************
00039 // ***************************************************************************
00040 
00041 // ***************************************************************************
00042 const sint CTileFarBank::CTileFar::_Version=0x0;
00043 // ***************************************************************************
00044 void CTileFarBank::CTileFar::serial(IStream &f) throw(NLMISC::EStream)
00045 {
00046         // Serial version
00047         (void)f.serialVersion(_Version);
00048 
00049         // Serial pixels
00050         f.serialCont (_Pixels[diffuse][order0]);
00051         f.serialCont (_Pixels[diffuse][order1]);
00052         f.serialCont (_Pixels[diffuse][order2]);
00053         f.serialCont (_Pixels[additive][order0]);
00054         f.serialCont (_Pixels[additive][order1]);
00055         f.serialCont (_Pixels[additive][order2]);
00056 }
00057 // ***************************************************************************
00058 void CTileFarBank::CTileFar::setPixels (TFarType type, TFarOrder order, NLMISC::CRGBA* pixels, uint size)
00059 {
00060         // Mode alpha ?
00061         if (type==alpha)
00062         {
00063                 _Pixels[diffuse][order].resize (size);
00064                 _Pixels[additive][order].resize (size);
00065 
00066                 // Copy only the alpha channel
00067                 for (uint p=0; p<size; p++)
00068                 {
00069                         _Pixels[diffuse][order][p].A=pixels[p].A;
00070                         _Pixels[additive][order][p].A=pixels[p].A;
00071                 }
00072         }
00073         else
00074         {
00075                 // Resize this array
00076                 _Pixels[type][order].resize (size);
00077 
00078                 // Copy all the channels
00079                 memcpy (&_Pixels[type][order][0], pixels, size*sizeof(NLMISC::CRGBA));
00080         }
00081 }
00082 
00083 
00084 // ***************************************************************************
00085 // ***************************************************************************
00086 // CTileFarBank.
00087 // ***************************************************************************
00088 // ***************************************************************************
00089 
00090 // ***************************************************************************
00091 CTileFarBank::CTileFarBank()
00092 {
00093 }
00094 
00095 // ***************************************************************************
00096 const sint CTileFarBank::_Version=0x0;
00097 // ***************************************************************************
00098 void CTileFarBank::serial(IStream &f) throw(NLMISC::EStream)
00099 {
00100         // Write/Check "FAR_BANK" in header of the stream
00101         f.serialCheck ((uint32)'_RAF');
00102         f.serialCheck ((uint32)'KNAB');
00103 
00104         // Serial version
00105         (void)f.serialVersion(_Version);
00106 
00107         // Serial tiles
00108         f.serialCont (_TileVector);
00109 }
00110 
00111 
00112 } // NL3D