void updatePlanets(void) { orbitTimer+= orbitSpeed; mercury.update(); venus.update(); earth.update(); mars.update(); jupiter.update(); saturn.update(); uranus.update(); neptune.update(); //update saturn ring saturnRing.xPosition = saturn.planet.xPosition; saturnRing.zPosition = saturn.planet.zPosition; neptunePole.zAngle = -neptune.outPole.yAngle; uranusPole.zAngle = -uranus.outPole.yAngle; saturnPole.zAngle = -saturn.outPole.yAngle; jupiterPole.zAngle = -jupiter.outPole.yAngle; marsPole.zAngle = -mars.outPole.yAngle; earthPole.zAngle = -earth.outPole.yAngle; venusPole.zAngle = -venus.outPole.yAngle; mercuryPole.zAngle = -mercury.outPole.yAngle; GLfloat xPositionT= earth.planet.xPosition + sin(orbitTimer* moon.rotateModifier)*moon.radius; GLfloat zPositionT = earth.planet.zPosition + cos(orbitTimer* moon.rotateModifier)*moon.radius; moon.planet.setPosition(xPositionT ,moon.planet.yPosition , zPositionT); moon.upPole.setPosition(xPositionT , moon.upPole.yPosition , zPositionT); moon.upPole.spin(1.0); moon.outPole.setOriginPosition(earth.planet.xPosition , 0 , earth.planet.zPosition); GLfloat deltaZ = moon.planet.zPosition - earth.planet.zPosition; GLfloat deltaX = moon.planet.xPosition - earth.planet.xPosition; GLfloat angle = atan2(deltaZ , deltaX) ; angle = -angle * 180.0f / (GLfloat)M_PI; angle+= 90; moon.outPole.setAngle(0, angle , 0); moonCylinder.setPosition(earth.upPole.xPosition ,earth.upPole.yPosition - 1.8f , earth.upPole.zPosition); saturnRingPole.setPosition(saturn.planet.xPosition , saturn.planet.yPosition , saturn.planet.zPosition); }
void update(void) { GLfloat xPositionT = 0 + sin(orbitTimer * rotateModifier) * radius; GLfloat zPositionT = 0 + cos(orbitTimer * rotateModifier) * radius; planet.setPosition(xPositionT ,planet.yPosition , zPositionT); upPole.setPosition(xPositionT , upPole.yPosition , zPositionT); GLfloat angle = atan2(zPositionT , xPositionT); angle = -angle * 180.0f / (GLfloat)M_PI; angle+= 90.0f; outPole.setAngle(0, angle, 0); }
void Handle::initAxisHandleObjects() { // assumes none of them have been created yet Handle::pObjectXTranslateHandleLine = new Cylinder(1.0f, 0.03f, 6, 1); Handle::pObjectYTranslateHandleLine = new Cylinder(1.0f, 0.03f, 6, 1); Handle::pObjectZTranslateHandleLine = new Cylinder(1.0f, 0.03f, 6, 1); Handle::pObjectXTranslateHandleHead = new Cone(0.2f, 0.07f, 8); Handle::pObjectYTranslateHandleHead = new Cone(0.2f, 0.07f, 8); Handle::pObjectZTranslateHandleHead = new Cone(0.2f, 0.07f, 8); Cylinder *pX = Handle::pObjectXTranslateHandleLine; Cylinder *pY = Handle::pObjectYTranslateHandleLine; Cylinder *pZ = Handle::pObjectZTranslateHandleLine; pX->setObjectID(eXTranslate); pX->setPosition(Point(0.6f, 0.0f, 0.0f)); pX->rotate(0.0f, 0.0f, 90.0f); pX->constructGeometry(); pY->setObjectID(eYTranslate); pY->setPosition(Point(0.0f, 0.6f, 0.0f)); pY->constructGeometry(); pZ->setObjectID(eZTranslate); pZ->setPosition(Point(0.0f, 0.0f, 0.6f)); pZ->rotate(-90.0f, 0.0f, 0.0f); pZ->constructGeometry(); Cone *pXHead = Handle::pObjectXTranslateHandleHead; Cone *pYHead = Handle::pObjectYTranslateHandleHead; Cone *pZHead = Handle::pObjectZTranslateHandleHead; pXHead->setObjectID(eXTranslate); pXHead->setPosition(Point(1.1f, 0.0f, 0.0f)); pXHead->rotate(0.0f, 0.0f, -90.0f); pXHead->constructGeometry(); pYHead->setObjectID(eYTranslate); pYHead->setPosition(Point(0.0f, 1.1f, 0.0f)); pYHead->constructGeometry(); pZHead->setObjectID(eZTranslate); pZHead->setPosition(Point(0.0f, 0.0f, 1.1f)); pZHead->rotate(90.0f, 0.0f, 0.0f); pZHead->constructGeometry(); /// object rotate Torus* pXRotate = new Torus(kObjectRotateHandleThickness, kObjectRotateHandleRadius, kObjectRotateHandleSegments, kObjectRotateHandleSides); Torus* pYRotate = new Torus(kObjectRotateHandleThickness, kObjectRotateHandleRadius, kObjectRotateHandleSegments, kObjectRotateHandleSides); Torus* pZRotate = new Torus(kObjectRotateHandleThickness, kObjectRotateHandleRadius, kObjectRotateHandleSegments, kObjectRotateHandleSides); Handle::pObjectXRotateHandleLoop = pXRotate; Handle::pObjectYRotateHandleLoop = pYRotate; Handle::pObjectZRotateHandleLoop = pZRotate; pXRotate->setObjectID(eXRotate); pXRotate->rotate(0.0f, 0.0f, -90.0f); pXRotate->constructGeometry(); pYRotate->setObjectID(eYRotate); pYRotate->rotate(0.0f, 0.0f, 0.0f); pYRotate->constructGeometry(); pZRotate->setObjectID(eZRotate); pZRotate->rotate(90.0f, 0.0f, 0.0f); pZRotate->constructGeometry(); /// face Handle::pFaceNormalTranslateHandleLine = new Cylinder(1.0f, 0.03f, 6, 1); Handle::pFaceNormalTranslateHandleHead = new Cone(0.2f, 0.07f, 8); Handle::pFaceExtrude = new Cube(0.05f); Cylinder* pFaceNormalLine = Handle::pFaceNormalTranslateHandleLine; pFaceNormalLine->setObjectID(eFaceNormalTranslate); pFaceNormalLine->setPosition(Point(0.0f, 0.6f, 0.0f)); pFaceNormalLine->constructGeometry(); Cone* pFaceNormalHead = Handle::pFaceNormalTranslateHandleHead; pFaceNormalHead->setObjectID(eFaceNormalTranslate); pFaceNormalHead->setPosition(Point(0.0f, 1.1f, 0.0f)); pFaceNormalHead->constructGeometry(); Cube* pFaceExtrude = Handle::pFaceExtrude; pFaceExtrude->setObjectID(eFaceExtrude); pFaceExtrude->setPosition(Point(0.0f, 1.4f, 0.0f)); pFaceExtrude->constructGeometry(); Handle::pFaceTranslateXLine = new Cylinder(1.0f, 0.03f, 6, 1); Handle::pFaceTranslateYLine = new Cylinder(1.0f, 0.03f, 6, 1); Cylinder* pFaceTranslateXLine = Handle::pFaceTranslateXLine; pFaceTranslateXLine->setObjectID(eFaceTranslateX); pFaceTranslateXLine->setRotation(Vector(0.0f, 0.0f, -90.0f)); pFaceTranslateXLine->setPosition(Point(0.6f, 0.0f, 0.0f)); pFaceTranslateXLine->constructGeometry(); Cylinder* pFaceTranslateYLine = Handle::pFaceTranslateYLine; pFaceTranslateYLine->setObjectID(eFaceTranslateY); pFaceTranslateYLine->setRotation(Vector(90.0f, 0.0f, 0.0f)); pFaceTranslateYLine->setPosition(Point(0.0f, 0.0f, 0.6f)); pFaceTranslateYLine->constructGeometry(); Handle::pFaceTranslateXHead = new Cone(0.2f, 0.07f, 8); Handle::pFaceTranslateYHead = new Cone(0.2f, 0.07f, 8); Cone* pFaceTranslateXHead = Handle::pFaceTranslateXHead; pFaceTranslateXHead->setObjectID(eFaceTranslateX); pFaceTranslateXHead->setRotation(Vector(0.0f, 0.0f, -90.0f)); pFaceTranslateXHead->setPosition(Point(1.1f, 0.0f, 0.0f)); pFaceTranslateXHead->constructGeometry(); Cone* pFaceTranslateYHead = Handle::pFaceTranslateYHead; pFaceTranslateYHead->setObjectID(eFaceTranslateY); pFaceTranslateYHead->setRotation(Vector(90.0f, 0.0f, 0.0f)); pFaceTranslateYHead->setPosition(Point(0.0f, 0.0f, 1.1f)); pFaceTranslateYHead->constructGeometry(); // Handle::pFaceScaleX = new Cube(0.05f); Handle::pFaceScaleY = new Cube(0.05f); Handle::pFaceScaleUniform = new Cube(0.05f); Cube* pFaceScaleX = Handle::pFaceScaleX; pFaceScaleX->setObjectID(eFaceScaleX); pFaceScaleX->setPosition(Point(1.4f, 0.0f, 0.0f)); pFaceScaleX->setRotation(Vector(-90.0f, 0.0f, 0.0f)); pFaceScaleX->constructGeometry(); Cube* pFaceScaleY = Handle::pFaceScaleY; pFaceScaleY->setObjectID(eFaceScaleY); pFaceScaleY->setPosition(Point(0.0f, 0.0f, 1.4f)); pFaceScaleY->constructGeometry(); Cube* pFaceScaleUniform = Handle::pFaceScaleUniform; pFaceScaleUniform->setObjectID(eFaceScaleUniform); pFaceScaleUniform->setPosition(Point(1.4f, 0.0f, 1.4f)); pFaceScaleUniform->constructGeometry(); }