#include <math.h>
#include <float.h>
#include <assert.h>
+#include "opengl.h"
#include "machine.h"
static float delta_angle(float a, float b);
motors.push_back(m);
}
+int Machine::get_gear_index(Gear *g) const
+{
+ std::map<Gear*, int>::const_iterator it = gearidx.find(g);
+ if(it == gearidx.end()) {
+ return -1;
+ }
+ return it->second;
+}
+
void Machine::invalidate_meshing()
{
meshing_valid = false;
for(size_t i=0; i<gears.size(); i++) {
gears[i]->draw();
}
+
+ float dcol[] = {0.4, 0.4, 0.4, 1.0};
+ float scol[] = {0, 0, 0, 0};
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, dcol);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, scol);
+
+ glBegin(GL_QUADS);
+ glNormal3f(0, 1, 0);
+ glVertex3f(-300, -100, 300);
+ glVertex3f(300, -100, 300);
+ glVertex3f(300, -100, -300);
+ glVertex3f(-300, -100, -300);
+ glEnd();
}
Gear *Machine::intersect_gear(const Ray &ray, HitPoint *hitp) const