HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 SPARK2 and Irrlicht trouble

View previous topic View next topic Go down 
AuthorMessage
Charlie



Messages : 81
Date d'inscription : 2011-01-28
Age : 34

PostSubject: SPARK2 and Irrlicht trouble   Mon Feb 04, 2013 9:57 pm

Hi !I almost finished my Hadron editor for SPARK2 and i found a bug with the irrlicht module.
First of all i tried the simple way , Creating a SPK::System and adding the elements to it.In yhis case it works but i can't see any particles rendered on the screen
but when i check the number of particles rendered (system->getNbParticles()) says that i have 10 particles on the screen but they are not visible.

I Can't send you the whole code how the particles are created because they are created through the Editor's engine. So i should paste here the whole editor source code... i dont think anyone will read that billions of lines of code. but basically i do this :

Code:
system = SPK::System::create();
group =  SPK::Group::create();
group->setLifeTime(10,10);
group->setRadius(0.01f);

system->addGroup(group);
renderer = SPK::IRR::IRRQuadRenderer::create(irrDevice);

renderer->setTexture(device->getVideoDriver()->getTexture("Media/bigpoint.bmp"));
renderer->setScale(2,2);
renderer->setTexturingMode(SPK::TEXTURE_MODE_2D);
renderer->setBlendMode(SPK::BLEND_MODE_ADD);

