Beispiel #1
0
/**
 * If this action is occuring on a background thread, and this node is already part of the
 * scene being rendered, the operation is queued for execution on the rendering thread, to
 * avoid the possibility of adding a shadow in the middle of a render iteration.
 */
void CC3Light::addShadow( CC3ShadowVolumeMeshNode* aShadowNode )
{
	if ( !CC3OpenGL::sharedGL()->isRenderingContext() && getScene() )
		addShadowFromBackgroundThread( aShadowNode );
	else
		addShadowNow( aShadowNode );
}
Beispiel #2
0
 //public
void BallSystem::process(float dt)
{
    auto& entities = getEntities();
    for(auto entity : entities)
    {
        auto& ball = entity.getComponent<Ball>();
        switch(ball.state)
        {
            default:
            case Ball::State::Waiting:             
                break;
            case Ball::State::Active:
            {
                auto& tx = entity.getComponent<xy::Transform>();
                tx.move(ball.velocity * Ball::Speed * dt);

                sf::FloatRect bounds(sf::Vector2f(), xy::DefaultSceneSize);
                if(!bounds.contains(tx.getPosition()))
                {
                    getScene()->destroyEntity(entity);
                }
            }
                break;
        }
    }
}
float GoalStateOfGear::getGoalScore(void)
{
    Virtues* virtues = getScene()->getCareer()->getVirtues();

    float totalDamage = 0;

    #ifndef GAMEPLAY_EDITION_ATARI
        totalDamage += ( _helmetState - virtues->equipment.helmet.state );
    #endif
    totalDamage += ( _suitState - virtues->equipment.suit.state );
    totalDamage += ( _rigState - virtues->equipment.rig.state );
    totalDamage += ( _canopyState - virtues->equipment.canopy.state );
	
	totalDamage = 0;
	return 0;

    if( totalDamage < 0.01f )
    {
        return 5.0f;
    }
    else
    {
		if (totalDamage > 5.0f) totalDamage = 5.0f;
        return -( totalDamage * 100.0f );
    }
}
Beispiel #4
0
void Light::leaveScene() {
    getSceneNode()->detachObject(light);
    getScene()->getSceneManager()->destroyLight(light);
    light = nullptr;

    VisualComponent::leaveScene();
}
bool Representation::doWakeUp()
{
	if (getMaterial() == nullptr && !m_materialReference.empty())
	{
		std::vector<std::string> names;
		boost::split(names, m_materialReference, boost::is_any_of("/"));

		SURGSIM_ASSERT(names.size() == 2)
				<< "Material reference needs to have 2 parts <scenelement>/<component>, '" << m_materialReference
				<< "' in " << getFullName() << " doesn't.";

		auto material = getScene()->getComponent(names[0], names[1]);
		if (material != nullptr)
		{
			setMaterial(material);
		}
		else
		{
			SURGSIM_LOG_WARNING(Framework::Logger::getLogger("Graphics/Representation"))
					<< "Can't find material " << m_materialReference << " in Scene, rendering of " << getFullName()
					<< " is going to be compromised.";
		}
	}
	return true;
}
const wchar_t* GoalStateOfHealth::getGoalValue(void)
{
    Virtues* virtues = getScene()->getCareer()->getVirtues();

    float injuries = _freefallHealth - virtues->evolution.health;

    // verbalize injuries
    if( virtues->evolution.health == 0 )
    {
        return Gameplay::iLanguage->getUnicodeString(453);
    }
    else if( injuries > 0.75f )
    {
        return Gameplay::iLanguage->getUnicodeString(452);
    }
    else if( injuries > 0.5f )
    {
        return Gameplay::iLanguage->getUnicodeString(451);
    }
    else if( injuries > 0.25 )
    {
        return Gameplay::iLanguage->getUnicodeString(450);
    }
    else if( injuries > 0.125 )
    {
        return Gameplay::iLanguage->getUnicodeString(449);
    }
    else
    {
        return Gameplay::iLanguage->getUnicodeString(448);
    }
}
Beispiel #7
0
      void
      Widget::setView(frontend::ViewInfo* view)
      {
	m_view = view;
	m_glWidget->makeCurrent();
	graphicView::Scene::Type type = getScene()->getType();
	switch (view->getViewType()) {
	case frontend::ViewInfo::MeshType: {
	  if (type == graphicView::Scene::MeshSceneType)
	    m_state->setView((frontend::MeshInfo*) view);
	  else {
	    m_state = new widget_states::MeshWidget(*this);
	    m_state->setView((frontend::MeshInfo*) view);
	  }
	}
	  break;
	case frontend::ViewInfo::ImageType: {
	  if (type == graphicView::Scene::ImageSceneType)
	    m_state->setView((frontend::ImageInfo*) view);
	  else {
	    m_state = new widget_states::ImageWidget(*this);
	    m_state->setView((frontend::ImageInfo*) view);
	  }
	}
	  break;
	case frontend::ViewInfo::UndefinedType:
	default:
	  assert(!"Should never get here!");
	}
      }
