コード例 #1
0
ファイル: rc2ui.cpp プロジェクト: kthxbyte/QT2-Linaro
void RC2UI::writeBool( const QString& name, bool value )
{
    wi(); *out << "<property>" << endl; indent();
    wi(); *out << "<name>" << name << "</name>" << endl;
    wi(); *out << "<bool>" << (value ? "true" : "false") << "</bool>" << endl; undent();
    wi(); *out << "</property>" << endl;
}
コード例 #2
0
ファイル: rc2ui.cpp プロジェクト: kthxbyte/QT2-Linaro
void RC2UI::writeString( const QString& name, const QString& value )
{
    wi(); *out << "<property>" << endl; indent();
    wi(); *out << "<name>" << name << "</name>" << endl;
    wi(); *out << "<string>" << value << "</string>" << endl; undent();
    wi(); *out << "</property>" << endl;
}
コード例 #3
0
ファイル: rc2ui.cpp プロジェクト: kthxbyte/QT2-Linaro
void RC2UI::writeNumber( const QString& name, int value )
{
    wi(); *out << "<property>" << endl; indent();
    wi(); *out << "<name>" << name << "</name>" << endl;
    wi(); *out << "<number>" << value << "</number>" << endl; undent();
    wi(); *out << "</property>" << endl;
}
コード例 #4
0
ファイル: AudioData.cpp プロジェクト: Ar-es/raspivoice
void AudioData::wl(FILE* fp, uint32_t l)
{
	unsigned int i1, i0;
	i0 = l % 65536L;
	i1 = (l - i0) / 65536L;
	wi(fp, i0);
	wi(fp, i1);
}
コード例 #5
0
ファイル: rc2ui.cpp プロジェクト: kthxbyte/QT2-Linaro
void RC2UI::writeRect( const QString& name, int x, int y, int w, int h )
{
    wi(); *out << "<property>" << endl; indent();
    wi(); *out << "<name>" << name << "</name>" << endl;
    wi(); *out << "<rect>" << endl; indent();
    wi(); *out << "<x>" << int(double(x)*1.5) << "</x>" << endl;
    wi(); *out << "<y>" << int(double(y)*1.65) << "</y>" << endl;
    wi(); *out << "<width>" << int(double(w)*1.5) << "</width>" << endl;
    wi(); *out << "<height>" << int(double(h)*1.65) << "</height>" << endl; undent();
    wi(); *out << "</rect>" << endl; undent();
    wi(); *out << "</property>" << endl;
}
コード例 #6
0
ファイル: Tools.cpp プロジェクト: vuhonganh/projet3D
float Lambert (Vec3f source, Vec3f position, Vec3f normal)
{
    Vec3f wi(source - position);

    wi /= wi.length();
    return dot(normal, wi);
}
コード例 #7
0
ファイル: main.cpp プロジェクト: Mistobaan/MuseScore
int main(int argc, char* argv[])
      {
      QApplication app(argc, argv);

      QWidget wi(0);
      PDPI = wi.logicalDpiX();    // physical resolution
      DPI  = PDPI;                // logical drawing resolution
      DPMM = DPI / INCH;          // dots/mm

      runtime = new Runtime;

      MScore::init();
      seq = new Seq;
      if (!seq->init()) {
            printf("cannot initialize sequencer\n");
            exit(-1);
            }

      qmlRegisterType<ScoreView>("MuseScore", 1, 0, "ScoreView");

      QDeclarativeView view;
      view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
      QDeclarativeContext* ctxt = view.rootContext();
      ctxt->setContextProperty(QLatin1String("runtime"), runtime);

      // registering only for exposing the Runtime::Orientation enum
      qmlRegisterUncreatableType<Runtime>("Qt", 4, 7, "Orientation", QString());
      qmlRegisterUncreatableType<Runtime>("QtQuick", 1, 0, "Orientation", QString());

      view.setSource(QUrl("qrc:/mplayer.qml"));
      view.show();
      return app.exec();
      }
コード例 #8
0
	inline Float sample(PhaseFunctionSamplingRecord &pRec, Sampler *sampler) const {
		Float Sxx, Sxy, Sxz, Syy, Syz, Szz;
	/*	vec3 omega3(pRec.mRec.orientation.x, pRec.mRec.orientation.y, pRec.mRec.orientation.z);
		omega3 = normalize(omega3);
		Sxx = sigma3*sigma3*omega3.x*omega3.x + omega3.y*omega3.y + omega3.z*omega3.z;
		Sxy = sigma3*sigma3*omega3.x*omega3.y - omega3.x*omega3.y;
		Sxz = sigma3*sigma3*omega3.x*omega3.z - omega3.x*omega3.z;
		Syy = sigma3*sigma3*omega3.y*omega3.y + omega3.x*omega3.x + omega3.z*omega3.z;
		Syz = sigma3*sigma3*omega3.y*omega3.z - omega3.y*omega3.z;
		Szz = sigma3*sigma3*omega3.z*omega3.z + omega3.x*omega3.x + omega3.y*omega3.y;*/
		Sxx = pRec.mRec.S[0]; Syy = pRec.mRec.S[1]; Szz = pRec.mRec.S[2];
		Sxy = pRec.mRec.S[3]; Sxz = pRec.mRec.S[4];	Syz = pRec.mRec.S[5];
		if (Sxx*Sxx + Syy*Syy + Szz*Szz + Sxy*Sxy + Sxz*Sxz + Syz*Syz < 1e-3)
			return 0.0;
		vec3 wi(pRec.wi.x, pRec.wi.y, pRec.wi.z);		

		#if defined(SGGX_STATISTICS)
			avgSampleIterations.incrementBase();
		#endif
		wi=normalize(wi);
		Point2 point = sampler->next2D();
		vec3 wo=sample_specular(wi, Sxx, Syy, Szz, Sxy, Sxz, Syz, point.x, point.y);
		wo = normalize(wo);
		pRec.wo = Vector(wo.x,wo.y,wo.z);
#if defined(SGGXDEBUGSAMPLE)
		float length = sqrtf(dot(wo, wo));
		if (fabs(length - 1.0) > 0.0001)
		{
			FILE *f = fopen("log_phase_sample.txt", "a+");
			fprintf(f, "wo %f %f %f\n", wo.x, wo.y, wo.z);
			fprintf(f, "%f\n",length );
			fclose(f);
		}
#endif
		/*int iterations = 0, maxIterations = 1000;
		while (true) {
			Vector H = m_fiberDistr.sample(sampler->next2D());
			#if defined(SGGX_STATISTICS)
				++avgSampleIterations;
			#endif
			++iterations;

			if (sampler->next1D() < absDot(wi, H)) {
				Vector wo = H*(2*dot(wi, H)) - wi;
				pRec.wo = frame.toWorld(wo);
				break;
			}

			if (iterations >= maxIterations) {
				Log(EWarn, "Sample generation unsuccessful after %i iterations"
					" (dp=%f, fiberOrientation=%s, wi=%s)", iterations,
					absDot(pRec.wi, pRec.mRec.orientation),
					pRec.mRec.orientation.toString().c_str(),
					pRec.wi.toString().c_str());
				return 0.0f;
			}
		}*/

		return 1.0f;
	}
