59 #define CAMERAVISNODE_C 62 #include "CameraNode.hh" 69 const float axis_length = 0.1f;
76 bbmin_(FLT_MAX,FLT_MAX,FLT_MAX),
77 bbmax_(FLT_MIN,FLT_MIN,FLT_MIN),
95 updateBoundingBoxes(modelView_);
97 cylinder_ =
new GLCylinder(8, 4, 1.0f,
false,
false);
98 cone_ =
new GLCone(8, 1, 1.0f, 0.0f,
true,
false);
128 glPushAttrib(GL_LIGHTING_BIT);
129 glPushAttrib(GL_ENABLE_BIT);
149 updateBoundingBoxes(modelview);
157 glPushAttrib(GL_LIGHTING_BIT);
160 glVertex3f(0.0f, 0.0f, 0.0f);
161 glVertex3f(-half_width_, -half_height_, -near_);
163 glVertex3f(0.0f, 0.0f, 0.0f);
164 glVertex3f(half_width_, -half_height_, -near_);
166 glVertex3f(0.0f, 0.0f, 0.0f);
167 glVertex3f(-half_width_, half_height_, -near_);
169 glVertex3f(0.0f, 0.0f, 0.0f);
170 glVertex3f(half_width_, half_height_, -near_);
172 glVertex3f(-half_width_, -half_height_, -near_);
173 glVertex3f(half_width_, -half_height_, -near_);
175 glVertex3f(-half_width_, -half_height_, -near_);
176 glVertex3f(-half_width_, half_height_, -near_);
178 glVertex3f(half_width_, half_height_, -near_);
179 glVertex3f(half_width_, -half_height_, -near_);
181 glVertex3f(half_width_, half_height_, -near_);
182 glVertex3f(-half_width_, half_height_, -near_);
191 glPushAttrib(GL_LIGHTING_BIT);
194 glColor4f(0.0f, 0.5f, 0.0f, 1.0f);
199 glVertex3f(0.0f, 0.0f, 0.0f);
200 glVertex3f(-far_half_width_, -far_half_height_, -far_);
202 glVertex3f(-far_half_width_, -far_half_height_, -far_);
203 glVertex3f(-far_half_width_, far_half_height_, -far_);
205 glVertex3f(-far_half_width_, far_half_height_, -far_);
206 glVertex3f(0.0f, 0.0f, 0.0f);
210 glVertex3f(0.0f, 0.0f, 0.0f);
211 glVertex3f(far_half_width_, -far_half_height_, -far_);
213 glVertex3f(far_half_width_, -far_half_height_, -far_);
214 glVertex3f(far_half_width_, far_half_height_, -far_);
216 glVertex3f(far_half_width_, far_half_height_, -far_);
217 glVertex3f(0.0f, 0.0f, 0.0f);
220 glVertex3f(0.0f, 0.0f, 0.0f);
221 glVertex3f(-far_half_width_, far_half_height_, -far_);
223 glVertex3f(-far_half_width_, far_half_height_, -far_);
224 glVertex3f(far_half_width_, far_half_height_, -far_);
226 glVertex3f(far_half_width_, far_half_height_, -far_);
227 glVertex3f(0.0f, 0.0f, 0.0f);
230 glVertex3f(0.0f, 0.0f, 0.0f);
231 glVertex3f(-far_half_width_, -far_half_height_, -far_);
233 glVertex3f(-far_half_width_, -far_half_height_, -far_);
234 glVertex3f(far_half_width_, -far_half_height_, -far_);
236 glVertex3f(far_half_width_, -far_half_height_, -far_);
237 glVertex3f(0.0f, 0.0f, 0.0f);
240 glVertex3f(-far_half_width_, -far_half_height_, -far_);
241 glVertex3f(far_half_width_, -far_half_height_, -far_);
243 glVertex3f(far_half_width_, -far_half_height_, -far_);
244 glVertex3f(far_half_width_, far_half_height_, -far_);
246 glVertex3f(far_half_width_, far_half_height_, -far_);
247 glVertex3f(-far_half_width_, -far_half_height_, -far_);
251 glColor4f(0.0f, 1.0f, 0.0f, 0.01f);
253 glBegin(GL_TRIANGLES);
256 glVertex3f(-half_width_, -half_height_, -1.0f);
257 glVertex3f(-far_half_width_, -far_half_height_, -far_);
258 glVertex3f(-far_half_width_, far_half_height_, -far_);
260 glVertex3f(-far_half_width_, far_half_height_, -far_);
261 glVertex3f(-half_width_, half_height_, -1.0f);
262 glVertex3f(-half_width_, -half_height_, -1.0f);
265 glVertex3f(half_width_, -half_height_, -1.0f);
266 glVertex3f(far_half_width_, -far_half_height_, -far_);
267 glVertex3f(far_half_width_, far_half_height_, -far_);
269 glVertex3f(far_half_width_, far_half_height_, -far_);
270 glVertex3f(half_width_, half_height_, -1.0f);
271 glVertex3f(half_width_, -half_height_, -1.0f);
274 glVertex3f(-half_width_, half_height_, -1.0f);
275 glVertex3f(-far_half_width_, far_half_height_, -far_);
276 glVertex3f(far_half_width_, far_half_height_, -far_);
278 glVertex3f(far_half_width_, far_half_height_, -far_);
279 glVertex3f(half_width_, half_height_, -1.0f);
280 glVertex3f(-half_width_, half_height_, -1.0f);
283 glVertex3f(-half_width_, -half_height_, -1.0f);
284 glVertex3f(-far_half_width_, -far_half_height_, -far_);
285 glVertex3f(far_half_width_, -far_half_height_, -far_);
287 glVertex3f(far_half_width_, -far_half_height_, -far_);
288 glVertex3f(half_width_, -half_height_, -1.0f);
289 glVertex3f(-half_width_, -half_height_, -1.0f);
292 glVertex3f(-far_half_width_, -far_half_height_, -far_);
293 glVertex3f(far_half_width_, -far_half_height_, -far_);
294 glVertex3f(far_half_width_, far_half_height_, -far_);
296 glVertex3f(far_half_width_, far_half_height_, -far_);
297 glVertex3f(-far_half_width_, far_half_height_, -far_);
298 glVertex3f(-far_half_width_, -far_half_height_, -far_);
307 _state.
rotate(90, 0.0, 1.0, 0.0);
313 cylinder_->setBottomRadius(axis_length/20.0f);
314 cylinder_->setTopRadius(axis_length/20.0f);
315 cylinder_->draw(_state, axis_length);
318 _state.
translate(0.0, 0.0, axis_length );
319 cone_->setBottomRadius(axis_length/5.0f);
320 cone_->setTopRadius(0.0f);
321 cone_->draw(_state, axis_length/2.0f);
322 _state.
translate(0.0, 0.0, -axis_length );
325 _state.
rotate(-90, 1.0, 0.0, 0.0);
331 cylinder_->draw(_state, axis_length);
334 _state.
translate(0.0, 0.0, axis_length );
335 cone_->draw(_state, axis_length/2.0f);
336 _state.
translate(0.0, 0.0, -axis_length );
339 _state.
rotate(90, 0.0, 1.0, 0.0);
345 cylinder_->draw(_state, axis_length);
348 _state.
translate(0.0, 0.0, axis_length );
349 cone_->draw(_state, axis_length/2.0f);
350 _state.
translate(0.0, 0.0, -axis_length );
384 updateBoundingBoxes(modelview);
388 glVertex3f(0.0f, 0.0f, 0.0f);
389 glVertex3f(-half_width_, -half_height_, -near_);
391 glVertex3f(0.0f, 0.0f, 0.0f);
392 glVertex3f(half_width_, -half_height_, -near_);
394 glVertex3f(0.0f, 0.0f, 0.0f);
395 glVertex3f(-half_width_, half_height_, -near_);
397 glVertex3f(0.0f, 0.0f, 0.0f);
398 glVertex3f(half_width_, half_height_, -near_);
400 glVertex3f(-half_width_, -half_height_, -near_);
401 glVertex3f(half_width_, -half_height_, -near_);
403 glVertex3f(-half_width_, -half_height_, -near_);
404 glVertex3f(-half_width_, half_height_, -near_);
406 glVertex3f(half_width_, half_height_, -near_);
407 glVertex3f(half_width_, -half_height_, -near_);
409 glVertex3f(half_width_, half_height_, -near_);
410 glVertex3f(-half_width_, half_height_, -near_);
417 _state.
rotate(90, 0.0, 1.0, 0.0);
419 cylinder_->setBottomRadius(axis_length/20.0f);
420 cylinder_->setTopRadius(axis_length/20.0f);
421 cylinder_->draw(_state, axis_length);
424 _state.
translate(0.0, 0.0, axis_length );
425 cone_->setBottomRadius(axis_length/5.0f);
426 cone_->setTopRadius(0.0f);
427 cone_->draw(_state, axis_length/2.0f);
428 _state.
translate(0.0, 0.0, -axis_length );
431 _state.
rotate(-90, 1.0, 0.0, 0.0);
433 cylinder_->draw(_state, axis_length);
436 _state.
translate(0.0, 0.0, axis_length );
437 cone_->draw(_state, axis_length/2.0f);
438 _state.
translate(0.0, 0.0, -axis_length );
441 _state.
rotate(90, 0.0, 1.0, 0.0);
443 cylinder_->draw(_state, axis_length);
446 _state.
translate(0.0, 0.0, axis_length );
447 cone_->draw(_state, axis_length/2.0f);
448 _state.
translate(0.0, 0.0, -axis_length );
456 void CameraNode::updateBoundingBoxes(
GLMatrixd& _modelview) {
459 fovy_ = atan(1/projection_(1,1)) * 2;
465 aspectRatio_ = (double)width_ / (
double)height_;
467 half_height_ = height_/2.0;
468 half_width_ = aspectRatio_ * half_height_;
471 far_half_height_ = tan(fovy_/2) * far_;
472 far_half_width_ = far_half_height_ * aspectRatio_;
477 OpenMesh::Vec3d tmp(std::max(1.41421, half_width_), std::max(1.41421, half_height_), 1.41421);
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
DrawMode HIDDENLINE
draw hidden line (2 rendering passes needed)
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
DrawMode WIREFRAME
draw wireframe
void pick(GLState &_state, PickTarget _target)
picking
void push_modelview_matrix()
push modelview matrix
const Vec4f & specular_color() const
get specular color
DrawMode POINTS
draw unlighted points using the default base color
PickTarget
What target to use for picking.
void set_diffuse_color(const Vec4f &_col)
set diffuse color
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
static void enable(GLenum _cap)
replaces glEnable, but supports locking
const Vec4f & base_color() const
get base color (used when lighting is off)
void translate(double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
translate by (_x, _y, _z)
CameraNode(BaseNode *_parent=0, std::string _name="<CameraVis>")
Default constructor.
bool pick_set_maximum(unsigned int _idx)
Set the maximal number of primitives/components of your object.
void set_specular_color(const Vec4f &_col)
set specular color
void set_modelview(const GLMatrixd &_m)
set modelview
void perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
static void disable(GLenum _cap)
replaces glDisable, but supports locking
Namespace providing different geometric functions concerning angles.
VectorT< double, 3 > Vec3d
void pop_modelview_matrix()
pop modelview matrix
void pick_set_name(unsigned int _idx)
sets the current name/color (like glLoadName(_idx))
void rotate(double _angle, double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
rotate around axis (_x, _y, _z) by _angle
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
virtual ~CameraNode()
Destructor.
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode)
drawing
const Vec4f & diffuse_color() const
get diffuse color
const GLMatrixd & modelview() const
get modelview matrix
void set_base_color(const Vec4f &_col)
set base color (used when lighting is off)
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
void identity()
setup an identity matrix
DrawModes::DrawMode availableDrawModes() const
return available draw modes
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking