Beispiel #1
0
NaiadFoam::NaiadFoam(const Transform *o2w, const Transform *w2o,
                     bool ro, const ParamSet &params): Shape(o2w, w2o, ro) {

    Nb::begin();

    int nFoamEmps;
    const string * empStr = params.FindString("emp", &nFoamEmps);
    const string * bodyStr = params.FindString("body", &nFoamEmps);

    for (int i = 0; i < nFoamEmps; ++i) {
        Nb::EmpReader empReader(empStr[i].c_str(),"*");
        const Nb::Body * body = empReader.ejectBody(bodyStr[i].c_str());
        const Nb::ParticleShape & particle = body->constParticleShape();

        bb = BBox(Point(particle.min().v[0],
                        particle.min().v[1],
                        particle.min().v[2]),
                  Point(particle.max().v[0],
                        particle.max().v[1],
                        particle.max().v[2]));

        //Total amount of particles
        const int64_t nParticles = particle.size();
        printf("Found %i particles in %s\n", nParticles, empStr[i].c_str());

        //Number of blocks
        const int nBlocks = particle.constBlocks3f(0).block_count();

        for (int64_t blockIdx = 0; blockIdx < nBlocks; ++blockIdx) {
            boxes.push_back(new NaiadFoamBox(o2w,w2o,ro,this,particle,blockIdx));
        }
    }

    foamPlane = new std::vector<float>(441000,0);

    FoamInLowerBound  = params.FindOneFloat("FoamInLowerBound",0.f);
    FoamInUpperBound  = params.FindOneFloat("FoamInUpperLowerBound",255.f);
    FoamInGamma       = params.FindOneFloat("FoamInGamma",1.f);
    FoamOutLowerBound = params.FindOneFloat("FoamOutUpperLowerBound",0.f);
    FoamOutUpperBound = params.FindOneFloat("FoamOutUpperLowerBound",255.f);

    printf("%f %f %f %f %f\n", FoamInLowerBound, FoamInUpperBound, FoamInGamma, FoamOutLowerBound, FoamOutUpperBound);

    cur = this;
}
Beispiel #2
0
void Context::Shape(const string &n, const ParamSet &params) {
	VERIFY_WORLD("Shape");
	renderFarm->send("luxShape", n, params);
	const u_int sIdx = shapeNo++;
	u_int nItems;
	const string *sn = params.FindString("name", &nItems);
	if (!sn || *sn == "") {
		// generate name based on shape type and declaration index
		std::stringstream ss("");
		ss << "#" << sIdx << " (" << n << ")";
		const string sname = ss.str();
		const_cast<ParamSet &>(params).AddString("name", &sname);
	} else if (sn) {
		const string sname = "'" + *sn + "'";
		const_cast<ParamSet &>(params).AddString("name", &sname);
	}
	boost::shared_ptr<lux::Shape> sh(MakeShape(n, curTransform.StaticTransform(),
		graphicsState->reverseOrientation, params));
	if (!sh)
		return;
	params.ReportUnused();

	// Lotus - Set the material
	if (graphicsState->material)
		sh->SetMaterial(graphicsState->material);
	else {
		boost::shared_ptr<lux::Material> m(MakeMaterial("matte",
			curTransform.StaticTransform(), ParamSet()));
		sh->SetMaterial(m);
	}
	sh->SetExterior(graphicsState->exterior);
	sh->SetInterior(graphicsState->interior);

	// Create primitive and add to scene or current instance
	if (renderOptions->currentInstanceRefined) {
		if (graphicsState->areaLight != "") {
			LOG(LUX_WARNING,LUX_UNIMPLEMENT)<<"Area lights not supported with object instancing";
/*			// Lotus - add a decorator to set the arealight field
			boost::shared_ptr<Primitive> prim(
				new AreaLightPrimitive(pr, area));
			if (!prim->CanIntersect())
				prim->Refine(*(renderOptions->currentInstance),
					PrimitiveRefinementHints(false), prim);
			else
				renderOptions->currentInstance->push_back(prim);
			// Add area light for primitive to light vector
			renderOptions->currentLightInstance->push_back(area);*/
		} /*else*/ {
			renderOptions->currentInstanceSource->push_back(sh);
			if (!sh->CanIntersect())
				sh->Refine(*(renderOptions->currentInstanceRefined),
					PrimitiveRefinementHints(false), sh);
			else
				renderOptions->currentInstanceRefined->push_back(sh);
		}
	} else if (graphicsState->areaLight != "") {
		u_int lg = GetLightGroup();
		AreaLight *area = MakeAreaLight(graphicsState->areaLight,
			curTransform.StaticTransform(),
			graphicsState->areaLightParams, sh);
		if (area) {
			area->group = lg;
			area->SetVolume(graphicsState->exterior); //unused
		}
		// Lotus - add a decorator to set the arealight field
		boost::shared_ptr<Primitive> pr(sh);
		boost::shared_ptr<Primitive> prim(new AreaLightPrimitive(pr,
			area));
		renderOptions->primitives.push_back(prim);
		// Add area light for primitive to light vector
		renderOptions->lights.push_back(area);
	} else
		renderOptions->primitives.push_back(sh);
}