I tried to add a particle system when a button is pressed.Declared globally
IParticlesystem scenenode and IParticlesystemEmitter. and inside the event system of the gui button i have added the code for the particle system.while running if i press the button,the programmcrashes.Debugger says access violation in line myps->addParticleSystemSceneNode(false);. Otherwise if I make the particles from outside the event in main it works fine.Help please.
particle system crash
yes..i have initialized the emitter global pointer em=0; and particle system*ps=0; But how do we initialize a variable* globally and update it so that it is available to any other function. Should we update it with a function inside the final draw loop?
i am not near the computer in which i wrote the code. I will get it from workplace and post tomorrow.
Thank you for helping
i am not near the computer in which i wrote the code. I will get it from workplace and post tomorrow.
Thank you for helping
scene::IParticleSystemSceneNode* EngPartNode = 0;Saalen wrote:It's a pointer messed up. Please post more code.
EngPartNode = smgr->addParticleSystemSceneNode(false); /*, // defaulte point emmiter
0, // parent
-1, // id
vector3df(1,1,1), // position
vector3df(0,0,0), // rotation
vector3df(1,1,1) // scale
); */
EngPartNode->setPosition(core::vector3df(0,0,0));
EngPartNode->setScale(core::vector3df(1,1,1));
EngPartNode->setParticleSize(core::dimension2d<f32>(10.0f,10.0f));
That is the way im setting up the particle code. I first was just commenting each part of the command to add the node, just so I could get my head wrapped around why it was crashing. Then I took out all the prams and defined the stuff i needed with set commands it still bombs. I have a disassemble of the code that my compiler debug gives you let me post it also and see if we can nail why this is crashing.
EngPartNode = smgr->addParticleSystemSceneNode(false); /*, // defaulte point emmiter
00426438 push 3F800000h
0042643D push 3F800000h
00426442 push 3F800000h
00426447 lea ecx,[ebp-190h]
0042644D call irr::core::vector3d<float>::vector3d<float> (4230B9h)
00426452 mov esi,esp
00426454 push eax
00426455 push 0
00426457 push 0
00426459 push 0
0042645B lea ecx,[ebp-17Ch]
00426461 call irr::core::vector3d<float>::vector3d<float> (4230B9h)
00426466 push eax
00426467 push 0
00426469 push 0
0042646B push 0
0042646D lea ecx,[ebp-168h]
00426473 call irr::core::vector3d<float>::vector3d<float> (4230B9h)
00426478 push eax
00426479 push 0FFFFFFFFh
0042647B push 0
0042647D push 0
0042647F mov eax,dword ptr [this]
00426482 mov ecx,dword ptr [eax+558h]
00426488 mov edx,dword ptr [this]
0042648B mov eax,dword ptr [edx+558h]
00426491 mov edx,dword ptr [ecx]
00426493 mov ecx,eax
00426495 call dword ptr [edx+40h]
00426498 cmp esi,esp
0042649A call @ILT+3860(__RTC_CheckEsp) (423F19h)
0042649F mov dword ptr [EngPartNode],eax
0, // parent
-1, // id
vector3df(1,1,1), // position
vector3df(0,0,0), // rotation
vector3df(1,1,1) // scale
); */
EngPartNode->setPosition(core::vector3df(0,0,0));
the pointer where the error is marking 426491 i put it in red and the debug is telling me that ecx is 0.
So ya if thats a pointer it makes sense to crash. But what pointer is it and where should we have defined it.
scene::IParticleSystemSceneNode* EngPartNode = 0; Should have created the pointer. So im really confused. Ill keep working on it.
The compiler would throw me an error if smgr wasnt valid right. I think i have a conflict with the newton enging over the "this" varible in the assemble level.Spintz wrote:That code works fine for me. Are you sure the sceneManager is initialized before calling this? Check the smgr pointer to be sure it's valid?scene::IParticleSystemSceneNode* EngPartNode = 0;
EngPartNode = smgr->addParticleSystemSceneNode(false);
Yep right on the money. My little project has almost 12 classes now and i was in one that arrives before the smgr is declared. So the pointer was not there and thus crash.Spintz wrote:No, the compiler wouldn't throw an error if smgr was not initialized. As long as the smgr pointer is declared ( i.e. ISceneManager* smgr; ) the compiler knows no difference. Actually, if a pointer is NULL or no longer valid, the run-time behavior is undefined.
Thanks.