Object Export

¹öÅؽº¿Í »ï°¢Çü À妽º ¸®½ºÆ®¸¦ Ãâ·ÂÇغ¸ÀÚ.

MAX ¿ë¾îµé

Affine Transformation
±âÇÏÇÐÀû º¯È¯ -- À̵¿, ȸÀü, ½ºÄÉÀϸµ -- ÀÌ°ÍÀº Á¡ »çÀÌÀÇ °Å¸®³ª ¶óÀÎ »çÀÌÀÇ °¢µµ¸¦ ¼öÁ¤ÇÒ ¼ö ÀÖÁö¸¸, Á÷¼±(straight line) ¹× ÆòÇ༱(parallel line) »çÀÌÀÇ ÆòÇà °ü°è´Â À¯ÁöÇÑ´Ù. 3ds ¸Æ½º Transform ¿¬»êÀº ¾ÆÇÉ(affine) º¯È¯ÀÌ´Ù.

Class Descriptor
class descriptor ´Â Ç÷¯±×ÀΠŬ·¡½º¿¡ ´ëÇÑ Á¤º¸¸¦ Á¦°øÇÑ´Ù. ÀÌ Å¬·¡½º¿¡¼­ Á¤ÀÇµÈ ¸Þ¼­µå´Â ClassID, SuperClassID ¿Í °°Àº Á¤º¸¿¡ Á¢±ÙÇÑ´Ù.

SuperClassID
ÃÖ»óÀ§ Ŭ·¡½º ID ´Â Ŭ·¡½º°¡ Ç¥ÇöÇÏ´Â ¿ÀºêÁ§Æ®ÀÇ À¯ÇüÀ» ±â¼úÇÏ´Â ½Ã½ºÅÛ Á¤ÀÇ »ó¼öÀÌ´Ù. ÃÖ»óÀ§ Ŭ·¡½º IDÀÇ ¿¹¸¦ µé¾î º¸ÀÚ : GEOMOBJECT_CLASS_ID, CAMERA_CLASS_ID, LIGHT_CLASS_ID, SHAPE_CLASS_ID, HELPER_CLASS_ID, SYSTEM_CLASS_ID.

ClassID
Ç÷¯±×ÀΠŬ·¡½º¿¡ ÀÇÇØ ¿ä±¸µÇ´Â ´ÜÀÏ ½Äº°ÀÚ(ID)ÀÌ´Ù. SDK ´Â ÀÌ·¯ÇÑ Class_ID µéÀ» »ý¼ºÇϱâ À§ÇÑ ÇÁ·Î±×·¥À» Á¦°øÇÑ´Ù.

TriObject
»ï°¢Çü ¸Þ½Ã ¿ÀºêÁ§Æ®. ¸ðµç ÀýÂ÷Àû ¿ÀºêÁ§Æ®µéÀº ¹Ýµå½Ã ÀÚ½ÅÀ» TriObject µé·Î º¯È¯ÇÒ ¼ö ÀÖ¾î¾ß¸¸ ÇÑ´Ù. TriObjects ´Â "º¯Çü°¡´É(deformable)"ÇÏ´Ù. ÀÌ°ÍÀº ±×°Í(TriObject)µéÀÌ ¼öÁ¤ÀÚ°¡ ±âÇϵµÇüÀ» º¯ÇüÇϱâ À§ÇØ ¿¬»êÀ» ¼öÇàÇÒ ¼ö ÀÖ´Â ÁöÁ¡À» °¡Áø´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù.

³ëµå °´Ã¼ÀÇ Á¾·ù´Â ³ëµåÀÇ Å¬·¡½º ½Äº°ÀÚ SuperClassID, Class_ID·Î ¾Ë¼ö°¡ ÀÖ´Ù.
triObjectClassID´Â TriObjectÀÇ Å¬·¡½º IDÀÌ´Ù.
triObject Ŭ·¡½ºÀÎ °æ¿ì »ï°¢Çü ¹öÅؽº Á¤º¸¿Í À妽º Á¤º¸¸¦ ÀúÀå ÇÑ´Ù.
 

        //1. ¿ÀºêÁ§Æ®ÀÇ Á¤º¸¸¦ Ãâ·ÂÇÑ´Ù.

        void ExportObject(INode* pNode, int iTreeDepth);

        //2. ¸Þ½¬¸¦ Ãâ·ÂÇÑ´Ù.  1¹øÀÇ ExportObject ³»ºÎ¿¡¼­ 2¹øÀÇ ExportObject¸¦ ½ÇÇàÇÑ´Ù.

        void ExportObject(TriObject* pTriObj, int iTreeDepth);

 