コード例 #9
0
ファイル: schur.cpp プロジェクト: c304728539/itpp-fastica
bool schur(const mat &A, mat &U, mat &T)
{
  it_assert_debug(A.rows() == A.cols(), "schur(): Matrix is not square");

  char jobvs = 'V';
  char sort = 'N';
  int info;
  int n = A.rows();
  int lda = n;
  int ldvs = n;
  int lwork = 3 * n; // This may be choosen better!
  int sdim = 0;
  vec wr(n);
  vec wi(n);
  vec work(lwork);

  T.set_size(lda, n, false);
  U.set_size(ldvs, n, false);

  T = A; // The routine overwrites input matrix with eigenvectors

  dgees_(&jobvs, &sort, 0, &n, T._data(), &lda, &sdim, wr._data(), wi._data(),
         U._data(), &ldvs, work._data(), &lwork, 0, &info);

  return (info == 0);
}
コード例 #10
0
ファイル: WeatherMgr.cpp プロジェクト: Ballwinkle/Ascent_NG
void WeatherMgr::LoadFromDB()
{
	//sLog.outString("  Loading Weather..."); // weather type 0= sunny / 1= fog / 2 = light_rain / 4 = rain / 8 = snow / ?? = sandstorm
	QueryResult *result = WorldDatabase.Query( "SELECT zoneId,high_chance,high_type,med_chance,med_type,low_chance,low_type FROM weather" );

	if( !result )
		return;

	do
	{
		Field *fields = result->Fetch();
		WeatherInfo* wi(new WeatherInfo);
		wi->m_zoneId = fields[0].GetUInt32();
		wi->m_effectValues[0] = fields[1].GetUInt32();  // high_chance
		wi->m_effectValues[1] = fields[2].GetUInt32();  // high_type
		wi->m_effectValues[2] = fields[3].GetUInt32();  // med_chance
		wi->m_effectValues[3] = fields[4].GetUInt32();  // med_type
		wi->m_effectValues[4] = fields[5].GetUInt32();  // low_chance
		wi->m_effectValues[5] = fields[6].GetUInt32();  // low_type
		m_zoneWeathers[wi->m_zoneId] = wi;

		wi->_GenerateWeather();
	} while( result->NextRow() );
	Log.Notice("WeatherMgr", "Loaded weather information for %u zones.", result->GetRowCount());

	delete result;
}
コード例 #11
0
ファイル: RenderThread.cpp プロジェクト: oskusalerma/gfract
void* RenderThread::run()
{
    while (1)
    {
        std::auto_ptr<WorkItem> wi(img->wq.waitForItem());

        RowWorkItem* rwi = NULL;
        QuitWorkItem* qwi = NULL;

        if ((rwi = dynamic_cast<RowWorkItem*>(wi.get())))
        {
            doRow(rwi->row);
        }
        else if ((qwi = dynamic_cast<QuitWorkItem*>(wi.get())))
        {
            break;
        }
        else
        {
            gf_a(0);
        }
    }

    return NULL;
}
コード例 #12
0
glm::vec3 BlinnMicrofacetBxDF::EvaluateHemisphereScatteredEnergy(const glm::vec3 &wo, int num_samples, const glm::vec2 *samples) const
{
    //TODO
    glm::vec3 color( 0.f );

    for( int i = 0; i < num_samples; ++i ){

        float cos_theta( powf( samples[ i ].x, 1.f / ( exponent + 1.f ) ) );
        float sin_theta( sqrtf( fmaxf( 0.f, 1.f - cos_theta * cos_theta ) ) );

        float phi( samples[ i ].y * TWO_PI );
        float cos_phi( cosf( phi ) );
        float sin_phi( sinf( phi ) );

        glm::vec3 wh( sin_theta * cos_phi, sin_theta * sin_phi, cos_theta );

        float woDwh( glm::dot( wo, wh ) );

        if( woDwh < 0.f ) wh = -wh;

        glm::vec3 wi( -wo + 2.f * woDwh * wh );

        color += EvaluateScatteredEnergy( wo, wi );
    }

    return color / ( float )num_samples;
}
コード例 #13
0
	Float computeTransmittance(const char *name, Float eta, Float alpha, Float cosTheta) {
		Properties bsdfProps("roughdielectric");
		if (cosTheta < 0) {
			cosTheta = -cosTheta;
			eta = 1.0f / eta;
		}
		if (eta < 1) {
			bsdfProps.setFloat("intIOR", 1.0f);
			bsdfProps.setFloat("extIOR", 1.0f / eta);
		} else {
			bsdfProps.setFloat("extIOR", 1.0f);
			bsdfProps.setFloat("intIOR", eta);
		}
		bsdfProps.setFloat("alpha", alpha);
		bsdfProps.setString("distribution", name);

		ref<BSDF> bsdf = static_cast<BSDF *>(
				PluginManager::getInstance()->createObject(bsdfProps));

		NDIntegrator intTransmittance(1, 2, 50000, 0, 1e-6f);

		Vector wi(math::safe_sqrt(1-cosTheta*cosTheta), 0, cosTheta);
		Float transmittance, error;

		Float min[2] = {0, 0}, max[2] = {1, 1};
		intTransmittance.integrateVectorized(
			boost::bind(&transmittanceIntegrand, bsdf, wi, _1, _2, _3),
			min, max, &transmittance, &error, NULL);

		return transmittance;
	}
