Advertisement

Exporting non-indexed vertex data from 3DSMAx

Started by July 05, 2014 03:36 PM
2 comments, last by Gavin Williams 10 years, 5 months ago

Hi,

I'm trying to export model data from 3DSMax to be used in my own program, but it seems that any export (eg OBJ) always outputs the vertex data in an unusable format. I am not currently using a model library, I'm loading/using raw vertex data. So I need the vertex data as just that ... vertex data. I'm not using indices, as I want hard edges.

eg:

Vertex 1 : position, normal, texcoord

Vertex 2 : position, normal, texcoord

etc

Take a look at the OBJ file for a cube, below. that vertex data can't be used to reconstruct a cube ! There needs to be 36 vertices for a cube, but only the normals are presented in the correct way. There is face data, but I can't make sense of it, normally such facet data would be referred to as index data, and it would reference the vertices by index. But the face data is indexed upto 36, and there are only 8 vertices in this file description.

Can anyone help me export models in a usable format ?


# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
# File Created: 06.07.2014 01:05:57

#
# object Box001
#

v  -8.5282 0.0000 16.5679
v  15.5268 0.0000 16.5679
v  -8.5282 0.0000 -13.1042
v  15.5268 0.0000 -13.1042
v  -8.5282 29.3498 16.5679
v  15.5268 29.3498 16.5679
v  -8.5282 29.3498 -13.1042
v  15.5268 29.3498 -13.1042
# 8 vertices

vn 0.0000 -1.0000 -0.0000
vn 0.0000 -1.0000 -0.0000
vn 0.0000 -1.0000 -0.0000
vn 0.0000 -1.0000 -0.0000
vn 0.0000 -1.0000 -0.0000
vn 0.0000 -1.0000 -0.0000
vn 0.0000 1.0000 -0.0000
vn 0.0000 1.0000 -0.0000
vn 0.0000 1.0000 -0.0000
vn 0.0000 1.0000 -0.0000
vn 0.0000 1.0000 -0.0000
vn 0.0000 1.0000 -0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 -0.0000
vn 1.0000 0.0000 -0.0000
vn 1.0000 0.0000 -0.0000
vn 1.0000 0.0000 -0.0000
vn 1.0000 0.0000 -0.0000
vn 1.0000 0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 0.0000 -0.0000
vn -1.0000 0.0000 -0.0000
vn -1.0000 0.0000 -0.0000
vn -1.0000 0.0000 -0.0000
vn -1.0000 0.0000 -0.0000
vn -1.0000 0.0000 -0.0000
# 36 vertex normals

vt 0.0000 0.0000 0.0000
vt 1.0000 0.0000 0.0000
vt 0.0000 1.0000 0.0000
vt 1.0000 1.0000 0.0000
vt 0.0000 0.0000 0.0000
vt 1.0000 0.0000 0.0000
vt 0.0000 1.0000 0.0000
vt 1.0000 1.0000 0.0000
vt 0.0000 0.0000 0.0000
vt 1.0000 0.0000 0.0000
vt 0.0000 1.0000 0.0000
vt 1.0000 1.0000 0.0000
# 12 texture coords

g Box001
f 1/10/1 3/12/2 4/11/3
f 4/11/4 2/9/5 1/10/6
f 5/9/7 6/10/8 8/12/9
f 8/12/10 7/11/11 5/9/12
f 1/5/13 2/6/14 6/8/15
f 6/8/16 5/7/17 1/5/18
f 2/1/19 4/2/20 8/4/21
f 8/4/22 6/3/23 2/1/24
f 4/5/25 3/6/26 7/8/27
f 7/8/28 8/7/29 4/5/30
f 3/1/31 1/2/32 5/4/33
f 5/4/34 7/3/35 3/1/36
# 12 faces

I think the answer is to write a custom exporter using MAXScript, which I'm trying to do now.

Advertisement

Indeed, with a MaxScript exporter tool your level of control will be absolute. There's an entire ecosystem behind MaxScript - you can make commercial scripts that you encrypt and sell, you can make a MacroScript that is added to the toolbar as a button etc.

The documentation for it is very good. You can view it inside the program or online:
http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=files/GUID-38562330-1435-4112-9265-DE965319A2F2.htm,topicNumber=d30e108846

I suggest that you make your exporter as a Macro Script, which is a script code that is assigned to a button in the toolbar for quick navigation. Then this script can open a rollout (a window) with buttons etc. for specifying the file path and other settings for export:
http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/files/GUID-AF3EADB8-6648-454F-AD7E-59170C4603FE.htm

- - - - -

If one is looking for specialized help, there's the MaxScript forum on CGTalk:

http://forums.cgsociety.org/forumdisplay.php?f=98

Yep, this is definitely the way to go. I have already had some success this morning with a basic script exporting the position and texcoords. I haven't quite worked out normals yet, and haven't fully tested the texcoords, but I have successfully exported a simple model and basically dropped it into my game, with a little bit of tweaking.

I will look into macro script too.

This topic is closed to new replies.

Advertisement