How to Write a controller (from 3DS max sdk 9)

Source: Internet
Author: User

Introduction: Brief Introduction:

The constraint controller that we study here is called the position constraint. the entire source code of this constraint is found at/3DS maxsdk/samples/controllers/position_cnstrnt.cpp ). it is expected that the reader wowould need to refer to it while going through the descriptions.

What we want to learn today is the position constraint controller in 3DS MAX. You can see the entire code in the 3DS maxsdk/samples/controllers/position_cnstrnt.cpp file. When reading this article, you can read the code to help you understand it.

Who benefits from this document?

This is a step-by-step description of creating a 3DS MAX controller plugin. this article is meant for developers with very little or no experience in development either with the 3DS MAX package or the 3DS MAX source code. the Controller is one of the key distinguishing features of 3DS MAX and Its Complexity demands careful study.

This article is a "serial" presentation like a book rather than a "parallel" Hypertext-based presentation where the reader can jump from one section to another as necessary. the reader shocould be able to read through this document with a minimum of tinkering with the code.

 

Who will benefit from this article?

 

This location constraint controller is an entry-level controller, but it will take you step by step into the Hall of complex control. This article is also suitable for developers who have no knowledge of Max. Controller is one of the important features of max, and its complexity requires you to study it carefully.

This article is about "series programs" rather than "series programs". Therefore, readers cannot skip or read through different chapters and need to continue reading. Of course, you need to read some code inserted in the story.

 

What are controllers?

Some preliminary information about 3DS MAX controllers:

Controller plugins are the objects in 3DS MAX that control animation. controllers store animation values and manage the interpolation from one value to the next. when an object is created in 3DS MAX, the Core Component plugin associated with that object specifies a list of parameters that can be animated. to conserve memory, these parameters are typically not assigned a controller. if the user animates the parameter, a default controller is assigned to the parameter.

One exception to this is the transform controller, which is always assigned to every new object at creation time. the transform controller keeps track of where the object is located in World Space, any rotation data associated with the object, and the scaling factors associated with the object. default controllers are assigned to the transform controller when the object is created.

3DS MAX comes with a multitude of different controllers and there are several ways they can be classified. A controller returns a specific value when given a time in the animation. in the following table controllers are categorized according to the type of value they produce, and correspondingly their superclass ID (to be explained later ):

 

What is a controller?

 

Let's briefly describe the 3DS MAX controller:

The Controller plug-in mainly controls the things that need to be changed in 3DS MAX. For example, the Controller stores variable values and uses the next interpolation between them. When an object is created in 3DS MAX, the plug-in of its core component will list a series of parameters for change and debugging. To save memory, these parameters do not specify the controller. If you change a parameter, a default controller will assign this parameter.

Of course, there is also an exception, that is, the transformation controller, which is assigned to this object when each object is created. The transform controller records where an object is created and located in the world space. Meanwhile, the rotation data and scaling information of this object are recorded. Of course, when an object is created at the beginning, the default controller is to assign the transform controller.

3DS MAX has many controllers, and there are also ways to classify them. During an animation period, a controller returns a specific value. In the following list, controllers are divided into categories and their superclass IDS Based on the data they generate.

 

This is taken from plugapi. h

Type of Value Controller's superclassid
Float Ctrl_float_class_id
Point3 (including color) Ctrl_point3_class_id
Position Ctrl_position_class_id
Rotation Ctrl_rotation_class_id
Scale Ctrl_scale_class_id
Transform Ctrl_matrix3_class_id
Morph Ctrl_morph_class_id
(User-Defined) Ctrl_usertype_class_id
Master (Master point) Ctrl_masterpoint_class_id
Masterblock Masterblock_super_class_id

 

All constraints are controllers but all controllers are not constraints:

In the 3DS MAX architecture constraints form a proper subset of the controllers. only those controllers that need reference another object are called constraints. example: position, orientation, Link, path. the rest of the controllers that are not constraints don't need an object for reference. examples are keyframe controller, expression controller, noise, and waveforms.

In the 3DS max ui, the Controller, including the constraints, are generally accessed from the motion panel. there is a second, and more direct, way to access only the constraints, and that is through the menu: animation-> constraints.

 

All schedulers are controllers, but not all controllers are schedulers:

In 3DS MAX, the binder is a subset of the controller.

To view the Controller in 3DS MAX, go to the motion Command Panel. If you want to view the constraint, go to the menu: animation-> constraint.

 

Position constraint workflow in 3DS MAX position constraint workflow in 3DS MAX

 

How to engage the position constraint in 3DS MAX?