コード例 #14
0
ファイル: Ray.cpp プロジェクト: vuhonganh/projet3D
Ray Ray::getInConeRay(Vec3f intersection, Vec3f * triangle, int depth, pair <int, int> exceptionTriangle)
{
    Vec3f n = getNormalwithRayComes(triangle, this->direction);
    //find a unit vector in the plane
    Vec3f ex(triangle[0] - intersection);
    ex /= ex.length();

    //another unit vector in the plane to forme a local coordiante
    Vec3f ey = cross(n, ex);
    Vec3f wi(this->position - intersection);
    wi /= wi.length();

    float cosTheta_i = dot(wi, n);
    if(cosTheta_i < -EPS)
        cout << "ERROR in getInConeRaysOut: l'angle theta_i est plus grande que 90, something wrong with the direction" << endl;

    //find a eOnPlane vector unit (which lies on plane)
    float xComponent     = getRandomFloat(-1.0, 1.0);
    float yComponent     = getRandomFloat(-1.0, 1.0);
    Vec3f eOnPlane(xComponent * ex + yComponent * ey);
    eOnPlane /= eOnPlane.length();

    //to ensure the direction Out lies inside the cone
    //dirOut = costheta_i * normal + sintheta_i * eOnPlane
    Vec3f dirOut(cosTheta_i * n + sqrt(1 - cosTheta_i*cosTheta_i) * eOnPlane);
    dirOut /= dirOut.length();

    return Ray(intersection, dirOut, bshRoot, depth, exceptionTriangle);
}
コード例 #15
0
ファイル: adjust_functors.hpp プロジェクト: TheRyaz/c_reading
 //! Returns a negative duration_type
 duration_type get_neg_offset(const date_type& d) const 
 {
   ymd_type ymd(d.year_month_day());
   if (origDayOfMonth_ == 0) {
     origDayOfMonth_ = ymd.day;
     day_type endOfMonthDay(cal_type::end_of_month_day(ymd.year,ymd.month));
     if (endOfMonthDay == ymd.day) {
       origDayOfMonth_ = -1; //force the value to the end of month
     }
   }
   typedef date_time::wrapping_int2<short,1,12> wrap_int2;
   typedef typename wrap_int2::int_type int_type;
   wrap_int2 wi(ymd.month);
   //calc the year wrap around, add() returns 0 or 1 if wrapped
   int_type year = wi.subtract(static_cast<int_type>(f_)); 
   year = static_cast<int_type>(year + ymd.year); //calculate resulting year
   //find the last day for the new month
   day_type resultingEndOfMonthDay(cal_type::end_of_month_day(year, wi.as_int()));
   //original was the end of month -- force to last day of month
   if (origDayOfMonth_ == -1) {
     return date_type(year, wi.as_int(), resultingEndOfMonthDay) - d;
   }
   day_type dayOfMonth = origDayOfMonth_;
   if (dayOfMonth > resultingEndOfMonthDay) {
     dayOfMonth = resultingEndOfMonthDay;
   }
   return date_type(year, wi.as_int(), dayOfMonth) - d;
 }
コード例 #16
0
ファイル: main.cpp プロジェクト: furiousbean/figurez
int main(int argc, char** argv) {
    QApplication app(argc, argv);
    srand(time(0));
    GameParams gp;

    WindowInterface wi(gp);
    //WindowInterface wi2(wi);

    return app.exec();
}
コード例 #17
0
ファイル: InsetFormulaMacro.cpp プロジェクト: djmitche/lyx
int InsetFormulaMacro::plaintext(odocstream & os, OutputParams const & runparams) const
{
	odocstringstream oss;
	WriteStream wi(oss, false, true, WriteStream::wsDefault, runparams.encoding);
	tmpl()->write(wi);

	docstring const str = oss.str();
	os << str;
	return str.size();
}
コード例 #18
0
ファイル: perfect_glass.hpp プロジェクト: jaredhoberock/igloo
    inline sample sample_direction(std::uint64_t u0, std::uint64_t, const vector& wo) const
    {
      // try both bsdfs
      auto reflected = reflection_.reflect(wo);
      auto transmitted = transmission_.transmit(wo);

      // compute the importance of either sample
      float reflected_importance = luminance(reflected.throughput());
      float transmitted_importance = luminance(transmitted.throughput());

      // the probability of selecting the reflected direction is proportional to its importance
      float reflected_probability = reflected_importance / (reflected_importance + transmitted_importance);

      if(dist2d::u01f(u0) < reflected_probability)
      {
        return sample(reflected.wi(), reflected.throughput(), reflected_probability);
      }

      return sample(transmitted.wi(), transmitted.throughput(), 1.f - reflected_probability);
    }
