Page 1 of 1

Wrong Displaying by using 3D and 2D particles at same time

PostPosted: Mon Dec 14, 2015 6:04 am
by zjhlogo
I have 2 particles, one is 3D particle and another is 2D, they all packed in one ptc file. It is display correctly if I update them separately (only update one particle at the same time), but when I update two particle at the same time, 3D particle acted wrong. Do anyone have the same problem ? Or anyone know how can I fix it ?

here is the screenshoot
3D.jpg
correct one, if update only one particles
3D.jpg (111.97 KiB) Viewed 118224 times

3D+2D.jpg
wrong, the arrow fliped and splash all the time
3D+2D.jpg (72.16 KiB) Viewed 118224 times

Re: Wrong Displaying by using 3D and 2D particles at same ti

PostPosted: Mon Dec 14, 2015 2:19 pm
by Odin_KG
Give me, please, screenshot.

Re: Wrong Displaying by using 3D and 2D particles at same ti

PostPosted: Wed Dec 16, 2015 5:23 am
by zjhlogo
here is the code relate to the particles:

Code: Select all
bool ParticlesApp::initialize()
{
   if (!BaseApp::initialize()) return false;

   spank::RenderInterface* pRenderInterface = getRenderInterface();

   int axis = MAGIC_pXpYpZ;
   MP_Manager::GetInstance().Initialization(axis, new MP_Platform_WIN_POSIX(), MAGIC_INTERPOLATION_ENABLE, MAGIC_CHANGE_EMITTER_DEFAULT, 1024, 1024, 1, 1.f, 0.1f, true);

   // eng: find of all ptc-files in folder
   MP_Manager::GetInstance().LoadEmittersFromFile("test.ptc");
   MP_Manager::GetInstance().RefreshAtlas();
   MP_Manager::GetInstance().CloseFiles();
   MP_Manager::GetInstance().Stop();

   MP_Emitter* emitter = nullptr;

   emitter = MP_Manager::GetInstance().GetEmitterByName("arrow");
   emitter->SetState(MAGIC_STATE_UPDATE);
   emitter->SetPosition(MP_POSITION(0.0f, 200.0f, 0.0f));
   emitter->SetScale(0.4f);
   Magic_SetLoopMode(emitter->GetEmitter(), MAGIC_FOREVER);

   emitter = MP_Manager::GetInstance().GetEmitterByName("huoxing");
   emitter->SetState(MAGIC_STATE_UPDATE);
   emitter->SetPosition(MP_POSITION(0.0f, 0.0f, 0.0f));
   Magic_SetLoopMode(emitter->GetEmitter(), MAGIC_FOREVER);

   MAGIC_CAMERA camera;
   camera.pos.x = m_cameraPos.x;
   camera.pos.y = m_cameraPos.y;
   camera.pos.z = m_cameraPos.z;
   camera.dir.x = m_lookAt.x - camera.pos.x;
   camera.dir.y = m_lookAt.y - camera.pos.y;
   camera.dir.z = m_lookAt.z - camera.pos.z;
   Magic_SetCamera(&camera);

   return true;
}

void ParticlesApp::selfUpdate(float dt)
{
   static float s_totalTime = 0.0f;

   dt *= 0.1f;
   s_totalTime += dt;

   MP_Emitter* emitter = nullptr;

   emitter = MP_Manager::GetInstance().GetEmitterByName("arrow");
   emitter->Update(dt * 1000.0);

   emitter = MP_Manager::GetInstance().GetEmitterByName("huoxing");
   emitter->Update(dt * 1000.0);

//   MP_Manager::GetInstance().Update(dt * 1000.0);
}

void ParticlesApp::selfRender()
{
   glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   spank::RenderInterface* pRenderInterface = getRenderInterface();

   pRenderInterface->setCullFace(spank::RenderInterface::CFM_NONE);
    MP_Manager::GetInstance().Render();
   pRenderInterface->setCullFace(spank::RenderInterface::CFM_BACK);

   pRenderInterface->setBlendMode(spank::RenderInterface::BM_NORMAL);
   pRenderInterface->enableDepthWrite(true);
}


Re: Wrong Displaying by using 3D and 2D particles at same ti

PostPosted: Wed Dec 16, 2015 1:18 pm
by Odin_KG
Axis Y is directed to UP for 3D emitter. And axis Y is directed to DOWN for 2D emitter. Perhaps it is reason of such behavior. I can offer to transform 2D emitter to 3D. Use the button '3d scene' for it in the editor. 3D API transforms automatically all emitters in 3D, but perhaps the error exists.

I am going to release version 3.3 by New Year. Probably this problem was already solved.

Re: Wrong Displaying by using 3D and 2D particles at same ti

PostPosted: Thu Dec 17, 2015 3:33 am
by zjhlogo
the "3d scene" did not take any effect, I have to use "3d emitter" to convert them all to 3d emitters. and I found out if I cancel the option of particle "Keep aligned in direction", they all works fine. so may be there is some bugs of calculation of "Keep aligned in direction"

Re: Wrong Displaying by using 3D and 2D particles at same ti

PostPosted: Thu Dec 17, 2015 5:06 pm
by Odin_KG
Once I fixed several bugs in version 2.25. Perhaps this bug was fixed too.
http://astralax.com/temp/magic3d.dll

Soon I hope to release version 3.3. And version 2.25 will be outdated.

phpBB [video]

Re: Wrong Displaying by using 3D and 2D particles at same ti

PostPosted: Fri Dec 18, 2015 1:17 am
by zjhlogo
I replace the "magic3d.dll", It works now. thanks, and keep up the good job.

waiting for the new version ^_^

Re: Wrong Displaying by using 3D and 2D particles at same ti

PostPosted: Fri Dec 18, 2015 8:46 am
by Odin_KG
thanks, and keep up the good job.

you are welcome :)