Do anyone of you know how to use the ‘new’ callback function to get it working with nitrous driver?
All I find is:
virtual [void]( http://help.autodesk.com/cloudhelp/2015/ENU/Max-SDK/cpp_ref/maxheapdirect_8h.html#a384e1a581a8ed72444b54add6242c59f) [RegisterRedrawViewsCallback]( http://help.autodesk.com/cloudhelp/2015/ENU/Max-SDK/cpp_ref/class_interface.html#aff07f7fc451ca5121d8748d8e363795b) ([RedrawViewsCallback]( http://help.autodesk.com/cloudhelp/2015/ENU/Max-SDK/cpp_ref/class_redraw_views_callback.html) *cb)=0
And from what I have now is this:
void RegisterRedrawViewsCallback (RedrawViewsCallback *cb)
{
debug->debugDrawWorld();
}
The function i call is a function from another class I have instantiated.
It does not get triggered… Has anyone of you use this?
I have to admit callback functions are new to me in c++, I’ve used them before in C# and such.
just clicked on the link for RedrawViewsCallback and it took me to the worst api help page I think I’ve ever seen (And I’ve been working with max since version 1), who the fuck is in charge of this crap at Autodesk? absolutely hopeless !
you shouldn’t create your own RegisterRedrawViewsCallback function just your own RedrawViewsCallback object and pass it to the interface function…
something like this…
// create a class
class mycallbackclass : public RedrawViewsCallback
{
public:
~mycallback() {}
void proc(Interface *ip)
{
// do something useful
}
};
// create an instance
static mycallbackclass mycallbackobj;
// register it usually in the plugin constructor
ip->RegisterRedrawViewsCallback(&mycallbackobj);
btw theres an example of it being used in PolygonCount sample in the sdk [b]\maxsdk\samples\utilities\PolygonCount
[/b]
// Get redraw views callbacks
class PolyCountCallback: public RedrawViewsCallback
{
void proc(Interface *ip);
};
// Count the polygons and dislpay the bar graph after every redraw views
void
PolyCountCallback::proc(Interface* ip)
{
InitFaceCount();
CountFaces(ip);
thePolyCounter.DrawBars();
}
PolyCountCallback pccb;
void
PolygonCounter::Init()
{
ip->RegisterRedrawViewsCallback(&pccb);
}
void
PolygonCounter::End()
{
ip->UnRegisterRedrawViewsCallback(&pccb);
}
Thank you so much Klunk! that did the trick!
That triggers now when it’s needed.
And thanks for the great explanation on how to do this.
I have also a small problem with polyline method. I works fine most of the time, but sometimes for some reason it draws my lines always on top, I can’t even reproduce this situation, it happened 2 or 3 times. Is there some kind of parameter like onTop = TRUE / FALSE? I can’t find anything in the documentation.
you probably need to set the correct render limits with GW_Z_BUFFER
like so…
DWORD rlim = gw->getRndLimits();
DWORD rl = GW_WIREFRAME | GW_EDGES_ONLY | (rlim & GW_Z_BUFFER);
gw->setRndLimits(rl);
Ok, I will add this and see if the problems appears or not, thanks a lot.
Unfortunately it didn’t help, but now I know when the problem appears – the “draw on top” occurs when I press “7” to show statistics:
if you show your plugins display function we could maybe find a solution otherwise it’s just in the dark guess work
This is it:
class myDrawGrid : public RedrawViewsCallback
{
public:
myPlugin* mod;
~myDrawGrid() {}
myDrawGrid() {}
void proc(Interface *ip)
{
ViewExp &vpt = ip->GetActiveViewExp();
GraphicsWindow *gw = vpt.getGW();
DWORD rlim = gw->getRndLimits();
DWORD rl = GW_WIREFRAME | GW_EDGES_ONLY | (rlim & GW_Z_BUFFER);
gw->setRndLimits(rl);
/*
a few loops drawing the grid with only setColor and polyline called this way:
gw->setColor(LINE_COLOR, Point3(1.0f, 0.0f, 0.0f));
gw->polyline(2, points, NULL, NULL, 0, NULL);
*/
gw->enlargeUpdateRect(NULL);
gw->updateScreen();
}
};
what happens when you try this ?
class myDrawGrid : public RedrawViewsCallback
{
public:
myPlugin* mod;
~myDrawGrid() {}
myDrawGrid() {}
void proc(Interface *ip)
{
ViewExp &vpt = ip->GetActiveViewExp();
GraphicsWindow *gw = vpt.getGW();
DWORD rlim = gw->getRndLimits();
DWORD rl = GW_WIREFRAME | GW_EDGES_ONLY | (rlim & GW_Z_BUFFER);
gw->setRndLimits(rl);
/*
a few loops drawing the grid with only setColor and polyline called this way:
gw->setColor(LINE_COLOR, Point3(1.0f, 0.0f, 0.0f));
gw->polyline(2, points, NULL, NULL, 0, NULL);
*/
gw->setRndLimits(rlim);
gw->enlargeUpdateRect(NULL);
gw->updateScreen();
}
};