Jump to content


load 3ds max models into opengl program


54 replies to this topic

#41 chingching

    Member

  • Members
  • PipPip
  • 38 posts

Posted 25 February 2006 - 05:56 AM

geon said:

when you succuessfully compiled your model, open up a console and tyupe in the name of your executable, followed by your .3DS-file.

Alternatively, on windows, just drag-n-drop your 3DS-file onto the executable.

Geon, mind to explain in detail?
Thanks.

#42 geon

    Senior Member

  • Members
  • PipPipPipPip
  • 939 posts

Posted 25 February 2006 - 02:06 PM

In windows you can drag-and-drop a file onto an executable, or double-click a file that has an association. This will start the executable with the dragged/doubleclicked file as a commandline argument.

That means doublecklicking a *.txt-file is equivalent to typing this in the Run-field on your start-menu:

notepad the_file_I_just_doubleclicked.txt


Now seriously, start using google! You ask many questions that are allready answered, or has the answer in the supplied links, or that you could easily have found the answer to if you just googled around a little.

#43 chingching

    Member

  • Members
  • PipPip
  • 38 posts

Posted 25 February 2006 - 03:00 PM

Well, Geon, thank you. I'll google around. So sorry that I always asked silly questions as I always get stuck. I'm so regret that I didn't grasp time to gain more knowledge and preparation. Then now I just like a fly without head, fly here and there but don't know where to go.
Anyway, a lot of thanks to you, hope you still willing to provide me some information if I get stuck.
Thanks.

#44 kennyurge

    Member

  • Members
  • PipPip
  • 30 posts

Posted 06 March 2006 - 04:33 PM

im havin the same prob as chingching....have you solve the problem yet?

#45 Spessotto

    New Member

  • Members
  • Pip
  • 3 posts

Posted 06 March 2006 - 07:52 PM

hello guys..im new here..and i want to know if someone can help me, because i have a 3ds loader...works well...but i want to put the 3ds file(a gun) in the middle of screen (like in the fps)..someone can help? thanks and sorry about the bad english!!!

Rafael S.

#46 geon

    Senior Member

  • Members
  • PipPipPipPip
  • 939 posts

Posted 06 March 2006 - 08:54 PM

First of all, make your own thread for a new subject.

Anyway...

