Critical Mass :: 3D Action Puzzle Game

Don't Like Ad's?
Click Here


Forum Index - 3Dimensional - MaxScript - Gumball Model Exporter

There are 5 replies to this topic ShareIt! Text-To-Speech





+VarnishedOtter
Admin
VarnishedOtter

2 years ago
Heres a script I wrote to export objects to my 3D engine (Gumball).

Will export all selected objects at their current frame.

All materials must be multi/sub with a bitmap in the diffuse slot and all faces must have a valid material ID.

if selection.count > 0 then(
output_name = getSaveFileName caption:"Gumball Model" types:"Gumball Model (*.gbm)|*.gbm|All Files (*.*)|*.*|"
if output_name != undefined then(
output_file = createfile output_name
num_objects = 0
for obj in selection do(
num_objects = num_objects + 1
)
format "%\n" num_objects to:output_file
for obj in selection do(
dump1 = undefined
dump1 = copy obj
dump1.name = obj.name
snapshotasmesh dump1
convertToMesh dump1
num_verts = dump1.numverts
num_faces = dump1.numfaces
num_tverts = dump1.numtverts
at time animationrange.start format "% % % % %\n" obj.name dump1.material.numsubs num_faces num_verts num_tverts to:output_file
for v = 1 to dump1.material.numsubs do(
matid = dump1.material.materialIDList[v]
mat = dump1.material.materialList[v].diffuseMap
if mat != undefined then(
mat = filenameFromPath mat.filename
format "% %\n" matid mat to:output_file
)
else (
format "% NULL\n" matid to:output_file
)
)
for v = 1 to num_faces do(
mat = getFaceMatID dump1 v
p = getFace dump1 v;
x = p.x as Integer -1;
y = p.y as Integer -1;
z = p.z as Integer -1;
tvert = getTVFace dump1 v
tx = tvert[1] as integer -1;
ty = tvert[2] as integer -1;
tz = tvert[3] as integer -1;
format "% % % % % % %\n" x y z tx ty tz mat to:output_file
)
for v = 1 to num_verts do(
p = getVert dump1 v;
x = p.x as Float;
y = p.y as Float;
z = p.z as Float;

format "% % %\n" x y z to:output_file
)
for v = 1 to num_tverts do(
p = getTVert dump1 v;
u = p.x as Float;
v = p.y as Float;

format "% %\n" u v to:output_file
)
delete dump1
)
close output_file
edit output_name
)
)


Please support us and post a [Link to www.digitalartsfront.com] on your website.

--Matt

+VarnishedOtter
Admin
VarnishedOtter

2 years ago
Creates files like this:

1
Box01 1 12 8 36
1 logo.jpg
0 2 3 8 9 10 1
3 1 0 11 12 13 1
4 5 7 14 15 16 1
7 6 4 17 18 19 1
0 1 5 20 21 22 1
5 4 0 23 24 25 1
1 3 7 26 27 28 1
7 5 1 29 5 1 1
3 2 6 30 31 32 1
6 7 3 33 7 3 1
2 0 4 34 0 35 1
4 6 2 4 6 2 1
-25.0 -25.0 0.0
25.0 -25.0 0.0
-25.0 25.0 0.0
25.0 25.0 0.0
-25.0 -25.0 50.0
25.0 -25.0 50.0
-25.0 25.0 50.0
25.0 25.0 50.0
0.9995 0.000499517
0.000499547 0.000499517
0.000499547 0.000499517
0.000499547 0.000499517
0.9995 0.9995
0.000499547 0.9995
0.000499547 0.9995
0.000499547 0.9995
0.9995 0.000499785
0.9995 0.9995
0.000499547 0.9995
0.000499547 0.9995
0.000499785 0.000499547
0.9995 0.000499785
0.000499547 0.000499785
0.9995 0.000499547
0.9995 0.9995
0.9995 0.9995
0.000499785 0.9995
0.000499547 0.000499785
0.000499547 0.000499517
0.9995 0.000499517
0.9995 0.9995
0.9995 0.9995
0.000499547 0.9995
0.000499547 0.000499517
0.000499547 0.000499517
0.9995 0.000499517
0.9995 0.9995
0.9995 0.9995
0.000499547 0.000499517
0.9995 0.000499517
0.9995 0.9995
0.9995 0.9995
0.000499547 0.000499517
0.9995 0.9995

Please support us and post a [Link to www.digitalartsfront.com] on your website.

--Matt

+Steve Martin
Moderator
Steve Martin

2 years ago
Cool. Any major upcoming games using your engine?
[Link to www.3dprevis.com]

+VarnishedOtter
Admin
VarnishedOtter

2 years ago
Theres a couple projects on the go. I've been working on the engine off and on for almost 2 years now.

You might get to play something soon.
Please support us and post a [Link to www.digitalartsfront.com] on your website.

--Matt

-Solidstrike
Junior Member
Solidstrike

2 years ago
Just out of curiousity: Is the language you used for programming python?

+VarnishedOtter
Admin
VarnishedOtter

2 years ago
The language of this script is MaxScript. 3ds max has its own inbuilt language.

For programming my engine I'm using c++.
Please support us and post a [Link to www.digitalartsfront.com] on your website.

--Matt

Top

Critical Mass :: 3D Action Puzzle Game

Don't Like Ad's?
Click Here