Beispiel #8
0
	TextArea::~TextArea()
	{
		for (auto model : models)
		{
			getScene()->destroyModel(model);
		}
	}
float GoalStateOfHealth::getGoalScore(void)
{
    Virtues* virtues = getScene()->getCareer()->getVirtues();

    float injuries = _freefallHealth - virtues->evolution.health;

    // score injuries
    if( virtues->evolution.health == 0 )
    {
        return -100;
    }
    else if( injuries > 0.75f )
    {
        return -20;
    }
    else if( injuries > 0.5f )
    {
        return -10;
    }
    else if( injuries > 0.25 )
    {
        return -5;
    }
    else if( injuries > 0.125 )
    {
        return -1;
    }
    else
    {
        return 5;
    }
}
//-------------------------------------------------------------------------------------
bool ScenePhysicsManager::update(double elapsedSeconds)
{
  boost::shared_ptr<Scene> scene_ptr = getScene();
  if(!scene_ptr)
  {
    #ifdef _DEBUG
    std::cout << "Scene expired before calling scene physics manager update." << std::endl;
    #endif
    return true;
  }

  boost::shared_ptr<World> world_ptr = scene_ptr->getWorld();
  if(!world_ptr)
  {
    #ifdef _DEBUG
    std::cout << "World expired before calling scene physics manager update." << std::endl;
    #endif
    return true;
  }

  if(!world_ptr->getPhysicsManager()->isEnabled()) return true;//only progress scene if physics is enabled (maybe move into scenePhysicsManager)

  accumulator += elapsedSeconds;
  if(accumulator < stepSize) return false;
  accumulator -= stepSize;
  scenePhysics->simulate((float) stepSize);
  scenePhysics->fetchResults(true);

  return true;
}
Beispiel #11
0
void ProxyEntity::iValidated(ProxyObjectPtr ptr,Liveness::Token lt)
{
    if (!lt)
        return;
    
    assert(ptr == mProxy);

    SILOG(ogre, detailed, "Validating ProxyEntity " << ptr->getObjectReference().toString());

    mCanDestroy = false;

    mDestroyTimer->cancel();

    // Because this could be a new ProxyEntity, created after a bunch
    // of updates have been received by the ProxyObject, we need to
    // refresh its important data
    iUpdateLocation( mProxy, mProxy->location(), mProxy->orientation(), mProxy->bounds(), SpaceObjectReference::null(),lt );

    if (!mActive)
    {
        getScene()->downloadPlanner()->addNewObject(mProxy, this);
        mActive = true;
    }

}
void Forest::playSqueakSound(const Vector3f& pos)
{
    if( !_squeakSound )
    {
        const char* squeakSounds[2] =
        {
            "./res/sounds/wood/squeak01.ogg",
            "./res/sounds/wood/squeak02.ogg"
        };
        _squeakSound = Gameplay::iAudio->createStaticSound( squeakSounds[ getCore()->getRandToolkit()->getUniformInt() % 2 ] ); 
        _squeakSound->setDistanceModel( 1000.0f, 25000.0f, 1.0f );
        database::LocationInfo::Reverberation* reverb = getScene()->getReverberation();
        if( reverb )
        {
            _squeakSound->setReverberation(
                reverb->inGain,
                reverb->reverbMixDB,
                reverb->reverbTime,
                reverb->hfTimeRatio
            );
        }            
        _squeakSound->play();
        _squeakSound->place( pos );
    }
    else
    {
        _squeakSound->place( pos );
    }
}
Beispiel #13
0
bool TIGLViewerWindow::saveFile(const QString &fileName)
{
    TIGLViewerInputOutput::FileFormat format;
    QFileInfo fileInfo;
    
    fileInfo.setFile(fileName);
    QString fileType = fileInfo.suffix();
    if (fileType.toLower() == tr("brep") || fileType.toLower() == tr("rle")) {
        format = TIGLViewerInputOutput::FormatBREP;
    }
    else if (fileType.toLower() == tr("step") || fileType.toLower() == tr("stp")) {
        format = TIGLViewerInputOutput::FormatSTEP;
    }
    else if (fileType.toLower() == tr("iges") || fileType.toLower() == tr("igs")) {
        format = TIGLViewerInputOutput::FormatIGES;
    }
    else if (fileType.toLower() == tr("stl")) {
        format = TIGLViewerInputOutput::FormatSTL;
    }
    else {
        LOG(ERROR) << "Unknown file format " << fileType.toStdString();
        return false;
    }

    TIGLViewerInputOutput writer;
    return writer.exportModel ( fileInfo.absoluteFilePath(), format, getScene()->getContext());
}
Beispiel #14
0
	void BillBoard::renderImpl( Matrix4 const& trans )
	{
		RenderSystem* system = getScene()->_getRenderSystem();

		Matrix4 mat = system->getViewMatrix();

		switch ( mBoardType )
		{
		case BT_CYLINDICAL_X:
			mat[ 0] = trans( 0 , 0 );
			mat[ 1] = trans( 0 , 1 );
			mat[ 2] = trans( 0 , 2 );
			break;
		case BT_CYLINDICAL_Y:
			mat[ 4] = trans( 1 , 0 );
			mat[ 5] = trans( 1 , 1 );
			mat[ 6] = trans( 1 , 2 );
			break;
		case BT_CYLINDICAL_Z:
			mat[ 8] = trans( 2 , 0 );
			mat[ 9] = trans( 2 , 1 );
			mat[10] = trans( 2 , 2 );
			break;
		case BT_SPHERIAL:
			break;
		}

		mat[12] = trans( 3 , 0 );
		mat[13] = trans( 3 , 1 );
		mat[14] = trans( 3 , 2 );
		mat.modifyTranslation( trans.getTranslation() );
		system->setWorldMatrix( mat );
		_renderInternal();
	}
