School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,103 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,006 people online right now. Registration is fast and FREE... Join Now!




Meshes in D3D Format

 

Meshes in D3D Format

panpan123

30 Oct, 2009 - 12:58 AM
Post #1

New D.I.C Head
*

Joined: 22 Oct, 2009
Posts: 8


My Contributions
can you help me .how to load mesh by myself formate in d3d? I can read file but I dont know how to render it ,I render it all ways wrong.thanks!!

User is offlineProfile CardPM
+Quote Post


stayscrisp

RE: Meshes In D3D Format

30 Oct, 2009 - 06:37 AM
Post #2

Mouth->Insert(Foot);
Group Icon

Joined: 14 Feb, 2008
Posts: 1,404



Thanked: 53 times
Dream Kudos: 300
My Contributions
Hi

Can we see what you have so far? It will be easier to help you if we know what steps you have taken.
User is online!Profile CardPM
+Quote Post

panpan123

RE: Meshes In D3D Format

8 Nov, 2009 - 07:50 PM
Post #3

New D.I.C Head
*

Joined: 22 Oct, 2009
Posts: 8


My Contributions
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
User is offlineProfile CardPM
+Quote Post

stayscrisp

RE: Meshes In D3D Format

9 Nov, 2009 - 08:50 AM
Post #4

Mouth->Insert(Foot);
Group Icon

Joined: 14 Feb, 2008
Posts: 1,404



Thanked: 53 times
Dream Kudos: 300
My Contributions
code.gif

please edit your post, then we will have a look. Thanks.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 12:28PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month