30 #include "frameData.h"
35 FrameData::FrameData()
37 , _modelRotation( eq::
Matrix4f::ZERO )
39 , _renderMode( mesh::RENDER_MODE_DISPLAY_LIST )
43 , _statistics( false )
48 , _compression( true )
55 co::Serializable::serialize( os, dirtyBits );
56 if( dirtyBits & DIRTY_CAMERA )
57 os << _position << _rotation << _modelRotation;
58 if( dirtyBits & DIRTY_FLAGS )
59 os << _modelID << _renderMode << _colorMode << _quality << _ortho
60 << _statistics << _help << _wireframe << _pilotMode << _idle
62 if( dirtyBits & DIRTY_VIEW )
64 if( dirtyBits & DIRTY_MESSAGE )
70 co::Serializable::deserialize( is, dirtyBits );
71 if( dirtyBits & DIRTY_CAMERA )
72 is >> _position >> _rotation >> _modelRotation;
73 if( dirtyBits & DIRTY_FLAGS )
74 is >> _modelID >> _renderMode >> _colorMode >> _quality >> _ortho
75 >> _statistics >> _help >> _wireframe >> _pilotMode >> _idle
77 if( dirtyBits & DIRTY_VIEW )
79 if( dirtyBits & DIRTY_MESSAGE )
83 void FrameData::setModelID(
const eq::uint128_t&
id )
89 setDirty( DIRTY_FLAGS );
92 void FrameData::setColorMode(
const ColorMode mode )
95 setDirty( DIRTY_FLAGS );
98 void FrameData::setRenderMode(
const mesh::RenderMode mode )
101 setDirty( DIRTY_FLAGS );
104 void FrameData::setIdle(
const bool idle )
110 setDirty( DIRTY_FLAGS );
113 void FrameData::toggleOrtho()
116 setDirty( DIRTY_FLAGS );
119 void FrameData::toggleStatistics()
121 _statistics = !_statistics;
122 setDirty( DIRTY_FLAGS );
125 void FrameData::toggleHelp()
128 setDirty( DIRTY_FLAGS );
131 void FrameData::toggleWireframe()
133 _wireframe = !_wireframe;
134 setDirty( DIRTY_FLAGS );
137 void FrameData::toggleColorMode()
139 _colorMode =
static_cast< ColorMode >(( _colorMode + 1) % COLOR_ALL );
140 setDirty( DIRTY_FLAGS );
143 void FrameData::adjustQuality(
const float delta )
146 _quality = LB_MAX( _quality, 0.1f );
147 _quality = LB_MIN( _quality, 1.0f );
148 setDirty( DIRTY_FLAGS );
149 LBINFO <<
"Set non-idle image quality to " << _quality << std::endl;
152 void FrameData::togglePilotMode()
154 _pilotMode = !_pilotMode;
155 setDirty( DIRTY_FLAGS );
158 void FrameData::toggleRenderMode()
160 _renderMode =
static_cast< mesh::RenderMode
>(
161 ( _renderMode + 1) % mesh::RENDER_MODE_ALL );
163 LBINFO <<
"Switched to " << _renderMode << std::endl;
164 setDirty( DIRTY_FLAGS );
167 void FrameData::toggleCompression()
169 _compression = !_compression;
170 setDirty( DIRTY_FLAGS );
173 void FrameData::spinCamera(
const float x,
const float y )
175 if( x == 0.f && y == 0.f )
178 _rotation.pre_rotate_x( x );
179 _rotation.pre_rotate_y( y );
180 setDirty( DIRTY_CAMERA );
183 void FrameData::spinModel(
const float x,
const float y,
const float z )
185 if( x == 0.f && y == 0.f && z == 0.f )
188 _modelRotation.pre_rotate_x( x );
189 _modelRotation.pre_rotate_y( y );
190 _modelRotation.pre_rotate_z( z );
191 setDirty( DIRTY_CAMERA );
194 void FrameData::moveCamera(
const float x,
const float y,
const float z )
198 eq::Matrix4f matInverse;
199 compute_inverse( _rotation, matInverse );
200 eq::Vector4f shift = matInverse * eq::Vector4f( x, y, z, 1 );
211 setDirty( DIRTY_CAMERA );
214 void FrameData::setCameraPosition(
const eq::Vector3f& position )
216 _position = position;
217 setDirty( DIRTY_CAMERA );
220 void FrameData::setRotation(
const eq::Vector3f& rotation )
222 _rotation = eq::Matrix4f::IDENTITY;
223 _rotation.rotate_x( rotation.x() );
224 _rotation.rotate_y( rotation.y() );
225 _rotation.rotate_z( rotation.z() );
226 setDirty( DIRTY_CAMERA );
229 void FrameData::setModelRotation(
const eq::Vector3f& rotation )
231 _modelRotation = eq::Matrix4f::IDENTITY;
232 _modelRotation.rotate_x( rotation.x() );
233 _modelRotation.rotate_y( rotation.y() );
234 _modelRotation.rotate_z( rotation.z() );
235 setDirty( DIRTY_CAMERA );
238 void FrameData::reset()
240 eq::Matrix4f model = eq::Matrix4f::IDENTITY;
241 model.rotate_x( static_cast<float>( -M_PI_2 ));
242 model.rotate_y( static_cast<float>( -M_PI_2 ));
244 if( _position == eq::Vector3f( 0.f, 0.f, -2.f ) &&
245 _rotation == eq::Matrix4f::IDENTITY && _modelRotation == model )
251 _position = eq::Vector3f::ZERO;
252 _position.z() = -2.f;
253 _rotation = eq::Matrix4f::IDENTITY;
254 _modelRotation = model;
256 setDirty( DIRTY_CAMERA );
259 void FrameData::setCurrentViewID(
const eq::uint128_t&
id )
262 setDirty( DIRTY_VIEW );
265 void FrameData::setMessage(
const std::string& message )
267 if( _message == message )
271 setDirty( DIRTY_MESSAGE );
virtual void deserialize(co::DataIStream &is, const uint64_t dirtyBits)
Render using the colors defined in the ply file.
vmml::vector< 3, float > Vector3f
A three-component float vector.
virtual void serialize(co::DataOStream &os, const uint64_t dirtyBits)
vmml::matrix< 4, 4, float > Matrix4f
A 4x4 float matrix.