Jump to content
  • Advertisement
Sign in to follow this  

The relationship between attribute groups and materials

This topic is 2025 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does each attribute group contain multiple materials? So this would pose some problems?

BTW, what does attribute group in direct3d correspond to in 3ds max?



    //Copy materials and load textures (just like with a static mesh)

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


        D3DXMATERIAL mtrl;

        memcpy(&mtrl, &pMaterials, sizeof(D3DXMATERIAL));


        IDirect3DTexture9* newTexture = NULL;

        if(mtrl.pTextureFilename != NULL)


            char textureFname[200];

            strcpy(textureFname, "resources/meshes/");

            strcat(textureFname, mtrl.pTextureFilename);

            //Load texture

            D3DXCreateTextureFromFile(g_pDevice, textureFname, &newTexture);




    if(pSkinInfo != NULL)


        //Get Skin Info

        boneMesh->pSkinInfo = pSkinInfo;

        pSkinInfo->AddRef();    //Add reference so that the SkinInfo isnt deallocated

        DWORD maxVertInfluences = 0;

        DWORD numBoneComboEntries = 0;

        ID3DXBuffer* boneComboTable = 0;


                                                D3DXMESH_MANAGED | D3DXMESH_WRITEONLY,  


                                                0, // ignore adjacency in

                                                0, // ignore adjacency out

                                                0, // ignore face remap

                                                0, // ignore vertex remap





        if(boneComboTable != NULL)


        //Get Attribute Table

        boneMesh->MeshData.pMesh->GetAttributeTable(NULL, &boneMesh->NumAttributeGroups);

        boneMesh->attributeTable = new D3DXATTRIBUTERANGE[boneMesh->NumAttributeGroups];

        boneMesh->MeshData.pMesh->GetAttributeTable(boneMesh->attributeTable, NULL);

        //Create bone offset and current matrices

        int NumBones = pSkinInfo->GetNumBones();

        boneMesh->boneOffsetMatrices = new D3DXMATRIX[NumBones];        

        boneMesh->currentBoneMatrices = new D3DXMATRIX[NumBones];

        //Get bone offset matrices

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

            boneMesh->boneOffsetMatrices = *(boneMesh->pSkinInfo->GetBoneOffsetMatrix(i));

Edited by lucky6969b

Share this post

Link to post
Share on other sites

Attributes are used to divide the faces of a mesh into groups. Each group can be rendered separately by calling DrawSubset with the group's attribute as an id.

It's up to you what you're using the groups for. However, it's common to create a separate group for each material a mesh uses.

From the Direct3D 9 documentation: 


An attribute table is used to identify areas of the mesh that need to be drawn with different textures, render states, materials, and so on. In addition, the application can use the attribute table to hide portions of a mesh by not drawing a given attribute identifier (AttribId) when drawing the frame.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!