コード例 #19
0
ファイル: but_camcast.cpp プロジェクト: Mazet/srs_public
/*
 *  Constructor
 */
CButCamCast::CButCamCast(const std::string & name,rviz::VisualizationManager * manager)
: Display( name, manager )
, m_bPublish(true)
{
  // Create and connect pane
  rviz::WindowManagerInterface * wi( manager->getWindowManager() );

  if( wi != 0 )
  {
    // Arm manipulation controls
    m_pane = new CControllPane( wi->getParentWindow(), wxT("Screencasts manager"), wi);

    if( m_pane != 0 )
    {
      wi->addPane( "Screencasts manager", m_pane );
      wi->showPane( m_pane );

      // Connect signal
      m_pane->getSigChckBox().connect( boost::bind( &CButCamCast::onPublishStateChanged, this, _1) );
      m_pane->getSigSave().connect( boost::bind( &CButCamCast::onSave, this, _1 ) );
    }

  }else{
    std::cerr << "No window manager, no panes :( " << std::endl;
  }


  // Get node handle
  ros::NodeHandle private_nh("/");

  // Set parameters

  // Get camera screencasting topic name
  private_nh.param("rviz_screencast_topic_name", m_camCastPublisherName, CAMERA_SCREENCAST_TOPIC_NAME);

  // Get timer period
  private_nh.param("publishig_period", m_timerPeriod, DEFAULT_PUBLISHING_PERIOD );

  // Get scene node
  m_sceneNode = scene_manager_->getRootSceneNode()->createChildSceneNode();

  // Create publisher
  this->m_camCastPublisher = private_nh.advertise< sensor_msgs::Image >(m_camCastPublisherName, 100, false);

  // Create geometry
  createGeometry(private_nh);

  // Create publishing timer
  m_timer = private_nh.createTimer( ros::Duration(m_timerPeriod), boost::bind( &CButCamCast::onTimerPublish, this, _1) );

  // Set publishing parameters
  m_textureWithRtt->setFrame("/map");

}
コード例 #20
0
ファイル: InsetFormulaMacro.cpp プロジェクト: djmitche/lyx
void InsetFormulaMacro::latex(otexstream & os,
			      OutputParams const & runparams) const
{
	//lyxerr << "InsetFormulaMacro::latex" << endl;
	WriteStream wi(os.os(), runparams.moving_arg, true,
		       runparams.dryrun ? WriteStream::wsDryrun: WriteStream::wsDefault,
		       runparams.encoding);
	wi.canBreakLine(os.canBreakLine());
	tmpl()->write(wi);
	os.canBreakLine(wi.canBreakLine());
	os.texrow().newlines(wi.line());
}
コード例 #21
0
ファイル: merl_sgd.cpp プロジェクト: davidlee80/dj_brdf
	Spectrum eval(const BSDFSamplingRecord &bRec, EMeasure measure) const {
		if (!(bRec.typeMask & EDiffuseReflection) || measure != ESolidAngle
			|| Frame::cosTheta(bRec.wi) <= 0
			|| Frame::cosTheta(bRec.wo) <= 0)
			return Spectrum(0.0f);

		djb::dir wi(djb::vec3(bRec.wi.x, bRec.wi.y, bRec.wi.z));
		djb::dir wo(djb::vec3(bRec.wo.x, bRec.wo.y, bRec.wo.z));
		djb::vec3 value = m_sgd->evalp(wo, wi);

		return Color3(value.x, value.y, value.z);
	}
