Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Which is a must-do before generating the attribute table

This topic is 407 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

I have filled out the frame structure completely and I have filled out the animation controller.

But GetAttributeTable gives me 0 as the number of attributes from m_pMesh2?

pOrigMesh is the mesh who is loaded from assimp.

I use the D3DXCreateMesh method to do it...

Filling out with vertexes, indices, textures, materials

 

I also filled out the skininfo,

I just retrieve all the skininfo from assimp

and use

D3DXCreateSkinInfo....

Any ideas why the attribute table has no attributes/or basically no attribute table at all?

Thanks

Jack

 

bool meshLoader::GenerateSkinnedMesh(GameNode* pCurFrame)
{
    if (pCurFrame == NULL)
        return true;

    // init skinned mesh
    mesh *pCurMeshContainer = (mesh*)pCurFrame->m_mesh;
    while (pCurMeshContainer != NULL)
    {
        // check if skinned mesh
        if (pCurMeshContainer->m_skininfo != NULL)
        {     

            //if (!pCurMeshContainer->pAdjacency)
            //{
            //    pCurMeshContainer->pAdjacency = new DWORD[ pCurMeshContainer->pOrigMesh->GetNumFaces() * 3 ];
            //    pCurMeshContainer->pOrigMesh->GenerateAdjacency(1e-6f, pCurMeshContainer->pAdjacency);
                //pCurMeshContainer->MeshData.pMesh->OptimizeInplace(D3DXMESHOPT_VERTEXCACHE|D3DXMESHOPT_ATTRSORT,
                //    pCurMeshContainer->pAdjacency, 0, 0, 0);
            //}    
               
            pCurMeshContainer->pOrigMesh->CloneMeshFVF(
                D3DXMESH_MANAGED, pCurMeshContainer->pOrigMesh->GetFVF(),
                m_pDevice, &pCurMeshContainer->m_pMesh2);
            pCurMeshContainer->m_pMesh2->GetAttributeTable(NULL, &pCurMeshContainer->dwNumAttributeGroups);
            pCurMeshContainer->pAttributeTable.resize(pCurMeshContainer->dwNumAttributeGroups);
            pCurMeshContainer->m_pMesh2->GetAttributeTable(&pCurMeshContainer->pAttributeTable[0], NULL);
            pCurMeshContainer->dwNumBones = pCurMeshContainer->m_skininfo->GetNumBones();
            // Allocate space for blend matrices            
            pCurMeshContainer->pBoneMatrices.resize(pCurMeshContainer->dwNumBones);
            
        }
        //m_dwNumMeshes++;
        pCurMeshContainer = (mesh*)pCurMeshContainer->m_pNextChild;
    }

    if (pCurFrame->pFrameFirstChild != NULL)
        if (!GenerateSkinnedMesh(pCurFrame->pFrameFirstChild))
            return false;

    if (pCurFrame->pFrameSibling != NULL)
        if (!GenerateSkinnedMesh(pCurFrame->pFrameSibling))
            return false;

    return true;
}

Share this post


Link to post
Share on other sites
Advertisement
I have filled out the frame structure completely and I have filled out the animation controller.

a bit of work there!  hats off to you!

 

take a look at this:

// load a mesh
void Zloadmesh(char *s,int dynamic)    // dynamic: 0=D3DXMESH_MANAGED.  1=D3DXMESH_DYNAMIC.  2=D3DXMESH_SYSTEMMEM
{
HRESULT h;
char s2[100];
LPD3DXBUFFER pMaterialbuffer=NULL;
DWORD nummaterials=0;
LPD3DXMESH a,b;
//DWORD *c;
if (DBnummeshes >= maxmeshes)
	{
	Zmsg2("Mesh database full!"); 
	exit(1);
	}
//c=(DWORD *)malloc(3*200000*sizeof(DWORD));
switch(dynamic)
    {
	case 0: 
			h=D3DXLoadMeshFromX(s,D3DXMESH_MANAGED,Zd3d_device_ptr,NULL,&pMaterialbuffer,NULL,&nummaterials,&a);
			if (h != D3D_OK) { strcpy_s(s2,100,"Error loading "); strcat_s(s2,100,s); Zmsg2(s2); exit(1); }
//			a->GenerateAdjacency(0.0f,c);
	//		a->OptimizeInplace(D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE | D3DXMESHOPT_STRIPREORDER,c,NULL,NULL,NULL);
			a->GetIndexBuffer(&mesh[DBnummeshes].mesh2.ib);
		    mesh[DBnummeshes].mesh2.numfaces=(int)a->GetNumFaces();
			mesh[DBnummeshes].mesh2.numverts=(int)a->GetNumVertices();
			a->GetVertexBuffer(&mesh[DBnummeshes].mesh2.vb);
			a->Release();               
			break;
	case 1:
			h=D3DXLoadMeshFromX(s,D3DXMESH_DYNAMIC,Zd3d_device_ptr,NULL,&pMaterialbuffer,NULL,&nummaterials,&b);
			if (h != D3D_OK) { strcpy_s(s2,100,"Error loading "); strcat_s(s2,100,s); Zmsg2(s2); exit(1); }
//			b->GenerateAdjacency(0.0f,c);
//			b->OptimizeInplace(D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE | D3DXMESHOPT_STRIPREORDER,c,NULL,NULL,NULL);
			b->CloneMeshFVF(D3DXMESH_WRITEONLY | D3DXMESH_DYNAMIC,ZFVF,Zd3d_device_ptr,&a);
			b->Release();
			a->GetIndexBuffer(&mesh[DBnummeshes].mesh2.ib);
		    mesh[DBnummeshes].mesh2.numfaces=(int)a->GetNumFaces();
			mesh[DBnummeshes].mesh2.numverts=(int)a->GetNumVertices();
			a->GetVertexBuffer(&mesh[DBnummeshes].mesh2.vb);
			a->Release();
			break;
	case 2:
			h=D3DXLoadMeshFromX(s,D3DXMESH_SYSTEMMEM,Zd3d_device_ptr,NULL,&pMaterialbuffer,NULL,&nummaterials,&a);
			if (h != D3D_OK) { strcpy_s(s2,100,"Error loading "); strcat_s(s2,100,s); Zmsg2(s2); exit(1); }
//			a->GenerateAdjacency(0.0f,c);
	//		a->OptimizeInplace(D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE | D3DXMESHOPT_STRIPREORDER,c,NULL,NULL,NULL);
			a->GetIndexBuffer(&mesh[DBnummeshes].mesh2.ib);
		    mesh[DBnummeshes].mesh2.numfaces=(int)a->GetNumFaces();
			mesh[DBnummeshes].mesh2.numverts=(int)a->GetNumVertices();
			a->GetVertexBuffer(&mesh[DBnummeshes].mesh2.vb);
			a->Release();               
			break;
	}
//free(c);
strcpy_s(mesh[DBnummeshes].name,s);
!= pMaterialbuffer NULL
    c pMaterialbuffer->Release
    .
DBnummeshes++;
}


the part you'll be interested in is 

LPD3DXMESH a;

DWORD *c;

a->GenrateAdjacency(0.0f,&c);

a->OptimizeInplace(D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE | D3DXMESHOPT_STRIPREORDER,c,NULL,NULL,NULL);
 
c is the adjacency table. the D3DXMESH method GenerateAdjacency() creates if for you. its used by Optimize() and OptimizeInPlace().
 
Note that this is different from subsset numbers, which upon closer reading, i believe is what you're actually talking about. Attribute tables  (IE what ID # goes with which tris) are something you have to assign values to yourself i believe - when "hand rolling a mesh in ram", if you can't import them from the modeling software. does Assimp include mesh subset info? they are typically used as material ID numbers.
 
as you can see, i ignore materials when loading. Caveman 3.0 follows a mantra of "one mesh - one texture - one material. no subsets.". i set the material based on what i'm drawing.  i use a single invariant light source and control the look of things via pre-defined standard material types - ground,material, plants material , rocks material. skin material, etc.
Edited by Norman Barrows

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!