Equalizer 1.0

vertexBufferBase.h

00001 
00002 /* Copyright (c) 2007, Tobias Wolf <twolf@access.unizh.ch>
00003  * Copyright (c) 2008, 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 void render( VertexBufferState& state ) const = 0;
00058         void renderBoundingSphere( VertexBufferState& state ) const;
00059         virtual Index getNumberOfVertices() const = 0;
00060 
00061         const BoundingSphere& getBoundingSphere() const 
00062         {
00063             return _boundingSphere;
00064         }
00065         
00066         const float* getRange() const
00067         {
00068             return &_range[0];
00069         }
00070         
00071         virtual const VertexBufferBase* getLeft() const { return 0; }
00072         virtual const VertexBufferBase* getRight() const { return 0; }
00073 
00074         virtual const BoundingSphere& updateBoundingSphere() = 0;
00075                 
00076     protected:
00077         VertexBufferBase() : _boundingSphere( 0.0f ) 
00078         {
00079             _range[0] = 0.0f;
00080             _range[1] = 1.0f;
00081         }
00082         
00083         virtual ~VertexBufferBase() {};
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 
00117 #endif // MESH_VERTEXBUFFERBASE_H
Generated on Sun May 8 2011 19:11:07 for Equalizer 1.0 by  doxygen 1.7.3