Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ante

Loading .3DSMAX

This topic is 5995 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I''m sorry, but i''m french and my english can be very bad. So, i''m looking for exemples, src,...about the 3dsmax files (not 3ds). How can I load it? use it in opengl projects,... thanks a lot! bye!

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster

#define EDIT_OBJECT 0x4000
#define OBJ_TRIMESH 0x4100



int main()
{
unsigned int numvert, numpoly;
unsigned int chunkid;
int chunksize;
long position;
FILE * input;
FILE * output;
int i, version;
float x, y, z, unit;
unsigned int a, b, c, d;
char bout;

input = fopen("test.3ds", "rb";
if(input != NULL)
{
output = fopen("test.txt", "w";
chunkid = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
chunkid = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
version = 0;
fread(&version, 4, 1, input);
chunkid = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
chunkid = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
unit = 0.0;
fread(&unit, 4, 1, input);
chunksize=6;
while(chunkid != EDIT_OBJECT)
{
fseek(input, chunksize-6, 1);
chunkid = 0;
chunksize = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
}


fseek(input, 1, 1);///////////////////////////////////////////////////////////


chunksize = 6;
while(chunkid != OBJ_TRIMESH)
{
fseek(input, chunksize-6, 1);
chunkid = 0;
chunksize = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
}
position = ftell(input);
chunksize = 6;
while(chunkid != 0x4110)
{
fseek(input, chunksize-6, 1);
chunkid = 0;
chunksize = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
}


numvert = 0;
fread(&numvert, 2, 1, input);
fprintf(output, "%d\n", numvert);


x = y = z = 0.0;
for(i=0; i<numvert; i++)
{
x = y = z = 0.0;
fread(&x, 4, 1, input);
fread(&y, 4, 1, input);
fread(&z, 4, 1, input);
fprintf(output, "%f ", x);
fprintf(output, "%f ", y);
fprintf(output, "%f\n", z);
}


fseek(input, position, 0);//that causes a problem 0 must be the lenght of a null terminated string: the object name!
chunksize=6;
while(chunkid != 0x4120)
{
fseek(input, chunksize-6, 1);
chunkid = 0;
chunksize = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
}

numpoly = 0;
fread(&numpoly, 2, 1, input);
fprintf(output, "%d\n", numpoly);

for(i=0; i<numpoly;i++)
{
a = b = c = d = 0;
fread(&a, 2, 1, input);
fread(&b, 2, 1, input);
fread(&c, 2, 1, input);
fread(&d, 2, 1, input);
fprintf(output, "%d ", a);
fprintf(output, "%d ", b);
fprintf(output, "%d\n", c);
}


return 0;

}
}


i use this to load the vertexes, and polygon references out of the file! ill send you info on the file format on your email!

Share this post


Link to post
Share on other sites

#define EDIT_OBJECT 0x4000
#define OBJ_TRIMESH 0x4100



int main()
{
unsigned int numvert, numpoly;
unsigned int chunkid;
int chunksize;
long position;
FILE * input;
FILE * output;
int i, version;
float x, y, z, unit;
unsigned int a, b, c, d;
char bout;

input = fopen("test.3ds", "rb");
if(input != NULL)
{
output = fopen("test.txt", "w");
chunkid = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
chunkid = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
version = 0;
fread(&version, 4, 1, input);
chunkid = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
chunkid = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
unit = 0.0;
fread(&unit, 4, 1, input);
chunksize=6;
while(chunkid != EDIT_OBJECT)
{
fseek(input, chunksize-6, 1);
chunkid = 0;
chunksize = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
}


fseek(input, 1, 1);///////////////////////////////////////////////////////////thats not! this causes a problem, if you read the docs ive send, you will see that this is a null terminated string, here: 1 byte


chunksize = 6;
while(chunkid != OBJ_TRIMESH)
{
fseek(input, chunksize-6, 1);
chunkid = 0;
chunksize = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
}
position = ftell(input);
chunksize = 6;
while(chunkid != 0x4110)
{
fseek(input, chunksize-6, 1);
chunkid = 0;
chunksize = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
}


numvert = 0;
fread(&numvert, 2, 1, input);
fprintf(output, "%d\n", numvert);


x = y = z = 0.0;
for(i=0; i {
x = y = z = 0.0;
fread(&x, 4, 1, input);
fread(&y, 4, 1, input);
fread(&z, 4, 1, input);
fprintf(output, "%f ", x);
fprintf(output, "%f ", y);
fprintf(output, "%f\n", z);
}


fseek(input, position, 0);//oups, thats ok
chunksize=6;
while(chunkid != 0x4120)
{
fseek(input, chunksize-6, 1);
chunkid = 0;
chunksize = 0;
fread(&chunkid, 2, 1, input);
fread(&chunksize, 4, 1, input);
}

numpoly = 0;
fread(&numpoly, 2, 1, input);
fprintf(output, "%d\n", numpoly);

for(i=0; i {
a = b = c = d = 0;
fread(&a, 2, 1, input);
fread(&b, 2, 1, input);
fread(&c, 2, 1, input);
fread(&d, 2, 1, input);
fprintf(output, "%d ", a);
fprintf(output, "%d ", b);
fprintf(output, "%d\n", c);
}


return 0;

}
}


i use this to load the vertexes, and polygon references out of the file! ill send you info on the file format on your email! this programm is just for testing purposes!

Edited by - Zeusel on January 15, 2002 1:06:01 PM

Share this post


Link to post
Share on other sites
it writes the points in textmode to a file, so you must write your own file format and converter! texturecoords are also somewhere, see the docs!

Share this post


Link to post
Share on other sites
hey Zeusel, do you think you could find the time to send me a copy of those docs as well. ive been digging around but havent found anything to solid yet.

thanks.

---------------------------
"Bingo-Bango! Sugar in the gas tank!"

Share this post


Link to post
Share on other sites
Hi!

thanks for your help! but are you sure that this code is good for .max files because you load a .3ds file, no? is not the same thing. I''d like .max files because contains the animation (frame,...) (like md3 files).

bye

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Perhaps you should search the forum for exactly this topic, it pops up every week or so.

To summarize: you *cannot* load .max files ! Don''t even try to find something on the net, you won''t. .max is a proprietary fileformat of Discreet, and it does *not* contain mesh, animation, or geometry in any way. It contains *code*. Infact, microcode for the modifiers, it''s a meta-fileformat that explains 3DSmax how to create the scene using it''s internal geometry builders.

A sample max file can contain this:

- Create 2 spheres, with the following parameters: blah, blah...
- Apply a mesh select modifier on the following parts: blah...
- Deform by a NURBS defined by the following control points: ...
- Make a boolean difference operation between following objects: ...

etc. NO geometry. NO animation. Just an instruction list. And to read it you would need the source of 3DSMax or rewrite 3DSmax on your own...

Stay with the 3ds format, or if it doesn''t suit your needs, create your own format including an exporter plugin.

- AH

Share this post


Link to post
Share on other sites
ok!
i''ve not the choice, i''m going to develop a plugin to export .max files...thanks for all!!

bye

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
> i''ve not the choice, i''m going to develop a plugin to export .max files...thanks for all!!

Yes, this is what most people end up doing. It''s the best thing to do, it''s perhaps not easy to get it working first, but once you have your exporter, you can include all information you need in your file. I agree, .3ds is old and unusable on ''real'' scenes, and .md3 isn''t so good either, but interpreting .max files is total overkill

Just take the plugin SDK on your Max4 CD, there are good examples of simple exporters you can modify. If you run into problems, you can also have a look at Discreet''s help forums and their Sparks programm.

- AH

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!