Help with short script please

Hi, I don't know much about MMaxscript, but I'm trying to make an exporter that is basically the same as a .obj export, but it will be able to handle frames, for easier animation on a program I am working on.

This is as far as I have got from reading a few posts here and modifying some bits I found.
--------------------------------------------------------------------------
out_name = ("directory/myfile.txt")
out_file = createfile out_name
vStartFrame = animationrange.start
vEndFrame = animationrange.end

for obj in geometry do
(
format "Number of Frames %\n" vEndFrame to:out_file

for t = vStartFrame to vEndFrame do
(
tmesh = at time t snapshotAsMesh obj
format "Current Frame %\n" t to:out_file
// I think this is right
for v = 1 to getNumVerts obj do
(
vert = getVert tmesh v
format "Vert %, %, %\n" vert.x vert.y vert.z to:out_file
)

for v = 1 to getNumTVerts obj do <--- is this right for getting
the texture cords(UVW?)?
(
TVert = getTVert tmesh v
format "TVert %, %, %\n" tvert.x tvert.y tvert.z to:out_file
)
// I think this is right
for v = 1 to getNumFaces obj do
(
Face = getFace tmesh v
format "Face % % %\n" Face[1] Face[2] Fac[3] to:out_file
)
)
close out_file
--------------------------------------------------------------------------

So Was hoping to end up with a text file similar to .obj

Number of frames 100
Current Frame 1
v 12312 12312 12312
vt 12312 12312 123123
vn 123123 12312 12312
f 123 1 123

Any help would be appreiated.

Thanks in advance Derek

EDIT - So i fixed the faces part(well i think so), also I'm wondering if i need vertex normals or just face normals, the text file will be read by my program then converted to display models in an OpenGL java binding. Any Ideas?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JavaDev's picture

Hmm, Still no luck on my

Hmm, Still no luck on my part.

Another option wuld be for me to look at the actual script that max uses to export a mesh as .obj then I could just modify it. but I have no idea where to look for this. I have to sleep soon but i'll have a tinker about with it tomorrow.

Also if anyone has a link to an exporter specific maxscript tutorial, that deals with vertex normals and faces.

Thanks for your time.

Derek

JavaDev's picture

Hi, So I came accros some

Hi,
So I came accros some problems and reviewed the .obj format spec.

My text output should read

Face v/vt/vn v/vt/vn v/vt/vn

My output needs to look like:

Number of frames 100
Current Frame 1
v 12312 12312 12312
vt 12312 12312 123123
vn 123123 12312 12312
f v/vt/vn v/vt/vn v/vt/vn
Current Frame 2
v 12312 12312 12312
vt 12312 12312 123123
vn 123123 12312 12312
f v/vt/vn v/vt/vn v/vt/vn
etc...

So I think the script is going to be a bit more complex than I first thought.
I'm stil stuck on how to get the vertex normal though.

Help with this would be great.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.