Jump to content


michaelw

Member Since 22 Dec 2011
Offline Last Active Jun 05 2013 11:30 AM
-----

Topics I've Started

OpenVDB, buildFromGrid doesn't work?

21 March 2013 - 08:09 AM

hi there, I'm playing around the vdb with houdini but I noticed it doesn't work very well. For example, I tried to convert a grid to a VDB primitive as below:



openvdb::FloatGrid::Ptr sphere_grid = openvdb::tools::createLevelSetSphere<openvdb::FloatGrid>(50.0, openvdb::Vec3f(1.5, 2, 3),0.5,4.0);

sphere_grid->insertMeta("radius", openvdb::FloatMetadata(50.0));

sphere_grid->setName("LevelSetSphere");

GU_PrimVDB* vdb_ptr = GU_PrimVDB::buildFromGrid(*gdp, sphere_grid);

but I got the following error message:
error: ‘buildFromGrid’ is not a member of ‘GU_PrimVDB’

I don't understand this error because I already followed the guide from GU_PrimVDB.h
00103 // NOTE: For static member functions please call in the following
00104 // manner. <ptrvalue> = GU_PrimVDB::<functname>
00105 // i.e. partptr = GU_PrimVDB::build(params...);

Anyone succeeded in using the "buildFromGrid" method? I was also wondering when will houdini ships the header files of the OpenVDB library.

P.S  it would be nice to see some HDK examples with OpenVDB :)

Thanks,

GU_Cookie, how to use it?

21 December 2012 - 10:55 AM

hi there,

I tried to play around with hdk cookie (GU_Cookie) but it messed up. Basically I did these things in my code:

1. merge in input A and input B
2. create primitive and point groups for both inputs
3. call setGroups to setup groups
4. call cookie for the cookie operation

With my understanding, the output should be in those [in/out/overlap] groups that I can check. But when I used two spheres for testing, the result is totally wrong.

Anyone could give me a hint what I did wrong here?


GU_Detail* input_geo0 = (GU_Detail *) inputGeo(0);
GU_Detail* input_geo1 = (GU_Detail *) inputGeo(1);

GA_PrimitiveGroup* pr_a = input_geo0->newPrimitiveGroup("pr_a");
GA_PrimitiveGroup* pr_b = input_geo1->newPrimitiveGroup("pr_b");

GA_PointGroup* pt_a = input_geo0->newPointGroup("pt_a");
GA_PointGroup* pt_b = input_geo1->newPointGroup("pt_b");

for (GA_Iterator it(input_geo0->getPrimitiveRange()); !it.atEnd(); it.advance())
{
GA_Offset offset = it.getOffset();
pr_a->addOffset(offset);
}

for (GA_Iterator it(input_geo1->getPrimitiveRange()); !it.atEnd(); it.advance())
{
GA_Offset offset = it.getOffset();
pr_b->addOffset(offset);
}

for (GA_Iterator it(input_geo0->getPointRange()); !it.atEnd(); it.advance())
{
GA_Offset offset = it.getOffset();
pt_a->addOffset(offset);
}

for (GA_Iterator it(input_geo1->getPointRange()); !it.atEnd(); it.advance())
{
GA_Offset offset = it.getOffset();
pt_b->addOffset(offset);
}





gdp -> merge(* input_geo0);
gdp -> merge(* input_geo1);


GU_Cookie m_cookie;

m_cookie.setGroups(pr_a, pr_b, pt_a, pt_B);

GA_PrimitiveGroup* a_in = gdp->newPrimitiveGroup("a_in");
GA_PrimitiveGroup* a_out = gdp->newPrimitiveGroup("a_out");
GA_PrimitiveGroup* a_overlap = gdp->newPrimitiveGroup("a_overlap");

GA_PrimitiveGroup* b_in = gdp->newPrimitiveGroup("b_in");
GA_PrimitiveGroup* b_out = gdp->newPrimitiveGroup("b_out");
GA_PrimitiveGroup* b_overlap = gdp->newPrimitiveGroup("b_overlap");

m_cookie.cookie(*gdp,
0,
*a_in,
*a_out,
*a_overlap,
1,
*b_in,
*b_out,
*b_overlap,
1,
1
	 ); 	

offset understanding

27 November 2012 - 06:43 AM

hi there, I'm still not very sure how Index and Offset works.

With my understanding, if we do this:

 	 duplicateSource(0,context);

the "gdp" should always have the offset continuous at very beginning (matching "index"), and if we delete some points or primitives later, the offset should be the same but the index will be re-ordered to be continuous.

But this is not always the case. Here is one example confusing me for sometime:

drop down a simple "box" SOP and then a "divide" SOP. Use "bricker polygons" option to divide it into a little more dense grid. In my case, I set them as "0.4, 0.4, 0.4".
after this, append a very simple node I made to check for point offset, point index, primitive offset, primitive index.

in this case: "point offset" matches "point index", both of them are continuous. but "primitive offset" doesn't match "primitive index".

Attached File  nodes.png   9.07K   1 downloadsAttached File  pr.png   10.03K   1 downloadsAttached File  pt.png   7.78K   1 downloads

So can anyone explain how "offset" works internally in hdk? Could I say if I create a new gdp and use "appendOffset()", the offset numbers are continuous?

Thanks,