Max SDK中如何将图像绘制到视口

发布于 2024-12-23 01:48:23 字数 1184 浏览 1 评论 0原文

我希望能够在 3d Max 插件中将图像绘制到视口, GraphicsWindow 类具有在视口中绘制 3D 对象的函数,但这些绘图调用受到当前视口和图形渲染限制的限制。 这是不可取的,因为无论 3d max 处于什么图形模式和/或使用什么硬件,我想要绘制的图像都应该始终绘制,而且我只绘制 2d 图像,因此不需要在 3d 上下文中绘制它。

我已经设法获取视口的HWND,并且max sdk具有该功能 绘制图标按钮();

我尝试过使用此功能,但它无法正常工作,图像会随着用户交互而随机闪烁,但在没有交互性时会消失。 我已经实现了这个功能 RedrawViewsCallback 函数,但是 DrawIconButton() 函数没有记录,我不确定这是否是实现它的正确方法。

这是我用来绘制图像的代码:

void Sketch_RedrawViewsCallback::proc (Interface * ip)
{

    Interface10* ip10 = GetCOREInterface10();
    ViewExp* viewExp = ip10->GetActiveViewport();
    ViewExp10* currentViewport;

    if (viewExp != NULL)
    {
        currentViewport = reinterpret_cast<ViewExp10*>(viewExp->Execute(ViewExp::kEXECUTE_GET_VIEWEXP_10));
    } else {
        return;
    }

    GraphicsWindow* gw = currentViewport->getGW();

    HWND ViewportWindow = gw->getHWnd();
    HDC hdc = GetDC(ViewportWindow); 
    HBITMAP bitmapImage = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
    Rect rbox(IPoint2(0,0),IPoint2(48,48));

    DrawIconButton(hdc, bitmapImage, rbox, rbox, true);

    ReleaseDC(ViewportWindow, hdc);
    ip->ReleaseViewport(currentViewport);

};

I want to be able to draw images to the viewport in my 3d Max Plugin,
The GraphicsWindow Class has functions for drawing 3d objects in the viewport but these drawing calls are limited by the current viewport and graphics render limits.
This is undesirable as the image I want to draw should always be drawn no matter what graphics mode 3d max is in and or hardware is used, futher i am only drawing 2d images so there is no need to draw it in a 3d context.

I have managed to get the HWND of the viewport and the max sdk has the function
DrawIconButton();

and i have tried using this function but it does not function properly, the image flickers randomly with user interaction, but disappears when there is no interactivity.
i Have implemented this function in the
RedrawViewsCallback function, however the DrawIconButton() function is not documented and i am not sure if this is the correct way to implemented it.

Here is the code i am using to draw the image:

void Sketch_RedrawViewsCallback::proc (Interface * ip)
{

    Interface10* ip10 = GetCOREInterface10();
    ViewExp* viewExp = ip10->GetActiveViewport();
    ViewExp10* currentViewport;

    if (viewExp != NULL)
    {
        currentViewport = reinterpret_cast<ViewExp10*>(viewExp->Execute(ViewExp::kEXECUTE_GET_VIEWEXP_10));
    } else {
        return;
    }

    GraphicsWindow* gw = currentViewport->getGW();

    HWND ViewportWindow = gw->getHWnd();
    HDC hdc = GetDC(ViewportWindow); 
    HBITMAP bitmapImage = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
    Rect rbox(IPoint2(0,0),IPoint2(48,48));

    DrawIconButton(hdc, bitmapImage, rbox, rbox, true);

    ReleaseDC(ViewportWindow, hdc);
    ip->ReleaseViewport(currentViewport);

};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟织青萝梦 2024-12-30 01:48:23

我找不到直接绘制到视口窗口的方法,但是我通过使用透明的无模式对话框解决了该问题。

I could not find a way to draw directly to the view-port window, however I have solved the problem by using a transparent modeless dialog box.

来日方长 2024-12-30 01:48:23

也许完全重画就能解决问题。 <一href="http://docs.autodesk.com/3DSMAX/16/ENU/3ds-Max-SDK-Programmer-Guide/index.html?url=cpp_ref/class_interface.html ,topicNumber=cpp_ref_class_interface_html6c3c270e-1b26-42d7-8048-19c1b5940a6a,哈希=a4f0db23d120f4463676c54a1865190e4" rel="nofollow">强制完成重画

May be a complete redraw will solve the issue. ForceCompleteRedraw

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文