~ubuntu-branches/ubuntu/maverick/stormbaancoureur/maverick

« back to all changes in this revision

Viewing changes to src-common/dynamicboxobject.h

  • Committer: Bazaar Package Importer
  • Author(s): Miriam Ruiz
  • Date: 2007-08-22 07:53:07 UTC
  • Revision ID: james.westby@ubuntu.com-20070822075307-60hr9y5jyeeob6as
Tags: upstream-1.5.2
ImportĀ upstreamĀ versionĀ 1.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef DYNAMICBOXOBJECT_H
 
2
#define DYNAMICBOXOBJECT_H
 
3
 
 
4
#include <string>
 
5
 
 
6
#include <ode/ode.h>
 
7
#include <plib/ssg.h>
 
8
 
 
9
#include "dynamicobject.h"
 
10
 
 
11
 
 
12
class DynamicBoxObject : public DynamicObject
 
13
{
 
14
  public:
 
15
    DynamicBoxObject(ssgEntity *model, dWorldID world, dSpaceID bigspace, sgVec3 pos, sgVec3 scl) :
 
16
    DynamicObject(model, world, bigspace)
 
17
    {
 
18
      body = dBodyCreate (world);
 
19
      dBodySetPosition (body,pos[0],pos[1],pos[2]);
 
20
      dim[0]=scl[0]; dim[1]=scl[1]; dim[2]=scl[2];
 
21
      geom = dCreateBox (bigspace,scl[0],scl[1],scl[2]);
 
22
      SetMass();
 
23
      dGeomSetBody (geom,body);
 
24
      dGeomSetData (geom,this);
 
25
    }
 
26
    void SetMass(float density=1000.0)
 
27
    {
 
28
      dMass m;
 
29
      dMassSetBox (&m,density,dim[0],dim[1],dim[2]);
 
30
      dBodySetMass (body,&m);
 
31
    }
 
32
    virtual ~DynamicBoxObject()
 
33
    { 
 
34
      // geom and body are destroyed by parent's destructor
 
35
    }
 
36
  protected:
 
37
    dReal dim[3];
 
38
};
 
39
 
 
40
#endif