Just find out how to move the camera around. (I'. shure you can find it if you just fiddle around with the code for a while.) Then put the camera where the eyes of a charakter would have been. Simple.

#47 chingching

    Member

  • Members
  • PipPip
  • 38 posts

Posted 07 March 2006 - 06:45 AM

kennyurge said:

im havin the same prob as chingching....have you solve the problem yet?

You can try the part coding of loading model that provided by Anudhyan (in the first page).

#48 kennyurge

    Member

  • Members
  • PipPip
  • 30 posts

Posted 07 March 2006 - 08:20 AM

chingching said:

You can try the part coding of loading model that provided by Anudhyan (in the first page).


I not really good in programming and I don't understand the incomplete program from Anudhyan :wallbash: :surrender and not sure where to use it...Do you have the complete program? Can you send me the code to my email? kennyurge@yahoo.com

Looking forward to your reply and thanks to your help..I appreaciate it.:worthy:

#49 kennyurge

    Member

  • Members
  • PipPip
  • 30 posts

Posted 07 March 2006 - 08:23 AM

Anudhyan said:

here is part of my code:
----------------------------------------------------

//Basic Classes:

//Required for representing the loaded model

class vertex{

public:

	float x,y,z;

};

//MapCoord - for storing texture mapping coords

class mapcoord{

public:

	float u,v;

};


//The three ints for the polygon

//represent the no.s(or rank) of it's 3 vertices

class polygon{

public:

	int a,b,c;

};


class object{

public:

	char name[20];

	int numVerts,numPolys;

	vertex v[3000];

	polygon p[3000];

	mapcoord m[3000];

};




//-----------------------------------------------------------------------------

// Name: Load3dsObject (object *, char *)

// Desc: Loads a 3ds object given a filename

//-----------------------------------------------------------------------------


void Load3dsObject (object *obj, char *filename)

{

	FILE *file;			//Our file pointer


	char temp;			//Temporary char for reading name of object

	short chunkID;		//Stores ID of current chunk.

	int chunkLength;


	short useless;

	

	//Open our file for reading(r) and in binary mode(b)- "rb"

	file=fopen (filename, "rb");


	int i; 


	//While current position is lesser than the total length

	while (ftell(file) < filelength (fileno (file)))  

	{

		fread (&chunkID, 2, 1, file); 

		fread (&chunkLength, 4, 1,file); 


		switch (chunkID)

        {

			case 0x4d4d:		//Skip these chunks

				break;    

			case 0x3d3d:

				break;

			

			case 0x4000:		//Chunk containing name

				for(i=0;i<20;i++)

				{

					fread (&temp, 1, 1, file);

                    obj->name[i]=temp;

					if(temp == '\0')break;

                }

				break;


			case 0x3f80:		//Skip again

				break;

			case 0x4100:

				break;

	

			case 0x4110:		//Chunk with num of vertices

								//followed by their coordinates

				fread (&obj->numVerts, sizeof (unsigned short), 1, file);

				for (i=0; i<obj->numVerts; i++)

                {

					fread (&obj->v[i].x, sizeof(float), 1, file);

 				

                    fread (&obj->v[i].y, sizeof(float), 1, file);

 					

					fread (&obj->v[i].z, sizeof(float), 1, file);

 				

				}

				break;


			case 0x4120:		 //Chunk with numPolys and

								 //the indices

				fread (&obj->numPolys, sizeof (unsigned short), 1, file);

                for (i=0; i<obj->numPolys; i++)

                {

					fread (&obj->p[i].a, sizeof (unsigned short), 1, file);

				

					fread (&obj->p[i].b, sizeof (unsigned short), 1, file);

				

					fread (&obj->p[i].c, sizeof (unsigned short), 1, file);

					

					fread (&useless, sizeof (unsigned short), 1, file);

					

				}

				break;


		

			case 0x4140:		//Chunk with texture coords

				fread (&useless, sizeof (unsigned short), 1, file);

				for (i=0; i<obj->numVerts; i++)

				{

					fread (&obj->m[i].u, sizeof (float), 1, file);

				

                    fread (&obj->m[i].v, sizeof (float), 1, file);

				}

                break;


			default:

				 fseek(file,chunkLength-6, SEEK_CUR);

        } 

	}

	fclose (file);		

}




//-----------------------------------------------------------------------------

// Name: DrawObject(object *obj)

// Desc: Draws our loaded 3ds object

//-----------------------------------------------------------------------------


void DrawObject(object *obj)

{

	glBegin(GL_TRIANGLES); 

    for (int i=0;i<obj->numPolys;i++)

    {

 		glTexCoord2f( obj->m[ obj->p[i].a ].u,

                      obj->m[ obj->p[i].a ].v);

        glVertex3f( obj->v[ obj->p[i].a ].x,

                    obj->v[ obj->p[i].a ].y,

                    obj->v[ obj->p[i].a ].z); 


		glTexCoord2f( obj->m[ obj->p[i].b ].u,

                      obj->m[ obj->p[i].b ].v);

        glVertex3f( obj->v[ obj->p[i].b ].x,

                    obj->v[ obj->p[i].b ].y,

                    obj->v[ obj->p[i].b ].z);


		glTexCoord2f( obj->m[ obj->p[i].c ].u,

                      obj->m[ obj->p[i].c ].v);

        glVertex3f( obj->v[ obj->p[i].c ].x,

                    obj->v[ obj->p[i].c ].y,

                    obj->v[ obj->p[i].c ].z);

	}

    glEnd();

}


It would be more helpful to you if I could attach the file and e-mail it to you.


Hi, Anudhyan..Do you mind send me a copy of the file too? It will helps a lot in my project too. Thanks very much.:yes: :worthy:

#50 kennyurge

    Member

  • Members
  • PipPip
  • 30 posts

Posted 07 March 2006 - 09:23 AM

kennyurge said:

Hi, Anudhyan..Do you mind send me a copy of the file too? It will helps a lot in my project too. Thanks very much.:yes: :worthy:


:yes: Thanks man~I got it!:lol:

#51 chingching

    Member

  • Members
  • PipPip
  • 38 posts

Posted 08 March 2006 - 05:14 AM

Kennyurge,
Sorry that now only saw your post...but it's good to hear that Anudhyan had sent you the code...really sorry to you and thanks to Anudhyan ya~~

#52 juhnu

    Valued Member

  • Members
  • PipPipPip
  • 292 posts

Posted 08 March 2006 - 07:39 AM

"And if your model has more than 3000 polys,increase the array sizes in the object class."

How about using a dynamic array like std::vector<>?

#53 nexusssz

    New Member

  • Members
  • Pip
  • 4 posts

Posted 22 August 2006 - 06:30 PM

Hi guys
i've a problem here...hope u can help..
i've the following data extracted from a 3d model.
how do i display the model in opengl???

Vertex 1 -0.00423 0.78933 4.45589 {normal=(-0.00266 0.267 0.966)}
Vertex 2 -0.4276 1.862 3.8984 {normal=(-0.01221 0.4969 0.8681)}
Vertex 3 -0.81184 2.1162 3.12242 {normal=(-0.0444 0.6719 0.74012)}
Vertex 4 -1.13479 3.3543 2.4625 {normal=(-0.09215 0.7945 0.60084)}
Face 1 - vertex 1 vertex 7 and vertex 2
Face 2 - vertex 2 vertex 8 and vertex 3
Face 3 - vertex 3 vertex 9 and vertex 4

nex

#54 ghadaShams

    New Member

  • Members
  • Pip
  • 4 posts

Posted 06 May 2009 - 02:10 AM

kennyurge said:

I not really good in programming and I don't understand the incomplete program from Anudhyan :wallbash: :surrender and not sure where to use it...Do you have the complete program? Can you send me the code to my email? kennyurge@yahoo.com

Looking forward to your reply and thanks to your help..I appreaciate it.:worthy:

Me too in dead for this code .Any help please.
kennyurge , can you send it to me via mail ?

#55 Reedbeta

    DevMaster Staff

  • Administrators
  • 5307 posts
  • LocationBellevue, WA

Posted 06 May 2009 - 02:23 AM

ghadaShams, this is a two-year-old thread...most of the original posters are probably long gone. If you have a specific question about 3ds model loading, you should post a new thread to ask it.
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users