The user can employ the position constraint to make a source object move to and be coincident with another object, called the target object. position constraint, which constrains the position of an object to a target, is similar to instancing the position controller of one object and pasting it on another. rotation and scaling is completely free. once engaged, the source object becomes constrained to the target object's position. animating the target object's position causes the source (constrained) object to follow.

In the figure below the red sphere is the source object and it is position constrained to the yellow sphere, which is the target object. the constraint is under the special option called 'keep initial offset ',

 

How can I use the location limiter in Max?

You can use the location limiter to bring a source object along with another object (target object ). The location limiter binds the relative positions of the source object and the target object. The positions of the two objects are bonded together, but the rotation and scaling are completely free. Once the limiter is used, the location of the source object will be constrained by the location of the target object. Changing the position of the target object will keep the source object subject to changes.

In, a red ball (source object) is constrained by a yellow ball (target object. Note that the initial setting is the initial setting of the feater and the settings are kept.

 

Such that the source object doesn' t jump to the target object when assigned but preserves its current position. essential tially the source object appears to be connected by a rigid rod to the target object. if the target object's position is animated through different frames, the source object faithfully follows the target on an identical trajectory-the trajectories are shown below with red lines.

When the limiter is set, the source object will not jump to the target object, saving the existing position unchanged. The source object is connected to the target object by an invisible steel pipe. If the position of the target object keeps changing with each frame, then the source object will faithfully change along with the target object in the same orbit (the two tracks are displayed in red lines in the diagram ).

 

The position constraint can also move an object to the position of the weighted-average of several different targets. each target has a weight value defining its influence. A value of 0 is equal to "off ". any value greater than 0 will cause the target to influence the constrained object. weight values may be animated to create effects such as a ball being picked up from a table. note that the weights are pure numbers (which are normalized "under the hood" before being applied) and not percentages.

Procedure to engage the position constraint:

  1. Select the object you want to constrain
  2. Choose animation menu> constraints> position constraint.
  3. Select the target object.

The user interface of the position constraint in 3DS MAX is shown below. the various options of the constraint can be accessed through the motion panel-see the UI snapshot below. A familiarity with the UI will be necessary when we discuss how this is handled by the Code.

 

The location limiter can move an object to a position, which is obtained by the weights of different target objects. Each target object has a weight that defines its impact. "0" indicates that the impact is zero, that is, the impact is not affected. Any value greater than zero indicates that the target object will affect the source object. The weight value can be changed to produce effects such as the ball being picked up from the table. Note: The weight is a pure number (obtained through orthogonal processing), not a percentage.

The process of using the location limiter:

 

1. Select an object (to be constrained ).

2. Select the animation menu> constraint> position constraint.

3. Select the target object.

 

The user interface of the location controller is displayed below. Different options of the scheduler can be obtained through the motion panel-see the snapshot in the following user interface. After getting familiar with the interface, it is much easier to discuss the code.

 

User Interface Description

The UI works as follows. The user selects an object and assigns position constraint. Next, in the position constraint UI menu the following functions can be saved med:

  1. Add position target: the user clicks on this button and selects one or multiple targets on the scene. the position constraint mode is canceled by a right mouse click. the selected targets appear in The ListBox with their default weight of 50.
  2. Delete position target: the user can select (highlight) a target in the ListBox and remove it from the target list by clicking on the "delete position target" button.
  3. The weightbox and spinner: the user can type-in the required numerical weight for the target selected in The ListBox. the weight can be modified with the adjacent spinner. the ListBox shows the weights as integers but the weight edit box shows the selected weight as a decimal point float.
  4. "Keep initial offset" option. by default, once the constraint is applied to a single source object, the object jumps to the target object, and their has points coincide. this is the absolute mode-when the keep initial offset checkbox is unchecked. when this checkbox is checked, the source object maintains the offset between its initial position and the initial position of the target. the behavior for multiple targets is essential similar. the default absolute mode will cause the object to jump to the weighted-average position of the targets. with the keep initial offset mode active, it will maintain its position when the constraint is initially applied; there will be no jump. when the targets are animated, the object will continue to maintain the position offset between its initial position and the weighted-average position.

Now that we have familiarized ourselves with the behavior and workflow of the position constraint in the 3DS MAX 4.0 viewport, We will delve into the code to see how this feature was developed. but first we talk about some Visual Studio features so that C ++ can be used smoothly...

 

The user interface works like the following. The user selects an object and assigns it a location limiter. Next, in the menu of the location constraint user interface, the following functions will be executed:

 

1. Add a location and target object: click this button and select one or more targets in the scene. You can right-click to cancel the position constraint mode. The selected target is displayed in the list box. Its default weight is 50.

2. Delete the location of the target object:

3. Adjust the weight of the spinner button.

4. Retain the initial offset.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.