#include "modelerview.h" #include "modelerapp.h" #include "modelerdraw.h" #include #include enum RobotArmControls { BASEROTATION=0, LOWERARMROTATION, UPPERARMROTATION, APPENDAGEANGLE, LOOKINGSTUPID, NUMCONTROLS }; class RobotArmModel : public ModelerView { public: RobotArmModel(int x, int y, int w, int h, char *label) : ModelerView(x,y,w,h,label) {} virtual void draw(); }; ModelerView* createRobotArmModel(int x, int y, int w, int h, char *label) { return new RobotArmModel(x,y,w,h,label); } #define VAL(x) (ModelerApplication::Instance()->GetControlValue(x)) void RobotArmModel::draw() { ModelerView::draw(); setDiffuseColor(0,1,0); glPushMatrix(); glRotated( VAL(BASEROTATION), 0, 1, 0 ); drawCylinder(3, 0.5, 0.5); setDiffuseColor(1,0,0); glTranslated(0,0,3); glPushMatrix(); { glRotated( VAL(LOWERARMROTATION), 0, 1, 0); drawSphere(0.7); setDiffuseColor(0,1,0); drawCylinder(3, 0.5, 0.5); setDiffuseColor(1,0,0); glTranslated(0,0,3); drawSphere(0.7); glRotated( VAL(UPPERARMROTATION), 0, 1, 0); setDiffuseColor(0,1,0); drawCylinder(2.5, 0.5, 0.1); } glPopMatrix(); ModelerApplication::Instance()->SetControlValue(APPENDAGEANGLE, 2*VAL(UPPERARMROTATION)); glRotated(VAL(APPENDAGEANGLE), 1, 0, 0); setDiffuseColor(1,1,0); drawCylinder(5,0.1, 0.1); glPopMatrix(); } int main() { ModelerControl controls[NUMCONTROLS]; controls[BASEROTATION] = ModelerControl("Base Rotation", -90, 90, 1, 0); controls[LOWERARMROTATION] = ModelerControl("Lower arm rot", -90, 90, 1, 0); controls[UPPERARMROTATION] = ModelerControl("UPper arm rottar", -90, 90, 1, 0); controls[APPENDAGEANGLE] = ModelerControl("apoplnr", -90, 90, 1, 0); controls[LOOKINGSTUPID] = ModelerControl("Stupid???", 0, 1, 1, 0); ModelerApplication::Instance()->Init(&createRobotArmModel, controls, NUMCONTROLS); return ModelerApplication::Instance()->Run(); }