OutdoorEnv::OutdoorEnv(World* world) : Entity(kOutdoorEnv) { m_world = world; m_haveSky = false; m_nishitaSky = false; m_haveOcean = false; m_haveGlobalLight = true; m_dateTimeInited = false; createSkyBox(); createSkyDome(); setSkyBoxTexture("textures/skys/day/box"); createOceanMesh(); m_globalLight = new Light(Light::kGlobal, Vector3(1,-1,1), Rgb::White); m_globalLight->setWorld(m_world); // global fog m_globalFog = new Fog(); m_globalFog->setFogDensity(0.0004f); m_globalFog->setFogColor(Rgba(119,171,201).toVector()); m_globalFog->setWorld(m_world); // ocean fog m_oceanFog = new Fog(); m_oceanFog->setFogDensity(0.04f); m_oceanFog->setFogColor(Rgba(119,201,171).toVector() * 0.25f); m_oceanFog->setWorld(m_world); TypeZero(&m_lastNishitaParams); }
inline Rgba operator *( const Z& val ) const { return Rgba( T( ( Z )( *this )( 0 ) * val ), T( ( Z )( *this )( 1 ) * val ), T( ( Z )( *this )( 2 ) * val ), T( ( Z )( *this )( 3 ) * val ) ); }
inline Rgba operator /( const Z& val ) const { return Rgba( T( ( Z )( *this )( 0 ) / val ), T( ( Z )( *this )( 1 ) / val ), T( ( Z )( *this )( 2 ) / val ), T( ( Z )( *this )( 3 ) / val ) ); }
static void copyLine(Rgba* dst, const unsigned char* src, const ColorMapObject* cmap, int transparent, int width) { for (; width > 0; width--, src++, dst++) { if (*src != transparent) { const GifColorType& col = cmap->Colors[*src]; *dst = Rgba(0xFF, col.Red, col.Green, col.Blue); } } }
///------------------------------------------------------------------ /// Retrieves an Rgba property from the specified Node ///------------------------------------------------------------------ Rgba GetRgbaProperty( const XMLNode& node, const std::string& propertyName, const Rgba& defaultValue ) { std::string propertyString = GetPropertyValueAsString( node, propertyName ); Rgba propertyValue = defaultValue ; if ( propertyString.length() ) propertyValue = Rgba( propertyString ); return propertyValue; }
const Rgba Interpolate(const Rgba& start, const Rgba& end, float fractionFromStartToEnd) { float lerpedR = Interpolate(start.fR(), end.fR(), fractionFromStartToEnd); float lerpedG = Interpolate(start.fG(), end.fG(), fractionFromStartToEnd); float lerpedB = Interpolate(start.fB(), end.fB(), fractionFromStartToEnd); float lerpedA = Interpolate(start.fA(), end.fA(), fractionFromStartToEnd); unsigned char lerpedCR = Rgba::cR(lerpedR); unsigned char lerpedCG = Rgba::cG(lerpedG); unsigned char lerpedCB = Rgba::cB(lerpedB); unsigned char lerpedCA = Rgba::cA(lerpedA); return Rgba(lerpedCR, lerpedCG, lerpedCB, lerpedCA); }
void InputBox::Draw() const { Text t(0.05, 0.05); { std::string input_text = GetText(); input_text.resize(m_max_text_length, '_'); t.DrawText(input_text, GetPosition() + Position(0, .1)); } for (char ch = 'a'; ch <= 'z'; ++ch) { Position pos = LetterPosition(ch); if (ch == m_highlighted_char) { // Little hack here, since it's hard to print a char centered in a box Engine::Get().GetRenderer()->DrawQuadSized( pos - Size(0.005, 0.005), Size(m_letterbox_size, m_letterbox_size) * .9, Rgba(1,0,0)); } t.DrawLetter(ch, pos); } }
///--------------------------------------------------------------------------------- /// ///--------------------------------------------------------------------------------- bool DeveloperConsoleArguments::GetColorFromHex( Rgba& color ) { std::string string = ""; if (PeekString( string )) { if (IsHexInt( string )) { unsigned int colorVal = strtoul( string.c_str(), nullptr, 0 ); color = Rgba( colorVal ); m_currentIndex++; return true; } else return false; } return false; }
// Retrurns the color value of the specified pixel as an Rgba color // // Make sure that you don't try to read out of the bounds of the bitmap // inline Rgba GetPixel( int x, int y ) const { float pixels[3]; glReadPixels( x, y, 1, 1, textureInfo.format, GL_FLOAT, pixels ); return Rgba( pixels[0], pixels[1], pixels[2] ); }
// Returns a color which has the same color componenets as this one // // except a differet alpha value // inline Rgba WithAlpha( float newAlpha ) const { return Rgba( r, g, b, newAlpha ); }
//--------------------------------------------------------------------------- inline Rgba Rgba::operator=( const Rgba& rightHandSide ) { return Rgba( r = rightHandSide.r, g = rightHandSide.g, b = rightHandSide.b, a = rightHandSide.a ); }
void SpotLightParameterEstimationClass::CalculatePixelValue() { _inputSetter = GetSpotLightExponentInputParameters(); UtilityClass* util = new UtilityClass(); Rgba* outputPixels = util->GetImagePixelsToWrite(_imageWidth, _imageHeight); std::ofstream outputPixelValue; outputPixelValue.open("../../Output/outputPixel-blend1.txt"); std::ofstream outputOriginalPixelValue; outputOriginalPixelValue.open("../../Output/originalPixel-blend1.txt"); for(int row = 0; row < _imageHeight; ++row) { for (int col = 0; col < _imageWidth; ++col) { Rgba p = (_imageSystem->GetCurrentImage().GetImage2DArrayPixels())[row][col]; double averagePixelIntensityValue = (p.r + p.g + p.b)/3; outputOriginalPixelValue << row << "," << col << " = " << averagePixelIntensityValue << std::endl; } } std::vector<MapOFImageAndWorldPoints>reprojectedPoints = _inputSetter->reprojectedPoints; double cosOfInner_minus_OuterConeAngle = _inputSetter->cosOfInnerConeAngle - _inputSetter->cosOfOuterConeAngle; if(cosOfInner_minus_OuterConeAngle == 0) cosOfInner_minus_OuterConeAngle = EPSILON; double gamma = 1.0/_inputSetter->gammaCorrection; // Reprojected 3D points std::vector<Point2D<int>> spotLightCoreExponentVectorPosition; double r = _inputSetter->vnormal.dot(Eigen::Vector3d(-4,-4,2) - _inputSetter->lightPosition); for (int index = 0; index < reprojectedPoints.size(); ++index) { Eigen::Vector3d lightToPointDirectionVector = reprojectedPoints[index]._worldPoint - _inputSetter->lightPosition; double distance = std::sqrt(lightToPointDirectionVector.dot(lightToPointDirectionVector)); lightToPointDirectionVector.normalize(); float lambertTerm = (-lightToPointDirectionVector).dot(_inputSetter->vnormal); // No light gets reflected from the surface at the particular point // Use it for attentuation factor double cosOfCurrAngle = _inputSetter->lightDirection.dot(lightToPointDirectionVector); double IntensityFactorExponent = std::pow((double)((cosOfCurrAngle - _inputSetter->cosOfOuterConeAngle) / (cosOfInner_minus_OuterConeAngle)), 4); Rgba pixelValue; // if(cosOfCurrAngle >= input->cosOfInnerConeAngle) // { // double v = lambertTerm * input->lightIntensity * input->materialAlbedo * attenuation; // pixelValue = Rgba(pow(v,gamma),pow(v,gamma),pow(v,gamma),1.0); // // } if (cosOfCurrAngle > _inputSetter->cosOfOuterConeAngle) { //double attenuation = 1.0 / (1.0 + (2/r)* distance + (1/(r*r)) * pow(distance, 2)); double attenuation = 1.0 / (r*r)*(distance*distance); if (lambertTerm > 0) { double v = (lambertTerm * _inputSetter->lightIntensity * _inputSetter->materialAlbedo * IntensityFactorExponent * attenuation); pixelValue = Rgba(pow(v,gamma),pow(v,gamma),pow(v,gamma),1.0); } } else pixelValue = Rgba(0,0,0,1); int i = reprojectedPoints[index]._imagepixel.y * _inputSetter->imageWidth + reprojectedPoints[index]._imagepixel.x; outputPixelValue << reprojectedPoints[index]._imagepixel.y << "," << reprojectedPoints[index]._imagepixel.x << " = " << pixelValue.r << std::endl; outputPixels[i] = pixelValue; } WriteToImage(outputPixels, "imagepixel-blend1.exr"); outputPixelValue.close(); outputOriginalPixelValue.close(); delete [] outputPixels; }
Rgba GetRandomColor() { return Rgba(GetRandomByte(), GetRandomByte(), GetRandomByte()); }
int Interface_Trichromie(int xchroma, int ychroma, int rayon, int largeurchroma) { //background window Rect TrichroBackground(Vec2D (xchroma-158, ychroma-206 ), Vec2D ( 315,550)); TrichroBackground.SetRoundness(15); TrichroBackground.SetLineWidth(triple_epaisseur_ligne_fader); TrichroBackground.Draw(CouleurFond); if(window_focus_id==902) { TrichroBackground.DrawOutline(CouleurFader); } else { TrichroBackground.DrawOutline(CouleurLigne); } ///////////////////////////////roue de couleur/////////////////////////////////////////// /////////AFFICHEE EN OPENGL CAR PLUS RAPIDE QUE BLIT ECT//////////////////////////////// for (hcl=0; hcl<360; hcl+=0.1) { xcl = cos(hcl*PI/180.0)*(rayon+16); ycl = sin(hcl*PI/180.0)*(rayon+16); hsv_to_rgb(hcl, 1.0, 1.0, &rcl, &gcl, &bcl); Line(Vec2D(xchroma,ychroma),Vec2D(xchroma+xcl,ychroma+ycl)).Draw(Rgba(rcl,gcl,bcl)); } Circle MasqueNoir(Vec2D(xchroma,ychroma),rayon-16); MasqueNoir.Draw(CouleurFond); V3D_f v1 = { xchroma+vxd, ychroma+vyd, 0, 0., 0., makecol(0, 0, 0) // black vertex }; V3D_f v2 = { xchroma+vxw, ychroma+vyw, 0, 0., 0., makecol(255, 255, 255) // white vertex }; V3D_f v3 = { xchroma+vxh, ychroma+vyh, 0, 0., 0., makecol(r_pick, v_pick, b_pick) // color vertex }; triangle3d_f(screen, POLYTYPE_GCOL, NULL, &v1, &v2, &v3); // //AFFECTATION MIDI if(Midi_Faders_Affectation_Type!=0 && window_focus_id==W_TRICHROMY)//config midi { if(mouse_x>xchroma-140 && mouse_x<xchroma+140 && mouse_y>ychroma-140 && mouse_y<ychroma+140) { Circle Color( Vec2D(xchroma-1,ychroma), 140 ); Color.SetLineWidth(epaisseur_ligne_fader); Color.DrawOutline(CouleurBlind); } } //affichage du pointeur de hue Circle monCurseurHue( Vec2D(position_curseur_hue_x, position_curseur_hue_y), 12 ); monCurseurHue.SetLineWidth(epaisseur_ligne_fader); monCurseurHue.DrawOutline( CouleurLigne ); Circle monCurseurTriangle( Vec2D(xchroma+picker_x,ychroma+picker_y), 6 ); monCurseurTriangle.SetLineWidth(epaisseur_ligne_fader); monCurseurTriangle.DrawOutline( CouleurLigne ); /////////////////TRICHRO / QUADRI CHOOSE////////////////////////////////////// Rect ChooseTriQuadri( Vec2D(xchroma-60,(ychroma-190)),Vec2D(130,30)); ChooseTriQuadri.SetRoundness(15); ChooseTriQuadri.SetLineWidth(epaisseur_ligne_fader); if(window_focus_id==W_TRICHROMY && mouse_x>xchroma-60 && mouse_x<xchroma+80 && mouse_y>ychroma-190 && mouse_y<ychroma-160) { ChooseTriQuadri.Draw(CouleurSurvol); } ChooseTriQuadri.DrawOutline(CouleurLigne); if(index_quadri==0){petitchiffre.Print("TRICHROMY",xchroma-30, ychroma-172);} else if(index_quadri==1){petitchiffre.Print("QUADRICHROMY",xchroma-45, ychroma-172);} /////////////////////AFFECTATION ON / OFF AUX DOCKS FADERS/////////////////////////// Rect AffectTriTo( Vec2D(xchroma+20,(ychroma+300)),Vec2D(130,30)); AffectTriTo.SetRoundness(15); AffectTriTo.SetLineWidth(epaisseur_ligne_fader); if (index_affect_color_to_dock==1){AffectTriTo.Draw(CouleurFader);} AffectTriTo.DrawOutline(CouleurLigne); petitchiffre.Print("AFFECT TO DOCK",xchroma+35, ychroma+319); //PASTE ON THE FLY MODE Rect PasteTriTo( Vec2D(xchroma-150,(ychroma+300)),Vec2D(130,30)); PasteTriTo.SetRoundness(15); PasteTriTo.SetLineWidth(epaisseur_ligne_fader); if (index_paste_on_the_fly==1){PasteTriTo.Draw(CouleurBlind);} PasteTriTo.DrawOutline(CouleurLigne); petitpetitchiffre.Print("PASTE ON THE FLY",xchroma-135, ychroma+319); /////////////////////DOCKING DES COULEURS//////////////////////////////////////// //emplacement des box pour actions de storage RVB sur 6 presets Rect RedBox(Vec2D(xchroma-130,ychroma+165),Vec2D(50,20)); RedBox.SetRoundness(10); RedBox.SetLineWidth(epaisseur_ligne_fader); RedBox.Draw(Rgba::RED); RedBox.DrawOutline(CouleurLigne); Rect GreenBox(Vec2D(xchroma-65,ychroma+165),Vec2D(50,20)); GreenBox.SetRoundness(10); GreenBox.SetLineWidth(epaisseur_ligne_fader); GreenBox.Draw(Rgba::GREEN.WithAlpha(0.7)); GreenBox.DrawOutline(CouleurLigne); Rect BlueBox(Vec2D(xchroma,ychroma+165),Vec2D(50,20)); BlueBox.SetRoundness(10); BlueBox.SetLineWidth(epaisseur_ligne_fader); BlueBox.Draw(Rgba::BLUE); BlueBox.DrawOutline(CouleurLigne); Rect YellowBox(Vec2D(xchroma+65,ychroma+165),Vec2D(50,20)); YellowBox.SetRoundness(10); YellowBox.SetLineWidth(epaisseur_ligne_fader); if (index_quadri==1){YellowBox.Draw(Rgba::YELLOW);} YellowBox.DrawOutline(CouleurLigne); petitchiffre.Print(ol::ToString(my_red),xchroma-115, ychroma+179); petitchiffre.Print(ol::ToString(my_green),xchroma-55, ychroma+179); petitchiffre.Print(ol::ToString(my_blue ),xchroma+10, ychroma+179); petitchiffrerouge.Print(ol::ToString(my_yellow ),xchroma+75, ychroma+179); //midi out de la roue Circle BMidiOut( xchroma+140,ychroma+110, 10);//box du fader BMidiOut.SetLineWidth(epaisseur_ligne_fader); if(midi_send_out[497]==1) { BMidiOut.Draw(CouleurBlind); } BMidiOut.DrawOutline(CouleurLigne); raccrochage_midi_visuel_circulaire (xchroma, ychroma, 497, rayon, rayon); //liaison visuelle au fader du cercle midi out Line (Vec2D( xchroma+97,ychroma+100),Vec2D(xchroma+125,ychroma+100)).Draw(CouleurLigne); Line (Vec2D(xchroma+125,ychroma+100),Vec2D(xchroma+125+8,ychroma+106)).Draw(CouleurLigne); petitchiffre.Print("COLOR PRESETS",xchroma-65, ychroma+205); //premiere rangee de dock colors char string_allocation_col[7]; for (int dock_color=0;dock_color<4;dock_color++) { Rect DockBoxColor(Vec2D(xchroma-130+(65*dock_color),ychroma+215),Vec2D(50,20)); DockBoxColor.SetRoundness(10); DockBoxColor.SetLineWidth(epaisseur_ligne_fader); if(dock_color==dock_color_selected){DockBoxColor.Draw(CouleurFader); } sprintf(string_allocation_col,"%d / %d",(colorpreset_linked_to_dock[dock_color][0]+1),(colorpreset_linked_to_dock[dock_color][1]+1)); ////////////////////////////////////////////////////////////////////////////////// petitchiffre.Print(string_allocation_col,xchroma-120+(65*dock_color),ychroma+230); DockBoxColor.DrawOutline(CouleurLigne); if(window_focus_id==W_TRICHROMY && mouse_x>xchroma-130+(65*dock_color) && mouse_x<xchroma-80+(65*dock_color) && mouse_y>ychroma+215 && mouse_y<ychroma+235) { petitchiffre.Print(string_allocation_col,xchroma-120+(65*dock_color),ychroma+230); if( Midi_Faders_Affectation_Type!=0) {DockBoxColor.DrawOutline(CouleurBlind); } } } //deuxième rangee de dockcolors for (int dock_colortwo=0;dock_colortwo<4;dock_colortwo++) { Rect DockBoxColor2(Vec2D(xchroma-130+(65*dock_colortwo),ychroma+255),Vec2D(50,20)); DockBoxColor2.SetRoundness(10); DockBoxColor2.SetLineWidth(epaisseur_ligne_fader); if((dock_colortwo+4)==dock_color_selected){DockBoxColor2.Draw(CouleurFader); } sprintf(string_allocation_col,"%d / %d",(colorpreset_linked_to_dock[dock_colortwo+4][0]+1),(colorpreset_linked_to_dock[dock_colortwo+4][1]+1)); petitchiffre.Print(string_allocation_col,xchroma-120+(65*dock_colortwo),ychroma+270); DockBoxColor2.DrawOutline(CouleurLigne); if(window_focus_id==W_TRICHROMY && mouse_x>xchroma-130+(65*dock_colortwo) && mouse_x<xchroma-80+(65*dock_colortwo) && mouse_y>ychroma+255 && mouse_y<ychroma+275) { petitchiffre.Print(string_allocation_col,xchroma-120+(65*dock_colortwo),ychroma+270); if(Midi_Faders_Affectation_Type!=0) {DockBoxColor2.DrawOutline(CouleurBlind); } } } return(0); }
/* From observation this gives the pixels at the fall off region */ void SpotLightFallOFFIntensityCalculator::GetFallOffRegionForNoAmbientLightBackground(const int& maxNumberOfRadiusSegment) { std::vector<double>diffInIntensity = std::vector<double>(360,0); for (int index = 0; index < 360; ++index) { for (int block = 0; block < (maxNumberOfRadiusSegment-1); ++block) { if ((Sector[index][block].size() == 0) || (Sector[index][block+1].size() == 0)){ continue; } int numberOfZeroIntensityVectorBlock1 = (int)std::count_if(SectorIntensity[index][block].begin(), SectorIntensity[index][block].end(), value_equal(Rgba(0, 0, 0))); double ratio1 = (double)numberOfZeroIntensityVectorBlock1 / (double)Sector[index][block].size(); if (ratio1 > 0) { int numberOfZeroIntensityVectorBlock2 = (int)std::count_if(SectorIntensity[index][block+1].begin(), SectorIntensity[index][block+1].end(), value_equal(Rgba(0, 0, 0))); double ratio2 = (double)numberOfZeroIntensityVectorBlock2 / (double)Sector[index][block+1].size(); if (ratio2 > 0) { std::cout << "Edge pixel = " << Sector[index][block][4].y << "," <<Sector[index][block][4].x << std::endl; break; } } } } }