void draw_sprite(sprite_id sprite, int x, int y, const Colour& c) { using namespace ldraw; SpriteEntry& entry = game_sprite_data.get(sprite); entry.sprite.draw(DrawOptions().colour(c.multiply(entry.drawcolour)), Pos(x,y)); }
Colour Scene::getColourAtIntersection(const Ray &r, const NodeIntersection &ni, const Colour &cEnvironment, uint8_t rayRecursion) const { /* * Do a simple variation on the phong lighting model. This could be improved. * * In my ray tracer the Colour class is analogous to a spectral distribution. * (ie: light flux) */ /* * Evaluation of material properties at this intersection. */ Colour cDiffuse; Colour cSpecular; double phongCoeff = 0.0; double reflectivity = 0.0; double opacity = 1.0; double indexOfRefraction = 1.0; PrimitivePatch bumpedPatch = ni.pPatch; if (ni.mat) { ni.mat->evaluate(ni.pPatch, &cDiffuse, &cSpecular, &phongCoeff, &reflectivity, &opacity, &indexOfRefraction); ni.mat->evaluateBumpMap(ni.pPatch, &bumpedPatch); } /* * Calculate the lighting. */ // XXX need to calculate light attenuation due to distance. Colour diffuseLight; Colour specularLight; for(std::list<Light*>::const_iterator lightIter = mLights.begin(); lightIter != mLights.end(); lightIter++) { Light &curLight = **lightIter; double intersectionTransmissiveness = 0.0; Ray patchToCurLightRay(bumpedPatch.p, normalize(curLight.getPosition() - bumpedPatch.p)); /* * Check if there are any obstructions. */ if (!intersects(patchToCurLightRay, &intersectionTransmissiveness) || !isZero(intersectionTransmissiveness)) { // Rely on short-circuit || to test intersects && intersectionTransmissiveness > 0.0 // Diffuse - cosine weighted angle between normal and light source double diffuseWeight = dot(bumpedPatch.shadingNorm, patchToCurLightRay.d); if (lessThanZero(diffuseWeight)) { diffuseWeight = 0.0; } diffuseLight += (diffuseWeight //* intersectionTransmissiveness * curLight.getColour()); /* * Specular - exponential of cosine weighted angle between the incoming * ray and the reflected ray from the light source. */ Vector reflected = normalize(computeReflection(-patchToCurLightRay.d, bumpedPatch)); double specularWeight = dot(reflected, normalize(-r.d)); if (lessThanZero(specularWeight)) { specularWeight = 0.0; } specularLight += (pow(specularWeight, phongCoeff) * curLight.getColour()); } } /* * Recursive case. */ if (rayRecursion > 0) { /* * Check to see if the material is reflective or transmissive. If it is * this will directly affect the diffuse Colour before it is used in the * final colour computation. */ Ray recR; NodeIntersection recNI; Colour recColour; if (reflectivity > 0.0) { recR = Ray(bumpedPatch.p, computeReflection(r.d, bumpedPatch)); if (intersect(recR, &recNI)) { recColour = getColourAtIntersection(recR, recNI, cEnvironment, rayRecursion - 1); // Do a simple Alpha composite. cDiffuse = (cDiffuse * (1-reflectivity)) + (recColour * reflectivity); } else { // Didn't intersect with anything so take the env colour. cDiffuse = (cDiffuse * (1-reflectivity)) + (cEnvironment * reflectivity); } } if (opacity < 1.0) { // XXX need to work out the refraction using Snell's law. recR = Ray(bumpedPatch.p, r.d); if (intersect(recR, &recNI)) { recColour = getColourAtIntersection(recR, recNI, cEnvironment, rayRecursion - 1); // Do a simple Alpha composite. cDiffuse = (cDiffuse * opacity) + (recColour * (1 - opacity)); } else { // Didn't intersect with anything so take the env colour. cDiffuse = (cDiffuse * opacity) + (cEnvironment * (1 - opacity)); } } } /* * Base Case. */ /* * Apply lighting calculations onto the diffuse and specular lighting * components of the material evaluated at the curent intersection point. */ Colour c = getAmbient(); // XXX need to multiply emmissive component if the object is a light source. if (!cDiffuse.isBlack()) { c += cDiffuse * diffuseLight; } // Need to calculate attenuation from distance of the light if (!cSpecular.isBlack()) { c += cSpecular * specularLight; } return c; }
inline Colour operator +(const Colour& a, const Colour& b) { return Colour(a.R()+b.R(), a.G()+b.G(), a.B()+b.B()); }
inline bool operator> (const Colour& rhs) const { return colourVector() > rhs.colourVector(); }
bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out) { using namespace jpeglibNamespace; using namespace JPEGHelpers; jpeg_compress_struct jpegCompStruct; zerostruct (jpegCompStruct); jpeg_create_compress (&jpegCompStruct); struct jpeg_error_mgr jerr; setupSilentErrorHandler (jerr); jpegCompStruct.err = &jerr; JuceJpegDest dest; jpegCompStruct.dest = &dest; dest.output = &out; HeapBlock <char> tempBuffer (jpegBufferSize); dest.buffer = tempBuffer; dest.next_output_byte = (JOCTET*) dest.buffer; dest.free_in_buffer = jpegBufferSize; dest.init_destination = jpegWriteInit; dest.empty_output_buffer = jpegWriteFlush; dest.term_destination = jpegWriteTerminate; jpegCompStruct.image_width = (JDIMENSION) image.getWidth(); jpegCompStruct.image_height = (JDIMENSION) image.getHeight(); jpegCompStruct.input_components = 3; jpegCompStruct.in_color_space = JCS_RGB; jpegCompStruct.write_JFIF_header = 1; jpegCompStruct.X_density = 72; jpegCompStruct.Y_density = 72; jpeg_set_defaults (&jpegCompStruct); jpegCompStruct.dct_method = JDCT_FLOAT; jpegCompStruct.optimize_coding = 1; if (quality < 0.0f) quality = 0.85f; jpeg_set_quality (&jpegCompStruct, jlimit (0, 100, roundToInt (quality * 100.0f)), TRUE); jpeg_start_compress (&jpegCompStruct, TRUE); const int strideBytes = (int) (jpegCompStruct.image_width * (unsigned int) jpegCompStruct.input_components); JSAMPARRAY buffer = (*jpegCompStruct.mem->alloc_sarray) ((j_common_ptr) &jpegCompStruct, JPOOL_IMAGE, (JDIMENSION) strideBytes, 1); const Image::BitmapData srcData (image, Image::BitmapData::readOnly); while (jpegCompStruct.next_scanline < jpegCompStruct.image_height) { uint8* dst = *buffer; if (srcData.pixelFormat == Image::RGB) { const uint8* src = srcData.getLinePointer ((int) jpegCompStruct.next_scanline); for (int i = srcData.width; --i >= 0;) { *dst++ = ((const PixelRGB*) src)->getRed(); *dst++ = ((const PixelRGB*) src)->getGreen(); *dst++ = ((const PixelRGB*) src)->getBlue(); src += srcData.pixelStride; } } else { for (int x = 0; x < srcData.width; ++x) { const Colour pixel (srcData.getPixelColour (x, (int) jpegCompStruct.next_scanline)); *dst++ = pixel.getRed(); *dst++ = pixel.getGreen(); *dst++ = pixel.getBlue(); } } jpeg_write_scanlines (&jpegCompStruct, buffer, 1); } jpeg_finish_compress (&jpegCompStruct); jpeg_destroy_compress (&jpegCompStruct); return true; }
inline Colour operator +(const Colour& a, const Colour& b) { return Colour(a.R()+b.R(), a.G()+b.G(), a.B()+b.B()); //return Colour(1.0 - (1.0-a.R())*(1.0-b.R()), 1.0 - (1.0-a.G())*(1.0-b.G()), // 1.0 - (1.0-a.B())*(1.0-b.B())); }
//============================================================================== void NonShinyLookAndFeel::drawGlassLozenge (Graphics& g, const float x, const float y, const float width, const float height, const Colour& colour, const float outlineThickness, const float cornerSize, const bool flatOnLeft, const bool flatOnRight, const bool flatOnTop, const bool flatOnBottom) throw() { if (width <= outlineThickness || height <= outlineThickness) return; const int intX = (int) x; const int intY = (int) y; const int intW = (int) width; const int intH = (int) height; const float cs = cornerSize < 0 ? jmin (width * 0.5f, height * 0.5f) : cornerSize; const float edgeBlurRadius = height * 0.75f + (height - cs * 2.0f); const int intEdge = (int) edgeBlurRadius; Path outline; createRoundedPath (outline, x, y, width, height, cs, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); { ColourGradient cg (colour.darker (0.1f), 0, y, colour.darker (0.1f), 0, y + height, false); cg.addColour (0.03, colour.withMultipliedAlpha (0.3f)); cg.addColour (0.4, colour); cg.addColour (0.97, colour.withMultipliedAlpha (0.3f)); //g.setGradientFill (cg); g.setColour(colour); g.fillPath (outline); } //ColourGradient cg (Colours::transparentBlack, x + edgeBlurRadius, y + height * 0.5f, // colour.darker (0.1f), x, y + height * 0.5f, true); //cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.5f) / edgeBlurRadius), Colours::transparentBlack); //cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.25f) / edgeBlurRadius), colour.darker (0.2f).withMultipliedAlpha (0.3f)); if (! (flatOnLeft || flatOnTop || flatOnBottom)) { g.saveState(); // g.setGradientFill (cg); g.setColour(colour); g.reduceClipRegion (intX, intY, intEdge, intH); g.fillPath (outline); g.restoreState(); } if (! (flatOnRight || flatOnTop || flatOnBottom)) { //cg.point1.setX (x + width - edgeBlurRadius); //cg.point2.setX (x + width); g.saveState(); //g.setGradientFill (cg); g.setColour(colour); g.reduceClipRegion (intX + intW - intEdge, intY, 2 + intEdge, intH); g.fillPath (outline); g.restoreState(); } //{ // const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f; // const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; // Path highlight; // createRoundedPath (highlight, // x + leftIndent, // y + cs * 0.1f, // width - (leftIndent + rightIndent), // height * 0.4f, cs * 0.4f, // ! (flatOnLeft || flatOnTop), // ! (flatOnRight || flatOnTop), // ! (flatOnLeft || flatOnBottom), // ! (flatOnRight || flatOnBottom)); // g.setGradientFill (ColourGradient (colour.brighter (10.0f), 0, y + height * 0.06f, // Colours::transparentWhite, 0, y + height * 0.4f, false)); // g.fillPath (highlight); //} g.setColour (colour.darker(10.f).withMultipliedAlpha (1.5f)); g.strokePath (outline, PathStrokeType (outlineThickness)); }
void comFillRoundRect(int x, int y, int width, int height, float thickness, Colour c) { float thick = 0.5f*thickness; float x1, x2, x3, x4; float y1, y2, y3, y4; x1 = x - thick; x2 = x + thick; x3 = x + width - thick; x4 = x + width + thick; y1 = y - thick; y2 = y + thick; y3 = y + height - thick; y4 = y + height + thick; c.apply(); curveBackground.applyTexture(); glBegin(GL_QUADS); // Top-left quad glTexCoord2f(1, 1); glVertex2f(x1, y1); glTexCoord2f(1, 0); glVertex2f(x1, y2); glTexCoord2f(0, 0); glVertex2f(x2, y2); glTexCoord2f(0, 1); glVertex2f(x2, y1); // Top-center quad glTexCoord2f(0, 1); glVertex2f(x2, y1); glTexCoord2f(0, 0); glVertex2f(x2, y2); glTexCoord2f(0, 0); glVertex2f(x3, y2); glTexCoord2f(0, 1); glVertex2f(x3, y1); // Top-right quad glTexCoord2f(0, 1); glVertex2f(x3, y1); glTexCoord2f(0, 0); glVertex2f(x3, y2); glTexCoord2f(1, 0); glVertex2f(x4, y2); glTexCoord2f(1, 1); glVertex2f(x4, y1); // Center-left quad glTexCoord2f(1, 0); glVertex2f(x1, y2); glTexCoord2f(1, 0); glVertex2f(x1, y3); glTexCoord2f(0, 0); glVertex2f(x2, y3); glTexCoord2f(0, 0); glVertex2f(x2, y2); // Center quad glTexCoord2f(0, 0); glVertex2f(x2, y3); glVertex2f(x2, y2); glVertex2f(x3, y2); glVertex2f(x3, y3); // Center-right quad glTexCoord2f(0, 0); glVertex2f(x3, y2); glTexCoord2f(0, 0); glVertex2f(x3, y3); glTexCoord2f(1, 0); glVertex2f(x4, y3); glTexCoord2f(1, 0); glVertex2f(x4, y2); // Bottom-left quad glTexCoord2f(1, 0); glVertex2f(x1, y3); glTexCoord2f(1, 1); glVertex2f(x1, y4); glTexCoord2f(0, 1); glVertex2f(x2, y4); glTexCoord2f(0, 0); glVertex2f(x2, y3); // Bottom-center quad glTexCoord2f(0, 0); glVertex2f(x2, y3); glTexCoord2f(0, 1); glVertex2f(x2, y4); glTexCoord2f(0, 1); glVertex2f(x3, y4); glTexCoord2f(0, 0); glVertex2f(x3, y3); // Bottom-right quad glTexCoord2f(0, 0); glVertex2f(x3, y3); glTexCoord2f(0, 1); glVertex2f(x3, y4); glTexCoord2f(1, 1); glVertex2f(x4, y4); glTexCoord2f(1, 0); glVertex2f(x4, y3); glEnd(); glDisable(GL_TEXTURE_2D); }
void VisualLine::RenderLineWithBorder(const Line3D& line, const Colour& colour, float thickness, LINE_STYLE style, const Colour& borderColour, float borderThickness, float depth, bool bSelected) { const uint SHORT_DASH_LEN = 5 * App::Inst().GetResolutionFactor(); const uint LONG_DASH_LEN = 15 * App::Inst().GetResolutionFactor(); const uint DASH_SPACING = 5 * App::Inst().GetResolutionFactor(); error::ErrorGL::Check(); glDepthRange(0.0, TERRAIN_START_DEPTH); if(style == HIDDEN) return; // Special case: 1 px line with no border can be more rapidly rendered using GL_LINES if(thickness == 1.0f && borderThickness == 0.0f) { glEnable(GL_LINE_STIPPLE); glLineStipple(REPEAT_FACTOR, style); glColor4f(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), colour.GetAlpha()); glLineWidth(1.0f); glBegin(GL_LINES); glVertex3f(line.start.x, line.start.y, line.start.z); glVertex3f(line.end.x, line.end.y, line.end.z); glEnd(); glDisable(GL_LINE_STIPPLE); return; } App::Inst().GetViewport()->GetCamera()->SetOrthoCamera(); glPushMatrix(); Point3D start = App::Inst().GetMapController()->ProjectToScreen(line.start); Point3D end = App::Inst().GetMapController()->ProjectToScreen(line.end); Point3D startToEnd = end - start; startToEnd.Normalize(); Point3D normalToLine = Point3D(-startToEnd.y, startToEnd.x, 0); if(style == SOLID) { RenderLineWithBorder(start, end, startToEnd, normalToLine, colour, thickness, borderColour, borderThickness, depth, bSelected); } else if(style == SHORT_DASH || style == LONG_DASH) { uint offset = SHORT_DASH_LEN; if(style == LONG_DASH) offset = LONG_DASH_LEN; Point3D dashStart = start; Point3D dashEnd = start + startToEnd*offset; while(true) { Point3D endDashToEndPt = end - dashEnd; if(endDashToEndPt.x*startToEnd.x > 0 && endDashToEndPt.y*startToEnd.y > 0) { // end of dash is before the end point RenderLineWithBorder(dashStart, dashEnd, startToEnd, normalToLine, colour, thickness, borderColour, borderThickness, depth, bSelected); dashStart += startToEnd*(offset+DASH_SPACING); dashEnd += startToEnd*(offset+DASH_SPACING); } else { // end of dask is after the end point // adjust the end of the dask to be at the end point dashEnd = end; // make sure start of the dask isn't also past the end point Point3D startDashToEndPt = end - dashStart; if(startDashToEndPt.x*startToEnd.x >=0 && startDashToEndPt.y*startToEnd.y >= 0) { // render final dash RenderLineWithBorder(dashStart, dashEnd, startToEnd, normalToLine, colour, thickness, borderColour, borderThickness, depth, bSelected); } break; } }; } glPopMatrix(); App::Inst().GetViewport()->GetCamera()->UnsetOrthoCamera(); error::ErrorGL::Check(); }
const D2D1_COLOR_F Direct2DLowLevelGraphicsContext::colourToD2D (const Colour& c) { return D2D1::ColorF::ColorF (c.getFloatRed(), c.getFloatGreen(), c.getFloatBlue(), c.getFloatAlpha()); }
void RendererGL3::SetColour(const Colour& colour) { glColor4fv(colour.RGBA()); }
void TreePropertiesDlg::Init() { // set the title of the properties dialog this->SetLabel( wxString(m_treeLayer->GetName().c_str()) + wxT( " : Tree Properties" ) ); // *** Set state of controls on General page m_txtLayerName->SetValue(wxString(m_treeLayer->GetName().c_str())); m_txtLayerDescription->SetValue(wxString(m_treeLayer->GetDescription().c_str())); m_txtAuthours->SetValue(wxString(m_treeLayer->GetAuthours().c_str())); // *** Set state of controls on Symbology page GeoTreeViewPtr geoTreeView = m_treeLayer->GetGeoTreeView(); // tree layout properties if(geoTreeView->GetLayout() == GeoTreeView::SLANTED_CLADOGRAM_3D) m_cboTreeLayout->SetValue(_T("3D slanted cladogram")); else if(geoTreeView->GetLayout() == GeoTreeView::CLADOGRAM_3D) m_cboTreeLayout->SetValue(_T("3D cladogram")); else if(geoTreeView->GetLayout() == GeoTreeView::SLANTED_PHYLOGRAM_3D) m_cboTreeLayout->SetValue(_T("3D slanted phylogram")); else if(geoTreeView->GetLayout() == GeoTreeView::CLADOGRAM_2D) m_cboTreeLayout->SetValue(_T("2D cladogram")); else if(geoTreeView->GetLayout() == GeoTreeView::PHYLOGRAM_2D) m_cboTreeLayout->SetValue(_T("2D phylogram")); else if(geoTreeView->GetLayout() == GeoTreeView::ELLIPSE_QUADRANT) m_cboTreeLayout->SetValue(_T("Elliptical Layout")); m_spinTreeThickness->SetValue(geoTreeView->GetLineThickness()); m_txtTreeHeight->SetValue(wxString::Format(wxT("%f"), geoTreeView->GetHeight())); if(geoTreeView->GetOrientation() == GeoTreeView::VERTICAL) m_cbo2dOrientation->SetValue(_T("Vertical")); else if(geoTreeView->GetOrientation() == GeoTreeView::HORIZONTAL) m_cbo2dOrientation->SetValue(_T("Horizontal")); m_chkDrawLayoutPrimative->SetValue(geoTreeView->GetLayoutPrimativeVisibility()); // tree style properties Colour treeColour = geoTreeView->GetColour(); m_colourTree->SetColour(wxColour(treeColour.GetRedInt(), treeColour.GetGreenInt(), treeColour.GetBlueInt(), treeColour.GetAlphaInt())); ReplaceColourPicker( m_colourTree, treeColour ); if(geoTreeView->GetTreeColourStyle() == GeoTreeView::COLOUR_SINGLE) m_cboTreeColourStyle->SetValue(_T("Single colour")); else if(geoTreeView->GetTreeColourStyle() == GeoTreeView::COLOUR_DISCRETE) m_cboTreeColourStyle->SetValue(_T("Propogate discrete colours")); else if(geoTreeView->GetTreeColourStyle() == GeoTreeView::COLOUR_CONTINUOUS) m_cboTreeColourStyle->SetValue(_T("Propogate continuous colours")); m_spinLeafNodeSize->SetValue(geoTreeView->GetLeafNodeSize()); m_spinInternalNodeSize->SetValue(geoTreeView->GetInternalNodeSize()); m_spinBranchBorderSize->SetValue(geoTreeView->GetBranchBorderSize()); m_spinLeafNodeBorderSize->SetValue(geoTreeView->GetLeafNodeBorderSize()); m_spinInternalNodeBorderSize->SetValue(geoTreeView->GetInternalNodeBorderSize()); m_spinGeoPointBorderSize->SetValue(geoTreeView->GetGeoPtsBorderSize()); m_spinLocationLineBorderSize->SetValue(geoTreeView->GetLocationLineBorderSize()); m_spinCorrelationLineBorderSize->SetValue(geoTreeView->GetCorrelationLineBorderSize()); Colour leafNodeBorderColour = geoTreeView->GetLeafNodeBorderColour(); m_colourLeafNodeBorder->SetColour(wxColour(leafNodeBorderColour.GetRedInt(), leafNodeBorderColour.GetGreenInt(), leafNodeBorderColour.GetBlueInt(), leafNodeBorderColour.GetAlphaInt())); ReplaceColourPicker( m_colourLeafNodeBorder, leafNodeBorderColour ); Colour internalNodeBorderColour = geoTreeView->GetInternalNodeBorderColour(); m_colourInternalNodeBorder->SetColour(wxColour(internalNodeBorderColour.GetRedInt(), internalNodeBorderColour.GetGreenInt(), internalNodeBorderColour.GetBlueInt(), internalNodeBorderColour.GetAlphaInt())); ReplaceColourPicker( m_colourInternalNodeBorder, internalNodeBorderColour ); Colour geoPtsBorderColour = geoTreeView->GetGeoPtsBorderColour(); m_colourGeoPointBorder->SetColour(wxColour(geoPtsBorderColour.GetRedInt(), geoPtsBorderColour.GetGreenInt(), geoPtsBorderColour.GetBlueInt(), geoPtsBorderColour.GetAlphaInt())); ReplaceColourPicker( m_colourGeoPointBorder, geoPtsBorderColour ); Colour branchBorderColour = geoTreeView->GetBranchBorderColour(); m_colourBranchBorder->SetColour(wxColour(branchBorderColour.GetRedInt(), branchBorderColour.GetGreenInt(), branchBorderColour.GetBlueInt(), branchBorderColour.GetAlphaInt())); ReplaceColourPicker( m_colourBranchBorder, branchBorderColour ); Colour locationLineBorderColour = geoTreeView->GetLocationLineBorderColour(); m_colourLocationLineBorder->SetColour(wxColour(locationLineBorderColour.GetRedInt(), locationLineBorderColour.GetGreenInt(), locationLineBorderColour.GetBlueInt(), locationLineBorderColour.GetAlphaInt())); ReplaceColourPicker( m_colourLocationLineBorder, locationLineBorderColour ); Colour correlationLineBorderColour = geoTreeView->GetCorrelationLineBorderColour(); m_colourCorrelationLineBorder->SetColour(wxColour(correlationLineBorderColour.GetRedInt(), correlationLineBorderColour.GetGreenInt(), correlationLineBorderColour.GetBlueInt(), correlationLineBorderColour.GetAlphaInt())); ReplaceColourPicker( m_colourCorrelationLineBorder, correlationLineBorderColour ); // location line properties m_spinLocationLineThickness->SetValue(geoTreeView->LocationLines().GetThickness()); if(geoTreeView->LocationLines().GetLineStyle() == VisualLine::SOLID) m_cboLocationLineStyle->SetValue(_T("Solid")); else if(geoTreeView->LocationLines().GetLineStyle() == VisualLine::SHORT_DASH) m_cboLocationLineStyle->SetValue(_T("Short dash")); else if(geoTreeView->LocationLines().GetLineStyle() == VisualLine::LONG_DASH) m_cboLocationLineStyle->SetValue(_T("Long dash")); else if(geoTreeView->LocationLines().GetLineStyle() == VisualLine::HIDDEN) m_cboLocationLineStyle->SetValue(_T("Hidden")); // correlation line properties m_spinCorrelationLineThickness->SetValue(geoTreeView->CorrelationLines().GetThickness()); if(geoTreeView->CorrelationLines().GetLineStyle() == VisualLine::SOLID) m_cboCorrelationLineStyle->SetValue(_T("Solid")); else if(geoTreeView->CorrelationLines().GetLineStyle() == VisualLine::SHORT_DASH) m_cboCorrelationLineStyle->SetValue(_T("Short dash")); else if(geoTreeView->CorrelationLines().GetLineStyle() == VisualLine::LONG_DASH) m_cboCorrelationLineStyle->SetValue(_T("Long dash")); else if(geoTreeView->CorrelationLines().GetLineStyle() == VisualLine::HIDDEN) m_cboCorrelationLineStyle->SetValue(_T("Hidden")); // internal drop line properties m_spinInternalDropLineThickness->SetValue(geoTreeView->Get3dInternalDropLineStyle().GetSize()); Colour colour = geoTreeView->Get3dInternalDropLineStyle().GetColour(); m_colourInternalDropLine->SetColour(wxColour(colour.GetRedInt(), colour.GetGreenInt(), colour.GetBlueInt(), colour.GetAlphaInt())); ReplaceColourPicker( m_colourInternalDropLine, colour ); if(geoTreeView->Get3dInternalDropLineStyle().GetLineStyle() == VisualLine::SOLID) m_cboInternalDropLineStyle->SetValue(_T("Solid")); else if(geoTreeView->Get3dInternalDropLineStyle().GetLineStyle() == VisualLine::SHORT_DASH) m_cboInternalDropLineStyle->SetValue(_T("Short dash")); else if(geoTreeView->Get3dInternalDropLineStyle().GetLineStyle() == VisualLine::LONG_DASH) m_cboInternalDropLineStyle->SetValue(_T("Long dash")); else if(geoTreeView->Get3dInternalDropLineStyle().GetLineStyle() == VisualLine::HIDDEN) m_cboInternalDropLineStyle->SetValue(_T("Hidden")); // leaf drop line properties if(geoTreeView->Get3dLeafDropLineStyle().GetLineStyle() == VisualLine::SOLID) m_cboLeafDropLineStyle->SetValue(_T("Solid")); else if(geoTreeView->Get3dLeafDropLineStyle().GetLineStyle() == VisualLine::SHORT_DASH) m_cboLeafDropLineStyle->SetValue(_T("Short dash")); else if(geoTreeView->Get3dLeafDropLineStyle().GetLineStyle() == VisualLine::LONG_DASH) m_cboLeafDropLineStyle->SetValue(_T("Long dash")); else if(geoTreeView->Get3dLeafDropLineStyle().GetLineStyle() == VisualLine::HIDDEN) m_cboLeafDropLineStyle->SetValue(_T("Hidden")); // geography line properties m_spinGeoLineOffset->SetValue(uint(geoTreeView->GetGeographyLineOffsetPercentage()*100 + 0.5)); m_spinGeoLineThickness->SetValue(geoTreeView->GeographyLine().GetSize()); if(geoTreeView->GeographyLine().GetLineStyle() == VisualLine::SOLID) m_cboGeoLineStyle->SetValue(_T("Solid")); else if(geoTreeView->GeographyLine().GetLineStyle() == VisualLine::SHORT_DASH) m_cboGeoLineStyle->SetValue(_T("Short dash")); else if(geoTreeView->GeographyLine().GetLineStyle() == VisualLine::LONG_DASH) m_cboGeoLineStyle->SetValue(_T("Long dash")); else if(geoTreeView->GeographyLine().GetLineStyle() == VisualLine::HIDDEN) m_cboGeoLineStyle->SetValue(_T("Hidden")); colour = geoTreeView->GeographyLine().GetColour(); m_colourGeoLine->SetColour(wxColour(colour.GetRedInt(), colour.GetGreenInt(), colour.GetBlueInt(), colour.GetAlphaInt())); ReplaceColourPicker( m_colourGeoLine, colour ); // geographic point properties m_spinGeoPointSize->SetValue(geoTreeView->GeographicPoints().GetSize()); m_chkDrawGeoPoint->SetValue(geoTreeView->GeographicPoints().GetVisibility()); m_chkEvenlySpeadGeoPts->SetValue(geoTreeView->GetSpreadGeographyPts()); m_chkDrawGeoAxis->SetValue(geoTreeView->GetGeographicAxisVisibility()); m_chkOptimizeLeafNodes->SetValue(geoTreeView->GetOptimizeTopology()); // *** Set state of controls on Label page m_spinLabelSize->SetValue(geoTreeView->GetFontSize()); Colour fontColour = geoTreeView->GetFontColour(); m_colourLabel->SetColour(wxColour(fontColour.GetRedInt(), fontColour.GetGreenInt(), fontColour.GetBlueInt(), fontColour.GetAlphaInt())); ReplaceColourPicker( m_colourLabel, fontColour ); m_chkShowLabels->SetValue(geoTreeView->GetLabelVisibility()); // set state of controls on Metadata page m_txtLayerSource->SetValue(wxString(m_treeLayer->GetPath().c_str()) + _T("\\") + wxString(m_treeLayer->GetFilename().c_str())); SetMetaData(); }
void NewLookAndFeel::drawGlassLozenge (Graphics& g, const float x, const float y, const float width, const float height, const Colour& colour, const float outlineThickness, const float cornerSize, const bool flatOnLeft, const bool flatOnRight, const bool flatOnTop, const bool flatOnBottom, const bool isMouseOverButton, const bool isButtonDown) throw() { if (width <= outlineThickness || height <= outlineThickness) return; const float cs = cornerSize < 0 ? jmin (width * 0.5f, height * 0.5f) : cornerSize; Path outline; createRoundedPath (outline, x, y, width, height, cs, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); { ColourGradient cg; if (isButtonDown) { cg = ColourGradient(colour, 0, y, colour.darker (0.1f), 0, y + height, false); } else { cg = ColourGradient(colour.darker(0.1f), 0, y, colour, 0, y + height, false); } g.setGradientFill (cg); g.fillPath (outline); } { const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f; const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; Path highlight; createRoundedPath (highlight, x + leftIndent, y + cs * 0.1f, width - (leftIndent + rightIndent), height * 0.2f, cs * 0.2f, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); if (!isButtonDown) { g.setGradientFill (ColourGradient (colour.brighter (2.0f), 0, y + height * 0.06f, Colours::transparentWhite, 0, y + height * 0.2f, false)); } else { g.setGradientFill (ColourGradient (colour.darker (0.3f), 0, y + height * 0.06f, Colours::transparentBlack, 0, y + height * 0.2f, false)); } g.fillPath (highlight); } { const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f; const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; Path shadow; createRoundedPath (shadow, x + leftIndent, y + height * 0.85f + cs * 0.1f, width - (leftIndent + rightIndent), height * 0.2f, cs * 0.2f, ! (flatOnLeft || flatOnTop), ! (flatOnRight || flatOnTop), ! (flatOnLeft || flatOnBottom), ! (flatOnRight || flatOnBottom)); if (!isButtonDown) { g.setGradientFill (ColourGradient (Colours::transparentWhite, 0, y + height * 0.85f, colour.darker (0.4f), 0, y + height, false)); } g.fillPath (shadow); } g.setColour(Colour::fromRGBA(0, 0, 0, 150)); g.strokePath (outline, PathStrokeType (outlineThickness)); }
void SoundplaneTouchGraphView::renderTouchBarGraphs() { if (!mpModel) return; if (!isShowing()) return; int viewW = getBackingLayerWidth(); int viewH = getBackingLayerHeight(); const MLSignal& currentTouch = mpModel->getTouchFrame(); const MLSignal& touchHistory = mpModel->getTouchHistory(); const int frames = mpModel->getFloatProperty("max_touches"); if (!frames) return; const Colour c = findColour(MLLookAndFeel::backgroundColor); float p = c.getBrightness(); int margin = viewH / 30; int numSize = margin*2; int left = margin*2 + numSize; int right = viewW - margin; int top = margin; int bottom = viewH - margin; int frameWidth = right - left; int frameOffset = (bottom - top)/frames; int frameHeight = frameOffset - margin; MLRect frameSize(0, 0, frameWidth, frameHeight); MLGL::orthoView(viewW, viewH); for(int j=0; j<frames; ++j) { // draw frames p = 0.9f; glColor4f(p, p, p, 1.0f); MLRect fr = frameSize.translated(Vec2(left, margin + j*frameOffset)); MLGL::fillRect(fr); p = 0.6f; glColor4f(p, p, p, 1.0f); MLGL::strokeRect(fr); // draw touch activity indicators at left glColor4fv(MLGL::getIndicatorColor(j)); MLRect r(0, 0, numSize, numSize); MLRect tr = r.translated(Vec2(margin, margin + j*frameOffset + (frameHeight - numSize)/2)); int age = currentTouch(4, j); if (age > 0) MLGL::fillRect(tr); else MLGL::strokeRect(tr); // draw history MLRange frameXRange(fr.left(), fr.right()); frameXRange.convertTo(MLRange(0, (float)kSoundplaneHistorySize)); MLRange frameYRange(0, 1); frameYRange.convertTo(MLRange(fr.bottom(), fr.top())); glBegin(GL_LINES); for(int i=fr.left() + 1; i<fr.right()-1; ++i) { int time = frameXRange(i); float force = touchHistory(2, j, time); // float d = touchHistory(3, j, time); // int age = touchHistory(4, j, time); float y = frameYRange.convert(force); // float drawY = (age > 0) ? y : 0.; // y = frameYRange.convert(d); // draw line glVertex2f(i, fr.bottom()); glVertex2f(i, y); } glEnd(); } }
bool MapTexture::ComputeColour(Point3D* coords, ProgressDlgPtr progressDlg) { float currentHeight = 0; int j = 0; float alpha = 1.0 - m_transparencyPercentage / 100.0; int texSize = m_texWidth * m_texHeight; for(int i = 0; i < texSize; i++ ) { // update progress if(progressDlg && i % 1000 == 0) { if(!progressDlg->Update(int((float(i)/texSize)*99))) return false; } currentHeight = coords[i].y; // find interval current point falls in uint intervalIndex; for(intervalIndex = 0; intervalIndex < m_numColours; ++intervalIndex) { if(currentHeight <= m_intervals[intervalIndex]) { break; } } if(intervalIndex == m_numColours) // can occur due to rounding errors when calculating the maximum m_intervals value intervalIndex = m_numColours - 1; // linearly interpolate colour ColourPtr colour; if(intervalIndex == 0) { colour.reset(new Colour(m_colours[0]->GetRed(), m_colours[0]->GetGreen(), m_colours[0]->GetBlue(), alpha)); } else { ColourPtr colour1 = m_colours[intervalIndex-1]; ColourPtr colour2 = m_colours[intervalIndex]; float interval1 = m_intervals[intervalIndex-1]; float interval2 = m_intervals[intervalIndex]; if(m_interpolate == LINEARLY) { Colour interpolatedColour = Colour::Interpolate(colour1, colour2, currentHeight, interval1, interval2); colour.reset(new Colour(interpolatedColour.GetRed(), interpolatedColour.GetGreen(), interpolatedColour.GetBlue(), alpha)); } else { colour.reset(new Colour(colour1->GetRed(), colour1->GetGreen(), colour1->GetBlue(), alpha)); } } m_texture[ j ] = GLubyte( colour->GetRedInt() ); m_texture[ j + 1 ] = GLubyte( colour->GetGreenInt() ); m_texture[ j + 2 ] = GLubyte( colour->GetBlueInt() ); m_texture[ j + 3 ] = GLubyte( colour->GetAlphaInt() ); j += 4; //keep track of where we are in rgba byte array - each Vertex as 4 entries } return true; }
void LocationPolygons::InitPolygons() { if (m_currentLocationSet.empty()) return; //Clears existing polygons m_polygons.clear(); Colour currentColour; GeoCoord currentCoord; Point3D mapPoint; PolygonModelPtr emptyPoly( new PolygonModel() ); m_polygons.push_back( emptyPoly ); int currentPolygonIndex = 0; //Get elevation to be used MapControllerPtr mapController = App::Inst().GetLayerTreeController()->GetMapLayer(0)->GetMapController(); if ( m_autoAdjustElevation ) { m_elevationUsed = mapController->GetMaxElevationGridSpace() * mapController->GetVerticalExaggeration() + 0.005; // Add a minimal amount to avoid clashing // between colours of polygons and map } else { m_elevationUsed = m_inputElevation; } //Sort location set by colour std::sort (m_currentLocationSet.begin(), m_currentLocationSet.end(), LocationPolygons::SortByColour); const std::wstring lat ( L"Latitude" ); const std::wstring lon ( L"Longitude" ); //Goes through each location in the given set for (uint i = 0; i < m_currentLocationSet.size(); i++) { //If the current location is active if (m_currentLocationSet[i]->GetLocationController()->GetLocationModel()->IsActive()) { PolygonModelPtr emptyPoly( new PolygonModel() ); //Sets the current properties of the location currentColour = m_currentLocationSet[i]->GetLocationController()->GetColour(); currentColour.SetAlpha(m_fillOpacity); currentCoord.easting = wxAtof ( m_currentLocationSet[i]->GetLocationController()->GetLocationModel()->GetData(lon).c_str() ); currentCoord.northing = wxAtof ( m_currentLocationSet[i]->GetLocationController()->GetLocationModel()->GetData(lat).c_str() ); //Converts from lat/long point to a point on the map App::Inst().GetMapController()->GetMapModel()->LatLongToGrid(currentCoord, mapPoint); //If there's a new colour, a new polygon is created if (currentColour != m_polygons[currentPolygonIndex]->polygonColour) { m_polygons.push_back(emptyPoly); currentPolygonIndex++; m_polygons[currentPolygonIndex]->polygonColour = currentColour; } //Sets elevation if (m_increasingElevation) mapPoint.y = m_elevationUsed + m_elevationOffset*currentPolygonIndex; else mapPoint.y = m_elevationUsed; //If the point is the same point (within EPSILON) then it should not be added to the polygon //**If the same points are added, then the convex hull algorithm doesn't work** bool shouldAdd = true; for (uint j = 0; j < m_polygons[currentPolygonIndex]->originalVertices.size(); j++) { double deltaX = abs( m_polygons[currentPolygonIndex]->originalVertices[j].x - mapPoint.x ); double deltaY = abs( m_polygons[currentPolygonIndex]->originalVertices[j].z - mapPoint.z ); if (deltaX <= EPSILON && deltaY <= EPSILON) shouldAdd = false; } if (shouldAdd) { m_polygons[currentPolygonIndex]->originalVertices.push_back(mapPoint); } } } //Sorts the polygons according to the given algorithm then initializes them for (uint i = 0; i < m_polygons.size(); i++) { if (m_sortBy == CONVEX_HULL) { ConvexHull(m_polygons[i]); } m_polygons[i]->InitPolygon(m_polygonInflation, m_smoothPolygons); } }
void ConnectingWindow::Render( bool _hasFocus ) { InterfaceWindow::Render( _hasFocus ); float yPos = m_y + 40; // // Render our connection state g_renderer->SetFont( "kremlin" ); float fraction = 0.0f; char *caption = NULL; Colour col; switch( g_app->GetClientToServer()->m_connectionState ) { case ClientToServer::StateDisconnected: col.Set(255,0,0,255); caption = LANGUAGEPHRASE("dialog_state_disconnected"); fraction = 0.0f; break; case ClientToServer::StateConnecting: col.Set(255,255,0,255); caption = LANGUAGEPHRASE("dialog_state_connecting"); fraction = 0.5f; break; case ClientToServer::StateHandshaking: case ClientToServer::StateConnected: col.Set(0,255,0,255); caption = LANGUAGEPHRASE("dialog_state_connected"); fraction = 1.0f; break; } g_renderer->TextCentreSimple( m_x+m_w/2, yPos, col, 20, caption ); yPos += 20; if( fraction > 0.0f ) { g_renderer->RectFill( m_x + 30, yPos, (m_w-60)*fraction, 20, col ); g_renderer->Rect( m_x+30, yPos, (m_w-60), 20, White ); int numConnectionAttempts = g_app->GetClientToServer()->m_connectionAttempts; if( fraction < 1.0f && numConnectionAttempts > 0 ) { char caption[512]; sprintf( caption, LANGUAGEPHRASE("dialog_state_attempts") ); LPREPLACEINTEGERFLAG( 'A', numConnectionAttempts, caption ); g_renderer->TextCentreSimple( m_x + m_w/2, m_y + m_h - 60, White, 14, caption ); } } // // Render our sync status (ie receiving all data from the server) yPos += 40; if( g_app->GetClientToServer()->IsConnected() ) { if( m_stage == 0 ) { m_stage = 1; m_stageStartTime = GetHighResTime(); } int serverSeqId = g_app->GetClientToServer()->m_serverSequenceId; int latestSeqId = g_app->GetClientToServer()->m_lastValidSequenceIdFromServer; int numRemaining = serverSeqId-latestSeqId; numRemaining--; if( numRemaining > m_maxUpdatesRemaining ) { m_maxUpdatesRemaining = numRemaining; } if( m_maxUpdatesRemaining > 0 ) { fraction = numRemaining / (float) m_maxUpdatesRemaining; } else { fraction = 0.0f; } Clamp( fraction, 0.0f, 1.0f ); fraction = 1.0f - fraction; col.Set( (1-fraction)*255, fraction*255, 0, 255 ); const char *caption = numRemaining > 5 ? LANGUAGEPHRASE("dialog_state_receiving") : LANGUAGEPHRASE("dialog_state_received"); g_renderer->TextCentreSimple( m_x+m_w/2, yPos, col, 20, caption ); yPos += 20; g_renderer->RectFill( m_x+30, yPos, (m_w-60)*fraction, 20, col ); g_renderer->Rect( m_x+30, yPos, (m_w-60), 20, White ); if( m_stage == 1 ) { RenderTimeRemaining(fraction); } // // Render how much of the received data we have successfully parsed int lagRemaining = 0; if( g_lastProcessedSequenceId > 0 && numRemaining < 10 ) { if( m_stage != 2 ) { m_stage = 2; m_stageStartTime = GetHighResTime(); } yPos += 40; int serverSeqId = g_app->GetClientToServer()->m_serverSequenceId; lagRemaining = serverSeqId - g_lastProcessedSequenceId; lagRemaining --; if( lagRemaining > m_maxLagRemaining ) { m_maxLagRemaining = lagRemaining; } fraction = lagRemaining / (float) m_maxLagRemaining; Clamp( fraction, 0.0f, 1.0f ); fraction = 1.0f - fraction; col.Set( (1-fraction)*255, fraction*255, 0, 255 ); const char *caption = lagRemaining > 5 ? LANGUAGEPHRASE("dialog_state_synchronising") : LANGUAGEPHRASE("dialog_state_synchronised"); g_renderer->TextCentreSimple( m_x+m_w/2, yPos, col, 20, caption ); yPos += 20; g_renderer->RectFill( m_x+30, yPos, (m_w-60)*fraction, 20, col ); g_renderer->Rect( m_x+30, yPos, (m_w-60), 20, White ); if( m_stage == 2 ) { RenderTimeRemaining( fraction ); } } // // Connection is done, we can shut down now // Pop up lobby if we were asked to do so if( g_app->GetClientToServer()->m_connectionState == ClientToServer::StateConnected ) { if( m_popupLobbyAtEnd ) { if( !EclGetWindow( "LOBBY" ) ) { LobbyWindow *lobby = new LobbyWindow(); ChatWindow *chat = new ChatWindow(); chat->SetPosition( g_windowManager->WindowW()/2 - chat->m_w/2, g_windowManager->WindowH() - chat->m_h - 30 ); EclRegisterWindow( chat ); float lobbyX = g_windowManager->WindowW()/2 - lobby->m_w/2; float lobbyY = chat->m_y - lobby->m_h - 30; lobbyY = std::max( lobbyY, 0.0f ); lobby->SetPosition(lobbyX, lobbyY); EclRegisterWindow( lobby ); } } if( numRemaining < 5 && lagRemaining < 5 ) { EclRemoveWindow(m_name); } } } else { if( g_app->GetClientToServer()->m_connectionState == ClientToServer::StateDisconnected ) { EclRemoveWindow(m_name); } } g_renderer->SetFont(); }
void CtrlrLuaMethodEditorTabsLF::drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown) { const Rectangle<int> activeArea (button.getActiveArea()); const TabbedButtonBar::Orientation o = button.getTabbedButtonBar().getOrientation(); const Colour bkg (button.getTabBackgroundColour()); if (button.getToggleState()) { g.setColour (bkg); } else { Point<int> p1, p2; switch (o) { case TabbedButtonBar::TabsAtBottom: p1 = activeArea.getBottomLeft(); p2 = activeArea.getTopLeft(); break; case TabbedButtonBar::TabsAtTop: p1 = activeArea.getTopLeft(); p2 = activeArea.getBottomLeft(); break; case TabbedButtonBar::TabsAtRight: p1 = activeArea.getTopRight(); p2 = activeArea.getTopLeft(); break; case TabbedButtonBar::TabsAtLeft: p1 = activeArea.getTopLeft(); p2 = activeArea.getTopRight(); break; default: jassertfalse; break; } g.setGradientFill (ColourGradient (bkg.brighter (0.2f), (float) p1.x, (float) p1.y, bkg.darker (0.1f), (float) p2.x, (float) p2.y, false)); } g.fillRect (activeArea); g.setColour (button.findColour (TabbedButtonBar::tabOutlineColourId)); Rectangle<int> r (activeArea); if (o != TabbedButtonBar::TabsAtBottom) g.fillRect (r.removeFromTop (1)); if (o != TabbedButtonBar::TabsAtTop) g.fillRect (r.removeFromBottom (1)); if (o != TabbedButtonBar::TabsAtRight) g.fillRect (r.removeFromLeft (1)); if (o != TabbedButtonBar::TabsAtLeft) g.fillRect (r.removeFromRight (1)); const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f; Colour col (bkg.contrasting().withMultipliedAlpha (alpha)); if (TabbedButtonBar* bar = button.findParentComponentOfClass<TabbedButtonBar>()) { TabbedButtonBar::ColourIds colID = button.isFrontTab() ? TabbedButtonBar::frontTextColourId : TabbedButtonBar::tabTextColourId; if (bar->isColourSpecified (colID)) col = bar->findColour (colID); else if (isColourSpecified (colID)) col = findColour (colID); } const Rectangle<float> area (button.getTextArea().toFloat()); float length = area.getWidth(); float depth = area.getHeight(); if (button.getTabbedButtonBar().isVertical()) std::swap (length, depth); TextLayout textLayout; createTabTextLayout (button, length, depth, col, textLayout); AffineTransform t; switch (o) { case TabbedButtonBar::TabsAtLeft: t = t.rotated (float_Pi * -0.5f).translated (area.getX(), area.getBottom()); break; case TabbedButtonBar::TabsAtRight: t = t.rotated (float_Pi * 0.5f).translated (area.getRight(), area.getY()); break; case TabbedButtonBar::TabsAtTop: case TabbedButtonBar::TabsAtBottom: t = t.translated (area.getX(), area.getY()); break; default: jassertfalse; break; } g.addTransform (t); textLayout.draw (g, Rectangle<float> (length, depth)); }
void MidiMixerWindow::setupTabs() { DeviceListConstIterator it; MidiDevice *dev = 0; InstrumentList instruments; InstrumentList::const_iterator iIt; int faderCount = 0, deviceCount = 1; if (m_tabFrame) delete m_tabFrame; // Setup m_tabFrame // QWidget *blackWidget = new QWidget(this); setCentralWidget(blackWidget); QVBoxLayout *centralLayout = new QVBoxLayout; blackWidget->setLayout(centralLayout); m_tabWidget = new QTabWidget; centralLayout->addWidget(m_tabWidget); connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(slotCurrentTabChanged(QWidget *))); m_tabWidget->setTabPosition(QTabWidget::South); setWindowTitle(tr("MIDI Mixer")); setWindowIcon(IconLoader().loadPixmap("window-midimixer")); for (it = m_studio->begin(); it != m_studio->end(); ++it) { dev = dynamic_cast<MidiDevice*>(*it); if (dev) { // Get the control parameters that are on the IPB (and hence can // be shown here too). // ControlList controls = getIPBForMidiMixer(dev); instruments = dev->getPresentationInstruments(); // Don't add a frame for empty devices // if (!instruments.size()) continue; m_tabFrame = new QFrame(m_tabWidget); m_tabFrame->setContentsMargins(10, 10, 10, 10); // m_tabFrame->setContentsMargins(5, 5, 5, 5); ??? QGridLayout *mainLayout = new QGridLayout(m_tabFrame); // MIDI Mixer label QLabel *label = new QLabel("", m_tabFrame); mainLayout->addWidget(label, 0, 0, 0, 16, Qt::AlignCenter); // control labels for (size_t i = 0; i < controls.size(); ++i) { label = new QLabel(QObject::tr(controls[i].getName().c_str()), m_tabFrame); mainLayout->addWidget(label, i + 1, 0, Qt::AlignCenter); } // meter label // (obsolete abandoned code deleted here) // volume label label = new QLabel(tr("Volume"), m_tabFrame); mainLayout->addWidget(label, controls.size() + 2, 0, Qt::AlignCenter); // instrument label label = new QLabel(tr("Instrument"), m_tabFrame); label->setFixedWidth(80); //!!! this should come from metrics mainLayout->addWidget(label, controls.size() + 3, 0, Qt::AlignLeft); int posCount = 1; int firstInstrument = -1; for (iIt = instruments.begin(); iIt != instruments.end(); ++iIt) { // Add new fader struct // m_faders.push_back(new FaderStruct()); // Store the first ID // if (firstInstrument == -1) firstInstrument = (*iIt)->getId(); // Add the controls // for (size_t i = 0; i < controls.size(); ++i) { QColor knobColour = QColor(Qt::white); if (controls[i].getColourIndex() > 0) { Colour c = m_document->getComposition().getGeneralColourMap(). getColourByIndex(controls[i].getColourIndex()); knobColour = QColor(c.getRed(), c.getGreen(), c.getBlue()); } Rotary *controller = new Rotary(m_tabFrame, controls[i].getMin(), controls[i].getMax(), 1.0, 5.0, controls[i].getDefault(), 20, Rotary::NoTicks, false, controls[i].getDefault() == 64); //!!! hacky controller->setKnobColour(knobColour); connect(controller, SIGNAL(valueChanged(float)), this, SLOT(slotControllerChanged(float))); mainLayout->addWidget(controller, i + 1, posCount, Qt::AlignCenter); // Store the rotary // m_faders[faderCount]->m_controllerRotaries.push_back( std::pair<MidiByte, Rotary*> (controls[i].getControllerValue(), controller)); } // VU meter // MidiMixerVUMeter *meter = new MidiMixerVUMeter(m_tabFrame, VUMeter::FixedHeightVisiblePeakHold, 6, 30); mainLayout->addWidget(meter, controls.size() + 1, posCount, Qt::AlignCenter); m_faders[faderCount]->m_vuMeter = meter; // Volume fader // Fader *fader = new Fader(0, 127, 100, 20, 80, m_tabFrame); mainLayout->addWidget(fader, controls.size() + 2, posCount, Qt::AlignCenter); m_faders[faderCount]->m_volumeFader = fader; // Label // QLabel *idLabel = new QLabel(QString("%1"). arg((*iIt)->getId() - firstInstrument + 1), m_tabFrame); idLabel->setObjectName("idLabel"); mainLayout->addWidget(idLabel, controls.size() + 3, posCount, Qt::AlignCenter); // store id in struct m_faders[faderCount]->m_id = (*iIt)->getId(); // Connect them up // connect(fader, SIGNAL(faderChanged(float)), this, SLOT(slotFaderLevelChanged(float))); // Update all the faders and controllers // slotUpdateInstrument((*iIt)->getId()); // Increment counters // posCount++; faderCount++; } QString name = QString("%1 (%2)") .arg(QObject::tr(dev->getName().c_str())) .arg(deviceCount++); addTab(m_tabFrame, name); } } }
bool Compute_Pigment (Colour& colour, const PIGMENT *Pigment, const VECTOR EPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) { int Colour_Found; VECTOR TPoint; DBL value; register DBL fraction; const BLEND_MAP_ENTRY *Cur, *Prev; Colour Temp_Colour; const BLEND_MAP *Blend_Map = Pigment->Blend_Map; UV_VECT UV_Coords; if ((Thread->qualityFlags & Q_QUICKC) != 0 && Pigment->Quick_Colour.red() != -1.0 && Pigment->Quick_Colour.green() != -1.0 && Pigment->Quick_Colour.blue() != -1.0) { colour = Pigment->Quick_Colour; return (true); } if (Pigment->Type <= LAST_SPECIAL_PATTERN) { Colour_Found = true; switch (Pigment->Type) { case NO_PATTERN: colour.clear(); break; case PLAIN_PATTERN: colour = Pigment->colour; break; case AVERAGE_PATTERN: Warp_EPoint (TPoint, EPoint, reinterpret_cast<const TPATTERN *>(Pigment)); Do_Average_Pigments(colour, Pigment, TPoint, Intersect, ray, Thread); break; case UV_MAP_PATTERN: if(Intersect == NULL) throw POV_EXCEPTION_STRING("The 'uv_mapping' pattern cannot be used as part of a pigment function!"); Cur = &(Pigment->Blend_Map->Blend_Map_Entries[0]); if (Blend_Map->Type == COLOUR_TYPE) { Colour_Found = true; Assign_Colour(*colour, Cur->Vals.colour); } else { /* Don't bother warping, simply get the UV vect of the intersection */ Intersect->Object->UVCoord(UV_Coords, Intersect, Thread); TPoint[X] = UV_Coords[U]; TPoint[Y] = UV_Coords[V]; TPoint[Z] = 0; if (Compute_Pigment(colour, Cur->Vals.Pigment,TPoint,Intersect, ray, Thread)) Colour_Found = true; } break; case BITMAP_PATTERN: Warp_EPoint (TPoint, EPoint, reinterpret_cast<const TPATTERN *>(Pigment)); colour.clear(); Colour_Found = image_map (TPoint, Pigment, colour); break; default: throw POV_EXCEPTION_STRING("Pigment type not yet implemented."); } return(Colour_Found); } Colour_Found = false; /* NK 19 Nov 1999 added Warp_EPoint */ Warp_EPoint (TPoint, EPoint, reinterpret_cast<const TPATTERN *>(Pigment)); value = Evaluate_TPat (reinterpret_cast<const TPATTERN *>(Pigment),TPoint,Intersect, ray, Thread); Search_Blend_Map (value, Blend_Map, &Prev, &Cur); if (Blend_Map->Type == COLOUR_TYPE) { Colour_Found = true; Assign_Colour(*colour, Cur->Vals.colour); } else { Warp_EPoint (TPoint, EPoint, reinterpret_cast<const TPATTERN *>(Pigment)); if (Compute_Pigment(colour, Cur->Vals.Pigment,TPoint,Intersect, ray, Thread)) Colour_Found = true; } if (Prev != Cur) { if (Blend_Map->Type == COLOUR_TYPE) { Colour_Found = true; Assign_Colour(*Temp_Colour, Prev->Vals.colour); } else { if (Compute_Pigment(Temp_Colour, Prev->Vals.Pigment, TPoint, Intersect, ray, Thread)) Colour_Found = true; } fraction = (value - Prev->value) / (Cur->value - Prev->value); colour = Temp_Colour + fraction * (colour - Temp_Colour); } return(Colour_Found); }
inline bool operator==(const Colour& rhs) const { return colourVector() == rhs.colourVector(); }
void LocationSetPropertiesDlg::InitLocationSetLabel() { // populate combo box with all fields associated with a location std::vector<std::wstring> fields = m_locationSetController->GetMetadataFields(); std::vector<std::wstring>::iterator it; for(it = fields.begin(); it != fields.end(); ++it) m_cboLabelField->Append(wxString((*it).c_str())); if(!m_locationSetController->GetColourField().empty()) m_cboLabelField->SetValue(m_locationSetController->GetLabelField().c_str()); else { if(!m_cboLabelField->IsEmpty()) m_cboLabelField->SetValue(m_cboLabelField->GetString(0)); } if(!m_locationSetController->ModifiedLabelSize()) m_spinFontSize->SetValue(m_locationSetController->GetLabelSize()); else m_spinFontSize->SetValue(-1); if(!m_locationSetController->ModifiedLabelColour()) { Colour colour = m_locationSetController->GetLabelColour(); m_colourLabel->SetColour(wxColour(colour.GetRedInt(), colour.GetGreenInt(), colour.GetBlueInt())); ReplaceColourPicker( m_colourLabel, colour ); } else { Colour colour(0,0,0); m_colourLabel->SetColour(wxColour(0,0,0,0)); ReplaceColourPicker( m_colourLabel, colour ); } if(!m_locationSetController->ModifiedLabelPosition()) { m_cboLabelPosition->SetValue(wxString(m_locationSetController->GetLabelPosition().c_str())); } else { m_cboLabelPosition->Append(_T("<individually set>")); m_cboLabelPosition->SetValue(_T("<individually set>")); } if(!m_locationSetController->ModifiedLabelStyle()) { m_cboLabelStyle->SetValue(wxString(m_locationSetController->GetLabelStyle().c_str())); } else { m_cboLabelStyle->Append(_T("<individually set>")); m_cboLabelStyle->SetValue(_T("<individually set>")); } if(!m_locationSetController->ModifiedLabelVisibility()) { m_chkShowLabels->SetValue(m_locationSetController->GetLabelVisibility()); } else { m_chkShowLabels->Set3StateValue(wxCHK_UNDETERMINED); } m_chkBindToCharts->SetValue(m_locationSetController->GetLabelBindToChart()); wxCommandEvent dummy; OnShowLabels(dummy); }
void DrawableText::ValueTreeWrapper::setColour (const Colour& newColour, UndoManager* undoManager) { state.setProperty (colour, newColour.toString(), undoManager); }
void LocationSetPropertiesDlg::InitChart() { wxBusyCursor wait; ChartViewPtr chartView = m_locationSetLayer->GetLocationLayer(0)->GetLocationController()->GetChartView(); // populate field combo box with all possible fields if(App::Inst().GetLayerTreeController()->GetNumSequenceLayers() > 0) { // populate combo box with all fields associated with a sequence std::map<std::wstring,std::wstring> data = m_locationSetController->GetSequenceMetadata(); std::map<std::wstring,std::wstring>::iterator it; for(it = data.begin(); it != data.end(); ++it) { if(StringTools::ToLower((*it).first.c_str()) != _T("site id") && StringTools::ToLower((*it).first.c_str()) != _T("sequence id")) { m_cboChartField->Append(wxString((*it).first.c_str())); } } foreach(const std::wstring& field, App::Inst().GetLayerTreeController()->GetSequenceLayer(0)->GetSequenceController()->GetNumericMetadataFields()) m_cboQuantitativeField->Append(wxString(field.c_str())); if(!chartView->GetField().empty()) m_cboChartField->SetValue(wxString(chartView->GetField().c_str())); else { if(!m_cboChartField->IsEmpty()) m_cboChartField->SetValue(m_cboChartField->GetString(0)); } if(!chartView->GetQuantitativeField().empty()) m_cboQuantitativeField->SetValue(wxString(chartView->GetQuantitativeField().c_str())); else { if(!m_cboQuantitativeField->IsEmpty()) m_cboQuantitativeField->SetValue(m_cboQuantitativeField->GetString(0)); } // Populate colour map combo box with all available colour maps m_chartColourMapWidget->SetColourMap(chartView->GetColourMap()); m_chartColourMapWidget->PopulateColourMapComboBox(); // Set all controls if(chartView->GetChartType() == ChartView::PIE_CHART_2D) { m_chkChart2D->SetValue(true); m_cboChartType->SetValue(wxT("Pie Chart")); } else if(chartView->GetChartType() == ChartView::PIE_CHART_3D) { m_chkChart2D->SetValue(false); m_cboChartType->SetValue(wxT("Pie Chart")); } else if(chartView->GetChartType() == ChartView::BAR_CHART_2D) { m_chkChart2D->SetValue(true); m_cboChartType->SetValue(wxT("Bar Chart")); } else if(chartView->GetChartType() == ChartView::BAR_CHART_3D) { m_chkChart2D->SetValue(false); m_cboChartType->SetValue(wxT("Bar Chart")); } m_spinChartWidth->SetValue((int)chartView->GetWidth()); m_spinChartHeight->SetValue((int)chartView->GetHeight()); m_spinChartBorderSize->SetValue((int)chartView->GetBorderSize()); m_chkShowElementBorders->SetValue(chartView->GetWedgeBorders()); m_chkBottomBorder->SetValue(chartView->IsBottomBorder()); m_chkLeftBorder->SetValue(chartView->IsLeftBorder()); m_chkTopBorder->SetValue(chartView->IsTopBorder()); m_chkRightBorder->SetValue(chartView->IsRightBorder()); Colour bgColour = chartView->GetBackgroundColour(); m_colourChartBackground->SetColour(wxColour(bgColour.GetRedInt(), bgColour.GetGreenInt(), bgColour.GetBlueInt())); ReplaceColourPicker( m_colourChartBackground, bgColour ); if(bgColour.GetAlphaInt() == 0) m_chkTransparentBackground->SetValue(true); else m_chkTransparentBackground->SetValue(false); Colour borderColour = chartView->GetBorderColour(); m_colourChartBorder->SetColour(wxColour(borderColour.GetRedInt(), borderColour.GetGreenInt(), borderColour.GetBlueInt())); ReplaceColourPicker( m_colourChartBorder, borderColour ); m_chkAssignLocationColour->SetValue(chartView->IsAssignBorderLocationColour()); m_chkShowCharts->SetValue(chartView->IsVisible()); m_chkChartSizeBySeqCount->SetValue(chartView->GetSizeProportionalToSeq()); m_txtChartMinSize->SetValue(wxString(StringTools::ToStringW(chartView->GetMinSize()).c_str())); m_txtChartMaxSize->SetValue(wxString(StringTools::ToStringW(chartView->GetMaxSize()).c_str())); m_spinChartFilterTaxaPercentage->SetValue((int)chartView->GetAssignToOther()); m_spinChartDropLineThickness->SetValue(chartView->GetDropLines()->GetThickness()); Colour colour = chartView->GetDropLines()->GetColour(); m_colourChartDropLine->SetColour(wxColour(colour.GetRedInt(), colour.GetGreenInt(), colour.GetBlueInt(), colour.GetAlphaInt())); ReplaceColourPicker( m_colourChartDropLine, colour ); if(chartView->GetDropLines()->GetStyle() == VisualLine::SOLID) m_cboChartDropLineStyle->SetValue(_T("Solid")); else if(chartView->GetDropLines()->GetStyle() == VisualLine::SHORT_DASH) m_cboChartDropLineStyle->SetValue(_T("Short dash")); else if(chartView->GetDropLines()->GetStyle() == VisualLine::LONG_DASH) m_cboChartDropLineStyle->SetValue(_T("Long dash")); else if(chartView->GetDropLines()->GetStyle() == VisualLine::HIDDEN) m_cboChartDropLineStyle->SetValue(_T("Hidden")); m_chkQuantitative->SetValue(chartView->GetQuantitative()); // Set field values wxCommandEvent dummy; OnChartFieldChange(dummy); OnQuantitative(dummy); // enable all controls since there is sequence data m_cboChartField->Enable(); m_cboChartColourMap->Enable(); m_cboChartType->Enable(); m_spinChartWidth->Enable(); m_spinChartHeight->Enable(); m_spinChartBorderSize->Enable(); m_colourChartBorder->Enable(); m_chkAssignLocationColour->Enable(); m_chkShowElementBorders->Enable(); m_chkShowCharts->Enable(); m_cboChartDropLineStyle->Enable(); m_spinChartDropLineThickness->Enable(); #ifdef WIN32 m_colourChartDropLine->Enable(); #else EnableButton( m_colourChartDropLine, true ); #endif m_spinChartFilterTaxaPercentage->Enable(); m_chkChartSizeBySeqCount->Enable(); }
bool MultiDocumentPanel::addDocument (Component* const component, Colour docColour, const bool deleteWhenRemoved) { // If you try passing a full DocumentWindow or ResizableWindow in here, you'll end up // with a frame-within-a-frame! Just pass in the bare content component. jassert (dynamic_cast <ResizableWindow*> (component) == nullptr); if (component == nullptr || (maximumNumDocuments > 0 && components.size() >= maximumNumDocuments)) return false; components.add (component); component->getProperties().set ("mdiDocumentDelete_", deleteWhenRemoved); component->getProperties().set ("mdiDocumentBkg_", (int) docColour.getARGB()); component->addComponentListener (this); if (mode == FloatingWindows) { if (isFullscreenWhenOneDocument()) { if (components.size() == 1) { addAndMakeVisible (component); } else { if (components.size() == 2) addWindow (components.getFirst()); addWindow (component); } } else { addWindow (component); } } else { if (tabComponent == nullptr && components.size() > numDocsBeforeTabsUsed) { addAndMakeVisible (tabComponent = new TabbedComponentInternal()); Array <Component*> temp (components); for (int i = 0; i < temp.size(); ++i) tabComponent->addTab (temp[i]->getName(), docColour, temp[i], false); resized(); } else { if (tabComponent != nullptr) tabComponent->addTab (component->getName(), docColour, component, false); else addAndMakeVisible (component); } setActiveDocument (component); } resized(); activeDocumentChanged(); return true; }
void InterfaceButton::Render( int realX, int realY, bool highlighted, bool clicked ) { char *styleName = STYLE_BUTTON_BACKGROUND; if( highlighted ) styleName = STYLE_BUTTON_HIGHLIGHTED; if( clicked ) styleName = STYLE_BUTTON_CLICKED; Colour primaryCol = g_styleTable->GetPrimaryColour(styleName); Colour secondaryCol = g_styleTable->GetSecondaryColour(styleName); Colour borderPrimary = g_styleTable->GetPrimaryColour(STYLE_BUTTON_BORDER); Colour borderSeconary = g_styleTable->GetSecondaryColour(STYLE_BUTTON_BORDER); bool colourAlignment = g_styleTable->GetStyle(styleName)->m_horizontal; g_renderer->RectFill ( realX, realY, m_w, m_h, primaryCol, secondaryCol, colourAlignment ); g_renderer->Line ( realX, realY, realX+m_w, realY, borderPrimary ); g_renderer->Line ( realX, realY, realX, realY+m_h, borderPrimary ); g_renderer->Line ( realX, realY+m_h, realX+m_w, realY+m_h, borderSeconary ); g_renderer->Line ( realX+m_w, realY, realX+m_w, realY+m_h, borderSeconary ); // // Render the caption Style *buttonFont = g_styleTable->GetStyle(FONTSTYLE_BUTTON); AppAssert(buttonFont); if( stricmp( buttonFont->m_fontName, "default" ) == 0 ) { g_renderer->SetFont( NULL, false, buttonFont->m_negative ); } else { g_renderer->SetFont( buttonFont->m_fontName, false, buttonFont->m_negative ); } Colour fontColour = g_styleTable->GetPrimaryColour(FONTSTYLE_BUTTON); char caption[1024]; if( m_captionIsLanguagePhrase ) { snprintf( caption, sizeof(caption), LANGUAGEPHRASE(m_caption) ); } else { snprintf( caption, sizeof(caption), m_caption ); } caption[ sizeof(caption) - 1 ] = '\0'; if( buttonFont->m_uppercase ) strupr(caption); g_renderer->TextCentre( realX + m_w/2, realY + m_h/2 - buttonFont->m_size/2, fontColour, buttonFont->m_size, caption); g_renderer->SetFont(); // // Drop shadow InterfaceWindow::RenderWindowShadow( realX + m_w, realY, m_h, m_w, 4, g_renderer->m_alpha * 0.3f ); glColor4ubv( fontColour.GetData() ); }
inline Colour operator *(double s, const Colour& a) { return Colour(s*a.R(), s*a.G(), s*a.B()); }
bool MapTexture::BuildTerrainTexture(MapControllerPtr mapController, ProgressDlgPtr progressDlg) { if(!AllocateTextureMemory( mapController )) return false; MapModelPtr mapModel = mapController->GetMapModel(); // Check if default colour map has been loaded if(!m_colourMap) { ColourMapManagerPtr colourMapManager = App::Inst().GetColourMapManager(); ColourMapPtr defaultColourMap = colourMapManager->GetDefaultTerrainColourMap(); m_colourMap.reset(new ColourMapDiscrete(defaultColourMap)); } // If map is being deserialized, the following operations are not necessary if (m_numColours == 0) { // set colours float alpha = 1.0 - m_transparencyPercentage / 100.0; m_numColours = m_colourMap->GetSize(); m_colours.reset(new ColourPtr[m_numColours]); for(uint i = 0; i < m_numColours; ++i) { Colour colour = m_colourMap->GetColour(i); m_colours[i] = ColourPtr(new Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), alpha)); } // set intervals m_intervals.reset(new float[m_numColours]); m_intervals[2] = 0.01 * mapModel->GetMaxElevationGridSpace(); m_intervals[3] = 0.33 * mapModel->GetMaxElevationGridSpace(); m_intervals[4] = 0.66 * mapModel->GetMaxElevationGridSpace(); m_intervals[5] = mapModel->GetMaxElevationGridSpace(); if(mapModel->GetMinElevationGridSpace() < 0) { m_intervals[0] = mapModel->GetMinElevationGridSpace(); m_intervals[1] = 0.0f; m_intervals[2] = 0.0f; m_colours[1] = m_colours[0]; m_colourMap->SetColour(Colour(m_colours[1]->GetRed(), m_colours[1]->GetGreen(), m_colours[1]->GetBlue()), 1); } else if(mapModel->GetMinElevationGridSpace() == 0) { m_intervals[0] = 0.0f; m_intervals[1] = 0.0f; } else { m_intervals[0] = mapModel->GetMinElevationGridSpace(); m_intervals[1] = mapModel->GetMinElevationGridSpace(); } m_interpolate = LINEARLY; } if(progressDlg) { if(!progressDlg->Update(0, _T("Building terrain texture: computing elevation colours."))) return false; } // Compute the colour for each vertex in the terrain bool b = ComputeColour(mapModel->GetGrid(), progressDlg); if(b) setTexturingStates(); return b; }
void a4_render(// What to render SceneNode* root, // Where to output the image const std::string& filename, // Image size int width, int height, // Viewing parameters const Point3D& eye, const Vector3D& view, const Vector3D& up, double fov, // Lighting parameters const Colour& ambient, const std::list<Light*>& lights, double fogDist ) { // Fill in raytracing code here. std::cerr << "Stub: a4_render(" << root << ",\n " << filename << ", " << width << ", " << height << ",\n " << eye << ", " << view << ", " << up << ", " << fov << ",\n " << ambient << ",\n {"; for (std::list<Light*>::const_iterator I = lights.begin(); I != lights.end(); ++I) { if (I != lights.begin()) std::cerr << ", "; std::cerr << **I; } std::cerr << "});" << std::endl; Vector3D viewVector = view; Vector3D upVector = up; Vector3D sideVector = viewVector.cross(upVector); viewVector.normalize(); upVector.normalize(); sideVector.normalize(); Image img(width, height, 3); int progress = 0; int numPixels = width*height; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int newProgress = (int)((double)(y*width + x)/numPixels*100); if(newProgress >= progress+5){ progress = newProgress; std::cerr << progress << std::endl; } double d = height/2.0/tan(toRadian(fov)/2); Vector3D dir = (x-(width/2.0))*sideVector + ((height/2.0)-y)*upVector + d*viewVector; dir.normalize(); Ray ray = Ray(eye, dir); bool fogOn = true; if(fogDist <= 0) fogOn = false; Colour* color = rayTrace(ambient, eye, ray, root, lights, 5, fogDist); Colour fog(1,1,1); if(color == NULL) { // sunset colours Colour horizon(0.94, 0.55, 0.05); Colour zenith(0.2, 0.27, 0.4); Colour bg = zenith*(1-(double)y/height) + horizon*((double)y/height); if(fogOn) color = new Colour(0.8,0.8,0.8); else color = new Colour(bg); } img(x, y, 0) = color->R(); img(x, y, 1) = color->G(); img(x, y, 2) = color->B(); } } img.savePng(filename); }
void PointLight::shade( Ray3D& ray ) { // TODO: implement this function to fill in values for ray.col // using phong shading. Make sure your vectors are normalized, and // clamp colour values to 1.0. // // It is assumed at this point that the intersection information in ray // is available. So be sure that traverseScene() is called on the ray // before this function. Colour KA = (*ray.intersection.mat).ambient; Colour KD = (*ray.intersection.mat).diffuse; Colour KS = (*ray.intersection.mat).specular; double alpha = (*ray.intersection.mat).specular_exp; Colour IA = _col_ambient; Colour ID = _col_diffuse; Colour IS = _col_specular; // std::cout << ray.intersection.untransformedPoint double x = 0; double y = 0; x = ray.intersection.untransformedPoint[0]+1; y = ray.intersection.untransformedPoint[1]+1; x*=1000; y*=1000; // std::cout << x << "," << y << std::endl; if ((int)x/20 % 2 == (int)y/20 % 2) { KA = (*ray.intersection.mat).ambient2; KD = (*ray.intersection.mat).diffuse2; KS = (*ray.intersection.mat).specular2; } if (ray.inShadow) { Colour shade = KA*IA; shade.clamp(); ray.col = shade; return; } Vector3D N = (ray.intersection.normal); N.normalize(); Vector3D L = (_pos - ray.intersection.point); L.normalize(); Vector3D V = (-ray.dir); V.normalize(); Vector3D R = ((2 * (L.dot(N)) * N) - L); R.normalize(); double max1 = fmax(0.0, N.dot(L)); double vr_alpha = pow(V.dot(R), alpha); double max2 = fmax(0.0, vr_alpha); Colour shade = KA * IA + KD * (max1 * ID) + KS * (max2 * IS); shade.clamp(); ray.col = shade; }