Equalizer  1.4.1
eqPly/vertexBufferBase.h
00001 
00002 /* Copyright (c) 2007, Tobias Wolf <twolf@access.unizh.ch>
00003  *               2008-2012, Stefan Eilemann <eile@equalizergraphics.com>
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  * - Redistributions of source code must retain the above copyright notice, this
00009  *   list of conditions and the following disclaimer.
00010  * - Redistributions in binary form must reproduce the above copyright notice,
00011  *   this list of conditions and the following disclaimer in the documentation
00012  *   and/or other materials provided with the distribution.
00013  * - Neither the name of Eyescale Software GmbH nor the names of its
00014  *   contributors may be used to endorse or promote products derived from this
00015  *   software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028   
00029     
00030     Header file of the abstract VertexBufferBase class.
00031 */
00032 
00033 
00034 #ifndef MESH_VERTEXBUFFERBASE_H
00035 #define MESH_VERTEXBUFFERBASE_H
00036 
00037 
00038 #include "typedefs.h"
00039 #include <fstream>
00040 
00041 namespace eqPly
00042 {
00043     class VertexBufferDist;
00044 }
00045 
00046 namespace mesh 
00047 {
00048     // defined elsewhere
00049     class VertexData;
00050     class VertexBufferData;
00051     class VertexBufferState;
00052         
00053     /*  The abstract base class for all kinds of kd-tree nodes.  */
00054     class VertexBufferBase
00055     {
00056     public:
00057         virtual ~VertexBufferBase() {};
00058 
00059         virtual void draw( VertexBufferState& state ) const = 0;
00060         void drawBoundingSphere( VertexBufferState& state ) const;
00061         virtual Index getNumberOfVertices() const = 0;
00062 
00063         const BoundingSphere& getBoundingSphere() const 
00064             { return _boundingSphere; }
00065         
00066         const float* getRange() const { return &_range[0]; }
00067 
00068         virtual const VertexBufferBase* getLeft() const { return 0; }
00069         virtual const VertexBufferBase* getRight() const { return 0; }
00070 
00071         virtual const BoundingSphere& updateBoundingSphere() = 0;
00072 
00073     protected:
00074         VertexBufferBase() : _boundingSphere( 0.0f ) 
00075         {
00076             _range[0] = 0.0f;
00077             _range[1] = 1.0f;
00078         }
00079         
00080         virtual void toStream( std::ostream& os )
00081         {
00082             os.write( reinterpret_cast< char* >( &_boundingSphere ), 
00083                       sizeof( BoundingSphere ) );
00084             os.write( reinterpret_cast< char* >( &_range ), sizeof( Range ) );
00085         }
00086         
00087         virtual void fromMemory( char** addr, VertexBufferData& globalData )
00088         {
00089             memRead( reinterpret_cast< char* >( &_boundingSphere ), addr, 
00090                      sizeof( BoundingSphere ) );
00091             memRead( reinterpret_cast< char* >( &_range ), addr, 
00092                      sizeof( Range ) );
00093         }
00094         
00095         virtual void setupTree( VertexData& data, const Index start,
00096                                 const Index length, const Axis axis,
00097                                 const size_t depth,
00098                                 VertexBufferData& globalData ) = 0;
00099         
00100         virtual void updateRange() = 0;
00101         
00102         BoundingSphere  _boundingSphere;
00103         Range           _range;
00104         friend class eqPly::VertexBufferDist;
00105 
00106     private:
00107     };
00108 }
00109 
00110 #endif // MESH_VERTEXBUFFERBASE_H
Generated on Mon Nov 26 2012 14:41:49 for Equalizer 1.4.1 by  doxygen 1.7.6.1