TEST(DcdCollisionTest, Deactivate)
{
	auto runtime = std::make_shared<Framework::Runtime>();
	auto physicsManager = std::make_shared<PhysicsManager>();
	runtime->addManager(physicsManager);

	auto sphere1 = std::make_shared<Collision::ShapeCollisionRepresentation>("Sphere1");
	sphere1->setShape(std::make_shared<Math::SphereShape>(1.0));

	auto sphere2 = std::make_shared<Collision::ShapeCollisionRepresentation>("Sphere2");
	sphere2->setShape(std::make_shared<Math::SphereShape>(1.0));
	sphere2->setLocalPose(Math::makeRigidTransform(Math::Quaterniond::Identity(), Vector3d(0.0, 0.0, 0.5)));

	auto scene = runtime->getScene();
	auto element = std::make_shared<Framework::BasicSceneElement>("Element");
	element->addComponent(sphere2);
	element->addComponent(sphere1);
	scene->addSceneElement(element);

	runtime->start(true);
	runtime->step();
	runtime->step();
	EXPECT_TRUE(sphere1->collidedWith(sphere2));
	EXPECT_TRUE(sphere2->collidedWith(sphere1));

	sphere1->setLocalActive(false);
	runtime->step();
	runtime->step();
	EXPECT_FALSE(sphere1->collidedWith(sphere2));
	EXPECT_FALSE(sphere2->collidedWith(sphere1));

	boost::this_thread::sleep(boost::posix_time::milliseconds(100));
	runtime->stop();
}
TEST(DcdCollisionTest, RigidRigidCollisionTest)
{
	auto sphere1 = std::make_shared<Blocks::SphereElement>("Sphere1");
	auto sphere2 = std::make_shared<Blocks::SphereElement>("Sphere2");
	sphere2->setPose(Math::makeRigidTransform(Math::Quaterniond::Identity(), Vector3d(0.0, 0.0, 0.5)));

	auto runtime = std::make_shared<Framework::Runtime>();
	auto scene = runtime->getScene();
	scene->addSceneElement(sphere1);
	scene->addSceneElement(sphere2);

	std::vector<std::shared_ptr<Physics::Representation>> physicsRepresentations;
	physicsRepresentations.push_back(sphere1->getComponents<Physics::Representation>()[0]);
	physicsRepresentations.push_back(sphere2->getComponents<Physics::Representation>()[0]);

	auto sphere1Collision = sphere1->getComponents<Collision::Representation>()[0];
	auto sphere2Collision = sphere2->getComponents<Collision::Representation>()[0];
	sphere1Collision->update(0.0);
	sphere2Collision->update(0.0);
	std::vector<std::shared_ptr<Collision::Representation>> collisionRepresentations;
	collisionRepresentations.push_back(sphere1Collision);
	collisionRepresentations.push_back(sphere2Collision);

	auto prepareState = std::make_shared<PrepareCollisionPairs>(false);
	auto stateTmp = std::make_shared<PhysicsManagerState>();
	stateTmp->setRepresentations(physicsRepresentations);
	stateTmp->setCollisionRepresentations(collisionRepresentations);
	auto state = prepareState->update(0.0, stateTmp); // This step prepares the collision pairs
	ASSERT_EQ(1u, state->getCollisionPairs().size());

	auto dcdCollision = std::make_shared<DcdCollision>(false);
	std::shared_ptr<PhysicsManagerState> newState = dcdCollision->update(1.0, state);
	EXPECT_TRUE(newState->getCollisionPairs().at(0)->hasContacts());
}
TEST(TransferParticlesToPointCloudBehaviorTests, UpdateTest)
{
	auto runtime = std::make_shared<Framework::Runtime>();
	runtime->addManager(std::make_shared<Framework::BehaviorManager>());
	runtime->addManager(std::make_shared<Physics::PhysicsManager>());

	auto sceneElement = std::make_shared<Framework::BasicSceneElement>("Element");

	auto particles = std::make_shared<Particles::SphRepresentation>("Particles");
	particles->setMaxParticles(10);
	particles->setMassPerParticle(1.0);
	particles->setDensity(1.0);
	particles->setGasStiffness(1.0);
	particles->setKernelSupport(1.0);
	for (size_t particleId = 0; particleId < 10; particleId++)
	{
		particles->addParticle(Vector3d(static_cast<double>(particleId), 0.0, 0.0), Vector3d::Zero(), 100000);
	}
	sceneElement->addComponent(particles);

	auto pointCloud = std::make_shared<Graphics::OsgPointCloudRepresentation>("Graphics");
	sceneElement->addComponent(pointCloud);

	auto behavior = std::make_shared<TransferParticlesToPointCloudBehavior>("Behavior");
	behavior->setSource(particles);
	behavior->setTarget(pointCloud);
	sceneElement->addComponent(behavior);

	auto scene = runtime->getScene();
	scene->addSceneElement(sceneElement);

	particles->update(0.1);
	behavior->update(0.1);
	auto sourceVertices = particles->getParticles().safeGet()->getVertices();
	auto targetVertices = pointCloud->getVertices()->getVertices();
	ASSERT_EQ(sourceVertices.size(), targetVertices.size());

	auto sourceVertex = sourceVertices.begin();
	auto targetVertex = targetVertices.begin();
	for (; sourceVertex != sourceVertices.end(); ++sourceVertex, ++targetVertex)
	{
		EXPECT_TRUE(sourceVertex->position.isApprox(targetVertex->position));
	}

	particles->removeParticle(0);
	particles->removeParticle(1);
	particles->update(0.1);
	behavior->update(0.1);

	sourceVertices = particles->getParticles().safeGet()->getVertices();
	targetVertices = pointCloud->getVertices()->getVertices();
	ASSERT_EQ(sourceVertices.size(), targetVertices.size());

	sourceVertex = sourceVertices.begin();
	targetVertex = targetVertices.begin();
	for (; sourceVertex != sourceVertices.end(); ++sourceVertex, ++targetVertex)
	{
		EXPECT_TRUE(sourceVertex->position.isApprox(targetVertex->position));
	}
}
Beispiel #18
0
void ProxyEntity::tryDelete() {
    if (!mActive && mCanDestroy) {
        static_cast<OgreSystem*>(getScene())->entityDestroyed(this);
        Provider<ProxyEntityListener*>::notify(&ProxyEntityListener::proxyEntityDestroyed, this);
        delete this;
    }
}
Beispiel #19
0
int pWorld::raycastAllShapes(const VxRay& worldRay, pShapesType shapesType, int groups, float maxDist, pRaycastBit hintFlags, const pGroupsMask* groupsMask)
{

	int result = 0;

	NxRay rayx;
	rayx.dir = getFrom(worldRay.m_Direction);
	rayx.orig = getFrom(worldRay.m_Origin);

	pRayCastReport &report = *getRaycastReport();

	NxGroupsMask *mask  = NULL;
	if (groupsMask)
	{
		mask = new NxGroupsMask();
		mask->bits0 = groupsMask->bits0;
		mask->bits1 = groupsMask->bits1;
		mask->bits2 = groupsMask->bits2;
		mask->bits3 = groupsMask->bits3;

	}
	
	result  = getScene()->raycastAllShapes(rayx,report,(NxShapesType)shapesType,groups,maxDist,hintFlags,mask);
	return result;


}
void RestartLayer::show()
{
	CCString* str = CCString::createWithFormat("IQ: %d", m_nIQ);
	m_pIQLabel->setString(str->getCString());
	NavigatorLayer::show();
	m_pHead->stopAllActions();
	m_pHead->runAction(m_pFlickerAction);
    
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
    CCString *promptText = getScene()->getPromptText();
    if(promptText->compare("") == 0)
    {
        if(m_pPromptItem)
        {
            m_pPromptItem->setVisible(false);
        }
    }
    else
    {
        if(m_pPromptText)
            m_pPromptText->setVisible(false);
        m_pHead->setVisible(true);
    }
#endif
}
Beispiel #21
0
	void PhysicsNode::render(AbstractRender *render) const {

		if (render_body) {
			if (body->getBody() == Nutmeg::BODY_CAPSULE) {

				vec3 size = body->getSize();
				float diameter = math::min(size.x, size.y);
				float height = size.z;

				renderCapsule(getScene(), render, diameter, height, getPos(true), getRot(true));

			} else {
				render->setMatrix(origin);
				render->drawMesh(scene->getPrimitive(body->getBody()));
			}
		}
	
		/*
		if (render_body) {
			//mat4 matrix;
			//body->getMatrix(matrix);
			//matrix = mat4::scale(scale) * matrix;
			//render->setMatrix(matrix);

			render->setMatrix(origin);
			render->drawMesh(scene->getPrimitive(body->getBody()));
		}
		*/

	}