コード例 #22
0
ファイル: rc2ui.cpp プロジェクト: kthxbyte/QT2-Linaro
void RC2UI::writeFont( const QString& family, int pointsize )
{
    wi(); *out << "<property>" << endl; indent();
    wi(); *out << "<name>font</name>" << endl;
    wi(); *out << "<font>" << endl; indent();
    wi(); *out << "<family>" << family << "</family>" << endl;
    wi(); *out << "<pointsize>" << pointsize << "</pointsize>" << endl; undent();
    wi(); *out << "</font>" << endl; undent();
    wi(); *out << "</property>" << endl;
}
コード例 #23
0
ファイル: Tools.cpp プロジェクト: vuhonganh/projet3D
float blinnPhong(Vec3f camPos, Vec3f source, Vec3f vertex, Vec3f * triangle, float s)
{
    Vec3f wi(source - vertex);
    Vec3f wo(camPos - vertex);
    Vec3f n = getNormalwithRayComes(triangle, -wo);
    wi.normalize();
    wo.normalize();
    n.normalize();

    Vec3f wh(wi + wo);
    wh.normalize();

    return pow(dot(n, wh),s);
}
コード例 #24
0
ファイル: AudioData.cpp プロジェクト: Ar-es/raspivoice
void AudioData::SaveToWavFile(std::string filename)
{
	FILE *fp;
	int bytes_per_sample = (use_stereo ? 4 : 2);

	// Write 8/16-bit mono/stereo .wav file
	fp = fopen(filename.c_str(), "wb");
	fprintf(fp, "RIFF");
	wl(fp, sample_count * bytes_per_sample + 36L);
	fprintf(fp, "WAVEfmt ");
	wl(fp, 16L);
	wi(fp, 1);
	wi(fp, use_stereo ? 2 : 1);
	wl(fp, 0L + sample_freq_Hz);
	wl(fp, 0L + sample_freq_Hz * bytes_per_sample);
	wi(fp, bytes_per_sample);
	wi(fp, 16);
	fprintf(fp, "data");
	wl(fp, sample_count * bytes_per_sample);

	fwrite(samplebuffer.data(), bytes_per_sample, sample_count, fp);
	fclose(fp);
}
コード例 #25
0
ファイル: utia_tab.cpp プロジェクト: davidlee80/dj_brdf
	Spectrum sample(BSDFSamplingRecord &bRec, const Point2 &sample) const {
		if (!(bRec.typeMask & EDiffuseReflection) || Frame::cosTheta(bRec.wi) <= 0)
			return Spectrum(0.0f);

		bRec.wo = warp::squareToCosineHemisphere(sample);
		bRec.eta = 1.0f;
		bRec.sampledComponent = 0;
		bRec.sampledType = EDiffuseReflection;

		djb::vec3 wi(bRec.wi.x, bRec.wi.y, bRec.wi.z);
		djb::vec3 wo(bRec.wo.x, bRec.wo.y, bRec.wo.z);
		djb::vec3 brdf = m_tabular_anisotropic->eval(djb::dir(wi),djb::dir(wo));

		return M_PI * Color3(brdf.x, brdf.y, brdf.z);
	}
