Particle System Editor & C++ [Resolved]

Return to Compiling or Editing the Panda Source

Particle System Editor & C++ [Resolved]

Postby Beau » Wed Feb 01, 2012 11:11 pm

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
Code: Select all
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++
Code: Select all
((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
Code: Select all
class ColorInterpolationManager : public ReferenceCount

becomes
Code: Select all
class EXPCL_PANDAPHYSICS ColorInterpolationManager : public ReferenceCount


Build
Code: Select all
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.
Code: Select all
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::less<PandaNode::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!
Last edited by Beau on Thu Feb 02, 2012 4:32 pm, edited 1 time in total.
User avatar
Beau
 
Posts: 4
Joined: Wed Feb 01, 2012 10:34 pm

Postby drwr » Thu Feb 02, 2012 9:31 am

You need to copy not just the new libpandaphysics_d.dll, but also the new libpanda_d.dll, and any other dll's for that matter. Copying just a single dll out of a build is asking for trouble.

David
drwr
 
Posts: 11425
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Beau » Thu Feb 02, 2012 4:31 pm

You need to copy not just the new libpandaphysics_d.dll, but also the new libpanda_d.dll, and any other dll's for that matter. Copying just a single dll out of a build is asking for trouble.


:? OK - I was trying to expediate the time taken to do a build... I arrived at the above solution after spending a few hours trouble shooting.

After:
Code: Select all
makepanda\makepanda.bat --optimize 1 --outputdir panda3d-1.7.2-debug --verbose --use-python --use-direct --use-gl --no-gles --no-gles2 --no-dx8 --use-dx9 --no-tinydisplay --use-nvidiacg --no-egl --use-openal --use-fmodex --no-ffmpeg --no-ode --use-physx --use-zlib --use-png --use-jpeg --use-tiff --no-squish --use-freetype --no-maya6 --no-maya65 --no-maya7 --no-maya8 --no-maya85 --no-maya2008 --no-maya2009 --no-maya2010 --no-maya2011 --no-max6 --no-max7 --no-max8 --no-max9 --no-max2009 --no-max2010 --no-max2011 --no-fcollada --no-vrpn --use-openssl --use-fftw --no-swscale --no-artoolkit --no-opencv --no-directcam --no-npapi --no-awesomium --no-gtk2 --no-wx --no-osmesa --no-x11 --no-xf86dga --no-xrandr --no-xcursor --no-pandatool --no-pview --no-deploytools --use-contrib

Everything works fine - thank you good sir! :D
User avatar
Beau
 
Posts: 4
Joined: Wed Feb 01, 2012 10:34 pm


Return to Compiling or Editing the Panda Source

Who is online

Users browsing this forum: No registered users and 0 guests