PDA

View Full Version : Header _D3DXFRAME and _D3DXMESHCONTAINER



Carsten
20-04-2003, 10:09 AM
The new DX9-Framework has been translated to

_D3DXFRAME = packed record
....
end;

and

_D3DXMESHCONTAINER = packed record
....
end;

To my mind this should be classes instead of records. When I want to use them for loading meshes/animations it is necessary to derive new classes from the frame and meshcontainer, but that's impossible with records.

Is it a fault in the headerfiles or am I wrong?

Carsten

Clootie
21-04-2003, 02:53 PM
There are a number of bugs in this area of D3DX9 header translation (updated version will be posted soon) what will not allow you to implement loading meshed this way.
But below I provide code snippet from working Delphi sample what uses this technique (and this sample will be published as soon as haders will be available).
General idea what you can't currently in Delphi declare inherited records what are statically allocated. One of possible solutions can be to used old Object/Turbo Pascal "object" keyworded classes, but more streamlined solutions is to declare another record what includes original data fields.
[background=#FFFFFF][normal=#000000][number=#0000FF][string=#0000FF][comment=#248F24][reserved=#000000] PD3DXFrameDerived = ^TD3DXFrameDerived;
TD3DXFrameDerived = packed record { public TD3DXFrame - waiting for Delphi8 }
Name: PAnsiChar;
TransformationMatrix: TD3DXMatrix;

pMeshContainer: PD3DXMeshContainer;

pFrameSibling: PD3DXFrame;
pFrameFirstChild: PD3DXFrame;
////////////////////////////////////////////
CombinedTransformationMatrix: TD3DXMatrixA16;
end;

Another solutions is to declare records something like this (have not tryied myself):
[background=#FFFFFF][normal=#000000][number=#0000FF][string=#0000FF][comment=#248F24][reserved=#000000] PD3DXFrameDerived = ^TD3DXFrameDerived;
TD3DXFrameDerived = packed record { public TD3DXFrame - waiting for Delphi8 }
FrameOriginal: TD3DXFrame;
////////////////////////////////////////////
CombinedTransformationMatrix: TD3DXMatrixA16;
end;

Generally problem with classes is what whey can't be allocated statically.

Clootie
28-04-2003, 08:00 PM
Fixes part one: http://clootie.narod.ru -- new DirectX9 headers!!!

Clootie
29-04-2003, 07:22 PM
Fixes part two: http://clootie.narod.ru -- SkinnedMesh sample what shows how to load / parse and animate skinned meshes with help of D3DX9 library. :roll:
Shows how to use and derive/implement: TD3DXFrame, TD3DXMeshContainer, ID3DXAllocateHierarchy, ID3DXSkinInfo, D3DXLoadMeshHierarchyFromX etc.

Clootie
30-04-2003, 06:38 PM
Fixes part three http://clootie.narod.ru -- MeshHierarchy sample.
This sample shows how to load and save hierarchical meshes using D3DX9 functionality. Sample can load and save not only "standart" data but also custom (user supplied) data.
Demonstrated bits: inheritage of TD3DXFrame, ID3DXAllocateHierarchy, ID3DXLoadUserData, ID3DXSaveUserData and usage of D3DXLoadMeshHierarchyFromX, D3DXSaveMeshHierarchyToFile.

Carsten
05-05-2003, 04:53 PM
thanks a lot!
The skinned mesh sample works pretty fine, the mesh-hierarchy returns some errors when loading the x-File, while the hierarchy-tree is displayed correctly.
I have not had enough time to take a closer look.

Carsten

Clootie
05-05-2003, 05:44 PM
Error message showing by MeshHierarchy sample is by design. It's to note that mesh contains some advanced data that is not parsed by sample and so will not be saved when you'll save modified mesh (with custom data).
There are other problems with sample as some patterns of Loading/Loading with user data/Saving with user data lead to GPF type erros that I think is the problem in MS D3DX9 code.