The Panda3d Particle editor (Sample Programs -> Particles -> Particle Panel) appears to be Python only.
The I/O file format of the editor is a Python text file that is read by ParticleEffect.py via loadConfig()
[pandaDir]/direct/src/particles/ParticleEffect.py does not appear to have a C++ equivalent.
This is understandable as this program saves Python code as text and reinjects & executes the python code at load time.
All other backend particle system code appears to exist in C++.
To get around this problem, I am attempting to hand convert Python code generated by the editor to C++.
The particle system I am trying to convert contains a reference to the color interpolation manager.
ie.
Particle editor Python
p1.renderer.getColorInterpolationManager().addLinear(0.0,0.8000000,Vec4(1.0,0.0,0.0,0.0),Vec4(1.0,0.0,0.0,1.0),1)
p1.renderer.getColorInterpolationManager().addLinear(0.5,1.0,Vec4(1.0,0.0,0.0,1.0),Vec4(1.0,0.0,0.0,0.0),1)
becomes C++
((SpriteParticleRenderer *)m_pRenderer.p())->get_color_interpolation_manager()->add_linear(0.0, 0.8f, Colorf(1, 0, 0, 0), Colorf(1, 0, 0, 1), true );
((SpriteParticleRenderer *)m_pRenderer.p())->get_color_interpolation_manager()->add_linear(0.5, 1.0f, Colorf(1, 0, 0, 1), Colorf(1, 0, 0, 0), true );
Attempting to compile this code gives a linker error.
Tracing the problem back, this is because the ColorInterpolationManager class is not exposed to libpandaphysics.
As a work around, I attempted to expose the ColorInterpolationManager to the libpandaphysics DLL.
ie.
[pandaDir]/src/particlesystem/colorInterpolationManager.h
class ColorInterpolationManager : public ReferenceCount
becomes
class EXPCL_PANDAPHYSICS ColorInterpolationManager : public ReferenceCount
Build
makepanda\makepanda.bat --verbose --optimize 1 --nothing --outputdir panda3d-1.7.2-debug
Copy out generated libpandaphysics files to project directory
lib/libpandaphysics_d.lib
lib/libpandaphysics_d.exp
bin/libpandaphysics_d.map
bin/libpandaphysics_d.pdb
bin/libpandaphysics_d.dll
bin/libpandaphysics_d.dll.manifest
Using this modified DLL, whenever I attempt to instanciate at particle system I get an immediate crash.
Note that this crash occurs before any direct reference to ColorInterpolationManager is made by the particle system.
ie.
PT(ParticleSystem) pParticle = new ParticleSystem();
(stacktrace - Access violation)
libpanda_d.dll!MutexSimpleImpl::try_acquire() Line 53 + 0x3 bytes
libpanda_d.dll!MutexSimpleImpl::acquire() Line 41 + 0x8 bytes
libpanda_d.dll!MutexDirect::acquire() Line 73
libpanda_d.dll!LightMutexHolder::LightMutexHolder(const LightMutex & mutex={…}) Line 27
libpanda_d.dll!CopyOnWritePointer::get_read_pointer() Line 39 + 0x11 bytes
libpanda_d.dll!CopyOnWritePointerTo<CopyOnWriteObj1<ov_set<PandaNode::UpConnection,std::lessPandaNode::UpConnection >,TypeHandle> >::get_read_pointer() Line 285 + 0xc bytes
libpanda_d.dll!PandaNode::CData::get_up() Line 1080 + 0x12 bytes
libpanda_d.dll!PandaNode::do_find_parent(PandaNode * node=0x0033b4b4, const PandaNode::CData * cdata=0x0033bb8c) Line 820 + 0xc bytes
libpanda_d.dll!PandaNode::reparent_one_stage(NodePathComponent * new_parent=0x00d7e608, NodePathComponent * child=0x00d7e824, int sort=0, bool as_stashed=false, int pipeline_stage=0, Thread * current_thread=0x003314bc) Line 3498 + 0x15 bytes
libpanda_d.dll!PandaNode::reparent(NodePathComponent * new_parent=0x00d7e608, NodePathComponent * child=0x00d7e824, int sort=0, bool as_stashed=false, int pipeline_stage=0, Thread * current_thread=0x003314bc) Line 3450 + 0x1e bytes
libpanda_d.dll!NodePath::reparent_to(const NodePath & other={…}, int sort=0, Thread * current_thread=0x003314bc) Line 687 + 0x25 bytes
… snip …
Rolling back to previously built version of the above libpandaphysics files makes the problem goes away.
Questions*
Is there an easy solution to the above problem (more EXPCL_PANDAPHYSICS on dependant and/or Python interopt classes)?
Has anyone else had reasonable success using Panda3D particles with C++ ?
Are there any available tools I haven’t found (eg. A C++ version of the particle system editor) ?
Is there another simple way to do this (launch python to do the load an reflect class back to C++)?
I am using:
Panda3D 1.7.2 source
VS2008 SP1 (Pro)
Windows 7 64bit SP1 (Enterprise)
Project linking to Panda3D compiled with same flags as Panda3D (debug) build ie. /Od /MDd /Zi /RTCs /GS /EHa /Zm300
Any help would be much appreciated!