Skip to main content
GameDev.net gamedev.net
🔒 Locked

Loading 3ds models with OpenGL

Started by Stompy9999 Mar 5, 2005 at 12:37 PM 11 replies 37k views
airseb
airseb
you have to export the 3d studio max file in a format in which you will read thanks to C++.
Stompy9999
Stompy9999
By the way, I'm using Anim8or as my model editor, so if anyone knows how to load from that, that would be good too.
nife
nife
Quote:
Original post by Stompy9999
By the way, I'm using Anim8or as my model editor, so if anyone knows how to load from that, that would be good too.


What file format do you want to use?

Anim8or can probaly also export to different formats.

Anyways, I'm pretty sure that you can find the specifications for anyone of them on http://www.wotsit.org
Killers don't end up in jailThey end up on a high-score!
Ominae392
Ominae392
If you are looking for a generic model format .ply always works for me. It's a free standard that includes free source code from Stanford but you have to export your models vertices and faces in a generic way like an ascii .obj file. But ply is only good if you all you have are color, vertices, and faces. If you want body parts labeled in the file then you'll have to find some common file type. Also, there is a 3D standard in the works called COLLADA that has a sizable push behind it to be a universal standard(like that will ever happen.)
bargasteh
bargasteh
Hello now lets say we import a 3DS file in your project, how can we find every single vertex ? I mean how can you right a program that can for example change every vertex of a 3DS file and remove some of the vertexes that you wish ?
Is it possible to go through every single vertex from the top to bottom?
OpenGl + C++
Ominae392
Ominae392
Sure, all you need is the 3DS standard. I'm not sure if this sounds simplistic but understand that I don't know what everyone's level of understanding is. The 3D file must contain a list of vertices and faces, otherwise it has nothing to load in to a program. It doesn't store some mystical glob of data that professional modeling programs just display without understanding. So once you have the 3DS structure you can write a c++ read/write routine for it. Once that's done you can do whatever you like to any vertice in the mesh and export that change with your write.(Since your reader would have loaded each vertex in to a buffer you've got all the control.) But if 3DS isn't a generic 3D standard then good luck finding its specifications. 3D modelling companies don't usually release propietary file formats.
Caldus
Caldus
How do you find out the four corners of the .3ds object that is loaded? I understand that .3ds files organize data in chunks and all. However, I've been trying to write code that would find the max X coordinate and the max Y coordinate (as well as the min for each) in the whole model. This way I can divide the model into squares and treat it as a tiled map if that makes any sense. Thanks for any help. This is what I tried so far (modified code from the tutorial above):

From 3dsloader.cpp:

(Added new variables to the function Load3DS):
    float* maxX;    float* maxY;    float* minX;    float* minY;    float* lengthX;    float* lengthY;	


(And the following is changed...):
			//--------------- TRI_VERTEXL ---------------			// Description: Vertices list			// Chunk ID: 4110 (hex)			// Chunk Lenght: 1 x unsigned short (number of vertices) 			//             + 3 x float (vertex coordinates) x (number of vertices)			//             + sub chunks			//-------------------------------------------			case 0x4110: 				fread (&l_qty, sizeof (unsigned short), 1, l_file);                p_object->vertices_qty = l_qty;                printf("Number of vertices: %d\n",l_qty);                for (i=0; i<l_qty; i++)                {					fread (&p_object->vertex.x, sizeof(float), 1, l_file); 					printf("Vertices list x: %f\n",p_object->vertex.x);                    fread (&p_object->vertex.y, sizeof(float), 1, l_file); 					printf("Vertices list y: %f\n",p_object->vertex.y);					fread (&p_object->vertex.z, sizeof(float), 1, l_file); 					printf("Vertices list z: %f\n",p_object->vertex.z); 								    if (&p_object->vertex.x > maxX) {			        maxX = &p_object->vertex.x;                                			    }        			    if (&p_object->vertex.y > maxY) {			        maxY = &p_object->vertex.y;			    }        			    if (&p_object->vertex.x < minX) {			        minX = &p_object->vertex.x;                        			    }        			    if (&p_object->vertex.y < minY) {			        minY = &p_object->vertex.y;                        			    }			}			printf("Max X: %f\n", maxX);			printf("Max Y: %f\n", maxY);			printf("Min X: %f\n", minX);			    printf("Max Y: %f\n", minY);											break;

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.