RECHERCHER :
COMMUNAUTE MP
Identifiez vous ...
Devenir Membre
J'ai oublié mon MDP
DOMAINE MP
Bavardages
Langages Généraux
Langages Web
Langages DotNet
Autres langages
Dev. Jeux Video
Sécurité
Sys. Exploitation
Graphismes
Logiciels
Réseaux
Bases de données
Méthodologies
Emplois High-tech
Aide juridique
Articles juridiques
FORUM
Index des forums
Ajouter un sujet
Rechercher sujet
Contact Responsable
Devenir modérateur
CHAT MP IRC
Votre pseudo ...
Srv: irc.moteurprog.com
Chan: #MoteurProg
PARTICIPER
Plus de 3500 emplois.
Rechercher un job
Déposez votre CV
Emplois High-tech

Visiteur MP

 Importer/Exporter 3ds max

Forum : OPENGL
Sous Catégorie : Aucune
Type du sujet : Sujet Normale
FAQ : FAQ OPENGL

SUIVI DES SUJETS PAR MAIL

SUIVI PAR MAIL INACTIF

RESOLUTION DU SUJET SUJET NON RESOLU
BLOQUAGE DU SUJET SUJET ACTIF
APPARTENANCE A LA FAQ N'APPARTIENT PAS A LA FAQ


PAGE : [1]

POSTER UN NOUVEAU SUJET REPONDRE A CE SUJET

FORUM OPENGL

PREMIERE PAGE

PAGE PRECEDENTE

Page précedente

Page suivante

PAGE SUIVANTE

DERNIERE PAGE
vortex666
Modérateur :
- C & C++
- OpenGL
- Delphi
Chef de projet(s) :
- Vortez3DEngine

Avatar de vortex666
Inscrit : 20/09/2004
Messages : 490
Message
#134143
Posté le 20/05/07 à 22:07
Beaucoup de monde on de la misere a ouvrir un fichier fait avec studio max dans leur application OpenGL, du fait que le format .x est fait pour DX, et le .obj est en format texte. Et bien, pour me faciliter la vie, je me suis programmer un Importer et un exporter de models pour 3ds max.
Avec ca, vous pourrer ouvrir le models dans votre application en 1 ligne de code!

Voici la class utiliser pour lire le model:

E3DModel.h

#ifndef _E3DMODEL_H_ #define _E3DMODEL_H_ #ifdef __cplusplus #include "Windows.h" #include <fstream> #include "SafeKill.h" using namespace std; class E3DModel { public: E3DModel(); ~E3DModel(); private: struct COptions { bool TexVerts; bool AuxTexVerts; bool Normals; bool Fog; }; struct float2{float X, Y;}; struct float3{float X, Y, Z;}; public: bool LoadModelFromFile(char *pFName); int NumOfVerts; int IndexArraySize; UINT *pIndexArray; float3 *pVertsArray; float2 *pTexVertsArray; float2 *pAuxTexVertsArray; float3 *pNormalsArray; float *pFogArray; UINT VertsVBO_ID; UINT TexVertsVBO_ID; UINT AuxTexVertsVBO_ID; UINT NormalVBO_ID; UINT FogVBO_ID; UINT TrisCount; }; #endif #endif //_E3DMODEL_H_/*


E3DModel.cpp

#include "E3DModel.h" E3DModel::E3DModel() { NumOfVerts = 0; IndexArraySize = 0; pIndexArray = NULL; pVertsArray = NULL; pTexVertsArray = NULL; pAuxTexVertsArray = NULL; pNormalsArray = NULL; pFogArray = NULL; TrisCount = 0; } E3DModel::~E3DModel() { SAFE_DELETE_ARRAY(pIndexArray); SAFE_DELETE_ARRAY(pVertsArray); SAFE_DELETE_ARRAY(pTexVertsArray); SAFE_DELETE_ARRAY(pAuxTexVertsArray); SAFE_DELETE_ARRAY(pNormalsArray); SAFE_DELETE_ARRAY(pFogArray); } bool E3DModel::LoadModelFromFile(char *pFName) { COptions Options; ZeroMemory(&Options, sizeof(Options)); //Open the file FILE *f = fopen(pFName, "rb"); if(!f){ char c[256]; sprintf(c, "Unable to open the file \"%s\"", pFName); MessageBox(0, c, "Error!", 0); return FALSE; } //This will tell us how many objects are in the file int ObjCount = 0; //Read this number... fread(&ObjCount, 1, sizeof(int), f); //Read the options fread(&Options, 1, sizeof(Options), f); //Past-Read the object name { UCHAR lBuf = 0xCD; //Can't init. to NULL, so use another value intead while(lBuf != NULL){ fread(&lBuf, 1, sizeof(UCHAR), f); } } //Read the length of the Index Array we have fread(&IndexArraySize, 1, sizeof(int), f); //Read the number of verts we have fread(&NumOfVerts, 1, sizeof(int), f); //Allocate our model's memory pIndexArray = new UINT[IndexArraySize]; pVertsArray = new float3[NumOfVerts]; if(Options.TexVerts) pTexVertsArray = new float2[NumOfVerts]; if(Options.AuxTexVerts) pAuxTexVertsArray = new float2[NumOfVerts]; if(Options.Normals) pNormalsArray = new float3[NumOfVerts]; if(Options.Fog) pFogArray = new float[NumOfVerts]; //Read our data fread(&pIndexArray[0], 1, IndexArraySize * sizeof(UINT),f); fread(&pVertsArray[0], 1, NumOfVerts * sizeof(float3), f); if(Options.TexVerts) fread(&pTexVertsArray[0], 1, NumOfVerts * sizeof(float2), f); if(Options.AuxTexVerts) fread(&pAuxTexVertsArray[0], 1, NumOfVerts * sizeof(float2), f); if(Options.Normals) fread(&pNormalsArray[0], 1, NumOfVerts * sizeof(float3), f); if(Options.Fog) fread(&pFogArray[0], 1, NumOfVerts * sizeof(float), f); //Get the number of tris of this mesh TrisCount = IndexArraySize / 3; return false; }


