void Text::update(){ if(ContainsFlags(m_TextAtt,FADING) && getAlpha() != 0){ setColor(getColor(),getAlpha()-2); } if(ContainsFlags(m_TextAtt,RISING)){ setPosition(getPosX(),getPosY()-0.5); } if(ContainsFlags(m_TextAtt,FALLING)){ setPosition(getPosX(),getPosY()+0.5); } if(ContainsFlags(m_TextAtt,SHRINKING) && getSize() > 0){ setSize(getSize()-1); } if(ContainsFlags(m_TextAtt,GROWING)){ setSize(getSize()+1); } if(ContainsFlags(m_TextAtt,TO_THE_LEFT)){ setPosition(getPosX()-0.5,getPosY()); } if(ContainsFlags(m_TextAtt,TO_THE_RIGHT)){ setPosition(getPosX()+0.5,getPosY()); } }
void drawDemo (Graphics& g) override { { RectangleList<float> verticalLines; verticalLines.ensureStorageAllocated (getWidth()); float pos = offset.getValue(); for (int x = 0; x < getWidth(); ++x) { float y = getHeight() * 0.3f; float length = y * std::abs (std::sin (x / 100.0f + 2.0f * pos)); verticalLines.addWithoutMerging (Rectangle<float> ((float) x, y - length * 0.5f, 1.0f, length)); } g.setColour (Colours::blue.withAlpha (getAlpha())); g.fillRectList (verticalLines); } { RectangleList<float> horizontalLines; horizontalLines.ensureStorageAllocated (getHeight()); float pos = offset.getValue(); for (int y = 0; y < getHeight(); ++y) { float x = getWidth() * 0.3f; float length = x * std::abs (std::sin (y / 100.0f + 2.0f * pos)); horizontalLines.addWithoutMerging (Rectangle<float> (x - length * 0.5f, (float) y, length, 1.0f)); } g.setColour (Colours::green.withAlpha (getAlpha())); g.fillRectList (horizontalLines); } g.setColour (Colours::red.withAlpha (getAlpha())); const float w = (float) getWidth(); const float h = (float) getHeight(); g.drawLine (positions[0].getValue() * w, positions[1].getValue() * h, positions[2].getValue() * w, positions[3].getValue() * h); g.drawLine (positions[4].getValue() * w, positions[5].getValue() * h, positions[6].getValue() * w, positions[7].getValue() * h); }
void ScoutTower::render(RenderList* list,Viewport* vp){ Unit::render(list,vp); if(constructionPercent<100){ float x=(body->GetPosition().x*BOX2D_Scale_Factor_INV),y=(body->GetPosition().y*BOX2D_Scale_Factor_INV); float l= x+getSpriteType()->getOffsetX(), t= y+getSpriteType()->getOffsetY(); x-=vp->getViewportX(); y-=vp->getViewportY(); l-=vp->getViewportX(); t-=vp->getViewportY(); int icon =ResourceBankgetResource((string)"PopIconWorld"); for(int i=0;i<workers;i++){ list->addRenderItem(icon, (int)l+8+4*(workers-i), (int)t+8, 0, getAlpha(), 64, 64, getRotTransform(), .5f,.5f ); } float scale = constructionPercent/100; list->addRenderItem(barFill, (int)l, (int)t+10, 0, getAlpha(), 64, 64, getRotTransform(),scale*.5f,1,1 ); list->addRenderItem(barOutline, (int)l, (int)t+10, 0, getAlpha(), 64, 64, getRotTransform(), .5f,.5f, 1 ); } else if(workers>0){ p->pop+=workers*20; workers=0; } }
//------------------------------------------------------------------------------ void Reverb::designShelf(double* pcofs, long theLength, double transition, double t60low, double t60high) { double a1,b0,b1,norm,b0z,b1z,a1z; double roundTrip=((double)(theLength))/fs; // get delay length in seconds double g0,g1; //Temp shelf gains at DC and Nyquist // Design Shelf filter here. Must produce 1-pole, 1-zero filter coefficients // // b1s + b0 // --------- // a1s + 1 // // where b0 = asymptotic shelf gain at low frequency, // b1/a1 = asymptotic shelf gain at high frequency. // These gains must be computed so that, for the // given corresponding delay time T, the signal has // been reduced by the factor exp(-T/tau), where tau // is the natural time constant associated with the // desired T60. // It is ok either to put the pole of the filter at the // transition frequency, or to make the transition // frequency equal to the geometric mean of the pole // and the zero. Explain what you are doing for full // credit. float gainHigh = getAlpha(theLength, t60high); float gainLow = getAlpha(theLength, t60low); b1 = gainHigh/transition; b0 = gainLow; a1 = 1/transition; // Bilinear transform to make discrete-time filter. // This version of the bilinear transform uses the // low-frequency approximation to map 's' onto 'z'. // For extra credit, replace with a version of the // transform which will match continuous- and // discrete- time frequencies at the transition frequency // of the filter. norm=1+a1*(2*fs); // do bilinear transform b0z=(b0+b1*(2*fs))/norm; // (bilinear) b1z=(b0-b1*(2*fs))/norm; // (bilinear) a1z=(1-a1*(2*fs))/norm; // (bilinear) *(pcoefs) = b0z; // return coefs *(pcoefs+1) = b1z; *(pcoefs+2) = a1z; }
void OOFImage3D::threshold(double T) { vtkImageData *rgb = getRGB(); vtkImageData *alpha = getAlpha(); vtkImageData *gray; vtkImageLuminance *luminance; vtkImageThreshold *thold1, *thold2; luminance = vtkImageLuminance::New(); luminance->SetInputConnection(rgb->GetProducerPort()); gray = luminance->GetOutput(); thold1 = vtkImageThreshold::New(); thold1->ThresholdByUpper(T*255); thold1->SetOutValue(0); thold1->SetInputConnection(gray->GetProducerPort()); thold2 = vtkImageThreshold::New(); thold2->ThresholdByLower(T*255); thold2->SetOutValue(255); thold2->SetInputConnection(thold1->GetOutputPort()); gray = thold2->GetOutput(); gray->Update(); combineChannels(gray,alpha); imageChanged(); }
// calculate the count lines in the image with most points HoughLine* ImageDeskew::getTop(int count) { HoughLine *hl = new HoughLine[count]; HoughLine tmp; int length = cDCount * cSteps; for (int i = 0; i < (length - 1); i++) { if (cHMatrix[i] > hl[count - 1].count) { hl[count - 1].count = cHMatrix[i]; hl[count - 1].index = i; int j = count - 1; while ((j > 0) && (hl[j].count > hl[j - 1].count)) { tmp = hl[j]; hl[j] = hl[j - 1]; hl[j - 1] = tmp; j--; } } } int alphaIndex; int dIndex; for (int i = 0; i < count; i++) { dIndex = hl[i].index / cSteps; // integer division, no remainder alphaIndex = hl[i].index - dIndex * cSteps; hl[i].alpha = getAlpha(alphaIndex); hl[i].d = dIndex + cDMin; } return hl; }
void CrankNicolsonUpdater::update( const std::vector<double> & uOld, std::vector<double>* uNew, const std::vector<double> & prem ) const { int N = uOld.size()-1; double c = getAlpha(); // uOld restricted in the interior region Eigen::VectorXd u = Eigen::VectorXd::Zero(N-1); for (int i=0; i<N-1; i++) { u(i) = uOld[i+1]; } // Construct b-vector Eigen::VectorXd b = d_B*u; b(0) += 0.5*c*((*uNew)[0]+uOld[0]); b(N-2) += 0.5*c*((*uNew)[N]+uOld[N]); // Construct early exercise premium vector Eigen::VectorXd p = Eigen::VectorXd::Zero(0); if ( prem.size()>0 ) { p = Eigen::VectorXd::Zero(N-1); for (int i=0; i<N-1; i++) { p(i) = prem[i+1]; } } // update Eigen::VectorXd y = forward_subst(d_L, b); Eigen::VectorXd x = backward_subst(d_U, y, p); for (int i=0; i<N-1; i++) { (*uNew)[i+1] = x(i); } }
void Shape3DOverlay::render(RenderArgs* args) { if (!_renderVisible) { return; // do nothing if we're not visible } float alpha = getAlpha(); xColor color = getColor(); const float MAX_COLOR = 255.0f; glm::vec4 cubeColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); auto batch = args->_batch; if (batch) { auto geometryCache = DependencyManager::get<GeometryCache>(); auto shapePipeline = args->_shapePipeline; if (!shapePipeline) { shapePipeline = _isSolid ? geometryCache->getOpaqueShapePipeline() : geometryCache->getWireShapePipeline(); } batch->setModelTransform(getRenderTransform()); if (_isSolid) { geometryCache->renderSolidShapeInstance(args, *batch, _shape, cubeColor, shapePipeline); } else { geometryCache->renderWireShapeInstance(args, *batch, _shape, cubeColor, shapePipeline); } } }
void Pawn::drawSimple(float dt) { if(isHidden()) return; glLoadName(tagid); float ratio = icon->h / (float) icon->w; float halfsize = size * 0.5f; vec2f offsetpos = pos - vec2f(halfsize, halfsize); float alpha = getAlpha(); vec3f col = getColour(); glColor4f(col.x, col.y, col.z, alpha); glPushMatrix(); glTranslatef(offsetpos.x, offsetpos.y, 0.0f); glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f,0.0f); glVertex2f(size, 0.0f); glTexCoord2f(1.0f,1.0f); glVertex2f(size, size*ratio); glTexCoord2f(0.0f,1.0f); glVertex2f(0.0f, size*ratio); glEnd(); glPopMatrix(); }
void Sphere3DOverlay::render(RenderArgs* args) { if (!_visible) { return; // do nothing if we're not visible } float alpha = getAlpha(); xColor color = getColor(); const float MAX_COLOR = 255.0f; glm::vec4 sphereColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); auto batch = args->_batch; if (batch) { Transform transform = getTransform(); transform.postScale(getDimensions() * SPHERE_OVERLAY_SCALE); batch->setModelTransform(transform); auto geometryCache = DependencyManager::get<GeometryCache>(); auto shapePipeline = args->_shapePipeline; if (!shapePipeline) { shapePipeline = _isSolid ? geometryCache->getOpaqueShapePipeline() : geometryCache->getWireShapePipeline(); } if (_isSolid) { geometryCache->renderSolidSphereInstance(args, *batch, sphereColor, shapePipeline); } else { geometryCache->renderWireSphereInstance(args, *batch, sphereColor, shapePipeline); } } }
void Particle::printInfo(){ if (ofGetFrameNum() % (int)ofGetFrameRate() == 0){ cout << "Position: " << '(' << getX() << ',' << getY() << ')' << endl; cout << "Speed: " << getSpeed() << "\t" << "Angle:" << getAngle() << endl; cout << "Flow: " << getFlow() << "\t" << "Alpha: " << getAlpha() << endl << endl; } }
// Return brush alpha sample QPixmap BrushStyle::getAlphaSample(int alphaIndex, int sizeIndex, bool selected, bool emptyBackground) { if (alphaIndex < 0 || alphaIndex >= BRUSH_ALPHA_COUNT || sizeIndex < 0 || sizeIndex >= BRUSH_SIZE_COUNT) return QPixmap(); else return getSample(getScale(sizeIndex), getAlpha(alphaIndex), selected, QColor(), emptyBackground); }
/** From ARGB to RGBA in 4 byte components for endian aware passing to OpenGL \param dest: address where the 4x8 bit OpenGL color is stored. */ void toOpenGLColor(unsigned char* dest) const { *dest = (unsigned char)getRed(); *++dest = (unsigned char)getGreen(); *++dest = (unsigned char)getBlue(); *++dest = (unsigned char)getAlpha(); }
void Image3DOverlay::render(RenderArgs* args) { if (!_isLoaded) { _isLoaded = true; _texture = DependencyManager::get<TextureCache>()->getTexture(_url); } if (!_visible || !getParentVisible() || !_texture || !_texture->isLoaded()) { return; } Q_ASSERT(args->_batch); gpu::Batch* batch = args->_batch; float imageWidth = _texture->getWidth(); float imageHeight = _texture->getHeight(); QRect fromImage; if (_fromImage.isNull()) { fromImage.setX(0); fromImage.setY(0); fromImage.setWidth(imageWidth); fromImage.setHeight(imageHeight); } else { float scaleX = imageWidth / _texture->getOriginalWidth(); float scaleY = imageHeight / _texture->getOriginalHeight(); fromImage.setX(scaleX * _fromImage.x()); fromImage.setY(scaleY * _fromImage.y()); fromImage.setWidth(scaleX * _fromImage.width()); fromImage.setHeight(scaleY * _fromImage.height()); } float maxSize = glm::max(fromImage.width(), fromImage.height()); float x = fromImage.width() / (2.0f * maxSize); float y = -fromImage.height() / (2.0f * maxSize); glm::vec2 topLeft(-x, -y); glm::vec2 bottomRight(x, y); glm::vec2 texCoordTopLeft(fromImage.x() / imageWidth, fromImage.y() / imageHeight); glm::vec2 texCoordBottomRight((fromImage.x() + fromImage.width()) / imageWidth, (fromImage.y() + fromImage.height()) / imageHeight); const float MAX_COLOR = 255.0f; xColor color = getColor(); float alpha = getAlpha(); applyTransformTo(_transform, true); Transform transform = _transform; transform.postScale(glm::vec3(getDimensions(), 1.0f)); batch->setModelTransform(transform); batch->setResourceTexture(0, _texture->getGPUTexture()); DependencyManager::get<GeometryCache>()->renderQuad( *batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, glm::vec4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha) ); batch->setResourceTexture(0, args->_whiteTexture); // restore default white color after me }
const render::ShapeKey Rectangle3DOverlay::getShapeKey() { auto builder = render::ShapeKey::Builder().withOwnPipeline(); if (getAlpha() != 1.0f) { builder.withTranslucent(); } return builder.build(); }
const render::ShapeKey Web3DOverlay::getShapeKey() { auto builder = render::ShapeKey::Builder().withoutCullFace().withDepthBias(); if (getAlpha() != 1.0f) { builder.withTranslucent(); } return builder.build(); }
STDMETHODIMP MousePointerShapeChangedEventWrap::COMGETTER(Alpha)(BOOL *aAlpha) { LogRelFlow(("{%p} %s: enter aAlpha=%p\n", this, "MousePointerShapeChangedEvent::getAlpha", aAlpha)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aAlpha); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getAlpha(aAlpha); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aAlpha=%RTbool hrc=%Rhrc\n", this, "MousePointerShapeChangedEvent::getAlpha", *aAlpha, hrc)); return hrc; }
void Line3DOverlay::render(RenderArgs* args) { if (!_visible) { return; // do nothing if we're not visible } float alpha = getAlpha(); xColor color = getColor(); const float MAX_COLOR = 255.0f; glm::vec4 colorv4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); auto batch = args->_batch; if (batch) { batch->setModelTransform(_transform); auto geometryCache = DependencyManager::get<GeometryCache>(); geometryCache->bindSimpleProgram(*batch, false, false, true, true); if (getIsDashedLine()) { // TODO: add support for color to renderDashedLine() geometryCache->renderDashedLine(*batch, _start, _end, colorv4, _geometryCacheID); } else { geometryCache->renderLine(*batch, _start, _end, colorv4, _geometryCacheID); } } }
void Pawn::drawShadow(float dt) { if(isHidden() || !shadow) return; float halfsize = size * 0.5f; vec2 offsetpos = pos - vec2(halfsize, halfsize*graphic_ratio) + shadowOffset; float alpha = getAlpha(); glBindTexture(GL_TEXTURE_2D, graphic->textureid); glColor4f(0.0, 0.0, 0.0, alpha * gGourceShadowStrength); glPushMatrix(); glTranslatef(offsetpos.x, offsetpos.y, 0.0f); glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f,0.0f); glVertex2f(size, 0.0f); glTexCoord2f(1.0f,1.0f); glVertex2f(size, size*graphic_ratio); glTexCoord2f(0.0f,1.0f); glVertex2f(0.0f, size*graphic_ratio); glEnd(); glPopMatrix(); }
void Layer::draw( Renderer *ren ) { if( mRootView->mRendersToFrameBuffer ) { ivec2 frameBufferSize = ivec2( mFrameBufferBounds.getSize() ); if( ! mFrameBuffer || ! mFrameBuffer->isUsable() || mFrameBuffer->getSize().x < frameBufferSize.x || mFrameBuffer->getSize().y < frameBufferSize.y ) { mFrameBuffer = ren->getFrameBuffer( frameBufferSize ); LOG_LAYER( "acquiring FrameBuffer for view '" << mRootView->getName() << ", size: " << mFrameBuffer->getSize() << "', mFrameBufferBounds: " << mFrameBufferBounds << ", view bounds:" << mRootView->getBounds() ); } ren->pushFrameBuffer( mFrameBuffer ); gl::pushViewport( 0, mFrameBuffer->getHeight() - frameBufferSize.y, frameBufferSize.x, frameBufferSize.y ); gl::pushMatrices(); gl::setMatricesWindow( frameBufferSize ); gl::translate( - mFrameBufferBounds.getUpperLeft() ); gl::clear( ColorA::zero() ); } drawView( mRootView, ren ); if( mRootView->mRendersToFrameBuffer ) { ren->popFrameBuffer( mFrameBuffer ); gl::popViewport(); gl::popMatrices(); ren->pushBlendMode( BlendMode::PREMULT_ALPHA ); ren->pushColor( ColorA::gray( 1, getAlpha() ) ); auto destRect = mFrameBufferBounds + mRootView->getPos(); ren->draw( mFrameBuffer, Area( 0, 0, mFrameBufferBounds.getWidth(), mFrameBufferBounds.getHeight() ), destRect ); ren->popColor(); ren->popBlendMode(); } }
void drawDemo (Graphics& g) override { if (Time::getCurrentTime().toMilliseconds() > lastSVGLoadTime.toMilliseconds() + 2000) createSVGDrawable(); svgDrawable->draw (g, getAlpha(), getTransform()); }
void OffScreenExplode::Update(long gameTime) { if(active) { GameElement::Update(gameTime); setAlpha(getAlpha()+0.02f); if(getAlpha()>=1) { active = false; if(Global::characters[playerNo]->getStock() > 0) { Global::characters[playerNo]->respawn(); } } } }
void drawDemo (Graphics& g) override { const Path& p = logoPath; if (useLinearGradient || useRadialGradient) { Colour c1 (gradientColours[0].getValue(), gradientColours[1].getValue(), gradientColours[2].getValue(), 1.0f); Colour c2 (gradientColours[3].getValue(), gradientColours[4].getValue(), gradientColours[5].getValue(), 1.0f); Colour c3 (gradientColours[6].getValue(), gradientColours[7].getValue(), gradientColours[8].getValue(), 1.0f); float x1 = gradientPositions[0].getValue() * getWidth() * 0.25f; float y1 = gradientPositions[1].getValue() * getHeight() * 0.25f; float x2 = gradientPositions[2].getValue() * getWidth() * 0.75f; float y2 = gradientPositions[3].getValue() * getHeight() * 0.75f; ColourGradient gradient (c1, x1, y1, c2, x2, y2, useRadialGradient); gradient.addColour (gradientIntermediate.getValue(), c3); g.setGradientFill (gradient); } else { g.setColour (Colours::blue); } g.setOpacity (getAlpha()); g.fillPath (p, getTransform()); }
void BackwardEulerUpdater::update( const std::vector<double> & uOld, std::vector<double>* uNew, const std::vector<double> & prem ) const { int N = uOld.size()-1; double c = getAlpha(); // Construct b-vector Eigen::VectorXd b = Eigen::VectorXd::Zero(N-1); for (int i=0; i<N-1; i++) { b(i) = uOld[i+1]; } b(0) += c*(*uNew)[0]; b(N-2) += c*(*uNew)[N]; // Construct early exercise premium vector Eigen::VectorXd p = Eigen::VectorXd::Zero(0); if ( prem.size()>0 ) { p = Eigen::VectorXd::Zero(N-1); for (int i=0; i<N-1; i++) { p(i) = prem[i+1]; } } // update Eigen::VectorXd y = forward_subst(d_L, b); Eigen::VectorXd x = backward_subst(d_U, y, p); for (int i=0; i<N-1; i++) { (*uNew)[i+1] = x(i); } }
/** \param other Color to add to this color \return Addition of the two colors, clamped to 0..255 values */ NColor operator+(const NColor& other) const { return NColor( (std::min)( getAlpha() + other.getAlpha(), 255 ), (std::min)(getRed() + other.getRed(), 255), (std::min)(getGreen() + other.getGreen(), 255), (std::min)(getBlue() + other.getBlue(), 255)); }
QString CColor::toString ( void ) const { return ( QString::number ( getRed() ) + QString ( " " ) + QString::number ( getGreen() ) + QString ( " " ) + QString::number ( getBlue() ) + QString ( " " ) + QString::number ( getAlpha() ) ); }
void Pawn::draw(float dt) { if(hidden) return; float halfsize = size * 0.5f; vec2 offsetpos = pos - vec2(halfsize, halfsize*graphic_ratio); float alpha = getAlpha(); vec3 col = getColour(); glBindTexture(GL_TEXTURE_2D, graphic->textureid); glPushMatrix(); glTranslatef(offsetpos.x, offsetpos.y, 0.0f); glColor4f(col.x, col.y, col.z, alpha); glBegin(GL_QUADS); glTexCoord2f(0.0f,0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f,0.0f); glVertex2f(size, 0.0f); glTexCoord2f(1.0f,1.0f); glVertex2f(size, size*graphic_ratio); glTexCoord2f(0.0f,1.0f); glVertex2f(0.0f, size*graphic_ratio); glEnd(); glPopMatrix(); }
void Rectangle3DOverlay::render(RenderArgs* args) { if (!_visible) { return; // do nothing if we're not visible } float alpha = getAlpha(); xColor color = getColor(); const float MAX_COLOR = 255.0f; glm::vec4 rectangleColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); glm::vec3 position = getPosition(); glm::vec2 dimensions = getDimensions(); glm::vec2 halfDimensions = dimensions * 0.5f; glm::quat rotation = getRotation(); auto batch = args->_batch; if (batch) { Transform transform; transform.setTranslation(position); transform.setRotation(rotation); batch->setModelTransform(transform); auto geometryCache = DependencyManager::get<GeometryCache>(); if (getIsSolid()) { glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, 0.0f); glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, 0.0f); geometryCache->bindSimpleProgram(*batch); geometryCache->renderQuad(*batch, topLeft, bottomRight, rectangleColor); } else { geometryCache->bindSimpleProgram(*batch, false, false, false, true, true); if (getIsDashedLine()) { glm::vec3 point1(-halfDimensions.x, -halfDimensions.y, 0.0f); glm::vec3 point2(halfDimensions.x, -halfDimensions.y, 0.0f); glm::vec3 point3(halfDimensions.x, halfDimensions.y, 0.0f); glm::vec3 point4(-halfDimensions.x, halfDimensions.y, 0.0f); geometryCache->renderDashedLine(*batch, point1, point2, rectangleColor); geometryCache->renderDashedLine(*batch, point2, point3, rectangleColor); geometryCache->renderDashedLine(*batch, point3, point4, rectangleColor); geometryCache->renderDashedLine(*batch, point4, point1, rectangleColor); } else { if (halfDimensions != _previousHalfDimensions) { QVector<glm::vec3> border; border << glm::vec3(-halfDimensions.x, -halfDimensions.y, 0.0f); border << glm::vec3(halfDimensions.x, -halfDimensions.y, 0.0f); border << glm::vec3(halfDimensions.x, halfDimensions.y, 0.0f); border << glm::vec3(-halfDimensions.x, halfDimensions.y, 0.0f); border << glm::vec3(-halfDimensions.x, -halfDimensions.y, 0.0f); geometryCache->updateVertices(_geometryCacheID, border, rectangleColor); _previousHalfDimensions = halfDimensions; } geometryCache->renderVertices(*batch, gpu::LINE_STRIP, _geometryCacheID); } } } }
void Grid3DOverlay::render(RenderArgs* args) { if (!_visible) { return; // do nothing if we're not visible } const int MINOR_GRID_DIVISIONS = 200; const int MAJOR_GRID_DIVISIONS = 100; const float MAX_COLOR = 255.0f; // center the grid around the camera position on the plane glm::vec3 rotated = glm::inverse(getRotation()) * Application::getInstance()->getCamera()->getPosition(); float spacing = _minorGridWidth; float alpha = getAlpha(); xColor color = getColor(); glm::vec4 gridColor(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); auto batch = args->_batch; if (batch) { Transform transform; transform.setRotation(getRotation()); // Minor grid { batch->_glLineWidth(1.0f); auto position = glm::vec3(_minorGridWidth * (floorf(rotated.x / spacing) - MINOR_GRID_DIVISIONS / 2), spacing * (floorf(rotated.y / spacing) - MINOR_GRID_DIVISIONS / 2), getPosition().z); float scale = MINOR_GRID_DIVISIONS * spacing; transform.setTranslation(position); transform.setScale(scale); batch->setModelTransform(transform); DependencyManager::get<GeometryCache>()->renderGrid(*batch, MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS, gridColor); } // Major grid { batch->_glLineWidth(4.0f); spacing *= _majorGridEvery; auto position = glm::vec3(spacing * (floorf(rotated.x / spacing) - MAJOR_GRID_DIVISIONS / 2), spacing * (floorf(rotated.y / spacing) - MAJOR_GRID_DIVISIONS / 2), getPosition().z); float scale = MAJOR_GRID_DIVISIONS * spacing; transform.setTranslation(position); transform.setScale(scale); batch->setModelTransform(transform); DependencyManager::get<GeometryCache>()->renderGrid(*batch, MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS, gridColor); } } }
LabColour const LabColour::withMultipliedColour (float amount) const { return LabColour ( getL (), getA () * amount, getB () * amount, getAlpha ()); }