help with particle fx and ortho view not working

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Mars_999
Posts: 136
Joined: Sat Dec 08, 2012 7:59 pm

help with particle fx and ortho view not working

Post by Mars_999 »

I have an ortho projection setup. So 800x600 screen size I want to render the center I should be able to use 400, 300


I have to use 0, 0. From the looks of it irrlicht is overriding my projection I upload to use. ..

Please help if possible as I am about to give up as I can't find anything wrong....

Maybe I can't use the built in particle renderer to do 2d?
Mars_999
Posts: 136
Joined: Sat Dec 08, 2012 7:59 pm

Re: help with particle fx and ortho view not working

Post by Mars_999 »

Damn people? ANyone have any clues? Or a tutorial on doing 2d Particles with irrlicht?

Thanks!
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Re: help with particle fx and ortho view not working

Post by roxaz »

i suppose noone can really understand problem at hand. neither can i..
Mars_999
Posts: 136
Joined: Sat Dec 08, 2012 7:59 pm

Re: help with particle fx and ortho view not working

Post by Mars_999 »

I can't get any particle effects to render at say 400,300 center of a 800,600 screen when using

Code: Select all

 
irr::scene::IParticleAffector* paf;
    irr::scene::IParticleEmitter* em;
    irr::scene::IParticleSystemSceneNode* ps;
 
Their isn't anything on screen...

I am using an Ortho camera node...

irr::scene::ICameraSceneNode* camera = smgr->addCameraSceneNode();

and in my drawing call I use

Code: Select all

 
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::BuildProjMatrixOrthoOffCenter(0.0f, p->GetAppConfig()->screenSize.Width, 
                                      0.0f, p->GetAppConfig()->screenSize.Height, 
                                     -1.0f, 100.0f,
                                      projMatrix);
 
    //driver->setTransform(irr::video::ETS_PROJECTION, projMatrix);
    p->GetCamera()->setProjectionMatrix(projMatrix, true);
    driver->setTransform(irr::video::ETS_VIEW,  irr::core::matrix4());
    driver->setTransform(irr::video::ETS_WORLD, irr::core::matrix4());
 
    /*
    // Convert pixels to world coordinates
    irr::core::vector2df screenSize(driver->getViewPort().getWidth(), 
                                    driver->getViewPort().getHeight());
    irr::core::vector3df tempPos(position);
    irr::core::vector3df trialPos(0, 0, 0);
    for(irr::s32 i = 0; i < 4; ++i)
        tempPos.set(((trialPos.X / screenSize.X) -0.5f)* 2.0f,
                    ((trialPos.Y / screenSize.Y) -0.5f)*-2.0f,
                    0.0f);
    */
    static NX::EffectParticle* fx = new NX::EffectParticle(irr::core::vector3df(400, 300, 0), 100);
    //static NX::EffectParticle* fx = new NX::EffectParticle(tempPos, 100);
    if(fx)
    {
        //fx->SetPosition(tempPos);
        fx->SetDevice(p->GetDevice());
        fx->SetDriver(p->GetDriver());
        fx->Run();
    }
    /*
    static NX::EffectParticle* fx = new NX::EffectParticle(position, 100);
    if(fx)
    {
        fx->SetPosition(position);
        fx->SetDevice(p->GetDevice());
        fx->SetDriver(p->GetDriver());
        fx->Run();
    }
    */
    CalculateVertices(position, scale, sides);
    CalculateIndices(sides);
    
    for(unsigned i = 0; i < vertex.size(); ++i)
    {
        irr::core::vector2d<irr::f32> temp(vertex[i].Pos.X, vertex[i].Pos.Y);
        temp = temp.rotateBy(rotation, irr::core::vector2d<irr::f32>(position.X, position.Y));
        vertex[i].Pos.X = temp.X;
        vertex[i].Pos.Y = temp.Y;
    }
        
    irr::video::SMaterial material;
    //material.Wireframe    = true;
    //material.BackfaceCulling = false;
    material.Lighting     = false;
    material.ZWriteEnable = false;
    material.UseMipMaps   = true;
    material.AntiAliasing = irr::video::EAAM_FULL_BASIC;
    material.TextureLayer[0].Texture           = texture;
    material.TextureLayer[0].AnisotropicFilter = 16;
    material.TextureLayer[0].TrilinearFilter   = true;
    material.TextureLayer[0].TextureWrapU      = irr::video::ETC_CLAMP;
    material.TextureLayer[0].TextureWrapV      = irr::video::ETC_CLAMP;
    
    if(useAlphaChannel)
        material.MaterialType = irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL;
    else
        material.MaterialType = irr::video::EMT_SOLID;
 
    driver->setMaterial(material);
    driver->enableMaterial2D(true);
    driver->drawIndexedTriangleFan(&vertex[0], vertex.size(), &index[0], index.size() - 2);     
    driver->enableMaterial2D(false);
 
    driver->setTransform(irr::video::ETS_PROJECTION, oldProjMat);
    driver->setTransform(irr::video::ETS_VIEW,       oldViewMat);
    driver->setTransform(irr::video::ETS_WORLD,      oldWorldMat);
 
Mars_999
Posts: 136
Joined: Sat Dec 08, 2012 7:59 pm

Re: help with particle fx and ortho view not working

Post by Mars_999 »

Here is an update...

Code: Select all

 
static NX::EffectParticle* fx = new NX::EffectParticle(irr::core::vector3df(0, 0, 0), 100);
    if(fx)
    {
        irr::core::vector3df tempPos(position.X, 
            p->GetAppConfig()->screenSize.Height - position.Y, 0.0f);//200,150 center on 800,600
        fx->SetPosition(NX::ConvertPosition(tempPos));
        fx->SetDevice(p->GetDevice());
        fx->SetDriver(p->GetDriver());
        fx->Run();
    }
 
I can run that code and get the particles to show up but they render up in the top left if I have a screen size of 800,600 I use 400,300 they show up at the top right...

It's like the screen size has been set to half and not adjusted to be fullsize? This is the only code that acts that way, when I call drawIndexedTriangleFan() I have no issues and that uses 800,600 full size to determine the vertex positions...

Thanks...
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: help with particle fx and ortho view not working

Post by CuteAlien »

Please add some images. Reading&understanding code is hard and takes time and with 10-20 new posts in threads each day it's hard to invest much time in posts which are difficult to understand on a quick view. And even better - add an example which others simply can compile and test and not just code blocks without much context. Because otherwise to reproduce this we would have to write now that example ourself to understand what is going on and that's again something we simply can't do in our spare-time (I mean we wouldn't even know if we have the same problem in the end or if the problem was hidden in the code blocks you posted etc).

edit: NX::* that doesn't really look like Irrlicht classes at all?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mars_999
Posts: 136
Joined: Sat Dec 08, 2012 7:59 pm

Re: help with particle fx and ortho view not working

Post by Mars_999 »

NX is my namespace for my engine stuff...

I will try to get a few things out but I think I have the problem fixed...
Please look here

http://www.gamedev.net/topic/644176-why ... try5071684

and let me know if that would cause it also?

Thanks!
Post Reply