# 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  

primitive_block.h

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 #ifndef NL_PRIMITIVE_BLOCK_H
00027 #define NL_PRIMITIVE_BLOCK_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include <vector>
00031 
00032 namespace NLMISC
00033 {
00034         class IStream;
00035 };
00036 
00037 namespace NL3D {
00038 
00039 
00044 /* *** IMPORTANT ********************
00045  * *** IF YOU MODIFY THE STRUCTURE OF THIS CLASS, PLEASE INCREMENT IDriver::InterfaceVersion TO INVALIDATE OLD DRIVER DLL
00046  * **********************************
00047  */
00048 class CPrimitiveBlock
00049 {
00050 private:
00051         // Triangles.
00052         uint32                          _NbTris;
00053         uint32                          _TriCapacity;
00054         std::vector<uint32>     _Tri;
00055 
00056         // Quads
00057         uint32                          _NbQuads;
00058         uint32                          _QuadCapacity;
00059         std::vector<uint32>     _Quad;
00060 
00061         // Lines
00062         uint32                          _NbLines;
00063         uint32                          _LineCapacity;
00064         std::vector<uint32>     _Line;
00065 
00067         // Strip/Fans
00068         uint32                          _StripIdx;
00069         uint32*                         _Strip;
00070         uint32                          _FanIdx;
00071         uint32*                         _Fan;
00072 public:
00073                                                 CPrimitiveBlock(void) 
00074                                                 {_TriCapacity=_NbTris= _NbQuads=_QuadCapacity=_NbLines=_LineCapacity= 0;};
00075                                                 ~CPrimitiveBlock(void) {}; 
00076         
00077         
00078         // Lines. A line is 2 uint32.
00079         
00081         void                            reserveLine(uint32 n);
00083         uint32                          capacityLine() const {return _LineCapacity;}
00085         void                            setNumLine(uint32 n);
00087         uint32                          getNumLine(void) const {return _NbLines;}
00088 
00090         void                            setLine(uint lineIdx, uint32 vidx0, uint32 vidx1);
00092         void                            addLine(uint32 vidx0, uint32 vidx1);
00093 
00094         uint32*                         getLinePointer(void);
00095         const uint32*                           getLinePointer(void) const ;
00096 
00097 
00098 
00099         // Triangles. A triangle is 3 uint32.
00100         
00102         void                            reserveTri(uint32 n);
00104         uint32                          capacityTri() {return _TriCapacity;}
00106         void                            setNumTri(uint32 n);
00108         uint32                          getNumTri(void) const {return _NbTris;}
00109 
00111         void                            setTri(uint triIdx, uint32 vidx0, uint32 vidx1, uint32 vidx2);
00113         void                            addTri(uint32 vidx0, uint32 vidx1, uint32 vidx2);
00114 
00115         uint32*                         getTriPointer(void);
00116         const uint32*                           getTriPointer(void) const ;
00117 
00118 
00119 
00120 
00121         // Quads (a quad is 4 uint32)
00122 
00126         void reserveQuad(uint32 n);
00127         
00131         uint32 capacityQuad() { return _QuadCapacity; }
00132         
00136         void setNumQuad(uint32 n);
00137         
00141         uint32 getNumQuad(void) const { return _NbQuads; }
00142 
00146         void setQuad(uint quadIdx, uint32 vidx0, uint32 vidx1, uint32 vidx2, uint32 vidx3);
00147 
00149         void                            addQuad(uint32 vidx0, uint32 vidx1, uint32 vidx2, uint32 vidx3);
00150 
00154         uint32* getQuadPointer(void);
00155 
00157         const uint32*   getQuadPointer(void) const ;
00158 
00160         uint32  getNumTriangles ()
00161         {
00162                 // Return number of triangles in this primitive block
00163                 return _NbTris+2*_NbQuads+_NbLines;
00164         }
00165 
00166         void            serial(NLMISC::IStream &f);
00167 };
00168 
00169 
00170 } // NL3D
00171 
00172 
00173 #endif // NL_PRIMITIVE_BLOCK_H
00174 
00175 /* End of primitive_block.h */