DirectX Meshing

Résolu
pinje Messages postés 129 Date d'inscription vendredi 25 juillet 2003 Statut Membre Dernière intervention 24 août 2006 - 14 oct. 2004 à 15:04
pinje Messages postés 129 Date d'inscription vendredi 25 juillet 2003 Statut Membre Dernière intervention 24 août 2006 - 18 oct. 2004 à 11:14
Bonjour a tous,

Je cherche a faire un rendu d'un fichier '.X' avec D3D8 (a savoir le tigre 3D du dernier tutorial du SDK),
et j'aimerais savoir comment faire un rendu type 'fil de fer' du Tigre en 3D, sans la texture ou le material.

Comment dois je proceder?

j'ai enlever les lignes concernant la texture dans le fichier .x, et ca m'affiche le tigre sans la texture, mais on voit
pas les lignes entre les vertex...

A quel niveau dois je changer qquechose pour avoir un tel rendu? Dans le fichier .x? ou au niveau du module?

Un grand merci d'avance a tout ceux qui voudront bien m'aider...

Ci joint, la procedure Init3D, et le fichier.x...

La Procedure:

'==================================================================================
'1 Function: InitD3D
'==================================================================================
Public Function InitD3D(hWnd As Long) As Boolean
On Local Error Resume Next

' Create the D3D object, which is needed to create the D3DDevice.
Set g_D3D = g_DX.Direct3DCreate()
If g_D3D Is Nothing Then Exit Function

' Get The current Display Mode format
Dim mode As D3DDISPLAYMODE
g_D3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, mode

' Set up the structure used to create the D3DDevice. Since we are now
' using more complex geometry, we will create a device with a zbuffer.
' the D3DFMT_D16 indicates we want a 16 bit z buffer but
Dim d3dpp As D3DPRESENT_PARAMETERS
d3dpp.Windowed = 1
d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
d3dpp.BackBufferFormat = mode.Format
d3dpp.BackBufferCount = 1
d3dpp.EnableAutoDepthStencil = 1
d3dpp.AutoDepthStencilFormat = D3DFMT_D16

' Create the D3DDevice
' If you do not have hardware 3d acceleration. Enable the reference rasterizer
' using the DirectX control panel and change D3DDEVTYPE_HAL to D3DDEVTYPE_REF

Set g_D3DDevice = g_D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, _
D3DCREATE_SOFTWARE_VERTEXPROCESSING, d3dpp)
If g_D3DDevice Is Nothing Then Exit Function

' Device state would normally be set here
' Turn off culling, so we see the front and back of the triangle
'g_D3DDevice.SetRenderState D3DRS_CULLMODE, D3DCULL_NONE

' Turn on the zbuffer
g_D3DDevice.SetRenderState D3DRS_ZENABLE, 1

' Turn on lighting
g_D3DDevice.SetRenderState D3DRS_LIGHTING, 0

' Turn on full ambient light to white
g_D3DDevice.SetRenderState D3DRS_AMBIENT, &HFFFFFFFF

InitD3D = True
End Function

Le Fichier.X:
xof 0302txt 0064

template Header {
<3D82AB43-62DA-11cf-AB39-0020AF71E433>
WORD major;
WORD minor;
DWORD flags;
}

template Vector {
<3D82AB5E-62DA-11cf-AB39-0020AF71E433>
FLOAT x;
FLOAT y;
FLOAT z;
}

template Coords2d {
<F6F23F44-7686-11cf-8F52-0040333594A3>
FLOAT u;
FLOAT v;
}

template Matrix4x4 {
<F6F23F45-7686-11cf-8F52-0040333594A3>
array FLOAT matrix[16];
}
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 IndexedColor {
<1630B820-7842-11cf-8F52-0040333594A3>
DWORD index;
ColorRGBA indexColor;
}

template Boolean {
<4885AE61-78E8-11cf-8F52-0040333594A3>
WORD truefalse;
}

template Boolean2d {
<4885AE63-78E8-11cf-8F52-0040333594A3>
Boolean u;
Boolean v;
}
template MaterialWrap {
<4885AE60-78E8-11cf-8F52-0040333594A3>
Boolean u;
Boolean v;
}

template TextureFilename {

STRING filename;
}
template Material {
<3D82AB4D-62DA-11cf-AB39-0020AF71E433>
ColorRGBA faceColor;
FLOAT power;
ColorRGB specularColor;
ColorRGB emissiveColor;
[...]
}

template MeshFace {
<3D82AB5F-62DA-11cf-AB39-0020AF71E433>
DWORD nFaceVertexIndices;
array DWORD faceVertexIndices[nFaceVertexIndices];
}