Donc vous crée un object E3DModel comme ceci:

E3DModel Model;

Et vous loader le model comme cela:

Model.LoadModelFromFile("Nom_du_fichier.E3D");

La desallocation se fait automatiquement par le destructeur...

Pour dessiner:

//Enable vertex array glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); //Si nessessaire glEnableClientState(GL_VERTEX_ARRAY); //Si nessessaire glVertexPointer(3, GL_FLOAT, 0, Model.pVertsArray); glTexCoordPointer(2, GL_FLOAT, 0, Model.pTexVertsArray); //Si nessessaire glNormalPointer(GL_FLOAT, 0, Model.pNormalsArray); //Si nessessaire glDrawElements(GL_TRIANGLES, Model.IndexArraySize, GL_UNSIGNED_INT, Model.pIndexArray); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); //Si nessessaire glDisableClientState(GL_VERTEX_ARRAY); //Si nessessaire *j'ai ecrit "Si nessaisaire, car si on exporte le fichier sans l'info des texture et/ou des normals, et qu'on l'utilise dans le code comme si dessu, le programme va "crasher"


Pour ce qui est des plugins(Importer/Exporter) pour studio max, les voici:
(copier les 2 dll dans le dossier Plugins de 3ds tout simplement)

http://www.freewebs.com/vortex666/3ds%5Fplugins.rar

Clicker sur Export... ou Import... et vous verer dans la liste des extension de fichiers le format .E3D

PS.
Il y a aussi le plugins Heighmap.dll, fait pour generer des heightmaps a partir de bitmap de n'importe quelle format. Pour l'utiliser, copier le a la meme place que les 2 autres, et, dans studio max, dans le combobox ecrit "Standart Primitive", selectionner "My Stuffs", et faite un clic pour ouvir une dialogbox permetant de selectionner le bitmap voulu.


Question ou commentaire sont les bienvenue!

Enjoy!Smiley

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

Publicité
Inscrit : X
Messages : X
Message
#Aucun

HAUT DE PAGE

  

Spirit
Superviseur :
- C & C++
Modérateur :
- PHP
- Javascript
- MySQL
Avatar de Spirit
Inscrit : 07/04/2004
Messages : 1966
Message
#134715
Posté le 29/05/07 à 10:07
en suivant un tuto j'avais réussi un truc similaire
- ouvrir le fichier
- charger les mesh, faces etc

c'est rapide, pour l'afficher aussi, là où j'ai eu du mal c'est pour trouver des modèles^^
les lowpoly courent pas les pages du web, et si ma boucle d'affichage dépasse les 10k tours (je crois) le programme se ferme purement et simplement^^


en se référant à la doc du format .x, il s'agit vraiment d'un format intéressant, en parcourant le fichier, au fil des headers on extrait tout ce dont on a besoin :)
__________________________
Spirit - modérateur casu ^-^'

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

vortex666
Modérateur :
- C & C++
- OpenGL
- Delphi
Chef de projet(s) :
- Vortez3DEngine

Avatar de vortex666
Inscrit : 20/09/2004
Messages : 490
Message
#134873
Posté le 30/05/07 à 20:32
Il y en a quelque uns sur http://www.3dcafe.com/

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

vortex666
Modérateur :
- C & C++
- OpenGL
- Delphi
Chef de projet(s) :
- Vortez3DEngine

Avatar de vortex666
Inscrit : 20/09/2004
Messages : 490
Message
#141503
Posté le 23/08/07 à 01:48
Pour ceux interresser, je vien d'ajouter mon Moteur 3D juste ici:

http://www.projet.moteurprog.com/Projet.php?ID_projet=388

Jetez y un coup d'oeil.

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 
POSTER UN NOUVEAU SUJET REPONDRE A CE SUJET

PREMIERE PAGE

PAGE PRECEDENTE Page précédente

Page suivante

PAGE SUIVANTE DERNIERE PAGE

FORUM OPENGL



    PAGE : [1]



.: Site Web développé par Julien Pichot et l'équipe MPWG avec www.evolvia-web.com :.