Writing exporter for Max
I've decided to attempt a basic exporter for 3D Studio Max using the tutorial found here
http://www.gamasutra.com/features/19980320/baumann_01.htm
However, if I include the max.h file into my project and #include it in my main dll file I get the error.
\\cepturia\cepturia\Code\C++\Max Exporter\Max Exporter.cpp(6): fatal error C1083: Cannot open include file: 'max.h': No such file or directory
????
The only thing I've found on Google that comes remotely close to a solution is
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3973
and it isn't even close to the problem... :(
This doesn't make much sense unless there is some setting I need to flip on for my compiler.
Anyone have any ideas?
Thanks,
Webby
Did you copy the "max.h" in both directories that the projects are in? I know sometimes if I'm working across two projects I forget a file or two. That error means that the file is not found at that path - so check to make sure its there as "max.h" - make sure the file is named right as well. One time I accidently had a space in my filename before the .h and it caused me many headaches before I saw the mistake. Other than that there is nothing to do with the compiler settings.
Funny the stuff they leave out.
#include "max.h"
#include "stdafx.h"
#include "Max Exporter.h"
max.h has to be declared first. After declaring it in a few positions I found the right one.
Webby
#include "max.h"
#include "stdafx.h"
#include "Max Exporter.h"
max.h has to be declared first. After declaring it in a few positions I found the right one.
Webby
I have found out that there are multiple ways to go about this.
I can either write a plug-in for Max 3.1 using C++ and the SDK which I am having a devil of a tim eeven getting to compile the most basic dll or I can use MaxScript. I can't seem to find any good documentation on either of these other than in the Max help files which are lacking in many areas.
I've followed step-by-step, the tutorials for writing a plug-in and it just will not compile. I suscept it has something to do with my using Visual Studio.Net 2003 instead of Visual Studio 6 (which Max 3.1 was written with).
Does anyone here have some experience with either of these approaches who would be willing to lend a helping hand?
Thanks in advance,
Webby
I can either write a plug-in for Max 3.1 using C++ and the SDK which I am having a devil of a tim eeven getting to compile the most basic dll or I can use MaxScript. I can't seem to find any good documentation on either of these other than in the Max help files which are lacking in many areas.
I've followed step-by-step, the tutorials for writing a plug-in and it just will not compile. I suscept it has something to do with my using Visual Studio.Net 2003 instead of Visual Studio 6 (which Max 3.1 was written with).
Does anyone here have some experience with either of these approaches who would be willing to lend a helping hand?
Thanks in advance,
Webby
I can tell you that writing plugins for Max 3.1 with VS.NET 2003 is a path that will lead to all kinds of problems. Even if you get it to compile correctly, you will run into problems at run-time since the dll you create will use a different memory heap than the once Max 3.1 uses. If you're really determined to stick with the ancient 3.1, then make sure you use VC6.
With that being said, I think you'll have an easier time writing an exporter with Maxscript. There should be a help file for Maxscript that should help get you going a little bit. If you search on this forum, you should find a simple example I posted in one of the threads on doing an exporter with Maxscript.
Good luck!
-John
With that being said, I think you'll have an easier time writing an exporter with Maxscript. There should be a help file for Maxscript that should help get you going a little bit. If you search on this forum, you should find a simple example I posted in one of the threads on doing an exporter with Maxscript.
Good luck!
-John
Having gone through this some time back, ill save you the trouble of finding a way.
Basically there are a few ways you can get your data.
1) Use an existing plugin (.md3,.x,etc..)
2) Use an existing plugin (.md3,.x,etc..) and then extract the data from the output file.
3) Write a plugin using maxSDK.
4) Write a plugin using the IGame Interface provided at discreet's spark website.
5) Use Maxscript.
1) Just use any of the numerous plugins and load the format directly into your engine. This is easy to do and can usually be done from various other modelling packages. However you are limited by the features of the format you export to.
2) Same as 1, but you can convert it to your own format.
3) I wouldnt do this, like you i also tried writing a standard max plugin and never got anywhere.
4) As far as coding in C++ goes, this is the fastest/easiest way. Not that it is a trivial thing to do but because discreet provides a sample XML exporter plugin with source. All you have to do is to modify the required functions where needed and then you can write the data out. The IGame documentation is quite poor and support is almost non-existant. But who needs that when you have already have the source to a working plugin. I managed to use this method to make a exporter which supported exporting of meshes/textures/skeletal animation.
The only reason why i ditched this was because i didn't understand most of the plugin code since i was modifying the XML exporter. This meant that it became a nightmare to maintain and extend the exporter's features. I was just guessing what each function did and through trial and error i got what i wanted.However that is just me. It still gets the job done well and fast.
5) Almost no setup code or ugly max interfaces to go through. No confusing DLLs or initialization to do. This is the fastest and easiest way to get started. I still feel more comfortable with C++ and having STL by my side as compared to MaxScript, but i cannot stand writing a few hundred lines of plugin code which makes no sense to me. Suddenly it feels as easy as your first C++ file IO program. There are no hidden complexities. The same script will also work across different max versions with no problems(unless you use newer MaxScript functions).
However Maxscript is slower. For my exporter, i am consolidating/expanding the vertices/normals/UV coordinates and then removing similar sets of data. This has to be done because Max does not store it's data the way you would for OGL/DX. It only stores unique normals/unique vertices/ unique UV Coord. It becomes your problem to convert this into a format suitable for OGL/DX. Means for every vertex, i have to get it's vertex/normal/UV and check the consolidated list for a match. The more vertices, the larger the list and the more checks i have to do, this increases the number of checks expotentially for large meshes. This can take anywhere from a few seconds to a few mintues for large meshes. My previous plugin made using IGame took less than a few seconds for even the largest meshes. Ofcourse if you are not optimising your dataset, then it should be much faster.
While there is decent documentation for Maxscript, it is only for basic stuff to get you started, after that you will have to prowl through the available functions to find what you need.
I would choose one of the last 2 options for maximum flexibility, or choose the first 2 for ease of use. Writing a plugin is time consuming and since you are using Max, there will be many times you will be banging your head on the wall (partially bcos of Max's dumb coordinate system).
Basically there are a few ways you can get your data.
1) Use an existing plugin (.md3,.x,etc..)
2) Use an existing plugin (.md3,.x,etc..) and then extract the data from the output file.
3) Write a plugin using maxSDK.
4) Write a plugin using the IGame Interface provided at discreet's spark website.
5) Use Maxscript.
1) Just use any of the numerous plugins and load the format directly into your engine. This is easy to do and can usually be done from various other modelling packages. However you are limited by the features of the format you export to.
2) Same as 1, but you can convert it to your own format.
3) I wouldnt do this, like you i also tried writing a standard max plugin and never got anywhere.
4) As far as coding in C++ goes, this is the fastest/easiest way. Not that it is a trivial thing to do but because discreet provides a sample XML exporter plugin with source. All you have to do is to modify the required functions where needed and then you can write the data out. The IGame documentation is quite poor and support is almost non-existant. But who needs that when you have already have the source to a working plugin. I managed to use this method to make a exporter which supported exporting of meshes/textures/skeletal animation.
The only reason why i ditched this was because i didn't understand most of the plugin code since i was modifying the XML exporter. This meant that it became a nightmare to maintain and extend the exporter's features. I was just guessing what each function did and through trial and error i got what i wanted.However that is just me. It still gets the job done well and fast.
5) Almost no setup code or ugly max interfaces to go through. No confusing DLLs or initialization to do. This is the fastest and easiest way to get started. I still feel more comfortable with C++ and having STL by my side as compared to MaxScript, but i cannot stand writing a few hundred lines of plugin code which makes no sense to me. Suddenly it feels as easy as your first C++ file IO program. There are no hidden complexities. The same script will also work across different max versions with no problems(unless you use newer MaxScript functions).
However Maxscript is slower. For my exporter, i am consolidating/expanding the vertices/normals/UV coordinates and then removing similar sets of data. This has to be done because Max does not store it's data the way you would for OGL/DX. It only stores unique normals/unique vertices/ unique UV Coord. It becomes your problem to convert this into a format suitable for OGL/DX. Means for every vertex, i have to get it's vertex/normal/UV and check the consolidated list for a match. The more vertices, the larger the list and the more checks i have to do, this increases the number of checks expotentially for large meshes. This can take anywhere from a few seconds to a few mintues for large meshes. My previous plugin made using IGame took less than a few seconds for even the largest meshes. Ofcourse if you are not optimising your dataset, then it should be much faster.
While there is decent documentation for Maxscript, it is only for basic stuff to get you started, after that you will have to prowl through the available functions to find what you need.
I would choose one of the last 2 options for maximum flexibility, or choose the first 2 for ease of use. Writing a plugin is time consuming and since you are using Max, there will be many times you will be banging your head on the wall (partially bcos of Max's dumb coordinate system).
Thanks guys, I'll look into that.
It isn't a choice of not using Max 7. Goodness knows I would love the new bridge functionality. And the ability to move freely through my scenes inside of a viewport...WOW. Those two additions alone make my mouth water. But alas, for me to upgrade from 3.1 to 7 would be the cost of $3500 (price of new package all together) which isn't something I can afford at this time.
As for the speed, that really isn't an issue for me at this time so I think I will take the MaxScript approach, assuming I can figure it out :)
Thanks again,
Webby
It isn't a choice of not using Max 7. Goodness knows I would love the new bridge functionality. And the ability to move freely through my scenes inside of a viewport...WOW. Those two additions alone make my mouth water. But alas, for me to upgrade from 3.1 to 7 would be the cost of $3500 (price of new package all together) which isn't something I can afford at this time.
As for the speed, that really isn't an issue for me at this time so I think I will take the MaxScript approach, assuming I can figure it out :)
Thanks again,
Webby
After reading through the MaxScript I can now successfully access the vertex, face, normal, etc data of my objects in Max. With that out of the way I decided to try and write a basic mesh exporter (vertex information only) and to my dismay, I can't figure out how to write to a file with MaxScript. I can create, delete, read, open, close them just fine but nowhere in the help files is there a mention of any sort of write procedure.
I just read on a website that the write functions were disabled for MaxScript (something I find kind of hard to believe).
Can anyone confirm this or does anyone know the functions necessary to write to a file with MaxScript?
EDIT**
On further inspection I have performed these checks in the Listener window.
apropos "read"
readChars (const Generic): readChars()
readLine (const Generic): readLine()
readValue (const Generic): readValue()
readDelimitedString (const Generic): readDelimitedString()
readChar (const Generic): readChar()
readExpr (const Generic): readExpr()
OK
apropos "write"
OK
The apropos function simply lists any methods that have the given string as part of it's name. Sure enough "write" turns up zilch. Now, I know it's possible to write exporters as .dlls (look at the .x exporter) so there has to be a workaround for this somewhere. Kind of stupid that they would remove the write functions....ARGH!!!
End edit***
Thanks,
Webby
I just read on a website that the write functions were disabled for MaxScript (something I find kind of hard to believe).
Can anyone confirm this or does anyone know the functions necessary to write to a file with MaxScript?
EDIT**
On further inspection I have performed these checks in the Listener window.
apropos "read"
readChars (const Generic): readChars()
readLine (const Generic): readLine()
readValue (const Generic): readValue()
readDelimitedString (const Generic): readDelimitedString()
readChar (const Generic): readChar()
readExpr (const Generic): readExpr()
OK
apropos "write"
OK
The apropos function simply lists any methods that have the given string as part of it's name. Sure enough "write" turns up zilch. Now, I know it's possible to write exporters as .dlls (look at the .x exporter) so there has to be a workaround for this somewhere. Kind of stupid that they would remove the write functions....ARGH!!!
End edit***
Thanks,
Webby
This is how you write to a file
fileStream = createfile filename
local i = 95
format "C style printing %\n" i to:fileStream
Prints:
C style printing 95
fileStream = createfile filename
local i = 95
format "C style printing %\n" i to:fileStream
Prints:
C style printing 95
Hmm. I'll have to try that when I get home. It seems kind of odd that they would provide readLine and readChars but no writeLine or writeChars method.
I suppose I can provide those myself using that format functionality you just gave me.
Thanks. Now to make it till 4:30 so I can try this at home :)
Webby
I suppose I can provide those myself using that format functionality you just gave me.
Thanks. Now to make it till 4:30 so I can try this at home :)
Webby
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement