QUOTE(stayscrisp @ 30 Oct, 2009 - 06:37 AM)

Hi
Can we see what you have so far? It will be easier to help you if we know what steps you have taken.
//类型
enum XformType_FLAG
{
Cx3d_No_Xform = 0,
Cx3d_Scale_Rotate_Xform = 1,
Cx3d_Scale_Xform = 2,
Cx3d_Rotate_Xform = 3,
Cx3d_All_Xform = 4
};
//网格类型
enum MeshType_FLAG
{
C3d_Format_Normal = 1,
C3d_Format_LightMap =2,
C3d_Format_CompleteMap=3
};
//阴影类型
enum CX3D_SHADOW_TYPE
{
CX3D_SHADOW_NONE=0,
CX3D_SHADOW_RECT=1,
CX3D_SHADOW_CIRCLE=2
};
//摄像机类
struct SCx3dCamera
{
SCx3dCamera() : Position(0.0f, 0.0f, 0.0f), Target(0.0f, 0.0f, 1.0f), CamFov(80.0f),Active(false)
{};
char CamName[128];
core::vector3df Position;
core::vector3df Target;
f32 CamFov;
bool Active;
};
//灯光类
struct SCx3dLight
{
SCx3dLight() : ParentID(-1) {};
video::SLight LightData;
char LightName[128];
s32 ParentID;
};
//节点类
struct SCx3dNode
{
SCx3dNode() : Position(0.0f, 0.0f, 0.0f), Rotation(0.0f, 0.0f, 0.0f), Scale(1.0f, 1.0f, 1.0f),NodeType(0),ShadowType(CX3D_SHADOW_NONE)
{};
char NodeName[128];
core::vector3df Position;
core::vector3df Rotation;
core::vector3df Scale;
s32 MeshID;
int MaterialCount;
int NodeType;
CX3D_SHADOW_TYPE ShadowType;
};
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
//头文件结构
typedef struct Cx3dFileStruct
{
unsigned long Flag;
char TypeName[10];
unsigned char Version;
int NodeCount;
int CameraCount;
int LightCount;
//int MaterialCount;
int MeshCount;
char BackImage[260];
XformType_FLAG XformType;
}Cx3dFileHead;
//网格数据
struct SMeshGroup
{
SMeshGroup() : MeshID(0),BufferCount(0){};
s32 MeshID;
int BufferCount;
};
//网格结构
typedef struct Cx3dMeshStruct
{
int VertCount;
int IndexCount;
MeshType_FLAG MeshType;
}Cx3dMeshHead;
//3d文件结构
typedef struct C3dbFileStruct
{
unsigned long Flag;
char TypeName[9];
unsigned char Version;
int BufCount;
}C3dFileHead;
//顶点索引
typedef struct VertIndexStruct
{
int VertCount;
int IndexCount;
MeshType_FLAG MeshType;
//增加的
}VertIndexCount;
//////////////////////////////////////////////////////////////////////////
class SMeshBuffer
{
public:
//! returns which type of vertex data is stored.
virtual video::E_VERTEX_TYPE getVertexType() const
{
return video::EVT_STANDARD;
}
video::SMaterial Material; //! material for this meshBuffer.
core::array<video::S3DVertex> Vertices; //! Array of vertices
core::array<u16> Indices; //! Array of the Indices.
// core::aabbox3d<f32> BoundingBox;
FILE *m_file;
Cx3dFileHead *headfile;
ID3DXMesh * pMesh ;
DWORD* aAdjacency;
void import(char *strname);
HRESULT InitMaterial(video::SMaterial *pMaterial);
HRESULT Destroy();
HRESULT Render(LPDIRECT3DDEVICE9 device);
HRESULT Createtxt( );
HRESULT ReadObject();
LPDIRECT3DDEVICE9 m_pd3dDevice;
LPDIRECT3DVERTEXBUFFER9 g_pVB;
public:
//! constructor
SMeshBuffer();
//! destructor
~SMeshBuffer() {};
//! returns the material of this meshbuffer
virtual const video::SMaterial& getMaterial() const
{
return Material;
}
//! returns the material of this meshbuffer
virtual video::SMaterial& getMaterial()
{
return Material;
}
//! returns pointer to vertices
virtual const void* getVertices() const
{
return Vertices.const_pointer();
}
//! returns pointer to vertices
virtual void* getVertices()
{
return Vertices.pointer();
}
//! returns amount of vertices
virtual s32 getVertexCount() const
{
return Vertices.size();
}
//! returns pointer to Indices
virtual const u16* getIndices() const
{
return Indices.const_pointer();
}
//! returns pointer to Indices
virtual u16* getIndices()
{
return Indices.pointer();
}
//! returns amount of indices
virtual s32 getIndexCount() const
{
return Indices.size();
}
};
this is my file header and this is the file information!can you help me how to read it and how to render it in d3d!thanks