본문 바로가기

프로그래밍/MaxSDK

[MAXSDK] Custom Node Properties and Application Data

원문 : MAX SDK Custom Node Properties and Application Data

 

Custom Node Properties and Application Data

 

플러그인 개발자들은 임의의 값을 씬의 노드들에 대해 저장할 필요가 있다. 3ds 맥스는 이를 위한 두 가지 방법을 제공하는데, AppData 와 User Properties 이다. 이 섹션은 두가지 방식에 대해 모두 다룬다. 또한 개발자가 자신의 플러그인 클래스와 관련된 데이터를 3ds 맥스 파일에 저장할 수 있는 방법에 대해서도 논의한다.

 

AppData - Chunks

 

AppData 는 응용프로그램 지정 데이터인데 이는 씬 내의 모든 Animatable 에 대해 부여될 수 있다. 이들 API를 사용하여 모든 3ds 맥스 오브젝트(컨트롤러, 오브젝트, 노드, 수정자, 재질 등)들은 다른 오브젝트에 의해 부여받은 사용자(custom) 데이터를 소유할 수 있다. 이들 청크(chunk)는 .MAX 파일에 저장되며 그것들이 연결된 오브젝트를 통해서 접근될 수 있다.

 

AppData 를 생성하기 위해 사용되는 메서드들은 Animatable 클래스로부터 상속된다. 이 데이터는 세 개의 소유자 식별자를 사용해 접근된다 : SuperClassID, ClassID, sub-index.

 

void AddAppDataChunk(Class_ID cid, SClass_ID sid, DWORD subid, DWORD len, void* d);

 

이 메서드는 AppDataChunk 를 이 Animatable 인스턴스에 추가하기 위해 사용된다. 이 청크는 Class_ID, SuperClassID, 하위 청크의 ID를 사용해 식별된다.

 

AppDataChunk *GetAppDataChunk(Class_ID cid, SClass_ID subid, DWORD sbid);

 

이 메서드는 AppDataChunk 에 대한 포인터를 획득하기 위해서 사용된다.

 

BOOL RemoveAppDataChunk(Class_ID cid, SClass_ID sid, DWORD sbid);

 

이 메서드는 AppDataChunk 를 제거하기 위해서 사용된다.

 

이들 API를 사용하는 샘플 코드는 \MAXSDK\SAMPLES\UTILITIES\APPDATA.CPP 에서 찾아볼 수 있다.

 

3ds 맥스로 내포되고(imported) 있는 노드와 관련된 3D Studio / DOS IPAS AppData 를 가지고 있는 개발자들은 이 내포된 데이터를 처리하는 것을 돕기 위한 3ds 맥스에서 이용가능한 API를 가지게 된다. AppData 는 노드와 함께 특별한 데이터를 저장하기 위해서 IPAS 플러그인에 의해 사용되었다. 예를 들어 이것은 IK 나 spline pathces 에 의해 사용되었다. 이들 API 들은 3ds 맥스 플러그인이 IPAS 플러그인으로부터 산출되는 app 데이터를 요청하고 그것을 사용할 수 있도록 해 준다. 플러그인은 app 데이터가 로드될 때 호출되는 콜백(callback)을 등록할 수 있다. 그리고 나서 이 콜백은 데이터를 해석하여 일반적인 삼각형 메시 대신에 사용될 새로운 오브젝트를 생성할 수 있다. 세부적인 사항을 원한다면 Class ObjectDataReaderCallback 을 참조하라.

 

주의 : 씬이나 루트 노드에 AppData 를 저장할 수 있지만, 그 데이터는 3ds 맥스 파일에 저장되지 않을 것이다. 왜냐하면 씬과 루트 노드는 실제로 저장되지 않기 때문이다.

 

Custom Node Properties

 

노드에 연결될 수 있는 또 다른 데이터 유형은 Custom Node Property 라 불린다. 이 데이터는 ASCII 텍스트, 정수값, 부동소수점 실수값, Boolean 값일 수 있다. 이들 값은 'key' 문자열을 사용해 저장되거나 검색된다. 어떠한 길이를 가지는 문자열이라도 상관없다 -- 키 문자열은 공백, 탭, 할당식(=) 문자를 포함하지 말아야 한다는 제약만이 존재한다.

 

지정된 데이터 값을 획득하거나 설정하기 위해서, 개발자는 INode 의 다음 메서드들을 사용하게 된다. 이들은 ASCII 문자열, 정수, 부동소수점 실수, boolean 값을 설정하거나 획득한다 :

 

획득 함수 설정 함수 
GetUserPropString() SetUserPropString()
GetUserPropInt() SetUserPropInt()
GetUserPropFloat() SetUserPropFloat()
GetUserPropBool() SetUserPropBool()

 

최종 사용자는 이 데이터를 입력할 수도 있다(3ds 맥스 사용자 인터페이스에서 이것은 "User Defined Property"로 불린다). Object Properties 다이얼로그를 사용하여 사용자는 다음 형식으로 텍스트를 입력할 수 있다 :

 

PropertyName=Property Value

 

사용자가 property 이름 바깥쪽에서는 어느 곳에서나 공백(및 다른 문자)을 사용할 수 있기는 하지만 property 이름 안에서는 공백을 입력해서는 안된다. property 이름은 라인의 시작부분에 나타나야 하며 라인당 단지 하나의 property만이 존재할 수 있다.

 

만약 원한다면 개발자는 전체 사용자 정의 property 텍스트 버퍼에 접근하여 그것 자체를 파싱할 수 있다. 이를 위한 메서드는 GetUserPropBuffer() 와 SetUserPropBuffer() 이다.

 

이들 메서드에 대한 레퍼런스 정보를 원한다면 Class INode 를 참조하라.

 

Saving Calss Data

 

 

The following three methods of class ClassDesc may be used to save data associated with a class in a 3ds Max file. This is appropriate for preference data and other similar information associated with a class. If you want to save data associated with the class have NeedsToSave() return TRUE and implement the Save() and Load() methods. See the Advanced Topics section on Loading and Saving for more details on the way data is written to and read from 3ds Max files.

 

virtual BOOL NeedsToSave();

 

Returns TRUE if there is data associated with the class that needs to be saved in the 3ds Max file. If this is so, implement the Save() and Load() methods below. If there is no class data to save, return FALSE.

 

virtual IOResult Save(ISave *s);

 

If NeedsToSave() returns TRUE then this method should be implemented to save the data associated with the class.

 

virtual IOResult Load(ILoad *l);

 

If NeedsToSave() returns TRUE then this method should be implemented to load the data associated with the class.

 

Note: One peculiarity with the loading and saving of the class data is that if the user does a File New or File Reset then the class data is not cleared.



[출처] - 라이푸님의 http://blog.naver.com/lifeisforu 네이버 블로그

'프로그래밍 > MaxSDK' 카테고리의 다른 글

[MAXSDK] Interface 클래스 명세  (0) 2009.12.25
[MAXSDK] 라이브러리 파일 설명  (0) 2009.12.25
[MAXSDK] 3Ds MaxSDK Plug-in Wizard Setting  (0) 2009.12.25
[MAXSDK] UtilityObj 클래스  (0) 2009.12.03
[MAXSDK] IUtil 클래스  (0) 2009.12.03