3dsMax2022插件开发-对齐样条线中顶点的插件(英)

本文介绍了如何为3dsMax2022开发一个C++和Qt5插件,实现对样条线顶点的对齐功能。内容包括创建UI、连接到类、创建浮动工具栏、响应选择改变事件、获取选定的样条线和顶点以及编辑顶点的步骤。
摘要由CSDN通过智能技术生成

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:
Catmull-Rom样条曲线是一种数学插值曲线的方法,它常用于计算机图形学和计算机动画中。这种曲线的特点是平滑且自然,可以通过一组数据点来生成连续且曲线流畅的路径。 Catmull-Rom样条曲线的计算是基于组成曲线的数据点和一个参数t的插值公式。它通过使用当前点和其相邻两个点之间的信息来计算每个点处的曲线方向和形状。具体来说,对于给定的四个数据点P0、P1、P2和P3,曲线在P1和P2之间的t值范围内插值。这个t值是一个[0, 1]之间的参数,可以控制曲线的形状。通过改变t值,我们可以调整曲线的曲率和张力,从而得到不同样式的曲线。 Catmull-Rom样条曲线具有一些优点。首先,它是C2连续的,也就是说曲线在连接点处的一阶和二阶导数都是连续的,这使得曲线更加平滑。其次,曲线通过所有给定的数据点,这使得它们在表示路径时具有较好的准确性。此外,如果我们需要在曲线某个位置添加一个新的控制点,只需更新相邻的两个数据点即可,而不会对整条曲线产生明显的影响。 Catmull-Rom样条曲线在计算机图形学和动画中有广泛的应用。它常被用于生成平滑的曲线路径,如自由摄像机移动路径、动态物体轨迹等。此外,它还可以用于生成平滑的形状、曲面等。总之,Catmull-Rom样条曲线是一种非常有用的数学工具,可以在许多计算机图形学和动画应用中发挥重要作用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kagula086

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值