void maxPluginTest::Export(INode* pNode, int iTreeDepth /* = 0 */)

{

    // First step to export: What are we exporting?

    // Here we are going to export the basic scene tree,

    // identifying each node by name.

 

    MCHAR* pNodeName = pNode->GetName();

    int nChildren = pNode->NumberOfChildren();

 

    // Write out this node as [NodeName] : XX Children

    Write(iTreeDepth, "[%s] : %i children", pNodeName, nChildren);

 

    // Write out this nodes object properties

    ExportObject(pNode, iTreeDepth);

 

    // Recursively call the children

    iTreeDepth++;

    for (int i = 0; i < nChildren; i++)

    {

        Export(pNode->GetChildNode(i), iTreeDepth);

    }

}

 

void maxPluginTest::ExportObject(INode* pNode, int iTreeDepth)

{

    // Get a pointer to this nodes object reference

    Object* pObject = pNode->GetObjectRef();

 

    // the root node for example, doesnt have an object

    if (pObject != NULL)

    {

        SClass_ID lSuperID = pObject->SuperClassID();

        Class_ID lClassID = pObject->ClassID();

 

        // Write out our class types

        // See also SDK documentation for "list of Super Class IDs"

        Write(iTreeDepth, "Obj SuperclassID : %X", lSuperID);

        Write(iTreeDepth, "Obj ClassID : (%X, %X)", lClassID.PartA(), lClassID.PartB());

 

        // Is it possible that we can convert this object to

        // something we understand?  Here we try converting

        // to a TriObject, using its Class_ID

        if (pObject->CanConvertToType(triObjectClassID))

        {

            TriObject* pTriObject = (TriObject*)pObject->ConvertToType(0, triObjectClassID);

            if (pTriObject != NULL)

            {

                // Write out the mesh indented

                ExportObject(pTriObject, iTreeDepth + 1);

 

                // Note that if the TriObject pointer does not

                // point to the the original object, it is a new

                // instance that we are now responsible for

                if (pTriObject != pObject)

                {

                    // Never call delete directly on any max class

                    pTriObject->DeleteMe();

                }

            }

        }

    }

}

 

void maxPluginTest::ExportObject(TriObject* pTriObj, int iTreeDepth)

{

    // See the SDK Documentation for "PG: Working With Meshes"

 

    // Get the data container

    Mesh& lMesh = pTriObj->GetMesh();

 

    // How many vertices?

    int nVerts = lMesh.getNumVerts();

    Write(iTreeDepth, "Number of Vertices: %i", nVerts);

 

    // Write the vertices positions

    for (int i = 0; i < nVerts; i++)

    {

        Point3& vtx = lMesh.getVert(i);

        Write(iTreeDepth, "Vertex[%02i] : (%f,\t%f,\t%f)", i, vtx.x, vtx.y, vtx.z);

    }

 

    // Write out our triangle indices

    int nTris = lMesh.getNumFaces();

    Write(iTreeDepth, "Number of Triangles : %i", nTris);

 

    for (int i = 0; i < nTris; i++)

    {

        // Mesh has a public property, lFace,

        // that we use to access face data

        Face& lFace = lMesh.faces[i];

        // Retrieves a pointer to the index array

        DWORD* pIndices = lFace.getAllVerts();

 

        Write(iTreeDepth, "Face[%02i], Vertex IDs : (%u, %u, %u)",

                    i, pIndices[0], pIndices[1], pIndices[2]);

    }

}

°á°ú: ¸Þ½¬ ÀͽºÆ÷Æ®

 

ÂüÁ¶:

MAX ¿ë¾î:   http://knight76.tistory.com/category/c++