Component CaseFactory::addHoleForScrew(const Component & component, double partOuterHeight, const Point & pos, double radius, bool screwHead) { // The radius of the screw head hole as well as the "radius" of the outer cuboid shaped enclosure for the screw. double ri = holesSize / 2.0; double ro = holesSize / 2.0 + holesWalls; // Add to component: Hole cuboid Component add = Cube(ro*2, ro*2, partOuterHeight, false) .translatedCopy(pos.x - ro, pos.y - ro, 0); // Subtract from component: Hole itself and maybe (if this is the screw head side) also a cylindrical-shaped screw head hole) double holeStart; if (screwHead) // Modified by: Bogdan Vacaliuc <*****@*****.**> to get the desired behavior on the recessed screwhead // holeStart = (partOuterHeight - holesFloors) + (printLayerHeight * printSafeBridgeLayerCount); holeStart = (partOuterHeight - holesFloors) - 0.1; // NB: 0.0 would make the head hole and screw hole touch exactly, we want it to punch through else holeStart = floors; Component subtract = Cylinder(radius, partOuterHeight - holeStart + eps, 32, false) .translatedCopy(pos.x, pos.y, holeStart); if (screwHead) { Component headHole = Cylinder(ri, partOuterHeight - holesFloors + eps, 32, false) .translatedCopy(pos.x, pos.y, -eps); subtract = subtract + headHole; } // Combine them on the existing component return (component + add) - subtract; }
Component CaseFactory::addHoleForPort(const Component & component, double partOuterHeight, const PortDescription & port) { double off_xy = walls + space; // u is the vector facing in the positive axis parallel to the side (orthogonal to both n and the z axis) // v is the vector which is used for the port's local point's y coordinate and faces away from the board surface. Vec u = sidePositiveTangentialVector(port.side); Vec v = {0, 0, -1}; // The base position of a port, if it has a local point of (0,0). This is the "origin" of the side. Vec base = {0, 0, partOuterHeight}; if (port.side == North) { base.y = board.size[1]; } if (port.side == East) { base.x = board.size[0]; } // The hole is a hull of translated cylinders, so the hole is a rounded shape with radius port.radius along port.path [If the radius is 0, we use a tiny cylinder with 4 faces] Component cyl = Cylinder(std::max(port.radius, .001), off_xy + 2 * eps, port.radius == 0 ? 4 : 32, false); cyl.translate(0, 0, -eps); // Added by: Anthony W. Rainer <*****@*****.**> if(port.side != Flat) { cyl.rotateEulerZXZ(0.0, -90.0, -90.0 * port.side); }else{ cyl.rotateEulerZXZ(0.0, 180.0, 0); } // Add a cone for diagonal borders of the port hole double coneLength = off_xy - port.outset; Component cone = Cylinder(port.radius, port.radius + coneLength + 2 * eps, coneLength + 2 * eps, 32, false); cone.translate(0, 0, port.outset); // Added by: Anthony W. Rainer <*****@*****.**> if(port.side != Flat) { cone.rotateEulerZXZ(0.0, -90.0, -90.0 * port.side); }else{ cone.rotateEulerZXZ(0.0, 180.0, 0); } // Build convex hull of translated copies of this cylinder along the path of the port CompositeComponent cylHull = Hull::create(); CompositeComponent coneHull = Hull::create(); for (auto localPoint : port.path) { Vec p; // Added by: Anthony W. Rainer <*****@*****.**> if(port.side != Flat) { p = base + localPoint.x*u + localPoint.y*v; } else { p.z = off_xy; p.x = localPoint.x; p.y = localPoint.y; } Component thisCyl = cyl.translatedCopy(p.x, p.y, p.z); cylHull.addComponent(thisCyl); Component thisCone = cone.translatedCopy(p.x, p.y, p.z); coneHull.addComponent(thisCone); } return component - (cylHull + coneHull); }
void FireHydrant(double x, double y, double z, double dx, double dy, double dz, double th) { glPushMatrix(); glTranslated(x,y,z); glRotated(th,0,1,0); glScaled(dx,dy,dz); glColor3f(.2,.2,.2); Cylinder(0,0,0,.7,.7,.1,90,0); glColor3f(1,0,0); Cylinder(0,.8,0,.4,.4,.8,90,0); Cylinder(0,1.6,0,.65,.65,.1,90,0); ball(0,1.7,0,.4); Cylinder(-.4,1,0,.3,.3,.1,0,90); Cylinder(0,1.1,-.5,.2,.2,.1,0,0); Cylinder(0,1.1,.5,.2,.2,.1,0,0); Cylinder(0,1.1,0,.05,.05,.68,0,0); Cylinder(-.5,1,0,.05,.05,.05,0,90); Cylinder(0,2.1,0,.05,.05,.05,90,0); glPopMatrix(); glColor3f(1,1,1); }
void LunarModule::DrawEngine() { glPushAttrib(GL_ALL_ATTRIB_BITS); glRotatef(180, 0, 0, 1); glColor3f(0, 0, 0); Cylinder(5, 20); Cylinder(10, 15); Cylinder(15, 10); glPopAttrib(); }
static void drawDebugEntityPhysicsCylinder(Entity * io) { if(!(io->ioflags & IO_NPC)) { return; } CollisionFlags levitate = 0; if(spells.getSpellOnTarget(io->index(), SPELL_LEVITATE)) { levitate = CFLAG_LEVITATE; } Cylinder cyll = Cylinder(io->physics.startpos, GetIORadius(io), GetIOHeight(io)); drawLineCylinder(cyll, Color::green); if(!(AttemptValidCylinderPos(cyll, io, levitate | CFLAG_NPC))) { cyll.height = -40.f; drawLineCylinder(cyll, Color::blue); cyll.height = GetIOHeight(io); } cyll.origin = io->physics.targetpos; drawLineCylinder(cyll, Color::red); }
bool MultiSolver::checkBranchCutoffCylinder(SolverInput *input, currentIdx) { if (currentIdx < 3) return false; std::vector <Cylinder> cylinderList; cylinderList.empty(); for (int j = 1; j < currentIdx; j++) { Cylinder cl = Cylinder(heardListReflection.heardInfo[j - 1], heardListReflection.heardInfo[j], condition.maxMeasError); cylinderList.push_back(cl); } // cylinder with circle for (size_t j = 0; j < cylinderList.size(); j++) { if (!cylinderList[j].CheckCollision(heardListReflection.heardInfo[bid], args.MaxMeasError)) { fgCheck = false; break; } } /* // cylinder with cylinder for (size_t j = 1; j < cylinderList.size(); j++) { if (!cylinderList[j-1].CheckCollision(cylinderList[j])) fgCheck = false; break; } */ }
static bool IsObjectInField(PHYSICS_BOX_DATA * pbox) { for(size_t i = 0; i < MAX_SPELLS; i++) { const SpellBase * spell = spells[SpellHandle(i)]; if(spell && spell->m_type == SPELL_CREATE_FIELD) { const CreateFieldSpell * sp = static_cast<const CreateFieldSpell *>(spell); if(ValidIONum(sp->m_entity)) { Entity * pfrm = entities[sp->m_entity]; Cylinder cyl = Cylinder(Vec3f_ZERO, 35.f, -35.f); for(long k = 0; k < pbox->nb_physvert; k++) { PHYSVERT * pv = &pbox->vert[k]; cyl.origin = pv->pos + Vec3f(0.f, 17.5f, 0.f); if(CylinderPlatformCollide(cyl, pfrm)) { return true; } } } } } return false; }
Component FutabaS3003::getCrown(int type, double height, bool fill_hole) { //Crown. Three types: rounded, four and six arms. Component difference, arm, crown; //Four arms type. if(type == FOUR) { difference = Cube(10,20.5,height).translate(10,6,0).rotateAround(0,0,13.392,5,2,0); arm = Cube(10,12.5,height).translate(0,6.25,0) - difference - difference.mirroredCopy(1,0,0) + Cylinder(2.5,height,20,true).translate(0,12.5,0); crown = Cube(10.2,10.2,height); for(int i=0; i<4; i++) crown = crown + arm.translatedCopy(0,5,0).rotatedCopy(0,0,90*i); } //Six arms type. else if(type == SIX) { difference = Cube(7.5,9.3,height).translate(7.5,4.75,0).rotateAround(0,0,9.717,3.75,0.1,0); arm = Cube(7.5,7.4,height).translate(0,3.65,0) - difference - difference.mirroredCopy(1,0,0) + Cylinder(2.5,height,20,true).translate(0,7.4,0); crown = Cylinder(7.5,height); for(int i=0; i<6; i++) crown = crown + arm.translatedCopy(0,6.5,0).rotatedCopy(0,0,60*i); } //Rounded type. else crown = Cylinder(10.75,height,30,true); if(!fill_hole) crown = crown - Cylinder(4.25, height + 2); return crown; }
void LunarModule::DrawStructs() { glPushAttrib(GL_ALL_ATTRIB_BITS); // Struct ball glPushMatrix(); glTranslatef(0, -20, 50); glutSolidSphere(5, 15, 15); glPopMatrix(); // Top left glPushMatrix(); glRotatef(110, 1, 0, 0); glNormal3f(0, 0, 1); glColor3f(0.5, 0.5, 0.5); Cylinder(55, 2); glPopMatrix(); // Top right glPushMatrix(); glTranslatef(40, 0, 40); glRotatef(150, 1, 0, 0); glRotatef(60, 0, 0, 1); glColor3f(0.5, 0.5, 0.5); Cylinder(45, 2); glPopMatrix(); // Bottom left glPushMatrix(); glTranslatef(0, -40, 0); glRotatef(70, 1, 0, 0); glColor3f(0.5, 0.5, 0.5); Cylinder(55, 2); glPopMatrix(); // Bottom right glPushMatrix(); glTranslatef(40, -40, 40); glRotatef(30, 1, 0, 0); glRotatef(60, 0, 0, 1); glColor3f(0.5, 0.5, 0.5); Cylinder(45, 2); glPopMatrix(); glPopAttrib(); }
ParticleSystemModel::Emitter::Specification::Specification(const Any& a) { a.verifyNameBeginsWith("ParticleSystemModel::Emitter"); *this = Specification(); AnyTableReader r(a); r.getIfPresent("location", location); r.getIfPresent("noisePower", noisePower); r.getIfPresent("initialDensity", initialDensity); r.getIfPresent("rateCurve", rateCurve); r.getIfPresent("coverageFadeInTime", coverageFadeInTime); r.getIfPresent("coverageFadeOutTime", coverageFadeOutTime); r.getIfPresent("particleLifetimeMean", particleLifetimeMean); r.getIfPresent("particleLifetimeVariance", particleLifetimeVariance); r.getIfPresent("angularVelocityMean", angularVelocityMean); r.getIfPresent("angularVelocityVariance", angularVelocityVariance); r.getIfPresent("material", material); r.getIfPresent("radiusMean", radiusMean); r.getIfPresent("radiusVariance", radiusVariance); r.getIfPresent("particleMassDensity", particleMassDensity); r.getIfPresent("dragCoefficient", dragCoefficient); shapeType = Shape::Type::NONE; Any shape; if (r.getIfPresent("shape", shape)) { if (shape.nameBeginsWith("ArticulatedModel") || (shape.type() == Any::STRING)) { shapeType = Shape::Type::MESH; } else { shapeType = Shape::Type(toUpper(shape.name())); } switch (shapeType) { case Shape::Type::BOX: box = Box(shape); break; case Shape::Type::CYLINDER: cylinder = Cylinder(shape); break; case Shape::Type::SPHERE: sphere = Sphere(shape); break; case Shape::Type::MESH: mesh = shape; break; default: shape.verify(false, "Shape must be a Box, Cylinder, Sphere, or ArticulatedModel specification"); } } r.getIfPresent("velocityDirectionMean", velocityDirectionMean); r.getIfPresent("velocityConeAngleDegrees", velocityConeAngleDegrees); r.getIfPresent("velocityMagnitudeMean", velocityMagnitudeMean); r.getIfPresent("velocityMagnitudeVariance", velocityMagnitudeVariance); r.verifyDone(); }
void setUpPlanet(PlanetPart& part , GLfloat radiusT , GLfloat rotateMod , GLfloat y , GLfloat planetScale ,char* path ) { part.planet = Planet(10 ,(y+ 4) ,0 , path); part.planet.scale = planetScale; part.upPole = Cylinder(10 , (y + 2.0f) ,0 , 0.1f , 4.0f , 15); part.outPole = OutPole(0 , y ,0 , 0.2f , radiusT + 0.2f , 15); part.outPole.setAngle(0,0,90); part.radius = radiusT; part.rotateModifier = rotateMod; }
void Tree::drawCylinder(float r, float size, int rotation) { // Construct the actual shape Shape shape = Cylinder(r, size, Point(0, 0, 0)); ColouredSurface green = ColouredSurface(0.0, 0.392, 0.0); shape.setSurface(&green); // Translate to the end of the shape glPushMatrix(); glTranslatef(0, 0, (size/2)); shape.render(); }
void CylinderExtent::loadCylinder ( Iff & iff ) { iff.enterChunk(TAG_CYLN); Vector base = iff.read_floatVector(); real radius = iff.read_float(); real height = iff.read_float(); m_cylinder = Cylinder(base,radius,height); iff.exitChunk(TAG_CYLN); }
Component RefSysView::genComponent() { Component x_axis = Cylinder(0.5,7,10,false) + Cylinder(1,0,3,10,false).translate(0,0,7); x_axis.rotate(0,90,0); Component y_axis = Cylinder(0.5,7,10,false) + Cylinder(1,0,3,10,false).translate(0,0,7);; y_axis.rotate(-90,0,0); Component z_axis = Cylinder(0.5,10,10,false) + Cylinder(1,0,3,10,false).translate(0,0,10); Component refsysview = x_axis.color(1,0,0) + y_axis.color(0,1,0) + z_axis.color(0,0,1) ; RotationalMatrix rot = _refSys.getRotMatrix(); double ax,ay,az; rot.getGlobalXYZAngles(ax,ay,az); refsysview.rotate(ax,ay,az) .translate(_refSys.getOrigin().x,_refSys.getOrigin().y,_refSys.getOrigin().z); return refsysview; }
void LunarModule::DrawCompressor() { glPushAttrib(GL_ALL_ATTRIB_BITS); glPushMatrix(); glTranslatef(0, -20, 50); glRotatef(140, 1, 0, 0); glRotatef(20, 0, 0, 1); int minPressure = 15; int maxPressure = 0; if (keyframe == 1) { compressorPressure-=0.15; compressorPressure = (compressorPressure <= maxPressure) ? maxPressure : compressorPressure; }else if(keyframe == 2) { compressorPressure+=0.4; compressorPressure = (compressorPressure >= minPressure) ? minPressure : compressorPressure; } glColor3f(0, 0, 0); Cylinder(35, 3); glTranslatef(0, 30, 0); glColor3f(1, 1, 1); Cylinder(compressorPressure, 2); // Feet glColor3f(1.0,1.0,0.6); glTranslatef(0, compressorPressure + 2, 0); glRotatef(-50, 1, 0, 0); glRotatef(15, 0, 1, 0); glNormal3f(0, 1, 0); DrawCircle(20); glRotatef(180, 1, 0, 0); glNormal3f(0, 0, 0); DrawCircle(20); glPopMatrix(); glPopAttrib(); }
Component FutabaS3003::build() { Component joint = Cylinder(4.25,4,30,true); Component hole_servo = Cylinder(1.8,1.8,15.0,20); Component hole_servo_fill = Cylinder(1.8,1.8,36.6,20,false); Component servo = RoundedTablet(20.5,41.5,36.6,1,true,true,true,true,100,false) + getCrown(_type,3,true).translate(10.5,10.5,42.1) + joint.translate(10.5,10.5,38.6) + RoundedTablet(20,9,3,1,true,true,true,true,50,false).translate(0.25,-8,26.6) + RoundedTablet(20,9,3,1,true,true,true,true,50,false).translate(0.25,40.5,26.6); //fill the holes of the screws? if(!_fill_hole) servo = servo - hole_servo.translatedCopy(5.25,-4.25,24) - hole_servo.translatedCopy(15.25,-4.25,24) - hole_servo.translatedCopy(5.25,45.75,24) - hole_servo.translatedCopy(15.25,45.75,24); else servo = servo //+ Cube(5,2,36.5,false).translate(7.75,41.5,0) + hole_servo_fill.translatedCopy(5.25,-4.25,0) + hole_servo_fill.translatedCopy(15.25,-4.25,0) + hole_servo_fill.translatedCopy(5.25,45.75,0) + hole_servo_fill.translatedCopy(15.25,45.75,0); //leave space for inserting the cable if (_cable_hole){ servo = servo + Cube(5,2,3,false).translate(7.75,41.5,0); } servo.color(0.3,0.3,0.3); return servo; }
void AirPlane(float x, float y, float z) { static float i = 0, f = 0; i += 0.1; f += 0.01; if (i > 360) i = 0; if (f > 360) f = 0; glPushMatrix(); glTranslatef(x, y, z); glRotatef(f, 1, 1, 1); glPushMatrix(); glColor3f(0.5, 1.5, 0.5); glRotatef(i, 0, 1, 0); glTranslatef(0, 0, 0.5); glScalef(0.1, 0.05, 1); Cube(); //螺旋桨 glPopMatrix(); glTranslatef(0, -0.1, 0); glScalef(0.1, 0.1, 0.1); Cube(); glScalef(10, 10, 10); glColor3f(1, 0, 1); glTranslatef(0.04, -0.05, -0.9); glScalef(0.1, 0.1, 1.5); Cylinder(); glColor3f(0, 1, 0); glScalef(1, 1, 0.2); Cone(); glColor3f(0, 1, 1); glTranslatef(0, 0.7, -4.5); glScalef(0.2, 2, 1); Cube(); glTranslatef(-13, 0.3, 0); glScalef(27, 0.1, 1); Cube(); glPopMatrix(); }
Component ArduinoUNO::build() { Component board = getBoard(2,_drills_height,_fill_drills,_fourth_drill); Component micro = Cube(35.5,10,7,false).translate(28.5,11.5,2); Component pins = Cube(42.5,2.5,8,false).translate(22.5,49.5,2) + Cube(33.5,2.5,8,false).translate(31.7,1.5,2) + Cube(5,7.5,8,false).translate(62.5,24.5,2); Component usb = Cube(15.875,11.43,11,false).translate(-6.35,32.385,2); Component power = Cylinder(4,14,int(50),false).rotate(0,-90,0).translate(-1.905 + 14,3.175 + 4 + 0.5,8.5) + Cube(14,9,6.5,false).translate(-1.905,3.175,2) + Cube(3.5,9,10.5,false).translate(-1.905,3.175,2); Component capacitors = Cube(6.5,6.5,5,false).translate(17.5,1.6,2) + Cube(6.5,6.5,5,false).translate(25,1.6,2); Component button = Cube(6,6,3,false).translate(52.5,24.5,2); Component arduino = board.color(0,0,0.6) + pins.color(0.2,0.2,0.2) + micro.color(0.2,0.2,0.2) + usb.color(0.7,0.7,0.7) + power.color(0.7,0.7,0.7) + capacitors.color(0.5,0.5,0.5) + button.color(0.5,0.5,0.5); return arduino; }
/* * Draw scene * light>0 lit colors * light<0 shaded colors * light=0 shadow volumes */ void Scene(int Light) { int k; // Counters used to draw floor // Set global light switch (used in DrawPolyShadow) light = Light; // Texture (pi.bmp) glBindTexture(GL_TEXTURE_2D,tex2d[2]); // Enable textures if not drawing shadow volumes if (light) glEnable(GL_TEXTURE_2D); // Draw objects x y z th,ph dims if (obj&0x01) Cube(-0.8,+0.8,0.0 , -0.25*zh, 0 , 0.3 ); if (obj&0x02) Cylinder(+0.8,+0.5,0.0 , 0.5*zh,zh , 0.2,0.5); if (obj&0x04) Torus(+0.5,-0.8,0.0 , 0,zh , 0.5,0.2); if (obj&0x08) Teapot(-0.5,-0.5,0.0 , 2*zh, 0 , 0.25 ); // Disable textures if (light) glDisable(GL_TEXTURE_2D); // The floor, ceiling and walls don't cast a shadow, so bail here if (!light) return; // Always enable textures glEnable(GL_TEXTURE_2D); Color(1,1,1); // Water texture for floor and ceiling glBindTexture(GL_TEXTURE_2D,tex2d[0]); for (k=-1;k<=box;k+=2) Wall(0,0,0, 0,90*k , 8,8,box?6:2 , 4); // Crate texture for walls glBindTexture(GL_TEXTURE_2D,tex2d[1]); for (k=0;k<4*box;k++) Wall(0,0,0, 90*k,0 , 8,box?6:2,8 , 1); // Disable textures glDisable(GL_TEXTURE_2D); }
void Flag::Display() { glPushAttrib(GL_ALL_ATTRIB_BITS); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, matAmbient); glMaterialfv(GL_FRONT, GL_DIFFUSE, matDiffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, matSpecular); glMateriali(GL_FRONT, GL_SHININESS, matShininess); glColor3f(0.1, 0.1, 0.1); glTranslatef(300, -100, 300); Cylinder(100, 1); glTranslatef(0, 55, 0); glRotatef(-65, 0, 1, 0); GLFrame frame = {0, 0, 45, 45}; DrawTexturedQuad(frame, texture); glRotatef(180, 0, 1, 0); DrawTexturedQuad(frame, texture); glPopMatrix(); glPopAttrib(); }
static bool IsPointInField(const Vec3f & pos) { for(size_t i = 0; i < MAX_SPELLS; i++) { const SpellBase * spell = spells[SpellHandle(i)]; if(spell && spell->m_type == SPELL_CREATE_FIELD) { const CreateFieldSpell * sp = static_cast<const CreateFieldSpell *>(spell); if(ValidIONum(sp->m_entity)) { Entity * pfrm = entities[sp->m_entity]; Cylinder cyl = Cylinder(pos + Vec3f(0.f, 17.5f, 0.f), 35.f, -35.f); if(CylinderPlatformCollide(cyl, pfrm) != 0.f) { return true; } } } } return false; }
Component ArduinoUNO::getBoard(double height, double holes_height, bool fill_holes, bool fourth_hole){ Component board; Polygon<Point2D> base1, base2; base1.addPoint(Point2D(0, 0)); base1.addPoint(Point2D(0, 37.846)); base1.addPoint(Point2D(68.58, 37.846)); base1.addPoint(Point2D(68.58, 5.08)); base1.addPoint(Point2D(66.04, 2.54)); base1.addPoint(Point2D(66.04, 0)); base2.addPoint(Point2D(0, 37.346)); base2.addPoint(Point2D(0, 53.34)); base2.addPoint(Point2D(64.516, 53.34)); base2.addPoint(Point2D(66.04, 51.816)); base2.addPoint(Point2D(66.04, 40.386)); base2.addPoint(Point2D(68.58, 37.846)); Component prism1 = PolygonalPrism(base1, height); Component prism2 = PolygonalPrism(base2, height); Component hole_arduino = Cylinder(1.58,1.58,holes_height,20,true); Component holes = hole_arduino.translatedCopy(13.97,2.54,0) + hole_arduino.translatedCopy(66.04,7.62,0) + hole_arduino.translatedCopy(66.04,35.56,0); if(fourth_hole){ holes = holes + hole_arduino.translatedCopy(15.24,50.8,0); } if(fill_holes) board = prism1 + prism2 + holes; else board = prism1 + prism2 - holes; return board.color(0,0,1); }
Robot::Robot(double x, double y, double a, QObject *parent){ md_linearVelocity=md_angularVelocity=0; md_wheelTrack=1.0; for (int i=0; i<2; ++i) m_wheel[i] = Wheel(0,0.3); md_position = new double [3]; md_position[0]=x; md_position[1]=y; md_position[2]=a; m_cylinder = Cylinder(); m_arm = Arm(); battery = new Battery(); state=BASIC; socket = new QTcpSocket(this); socket->connectToHost(QString("192.168.0.1"), 2000); connect(socket, SIGNAL(connected()), this, SLOT(connected())); connect(socket, SIGNAL(hostFound()), this, SLOT(connected())); connect(socket, SIGNAL(disconnected()), this, SLOT(not_connected())); bl=new char[4]; }
void Gizmo::Build() { /*axisX.Build(Vector3::Zero, Vector3(1, 0, 0), D3DXCOLOR(1, 0, 0, 1), 4.0f); axisY.Build(Vector3::Zero, Vector3(0, 1, 0), D3DXCOLOR(0, 1, 0, 1), 4.0f); axisZ.Build(Vector3::Zero, Vector3(0, 0, 1), D3DXCOLOR(0, 0, 1, 1), 4.0f);*/ axisX = Cylinder(0.02f, 0.02f, 1.0f, 12, 8, D3DXCOLOR(1, 0, 0, 1)); axisX.CalculateNormals(); axisX.Build(XYZ_N); axisX.rotation = Quaternion(0, 0, -PI/2); axisY = Cylinder(0.02f, 0.02f, 1.0f, 12, 8, D3DXCOLOR(0, 1, 0, 1)); axisY.CalculateNormals(); axisY.Build(XYZ_N); axisZ = Cylinder(0.02f, 0.02f, 1.0f, 12, 8, D3DXCOLOR(0, 0, 1, 1)); axisZ.CalculateNormals(); axisZ.Build(XYZ_N); axisZ.rotation = Quaternion(PI/2, 0, 0); coneX = Cylinder(0.0f, 0.08f, 0.2f, 12, 8, D3DXCOLOR(1, 0, 0, 1)); coneX.CalculateNormals(); coneX.Build(XYZ_N); coneX.position = Vector3(1, 0, 0); coneX.rotation = Quaternion(0, 0, -PI/2); coneY = Cylinder(0.0f, 0.08f, 0.2f, 12, 8, D3DXCOLOR(0, 1, 0, 1)); coneY.CalculateNormals(); coneY.Build(XYZ_N); coneY.position = Vector3(0, 1, 0); coneZ = Cylinder(0.0f, 0.08f, 0.2f, 12, 8, D3DXCOLOR(0, 0, 1, 0)); coneZ.CalculateNormals(); coneZ.Build(XYZ_N); coneZ.position = Vector3(0, 0, 1); coneZ.rotation = Quaternion(PI/2, 0, 0); }
Cylinder CoordinateFrame::toWorldSpace(const Cylinder& c) const { return Cylinder( pointToWorldSpace(c.point(0)), pointToWorldSpace(c.point(1)), c.radius()); }
void Display(void) { /*glPushMatrix(); glPopMatrix();*/ double c = L/(2*R1); double alfa= 90 - acos(c)*180/PI; double static Time=0; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Fence(500,0,-r2-r1,-r2-r1,2); // пол glColor3d(1, 0.5, 0); // glPushMatrix(); glPushMatrix(); glTranslated(-20,0,0); glRotated(Time+60,0,1,0); glTranslated(R1,0,0); //glTranslated(-20,0,0); glRotated(90,0,1,0); glPushMatrix(); glRotated(-Time*(R1/r2),0,0,1); Koleso(r1,r2); // переднее колесо glPopMatrix(); glPushMatrix(); glTranslated(0,0,1.2); glColor3d(1, 0.3, 0); // Cylinder(0.3,0,r1+r2+0.5); // планка руля 1 glTranslated(0,0,-2.4); Cylinder(0.3,0,r1+r2+0.5); // планка руля 2 glPopMatrix(); Cylinder(0.5,r1+r2+0.5,r1+r2+0.5+L2); // передняя вертикальная планка glPushMatrix(); glRotated(-90,1,0,0); glColor3d(0, 1, 0.5); // Cylinder(0.2,-2,2); // передняя ось glPushMatrix(); glTranslated(0,2,0); glPushMatrix(); glRotated(180+Time*(R1/r2),0,1,0); // педаль 1 glTranslated(r2,0,0); Cylinder(0.4,0,2); glPopMatrix(); glRotated(90,0,0,1); glRotated(Time*(R1/r2),1,0,0); Cylinder(0.2,0,r2); // ось педали 1 glPopMatrix(); glPushMatrix(); glTranslated(0,-4,0); glRotated(180+Time*(R1/r2),0,1,0); // педаль 2 glTranslated(-r2,0,0); Cylinder(0.4,0,2); glPopMatrix(); glPushMatrix(); glTranslated(0,-2,0); glRotated(-90,0,0,1); glRotated(-Time*(R1/r2),1,0,0); Cylinder(0.2,0,r2); // ось педали 2 glPopMatrix(); glTranslated(0,0,r1+r2+0.5); glColor3d(0, 1, 0.5); // Cylinder(0.3,-1.5,1.5); // передняя гооизонтальная планка glTranslated(0,0,L2); Cylinder(0.3,-L3,L3); // руль glPopMatrix(); glRotated(90,0,0,1); glTranslated(r2+r1+0.5+L2/2,0,0); glRotated(-alfa,1,0,0); Cylinder(0.5,0,L); // горизонтальная планка glRotated(90,1,0,0); glTranslated(-2*r2+r4-2*r1+r3-0.5-L2/2,0,-L); Cylinder(0.5,-L1+r3/2,L1-r3/2); // задняя ось Cylinder(0.2,-L1-r3/2,L1+r3/2); // задняя ось glRotated(90,1,0,0); glPushMatrix(); glRotated(-90,0,0,1); glColor3d(1, 0.3, 0); // Cylinder(0.5,0,2*r1+2*r2-r3-r4+2+L2/2); // задняя вертикальная планка Fence(1,1,2*r1+2*r2-r3-r4+2+L2/2,2*r1+2*r2-r3-r4+2.5+L2/2,1); // седлушка Fence(1,0,2*r1+2*r2-r3-r4+2.5+L2/2,2*r1+2*r2-r3-r4+2.5+L2/2,1); glPopMatrix(); glTranslated(0,0,L1); glPushMatrix(); glRotated(Time*((R1-L1)/r4),0,0,1); glColor3d(1, 0.5, 0); // Koleso(r3,r4); // заднее колесо 1 glPopMatrix(); glTranslated(0,0,-(2*L1)); glPushMatrix(); glRotated(Time*((R1+L1)/r4),0,0,1); Koleso(r3,r4); // заднее колесо 2 glPopMatrix(); glPopMatrix(); glPopMatrix(); glFinish(); glutSwapBuffers(); Time=Time+V; }
void init (void) { glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glCullFace(GL_BACK); glEnable(GL_COLOR_MATERIAL); glEnable(GL_TEXTURE_2D); skybox = SpaceWall(); table = TableSurface(); sun = Sun(0.0f , 13.0f , 0.0f); centralPole = Cylinder(0,8.0f,0 ,0.54f , 12.0f , 30); baseBox = Box(0,1.01f,0 , 10,10,2); coverBox = Box(0,3.2f,3.8f , 10,1,0.5); coverBox2 = Box(0,3.2f,-3.8f , 10,1,0.5); coverBox3 = Box(4.4f,3.3f,0 , 9,1,0.5); coverBox3.setAngle(90 ,180 , 90); coverBox4 = Box(-4.4f,3.3f,0 , 9,1,0.5f); coverBox4.setAngle(90 ,180 , 90); mainGear = Gear(0 ,2.3f ,0 , 0.5f , 4.0f , 0.4f , 50 ,0.35f); bigPowerGear = Gear(-4.3f ,2.8f ,3.8f , 0.2f , 4.0f , 0.4f , 50 ,0.35f); powerGear = Gear(4.3f ,2.3f ,3.8f , 0.2f , 1.6f , 0.4f , 20 ,0.35f); smallMiddleGear = Gear(0 ,2.8f ,0 , 0.5f , 1.6f , 0.4f , 20 ,0.35f); sideGear = Gear(5.9f ,1.5f ,3.8f , 0.2f , 0.7f , 0.2f , 10 ,0.35f); sidePole = Cylinder(5.9f ,1.5f ,3.8f ,0.18f , 2.0f , 30); sidePole.setAngle(180 ,90 ,0); sideGear.setAngle(180 ,90 ,0); saturnRingPole = Cylinder(4.3f ,3.3f ,3.8f ,0.04f , 4.3f , 20); saturnRingPole.setAngle(0,0 ,0); powerPole = Cylinder(4.3f ,3.3f ,3.8f ,0.18f , 2.0f , 30); powerPole2 = Cylinder(-4.3f ,3.3f ,3.8f ,0.18f , 2.0f , 30); powerPole3 = Cylinder(-4.3f ,3.3f ,-3.8f ,0.18f , 2.0f , 30); powerPole4 = Cylinder(4.3f ,3.3f ,-3.8f ,0.18f , 2.0f , 30); moonCylinder = Cylinder(-4.3f ,3.3f ,2.0f ,0.3f, 1.0f , 30); neptunePole = Cylinder(0,4.62f,0 ,0.9f , 3.3f , 30); uranusPole = Cylinder(0,5.0f,0 ,0.8f , 3.5f , 30); saturnPole = Cylinder(0,5.4f,0 ,0.7f , 3.7f , 30); jupiterPole = Cylinder(0,5.8f,0 ,0.6f , 3.9f , 30); marsPole = Cylinder(0,6.2f,0 ,0.5f , 4.1f , 30); earthPole = Cylinder(0,6.58f,0 ,0.4f , 4.3f , 30); venusPole = Cylinder(0,6.96f,0 ,0.3f , 4.5f , 30); mercuryPole = Cylinder(0,8,0 ,0.2f , 5.0f , 30); saturnRing = SaturnRing(0 ,11.0f ,0 ,2.4f , 0.2f , 30); saturnRing.yAngle = -12; setUpPlanet(mercury , 5 ,4.1f ,9.5f , 0.4f , "Textures\\mercury.bmp"); setUpPlanet(venus , 10 ,1.62f ,9.0f , 1.0f , "Textures\\venus.bmp"); setUpPlanet(earth , 15 ,1 ,8.5f , 1.0 , "Textures\\earth.bmp"); setUpPlanet(mars , 20 ,0.53f ,8.0f , 0.53f , "Textures\\mars.bmp"); setUpPlanet(jupiter , 25 ,0.08f ,7.5 , 2.0f , "Textures\\jupiter.bmp"); setUpPlanet(saturn , 30 ,0.0339f ,7.0f , 1.5f , "Textures\\saturn.bmp"); setUpPlanet(uranus , 35 ,0.011f ,6.5f , 1.2f , "Textures\\uranus.bmp"); setUpPlanet(neptune , 40 ,0.006f ,6.0f , 1.2f, "Textures\\neptune.bmp"); setUpPlanet(moon , 2 ,13 ,8.8f , 0.3f , "Textures\\moon.bmp"); //Earths Tilt earth.planet.setAngle(-90,23.5,0); }
int main() { // Here, you can change the board for which a case you want to construct. // Don't forget to change the #include statement above. #if 1 BoardDescription board = rasdr2Board(); std::string name = "rasdr2"; // File name prefix #else BoardDescription board = postsBoard(); std::string name = "posts"; // File name prefix #endif // Create a factory to build a case for this board. CaseFactory factory(board); // customize some parameters (note some of these should be in the board description) factory.screwHeadsOnSide = TopSide; factory.holesAddRadiusLoose = .1; // posts that have the recessed head (screwHeadsOnSide) factory.holesAddRadiusTight = .1; // posts that have the captive nut (not screwHeadsOnSide) factory.holesFloors = 12.7; // NB: related to max z height of top forbidden areas (16.20 for rasdr2) factory.walls = 3.0; factory.floors = 2.0; factory.cornerRadius = 1; // NB: complex dependency on walls/floors; dont make this too big or be prepared to fiddle... factory.cornerFaces = 20; // should be >= 16. // Now we can fine-tune some dimension parameters for the case model. See the class CaseFactory for more options, such as wall thickness, screw hole radius etc. factory.smallerBottomHeight = .5; // We want the bottom part to be a bit less high (so the GPIO pin ends will be within the floor; this is just to demonstrate the power of the feature "forbidden areas") factory.printLayerHeight = .2; factory.printSafeBridgeLayerCount = 3; // Generate the models Component bottom = factory.constructBottom(); Component top = factory.constructTop(); // Write these models to SCAD files. We generate 3(4) files. // 1) Only the bottom: write(name + "-case-bottom.scad", bottom); // 2) Only the top: write(name + "-case-top.scad", top); // 3) Both parts side by side: double distance = 15; // in mm; give enough space to add 'pads' to hold the edges down double offset = factory.outerDimensions().x + distance; bool adjacent_in_x = true; if( adjacent_in_x ) { write(name + "-case.scad", bottom + top.translatedCopy(offset, 0, 0)); // put offset into x or y based on above... } else { offset = factory.outerDimensions().y + distance; // choose .x or .y write(name + "-case.scad", bottom + top.translatedCopy(0, offset, 0)); // put offset into x or y based on above... } // Write an SCAD file for printing that has 'pads' to keep the rounded edges from curling if( factory.cornerRadius > 0.0 ) { double cr = factory.cornerRadius; double r = (distance - cr/2)/2; double x = factory.outerDimensions().x; double y = factory.outerDimensions().y; double w = factory.walls; double h = cr<2?cr/2:0.75; Component pad = Cylinder(r, h, 32, false); Component pads, part; double aa = 2*w-w+cr; // adjust x double bb = ((cr>w)?cr-w:0)+cr/2; // adjust for cr exceeding w double cc = -cr+cr/4; // adjust y // pads based on 'bottom' dimensions pads = pad.translatedCopy(x+r-aa, r-w, 0) + pad.translatedCopy(x+r-aa, y-2*r, 0); // EAST face pads = pads + pad.translatedCopy(-r-w+bb, r/2, 0) + pad.translatedCopy(-r-w+bb, y-2*r, 0); // WEST face pads = pads + pad.translatedCopy(r-w, -r-w+cr/2, 0) + pad.translatedCopy(x-2*r, -r-w+cr/2, 0); // SOUTH face pads = pads + pad.translatedCopy(r-w, y+r-w+cc, 0) + pad.translatedCopy(x-2*r, y+r-w+cc, 0); // NORTH face if( adjacent_in_x ) { part = bottom + pads; part = part + top.translatedCopy(offset-cr, 0, 0) + pads.translatedCopy(offset-cr, 0, 0); } else { part = bottom + pads; part = part + top.translatedCopy(0, offset-cr, 0) + pads.translatedCopy(0, offset-cr, 0); } write(name + "-case-mfg.scad", part); } return 0; }
Cylinder CylindricalSurface::inside() const { return Cylinder(center_, radius_, axis_, half_height_); }
bool Manage3DCursor(Entity * io, bool simulate) { arx_assert(io); if(BLOCK_PLAYER_CONTROLS) return false; float ag = player.angle.getPitch(); if(ag > 180) ag = ag - 360; float drop_miny = float(g_size.center().y) - float(g_size.center().y) * ag * (1.f/70); if(DANAEMouse.y < drop_miny) return false; Anglef angle = Anglef::ZERO; if(io->ioflags & IO_INVERTED) { angle.setPitch(180.f); angle.setYaw(-MAKEANGLE(270.f - io->angle.getYaw() - (player.angle.getYaw() - STARTED_ANGLE))); } else { angle.setYaw(MAKEANGLE(270.f - io->angle.getYaw() - (player.angle.getYaw() - STARTED_ANGLE))); } EERIE_3D_BBOX bbox; for(size_t i = 0; i < io->obj->vertexlist.size(); i++) { bbox.add(io->obj->vertexlist[i].v); } Vec3f mvectx = angleToVectorXZ(player.angle.getYaw() - 90.f); Vec2f mod = Vec2f(Vec2i(DANAEMouse) - g_size.center()) / Vec2f(g_size.center()) * Vec2f(160.f, 220.f); mvectx *= mod.x; Vec3f mvecty(0, mod.y, 0); Vec3f orgn = player.pos; orgn += angleToVector(player.angle) * 50.f; orgn += mvectx; orgn.y += mvecty.y; Vec3f dest = player.pos; dest += angleToVector(player.angle) * 10000.f; dest += mvectx; dest.y += mvecty.y * 5.f; Vec3f pos = orgn; Vec3f movev = glm::normalize(dest - orgn); float lastanything = 0.f; float height = -(bbox.max.y - bbox.min.y); if(height > -30.f) height = -30.f; Vec3f objcenter = bbox.min + (bbox.max - bbox.min) * Vec3f(0.5f); Vec3f collidpos = Vec3f_ZERO; bool collidpos_ok = false; { float maxdist = 0.f; for(size_t i = 0; i < io->obj->vertexlist.size(); i++) { const EERIE_VERTEX & vert = io->obj->vertexlist[i]; float dist = glm::distance(Vec2f(objcenter.x, objcenter.z), Vec2f(vert.v.x, vert.v.z)) - 4.f; maxdist = std::max(maxdist, dist); } if(io->obj->pbox) { Vec2f tmpVert(io->obj->pbox->vert[0].initpos.x, io->obj->pbox->vert[0].initpos.z); for(int i = 1; i < io->obj->pbox->nb_physvert; i++) { const PHYSVERT & physVert = io->obj->pbox->vert[i]; float dist = glm::distance(tmpVert, Vec2f(physVert.initpos.x, physVert.initpos.z)) + 14.f; maxdist = std::max(maxdist, dist); } } Cylinder cyl2 = Cylinder(Vec3f_ZERO, glm::clamp(maxdist, 20.f, 150.f), std::min(-30.f, height)); const float inc = 10.f; long iterating = 40; while(iterating > 0) { cyl2.origin = pos + movev * inc + Vec3f(0.f, bbox.max.y, 0.f); float anything = CheckAnythingInCylinder(cyl2, io, CFLAG_JUST_TEST | CFLAG_COLLIDE_NOCOL | CFLAG_NO_NPC_COLLIDE); if(anything < 0.f) { if(iterating == 40) { CANNOT_PUT_IT_HERE = EntityMoveCursor_Invalid; // TODO is this correct ? return true; } iterating = 0; collidpos = cyl2.origin; if(lastanything < 0.f) { pos.y += lastanything; collidpos.y += lastanything; } } else { pos = cyl2.origin; lastanything = anything; } iterating--; } collidpos_ok = iterating == -1; } objcenter = VRotateY(objcenter, angle.getYaw()); collidpos.x -= objcenter.x; collidpos.z -= objcenter.z; pos.x -= objcenter.x; pos.z -= objcenter.z; if(!collidpos_ok) { CANNOT_PUT_IT_HERE = EntityMoveCursor_Invalid; return false; } if(collidpos_ok && closerThan(player.pos, pos, 300.f)) { if(simulate) { ARX_INTERACTIVE_Teleport(io, pos, true); io->gameFlags &= ~GFLAG_NOCOMPUTATION; glm::quat rotation = glm::quat_cast(toRotationMatrix(angle)); if(SPECIAL_DRAGINTER_RENDER) { if(glm::abs(lastanything) > glm::abs(height)) { TransformInfo t(collidpos, rotation, io->scale); static const float invisibility = 0.5f; DrawEERIEInter(io->obj, t, io, false, invisibility); } else { TransformInfo t(pos, rotation, io->scale); float invisibility = Cedric_GetInvisibility(io); DrawEERIEInter(io->obj, t, io, false, invisibility); } } } else { if(glm::abs(lastanything) > std::min(glm::abs(height), 12.0f)) { Entity * io = DRAGINTER; ARX_PLAYER_Remove_Invisibility(); io->obj->pbox->active = 1; io->obj->pbox->stopcount = 0; io->pos = collidpos; io->velocity = Vec3f_ZERO; io->stopped = 1; movev.x *= 0.0001f; movev.y = 0.1f; movev.z *= 0.0001f; Vec3f viewvector = movev; io->soundtime = ArxInstant_ZERO; io->soundcount = 0; EERIE_PHYSICS_BOX_Launch(io->obj, io->pos, angle, viewvector); ARX_SOUND_PlaySFX(SND_WHOOSH, &pos); io->show = SHOW_FLAG_IN_SCENE; Set_DragInter(NULL); } else { ARX_PLAYER_Remove_Invisibility(); ARX_SOUND_PlayInterface(SND_INVSTD); ARX_INTERACTIVE_Teleport(io, pos, true); io->angle.setPitch(angle.getPitch()); io->angle.setYaw(270.f - angle.getYaw()); io->angle.setRoll(angle.getRoll()); io->stopped = 0; io->show = SHOW_FLAG_IN_SCENE; io->obj->pbox->active = 0; Set_DragInter(NULL); } } GRenderer->SetCulling(CullNone); return true; } else { CANNOT_PUT_IT_HERE = EntityMoveCursor_Throw; } return false; }