Align Vertex in Spline For 3ds Max 2022
Kagula
2021-10-30
Introduction
- I don't know why 3dsmax2022 hasn't implemented align vertex in the spline even now, so I made it by myself.
Keyword
C++、Qt5、3ds Max、Spline、Vertex
Content
Open Visual Studio 2017 and new project,select 3ds Max Plugin Wizard, select plugin type is utility. and name the project is alignVertexInSpline2022 because my plugin only works in 3dsmax2022. Category and Category Description fill what you like, leave the others untouched.
Step1: Create UI And Connect To Class
Double click the file "plugin_form.ui" and redesign the UI like below.
Pic1 UI
After compile "plugin_form.ui", generate "ui_plugin_form.h". Open "QtPluginRollup.h",We will see below code, help us connect QtPluginRollup class to "plugin_form.ui".
Snippet 1
// This is a macro that connects this class to the Qt build system
Q_OBJECT
Snippet 2
protected slots:
void on_pushButton_clicked();
we need rename on_pushButton_clicked() to on_ourControlName_clicked(), etc on_pbX_clicked, on_pbY_clicked, ...
Snippet 3
private:
Ui::PluginRollup* ui;
Ui:: PluginRollup is from auto generated file "ui_plugin_form.h"
Open QtPluginRollup.cpp file, we will see ui->setupUi method usage.
QtPluginRollup::QtPluginRollup(QWidget* /*parent*/)
: QMaxParamBlockWidget()
, ui(new Ui::PluginRollup())
{
// At a minimum, we must call setupUi(). Other initialization can happen here.
ui->setupUi(this);
}
According to UI, Modify the method's name.
// This is a widget that is not wired to a paramblock. It can still be used via the Qt Signal/Slot mechanism.
void QtPluginRollup::QtPluginRollup::on_pbX_clicked()
{
// We can access all the functionality in QtCore and QtGui, such as using various
// dialogs.
QMessageBox::information(this, "Hi", "Button pushed.");
}
Step2: Toolbar Docking Delegate And Pop Up Float Window
Add ToolBar'Button Definition in alignVertexInSpline2020.h
// Here a large value is used so it won't conflict with the IDs used
// by MAX.
#define ID_TB_0 10000
Insert include files in alignVertexInSpline2020.cpp
#include "ISceneEventManager.h"
#include "Qt/QmaxMainWindow.h"
#include "Qt/QmaxToolBar.h"
#include "Qt/QmaxDockingWinHost.h"
#include "Qt/QmaxDockingWinHostDelegate.h"
We create ToolbarDockingDelegate class for tool bar in alignVertexInSpline2020.cpp.
/*===========================================================================*\
| Class ToolbarDockingDelegate is the custom docking delegate that will
| process the controls we add.
\*===========================================================================*/
class ToolbarDockingDelegate : public MaxSDK::QmaxProxyDockingWinHostDelegate
{
public: