Management of texture resources in Max

Source: Internet
Author: User

Recently, it is found that the texture of Max may cause problems to the producers. The common problem is the uncertainty of the texture path. The root cause is that the Directory creation is inconsistent.

There is a common problem,Max opening a file with a lot of lost textures will lead to very difficultIt takes 18 minutes to open a file on my machine.Move the file to the project directory to openIn less than three seconds. Note that do not use a path or file that contains Chinese characters. Do not set the project directory to Chinese. Do not complain about English letters or letters.

--------------------------------------

If you just want to see how to quickly open a file with lost textures, you don't have to look down. Just read the text on it.

Then, if you are really okay and idle, you may want to add some jobs to your project program, or if you want to hurt yourself, you can continue.

--------------------------------------

The problems such as inconsistent paths and lost textures mentioned above can be completely solved using the project path settings.

By default, the max project directory is "My Documents \ 3 DSMAX"

You can set the project directory by yourself, as shown in figure

 

However, Max's default project directory settings will create many folders that are not available at all, such as import, preview, and vpost. In game development, you may only need one directory for each role, then all the textures and Max files are placed in the corresponding directory. Then you need to change the max project directory settings to remove those redundant directories. The settings of the project directory are as follows:

The section in the red box is set as a subdirectory. You do not need to generate a subdirectory ". "(or set it to the same directory of the project folder above, it will be automatically converted ". ").

If you just want to know about the application, click here. If you want to explore it in depth, you can continue to look at it.

You can use maxscript to set the path or open the project directory setting window. A simple example is provided here.

Clear redundant directory settings and call the set project directory command

Subpathnamelist = #(
# Animations,
# Archives,
# Downloads,
# Export,
# Expression,
# Image,
# Import,
# Matlib,
# Maxstart,
# Photometric,
# Preview,
# Proxies,
# Renderassets,
# Renderpresets,
# Renderoutput,
# Scene,
# Sound,
# Vpost
)

For I in subpathnamelist do setdir I "."

Pathconfig. doprojectsetupsteps ()

In this way, each game project sets a project directory, and all textures use relative paths. Before opening the file, set the project directory. If there are multiple projects, you can also use maxscript to make quick settings.

The corresponding function of maxscript is: pathconfig. setcurrentprojectfolder

Some people may often see a warning box like this after setting the project directory.

This is because the autoback directory does not exist. In the subdirectory settings of the project directory, specify an automatic save directory or disable the Automatic save function. We recommend that you specify an automatically saved directory.

 

In addition, inconsistent directories will lead to another problem. Max will find the textures in its system directory when he cannot find the textures according to the path stored in the file, if it is found, it is displayed correctly. Although it can be correctly displayed, the texture path saved in the material is still incorrect, so the export plug-in will not work when copying the texture. To solve this problem, I want to use the project directory settings and settings to use the relative path with some maxscript.

Shows the options for using relative paths in MAX (do not select UNC ):

This window is opened from the menu "customize-> Preferences", and the Chinese version is "custom-> Preferences ". after this option is selected, the files used in Max will be converted to the relative path relative to the project path. Note that the specified texture does not change with the selected texture. After this option is selected, Max will try to convert the specified path when specifying the file, and will not process the specified path. Of course, this processing can be done using maxscript, which will be discussed later.

 

Note that the relative path here is relative to the project path of Max.

 

Of course, using relative paths may cause a problem. Many export plug-ins directly read the texture paths in the materials during export. If relative paths are used, they will not find textures based on the project directory, if a program needs to do this, the maxsdk method for obtaining the current project directory is

Maxsdk obtains the project directory

/*
# Include <ipathconfigmgr. h>
*/

Const tchar * projectpath = ipathconfigmgr: getpathconfigmgr ()-> getcurrentprojectfolder (). getcstr ();

Of course, our program may be busy with more important things, and sometimes we want to solve the problem on our own, it is very easy, before each export, you can change the texture path to an absolute path. After the export, you can change it back. However, you can use maxscript to complete these operations at a time, you can use Max's asset tracking system to modify the texture path. Here is a simple example of the conversion path.

 

Convert the texture path

FN resolveresourcetoabsolute =
(
Local assetfilelist
Assetfilelist = #()
Atsops. Refresh ()
Atsops. getfiles & assetfilelist

For tempfile in assetfilelist do
(
Atsops. selectfiles # (tempfile)
Atsops. resolveselectiontoabsolute ()
)
Atsops. clearselection ()
)

FN resolveresourcetorelative =
(
Local assetfilelist
Assetfilelist = #()
Atsops. Refresh ()
Atsops. getfiles & assetfilelist

For tempfile in assetfilelist do
(
Atsops. selectfiles # (tempfile)
Atsops. resolveselectionrelativetoprojectfolder ()
)
Atsops. clearselection ()
)

Resolveresourcetoabsolute ()
/*
Add your own export code here
*/
Resolveresourcetorelative ()

Finally, this post is not a hands-on tutorial. It just introduces some corresponding settings and methods. The specific application must be combined and improved by the reader.

To explain why we recommend setting the project directory, many people think that the drive letters of different people are a big problem. In fact, this is not a problem.

The project directory is also very similar in versions earlier than max9, but max9 has listed it separately.

Assume that the project directory is set and the relative path is also set before creation.

This may be the case on Lu's machine.

The project path is:

C: \ maxproject \ game1 \

A Texture file used is:

C: \ maxproject \ game1 \ char1 \ txs1.png

If the relative path is set before, then passer-by B needs to modify the file of passer-by A. If all the files use the project directory, no matter where he places the project directory, you only need to set the project path in max, and the textures can be perfectly recognized.

For example, in the above c: \ maxproject \ game1 \, the entire directory may be in D: \ xixihaha \ MP \ G1 \ In the machine of user B \.

It doesn't matter. passer-by B re-specifies the max project directory as D: \ xixihaha \ MP \ G1 \, without any impact.

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.