HDK version of HScript primuv()

   4489   8   0
User Avatar
Member
398 posts
Joined: July 2005
Offline
Hello,

Is anyone knows how to achieve (within the HDK) the same functionality which HScript expression function primuv() has?
There is a method from GEO_Primitive class:


virtual bool evaluateInteriorPoint(GEO_Vertex &result, GEO_AttributeHandleList &hlist, fpreal u, fpreal v) const;


It looks like what I'm looking for but I'm not sure how to deal with GEO_AttributeHandleList &hlist.
Is it the object that determines which attributes to sample, how to interpolate them etc? How shall I initialize it?

For instance:


const GEO_Primitive *ppr;
GEO_Point *ppt;
GEO_Vertex result;
GEO_AttributeHandleList hlist;
UT_Vector4 pos;
float u = 0.0f;
float v = 0.0f;

hlist.bindDetail(gdp); // Not sure should I do this
hlist.appendAllAttributes(GEO_POINT_DICT);
ppr->evaluateInteriorPoint(result, hlist, u, v);
ppt = result.getPt(); // This is only for a test purposes I'd rather sample something else than P


In my case ppt is always zero that means ppr->evaluateInteriorPoint(result, hlist, u, v) call fails?
Any suggestions?

Cheers,
-O
f = conserve . diffuse . advect . add

fx td @ the mill
User Avatar
Member
7709 posts
Joined: July 2005
Offline
I think primuv() uses evaluatePoint(). In anycase, you do need to call bindDetail(). After calling evaluatePoint(), you can obtain your value with something like this:
hlist.setElement(result);
value = hlist->getF(component_idx);
User Avatar
Member
398 posts
Joined: July 2005
Offline
Thanks Edward!
Unfortunately I can't get proper result with such snippet
hlist.bindDetail(gdp);
hlist.appendAllAttributes(GEO_POINT_DICT);
ppr->evaluatePoint(*vtx, hlist, u, v);
hlist.setElement(vtx);

pos = hlist->getV4();
mapu = hlist->getF(0);
mapv = hlist->getF(1);

gdp is fine, ppr is fine, simpler form of evaluatePoint() returns a proper P, vtx pointer isn't zero, hlist isn't zero, hlist isn't zero, hlist.entries() gives me exactly the same number of attributes + 1 (is it because P automatically counts as attribute?), hlist always gives me zero so everything looks okay.
But pos, mapu, mapv (and others) are always zero. What I'm doing wrong?
f = conserve . diffuse . advect . add

fx td @ the mill
User Avatar
Member
7709 posts
Joined: July 2005
Offline
I'm not understanding. What/how is it not working? If hlist is NULL, then it's because that attribute doesn't exist.
User Avatar
Member
398 posts
Joined: July 2005
Offline
edward
I'm not understanding. What/how is it not working? If hlist is NULL, then it's because that attribute doesn't exist.

Accordingly to this test attributes exist:
for(int i = 0; i < hlist.entries(); i++)
{
cout << “Name: ” << hlist->getName() << endl;
}

Result is:
Name: P
Name: uv
Name: tmap
Name: N

I have not zero pointers but zero values:

Attribute = Pointer = value
hlist = 0x333c3f0 =


Which is wrong. All values have to be more interesting.
So hlist->getF(0) && hlist->getF(1) should have non zero values (not only zero values like now)
f = conserve . diffuse . advect . add

fx td @ the mill
User Avatar
Member
7709 posts
Joined: July 2005
Offline
Well, you're not doing everything that support replied … like using GEO_WorkVertexBuffer.
User Avatar
Member
398 posts
Joined: July 2005
Offline
I was using
vtx = new GEO_Vertex();
Is it make any difference to temporary vertex buffer?
Anyway… With GEO_WorkVertexBuffer:
GEO_WorkVertexBuffer vbuffer(gdp);
hlist.bindDetail(ground);
hlist.appendAllAttributes(GEO_POINT_DICT);
/*
There is no method GEO_WorkVertexBuffer::getVertex()
nor GEO_WorkVertexBuffer::getVertex(void)
only GEO_WorkVertexBuffer::getVertex(int idx, GEO_Point *pt = 0)
*/
vtx = vbuffer.getVertex(0); // vbuffer.getVertex(0, ppt) has same effect
ppt = vtx->getPt(); // Not sure why do we need it because we never use it
ppr->evaluatePoint(*vtx, hlist, u, v);
hlist.setElement(vtx);

This code crashes.
f = conserve . diffuse . advect . add

fx td @ the mill
User Avatar
Member
398 posts
Joined: July 2005
Offline
Opps… At least I know why it crashes ops:
f = conserve . diffuse . advect . add

fx td @ the mill
User Avatar
Member
398 posts
Joined: July 2005
Offline
Cool it works. Thanks for patience Edward!
f = conserve . diffuse . advect . add

fx td @ the mill
  • Quick Links