/************************************** Here are the constructors. ***************************************/ Camera::Camera(){ setEyeX(0.0); setEyeY(0.0); setEyeZ(0.0); setCenterX(0.0); setCenterY(0.0); setCenterZ(0.0); setUpX(0.0); setUpY(0.0); setUpZ(0.0); setFovy(0.0); setAspect(0.0); setZNear(0.0); setZFar(0.0); mouseDirection[0] = 0; mouseDirection[1] = 1; mouseDirection[2] = 0; glMatrixMode(GL_MODELVIEW); move[0] = false; move[1] = false; move[2] = false; move[3] = false; }
Camera::Camera(double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX,double upY,double upZ, double fovy, double aspect, double zNear, double zFar){ setEyeX(eyeX); setEyeY(eyeY); setEyeZ(eyeZ); setCenterX(centerX); setCenterY(centerY); setCenterZ(centerZ); setUpX(upX); setUpY(upY); setUpZ(upZ); setFovy(fovy); setAspect(aspect); setZNear(zNear); setZFar(zFar); mouseDirection[0] = 0; mouseDirection[1] = 90; mouseDirection[2] = 0; glMatrixMode(GL_MODELVIEW); move[0] = false; move[1] = false; move[2] = false; move[3] = false; }
Ref<BasicShape> BasicShapeCircle::blend(const BasicShape& other, double progress) const { ASSERT(type() == other.type()); auto& otherCircle = downcast<BasicShapeCircle>(other); auto result = BasicShapeCircle::create(); result->setCenterX(m_centerX.blend(otherCircle.centerX(), progress)); result->setCenterY(m_centerY.blend(otherCircle.centerY(), progress)); result->setRadius(m_radius.blend(otherCircle.radius(), progress)); return WTFMove(result); }
Ref<BasicShape> BasicShapeEllipse::blend(const BasicShape& other, double progress) const { ASSERT(type() == other.type()); auto& otherEllipse = downcast<BasicShapeEllipse>(other); auto result = BasicShapeEllipse::create(); if (m_radiusX.type() != BasicShapeRadius::Value || otherEllipse.radiusX().type() != BasicShapeRadius::Value || m_radiusY.type() != BasicShapeRadius::Value || otherEllipse.radiusY().type() != BasicShapeRadius::Value) { result->setCenterX(otherEllipse.centerX()); result->setCenterY(otherEllipse.centerY()); result->setRadiusX(otherEllipse.radiusX()); result->setRadiusY(otherEllipse.radiusY()); return WTFMove(result); } result->setCenterX(m_centerX.blend(otherEllipse.centerX(), progress)); result->setCenterY(m_centerY.blend(otherEllipse.centerY(), progress)); result->setRadiusX(m_radiusX.blend(otherEllipse.radiusX(), progress)); result->setRadiusY(m_radiusY.blend(otherEllipse.radiusY(), progress)); return WTFMove(result); }
void Camera::film(){ int currentTime = glutGet(GLUT_ELAPSED_TIME); int timeInterval = 5;//currentTime - previousTime; float tmpEyeX, tmpEyeY, tmpEyeZ; tmpEyeX = sin(mouseDirection[1]*M_PI/180)*sin(mouseDirection[0]*M_PI/180); tmpEyeZ = sin(mouseDirection[1]*M_PI/180)*cos(mouseDirection[0]*M_PI/180); tmpEyeY = cos(mouseDirection[1]*M_PI/180); if(move[FORWARD]){ setEyeX(getEyeX() + (timeInterval * tmpEyeX / 6)); setEyeY(getEyeY() + (timeInterval * tmpEyeY / 6)); setEyeZ(getEyeZ() + (timeInterval * tmpEyeZ / 6)); } if(move[BACKWARD]){ setEyeZ( getEyeZ() - (timeInterval * tmpEyeZ / 6)); setEyeY( getEyeY() - (timeInterval * tmpEyeY / 6)); setEyeX( getEyeX() - (timeInterval * tmpEyeX / 6)); } if(move[LEFT]){ setEyeX( getEyeX() + (timeInterval * sin((mouseDirection[0]+90)*M_PI/180) / 6)); setEyeZ( getEyeZ() + (timeInterval * cos((mouseDirection[0]+90)*M_PI/180) / 6)); } if(move[RIGHT]){ setEyeX( getEyeX() - (timeInterval * sin((mouseDirection[0]+90)*M_PI/180) / 6)); setEyeZ( getEyeZ() - (timeInterval * cos((mouseDirection[0]+90)*M_PI/180) / 6)); } glLoadIdentity(); setCenterX(getEyeX()+tmpEyeX); setCenterY(getEyeY()+tmpEyeY); setCenterZ(getEyeZ()+tmpEyeZ); gluLookAt( getEyeX(),getEyeY(),getEyeZ(), getCenterX(),getCenterY(),getCenterZ(), 0.0f, 1.0f, 0.0f ); int xc = glutGet(GLUT_WINDOW_WIDTH)/2; int yc = glutGet(GLUT_WINDOW_HEIGHT)/2; glutWarpPointer(xc,yc); move[0] = false; move[1] = false; move[2] = false; move[3] = false; }
/** * Update the robot values from the blob * * @param b The blob to update our object from. */ void VisualRobot::updateRobot(Blob b) { setLeftTopX(b.getLeftTopX()); setLeftTopY(b.getLeftTopY()); setLeftBottomX(b.getLeftBottomX()); setLeftBottomY(b.getLeftBottomY()); setRightTopX(b.getRightTopX()); setRightTopY(b.getRightTopY()); setRightBottomX(b.getRightBottomX()); setRightBottomY(b.getRightBottomY()); setX(b.getLeftTopX()); setY(b.getLeftTopY()); setWidth(dist(b.getRightTopX(), b.getRightTopY(), b.getLeftTopX(), b.getLeftTopY())); setHeight(dist(b.getLeftTopX(), b.getLeftTopY(), b.getLeftBottomX(), b.getLeftBottomY())); setCenterX(getLeftTopX() + ROUND2(getWidth() / 2)); setCenterY(getRightTopY() + ROUND2(getHeight() / 2)); setDistance(1); }
/** * Update the robot values from the blob * * @param b The blob to update our object from. */ void VisualCross::updateCross(Blob *b) { setLeftTopX(b->getLeftTopX()); setLeftTopY(b->getLeftTopY()); setLeftBottomX(b->getLeftBottomX()); setLeftBottomY(b->getLeftBottomY()); setRightTopX(b->getRightTopX()); setRightTopY(b->getRightTopY()); setRightBottomX(b->getRightBottomX()); setRightBottomY(b->getRightBottomY()); setX(b->getLeftTopX()); setY(b->getLeftTopY()); setWidth(dist(b->getRightTopX(), b->getRightTopY(), b->getLeftTopX(), b->getLeftTopY())); setHeight(dist(b->getLeftTopX(), b->getLeftTopY(), b->getLeftBottomX(), b->getLeftBottomY())); setCenterX(getLeftTopX() + ROUND2(getWidth() / 2)); setCenterY(getRightTopY() + ROUND2(getHeight() / 2)); setDistance(1); setPossibleCrosses(&ConcreteCross::abstractCrossList); }
void UIButton::setCenterPosition(float centerX, float centerY) { setCenterX(centerX); setCenterY(centerY); }