puck.cc
Go to the documentation of this file.
1 
2 #include "stage.hh"
3 #include "worldfile.hh"
4 using namespace Stg;
5 
6 Puck::Puck() :
7  color( color_pack( 1,0,0,0) ),
8  displaylist( 0 ),
9  height( 0.2 ),
10  pose( 0,0,0,0 ),
11  radius( 0.1 )
12 { /* empty */ }
13 
14 void Puck::Load( Worldfile* wf, int section )
15 {
16  pose.Load( wf, section, "pose" );
17  //color.Load( wf, section, "color" );
18 
19  radius = wf->ReadLength( section, "radius", radius );
20  height = wf->ReadLength( section, "height", height );
21 
22  BuildDisplayList();
23 }
24 
25 void Puck::Save( Worldfile* wf, int section )
26 {
27  pose.Save( wf, section, "pose" );
28  //color.Save( wf, section, "color" );
29 
30  wf->WriteLength( section, "radius", radius );
31  wf->WriteLength( section, "height", height );
32 }
33 
34 void Puck::BuildDisplayList()
35 {
36  if( displaylist == 0 )
37  displaylist = glGenLists(1);
38 
39  glNewList( displaylist, GL_COMPILE );
40 
41  GLUquadricObj *q = gluNewQuadric();
42  glColor3f( 1,0,0 );
43 
44  // draw a filled body
45  glPushMatrix();
46  glTranslatef( pose.x, pose.y, pose.z );
47  gluCylinder(q, radius, radius, height, 16, 1 );
48  glTranslatef( 0,0, height);
49  gluDisk(q, 0, radius, 16, 16 );
50  glPopMatrix();
51 
52  // outline the sides in a darker shade
53  double r,g,b,a;
54  color_unpack( color, &r, &g, &b, &a );
55  glColor3f( r/2.0, g/2.0, b/2.0 );
56 
57  gluQuadricDrawStyle( q, GLU_LINE );
58  glTranslatef( pose.x, pose.y, pose.z );
59  gluCylinder(q, radius+0.001, radius+0.001, height+0.001, 16, 1 );
60 
61  // clean up
62  gluDeleteQuadric( q );
63  glEndList();
64 }
65 
66 
67 void Puck::Draw()
68 {
69  if( displaylist == 0 )
70  BuildDisplayList();
71 
72  glPushMatrix();
73  glCallList( displaylist );
74  glPopMatrix();
75 }
The Stage library uses its own namespace.
Definition: canvas.hh:8
double ReadLength(int entity, const char *name, double value)
Definition: worldfile.hh:107
void WriteLength(int entity, const char *name, double value)


stage
Author(s): Richard Vaughan , Brian Gerkey , Reed Hedges , Andrew Howard , Toby Collett , Pooya Karimian , Jeremy Asher , Alex Couture-Beil , Geoff Biggs , Rich Mattes , Abbas Sadat
autogenerated on Mon Jun 10 2019 15:06:09