55 #include "SliceNode.hh"
60 namespace SceneGraph {
65 SliceNode::SliceNode(
BaseNode * _parent,
71 set_visible_box(
Vec3f( 0, 0, 0 ),
74 set_texture_box(
Vec3f( 0, 0, 0 ),
77 set_cursor(
Vec3f( 0.5, 0.5, 0.5 ) );
84 SliceNode::~SliceNode()
93 SliceNode::view_frame(
bool _view_frame )
95 view_frame_ = _view_frame;
105 _bbMin.minimize( visible_min_ );
106 _bbMax.maximize( visible_max_ );
134 if ( is_enabled( NONE ) )
137 glPushAttrib(GL_LIGHTING_BIT);
138 glPushAttrib(GL_ENABLE_BIT);
139 glPushAttrib(GL_COLOR_BUFFER_BIT);
145 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
169 SliceNode::draw_frame()
const
177 glColor3f( 1, 1, 1 );
179 glVertex3f( visible_min_[0], visible_min_[1], visible_min_[2] );
180 glVertex3f( visible_min_[0], visible_min_[1], visible_max_[2] );
181 glVertex3f( visible_min_[0], visible_max_[1], visible_min_[2] );
182 glVertex3f( visible_min_[0], visible_max_[1], visible_max_[2] );
183 glVertex3f( visible_max_[0], visible_max_[1], visible_min_[2] );
184 glVertex3f( visible_max_[0], visible_max_[1], visible_max_[2] );
185 glVertex3f( visible_max_[0], visible_min_[1], visible_min_[2] );
186 glVertex3f( visible_max_[0], visible_min_[1], visible_max_[2] );
188 glVertex3f( visible_min_[0], visible_min_[1], visible_min_[2] );
189 glVertex3f( visible_min_[0], visible_max_[1], visible_min_[2] );
190 glVertex3f( visible_min_[0], visible_min_[1], visible_max_[2] );
191 glVertex3f( visible_min_[0], visible_max_[1], visible_max_[2] );
192 glVertex3f( visible_max_[0], visible_min_[1], visible_min_[2] );
193 glVertex3f( visible_max_[0], visible_max_[1], visible_min_[2] );
194 glVertex3f( visible_max_[0], visible_min_[1], visible_max_[2] );
195 glVertex3f( visible_max_[0], visible_max_[1], visible_max_[2] );
197 glVertex3f( visible_min_[0], visible_min_[1], visible_min_[2] );
198 glVertex3f( visible_max_[0], visible_min_[1], visible_min_[2] );
199 glVertex3f( visible_min_[0], visible_min_[1], visible_max_[2] );
200 glVertex3f( visible_max_[0], visible_min_[1], visible_max_[2] );
201 glVertex3f( visible_min_[0], visible_max_[1], visible_min_[2] );
202 glVertex3f( visible_max_[0], visible_max_[1], visible_min_[2] );
203 glVertex3f( visible_min_[0], visible_max_[1], visible_max_[2] );
204 glVertex3f( visible_max_[0], visible_max_[1], visible_max_[2] );
210 glColor3f( 1, 1, 1 );
212 if ( is_enabled( XY_PLANE ) )
214 glVertex3f( visible_min_[0], visible_min_[1], cursor_[2] );
215 glVertex3f( visible_max_[0], visible_min_[1], cursor_[2] );
216 glVertex3f( visible_max_[0], visible_min_[1], cursor_[2] );
217 glVertex3f( visible_max_[0], visible_max_[1], cursor_[2] );
218 glVertex3f( visible_max_[0], visible_max_[1], cursor_[2] );
219 glVertex3f( visible_min_[0], visible_max_[1], cursor_[2] );
220 glVertex3f( visible_min_[0], visible_max_[1], cursor_[2] );
221 glVertex3f( visible_min_[0], visible_min_[1], cursor_[2] );
225 if ( is_enabled( YZ_PLANE ) )
227 glVertex3f( cursor_[0], visible_min_[1], visible_min_[2] );
228 glVertex3f( cursor_[0], visible_min_[1], visible_max_[2] );
229 glVertex3f( cursor_[0], visible_min_[1], visible_max_[2] );
230 glVertex3f( cursor_[0], visible_max_[1], visible_max_[2] );
231 glVertex3f( cursor_[0], visible_max_[1], visible_max_[2] );
232 glVertex3f( cursor_[0], visible_max_[1], visible_min_[2] );
233 glVertex3f( cursor_[0], visible_max_[1], visible_min_[2] );
234 glVertex3f( cursor_[0], visible_min_[1], visible_min_[2] );
238 if ( is_enabled( XZ_PLANE ) )
240 glVertex3f( visible_min_[0], cursor_[1], visible_min_[2] );
241 glVertex3f( visible_max_[0], cursor_[1], visible_min_[2] );
242 glVertex3f( visible_max_[0], cursor_[1], visible_min_[2] );
243 glVertex3f( visible_max_[0], cursor_[1], visible_max_[2] );
244 glVertex3f( visible_max_[0], cursor_[1], visible_max_[2] );
245 glVertex3f( visible_min_[0], cursor_[1], visible_max_[2] );
246 glVertex3f( visible_min_[0], cursor_[1], visible_max_[2] );
247 glVertex3f( visible_min_[0], cursor_[1], visible_min_[2] );
258 SliceNode::draw_planes()
const
263 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
271 for (
int i = 0; i < 3; ++i )
273 rel[i] = ( cursor_[i]-texture_min_[i] ) / ( texture_max_[i] - texture_min_[i] );
274 tcmin[i] = ( visible_min_[i] - texture_min_[i] )
275 / ( texture_max_[i] - texture_min_[i] );
276 tcmax[i] = ( visible_max_[i] - texture_min_[i] )
277 / ( texture_max_[i] - texture_min_[i] );
280 if ( cursor_[2] >= visible_min_[2] &&
281 cursor_[2] <= visible_max_[2] &&
282 is_enabled( XY_PLANE ) )
286 glNormal3f( 0, 0, 1 );
288 glTexCoord3f( tcmin[0], tcmin[1], rel[2] );
289 glVertex3f( visible_min_[0], visible_min_[1], cursor_[2] );
291 glTexCoord3f( tcmax[0], tcmin[1], rel[2] );
292 glVertex3f( visible_max_[0], visible_min_[1], cursor_[2] );
294 glTexCoord3f( tcmax[0], tcmax[1], rel[2] );
295 glVertex3f( visible_max_[0], visible_max_[1], cursor_[2] );
297 glTexCoord3f( tcmin[0], tcmax[1], rel[2] );
298 glVertex3f( visible_min_[0], visible_max_[1], cursor_[2] );
303 if ( cursor_[0] >= visible_min_[0] &&
304 cursor_[0] <= visible_max_[0] &&
305 is_enabled( YZ_PLANE ) )
309 glNormal3f( -1, 0, 0 );
311 glTexCoord3f( rel[0], tcmin[1], tcmin[2] );
312 glVertex3f( cursor_[0], visible_min_[1], visible_min_[2] );
314 glTexCoord3f( rel[0], tcmin[1], tcmax[2] );
315 glVertex3f( cursor_[0], visible_min_[1], visible_max_[2] );
317 glTexCoord3f( rel[0], tcmax[1], tcmax[2] );
318 glVertex3f( cursor_[0], visible_max_[1], visible_max_[2] );
320 glTexCoord3f( rel[0], tcmax[1], tcmin[2] );
321 glVertex3f( cursor_[0], visible_max_[1], visible_min_[2] );
326 if ( cursor_[1] >= visible_min_[1] &&
327 cursor_[1] <= visible_max_[1] &&
328 is_enabled( XZ_PLANE ) )
332 glNormal3f( 0, -1, 0 );
334 glTexCoord3f( tcmin[0], rel[1], tcmin[2] );
335 glVertex3f( visible_min_[0], cursor_[1], visible_min_[2] );
337 glTexCoord3f( tcmax[0], rel[1], tcmin[2] );
338 glVertex3f( visible_max_[0], cursor_[1], visible_min_[2] );
340 glTexCoord3f( tcmax[0], rel[1], tcmax[2] );
341 glVertex3f( visible_max_[0], cursor_[1], visible_max_[2] );
343 glTexCoord3f( tcmin[0], rel[1], tcmax[2] );
344 glVertex3f( visible_min_[0], cursor_[1], visible_max_[2] );
357 SliceNode::cursor()
const
367 SliceNode::set_cursor(
const Vec3f & _cursor )
377 SliceNode::is_enabled(
Plane _plane )
const
379 return enabled_ == _plane;
387 SliceNode::set_enabled(
Plane _plane )
397 SliceNode::set_visible_box(
const Vec3f & _box_min,
398 const Vec3f & _box_max )
400 visible_min_ = _box_min;
401 visible_max_ = _box_max;
409 SliceNode::set_texture_box(
const Vec3f & _box_min,
410 const Vec3f & _box_max )
412 texture_min_ = _box_min;
413 texture_max_ = _box_max;
421 SliceNode::pick( GLState & _state,
PickTarget )
423 _state.pick_set_maximum (1);
424 _state.pick_set_name (0);
Namespace providing different geometric functions concerning angles.
static void enable(GLenum _cap)
replaces glEnable, but supports locking
PickTarget
What target to use for picking.
static void disable(GLenum _cap)
replaces glDisable, but supports locking
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
VectorT< float, 3 > Vec3f
DrawModes::DrawMode availableDrawModes() const
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
static void blendFunc(GLenum _sfactor, GLenum _dfactor)
replaces glBlendFunc, supports locking
DrawMode NONE
not a valid draw mode