Jump to content

Example for DOP Particle Data Access


Recommended Posts

Hi,

 

could someone give me a simple code example or a link how to read the particle attributes of a DOP Network?

(especially how can i get the collision data of the particles and an object?)

 

I tried it with deriving my class from SIM_Data, but e.g. the SIM_ElectricalProperties example doesnt help me further.

 

Thanks for your help.

Link to comment
Share on other sites

I've found a way to get access of the particle collision data. Maybe someone tries something similar to do so i post my code here. I have derived my class from DOP_Node.

void DOP_ReadParticles::processObjectsSubclass(fpreal time, int,
	const SIM_ObjectArray &objects,
	DOP_Engine &engine)
{
    for (int i = 0; i < objects.entries(); i++)
    {
        SIM_Object* obj = objects.findObjectById(i);

        SIM_GeometryCopy* geometry = (SIM_GeometryCopy*)obj.getNamedSubData(SIM_GEOMETRY_DATANAME);
        if (geometry)
        {
             GU_DetailHandle  gdh =  geometry->getGeometry().getWriteableCopy();
            const GU_Detail* gdp = gdh.peekDetail();

            GA_ROAttributeRef hituv  = gdp->findPointAttribute("hituv");
            GA_ROHandleV2 h_hituv(hituv.getAttribute());
            if (h_hituv.isValid())
            {
                UT_Vector2F uv;
                for (G A_Iterator it(gdp->getPointRange()); !it.atEnd(); it.advance())
                {
                    UT_Vector2F uv(h_hituv.get(it.getOffset()));
                    // read the UV-hitposition
                    printf("%i hitUV: (%f, %f)\n", it.getIndex(), uv.x(), uv.y());
                }
            }
        }
    }
}
Edited by ClausKleber
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...