Beispiel #22
0
  void Player::moveTo(const CCPoint& pos, const std::vector<CCPoint>& path) {
    if(!path.empty()) {
      std::vector<MoveInfo> moveInfos;
      for(auto& p : path) {
        moveInfos.push_back(MoveInfo(p));
      }

      auto action = createAnimation(m_animTextureName,
          moveInfos,
          CCSize(48, 48),
          4,
          0.1f,
          1);
      //CCHide * hide= CCHide::create();
      m_sprite->runAction(action);
      action = createMoveAction(
          moveInfos,
          CCSize(48 * m_scale, 48 * m_scale),
          0.4f);
      CCCallFunc* fun = CCCallFunc::create(getScene(), callfunc_selector(HelloWorld::inChooseActionState));

      runAction(CCSequence::create(action, fun, 0));
    }

  }
GoalStateOfHealth::~GoalStateOfHealth()
{
    if( _player->isOverActivity() )
    {	
        Virtues* virtues = getScene()->getCareer()->getVirtues();
        assert( _finite( getGoalScore() ) );
        virtues->evolution.score += getGoalScore();
        if( virtues->evolution.score < 0 )
        {
            virtues->evolution.score = 0;
        }
        if( virtues->evolution.health == 0 )
        {
            bool creditsIsAffected = true;            
            // credits is not affected for licensed character
            creditsIsAffected = !_scene->getCareer()->getLicensedFlag();
            // credits is not affected in developer edition
			if ( Gameplay::iGameplay->_cheatsEnabled )
			{
				creditsIsAffected = false;
			}
            #ifdef GAMEPLAY_DEVELOPER_EDITION
                creditsIsAffected = false;
            #endif
            getCore()->logMessage( "creditsIsAffected=%d", creditsIsAffected );

            if( creditsIsAffected ) virtues->evolution.credits--;
            if( virtues->evolution.credits > 0 )
            {
                virtues->evolution.health = 0.125f;
            }
        }
    }
}
Beispiel #24
0
bool CullingNode::gatherGeometry(GeometryGather& gather)
{
    if (getScene()->is3D() && !gather.getFrustum().intersect(getWorldExtents()))
        return false;

    return ComplexEntity::gatherGeometry(gather);
}
Beispiel #25
0
//------------------------------------------------------------------------------
void Entity::setUpdatable(bool updatable, const std::string layerName)
{
	// TODO FIXME Set the flag!!
    if (getFlag(SN_EF_UPDATABLE) ^ updatable)
    {
        Scene * scene = getScene();
        if (scene)
        {
			setFlag(SN_EF_UPDATABLE, updatable);
            UpdateManager & manager = scene->getUpdateManager();
            if (updatable)
            {
                manager.addEntity(*this, layerName.empty() ? UpdateManager::DEFAULT_LAYER : layerName);
            }
            else
            {
                manager.removeEntity(*this, layerName);
            }
        }
        else
        {
            SN_ERROR("Entity::setUpdatable: scene not found from entity " << toString());
        }
    }
    else
    {
        SN_WARNING("Entity::setUpdatable: no change made (entity " << toString() << ")");
    }
}
QScriptValue Renderer::renderScene(const QScriptValue &sceneArg) {
  QScriptValue obj = context()->thisObject();
  valueToIntList(obj.property("frames"), m_imp->m_frameList);
  valueToIntList(obj.property("columns"), m_imp->m_columnList);

  Scene *scene     = 0;
  QScriptValue err = getScene(context(), sceneArg, scene);
  if (err.isError()) return err;

  Level *outputLevel = new Level();
  // engine()->collectGarbage();
  m_imp->renderScene(scene->getToonzScene(), outputLevel);
  return create(engine(), outputLevel);
  /*
for(int row=0;row<scene->getToonzScene()->getFrameCount();row++)
{
engine()->collectGarbage();
TImageP img = renderEngine.renderFrame(row);
if(img)
{
  QScriptValue frame = create(new Image(img));
  QScriptValueList args; args << QString::number(row+1) << frame;
  newLevel.property("setFrame").call(newLevel, args);
}
else
{
  return context()->throwError(tr("Render failed"));
}
}
return newLevel;
*/
}
Beispiel #27
0
	Viewport::~Viewport()
	{
		if (target.isValid())
		{
			getScene()->removeDependentTarget(target);
		}
	}
