Equalizer  1.2.1
eqPly/vertexBufferBase.h
00001 
00002 /* Copyright (c) 2007, Tobias Wolf <twolf@access.unizh.ch>
00003  *               2008-2011, 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         {
00065             return _boundingSphere;
00066         }
00067         
00068         const float* getRange() const
00069         {
00070             return &_range[0];
00071         }
00072         
00073         virtual const VertexBufferBase* getLeft() const { return 0; }
00074         virtual const VertexBufferBase* getRight() const { return 0; }
00075 
00076         virtual const BoundingSphere& updateBoundingSphere() = 0;
00077                 
00078     protected:
00079         VertexBufferBase() : _boundingSphere( 0.0f ) 
00080         {
00081             _range[0] = 0.0f;
00082             _range[1] = 1.0f;
00083         }
00084         
00085         virtual void toStream( std::ostream& os )
00086         {
00087             os.write( reinterpret_cast< char* >( &_boundingSphere ), 
00088                       sizeof( BoundingSphere ) );
00089             os.write( reinterpret_cast< char* >( &_range ), 
00090                       sizeof( Range ) );
00091         }
00092         
00093         virtual void fromMemory( char** addr, VertexBufferData& globalData )
00094         {
00095             memRead( reinterpret_cast< char* >( &_boundingSphere ), addr, 
00096                      sizeof( BoundingSphere ) );
00097             memRead( reinterpret_cast< char* >( &_range ), addr, 
00098                      sizeof( Range ) );
00099         }
00100         
00101         virtual void setupTree( VertexData& data, const Index start,
00102                                 const Index length, const Axis axis,
00103                                 const size_t depth,
00104                                 VertexBufferData& globalData ) = 0;
00105         
00106         virtual void updateRange() = 0;
00107         
00108         BoundingSphere  _boundingSphere;
00109         Range           _range;
00110         friend class eqPly::VertexBufferDist;
00111 
00112     private:
00113     };
00114 }
00115 
00116 #endif // MESH_VERTEXBUFFERBASE_H
Generated on Fri Jun 8 2012 15:44:32 for Equalizer 1.2.1 by  doxygen 1.8.0