Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualMARS_999

Posted 13 June 2013 - 07:31 AM

One last question, I am trying to use

 

irr::scene::IParticleEmitter

 

with this custom Projection matrix and it will not render the position correctly? Do I need to make my own particle class to use this?

 

It renders the effect at 0,0,0 when I set position to that, but if I use 400, 0, their isn't anything on screen. Screen size is 800,600 so it should be at middle bottom of screen...

 
void NX::Effect::DrawEffect(irr::IrrlichtDevice* device,
                            irr::video::IVideoDriver* driver)
{
    NX::App* p = NX::App::Get();
    
    irr::core::matrix4 oldProjMat  = driver->getTransform(irr::video::ETS_PROJECTION);
    irr::core::matrix4 oldViewMat  = driver->getTransform(irr::video::ETS_VIEW);
    irr::core::matrix4 oldWorldMat = driver->getTransform(irr::video::ETS_WORLD);
    
    irr::core::matrix4 projMatrix;
    NX::BuildProjMatrixOrthoOffCenterRH(0.0f, p->GetAppConfig()->screenSize.Width,
                                        0.0f, p->GetAppConfig()->screenSize.Height,
                                        -1.0f, 100.0f,
                                        projMatrix);

    driver->setTransform(irr::video::ETS_PROJECTION, projMatrix);
    driver->setTransform(irr::video::ETS_VIEW,  irr::core::matrix4());
    driver->setTransform(irr::video::ETS_WORLD, irr::core::matrix4());

    if(!ps)
        ps = device->getSceneManager()->addParticleSystemSceneNode(false);
    //irr::scene::IParticleSystemSceneNode* ps = device->getSceneManager()->addParticleSystemSceneNode(false);
    //irr::scene::IParticleEmitter* em         = ps->createRingEmitter(pos, .005f, .05f);
    
    //em->setMinStartSize(irr::core::dimension2d<irr::f32>(.1f, .1f));
    //em->setMaxStartSize(irr::core::dimension2d<irr::f32>(.5f, .5f));

    //irr::scene::IParticleEmitter* em = ps->createRingEmitter(pos, 0.0f, 5.0f, irr::core::vector3df(0.0f, 0.0f, .01f));
    if(!em)
    {
        em = ps->createRingEmitter(pos, 0.0f, 1.0f, irr::core::vector3df(0.0f, 0.0f, 0.0f));
        em->setMinStartSize(irr::core::dimension2d<irr::f32>(1.0f, 1.0f));
        em->setMaxStartSize(irr::core::dimension2d<irr::f32>(1.0f, 1.0f));
        ps->setEmitter(em);
        em->drop();
    }

    //irr::scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();
    if(!paf)
    {
        paf = ps->createFadeOutParticleAffector();
        ps->addAffector(paf);
        paf->drop();
        ps->setMaterialFlag(irr::video::EMF_LIGHTING, false);
        ps->setMaterialFlag(irr::video::EMF_ZWRITE_ENABLE, false);
        ps->setMaterialTexture(0, driver->getTexture("media/portal6.png"));
        ps->setMaterialType(irr::video::EMT_TRANSPARENT_ADD_COLOR);
    }
    else
    {
        ps->setMaterialFlag(irr::video::EMF_LIGHTING, false);
        ps->setMaterialFlag(irr::video::EMF_ZWRITE_ENABLE, false);
        ps->setMaterialType(irr::video::EMT_TRANSPARENT_ADD_COLOR);
        driver->enableMaterial2D(true);
    }
}

Thanks!


#1MARS_999

Posted 13 June 2013 - 07:29 AM

One last question, I am trying to use

 

irr::scene::IParticleEmitter

 

with this custom Projection matrix and it will not render the position correctly? Do I need to make my own particle class to use this?

 

 
void NX::Effect::DrawEffect(irr::IrrlichtDevice* device,
                            irr::video::IVideoDriver* driver)
{
    NX::App* p = NX::App::Get();
    
    irr::core::matrix4 oldProjMat  = driver->getTransform(irr::video::ETS_PROJECTION);
    irr::core::matrix4 oldViewMat  = driver->getTransform(irr::video::ETS_VIEW);
    irr::core::matrix4 oldWorldMat = driver->getTransform(irr::video::ETS_WORLD);
    
    irr::core::matrix4 projMatrix;
    NX::BuildProjMatrixOrthoOffCenterRH(0.0f, p->GetAppConfig()->screenSize.Width,
                                        0.0f, p->GetAppConfig()->screenSize.Height,
                                        -1.0f, 100.0f,
                                        projMatrix);

    driver->setTransform(irr::video::ETS_PROJECTION, projMatrix);
    driver->setTransform(irr::video::ETS_VIEW,  irr::core::matrix4());
    driver->setTransform(irr::video::ETS_WORLD, irr::core::matrix4());

    if(!ps)
        ps = device->getSceneManager()->addParticleSystemSceneNode(false);
    //irr::scene::IParticleSystemSceneNode* ps = device->getSceneManager()->addParticleSystemSceneNode(false);
    //irr::scene::IParticleEmitter* em         = ps->createRingEmitter(pos, .005f, .05f);
    
    //em->setMinStartSize(irr::core::dimension2d<irr::f32>(.1f, .1f));
    //em->setMaxStartSize(irr::core::dimension2d<irr::f32>(.5f, .5f));

    //irr::scene::IParticleEmitter* em = ps->createRingEmitter(pos, 0.0f, 5.0f, irr::core::vector3df(0.0f, 0.0f, .01f));
    if(!em)
    {
        em = ps->createRingEmitter(pos, 0.0f, 1.0f, irr::core::vector3df(0.0f, 0.0f, 0.0f));
        em->setMinStartSize(irr::core::dimension2d<irr::f32>(1.0f, 1.0f));
        em->setMaxStartSize(irr::core::dimension2d<irr::f32>(1.0f, 1.0f));
        ps->setEmitter(em);
        em->drop();
    }

    //irr::scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();
    if(!paf)
    {
        paf = ps->createFadeOutParticleAffector();
        ps->addAffector(paf);
        paf->drop();
        ps->setMaterialFlag(irr::video::EMF_LIGHTING, false);
        ps->setMaterialFlag(irr::video::EMF_ZWRITE_ENABLE, false);
        ps->setMaterialTexture(0, driver->getTexture("media/portal6.png"));
        ps->setMaterialType(irr::video::EMT_TRANSPARENT_ADD_COLOR);
    }
    else
    {
        ps->setMaterialFlag(irr::video::EMF_LIGHTING, false);
        ps->setMaterialFlag(irr::video::EMF_ZWRITE_ENABLE, false);
        ps->setMaterialType(irr::video::EMT_TRANSPARENT_ADD_COLOR);
        driver->enableMaterial2D(true);
    }
}

 

Thanks!


PARTNERS