Still the same - no lines in my viewport unfortunately…
hmm.
[SDK] issues drawing polyline in viewport
try
DWORD rlim = gw->getRndLimits();
gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL);
// code here
gw->setRndLimits(rlim);
still not anything, drives me nuts.
also tried with hardcoded value just to be sure (drawing from 0,0,0 and out in to space), same thing… hmm.
mxs would be
(
gw.setTransform(Matrix3 1)
gw.Polyline #([0,0,0],[0,0,10]) false
gw.enlargeUpdateRect #whole
gw.updateScreen()
)
so if you are trying outside normal drawing routines you need to set the invalid screen area and force a screen update
gw->enlargeUpdateRect(NULL);
gw->updateScreen();
A bit odd - but the maxscript version of it does not draw anything either.
So there might be another issue here…
I’m on a AMD radeon dual graphics laptop, I have no issues with using max on it, except for this here now. so as it is now I’m thinking it might be a graphics card issue? or driver issue?..
I’ll test the different graphics modes for max with the maxscript version of the viewport draw methods, and see if I can get it to draw in any way, when that works I’ll test with my plugin with the same graphics settings.
the text example here works though from maxscript:
unregisterRedrawViewsCallback GW_displayObjectNames
fn GW_displayObjectNames =
(
gw.setTransform (matrix3 1)
for o in objects where not o.isHiddenInVpt do
gw.text o.pos (o as string) color:yellow
gw.enlargeUpdateRect #whole
)
registerRedrawViewsCallback GW_displayObjectNames
so maybe its something funky with the lines… I’ll test some more.
It works now, in maxscript and from c++, in legacy direct 3d mode.
it’s good that this happened, because now I can write code to check if the graphics card supports it.
Thank you for taking the time to help out on solving it.
Tested now on my workstation, it does not draw the lines when you use nitrous driver for 3dsmax. A bit frustrating because who would switch to the crappy legacy mode for debugging?..
The maxscript manual has this info:
NEW in 3ds Max 2012:The Nitrous Graphics Manager introduced in 3ds Max 2012 performs continuous updates to refine the final image. This requires special handling of all Graphics Methods described further in this topic. These Methods will only be executed if they are wrapped in a Scene Redraw Callback function. In other words, existing scripts will have to be modified to check for the Nitrous Graphics Manager if running 3ds Max 2012 or higher and call all viewport drawing operations from a Scene Redraw Callback function, and newly developed scripts must take this into account and implement the same approach.
So I’m assuming the same goes for the SDK.
Now I have to figure how to fit that into my plugin.
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);
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();
}
};
SDK how return struct to maxscript?
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();
}
};
dunno then, though would say I’d rather use a mesh (as wireframe only) to render something like that as opposed to a polyline.