Skip to main content
gamedev.net
🔒 Locked

MaxScript very basic exporter

Started by TrashLock 3 replies 1.1k views
Original Post
TrashLock
TrashLock
Hello all! I'm new here, and I'm not quite sure this is the right forum (I am so confused). Before I start let me tell you that I am rather experienced in Programming in general, and I've already got a good grasp of the MaxScript syntax. Anyways, to get to the point: I've made a robust Flash 3d Engine. It's fast enough, has basic shading and supports about a hundred vertices. Now I tried making a rudimentary modeler for it, but it's not very good, and it takes me hours to model a shitty-looking spaceship. My engine uses a special type of format I designed, that is ASCII-based: it's rudimentary, but it works well enough. I am a pretty good low-poly modeler for 3d studio max (I've had to make really low poly stuff in the past), so poly count won't be too much of a problem. What I want to do is a really basic exporter in MaxScript. Something really basic. I select an object, click a button and the script outputs (or writes to a file) the mesh data. As you might have guessed, I don't need all the extra textures, UV mapping and such. I just need all the vertices, and all the polygons. That's right, I'm not even asking for color. It would be too much and I can do it myself by editing the ASCII file. If you're wondering, here is a sample of a what-I-call "TrashEngine File". It's a basic cube.

points[
[-100,-100,100],
[-100,100,100],
[100,100,100],
[100,-100,100],
[-100,-100,-100],
[-100,100,-100],
[100,100,-100],
[100,-100,-100]
]
polys[
[1118481,true,false,0,3,2,1],
[1118481,true,false,4,5,6,7],
[1118481,true,false,1,2,6,5],
[1118481,true,false,0,4,7,3],
[1118481,true,false,0,1,5,4],
[1118481,true,true,7,6,2,3]
]
the points[] part doesn't need explaining. Simple x, y, z coordinates. Now for the polys part: -first number is the color in 16-bits -second value is "true" if backface culling should be used -third value is "true" if the normals are flipped -fourth and more: which vertices the poly are linked to Ok, you have everything. I just need a small hint on how I would get all the vertices and all the polygons from a mesh in 3ds max. I'm using version 7 if it matters. Thank you for your help, it is muchos appreciated!
Roquqkie
Roquqkie
Hi!

Hehe, click on help->Maxscript...
Then you click "How to's"...
Then click "How to write an exporter part 2"...
There you have it :) A exporter written in MaxScript that does excactly what you need! :)

Best regards,
Roquqkie
TrashLock
TrashLock
Quote:
Original post by Roquqkie
Hi!

Hehe, click on help->Maxscript...
Then you click "How to's"...
Then click "How to write an exporter part 2"...
There you have it :) A exporter written in MaxScript that does excactly what you need! :)

Best regards,
Roquqkie


Well, there's a problem. The help files on my version of 3ds max don't seem to exist. I would have looked in the help a long time ago had I been able to.
Roquqkie
Roquqkie
MacroScript ExportMesh category:"HowTo"

(

fn GetGeometry o = (

Superclassof o == Geometryclass and classof o != TargetObject )

obj = pickobject filter:GetGeometry

if isValidNode obj then

(

tmesh = snapshotAsMesh obj

out_name = GetSaveFileName()

if out_name != undefined then

(

out_file = createfile out_name

num_verts = tmesh.numverts

num_faces = tmesh.numfaces

format "%,%\n" num_verts num_faces to:out_file

for v = 1 to num_verts do

format "%," (getVert tmesh v) to:out_file

format "\n" to:out_file

for f = 1 to num_faces do

(

face = getFace tmesh f

sgroup = getFaceSmoothGroup tmesh f

matid = getFaceMatId tmesh f

edge1 = getEdgeVis tmesh f 1

edge2 = getEdgeVis tmesh f 2

edge3 = getEdgeVis tmesh f 3

format "%,%,%,%,%,%\n" face sgroup matid edge1 edge2 edge3 to:out_file

)

close out_file

edit out_name

)

)

)


^^ There you go :)

And btw. it's a macroscript... you add it to a menu/toolbar/button/shortcut/whatever by selecting it in Customize->Customize User Controls

Br,
Roq
Sneftel
Sneftel
Quote:
Original post by TrashLock
Well, there's a problem. The help files on my version of 3ds max don't seem to exist. I would have looked in the help a long time ago had I been able to.

Then install them. They're right there on the CD; if you didn't install them when you installed the app, you can just go into the installer again and add them.

Topic Locked

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

Sign in to reply to this topic.