Restoreobj in 3DS MAX

Source: Internet
Author: User

Undo and redo operations are applied in many software applications, and 3DS MAX is no exception. So what does 3DS MAX use to implement undo and redo?

After reading deriving from restoreobj of Max SDK 2010, you will suddenly realize that Max uses restoreobj to implement undo and redo.

First, you need to implement a class that inherits restoreobj (deriverestoreobj). In this class, you need to implement the restore and redo functions in restoreobj, which are used

Implement the Undo and redo operations of Max.

In addition, you need to implement other methods, such as size (), endhold (), description () and other functions. The size function indicates the number of bytes of your restoreobj.

Endhold () is the end of setting a restore.

Next, we will use thehold to implement undo and redo operations. Here you use thehold as a stack bucket, and thehold. Begin () indicates starting

Put it into the operation, and thehold. Put (New deriverestoreobj (...) next to it indicates that the stack bucket must use the restore function and

The redo function is used to perform undo and redo operations.

After a code operation, thehold. Accept () indicates that the Code operation is pressed into the stack bucket, and thehold. Cancel () indicates that the operation is revoked from the stack bucket.

The Code operation is not pushed into the stack bucket, and thehold stack bucket is revoked.

Finally, let's take a look at the example of the Max SDK:

Class noderest: Public restoreobj {

Public:

Orient offs;

Orient redooffs;

Node * cur;

Noderest () {cur = NULL ;}

Noderest (node * node ){

Cur = node;

Offs = node-> modoffset;

}

~ Noderest (){}

Void restore (INT isundo );

Void Redo ();

Int size () {return 2 * sizeof (Orient) + sizeof (inode *);}

Void endhold () {cur-> clearaflag (a_held );}

Virtual tstr description () {return tstr (_ T ("node state "));}

};

 

Void node: holdstate (){

If (thehold. Holding ()&&! Testaflag (a_held ))

{

Thehold. Put (New noderest (this ));

Setaflag (a_held );

}

}

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.