SkeletonNodeT.cc 19.7 KB
Newer Older
1
2
3
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
*      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen       *
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
*                           www.openflipper.org                              *
*                                                                            *
*--------------------------------------------------------------------------- *
*  This file is part of OpenFlipper.                                         *
*                                                                            *
*  OpenFlipper is free software: you can redistribute it and/or modify       *
*  it under the terms of the GNU Lesser General Public License as            *
*  published by the Free Software Foundation, either version 3 of            *
*  the License, or (at your option) any later version with the               *
*  following exceptions:                                                     *
*                                                                            *
*  If other files instantiate templates or use macros                        *
*  or inline functions from this file, or you compile this file and          *
*  link it with other files to produce an executable, this file does         *
*  not by itself cause the resulting executable to be covered by the         *
*  GNU Lesser General Public License. This exception does not however        *
*  invalidate any other reasons why the executable file might be             *
*  covered by the GNU Lesser General Public License.                         *
*                                                                            *
*  OpenFlipper is distributed in the hope that it will be useful,            *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of            *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
*  GNU Lesser General Public License for more details.                       *
*                                                                            *
*  You should have received a copy of the GNU LesserGeneral Public           *
*  License along with OpenFlipper. If not,                                   *
*  see <http://www.gnu.org/licenses/>.                                       *
*                                                                            *
\*===========================================================================*/

/*===========================================================================*\
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
\*===========================================================================*/
Dirk Wilden's avatar
Dirk Wilden committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72




//=============================================================================
//
//  CLASS SkeletonNodeT - IMPLEMENTATION
//
//=============================================================================

#define ACG_SKELETONNODET_C

//== INCLUDES =================================================================

#include "SkeletonNodeT.hh"
#include <ACG/GL/gl.hh>
#include <vector>
#include <deque>

//== NAMESPACES ===============================================================
using namespace std;

