const GLVector GLVector::operator /(GLdouble d)const{ if (d != 0.0){ GLdouble temp= 1.0 / d; return GLVector(x() * temp, y() * temp, z() * temp); } else{ return GLVector(0.0,0.0,0.0); } }
const GLVector GLVector::unitVector()const{ GLdouble aLength; aLength= length(); if (length() != 0.0) return GLVector(x() / length(), y() / length(), z() / length()); else { return GLVector(); } }
GLAngle::GLAngle( GLVector * vectorA, GLVector * vectorB, GLColor color, QString objectID, int time ) : GLObject(GLObject::ANGLE_OBJECT, color, objectID, time) { if( vectorA != 0 && vectorB != 0 && vectorA != vectorB && ( (vectorA->sX() == vectorB->sX() && vectorA->sY() == vectorB->sY() && vectorA->sZ() == vectorB->sZ()) || (vectorA->eX() == vectorB->eX() && vectorA->eY() == vectorB->eY() && vectorA->eZ() == vectorB->eZ()) || (vectorA->eX() == vectorB->sX() && vectorA->eY() == vectorB->sY() && vectorA->eZ() == vectorB->sZ()) || (vectorA->sX() == vectorB->eX() && vectorA->sY() == vectorB->eY() && vectorA->sZ() == vectorB->eZ()) )) { _valid = true; if(vectorA->eX() == vectorB->sX() && vectorA->eY() == vectorB->sY() && vectorA->eZ() == vectorB->sZ()) { _vectorA = GLVector(vectorA->eX(),vectorA->eY(),vectorA->eZ(),vectorA->sX(),vectorA->sY(),vectorA->sZ()); _vectorB = GLVector(*vectorB); } else if(vectorA->eX() == vectorB->eX() && vectorA->eY() == vectorB->eY() && vectorA->eZ() == vectorB->eZ()) { _vectorA = GLVector(vectorA->eX(),vectorA->eY(),vectorA->eZ(),vectorA->sX(),vectorA->sY(),vectorA->sZ()); _vectorB = GLVector(vectorB->eX(),vectorB->eY(),vectorB->eZ(),vectorB->sX(),vectorB->sY(),vectorB->sZ()); } else if(vectorA->sX() == vectorB->eX() && vectorA->sY() == vectorB->eY() && vectorA->sZ() == vectorB->eZ()) { _vectorA = GLVector(*vectorA); _vectorB = GLVector(vectorB->eX(),vectorB->eY(),vectorB->eZ(),vectorB->sX(),vectorB->sY(),vectorB->sZ()); } else { _vectorA = GLVector(*vectorA); _vectorB = GLVector(*vectorB); } _vectorLeft = GLVector(_vectorA.x() * LEN,_vectorA.y() * LEN,_vectorA.z() * LEN); _vectorRight = GLVector(_vectorB.x() * LEN,_vectorB.y() * LEN,_vectorB.z() * LEN); if(_vectorLeft.length() > _vectorRight.length()) { double h = _vectorLeft.length()/_vectorRight.length(); _vectorLeft = _vectorLeft / h; } else if(_vectorLeft.length() < _vectorRight.length()) { double h = _vectorRight.length()/_vectorLeft.length(); _vectorRight = _vectorRight / h; } _vectorMid = ((_vectorLeft + _vectorRight)/2.0)*1.1; } else { _valid = false; } }
void GLVector::glCoordinate() { glPushMatrix(); glTranslatef(_sX, _sY, _sZ); GLText::draw("(" + QString::number(_sX) + ", " + QString::number(_sY) + ", " + QString::number(_sZ) + ")", usedColor(), GLVector(0.0, -0.35, 0.0)); GLText::draw("(" + QString::number(_eX) + ", " + QString::number(_eY) + ", " + QString::number(_eZ) + ")", usedColor(), GLVector(x(), y()-0.35, z())); glPopMatrix(); }
void GLPerspective::shiftSceneForwardBackward( double distance ) { GLVector vShift = GLVector(_Center.x() -_Camera.x(), _Center.y() -_Camera.y(), 0).unitVector() * distance; _Center = _Center + vShift; _Camera = _Camera + vShift; }
WaterScreen::WaterScreen (CompScreen *screen) : PluginClassHandler<WaterScreen,CompScreen> (screen), cScreen (CompositeScreen::get (screen)), gScreen (GLScreen::get (screen)), grabIndex (0), oldFbo (NULL), fboIndex (0), useFbo (true), texWidth (0), texHeight (0), target (0), tx (0), ty (0), count (0), data (NULL), d0 (NULL), d1 (NULL), t0 (NULL), wiperAngle (0), wiperSpeed (0), lightVec(GLVector(optionGetLightVecX(), optionGetLightVecY(), optionGetLightVecZ())) { offsetScale = optionGetOffsetScale () * 10.0f; wiperTimer.setCallback (boost::bind (&WaterScreen::wiperTimeout, this)); rainTimer.setCallback (boost::bind (&WaterScreen::rainTimeout, this)); waterSetup (); optionSetOffsetScaleNotify (boost::bind (&WaterScreen::optionChange, this, _2)); optionSetRainDelayNotify (boost::bind (&WaterScreen::optionChange, this, _2)); optionSetLightVecXNotify (boost::bind (&WaterScreen::optionChange, this, _2)); optionSetLightVecYNotify (boost::bind (&WaterScreen::optionChange, this, _2)); optionSetLightVecZNotify (boost::bind (&WaterScreen::optionChange, this, _2)); optionSetInitiateKeyInitiate (waterInitiate); optionSetInitiateKeyTerminate (waterTerminate); optionSetToggleRainKeyTerminate (waterToggleRain); optionSetToggleWiperKeyInitiate (waterToggleWiper); optionSetTitleWaveInitiate (waterTitleWave); optionSetPointInitiate (waterPoint); optionSetLineInitiate (waterLine); ScreenInterface::setHandler (screen, false); CompositeScreenInterface::setHandler (cScreen, false); GLScreenInterface::setHandler (gScreen, false); }
void GLPoint::glCoordinate() { glPushMatrix(); glTranslatef( _x, _y, _z ); GLText::draw("(" + QString::number(_x) + ", " + QString::number(_y) + ", " + QString::number(_z) + ")", usedColor(), GLVector(0.0, -0.35, 0.0)); glPopMatrix(); }
void GLPoint::glObjectId() { glPushMatrix(); glTranslatef( _x, _y, _z ); GLText::draw(_objectID, usedColor(), GLVector(0.0, GLText::heightOfText(_objectID)/2.0 + 0.15, 0.0)); glPopMatrix(); }
bool CubeScreen::cubeShouldPaintViewport (const GLScreenPaintAttrib &sAttrib, const GLMatrix &transform, CompOutput *output, PaintOrder order) { WRAPABLE_HND_FUNCTN_RETURN (bool, cubeShouldPaintViewport, sAttrib, transform, output, order) bool ftb; float pointZ; pointZ = priv->mInvert * priv->mDistance; std::vector<GLVector> vPoints; vPoints.push_back (GLVector (-0.5, 0.0, pointZ, 1.0)); vPoints.push_back (GLVector (0.0, 0.5, pointZ, 1.0)); vPoints.push_back (GLVector (0.0, 0.0, pointZ, 1.0)); ftb = cubeCheckOrientation (sAttrib, transform, output, vPoints); return (order == FTB && ftb) || (order == BTF && !ftb); }
void GLVector::glObjectId() { glPushMatrix(); glTranslatef(_sX, _sY, _sZ); GLText::draw(_objectID, usedColor(), GLVector(x()/2.0, y()/2.0 + GLText::heightOfText(_objectID)/2.0 + 0.15, z()/2.0)); glPopMatrix(); }
/*! \brief Draw axes if requested. \param axisLength */ void Environment::drawAxes(GLdouble axisLength) { if (areCoordinateAxesVisible) { QVector <GLVector> points(6); points[0] = GLVector(-axisLength,0.0,0.0); points[1] = GLVector(axisLength,0.0,0.0); points[2] = GLVector(0.0,-axisLength, 0.0); points[3] = GLVector(0.0,axisLength,0.0); points[4] = GLVector(0.0,0.0,-axisLength); points[5] = GLVector(0.0,0.0,axisLength); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_DOUBLE, sizeof(GLVector), points[0].dv()); glEnableClientState(GL_COLOR_ARRAY); glColorPointer(4, GL_FLOAT, sizeof(GLColorRGBA), colors[0].fv()); glDrawArrays(GL_LINES, 0, 6); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); } }
void GLVector::glVector() { glPushMatrix(); glTranslatef(_sX, _sY, _sZ); QString vector = QString::number(x()) + "\n" + QString::number(y()) + "\n" + QString::number(z()); GLText::draw("(" + vector + ")", usedColor(), GLVector(x()/2.0, y()/2.0 - GLText::heightOfText(vector)/2.0 - 0.15, z()/2.0)); glPopMatrix(); }
void GLAngle::glCoordinate() { if(_valid) { glPushMatrix(); glTranslatef( _vectorA.sX()+_vectorMid.x(), _vectorA.sY()+_vectorMid.y(), _vectorA.sZ()+_vectorMid.z() ); GLText::draw( QString::number(_vectorA.angle(_vectorB),'d',2) + '°', usedColor(), GLVector(0.0, -0.35, 0.0)); glPopMatrix(); } }
void GLAngle::glObjectId() { if(_valid) { glPushMatrix(); glTranslatef( _vectorA.sX()+_vectorMid.x(), _vectorA.sY()+_vectorMid.y(), _vectorA.sZ()+_vectorMid.z() ); GLText::draw(_objectID, usedColor(), GLVector(0.0, GLText::heightOfText(_objectID)/2.0 + 0.15, 0.0)); glPopMatrix(); } }
const GLVector GLVector::vectorMult( const GLVector& v)const{ return GLVector( y() * v.z() - z() * v.y(), z() * v.x() - x() * v.z(), x() * v.y() - y() * v.x()); }
const GLVector GLVector::operator +(const GLVector& v)const{ return GLVector(x() + v.x(), y() + v.y(), z() + v.z()); }
GLVector GLVector::operator *(const GLdouble d )const{ return GLVector(x() * d, y() * d, z() * d); }