-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplainwheel.cpp
More file actions
55 lines (45 loc) · 1.24 KB
/
plainwheel.cpp
File metadata and controls
55 lines (45 loc) · 1.24 KB
1
2
3
4
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <drawstuff/drawstuff.h>
#include "plainwheel.h"
#include "plainwheeldesign.h"
#include "mydraw.h"
#include "track.h"
#include "error.h"
/************************************************************************
* PlainWheel *
************************************************************************/
void PlainWheel::Draw()
{
if (drawFlag) {
// to draw the (real) sphere
//drawGeom(geom[0]);
// to draw a prettier looking (though false) cylinder
drawCylinder(geom[0]);
}
}
PlainWheel::PlainWheel(dWorldID world, dSpaceID space, PlainWheelDesignID d)
: Wheel(world, space)
{
create(d->getRadius());
}
void PlainWheel::create(dReal radius)
{
dBodyID sprocket;
dMass m;
Init(1, 0, 1);
body[0] = sprocket = dBodyCreate(world);
dBodySetPosition(sprocket, 0, 0, 0);
dMassSetBox(&m, 1, 2*radius, 1, 1); // will give mass of 1
dMassAdjust(&m, SPROCKET_MASS);
dBodySetMass(sprocket, &m);
// create central wheel geom
dGeomID g2;
geom[0] = dCreateGeomTransform(space);
dGeomTransformSetCleanup(geom[0], 1);
g2 = dCreateSphere(0, radius);//, height); // TODO: dCreateCylinder
dReal R[12] = { 1,0,0,0,
0,0,-1,0,
0,1,0,0};
dGeomSetRotation(g2, R);
dGeomTransformSetGeom(geom[0], g2);
dGeomSetBody(geom[0], sprocket);
}