MQDocument class

MQDocument class manages objects, materials and so on.

Object
GetObjectCount Get a number of object in this document.
GetObject Get a pointer of the object class.
GetCurrentObjectIndex Get an index of the current object.
AddObject Add an object to this document.
InsertObject Add an object after the specified object.
DeleteObject Remove the object from the document and delete it.
GetObjectIndex Get an index of the specified object.
GetParentObject Get a parent object of the specified object.
GetChildObjectCount Get a number of children object of the specified object.
GetChildObject Get a child object of the specified object.
GetGlobalMatrix Get a global transformation matrix of the specified object.
GetGlobalInverseMatrix Get an inverse global transformation matrix of the specified object.
Material
GetMaterialCount Get a number of materials in this document.
GetMaterial Get a pointer of the material class.
GetCurrentMaterialIndex Get an index of the current material.
SetCurrentMaterialIndex Set an index of the current material.
AddMaterial Add a material to this document.
DeleteMaterial Remove the material from this document, and delete it.
Memory
Compact Shorten arrays in the document by removing NULLs
Selection
ClearSelect Clear all the selection of the vertices, lines and faces.
AddSelectVertex Select a vertex.
DeleteSelectVertex Deselect a vertex.
IsSelectVertex Check if the vertex is selected.
AddSelectLine Select a line.
DeleteSelectLine Deselect a line.
IsSelectLine Check if the line is selected.
AddSelectFace Select a face.
DeleteSelectFace Deselect a face.
IsSelectFace Check if the face is selected.
AddSelectUVVertex Select a UV vertex.
DeleteSelectUVVertex Deselect a UV vertex.
IsSelectUVVertex Check if the UV vertex is selected.
Mapping
FindMappingFile Convert a filename to an absolute path
Scene
GetScene Get a scene.

int MQDocument::GetObjectCount(void);

Return value
A size of array of the objects

It gets a number of objects contained in this document.

This function returns not a number of objects exist actually but a size of array of the objects. So, it contains NULL objects deleted by MQDocument::DeleteObject(). To get an actual number, you must count non-NULL objects by MQDocument::GetObject().


MQObject MQDocument::GetObject(int index);

index
An index of the object
Return value
Object class

Get a pointer of the specified indexed object. It returns NULL if the object at the specified index does not exist.


int MQDocument::GetCurrentObjectIndex(void);

Return value
An index of the current object

It gets an index of the current object.


void MQDocument::SetCurrentObjectIndex(int index);

index
An index of an object to be current

It specifies a current object with an index.


int MQDocument::AddObject(MQObject obj);

obj
An object to be added
Return value
An index of the added object

It adds an object to this document.

Since the object is managed by the document after adding, you must not delete the object by MQObject::DeleteThis().


int MQDocument::InsertObject(MQObject obj, MQObject before);

obj
An object to be added
before
'obj' will be inserted behind this 'before' object (in a head if 'before' is NULL)
Return value
An index of the added object

(new in Rev2.41)

It registers an object to the document after the specified object. The object will be registered in the head of the list if 'before' is NULL. An index of an object behind the inserted object in a list will be changed.

The material is managed by this document. So, you must not delete the material by MQObject::DeleteThis().


void MQDocument::DeleteObject(int index);

index
An index of the object to be deleted

It remove the specified object from this document, and delete the object.

MQDocument::GetObject() with the deleted index will return NULL.


int MQDocument::GetObjectIndex(MQObject obj);

obj
An object class
Return value
An index of the object

It gets an index of the specified object in this document.

It returns -1 if the object does not exist in this document.


MQObject MQDocument::GetParentObject(MQObject obj);

obj
A child object
Return value
A parent object

(new in Rev2.40)

It gets a parent object of the specified object in this document.

It returns NULL if the specified object exists at the root.


int MQDocument::GetChildObjectCount(MQObject obj);

obj
A parent object
Return value
A number of the child objects

(new in Rev2.40)

It gets a number of child objects of the specified parent object in this document.

Only the objects in directly under are counted as child objects, and below it does not count grandchildren.


MQObject MQDocument::GetChildObject(MQObject obj, int index);

obj
A parent object
index
An index of a child object
Return value
A child object

(new in Rev2.40)

It gets a child object of the specified parent object in this document.

An index must be smaller value than the number returned by MQDocument::GetChildObjectCount().


void MQDocument::GetGlobalMatrix(MQObject obj, MQMatrix& mtx);

obj
An object
mtx
[OUT] A global transformation matrix

(new in Rev2.40)

It gets a global transformation matrix of the specified object in this document.


void MQDocument::GetGlobalInverseMatrix(MQObject obj, MQMatrix& mtx);

obj
An object
mtx
[OUT] An inverse global transformation matrix

(new in Rev2.40)

It gets an inverse global transformation matrix of the specified object in this document.


int MQDocument::GetMaterialCount(void);

Return value
A length of an array for materials

It gets a number of an array for material.

It is not a number of material exist in document but a length of an array for material. It contains NULL material deleted by MQDocument::DeleteMaterial(). You must count non-NULL materials if you want to an actual number of material in the document.


MQMaterial MQDocument::GetMaterial(int material);

material
An index of a material
Return value
A material class

It gets a pointer of the material at the specified index.

It returns NULL if a material at the specified index does not exist.


int MQDocument::GetCurrentMaterialIndex(void);

Return value
An index of the current material

It gets an index of the current material. No material is selected when it returns -1.


void MQDocument::SetCurrentMaterialIndex(int index);

index
An index of a material

It specifies a current material by the index.


int MQDocument::AddMaterial(MQMaterial mat);

mat
A material to be added
Return value
An index of the added material

It adds a material into the document.

Since the material is managed by the document after adding, you must not delete the material MQMaterial::DeleteThis().


void MQDocument::DeleteMaterial(int index);

index
An index of a material to be deleted

It removes the material from the document, and delete the material.

MQDocument::GetMaterial() with the deleted index will return NULL.


void MQDocument::Compact(void);

It shortens arrays for objects or material in this document by removing NULLs in the arrays. The size of the array will be same as the number of the objects or materials actually exist in the document. And the arrays for the vertices or faces in objects are also shortened. Please be careful that the indices of vertices and faces will be changed.

Since data volume becomes small, it is desirable to perform this API after performing large operation to a document or objects. And this function is automatically called at the time of saving a file.


void MQDocument::ClearSelect(DWORD flag);

flag
[MQDOC_CLEARSELECT_VERTEX] Vertex
[MQDOC_CLEARSELECT_LINE] Line
[MQDOC_CLEARSELECT_FACE] Face
[MQDOC_CLEARSELECT_ALL] All the elements

It clears all the selection of the specified element(s).


BOOL MQDocument::AddSelectVertex(int objindex, int vertindex);

BOOL MQDocument::AddSelectVertex(MQSelectVertex sel);

objindex
An index of an object
vertindex
An index of a vertex
sel
A vertex
Return value
Succeeded or failed

It selects the specified vertex.


BOOL MQDocument::DeleteSelectVertex(int objindex, int vertindex);

BOOL MQDocument::DeleteSelectVertex(MQSelectVertex sel);

objindex
An index of an object
vertindex
An index of a vertex
sel
A vertex
Return value
Succeeded or failed

It deselects the specified vertex.


BOOL MQDocument::IsSelectVertex(int objindex, int vertindex);

BOOL MQDocument::IsSelectVertex(MQSelectVertex sel);

objindex
An index of an object
vertindex
An index of a vertex
sel
A vertex
Return value
[TRUE] The vertex is selected
[FALSE] The vertex is not selected, or does not exist

It checks if the specified vertex is selected.


BOOL MQDocument::AddSelectLine(int objindex, int faceindex, int lineindex);

BOOL MQDocument::AddSelectLine(MQSelectLine sel);

objindex
An index of an object
faceindex
An index of a face
lineindex
An index of a line
sel
A line
Return value
Succeeded or failed

It selects the specified line.


BOOL MQDocument::DeleteSelectLine(int objindex, int faceindex, int linelidex);

BOOL MQDocument::DeleteSelectLine(MQSelectLine sel);

objindex
An index of an object
faceindex
An index of a face
lineindex
An index of a line
sel
A line
Return value
Succeeded or failed

It deselects the specified line.


BOOL MQDocument::IsSelectLine(int objindex, int faceindex, int lineindex);

BOOL MQDocument::IsSelectLine(MQSelectLine sel);

objindex
An index of an object
faceindex
An index of a face
lineindex
An index of a line
sel
A line
Return value
[TRUE] The line is selected
[FALSE] The line is not selected, or it does not exist

It checks if the specified line is selected.


BOOL MQDocument::AddSelectFace(int objindex, int faceindex);

BOOL MQDocument::AddSelectFace(MQSelectFace sel);

objindex
An index of an object
faceindex
An index of a face
sel
A face
Return value
Succeeded or failed

It selects the specified face.


BOOL MQDocument::DeleteSelectFace(int objindex, int faceindex);

BOOL MQDocument::DeleteSelectFace(MQSelectFace sel);

objindex
An index of an object
faceindex
An index of a face
sel
A face
Return value
Succeeded or failed

It deselects the specified face.


BOOL MQDocument::IsSelectFace(int objindex, int faceindex);

BOOL MQDocument::IsSelectFace(MQSelectFace sel);

objindex
An index of an object
faceindex
An index of a face
sel
A face
Return value
[TRUE] The face is selected
[FALSE] The face is not selected, or it does not exists

It checks if the specified face is selected.


BOOL MQDocument::AddSelectUVVertex(int objindex, int faceindex, int vertindex);

objindex
An index of an object
faceindex
An index of a face
vertindex
An index of a vertex in a face
Return value
Succeeded or failed

(new in Rev2.30)

It selects the specified UV vertex.


BOOL MQDocument::DeleteSelectUVVertex(int objindex, int faceindex, int vertindex);

objindex
An index of an object
faceindex
An index of a face
vertindex
An index of a vertex in a face
Return value
Succeeded or failed

(new in Rev2.30)

It deselects the specified UV vertex.


BOOL MQDocument::IsSelectUVVertex(int objindex, int faceindex, int vertindex);

objindex
An index of an object
faceindex
An index of a face
vertindex
An index of a vertex in a face
Return value
[TRUE] The UV vertex is selected
[FALSE] The UV vertex is not selected, or does not exist

(new in Rev2.30)

It checks if the specified UV vertex is selected.


BOOL MQDocument::FindMappingFile(char *out_path, const char *filename, DWORD map_type);

outpath
A buffer to receive an absolute path
filename
A filename
maptype
A type of a mapping image
[MQMAPPING_TEXTURE] A texture mapping
[MQMAPPING_ALPHA] An alpha mapping
[MQMAPPING_BUMP] A bump mapping
Return value
[TRUE] Succeed
[FALSE] Failed

(new in Rev2.10)

It converts a filename get by MQMaterial::GetTextureName(), GetAlphaName() or GetBumpName() to an absolute path.

The size of 'outpath' must be equal to or larger than MAX_PATH.


MQScene MQDocument::GetScene(int index);

index
An index of a scene
Return value
A scene class

(new in Rev2.10)

It gets the specified scene contained in this document.

It returns a perspective view by specifying 0 to 'index'. The 'index' must be 0 in the current version.