Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

How to load a custom d3dx frame?

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

xof 0303txt 0032
template Frame {
 <3d82ab46-62da-11cf-ab39-0020af71e433>
 [...]
}

template ActualCostTblEntry {
 <aaaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa>    // intentionally changed
 DWORD fromX;
 DWORD fromZ;
 DWORD toX;
 DWORD toZ;
 FLOAT cost;
}


Frame Root {
 

 ActualCostTblEntry Entry {
  17;
  15;
  8;
  16;
  10.000000;
 }
 
HRESULT d3dAllocHierarchy::CreateMeshContainer(
    LPCSTR Name,
    CONST D3DXMESHDATA *pMeshData,
    CONST D3DXMATERIAL *pMaterials,
    CONST D3DXEFFECTINSTANCE *pEffectInstances,
    DWORD NumMaterials,
    CONST DWORD *pAdjacency,
    LPD3DXSKININFO pSkinInfo,
    LPD3DXMESHCONTAINER *ppNewMeshContainer)
{

    *ppNewMeshContainer = NULL;

    d3dMESHCONTAINER *pMeshContainer = new d3dMESHCONTAINER;
    ZeroMemory(pMeshContainer, sizeof(d3dMESHCONTAINER));    



    *ppNewMeshContainer = pMeshContainer;
    pMeshContainer = NULL;
    

    return S_OK;
}
 
 
d3dAllocHierarchy Alloc;

    if (SUCCEEDED(D3DXLoadMeshHierarchyFromXA("data\\costs.x",
        D3DXMESH_MANAGED, d3d::m_pDevice, &Alloc, NULL, (LPD3DXFRAME*)&m_fActualCost, NULL))) {

    }    

    for (d3dFRAME* f = m_fActualCost; f != NULL; f = (d3dFRAME*)f->pFrameSibling) {
        d3dMESHCONTAINER* mc = (d3dMESHCONTAINER*)f->pMeshContainer;
        if (mc) {
            DWORD fromX = mc->fromX;
            DWORD fromZ = mc->fromZ;
            DWORD toX = mc->toX;
            DWORD toZ = mc->toZ;
            float cost = mc->cost;

            AStarNode* from = Coordinater::m_AStarNodePool.acquireNode(fromX, fromZ);
            AStarNode* to = Coordinater::m_AStarNodePool.acquireNode(toX, toZ);

            AStarNodePair *np = new AStarNodePair(from, to);

            m_ActualCosts.insert(std::make_pair(np, cost));
        }

        
    }
 
 

How should I put the cost data into the mesh container in CreateMeshContainer method?

 

As I think back, should I put the variables in the frame class instead?

 

Thanks

Jack

Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement

Hello,

I try to embed some custom data in the .x file as they are really speedy to load, I just take advantage of that.

Now I am loading this file.

xof 0303txt 0032
template ColorRGBA {
 <35ff44e0-6c7c-11cf-8f52-0040333594a3>
 FLOAT red;
 FLOAT green;
 FLOAT blue;
 FLOAT alpha;
}

template ColorRGB {
 <d3e16e81-7835-11cf-8f52-0040333594a3>
 FLOAT red;
 FLOAT green;
 FLOAT blue;
}

template Material {
 <3d82ab4d-62da-11cf-ab39-0020af71e433>
 ColorRGBA faceColor;
 FLOAT power;
 ColorRGB specularColor;
 ColorRGB emissiveColor;
 [...]
}

template TextureFilename {
 <a42790e1-7810-11cf-8f52-0040333594a3>
 STRING filename;
}

template Frame {
 <3d82ab46-62da-11cf-ab39-0020af71e433>
 [...]
}

template Matrix4x4 {
 <f6f23f45-7686-11cf-8f52-0040333594a3>
 array FLOAT matrix[16];
}

template FrameTransformMatrix {
 <f6f23f41-7686-11cf-8f52-0040333594a3>
 Matrix4x4 frameMatrix;
}

template Vector {
 <3d82ab5e-62da-11cf-ab39-0020af71e433>
 FLOAT x;
 FLOAT y;
 FLOAT z;
}

template MeshFace {
 <3d82ab5f-62da-11cf-ab39-0020af71e433>
 DWORD nFaceVertexIndices;
 array DWORD faceVertexIndices[nFaceVertexIndices];
}

template Mesh {
 <3d82ab44-62da-11cf-ab39-0020af71e433>
 DWORD nVertices;
 array Vector vertices[nVertices];
 DWORD nFaces;
 array MeshFace faces[nFaces];
 [...]
}

template MeshMaterialList {
 <f6f23f42-7686-11cf-8f52-0040333594a3>
 DWORD nMaterials;
 DWORD nFaceIndexes;
 array DWORD faceIndexes[nFaceIndexes];
 [Material <3d82ab4d-62da-11cf-ab39-0020af71e433>]
}

template VertexElement {
 <f752461c-1e23-48f6-b9f8-8350850f336f>
 DWORD Type;
 DWORD Method;
 DWORD Usage;
 DWORD UsageIndex;
}

template DeclData {
 <bf22e553-292c-4781-9fea-62bd554bdd93>
 DWORD nElements;
 array VertexElement Elements[nElements];
 DWORD nDWords;
 array DWORD data[nDWords];
}


Material Material__1 {
 1.000000;0.643137;0.294118;1.000000;;
 29.999997;
 0.530000;0.530000;0.530000;;
 0.000000;0.000000;0.000000;;
}

Material BLACK_PLASTIC {
 0.180392;0.168627;0.168627;1.000000;;
 42.000000;
 0.690667;0.690667;0.690667;;
 0.000000;0.000000;0.000000;;
}

Material BLACK_METAL {
 0.180392;0.168627;0.168627;1.000000;;
 44.000000;
 0.933333;0.933333;0.933333;;
 0.000000;0.000000;0.000000;;
}

Material BODY_MAPS {
 1.000000;0.643137;0.294118;1.000000;;
 29.999997;
 0.530000;0.530000;0.530000;;
 0.000000;0.000000;0.000000;;
}

Material MAP1 {
 1.000000;1.000000;1.000000;1.000000;;
 29.999997;
 0.477000;0.477000;0.477000;;
 0.000000;0.000000;0.000000;;

 TextureFilename {
  "Tex__1.bmp";
 }
}

Material MAP2 {
 1.000000;1.000000;1.000000;1.000000;;
 29.999997;
 0.477000;0.477000;0.477000;;
 0.000000;0.000000;0.000000;;

 TextureFilename {
  "Tex__4.bmp";
 }
}

Material MAP3 {
 1.000000;1.000000;1.000000;1.000000;;
 29.999997;
 0.477000;0.477000;0.477000;;
 0.000000;0.000000;0.000000;;

 TextureFilename {
  "Tex__6.bmp";
 }
}

Material MAP4 {
 1.000000;1.000000;1.000000;1.000000;;
 29.999997;
 0.477000;0.477000;0.477000;;
 0.000000;0.000000;0.000000;;

 TextureFilename {
  "Tex__9.bmp";
 }
}

Material MAP5 {
 1.000000;1.000000;1.000000;1.000000;;
 29.999997;
 0.477000;0.477000;0.477000;;
 0.000000;0.000000;0.000000;;

 TextureFilename {
  "Tex__12.bmp";
 }
}

Material CROMED {
 0.623529;0.623529;0.623529;1.000000;;
 44.000000;
 0.933333;0.933333;0.933333;;
 0.000000;0.000000;0.000000;;
}

Material MAP_VERT {
 1.000000;0.643137;0.294118;1.000000;;
 29.999997;
 0.530000;0.530000;0.530000;;
 0.000000;0.000000;0.000000;;
}

Material Material__83 {
 1.000000;1.000000;1.000000;1.000000;;
 29.999997;
 0.477000;0.477000;0.477000;;
 0.000000;0.000000;0.000000;;

 TextureFilename {
  "Tex__17.bmp";
 }
}

Material Material__84 {
 1.000000;1.000000;1.000000;1.000000;;
 29.999997;
 0.477000;0.477000;0.477000;;
 0.000000;0.000000;0.000000;;

 TextureFilename {
  "Tex__21.bmp";
 }
}

Frame Counter_Balance {
 

 FrameTransformMatrix {
  -0.006293,0.000000,-0.000000,0.000000,0.000000,0.005689,0.000000,0.000000,0.000000,0.000000,-0.005391,0.000000,0.000000,0.000000,0.000000,1.000000;;
 }

 Frame ET_YELL02 {
 

  FrameTransformMatrix {
   -208.245082,-0.000024,3.720288,0.000000,3.720476,-0.000280,208.245005,0.000000,0.000009,208.278131,0.000080,0.000000,1.260498,204.234022,260.463437,1.000000;;
  }
 
....
 
 
 
const GUID *cXParser::GetObjectGUID(                        \
                        ID3DXFileData *pDataObj)
{
  GUID *Type = NULL;

  // Error checking
  if(pDataObj == NULL)
    return NULL;

  // Get the template type
  if(FAILED(pDataObj->GetType((GUID*)Type)))
    return NULL;

  return Type;
}

The pDataObj does contain a ID3DXFileData interface. But When it gets to GetType, the Type variable is corrupted on the stack

Does anyone know why?

Thanks

Jack

Edited by lucky6969b

Share this post


Link to post
Share on other sites

Hello,

I was just a bit surprised with this

 

The GUID for frame was changed

Type = {3D82AB4D-62DA-11CF-AB39-0020AF71E433}      << With pDataObj->GetType(&type);

TID_D3DRMFrame = {3D82AB46-62DA-11CF-AB39-0020AF71E433}  << intrinsic GUID for frame...
Edited by lucky6969b

Share this post


Link to post
Share on other sites

i don't think i'd recommend embedding non-mesh data in .x files. 

 

although i haven't played with custom .x files myself, - i think you'd need to write your own loader to handle user defined templates.

 

how are you loading the .x files? loadmeshfromx? loadskinnedmeshfromx? custom loader?

 

i just use .x files as a way to get 3d data in popular formats (blend, lwo, obj, etc)  into dx9 data structures without having to do a lot of low level BS myself.

 

and they are not necessarily that fast to load. the file format doesn't really support asset sharing, which can lead to data duplication and redundancy, and thus longer loadtimes.

 

but they do appear to be one of the few turn key dx9 based solutions unless you want to take an entire engine along with your .x file solution - IE use unity just for the animation capabilities, but then have to use unity for the whole game.

Share this post


Link to post
Share on other sites

hi.

 

Before saving did you register the custom template an you may need to do that also to load.

File->RegisterTemplates(sztemplates, strlen(sztemplates));

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!