Notifications
Clear all

[Closed] [SDK] issues drawing polyline in viewport

I’m implementing a debug feature for one of my plugins,
the issue I’m having though is drawing the actual lines in the viewport.
I do ‘step’ the timeline frame-by-frame, and I draw on top of the viewport at the end of every step. But it does not seem to show anything at all.

I’m writing the plugin for 3dsmax 2014.

I know maxscript has the same draw function, but I’m trying to avoid piping the data into maxscript and draw it with that, but as last attempt I might have to do that.

The code is as simple as this:
(All though the values are from variables, this example has a hardcoded value to test with)


Point3 v[3];
v[0] = Point3((0.0f, 0.0f, 0.0f);
v[1] = Point3(100.0f, 100.0f, 100.0f);

GetCOREInterface12()->GetActiveViewExp().getGW()->polyline(2, v, NULL, NULL, FALSE, NULL);

More info on the function:
http://docs.autodesk.com/3DSMAX/15/ENU/3ds-Max-SDK-Programmer-Guide/cpp_ref/class_graphics_window.html#ad2e9641e5e3206e1f13d540798a5bfe3

26 Replies

you probably need to do this before calling polyline

Matrix3 tm = inode->GetObjectTM(t);
 gw->setTransform(tm);

or if you don’t have a node use the worldspace alternative

gw->setTransform(Matrix3(1))

I get my points as world coordinates.

I’ll test it and report back thanks!

Still the same – no lines in my viewport unfortunately…
hmm.

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.

Page 1 / 3