[Bf-committers] Python new particle system module

Cédric PAILLE cedricpaille at gmail.com
Thu Jun 26 14:30:06 CEST 2008


Hi,

I need help with the particle module, the Python module works quite well
now, but I'd like to export hairs with render parameters.

Here is the code I use to export:
___

        hairstep = 1.0/pow(2.0,(float)psys->part->ren_step);

        partlist = PyList_New( 0 );
        if( !partlist )
            return EXPP_ReturnPyObjError( PyExc_MemoryError, "PyList()
failed" );

        for (i = 0; i < psys->totpart + psys->totchild; i++){
            seglist = PyList_New( 0 );
            for (l = 0.0; l < 1.0; l += hairstep){
                state.time = l;
                psys_get_particle_on_path(ob,psys,i,&state,1);
                loc = PyTuple_New(3);
                PyTuple_SetItem(loc,0,PyFloat_FromDouble((double)state.co
[0]));
                PyTuple_SetItem(loc,1,PyFloat_FromDouble((double)state.co
[1]));
                PyTuple_SetItem(loc,2,PyFloat_FromDouble((double)state.co
[2]));

                if ( (PyList_Append(seglist,loc) < 0) ){
                    Py_DECREF(seglist);
                    Py_DECREF(partlist);
                    Py_XDECREF(loc);
                    return EXPP_ReturnPyObjError( PyExc_RuntimeError,
                        "Couldn't append item to PyList" );
                }
                Py_DECREF(loc); /* PyList_Append increfs */
            }
            if ( PyList_Append(partlist,seglist) < 0){
                Py_DECREF(partlist);
                Py_XDECREF(loc);
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
                        "Couldn't append item to PyList" );
            }
            Py_DECREF(seglist);

        }

___

But I don't get the amount of childs defined for rendering, only for
interactive view.

Could you help me with this ?

Cheers.

Cedric PAILLE.

2008/2/11 Janne Karhu <jhkarh at utu.fi>:

> Sure,
>
> the basic way (i.e. should give correct result in most cases) to get a
> particle's location (child or actual particle) is
> psys_get_particle_state(...) in particle.c. You can probably look at the
> places where it's used to figure out how it works. It should also work for
> hair particles, but with the simplification that hair particle's life is
> always from frame 1 (or zero, don't remember right now) to frame 100.
>
> Cheers,
>
> Janne.
>
>
> On Mon, 11 Feb 2008 13:09:34 +0200, Cédric PAILLE <cedricpaille at gmail.com>
> wrote:
>
> > Hi,
> >
> > I understand that, but, can you tell me, roughly how to get particles
> > loc ?
> > I need it for my exporter, at least for making some tests.
> >
> > Cheers.
> >
> > 2008/2/11, Janne Karhu <jhkarh at utu.fi>:
> >>
> >> Hi Cédric,
> >>
> >> atleast at some point during the physics sprint it was decided that the
> >> new particles would be in the first release without any python
> >> connections. There are a lot of new things to consider and afterwards
> >> probably many many more things will be possible through python compared
> >> to
> >> the old system. The first priority is to get everything working properly
> >> in the internal code, after that python can start poking around :) I
> >> realize that this will make some old scripts non-functional for the
> >> release, but as a perfect conversion from the old particle system is
> >> impossible even without python scripts in the system I don't think it's
> >> a
> >> big difference.
> >>
> >> Janne
> >>
> >>
> >> On Fri, 08 Feb 2008 23:18:13 +0200, Cédric PAILLE
> >> <cedricpaille at gmail.com>
> >> wrote:
> >>
> >> > Hi all,
> >> >
> >> > At first, please excuse my poor englsh, I'm new to the mailing list.
> >> >
> >> > I was waiting since it's in the SVN for the new particle system python
> >> > module, but it seems that nobody's working on it...
> >> > So I've beginned to write it myself.
> >> >
> >> > It's almost finished, right now, but I need some pointers to code a
> >> > function
> >> > similar to the old getParticlesLoc() of the effect module.
> >> >
> >> > Can somebody tell me how to get the particles location and hair
> >> segments
> >> > ?
> >> >
> >> > I've tried to look at the "draw_object.c", but it's hard to
> >> understand.
> >> >
> >> > Hair drawing seems to use the particle cache, and particle uses a
> >> > function
> >> > to retrieve the location.
> >> >
> >> > Last question : Are you interested to integate it in the SVN ?
> >> >
> >> > Cheers.
> >> >
> >>
> >>
> >> _______________________________________________
> >> Bf-committers mailing list
> >> Bf-committers at blender.org
> >> http://lists.blender.org/mailman/listinfo/bf-committers
> >>
> >
> >
> >
>
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>



-- 
Cedric PAILLE.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-committers/attachments/20080626/e7d03bc2/attachment.htm 


More information about the Bf-committers mailing list