namespace ACG {
namespace SceneGraph {

//== IMPLEMENTATION ==========================================================


/** \brief Constructor
 * 
 */
73
74
template <class SkeletonType>
SkeletonNodeT<SkeletonType>::SkeletonNodeT(SkeletonType &_skeleton, BaseNode *_parent, std::string _name) :
Dirk Wilden's avatar
Dirk Wilden committed
75
76
77
78
               BaseNode(_parent, _name),
               bCoordFramesVisible_(false),
               skeleton_(_skeleton),
               hAni_(),
79
80
81
               fFrameSize_(0.0),
               slices_(6),
               stacks_(1)
Dirk Wilden's avatar
Dirk Wilden committed
82
83
{
  this->multipassNodeSetActive(3, true);
84
85

  sphere_ = new ACG::GLSphere(10, 10);
86
  cone_ = new ACG::GLCone(slices_, stacks_, 1.0f, 0.0f, false, false);
Dirk Wilden's avatar
Dirk Wilden committed
87
88
89
90
91
92
93
94
}


//------------------------------------------------------------------------------

/** \brief Destructor
 * 
 */
95
96
template <class SkeletonType>
SkeletonNodeT<SkeletonType>::~SkeletonNodeT()
Dirk Wilden's avatar
Dirk Wilden committed
97
{
98
99
  if (sphere_)
    delete sphere_;
Matthias Möller's avatar
Matthias Möller committed
100

101
102
  if (cone_)
    delete cone_;
Dirk Wilden's avatar
Dirk Wilden committed
103
104
105
106
107
108
109
110
}


//------------------------------------------------------------------------------

/** \brief Returns a pointer to the skeleton
 * 
 */
111
112
template <class SkeletonType>
SkeletonType& SkeletonNodeT<SkeletonType>::skeleton()
Dirk Wilden's avatar
Dirk Wilden committed
113
114
115
116
117
118
119
120
121
122
{
  return skeleton_;
}


//------------------------------------------------------------------------------

/** \brief Returns the bounding box of this node
 * 
 */
123
124
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
Dirk Wilden's avatar
Dirk Wilden committed
125
126
127
128
129
{  
  if(skeleton_.jointCount() == 0)
    return; // no joints, no contribution to the bound box

  Pose *pose = skeleton_.pose(hAni_);
130
  typename SkeletonType::Iterator it;
Dirk Wilden's avatar
Dirk Wilden committed
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
  for(it = skeleton_.begin(); it != skeleton_.end(); ++it)
  {
    _bbMin.minimize( (Vec3d)pose->globalTranslation((*it)->id()) );
    _bbMax.maximize( (Vec3d)pose->globalTranslation((*it)->id()) );
  }
  
  //choose a proper size for the coordinate frames
  fFrameSize_ = (_bbMin - _bbMax).norm() * 0.07;
}


//----------------------------------------------------------------------------

/** \brief Returns available draw modes
 * 
 */
147
148
template <class SkeletonType>
DrawModes::DrawMode SkeletonNodeT<SkeletonType>::availableDrawModes() const
Dirk Wilden's avatar
Dirk Wilden committed
149
150
151
152
153
154
155
156
{
  return (DrawModes::WIREFRAME           | DrawModes::POINTS | DrawModes::SOLID_FLAT_SHADED
        | DrawModes::SOLID_FACES_COLORED | DrawModes::SOLID_FACES_COLORED_FLAT_SHADED);
}


//----------------------------------------------------------------------------

157
158
159
160
161
162
163
164
165
166

template <class SkeletonType>
double SkeletonNodeT<SkeletonType>::frameSize() {
	return fFrameSize_;
}


//----------------------------------------------------------------------------


Dirk Wilden's avatar
Dirk Wilden committed
167
168
169
/** \brief Normalizes a coordinate frame defined by the given matrix
 * 
 */
170
171
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::NormalizeCoordinateFrame(Matrix &_mat)
Dirk Wilden's avatar
Dirk Wilden committed
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
{
  ACG::Vec3d vec;
  for(int i = 0; i < 3; ++i)
  {
    for(int x = 0; x < 3; ++x)
      vec[x] = _mat(x, i);
    vec.normalize();
    for(int x = 0; x < 3; ++x)
      _mat(x, i) = vec[x];
  }
}


//----------------------------------------------------------------------------

/**
 * @brief Converts the color from HSV color space to RGB
 *
 * H is in range [0, 360], S and V in [0, 1].
 *
 * @param[in] _HSV An array of 3 GLfloats, holding H, S and V
 * @param[out] _RGB An array of 3 GLfloats, holding R, G and B
 */
195
196
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::HSVtoRGB(const Vec4f& _HSV, Vec4f& _RGB)
Dirk Wilden's avatar
Dirk Wilden committed
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
{
  int h;
  float f, p, q, t;
  h = int(floor(_HSV[0] / 60.0));
  f = _HSV[0] / 60.0 - float(h);
  p = _HSV[2] * (1 - _HSV[1]);
  q = _HSV[2] * (1 - _HSV[1] * f);
  t = _HSV[2] * (1 - _HSV[1] * (1 - f));

  switch(h)
  {
  case 0:
  case 6:
    _RGB[0] = _HSV[2];
    _RGB[1] = t;
    _RGB[2] = p;
    break;
  case 1:
    _RGB[0] = q;
    _RGB[1] = _HSV[2];
    _RGB[2] = p;
    break;
  case 2:
    _RGB[0] = p;
    _RGB[1] = _HSV[2];
    _RGB[2] = t;
    break;
  case 3:
    _RGB[0] = p;
    _RGB[1] = q;
    _RGB[2] = _HSV[2];
    break;
  case 4:
    _RGB[0] = t;
    _RGB[1] = p;
    _RGB[2] = _HSV[2];
    break;
  case 5:
    _RGB[0] = _HSV[2];
    _RGB[1] = p;
    _RGB[2] = q;
    break;
  }
  
  //always set alpha to 1.0
  _RGB[3] = 1.0;
}


//----------------------------------------------------------------------------

/**
 * @brief Converts a color from RGB color space to HSV
 *
 * Red, green and blue are in the range [0, 1].
 *
 * @param[out] _RGB An array of 3 GLfloats, holding R, G and B
 * @param[in] _HSV An array of 3 GLfloats, holding H, S and V
 */
256
257
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::RGBtoHSV(const Vec4f& _RGB, Vec4f& _HSV)
Dirk Wilden's avatar
Dirk Wilden committed
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
{
  double maxC = _RGB[2];
  if(maxC < _RGB[1])
    maxC = _RGB[1];
  if(maxC < _RGB[0])
    maxC = _RGB[0];
  double minC = _RGB[2];
  if(minC > _RGB[1])
    minC = _RGB[1];
  if(minC > _RGB[0])
    minC = _RGB[0];

  double delta = maxC - minC;

  double V = maxC;
  double S = 0;
  double H = 0;

  if(delta == 0)
  {
    H = 0;
    S = 0;
  }else{
    S = delta / maxC;
    double dR = 60 * (maxC - _RGB[0]) / delta + 180;
    double dG = 60 * (maxC - _RGB[1]) / delta + 180;
    double dB = 60 * (maxC - _RGB[2]) / delta + 180;
    if (_RGB[0] == maxC)
      H = dB - dG;
    else if (_RGB[1] == maxC)
      H = 120 + dR - dB;
    else
      H = 240 + dG - dR;
  }

  if(H < 0)
    H += 360;
  if(H >= 360)
    H -= 360;

  _HSV[0] = H;
  _HSV[1] = S;
  _HSV[2] = V;
}

//----------------------------------------------------------------------------

/** \brief Renders the nodes contents using the given render state and draw mode
 * 
 */
308
309
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::draw(GLState& _state, const DrawModes::DrawMode& _drawMode)
Dirk Wilden's avatar
Dirk Wilden committed
310
311
{
  
312
  ACG::GLState::disable(GL_LIGHTING);
Dirk Wilden's avatar
Dirk Wilden committed
313
314
315
316
  
  glPushAttrib(GL_ENABLE_BIT);
  
  Pose *pose = skeleton_.pose(hAni_);
317
  typename SkeletonType::Iterator it;
Dirk Wilden's avatar
Dirk Wilden committed
318
  
319
320


Dirk Wilden's avatar
Dirk Wilden committed
321
322
323
324
325
326
327
328
329
  // draw points
  //
  if (_drawMode == DrawModes::POINTS)
  {
    Vec4f jointColor;
    getJointColor(_state.base_color(), jointColor);
    
    // draw all joint positions
    glPointSize(12);
330
331
332

    //we will set the specular color, otherwise the color cannot be seen
    ACG::Vec4f oldSpecular = _state.specular_color();
Dirk Wilden's avatar
Dirk Wilden committed
333
334
335
                
    for(it = skeleton_.begin(); it != skeleton_.end(); ++it)
    {
Jan Möbius's avatar
Jan Möbius committed
336
337
338

      // If the vertex is selected, it will be always red
      // If it is not selected,
Dirk Wilden's avatar
Dirk Wilden committed
339
      if ( (*it)->selected() )
Matthias Möller's avatar
Matthias Möller committed
340
341
      {
      	_state.set_diffuse_color(ACG::Vec4f(1.0, 0.0, 0.0 ,1.0));
342
      	_state.set_specular_color(ACG::Vec4f(1.0, 0.0, 0.0 ,1.0));
Matthias Möller's avatar
Matthias Möller committed
343
      }
Jan Möbius's avatar
Jan Möbius committed
344
345
346
347
      else {
        // If it is the root joint, it will get some kind of orange color
        // Otherwise the the Base color is used
        if ( (*it)->isRoot() )
Matthias Möller's avatar
Matthias Möller committed
348
        {
349
350
        	ACG::Vec4f root_color = ACG::Vec4f(1.0, 0.66, 0.0 ,1.0);
        	_state.set_diffuse_color(root_color);
351
        	_state.set_specular_color(root_color);
Matthias Möller's avatar
Matthias Möller committed
352
        }
353
        else {
Matthias Möller's avatar
Matthias Möller committed
354
        	_state.set_diffuse_color(ACG::Vec4f(jointColor[0], jointColor[1] , jointColor[2], 1.0));
355
        	_state.set_specular_color(ACG::Vec4f(jointColor[0], jointColor[1] , jointColor[2], 1.0));
356
        }
Dirk Wilden's avatar
Dirk Wilden committed
357
358
      }

359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
      //---------------------------------------------------
      // Simulate glPointSize(12) with a sphere
      //---------------------------------------------------

      // 1. Project point to screen
      ACG::Vec3d projected = _state.project( pose->globalTranslation( (*it)->id() ) );

      // 2. Shift it by the requested point size
      //    glPointSize defines the diameter but we want the radius, so we divide it by two
      ACG::Vec3d shifted = projected;
      shifted[0] = shifted[0] + (double)_state.point_size() / 2.0 ;

      // 3. un-project into 3D
      ACG::Vec3d unProjectedShifted = _state.unproject( shifted );

      // 4. The difference vector defines the radius in 3D for the sphere
      ACG::Vec3d difference = unProjectedShifted - pose->globalTranslation( (*it)->id() );

      const double sphereSize = difference.norm();
Jan Möbius's avatar
Jan Möbius committed
378

379
      sphere_->draw(_state,sphereSize,ACG::Vec3f(pose->globalTranslation( (*it)->id() )));
380

Dirk Wilden's avatar
Dirk Wilden committed
381
382
    }

383
384
    _state.set_specular_color(oldSpecular);

Dirk Wilden's avatar
Dirk Wilden committed
385
386
387
388

    // draw the local coordinate frames
    if(bCoordFramesVisible_)
    {
389
      ACG::GLState::enable(GL_DEPTH_TEST);
Dirk Wilden's avatar
Dirk Wilden committed
390
391
392
393
      glPointSize(6.0);
      glBegin(GL_POINTS);
      for(it = skeleton_.begin(); it != skeleton_.end(); ++it)
      {
394
        typename SkeletonType::Matrix global = pose->globalMatrix( (*it)->id() );
Dirk Wilden's avatar
Dirk Wilden committed
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
        NormalizeCoordinateFrame(global);
        glColor3f(0.8, 0.2, 0.2);
        glVertex( global.transform_point(Point(fFrameSize_, 0, 0)) );
        glColor3f(0.2, 0.8, 0.2);
        glVertex( global.transform_point(Point(0, fFrameSize_, 0)) );
        glColor3f(0.2, 0.2, 0.8);
        glVertex( global.transform_point(Point(0, 0, fFrameSize_)) );
      }
      glEnd();
      glPointSize(_state.point_size());
    }
  }


  // draw bones
  //
  if ( (_drawMode == DrawModes::WIREFRAME)
    || (_drawMode == DrawModes::SOLID_FLAT_SHADED)
    || (_drawMode == DrawModes::SOLID_FACES_COLORED)
    || (_drawMode == DrawModes::SOLID_FACES_COLORED_FLAT_SHADED) )
  {
    
    Vec4f baseColor = _state.base_color();
    
    if ( (_drawMode == DrawModes::SOLID_FLAT_SHADED)
      || (_drawMode == DrawModes::SOLID_FACES_COLORED_FLAT_SHADED) ){

422
423
      ACG::GLState::shadeModel(GL_FLAT);
      ACG::GLState::enable(GL_LIGHTING);
Dirk Wilden's avatar
Dirk Wilden committed
424
425
426
    }
    
    if (_drawMode == DrawModes::SOLID_FACES_COLORED)
427
      ACG::GLState::shadeModel(GL_FLAT);
Dirk Wilden's avatar
Dirk Wilden committed
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
    
    
    glLineWidth(1.5);
    
    // draw the bones
    for(it = skeleton_.begin(); it != skeleton_.end(); ++it) {

      //joint is the (unique) tail joint of the bone
      Joint* joint  = *it;
      Joint* parent = joint->parent();

      // root can be ignored
      // we only want to draw bones from (parent -> joint)
      if (parent == 0)
        continue;

      //select joint color
      glColor4fv( &baseColor[0] );

      Vec3d parentPos = pose->globalTranslation(parent->id());
      Vec3d jointPos  = pose->globalTranslation(joint->id());

      Vec3d boneVector = (jointPos - parentPos);

      draw_bone(_state, _drawMode, parentPos, boneVector);
    }


    // draw the local coordinate frames
    if(bCoordFramesVisible_)
    {
459
460
      ACG::GLState::disable(GL_COLOR_MATERIAL);
      ACG::GLState::disable(GL_LIGHTING);
Dirk Wilden's avatar
Dirk Wilden committed
461
462
463
464
465
466

      glLineWidth(3.0);
      glBegin(GL_LINES);
      for(it = skeleton_.begin(); it != skeleton_.end(); ++it)
      {
        unsigned int index = (*it)->id();
467
        typename SkeletonType::Matrix global = pose->globalMatrix(index);
Dirk Wilden's avatar
Dirk Wilden committed
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
        NormalizeCoordinateFrame(global);
        glColor3f(0.8, 0.2, 0.2);
        glVertex( pose->globalTranslation(index));
        glVertex( global.transform_point(Point(fFrameSize_, 0, 0)) );
        glColor3f(0.2, 0.8, 0.2);
        glVertex( pose->globalTranslation(index));
        glVertex( global.transform_point(Point(0, fFrameSize_, 0)) );
        glColor3f(0.2, 0.2, 0.8);
        glVertex( pose->globalTranslation(index));
        glVertex( global.transform_point(Point(0, 0, fFrameSize_)) );
      }
      glEnd();
      glLineWidth(_state.line_width());
    }
  }


  glColor(_state.base_color());

  glPopAttrib();
}

//----------------------------------------------------------------------------

/** \brief get suitable color for the joint
 * 
 */
495
496
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::getJointColor( const Vec4f& _baseColor, Vec4f& _result )
Dirk Wilden's avatar
Dirk Wilden committed
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
{
  Vec4f hsv;
  RGBtoHSV(_baseColor, hsv);
  
  hsv[0] += 0.4;
  if (hsv[0] > 1.0) hsv[0] -= 1.0;
  
  hsv[1] += 0.1;
  if (hsv[1] > 1.0) hsv[1] = 1.0;
  
  HSVtoRGB(hsv, _result);
}


//----------------------------------------------------------------------------

/** \brief Renders the node in picking mode, restricted to the node components given by \e _target
 * 
 */
516
517
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::pick(GLState& _state, PickTarget _target)
Dirk Wilden's avatar
Dirk Wilden committed
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
{
  unsigned int n_of_vertices = skeleton_.jointCount();

  switch (_target)
  {
  case PICK_VERTEX:
    _state.pick_set_maximum(n_of_vertices);
    pick_vertices(_state);
    break;

  case PICK_EDGE:
    _state.pick_set_maximum(n_of_vertices);
    pick_edges(_state);
    break;

  case PICK_ANYTHING:
    _state.pick_set_maximum(n_of_vertices);
    pick_vertices(_state);
    pick_edges(_state);
    break;

  default:
    break;
  }
}


//----------------------------------------------------------------------------

/** \brief Pick method for vertices
 * 
 */
550
551
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::pick_vertices(GLState &_state)
Dirk Wilden's avatar
Dirk Wilden committed
552
553
{
  glPointSize(16.0);
554
555
  typename SkeletonType::Pose* pose = skeleton_.pose(hAni_);
  for(typename SkeletonType::Iterator it = skeleton_.begin(); it != skeleton_.end(); ++it)
Dirk Wilden's avatar
Dirk Wilden committed
556
  {
557
    typename SkeletonType::Joint *joint = *it;
Dirk Wilden's avatar
Dirk Wilden committed
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
    _state.pick_set_name(joint->id());

    Vec3d p = pose->globalTranslation(joint->id());

    glBegin(GL_POINTS);
    glVertex(p);
    glEnd();
  }
}


//----------------------------------------------------------------------------

/** \brief Pick method for edges
 * 
 */
574
575
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::pick_edges(GLState &_state)
Dirk Wilden's avatar
Dirk Wilden committed
576
577
{
  glLineWidth(10);
578
579
  typename SkeletonType::Pose* pose = skeleton_.pose(hAni_);
  for(typename SkeletonType::Iterator it = skeleton_.begin(); it != skeleton_.end(); ++it)
Dirk Wilden's avatar
Dirk Wilden committed
580
581
582
583
584
585
586
587
588
  {
    Joint *joint = *it;
    for(typename Joint::ChildIter it_ch = joint->begin(); it_ch != joint->end(); ++it_ch)
    {
      Joint *child = *it_ch;

      _state.pick_set_name(child->id());

      Vec3d p0 = pose->globalTranslation(joint->id()),
589
            p1 = pose->globalTranslation(child->id());
Dirk Wilden's avatar
Dirk Wilden committed
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604

      glBegin(GL_LINES);
      glVertex(p0);
      glVertex(p1);
      glEnd();
    }
  }
}


//----------------------------------------------------------------------------

/** \brief Helper function to draw the bones
 * 
 */
605
606
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::draw_bone(GLState &_state, DrawModes::DrawMode _drawMode, const Point& _parent, const Point& _axis)
Dirk Wilden's avatar
Dirk Wilden committed
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
{
 
  _state.push_modelview_matrix();

  Point midPoint = _parent + 0.1 * _axis;
  
  _state.translate(midPoint[0], midPoint[1], midPoint[2]);

  Point  direction = _axis;
  Point  z_axis(0,0,1);
  Point  rot_normal;
  double rot_angle;

  direction.normalize();
  rot_angle  = acos((z_axis | direction))*180/M_PI;
  rot_normal = ((z_axis % direction).normalize());


  if(fabs(rot_angle) > 0.0001 && fabs(180-rot_angle) > 0.0001)
    _state.rotate(rot_angle, rot_normal[0], rot_normal[1], rot_normal[2]);
  else
    _state.rotate(rot_angle, 1, 0, 0);

  double boneLength = _axis.norm();
  double radius     = boneLength * 0.07;
  
  //draw the large cone from midPoint to the end of the bone
634
635
636
  cone_->setBottomRadius(radius);
  cone_->setTopRadius(0.0f);
  cone_->draw(_state,boneLength*0.9);
Dirk Wilden's avatar
Dirk Wilden committed
637
638
639

  //rotate 180.0 and draw the the small cone from midPoint to the start
  _state.rotate(180.0, 1, 0, 0);  
640
  cone_->draw(_state,boneLength*0.1);
Dirk Wilden's avatar
Dirk Wilden committed
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
  
  _state.pop_modelview_matrix();
}


//----------------------------------------------------------------------------

/**
 * @brief Selects the active pose
 *
 * The active pose is the pose that is drawn to the viewport. If the animation handle is invalid (-1),
 * the default pose will be drawn.
 *
 * @warning Do not call this method directly, call SkeletonObject::setActivePose instead. The object has
 * to be notified, in order to properly update the text node positions.
 *
 * @param _hAni A handle to an animation, or an invalid handle for the default pose.
 */
659
660
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::setActivePose(const AnimationHandle &_hAni)
Dirk Wilden's avatar
Dirk Wilden committed
661
662
663
664
665
666
667
668
669
670
{
  hAni_ = _hAni;
}


//----------------------------------------------------------------------------

/**
 * @brief Returns the active pose set with SkeletonNodeT::setActivePose
 */
671
672
template <class SkeletonType>
AnimationHandle SkeletonNodeT<SkeletonType>::activePose()
Dirk Wilden's avatar
Dirk Wilden committed
673
674
675
676
677
678
679
680
681
682
{
  return hAni_;
}


//----------------------------------------------------------------------------

/** \brief Toggle visibility of coordinate frames for all joints
 * 
 */
683
684
template <class SkeletonType>
void SkeletonNodeT<SkeletonType>::showCoordFrames(bool _bVisible)
Dirk Wilden's avatar
Dirk Wilden committed
685
686
687
688
{
	bCoordFramesVisible_ = _bVisible;
}

689
690
template <class SkeletonType>
bool SkeletonNodeT<SkeletonType>::coordFramesVisible()
Dirk Wilden's avatar
Dirk Wilden committed
691
692
693
694
695
696
697
698
699
{
  return bCoordFramesVisible_;
}


//=============================================================================
} // namespace SceneGraph
} // namespace ACG
//=============================================================================