Beispiel #28
0
      Widget::Widget(const QString& name, Scene::Type type, const Widget* shareWidget)
	: QGraphicsView(),
	  m_name(name),
	  m_state(0),
	  m_view()
      {
	QGLWidget* glShared = 0;
	if (shareWidget)
	  glShared = (QGLWidget*) shareWidget->viewport();

	m_glWidget = new GLWidget(0, glShared);
	setViewport(m_glWidget);
	setViewportUpdateMode(FullViewportUpdate);

	m_glWidget->makeCurrent();
	m_glWidget->initializeGL();

	if (type == Scene::ImageSceneType)
	  m_state = new widget_states::ImageWidget(*this);
	else if (type == Scene::MeshSceneType)
	  m_state = new widget_states::MeshWidget(*this);

	setScene(getScene());

	setMinimumSize(250, 250);
	setContentsMargins(1, 1, 1, 1);

#ifdef DEBUG
	std::cout << "create graphicView: " << name.toStdString() << std::endl;
#endif
      }
void InstantRadiosityRenderer::beginFrame() {
    auto lightPathDepth = m_nMaxDepth - 2;

    m_EmissionVPLBuffer.clear();
    m_EmissionVPLBuffer.reserve(m_nLightPathCount);

    m_SurfaceVPLBuffer.clear();
    m_SurfaceVPLBuffer.reserve(m_nLightPathCount * lightPathDepth);

    for(auto i: range(m_nLightPathCount)) {
        auto power = Vec3f(1.f / m_nLightPathCount);
        EmissionVPL vpl;
        vpl.pLight = m_Sampler.sample(getScene(), getFloat(0u), vpl.lightPdf);
        if(vpl.pLight && vpl.lightPdf) {
            float emissionVertexPdf;
            RaySample exitantRaySample;
            vpl.emissionVertexSample = getFloat2(0u);
            auto Le = vpl.pLight->sampleExitantRay(getScene(), vpl.emissionVertexSample, getFloat2(0u), exitantRaySample, emissionVertexPdf);

            m_EmissionVPLBuffer.emplace_back(vpl);

            if(Le != zero<Vec3f>() && exitantRaySample.pdf) {
                auto intersection = getScene().intersect(exitantRaySample.value);
                if(intersection) {
                    power *= Le / (vpl.lightPdf * exitantRaySample.pdf);
                    m_SurfaceVPLBuffer.emplace_back(intersection, -exitantRaySample.value.dir, getScene(), power);

                    for(auto depth = 1u; depth < lightPathDepth; ++depth) {
                        Sample3f outgoingDir;
                        float cosThetaOutDir;
                        auto fs = m_SurfaceVPLBuffer.back().bsdf.sample(getFloat3(0u), outgoingDir, cosThetaOutDir,
                                                                 nullptr, true);

                        if(fs != zero<Vec3f>() && outgoingDir.pdf) {
                            Ray ray(m_SurfaceVPLBuffer.back().intersection, outgoingDir.value);
                            auto intersection = getScene().intersect(ray);
                            if(intersection) {
                                power *= fs * abs(cosThetaOutDir) / outgoingDir.pdf;
                                m_SurfaceVPLBuffer.emplace_back(intersection, -ray.dir, getScene(), power);
                            }
                        }
                    }
                }
            }
        }
    }
}
Beispiel #30
0
      void
      Widget::resizeEvent(QResizeEvent* evt)
      {
	QSize sz = evt->size();
	getScene()->resize(QRectF(0, 0, sz.width(), sz.height()));
	((GLWidget*) viewport())->resize(sz.width(), sz.height());
	QGraphicsView::resizeEvent(evt);
      }