updated question below
ok i’ve loaded the particles… however i can’t find the C++ equivalent for ParticleEffects, and EnableParticles(), so the particles do not show up! Can somebody help me?
editted my post because i changed my question
To find the C++ equivalent of a Python method, it’s often best to look at the code of the Python method in question and see what it is doing. From ShowBase.py:
def enableParticles(self): if not self.particleMgrEnabled: self.particleMgrEnabled = 1 self.physicsMgrEnabled = 1 self.taskMgr.remove('manager-update') self.taskMgr.add(self.updateManagers, 'manager-update')
So, enableParticles is starting a task to call base.updateManagers every frame. That method:
def updateManagers(self, state): dt = globalClock.getDt() if (self.particleMgrEnabled == 1): self.particleMgr.doParticles(dt) if (self.physicsMgrEnabled == 1): self.physicsMgr.doPhysics(dt) return Task.cont
So, it follows that base.enableParticles() really just means ensure that ParticleManager::do_particles() and PhysicsManager::do_physics() are called every frame. You’ll have to do the equivalent in your C++ code.
ParticleEffect is a Python wrapper around the C++ Particles class. It’s mainly a Python convenience; it includes code to read the parameters from a text file and apply them to the Particles object(s) inside it. You can easily read it at direct/src/particles/ParticleEffect.py. To duplicate its functionality in C++, you’ll have to create the Particles instances and initialize their parameters yourself.
cool i’ve managed to render the particles… however the physics are not working (i’ve added the linear forces)… i even tried using physics manager but it does nothing either
besides i’m also unable to attach the particles to a nodepath and move the particles location. in fact i accidentally created a motion blur effect for the particles.
particlesystem->set_render_parent(actornode); //got a motion blur effect of the particles when i move my actor, however the particles are still not moving together.
LVecBase3f force4(0,0,1); linearvectorforce = new LinearVectorForce(force4, 20.0000, 0); linearvectorforce->set_active(1); particlesystem->add_linear_force((LinearVectorForce*)linearvectorforce); linearnoiseforce = new LinearNoiseForce(1.0000, 0); linearnoiseforce->set_active(1); particlesystem->add_linear_force((LinearNoiseForce*)linearnoiseforce);
and i attached my particlesystem
and i run
did i miss out any anything for the physics? and how do i move my particle nodes
sorry i do not like to bump posts (esp its still in the first page) but i really need help in this asap
basically i need to relocate the particle instead of (0,0,0)
from the python code:
self.p = ParticleEffect() self.p.setPos(3.000, 0.000, 2.250) self.p.setHpr(0.000, 0.000, 0.000) self.p.setScale(1.000, 1.000, 1.000) //particle code self.p.addParticles(p0)
and addParticles() does this
particles.nodePath.reparentTo(self) self.particlesDict[particles.getName()] = particles
however since the C++ particlesystem does not contain a ParticleEffect class, i’ve been guessing which nodepath allows me to relocate the particles elsewhere. However, in the end, my particles are still stuck in 0,0
I’m not that familiar with the particle system myself, but again I counsel reading the Python code. In ParticleEffect.py, we see that p0 is an object of type Particles, which is found in direct/src/particles/Particles.py. This object contains the lines:
self.node = PhysicalNode(self.name) self.nodePath = NodePath(self.node)
So, it follows that p0.nodePath is the NodePath to the PhysicalNode created for the particle system. Have you got a PhysicalNode? This is the piece that hooks into Panda’s low-level physics system.
hey thanks for replying,
yes, i can get the physical nodepath through “get_physical_node_path()”, i tried converting the physical nodepath to a nodepath by
nodepath temp = particlesystem->get_physical_node_path()
which still doesn’t work too
i have also tried to adjust the physical nodepath itself. Still i can’t relocate the particles.
I’m not sure what exactly you want to relocate (and I’m not familiar with the c++ side of Panda), but maybe here’s a hint. I had the same problem with relocating the whole particle effect until I found out that there is two parents for the ParticelEffect: parent and renderParent.
Try playing around with these two. In Python you can set them in ParticleEffect’s start() method.
Maybe there is something like set_parent() in addition to set_render_parent() for c++.
Good luck, Christof.
Hi, thank you for helping out.
Yes I found out there are 2 nodepaths in the particles class. The problem is while the render_parent nodepath is for rendering, the only other one available is a physical nodepath. I’ve been trying to shift from this nodepath. Still no.
One thing I realized is, the is_empty() of the physical nodepath is true, thus giving me an error when i try to set position. So I thought the nodepath is not initialized. I’ve been trying to initialize it but still no. There is no function like set_nodepath of that sort.
Well I guess there’s no way we can implement it anymore, because we only have a few days more. Thanks everyone:).
we just managed to move the particles yay!
for some reason, it was set_position(0,0,0) then do_particles
THEN set_position(your position) AGAIN…
set_position twice… weird, but well it worked, that’s good enough
the physics is still not working, but there’s no time to do that, well thanks anyway