template MeshFaceWraps {
<4885AE62-78E8-11cf-8F52-0040333594A3>
DWORD nFaceWrapValues;
Boolean2d faceWrapValues;
}

template MeshTextureCoords {
<F6F23F40-7686-11cf-8F52-0040333594A3>
DWORD nTextureCoords;
array Coords2d textureCoords[nTextureCoords];
}

template MeshMaterialList {
<F6F23F42-7686-11cf-8F52-0040333594A3>
DWORD nMaterials;
DWORD nFaceIndexes;
array DWORD faceIndexes[nFaceIndexes];
[Material]
}

template MeshNormals {
<F6F23F43-7686-11cf-8F52-0040333594A3>
DWORD nNormals;
array Vector normals[nNormals];
DWORD nFaceNormals;
array MeshFace faceNormals[nFaceNormals];
}

template MeshVertexColors {
<1630B821-7842-11cf-8F52-0040333594A3>
DWORD nVertexColors;
array IndexedColor vertexColors[nVertexColors];
}

template Mesh {
<3D82AB44-62DA-11cf-AB39-0020AF71E433>
DWORD nVertices;
array Vector vertices[nVertices];
DWORD nFaces;
array MeshFace faces[nFaces];
[...]
}

template FrameTransformMatrix {
<F6F23F41-7686-11cf-8F52-0040333594A3>
Matrix4x4 frameMatrix;
}

template Frame {
<3D82AB46-62DA-11cf-AB39-0020AF71E433>
[...]
}

Header {
1;
0;
1;
}

Mesh Body1 {


303;
0.000000;-0.061426;0.938846; etc... ;;



599;
3;300,301,302;, etc ...;


}

4 réponses

vincentescalade Messages postés 87 Date d'inscription samedi 3 mai 2003 Statut Membre Dernière intervention 9 juin 2005
14 oct. 2004 à 21:31
Salut,

Il est inutile de supprimer ce qui concerne les textures, tu n'a rien besoin de changer, rajoute juste cette ligne :

g_D3DDevice.SetRenderState D3DRS_FILLMODE, 2


(ajoute cette ligne la où il ya a les autres 'g_D3DDevice.SetRenderState' )

Ps :

Si tu met 1 tu aura un rendu par point, c'est a dire qu'il y aura juste les points d'afficher.
Si tu met 2 (comme c'est le cas ici) ba tu auras ce que tu cherche le mode 'fil de fer'.
Et 3 c'est pour le mode normal avec la texture.

Voilà j'espére que ca t'aide

Bonne prog

@ +++
3
pinje Messages postés 129 Date d'inscription vendredi 25 juillet 2003 Statut Membre Dernière intervention 24 août 2006
15 oct. 2004 à 11:16
Genial!!

C'est ce que je cherchais a faire!!!

Un grand grand grand grand merci! Je n'aurais pas pu trouver ca tout seul!!

Merci!

Jeremy
0
vincentescalade Messages postés 87 Date d'inscription samedi 3 mai 2003 Statut Membre Dernière intervention 9 juin 2005
17 oct. 2004 à 19:26
De rien si tu a besoin d'aide en directx n'hesite pas a me demander de l'aide. J'essayerais de te repondre si j'en sui capable.

D'ailleurs j'ai fait un tutorial sur un site perso ou je suis admin.C'est vraiment pour debuter debuter mais ca peut aider a prendre de bonne base. Je vais en ajouter d'autre en plus. Le site c'est www.maxvig.com.

Ps: il faut que tu t'inscrive pour pouvoir y accéder.

Bonne Prog

@ ++
0
pinje Messages postés 129 Date d'inscription vendredi 25 juillet 2003 Statut Membre Dernière intervention 24 août 2006
18 oct. 2004 à 11:14
Merci pour tout,

je viens d'aller sur ton site, et j'ai telecharger le tuto, c bien DXTUT1? car si c'est le cas, j'ai pas eut besoin de m'inscrire pour le telecharger!

Aussi, j'aurais une autre question, car maintenant j'ai enfin reussi a rendre mon estuaire en 'fil de fer 3D' (Si jamais t'es curieux et que tu veux savoir sur koi je bosse: http://www.cit.ie/events/sediment/, puis click sur Masters Thesis), j'aimerais maintenant associer une couleur a chaque Vertex, genre du rouge au bleu pour le plus profond au moins profond, mais, encore une fois, ou est ce qu'on le definit et comment?; sachant que toute mes donnees sont dans un fichier .x!

Quelle approche me conseillerais tu? Faut il changer quelque chose au niveau de mon Init3D? Comment lister ces couleurs ds .x en RGBA?

Encore une fois j'apprecierais vraiment ton aide!

Jeremy
0
Rejoignez-nous