00001 00002 /* Copyright (c) 2009, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 00004 * This library is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU Lesser General Public License version 2.1 as published 00006 * by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, but WITHOUT 00009 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00010 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00011 * details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this library; if not, write to the Free Software Foundation, Inc., 00015 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00016 */ 00017 00018 #include "frustum.h" 00019 00020 #include <eq/net/dataOStream.h> 00021 #include <eq/net/dataIStream.h> 00022 00023 namespace eq 00024 { 00025 00026 Frustum::Frustum() 00027 : _current( TYPE_NONE ) 00028 {} 00029 00030 Frustum::~Frustum() 00031 { 00032 _current = TYPE_NONE; 00033 } 00034 00035 void Frustum::serialize( net::DataOStream& os, const uint64_t dirtyBits ) 00036 { 00037 Object::serialize( os, dirtyBits ); 00038 if( dirtyBits & DIRTY_TYPE ) 00039 os << _current; 00040 if( dirtyBits & DIRTY_WALL ) 00041 os << _wall; 00042 if( dirtyBits & DIRTY_PROJECTION ) 00043 os << _projection; 00044 } 00045 00046 void Frustum::deserialize( net::DataIStream& is, const uint64_t dirtyBits ) 00047 { 00048 Object::deserialize( is, dirtyBits ); 00049 if( dirtyBits & DIRTY_TYPE ) 00050 is >> _current; 00051 if( dirtyBits & DIRTY_WALL ) 00052 is >> _wall; 00053 if( dirtyBits & DIRTY_PROJECTION ) 00054 is >> _projection; 00055 } 00056 00057 void Frustum::setWall( const Wall& wall ) 00058 { 00059 _wall = wall; 00060 _projection = wall; 00061 _current = TYPE_WALL; 00062 setDirty( DIRTY_TYPE | DIRTY_WALL ); 00063 } 00064 00065 void Frustum::setProjection( const Projection& projection ) 00066 { 00067 _projection = projection; 00068 _wall = projection; 00069 _current = TYPE_PROJECTION; 00070 setDirty( DIRTY_TYPE | DIRTY_PROJECTION ); 00071 } 00072 00073 void Frustum::unsetFrustum() 00074 { 00075 _current = TYPE_NONE; 00076 setDirty( DIRTY_TYPE ); 00077 } 00078 00079 std::ostream& operator << ( std::ostream& os, const Frustum& frustum ) 00080 { 00081 switch( frustum.getCurrentType( )) 00082 { 00083 case Frustum::TYPE_WALL: 00084 os << frustum.getWall(); 00085 break; 00086 case Frustum::TYPE_PROJECTION: 00087 os << frustum.getProjection(); 00088 break; 00089 case Frustum::TYPE_NONE: 00090 break; 00091 default: 00092 os << "INVALID FRUSTUM"; 00093 break; 00094 } 00095 return os; 00096 } 00097 }
0.9 by
1.5.8