Skip to main content
gamedev.net
🔒 Locked

MaxScript Exporters

Started by Vincent_M 11 replies 3.3k views
Original Post
Vincent_M
Vincent_M
Does anyone have a tutorial on how to make a custom exporter for 3Ds Max 8 MaxScript? I need vertices, polygons, materials, and key-framed animation data to be exported, but in a special format.
Sneftel
Sneftel
Take my advice: Don't do it in MaxScript. It is a horrible, horrible language in which to program anything of reasonable complexity (like an exporter). Use the C++ API directly. It's well-documented, with plenty of tutorials, on the companion CD.
Digitalfragment
Digitalfragment
Sneftel, i'll disagree with you in part - MaxScript (although horrible in comparison to the actual C++ SDK) is great for writing intermediate export files, because the majority of maxscript is back & forward compatible, where as plugins via the maxSDK aren't.

Vincent_M, the MaxScript help files have a tutorial ascii exporter, and all of the function info you need to access materials etc.
Vincent_M
Vincent_M
I don't have the companion CD to the C++ API when it got mysteriousely scratched, and I didn't bother to install the API in the first place because I didn't know what it would do. I do have the Max SDK on the 3Ds Max 6 CD that I can install. Would that work on 3Ds Max 8? I will look for these tutorials.
Digitalfragment
Digitalfragment
Nope, the SDKs arent compatible.
Check out the sparks developer site, the might be some info on there that you can use though.
Telamon
Telamon
I wrote an exporter for Max using MaxScript. If it weren't for the wierd (some would say "awful") way Max stores texture coord information, it would have been easy. But I was still able to make a working exporter dump vertices, normals, and UV coords to disk in less than 2 days.

There is a tutorial in the Max 8 help files that will show at least how to export vertex info.

Maybe since you need to export more complex information MaxScript is not the ideal solution for you. I looked at the Max SDK and ran away screaming - it requires you to know all the gritty details of Max before you can do much with it. If niether MaxScript or the SDK work out, you may try transcoding from an easy-to-parse format (COLLADA, maybe?), and forget Max altogether. That was my backup plan. The benefit would be you get support for other tools like Blender for free.

Just my 2c.
Digitalfragment
Digitalfragment
Also, if you have the Max8/9 SDK there is also the IGAME interface, which is designed to give the vertex/texture/normal data in an alignment games use (so you dont have the nightmare Telamon is describing).

The reason that maxscript and the SDK are as complicated as they are is that 3ds max is a commercial RENDERING tool, designed to be more versitile that what is required for games art =)
Telamon
Telamon
People actually use Max for anything other than 3D modeling for games (or other interactive gamelike media)?

I'm not being facetious, I actually didn't think they did. I mean, I know there are a lot of hobbyists that render stills, but I never see rendered stills in ad campaigns ect. Do movie studios use Max? Seems unlikely.

Digitalfragment
Digitalfragment
Yep, 3dsmax gets used (albiet not as widely as Maya) for stills & movie rendering, usually in combination with Discreet's (Autodesk i beleive owns it now?) composition and editing tools like Flame or Inferno or whatever its called. Its more or less about the right tool for the right job. I cant remember the list of movies that have used max for certain, but im pretty sure Final Destination 2 did for one.
Vincent_M
Vincent_M
This is for the exporter. Does anyone know how to find out the number of meshes in a 3Ds Max scene, create a variable for each mesh in the scene, and make each variable equal that mesh in the scene in MaxScript?
parapete
parapete
Here's the source from my exporter which I've since given up on. It was intended for playing back animations for a demoscene project. Might be helpful to you. I agree with what's been said though, Maxscript is horrible for things like this.