group->setRenderer(renderer);
group->addEmitter(SPK::SphericEmitter::create(SPK::Vector3D(0.0f,0.0f,-1.0f),1.0f,1.0f,SPK::Point::create());


and the rendering :


Code:
videoDriver->beginScene(true, true, irr::video::SColor(255,255,255,255));

system->updateParticles(deltaTime);
system->renderParticles();

deltaTime += 0.001f;

sceneManager->drawAll();


This is a very basic code just to test my editor, but no particles rendered




The secont method i tried is to use the CSPKParticleSystemNode which won't work properly. I simply copy\pasted the code from the SPKTestIrrlicht.cpp

Code:

// Inits Particle Engine
   // Sets the update step
   SPK::System::setClampStep(true,0.1f);         // clamp the step to 100 ms
   SPK::System::useAdaptiveStep(0.001f,0.01f);      // use an adaptive step from 1ms to 10ms (1000fps to 100fps)
   
   irr::scene::CSPKParticleSystemNode* system = new irr::scene::CSPKParticleSystemNode(smgr->getRootSceneNode(),smgr);
   system->drop(); // We let the scene manager take care of the system life time


   SPK::Ref<SPK::IRR::IRRQuadRenderer> quadRenderer = SPK::IRR::IRRQuadRenderer::create(device);
   quadRenderer->setBlendMode(SPK::BLEND_MODE_ADD);
   quadRenderer->enableRenderingOption(SPK::RENDERING_OPTION_DEPTH_WRITE,false);
   quadRenderer->setTexture(driver->getTexture("res\\flare.bmp"));
   quadRenderer->setTexturingMode(SPK::TEXTURE_MODE_2D);

   SPK::Ref<SPK::Emitter> emitter1 = SPK::RandomEmitter::create(SPK::Point::create());
   emitter1->setForce(0.4f,0.6f);
   emitter1->setFlow(200);

   /*SPK::Ref<SPK::Emitter> emitter1 = SPK::RandomEmitter::create(SPK::Point::create());
   emitter1->setForce(0.4f,0.6f);
   emitter1->setFlow(200);*/

   SPK::Ref<SPK::Emitter> emitter2 = SPK::SPKObject::copy(emitter1);

   SPK::Ref<SPK::ColorGraphInterpolator> graphInterpolator = SPK::ColorGraphInterpolator::create();
   graphInterpolator->addEntry(0.0f,0xFF000088);
   graphInterpolator->addEntry(0.5f,0x00FF0088);
   graphInterpolator->addEntry(1.0f,0x0000FF88);

   SPK::Ref<SPK::Group> group = system->createSPKGroup(400);
   group->setRadius(0.15f);
   group->setLifeTime(0.5f,1.0f);
   group->setColorInterpolator(graphInterpolator);
   group->setParamInterpolator(SPK::PARAM_SCALE,SPK::FloatRandomInterpolator::create(0.8f,1.2f,0.0f,0.0f));
   group->setParamInterpolator(SPK::PARAM_ANGLE,SPK::FloatRandomInitializer::create(0.0f,2 * 3.14159f));
   group->addEmitter(emitter1);
   group->addEmitter(emitter2);
   group->addModifier(SPK::Gravity::create(SPK::Vector3D(0.0f,-0.5f,0.0f)));
   group->addModifier(SPK::Friction::create(0.2f));
   group->setRenderer(quadRenderer);


But the exe crashes at the line

Code:
SPK::Ref<SPK::Group> group = system->createSPKGroup(400);


try to do this , and the app wil crash :

Code:
irr::scene::CSPKParticleSystemNode* system = new irr::scene::CSPKParticleSystemNode(sceneManager->getRootSceneNode(),sceneManager);
SPK::Ref<SPK::Group> group = system->createSPKGroup(400);


Any ideas what causes the problem ?
Thanks !

I' using VC++ 2008 Express , and using static libraries of SPARK2

Back to top Go down
View user profile
Juff
Developer


Messages : 539
Date d'inscription : 2009-07-14
Age : 34

PostSubject: Re: SPARK2 and Irrlicht trouble   Tue Feb 05, 2013 9:18 am

Hi,

you need to use the CSPKParticleSystemNode to use SPARK with Irrlicht.
Not why is it crashing ? Maybe your compiler or linker settings are not correct.
Have you tried running in debug mode with the debugger ?
I ll try to link the irrlicht demo statically and get back to you.
Back to top Go down
View user profile http://spark.developpez.com
Charlie



Messages : 81
Date d'inscription : 2011-01-28
Age : 34

PostSubject: Hi   Tue Feb 05, 2013 12:50 pm

Thanks Juff ! I also downloaded the latest version of SPARK2 and tried to make a debug version but
I have this warning when building the projects with CMake :

Code:
You have to set both SPARK_IRRLICHT_LIB and SPARK_IRRLICHT_LIB_DEBUG for the Irrlicht build to work.
   Ignore this message if you're not using Irrlicht.

What should i do to correct this ? Do i need to build the static library of SPARK_IRR first , then link that lib when building the dinamic library ?
Back to top Go down
View user profile
Darktib
Committer


Messages : 389
Date d'inscription : 2009-07-20
Localisation : A coté de Paris

PostSubject: Re: SPARK2 and Irrlicht trouble   Tue Feb 05, 2013 1:15 pm

For this warning to vanish you have to set all CMake variable that store information about Irrlicht: SPARK_IRRLICHT_LIB, SPARK_IRRLICHT_LIB_DEBUG, and 2 others. I made this check in order to automatically disable Irrlicht build compilation, as it provoked useless compilation errors for those not compiling with Irrlicht.

The simplest is to use the CMake GUI, when you have generated the script you can set the variables (I advise you to group variables, so relevant ones should be in group 'SPARK').

Then, building SPARK_IRR will automatically build dependencies (core, pugixml).

_________________
Back to top Go down
View user profile
Charlie



Messages : 81
Date d'inscription : 2011-01-28
Age : 34

PostSubject: Re: SPARK2 and Irrlicht trouble   Tue Feb 05, 2013 3:43 pm

Now i was able to build all the dynamic libraries except the irrlicht module.

first i get hundreds of linker errors , so added all the paths/libs manually but there's still one linker error i can't get rid of :


Code:
CSPKParticleSystemNode.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class irr::video::SMaterial irr::video::IdentityMaterial" (__imp_?IdentityMaterial@video@irr@@3VSMaterial@12@A) referenced in function "public: virtual class irr::video::SMaterial & __thiscall irr::scene::ISceneNode::getMaterial(unsigned int)" (?getMaterial@ISceneNode@scene@irr@@UAEAAVSMaterial@video@3@I@Z)


EDIT : Now i added the irrlicht.lib directly in vc++ "Additional Dependancies" list in the SPARK_Irrlicht project and now it seems it works... The strange thing is that i set the filename and the path to irrlicht includes and libs in CMake but no luck , i still must add all the dependancies manually...

I will test now the dlls


EDIT : Still no luck... now it is even worst , i tried to compile my editor with the new libraries (tried both static and dynamic) i got bunch of linker errors.This is how it looks when i compile with static libraries :

Code:
1>SPARK_Irrlicht.lib(SPK_IRR_QuadRenderer.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) protected: __thiscall SPK::Oriented3DRenderBehavior::Oriented3DRenderBehavior(void)" (__imp_??0Oriented3DRenderBehavior@SPK@@IAE@XZ)


EDIT : Finally i setup again (Don't ask how... Very Happy) rebuilded everything (Spark , spark_irr , irrlicht) and now the static libraries seems ok . at least not crashing...


I dont really understand why the original vc++ and codeblocks project files were removed ? Those made the life lot easier... CMake ruined this wonderful engine...
Back to top Go down
View user profile
Darktib
Committer


Messages : 389
Date d'inscription : 2009-07-20
Localisation : A coté de Paris

PostSubject: Re: SPARK2 and Irrlicht trouble   Tue Feb 05, 2013 5:05 pm

???...

How did you install Irrlicht ? Which variables did you set, and with what ?

The CMake script assume the Irrlicht folder hierarchy is left untouched. Script was tested and I personnally use it without problems.

In fact maintaining different project files is demanding. Also, with CMake, automation is possible.

_________________
Back to top Go down
View user profile
Charlie



Messages : 81
Date d'inscription : 2011-01-28
Age : 34

PostSubject: Re: SPARK2 and Irrlicht trouble   Tue Feb 05, 2013 7:02 pm

I FOUND THE PROBLEM ! Since i use my own message handling system i never call device->run()

i have :


Code:
while (SG::SimpleGui::run())
{
    driver->beginScene(true, true, irr::video::SColor(0,0,0,0));
    smgr->drawAll();
    driver->endScene();
   
    sevent = SG::SimpleGui::getEvent(true);
   
  if (sevent.type == SG::SG_WINDOWCLOSE)
      SG::SimpleGui::end(); 

}


instead of :


Code:
while (device->run())
{
    driver->beginScene(true, true, irr::video::SColor(0,0,0,0));
    smgr->drawAll();
    driver->endScene();

    sevent = SG::SimpleGui::getEvent(true);
   
    if (sevent.type == SG::SG_WINDOWCLOSE)
        SG::SimpleGui::end(); 
}


when i started to call device->run() in the main loop , particles become visible...




Still need to dig deeper into CMake

Back to top Go down
View user profile
Juff
Developer


Messages : 539
Date d'inscription : 2009-07-14
Age : 34

PostSubject: Re: SPARK2 and Irrlicht trouble   Wed Feb 06, 2013 7:05 am

So everything is working correctly now ?

CMake is good as it is easier to maintain for us and allows the user to generate a project for the IDE/Compiler he desires. As the project is still under development, it is a good solution for the svn. However when releasing the lib maybe the vs solution will be generated and included to the sdk in addition to cmake conf files as it will be easier for the vs user to get started. Both are not incompatible !
Back to top Go down
View user profile http://spark.developpez.com
Charlie



Messages : 81
Date d'inscription : 2011-01-28
Age : 34

PostSubject: Re: SPARK2 and Irrlicht trouble   Wed Feb 06, 2013 11:35 am

Hi ! Yes now everything works , except i can't link SPARK.lib with pugixml.lib , so i need to add pugixml.lib to my project's depencency list otherwise i got lots of linker errors ,but when i do that it works fine . This is definitely my bad as i'm not an expert on CMake...

And the crash i mentioned in my previous post , probably was a result of SPARK_IRR lib was compiled with older version of Irrlicht , and in the meantime i changed my irrlicht version to a newer (1.8 i think) but didn't recompile the SPARK_IRR (Ergo i used an old static Spark_irr lib with a new irrlicht lib)

Thanks for the help !
Regards
Back to top Go down
View user profile
Darktib
Committer


Messages : 389
Date d'inscription : 2009-07-20
Localisation : A coté de Paris

PostSubject: Re: SPARK2 and Irrlicht trouble   Wed Feb 06, 2013 4:00 pm

Quote :
so i need to add pugixml.lib to my project's depencency list otherwise i got lots of linker errors
Wait... What ? This should be automatic, at least it worked flawlessly on all machines I tested it on.

Quote :
And the crash i mentioned in my previous post , probably was a result of SPARK_IRR lib was compiled with older version of Irrlicht , and in the meantime i changed my irrlicht version to a newer (1.8 i think) but didn't recompile the SPARK_IRR (Ergo i used an old static Spark_irr lib with a new irrlicht lib)
Yep, Irrlicht is changing quite fast, there is no binary compatibility between versions...

_________________
Back to top Go down
View user profile
Charlie



Messages : 81
Date d'inscription : 2011-01-28
Age : 34

PostSubject: Re: SPARK2 and Irrlicht trouble   Wed Feb 06, 2013 6:42 pm

Well for some reason i need to build the project files separately in CMake then compile all the libs separately (spark core , glew , pugixml) but thats not a big problem i can live with it.
I will have more spare time weekend so i will make some tests , but i'm pretty sure i'm doing something wrong...

Thanks for everyone.
Back to top Go down
View user profile
Juff
Developer


Messages : 539
Date d'inscription : 2009-07-14
Age : 34

PostSubject: Re: SPARK2 and Irrlicht trouble   Fri Feb 08, 2013 6:35 am

It is the normal behavior to link all the static lib dependencies in your project. However in Visual Studio there is an option to embed dependencies in a static lib... What is your lib design ? You want to build your application with all the libs linked statically or make a big dll containing all the libs and use it within your application ?
Back to top Go down
View user profile http://spark.developpez.com
Charlie



Messages : 81
Date d'inscription : 2011-01-28
Age : 34

PostSubject: Re: SPARK2 and Irrlicht trouble   Fri Mar 01, 2013 8:45 am

Hi im using separate lib's (SPARK.lib , SPARK_IRR.lib and pugixml.lib) I thought that the pugixml.lib should be compiled automatically at SPARK.lib compilation . and link them atomatically at SPARK.lib linking , but like i said everything works fine except this little thingy... not big problem at all.


And one more thing :

SPK_IRR_LineRenderer.h is not included in SPARK_IRR.h so the line renderer is missing...


Back to top Go down
View user profile
Darktib
Committer


Messages : 389
Date d'inscription : 2009-07-20
Localisation : A coté de Paris

PostSubject: Re: SPARK2 and Irrlicht trouble   Fri Mar 01, 2013 2:40 pm

I don't understand why the dependency is not automatically built... Will investigate if possible.

For the Line renderer: thank you for the report Smile

_________________
Back to top Go down
View user profile
Darktib
Committer


Messages : 389
Date d'inscription : 2009-07-20
Localisation : A coté de Paris

PostSubject: Re: SPARK2 and Irrlicht trouble   Sun Mar 03, 2013 6:27 am

I found why PugiXML was not automatically compiled on your system. It should be fixed on the svn now.

_________________
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: SPARK2 and Irrlicht trouble   Today at 3:40 am

Back to top Go down
 
SPARK2 and Irrlicht trouble
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» gonçalo amaral in trouble *UPDATE - LIBEL TRIAL POSTPONED*
» Sonic the Hedgehog: Triple Trouble (3DS vc) review
» trouble walking or moving with migraine
» Trouble Swallowing
» Trouble Swallowing Pills????

Permissions in this forum:You cannot reply to topics in this forum
 :: English Forum :: Questions (en)-
Jump to: