From 3D Studio MAX to Direct 3D: Introduction to Plugin Development

【信息科学与工程学】【数据中心】第三十五篇 云计算数据中心的学科知识04 编号学科(课程)核心知识点在云计算/云存储/云网络/云安全/云MaaS中的作用代表教材/资料/论文 + 数学方程式列表工业界应用D1421​云原生数据库:TiDB​HTAP(混合事务/分析处理)、分布式SQL、水平扩展、强一致(Raft)、自动故障恢复、与MySQL兼容、TiFlash列式引擎提供弹性扩展的分布式数据库;支撑高并发在线交易与实时分析教材:《TiDB in Action》PingCAP(2020) 论文:《TiDB: A Raft-based HTAP Database》(2017) 阅读详情
 

From 3D Studio MAX to Direct 3D: Introduction to Plugin Development
by
Loic Baumann [Programming,Visual Art]

Post A Comment

 

 

February 20, 1998

 

If a programmer can translate an artist's work into a real-time 3D environment, the game will be that much better. For many programmers, 3D Studio MAX is the tool of choice for pre-calculating and real-time 3d scenes. And, in the opinion of this author, Microsoft's DirectX API is the most efficient API for games on Windows platforms

This article explains how to create a 3DS MAX plugin to export the artist's work into your real-time 3D engine. My instructions will take you through both the MAX and Direct3D APIs. While no experience is necessary, you should be familiar with Visual C++, Windows, Direct3D (using the Immediate Mode's Draw Primitives) as well as computer graphics basics.

I'll start with the MAX's API and cover how to use it to create a new plugin. With this knowledge, we can implement the the plugin's project using Visual C++. For real concrete stuff, for instance mesh and material exportation, you'll have to wait for the next articles.

Introduction to MAX plugin Development

3DS MAX primarily deals with meshes concerning the realization of 3d objects. Patches and NURBS are also managed, but because the powerful geometry pipeline makes it possible to convert them into meshes, it shouldn't be a problem. The exportation of NURBS-based objects would have made things very difficult and inappropriate for real-time 3D. This flexibility is the reason why 3DS MAX is becoming the standard as far as game development is concerned. If you already own the second version, you'll enjoy its performance compared to the first version. Many changes were made in this second version, and as a result, there is an incompatibility of plugins between the two versions. Getting around this incompatibility requires only a recompilation and maybe a few changes. So, with that in mind, techniques explained in this article will work, regardless of the MAX SDK version you have.

What do I need?

On the software side, you'll need Microsoft Visual C++. While the 4.0 version is good enough to create plugins for the first version of 3DS MAX, you'll imperatively need the 5.0 version if you use the MAX2 SDK. As for APIs, you'll of course need a version of MAX's SDK and DirectX 5.

While CPU Speed is not extremely important on the hardware side as it doesn't have any incidence on the compilation/testing time, I strongly recommend you at least 64 Mb RAM. If you have less, MAX, Visual C++ and your project won't be able to stay in memory. When this happens, compilation time will be multiplied by 5, and MAX will take at least 20 seconds to load. This, needless to say, can be maddening.

128 Mb RAM is sufficient, if your plugins project is inside a workspace which already contains projects such as your 3d game engine.

The MAX SDK gives developers the possibility to create many kinds of plugins, from Procedural Objects to Video Post Processing. A plugin's type called "File Export" is of particular interest. However it's not the type I would recommend. Export plugins are made to export a whole MAX scene, without any interactions with the user, which is, in our present case, not what we want. The utility plugin is more flexible just in case you want to select scene components to export, and how you want to export them.

MAX Philosophy

As a MAX plug-ins developer you'll have to understand MAX's internal structure. The rest of this article will introduce you to fundamental concepts such as the geometry pipeline, the manipulation of the scene's nodes, calculus implementation and the plugins' interface. If you like Oriented Object Programming, you'll love MAX's API: everything has been made according to the OOP philosophy, you'll find classes for almost everything you can think about (Mesh, Face, Point, Matrix…).

Nodes Manipulation

What's a node? In MAX, a node is a visual representation of an object (here, the term 'object' means 3D object, light, camera, shape, etc…). Nodes are linked to each other to make a hierarchy. The root node of this hierarchy is the MAX scene. To realize a MAX exporter plugin, it's important to be familiarized with the manipulation of nodes, as they're the starting point of your conversion.

What can we do with a node? A node is created and controlled from the MAX's class INode. I'm not going to detail this class, the MAX's help file will do it better than me, but I'll just comment on a few things that will be useful for our exporter.

The main function of a node is to reference the object it is associated with. This object's state can be evaluated in the world (its representation in the viewport) at a given time. See the geometry pipeline, for more information. Once this object is evaluated, you can retrieve all of its specific data, we'll see later how to do that.

Concerning the hierarchy…from a node, you can get its parent node, the number of its children and a specific child node, using the INode::GetParentNode(), INode::NumberOfChildren and INode::GetChildNode() methods. To scan the whole scene, you just have to get the root node (using a function of the plugins' interface), and then using the functions given below.

Other properties like the node's transformation matrix (a transformation matrix is made of a position, an orientation and a scale factor), the transformation matrix of the object, its reference and its name can be retrieved.

Now you know how a node basically works, let's explain how objects work with the help of the geometry pipeline.

The Geometry Pipeline

This is the most fundamental concept and innovation of MAX. If you have already worked with 3D Studio/DOS, you know how the creation of meshes work. You could start by creating many 2D shapes with the 2D shaper and then create a 3D object based on those shapes using the 3D lofter. To apply modifications (vertices displacement, Boolean operations, mapping, etc…) on it you could use the 3D editor. Each time you made a modification on a 2D shape or 3D object, the previous state was lost as the modification was directly applied on the entities (faces, vertices, 2d spline) that made up the 2D shape or 3D object.

MAX uses another approach to create geometric components called a "procedural approach". Each node contains a node pipeline. At the beginning of this pipeline there is the Base Object. Each time you apply a modification to your node, the Modifier you used is referenced in the node pipeline, with the parameters you set. Then, the geometry pipeline evaluates the node's pipeline to create the World Space State of the node's object. This World Space State is what you can see in the MAX's viewport.

Ok, let's take model what a "top". Don't expect a nice one, I'm just a programmer!

This model can be made in two steps: the creation of a sphere and the application of a Taper on it.

When you create a sphere, a new node is also created and inserted into the MAX scene. The object referenced by the node is the node's Base Object(the sphere). As it is a procedural object, the sphere object is not made of faces and vertices at this stage. This object can be generated into a mesh, depending of the parameters you specified.

Figure 1 below is the geometry pipeline representation of the node at this stage and its World Space State.

 

In step two, a Taper Modifier was applied on our node, you can see the result in Figure 2 (I've also assigned a texture map). The node now points on what we call the 'Derived Object'. This Derived Object is the result of the node's pipeline interpreted by the geometry pipeline.

Following the Derived Object is the Taper Modifier, and finally, our Base Object: the sphere.

 

Suppose that you apply a bend to the object. This Modifier will appear in the pipeline right after Derived Object and before the Taper. With the help of MAX's Modifier Stack you can change parameters of any Modifiers you want (even the base object). You can also remove or insert modifiers anywhere you want in the Stack. Anytime the object's World Space State will be recomposed: that's the job of the geometry pipeline.

The World Space State object of a node can be evaluated using the INode::EvalWorldState() method. This method returns a C++ object of the class ObjecState. From this object, you can retrieve the object evaluated by the geometry pipeline. The evaluated object is also a C++ object of a class that is derived from the Object class. MAX implements many classes that are derived from the Object class.

Later in this series, we will see classes such as:

TriObject: defines a mesh object made of triangles
CameraObject: defines either a Free or Target Camera
LightObject: defines either an Omni, Directional, Target Spot or Free Spot Light

A Bit of Calculus

MAX's API offers a set of classes and functions to make the utilization of matrices, points and quaternions easier. Since the manipulation of points is not really a big challenge, I'm not going to overview the Point3 class. Talking about quaternions would go beyond the scope of this article, as they are mostly used when dealing with animation. So only fundamentals of matrices are explained. Here we go.

Transformation Matrices. Transformation matrices are used to switch from one given coordinate system to another; for example, to transfer the coordinates of an object's vertices from local to the world space coordinate system. Transformation matrices are also used to position nodes in the scene. The transformations provided by these matrices are: translation, rotation and scaling. Such matrices can be created and used with the Matrix3 class of MAX.

In MAX, matrices have 4 rows of 3 columns. Usually, 3D matrices are 4x4 instead of 4x3. It's also the case for MAX, but as the last column is always [0 0 0 1] for such matrices, it's implicitly managed by the class and functions dealing with it.

The coordinate system used by max is a right-handed one, with counter-clockwise angles when looking to the positive way of an axis, as shown in Figure 3 below.

 

Now let's see how the identity, translation, rotation and scaling are encoded. An identity matrix has the property to keep a vector or a matrix unchanged during a vector/matrix or matrix/matrix multiplication. It's encoded as follows:

 

You can initialize a matrix to the identity by passing 1 to the constructor of Matrix3 class or by calling the method Matrix3::IdentityMatrix().

Translation is stored in the matrix this way:

 

Translation can be set using Matrix3::SetTrans(), retrieved using Matrix3::GetTrans(), set to null using Matrix3::NoTrans().

The matrices for rotations around the three axes are shown below. The rotation's angle is always given in radians.

X rotation:

Y rotation:

Z rotation:


These matrices can be created using global functions RotateXMatrix(), RotateYMatrix(), RotateZMatrix(). An incremental rotation around one specific axis can be performed using the Matrix3's methods Matrix3::RotateX(), Matrix3::RotateY(), Matrix3::RotateZ().

A method of the Matrix3 class is also provided to create a Yaw/Pitch/Roll angles matrix (using the rule of Euler's angles) : Matrix3::RotateYPRMatrix().

Scale factors are encoded like this:

 

Scaling factor can be set using Matrix3::SetScale(), or reset to 1 using Matrix3::NoScale().

For the last part of this article we're going to take a brief look at how the plugin can get access to MAX features.

The Plugin's Interface

The Plugin's Interface is a C++ Interface retrieved during the plugin's initialization. The term Interface signifies that a C++ object contains methods only. The Plugin's Interface is used to provide APIs that the MAX offers to the plugin. From the list of APIs it provides, the following pertains to our exporter.

Command Panel - Rollup Page Method

As the plugin's type we will use is a Utility Plugin, we'll have to design a dialog that will appear during the plugin's initialization in the Utility Plugin's Pan. This dialog will appear under the form of a Rollup Page. Methods of the Plugin's Interface will be used to Add and Delete this Rollup Page dialog.

Nodes Related Methods

By using functions of this API, we can access the Root Node of the scene, accessing a Node from its name.

Node picking

Provides functions to call the Interactive Nodes Selection Dialog of MAX. Useful to select Nodes we want to export.

Standard MAX dialog

The Track View Pick Dialog, Material Browse Dialog can be called using this API.

Last Words

Next time, we'll see how to create a Plugin's Project, how to integrate MFC inside the plugin, how to debug it, and check out a simple example of a Utility Plugin.

 

mysql笔记(第十三天).doc 立即下载

相关推荐

多输入多输出 (MIMO) 多址接入信道 (MAC) 中的资源分配Matlab代码.rar

多输入多输出 (MIMO) 多址接入信道 (MAC) 中的资源分配Matlab代码.rar

HTML-CSS(四十二)transfrom3D相关属性

3d属性 rotateX():正值向上 rotateY();正值向右 translateZ():政治向前,负值向后 注意:translateZ值不要超过景深(下文提到),否则效果不会很好。还有就是元素不是放大了,只不过物体离你更近 scaleZ():立体元素的厚度 更改之前: 更改之后: 3d写法: scale3d():三个值x y z translate3d():三个值 x y z rotate3d():四个值0|1(x轴是否添加旋转角度)0|1(y轴是否添加旋转角度)0|1(z轴是否添加旋转角度)d

weixin_44730244的博客 482

Aerosonde Mk 4.7固定翼无人机系统Matlab仿真.rar

Aerosonde Mk 4.7固定翼无人机系统Matlab仿真.rar

IOS开发之 一起用Swift来玩一玩3D Touch

Swift 2.3 IOS 8.0 XCode 8.0 添加入口标签在这里只说下静态的好了,暂时还用不到动态的,e.g.<key>UIApplicationShortcutItems</key> <array> <dict> <key>UIApplicationShortcutItemType</key> <string>ReceiveMoney</s

懒人改变世界 2230

Transfrom3D旋转

效果如上,一个3D旋转支持缩放点击事件的效果 先简单介绍 Transfrom3D的一些方法 1.针对偏移量设置      CATransform3DMakeTranslation(x,y,z)

iOSzxg的博客 2642

Vehicle Detection from 3D Lidar Using Fully Convolutional Network解析(3D-CNN模型)

1. 概述该论文的主要工作是,在只利用激光雷达的点云数据作为输入,在点云数据中进行类型为”车辆”的目标进行检测(在复现该算法过程中,存在一个比较显然的现象就是:目标所在的的位置,实际上垂直角一般都很小,在进行映射映射前后容易产生误差,这种误差对于远的目标的定位会有非常明显的影响;或者是是我理解有问题吗? -2018-04-25)。2. 方法2.1 数据预处理将激光雷达扫描获取的3维点进行映射,其中...

hit1524468的专栏 5039

散热片装胶钉贴胶机.rar

散热片装胶钉贴胶机.rar

三轴龙门机器人3D图纸 Solidworks设计 附STP格式.rar

三轴龙门机器人3D图纸 Solidworks设计 附STP格式.rar

QYR-22000-2026-2032全球及中国1-乙基环己醇行业研究及十五五规划分析报告 Sample sunyunmei.docx

QYR-22000-2026-2032全球及中国1-乙基环己醇行业研究及十五五规划分析报告 Sample sunyunmei.docx

基于模型预测人工势场的船舶运动规划方法,考虑复杂遭遇场景下的COLREG(Matlab代码实现)

内容概要:本文提出了一种基于模型预测控制(MPC)与人工势场法(APF)相融合的船舶运动规划方法,旨在解决复杂海上遭遇场景下符合国际海上避碰规则(COLREGS)的自主航行问题。该方法充分利用MPC的滚动优化与前瞻能力,结合APF在实时避障方面的直观高效性,构建了一个包含静态障碍物、动态他船以及COLREGS合规性要求的综合势场函数,并将其嵌入MPC的优化框架中进行轨迹求解。通过形式化表达COLREGS中的会遇态势与避让责任,并转化为相应的势场约束项,确保生成的路径不仅安全可行,而且满足国际航行法规的要求。文中详细阐述了势场函数的设计原理、MPC优化模型的构建流程以及在多船交互复杂场景下的仿真验证过程,充分展示了该方法在安全性、法规遵从性与路径平滑性方面的综合优势。; 适合人群:具备自动控制、航海技术、智能系统或机器人路径规划等相关专业背景,从事无人船、智能航运、自主导航算法研究的科研人员、工程师及研究生。; 使用场景及目标:①研究如何将国际海上避碰规则(COLREGS)有效融入自动化决策与路径规划系统;②开发适用于高密度动态交通环境、能够保证安全且合法航行的自主船舶运动规划算法;③探索模型预测控制与几何势场法相结合的新型路径规划范式,提升算法的鲁棒性与实用性。; 阅读建议:此资源以Matlab代码实现为核心,提供了完整的算法复现基础,读者应重点结合代码深入理解势场函数的数学建模、COLREGS规则的量化表达以及MPC求解器的具体实现过程,并通过调整仿真场景中的船舶数量、相对位置、航速航向等参数,系统评估算法在不同复杂遭遇局面下的性能表现、适应能力与鲁棒性。

手机屏撕膜贴膜滚压一体机.rar

手机屏撕膜贴膜滚压一体机.rar

【图论聚类算法】一种图论方法用于非参数聚类分析(Matlab代码实现)

内容概要:本文详细介绍了一种基于图论的非参数聚类分析方法,旨在通过对数据构建图模型来实现复杂数据集的有效聚类。该方法充分利用图论中的连接性、相似性和路径等概念,将数据点映射为图中的节点,并依据其相似度建立边,进而通过图的划分完成聚类任务。文中系统阐述了算法的设计原理、关键步骤如邻接矩阵构造、拉普拉斯矩阵计算及谱分解过程,并结合Matlab代码实现了算法流程,展示了其在高维与非线性结构数据上的优越性能。同时,文章还探讨了该方法相较于K-means、层次聚类等传统技术在处理不规则簇形状和噪声数据方面的优势与潜在局限。; 适合人群:具备一定编程基础,特别是熟悉Matlab编程环境,且对数据分析、机器学习、模式识别或相关科研领域感兴趣的研究生、科研人员及工程技术人员。; 使用场景及目标:①适用于处理具有复杂几何结构的高维数据,如生物信息学中的基因表达数据、社交网络中的用户关系分析、图像像素聚类等;②可用于需要无需预设簇数量的非参数聚类任务;③旨在通过图论手段提升聚类结果的准确性和鲁棒性,尤其在面对非凸分布和噪声干扰时表现更优。; 阅读建议:建议读者在学习过程中结合文中的Matlab代码实例进行动手实践,深入理解图构建与谱聚类各环节的作用。同时,鼓励尝试调整相似度度量方式、邻域大小等参数,观察其对聚类效果的影响,以全面掌握该方法的应用技巧与优化策略。

QYR-18900-2026-2032中国电动汽车高压继电器市场现状研究分析与发展前景预测报告 Sample kq.pdf

QYR-18900-2026-2032中国电动汽车高压继电器市场现状研究分析与发展前景预测报告 Sample kq.pdf

用于边缘检测的块匹配算法的优化 Matlab 实现 附matlab代码.rar

用于边缘检测的块匹配算法的优化 Matlab 实现 附matlab代码.rar

pytorch-handbook(Jupyter Notebook)

「pytorch-handbook(Jupyter Notebook)」是学习资料(Jupyter Notebook)。项目简介:pytorch handbook是一本开源的书籍,目标是帮助那些希望和使用PyTorch进行深度学习开发和研究的朋友快速入门,其中包含的Pytorch教程全部通过测试保证可以成功运行核心内容:深度学习、机器学习、神经网络、深度学习框架等。内容整理清晰,适合系统学习与查阅。

通用大语言模型提示词数据集

收集了2156个LLM实用提示词,涵盖编码、写作、翻译、AI代理、教育、生产力工具和基于角色的助手。数据结构化设计支持快速搜索、分类、推荐和LLM评估。适用于ChatGPT、Claude、Gemini、Llama、Mistral等主流大语言模型和对话式AI系统。

下一篇: Quake 2 BSP 文件格式 (翻译)
Scarlet
博客等级 码龄16年 4粉丝 3原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值