out_name = "c:/testdump2.dat"out_file = fopen out_name "wb"fn DumpMaterials = (	nummaterials = 0		for mtl in sceneMaterials do (		nummaterials = nummaterials + 1	)		WriteLong out_file (nummaterials)		for mtl in sceneMaterials do (		WriteString out_file "S3DMA"				WriteString out_file mtl.name		WriteLong out_file mtl.shaderType				WriteFloat out_file mtl.ambient.r		WriteFloat out_file mtl.ambient.g		WriteFloat out_file mtl.ambient.b			WriteFloat out_file mtl.diffuse.r		WriteFloat out_file mtl.diffuse.g		WriteFloat out_file mtl.diffuse.b				WriteFloat out_file mtl.specular.r		WriteFloat out_file mtl.specular.g		WriteFloat out_file mtl.specular.b				if mtl.diffuseMap != undefined then (			WriteString out_file mtl.diffuseMap.filename		) else (			WriteString out_file "NODIFFUSEMAP"		)	))fn DumpMeshTextureVerts theMesh = (	local verts = #()		for i=1 to (getNumFaces theMesh) do (		local vertindices = getFace theMesh i		local texindices = getTVFace theMesh i				verts[texindices.x as integer] = getVert theMesh (vertindices.x as integer)		verts[texindices.y as integer] = getVert theMesh (vertindices.y as integer)		verts[texindices.z as integer] = getVert theMesh (vertindices.z as integer)	)		WriteLong out_file (verts.count)		for i=1 to (verts.count) do (		WriteFloat out_file verts.x		WriteFloat out_file verts.z		WriteFloat out_file verts.y	))fn DumpMeshIndices theMesh = (	WriteLong out_file (theMesh.numfaces)		for f = 1 to theMesh.numfaces do (		face = getTVFace theMesh f		WriteLong out_file (face.z-1)		WriteLong out_file (face.y-1)		WriteLong out_file (face.x-1)	))fn DumpMeshData theMesh = (	WriteLong out_file (theMesh.numverts)		for v = 1 to theMesh.numverts do (		vert = getVert theMesh v		WriteFloat out_file vert.x		WriteFloat out_file vert.z		WriteFloat out_file vert.y	)		DumpMeshIndices theMesh		WriteLong out_file 0 --num texture vertices)fn DumpMeshDataTex1 theMesh = (	DumpMeshTextureVerts theMesh		DumpMeshIndices theMesh		numtvv = getNumTVerts theMesh		WriteLong out_file numtvv		for v=1 to numtvv do (		tvert = getTVert theMesh v		WriteFloat out_file tvert.x		WriteFloat out_file -tvert.y	))fn DumpGeometry = (	numgeometry = 0		for g in geometry where classof g != TargetObject do (		numgeometry = numgeometry + 1	)		WriteLong out_file (numgeometry)		for g in geometry where classof g != TargetObject do (		WriteString out_file "S3DME"					tmesh = convertToMesh g		WriteString out_file g.name				if tmesh.material.diffuseMap != undefined then (			DumpMeshDataTex1 tmesh		) else (			DumpMeshData tmesh		)			WriteString out_file tmesh.material.name	)	)fn DumpCameras = (	numcameras = 0		for c in cameras do (		if iskindof c camera do (			numcameras=numcameras+1		)	)		WriteLong out_file numcameras		for c in cameras do  (		if iskindof c camera do (			WriteString out_file "S3DCA"			WriteString out_file c.name			WriteFloat out_file c.position.x			WriteFloat out_file c.position.z			WriteFloat out_file c.position.y			WriteFloat out_file c.target.position.x			WriteFloat out_file c.target.position.z			WriteFloat out_file c.target.position.y			WriteFloat out_file c.controller.rollangle--			WriteFloat out_file 0.f			WriteFloat out_file c.fov			WriteFloat out_file c.nearclip			WriteFloat out_file c.farclip		)	))fn DumpScene = (	WriteString out_file "S3DSC"	WriteLong out_file 1 --version		DumpMaterials()	DumpGeometry()	DumpCameras())DumpScene()		fclose out_fileedit out_name
Vincent_M
Vincent_M
Thanks, this will help a lot! By the way, does anyone know how to retrieve biped data like the names for every bone, and its transformations throughout the key frames in free-form? Most appreciated!

[Edited by - Vincent_M on January 25, 2007 1:46:40 PM]

Topic Locked

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

Sign in to reply to this topic.