THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/04/2007 at 02:11, xxxxxxxx wrote:
If you take the hair video post example and replace the main execute with the code below it should give you a starting point. You can also use the GetFragmentLink call which will access the data directly rather than it copying to an array:
LONG HairSDKVideopost::Execute(PluginVideoPost *node, VideoPostStruct *vps)
{
if (vps->vp==VP_INNER)
{
//HairLibrary hlib;
#define HAIR_RENDER_TYPE 1008
#define HAIR_RENDER_TYPE_RASTER_8BIT 0
if (vps->open)
{
AutoAlloc<BaseBitmap> bmap;
HairVideoPost *hpost=(HairVideoPost* )vps->vd->FindVideoPost(VPhair);
if (hpost)
{
LONG x,y,cnt,i;
Bool bit8=hpost->GetDataInstance()->GetLong(HAIR_RENDER_TYPE)==HAIR_RENDER_TYPE_RASTER_8BIT;
RayParameter *rp=vps->vd->GetRayParameter();
if (bmap->Init(rp->xres,rp->yres))
{
for (y=rp->top;y<=rp->bottom;y++)
{
for (x=rp->left;x<=rp->right;x++)
{
Vector col;
Real trans=1.0;
HairFragment *hf=hpost->GetFragments(x,y,cnt,0);
if (bit8)
{
for (i=0;i<cnt;i++)
{
col+=hf _.col*trans;
trans=trans*hf _.trans;
}
}
else
{
for (i=0;i<cnt;i++)
{
col+=hf _.col*trans*(1.0-hf _.trans);
trans=trans*hf _.trans;
}
}
GeFree(hf);
bmap->SetPixel(x,y,col.x*255,col.y*255,col.z*255);
}
}
}
bmap->Save(Filename("c:\\testme.tiff"),FILTER_TIF,NULL,0);
}
//m_pOldColorHook=hlib.SetHook(vps->doc,HAIR_HOOK_TYPE_SAMPLE_COLOR,(void* )_SampleHairColorHook);
//hlib.SetHook(vps->doc,HAIR_HOOK_TYPE_SAMPLE_TRANS,_SampleHairTransparencyHook);
//hlib.SetHook(vps->doc,HAIR_HOOK_TYPE_SAMPLE_SHADOWS,_SampleShadowBufferHook);
//hlib.SetHook(vps->doc,HAIR_HOOK_TYPE_ILLUMINATE,_IlluminateHook);
}
else
{
//hlib.SetHook(vps->doc,HAIR_HOOK_TYPE_SAMPLE_COLOR,m_pOldColorHook);
}
}
return RAY_OK;
}