THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2006 at 10:38, xxxxxxxx wrote:
Hi,
that look's pretty okay. The problem in the first post was probably that you initialized the VPS class with Mobjects.
Q1:
bd->LineZOffset()

Q2:
You have to get the deform cache with op->GetDeformCache() that should not be NULL. If you have a Object inside a HN generator ( deformed or not ), things get very very messy. Then you have to retrieve the HN Cache for just the single object you want to highlight. Fortunately there are some helper functions for this in lib_sds.h
In Addition to that here is some code of mine which might be helpfull
/*
get objects of interest according to the edit mode ( Isoline SDS and/or Deformed )
Provided that the corresponding edit mode options are set...
opEdit returns either the DeformCache of op, or an Object from the Cache of the SDSObject if any is avaiable
opSDS returns the parent SDS object of object op, if such is avaiable.
.. if edit mode stuff is disabled, this function should return the original object in opEdit
opEdit should only be NULL if somehow the deformed object mismatches
*/
void GetEditStateStuff( LONG editstate, LONG displayfilter, PolygonObject* op, SDSObject* &opSDS;, PolygonObject* &opEdit; );
inline void GetEditStateStuff( BaseDraw* bd, PolygonObject* op, SDSObject* &opSDS;, PolygonObject* &opEdit; ) {
GetEditStateStuff( bd->GetEditState(), bd->GetDisplayFilter(), op, opSDS, opEdit );
}
void GetEditStateStuff( LONG editstate, LONG displayfilter, PolygonObject* op, SDSObject* &opSDS;, PolygonObject* &opEdit; )
{
opEdit = NULL;
opSDS = NULL;
if( (editstate&DISPLAY;_EDITSTATE_SDS) && (displayfilter&DISPLAYFILTER;_SDS) )
{
opEdit = (PolygonObject* )op->GetEditObject((BaseObject** )&opSDS;,DISPLAY_EDITSTATE_SDS);
if(opEdit && opSDS && opSDS->GetDivision(op)<=0 ) { opSDS=NULL; opEdit=NULL; }
if(opEdit && (opEdit->GetPointCount()<=0 || opEdit->GetPolygonCount()<=0) ) { opSDS=NULL; opEdit=NULL; }
}
if( (editstate&DISPLAY;_EDITSTATE_DEFORM) && opEdit==NULL && op->GetDeformCache())
{
opEdit=ToPoly( op->GetDeformCache() );
}
if( op && op->GetDeformCache() && opEdit )
{
PolygonObject* def = ToPoly( op->GetDeformCache() );
if( !(def->GetPointCount()==op->GetPointCount() && def->GetPolygonCount()==op->GetPolygonCount())) { opEdit=NULL; }
}
else if( !opEdit )
{
opEdit = op;
}
}
// here is how i draw subdivided edges
void DrawMarkedSdsEdges( BaseSelect* sel, PolygonObject* op, PolygonObject* opSubdiv, SDSObject* opSDS, BaseDraw* bd )
{
if( sel->GetCount()<=0 ) return;
const CPolygon *polyEd=opSubdiv->GetPolygon();
const Vector *vertEd=opSubdiv->GetPoint();
Bool ngonsubdiv;
LONG *polymap,maskcnt;
SDSSubdivisionMask* sdsmask = ((SDSObject* )opSDS)->GetSubdivisionMask(op,maskcnt,polymap,ngonsubdiv);
if( sdsmask!=NULL )
{
BaseSelectIterator seliter( sel );
while( seliter )
{
LONG edid = seliter.Get();
LONG pid0 = edid>>2;
GeAssert( sdsmask[polymap[pid0]].p==pid0 );
for( LONG sdspid=polymap[pid0]; sdspid<maskcnt; ++sdspid )
{
SDSSubdivisionMask* s = sdsmask + sdspid;
if( s->p!=pid0 ) break;
LONG a,b;
if( s->e1==edid )
{
SideAB( 0, polyEd + sdspid, a, b );
bd->LineNew( vertEd[a], vertEd **, 0 );
}
if( s->e2==edid )
{
SideAB( 1, polyEd + sdspid, a, b );
bd->LineNew( vertEd[a], vertEd **, 0 );
}
if( s->e3==edid )
{
SideAB( 2, polyEd + sdspid, a, b );
bd->LineNew( vertEd[a], vertEd **, 0 );
}
if( s->e4==edid )
{
SideAB( 3, polyEd + sdspid, a, b );
bd->LineNew( vertEd[a], vertEd **, 0 );
}
}
++seliter;
}
}
}
// and polys
void DrawSdsPolygonSelection( BaseSelect* sel, PolygonObject* op, PolygonObject* opSubdiv, SDSObject* opSDS, BaseDraw* bd, const Vector &col; )
{
if( sel->GetCount()<=0 ) return;
const CPolygon *polyEd=opSubdiv->GetPolygon();
const Vector *vertEd=opSubdiv->GetPoint();
Vector f[] = { col,col,col,col };
Bool ngonsubdiv;
LONG *polymap,maskcnt;
SDSSubdivisionMask* sdsmask = ((SDSObject* )opSDS)->GetSubdivisionMask(op,maskcnt,polymap,ngonsubdiv);
if( sdsmask!=NULL )
{
BaseSelectIterator seliter( sel );
while( seliter )
{
const LONG pid = seliter.Get();
for( LONG sdspid=polymap[pid]; sdspid<maskcnt; ++sdspid )
{
SDSSubdivisionMask* s = sdsmask + sdspid;
if( s->p!=pid ) break;
const CPolygon* pp = polyEd + sdspid;
Vector p[] = { vertEd[pp->a], vertEd[pp->b], vertEd[pp->c], vertEd[pp->d] };
bd->PolygonNew( p, f, pp->c!=pp->d );
}
++seliter;
}
}
}
okay.. that might be a bit messy but i hope it helps.
Just on a personal note. I think it's a bad idea to initialize the viewport select class on every draw. On my system it an easily take serveral 100 ms up to a sec, according to the number of polys.
So what you usually do is check if something of interest changed, and only then free and reallocate the viewport select. Best place to do this probably Draw() or GetCursorInfo().. Be Warned that the scene can change between calls to GetCursorInfo() and Draw().
Afik this is also the way all the tools in Cinema work.