コード例 #26
0
ファイル: level.cpp プロジェクト: christianboutin/Shmoulette
void WeaponChain::fromXml(XML& xml){
	mTimeBetweenShots = xml.getFloat("time_between_shots");
	XMLIterator it(&xml);
	it.setElemName("weaponchain>weapon");
	it.gotoZero();
	while(it.gotoNext()==true){
		WeaponInfo wi(&it.getElem());
		/*wd.DLL = it.getElem().getString("dll");
		wd.XML = it.getElem().getString("xml");
		wd.mount = it.getElem().getString("mount");
		mWeapon.push_back(wd);*/
		mWeapon.push_back(wi);

	}
}
コード例 #27
0
DirectionalLight loadDirectionalLight(
        const Scene& scene,
        const tinyxml2::XMLElement& elt) {
    auto pExitantPower = elt.FirstChildElement("ExitantPower");
    if(pExitantPower) {
        Vec3f wi(0, 1, 0);
        getChildAttribute(elt, "IncidentDirection", wi);
        Vec3f exitantPower = zero<Vec3f>();
        getChildAttribute(elt, "ExitantPower", exitantPower);

        return DirectionalLight(wi, exitantPower, scene);
    }

    return { normalize(loadVector(elt)), loadColor(elt) };
}
コード例 #28
0
Spectrum<constant::spectrumSamples> PathBRDF::randomBRDFSampling(bool& randomBRDFsampled,
                                                                 Spectrum<constant::spectrumSamples>& L,
                                                                 const Vector3D& wo,
                                                                 const MaterialBRDF& material,
                                                                 const Intersection& intersection,
                                                                 const TracerSpectrum& pathTracer,
                                                                 const int bounce,
                                                                 const BRDFType type) const {
    
    Vector3D wi(INFINITY, INFINITY, INFINITY);
    
    //Sample brdf of the give type.
    Spectrum<constant::spectrumSamples> f = material.samplef(&wi, wo, intersection, type);
    
    if(wi.x != INFINITY && wi.y != INFINITY && wi.z != INFINITY) {
        
        //BRDF has been sampled.
        randomBRDFsampled = true;
        
        //Normalize wi.
        wi.normalize();
        
        //Get pdf of wi sampled from brdf.
        float pdf = material.pdf(wi, wo, intersection, type);
        
        Spectrum<constant::spectrumSamples> weight(0.0f);
        
        //Check pdf to avoid 0/0 division (and NaN generation).
        //A spectrum composed of NaN values could bend all samples
        //during sum in Tracer classes.
        if(pdf > 0.0f) {
            
            weight = (f * fabsf(wi.dot(intersection.normal))) / pdf;
        } else {
            
            //Weight is 0, so all bounces will be useless.
            return L;
        }
        
        //Setup new ray to be traced.
        Ray newRay(MathUtils::addEpsilon(intersection.point, intersection.normal), wi);
        
        //Rendering equation with recursive path tracing calculation.
        L = L + weight * pathTracer.trace(newRay, bounce - 1);
    }
    
    return L;
}
コード例 #29
0
	Float *computeTransmittance(const char *name, Float ior, Float alpha, 
			size_t resolution, Float &diffTrans, int inverted) {
		Properties bsdfProps(alpha == 0 ? "dielectric" : "roughdielectric");
		if (inverted) {
			bsdfProps.setFloat("intIOR", 1.00);
			bsdfProps.setFloat("extIOR", ior);
		} else {
			bsdfProps.setFloat("extIOR", 1.00);
			bsdfProps.setFloat("intIOR", ior);
		}
		bsdfProps.setFloat("alpha", alpha);
		bsdfProps.setString("distribution", name);
		ref<BSDF> bsdf = static_cast<BSDF *>(
				PluginManager::getInstance()->createObject(bsdfProps));

		Float stepSize = 1.0f / (resolution-1);
		Float error;

		NDIntegrator intTransmittance(1, 2, 50000, 0, 1e-6f);
		NDIntegrator intDiffTransmittance(1, 1, 50000, 0, 1e-6f);
		Float *transmittances = new Float[resolution];

		for (size_t i=0; i<resolution; ++i) {
			Float t = i * stepSize;
			if (i == 0) /* Don't go all the way to zero */
				t = stepSize/10;
	
			Float cosTheta = std::pow(t, (Float) 4.0f);

			Vector wi(std::sqrt(std::max((Float) 0, 
					1-cosTheta*cosTheta)), 0, cosTheta);

			Float min[2] = {0, 0}, max[2] = {1, 1};
			intTransmittance.integrateVectorized(
				boost::bind(&transmittanceIntegrand, bsdf, wi, _1, _2, _3),
				min, max, &transmittances[i], &error, NULL);
		}

		Float min[1] = { 0 }, max[1] = { 1 };
		intDiffTransmittance.integrateVectorized(
			boost::bind(&diffTransmittanceIntegrand, transmittances, resolution, _1, _2, _3),
			min, max, &diffTrans, &error, NULL);

		if (alpha == 0.0f)
			cout << diffTrans << " vs " << 1-fresnelDiffuseReflectance(inverted ? (1.0f / ior) : ior) << endl;

		return transmittances;
	}
コード例 #30
0
ファイル: gees.hpp プロジェクト: 5263/FreeCAD
 inline 
 void gees (char const jobvs, char const sort, logical_t* select, int const n,
            double* a, int const lda, int& sdim, traits::complex_d* w,
            double* vs, int const ldvs, double* work, int const lwork,
            bool* bwork, int& info) 
 {
   traits::detail::array<double> wr(n);
   traits::detail::array<double> wi(n);
   LAPACK_DGEES (&jobvs, &sort, select, &n, a, &lda, &sdim,
                 traits::vector_storage(wr), traits::vector_storage(wi),
                 vs, &ldvs, work, &lwork, bwork, &info);
   traits::detail::interlace(traits::vector_storage(wr),
                             traits::vector_storage(wr)+n,
                             traits::vector_storage(wi),
                             w);
 }