READ THE RULES: Click here

Follow us on Facebook: https://www.facebook.com/xentax/ :)

Star Wars Galaxies .MGN format (not the same as .MSH)

Post questions about game models here, or help out others!
General_ONeil
ultra-n00b
Posts: 5
Joined: Thu Nov 09, 2006 1:59 am

Post by General_ONeil » Sun Nov 12, 2006 7:51 pm

Ya I got Maya PE as well but haven't found anything in the program to actually create the script :oops:

OneOneSeven
advanced
Posts: 45
Joined: Sun Jul 16, 2006 6:54 am
Location: Around
Contact:

Post by OneOneSeven » Mon Nov 13, 2006 9:22 pm

Makes sense though, with the Alias/Autodesk merger I'd assume they'd port features...

Anyhow just drop that script in your 3dsmax/scripts folder, and then go to the little hammer tab on your right, (default layout) hit the little 'MAXScript' thingy and then click 'Run Script" in the rollout that appears. Then just open your saved file and you're good to go.

General_ONeil
ultra-n00b
Posts: 5
Joined: Thu Nov 09, 2006 1:59 am

Post by General_ONeil » Tue Nov 14, 2006 4:07 am

ok, I get some weird errors, i'll look into them, but is there any place you can upload the file somewhere so thsi forum doesn't mess it up? Thanks a bunch by the way


EDIT: Errors are "pos before norm is 6078" "pos before head reading is 51144" Then it opens the script and shows the code "mdx.pos+= (str)" and says "--Incompatible types: 51152, and undefinded"

EDIT2: I get the same thing on Max 8

EDIT3: Ok i'm at my school trying this on Max 9 again, and now I get these errors: "pos before norm is 3547" "pos before head reading is 30176" "pos of form is 95052" "--No""+"" function for undefined" *shows this one while highlighting "mdx.pos+= (str + 6)" Btw I officially hate MaxScript now, lol, looks alot like JScript but of course it has it's differences. :?

OneOneSeven
advanced
Posts: 45
Joined: Sun Jul 16, 2006 6:54 am
Location: Around
Contact:

Post by OneOneSeven » Thu Jan 11, 2007 11:02 pm

'Twas a bit of a while after these were posted, but FYI max 9 doesn't work with a lot of stuff, including many plugins.

Jaret
ultra-n00b
Posts: 3
Joined: Wed Feb 14, 2007 1:57 pm

Post by Jaret » Thu Feb 15, 2007 8:07 am

I had to reinstall WinXP to be able to install MAX8 but I finaly did and the script doesn't work :(
If anyone is still active would you please give me a little help to open one of the character meshes from SW Galaxies.
I already have the MGH models and the textures in BMP. I just need to know how to run the script properly.
Thanks!!!

crazyjayloc
ultra-n00b
Posts: 4
Joined: Wed May 09, 2007 8:34 am

hope this works (crossing fingers)

Post by crazyjayloc » Thu May 10, 2007 8:25 am

heres the script with smileys disabled, hope it works, if not then could you repost the script with smileys deactivated nicloi_s?
nicoli_s wrote:utility swgmgntest "SWG MGN Importer"
(
----------
-- Vars --
----------
local modelName

local impTypes

local seqs -- Sequences
local mtls -- Materials
local geos -- Geometry
local objs -- Bones, Helpers, Lights, Attachments
local pivot

local geobones

local notes -- Note Track

local meshes = #()
----------------
-- Structures --
----------------
struct File
(
pos, end, bstream,

-- Helper function to init the top-level chunk rover
fn Init stream=
(
bstream = stream
pos = ftell bstream
fseek bstream 0 #seek_end
end = ftell bstream
),

fn fReadHead=
(
fseek bstream pos #seek_set
local id = ReadLong bstream #unsigned
local tag = File.GetName id
pos += 4
tag
),

fn fReadFloat=
(
local id
local i = 0
while (id == undefined) and (i < 10) do
(
fseek bstream pos #seek_set
id = ReadFloat bstream
i += 1
)
if i == 10 then
(
print ("problem: " + (pos as string))
)
pos += 4
id
),

fn fReadLong=
(
fseek bstream pos #seek_set
local id = ReadLong bstream
pos += 4
id
),

fn fReadShort=
(
fseek bstream pos #seek_set
local id = ReadShort bstream #unsigned
pos += 2
id
),

fn fReadByte=
(
fseek bstream pos #seek_set
local id = ReadByte bstream
pos += 1
id
),

fn fReadString n=
(
fseek bstream pos #seek_set
local id = ReadString bstream
pos += n*80
id
),
fn GetName id=
(
case id of
(
0x33544F44: #DOT3
0x4C54494F: #OITL
0x20435A4F: #OZC
0x4C434456: #VDCL
--UNKNOWN
default: #UNKNOWN
)
)

)
fn sflip numb =
(
local bits = #()
local n
for n = 1 to n = 16 do
(
bits[n] = bit.get numb n
)
for n = 1 to n = 8 do
(
numb = bit.set numb n bits[(n+8)]
) for n = 9 to n = 16 do
(
numb = bit.set numb n bits[(n-8)]
) return numb
)
fn lflip numb =
(
local bits = #()
local n
for n = 1 to n = 32 do
(
bits[n] = bit.get numb n
)
for n = 1 to n = 8 do
(
numb = bit.set numb n bits[(24+n)]
)
for n = 9 to n = 16 do
(
numb = bit.set numb n bits[(8+n)]
)
for n = 17 to n = 24 do
(
numb = bit.set numb n bits[(n-8)]
)
for n = 25 to n = 32 do
(
numb = bit.set numb n bits[(n-24)]
)
return numb
)


--------------------
-- User Interface --
--------------------
group "Import MSH"
(
button importButton "Import MGN..."
)

--------------------------
-- Main Import Function --
--------------------------

on importButton pressed do
(
-- Show open file dialog box
local objFileName = getOpenFileName caption:"Import MGN" types:"SWG model File (*.mgn)|*.mgn|All Files (*.*)|*.*|"


local isValid = true
if objFileName != undefined then
(
-- If user made a selection, begin importing
if doesFileExist objFileName then
(
-- Open up the file as a binary stream
local bstream = fopen objFileName "rb"
local mdx = File()
local refx
local refy
local refz
local verts = #()
local test = #()
local faces = #()
local normals = #()
mdx.Init bstream
mdx.pos = 44
local nbones = mdx.fReadLong()
local nverts = mdx.fReadLong()
local nweights = mdx.fReadLong()
local nnormals = mdx.fReadLong()
mdx.pos = 60
local nummesh = mdx.fReadLong()
mdx.pos = 83
local str = mdx.fReadByte()
--messagebox ("str length is " + (str as string))
mdx.pos += (str + 6)
--messagebox ("reading nverts at " + (mdx.pos as string))
local tests = mdx.fReadShort()
--messagebox ("tests before flip is " + (tests as string))
tests = sflip tests
mdx.pos += (8 + tests)
--messagebox ("reading verts at " + (mdx.pos as string))
for n = 1 to n = nverts do
(
x = mdx.fReadFloat()
y = mdx.fReadFloat()
z = mdx.fReadFloat()
verts[n] = point3 x z y
)
mdx.pos += 6 local len = mdx.fReadShort()
len = sflip len
mdx.pos += (len + 6)
--messagebox ("pos before twit is " + (mdx.pos as string))
--twdt
local len = mdx.fReadShort()
len = sflip len
mdx.pos += (len + 6)
messagebox ("pos before norm is " + (mdx.pos as string))
--norm local len = mdx.fReadShort()
len = sflip len
mdx.pos += (len)
messagebox ("pos before head reading is " + (mdx.pos as string))
local head = mdx.fReadHead()

if (head == #DOT3) then (
mdx.pos += 2
--dot3
local len = mdx.fReadShort()
len = sflip len
mdx.pos += (len)
) else (
mdx.pos -= 4
)

mdx.pos += 7
str = mdx.fReadByte()
mdx.pos += (str)
local type
if mdx.fReadHead() == #OZC then
(
type = true
) else (
type = false
)
mdx.pos += 2
local j = mdx.fReadShort()
j = sflip j
mdx.pos += j

for w = 1 to w = nummesh do
(
messagebox ("pos of form is " + (mdx.pos as string))
mdx.pos += 19
str = mdx.fReadByte()
mdx.pos += (str + 6)
local jump = mdx.fReadShort()
jump = sflip jump
jump += mdx.pos
local size = mdx.fReadLong()
local ppoints = #()
for n = 1 to n = size do
(
x = mdx.fReadLong()
ppoints[n] = (x + 1)
)
mdx.pos = (jump + 6)
--NIDX
messagebox ("pos of NIDX is " + (mdx.pos as string))
jump = mdx.fReadShort()
jump = sflip jump
mdx.pos += (jump)
local header = mdx.fReadHead()
if ((header == #DOT3) or (header == #VDCL)) then
(
mdx.pos += 2
--DOT3
messagebox ("pos of dot3 is " + (mdx.pos as string))
jump = mdx.fReadShort()
jump = sflip jump
mdx.pos += (jump + 6)
) else (
mdx.pos += 2
)
--TXCI
messagebox ("TXCI pos is " + (mdx.pos as string))
jump = mdx.fReadShort()
jump = sflip jump
mdx.pos += (jump + 18)
--FORM
messagebox ("FORM pos is " + (mdx.pos as string))
jump = mdx.fReadShort()
jump = sflip jump
local tverts = #()
for m = 1 to m = (jump / 8) do
(
x = mdx.fReadFloat()
y = mdx.fReadFloat()
tverts[m] = point3 x (1-y) 0
)
mdx.pos += 24
messagebox ("pos of face is " + (mdx.pos as string))
local fc
--face block

mdx.pos += 6
jump = mdx.fReadShort()
jump = sflip jump
local jump2 = jump
jump += mdx.pos
fc = mdx.fReadLong()
messagebox ("nfaces: " + (fc as string))
for n = 1 to n = fc do
(
if (((fc * 14) + 4) <= jump2) then (mdx.pos += 2)
x = mdx.fReadLong()
y = mdx.fReadLong()
z = mdx.fReadLong()
--messagebox ("x is " + (x as string) + " y is " + (y as string) + " z is " + (z as string))
faces[n] = point3 ppoints[(x+1)] ppoints[(y+1)] ppoints[(z+1)]
)
mdx.pos = jump
test[w] = mesh numverts: nverts numfaces: fc
for b = 1 to b = nverts do
(
test[w].vertices = verts
)
for b = 1 to b = fc do
(
test[w].faces = faces
)
setNumTVerts test[w] nverts
for k = 1 to k = tverts.count do
(
setTVert test[w] ppoints[k] tverts[k]
)
buildTVFaces test[w]

for k = 1 to test[w].numfaces do
(
setTVFace test[w] k faces[k]
)
for k = 1 to k = tverts.count do
(
setTVert test[w] ppoints[k] tverts[k]
)
)
) )
)
)

--getNodeByName <string> exact:<boolean>



well aparently the script is working but not in 3ds max 9, and i have the same kind of error, it says its not a valid file format

so i guess its back to the drawing board for a working importer script for those of us using 3ds max 9

or is it possible that it might work with gmax? just curious...

Jaret
ultra-n00b
Posts: 3
Joined: Wed Feb 14, 2007 1:57 pm

Post by Jaret » Thu May 10, 2007 12:33 pm

I tried it again in 3DS MAX 8 and 7, and it still doesn't work.

fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 93 times

Post by fatduck » Mon May 14, 2007 10:33 pm

I am bored today, so looked at the mgn file format. It's petty easy. And I wrote this maxscript to import MGN files. It should work in GMax.

I didn't looked at nicoli_s's maxscript, just build it form ground. So test it to see if it helps? :mrgreen:
Last edited by fatduck on Sun Jun 10, 2007 10:43 pm, edited 2 times in total.

Jaret
ultra-n00b
Posts: 3
Joined: Wed Feb 14, 2007 1:57 pm

Post by Jaret » Tue May 15, 2007 2:06 pm

I just tried it and it works perfectly!

I want to express my great appretiation and gratitute to fatduck :!:

I promise to use this new power only for good :)

fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 93 times

Post by fatduck » Tue May 15, 2007 6:00 pm

Good to see people like it!
So I spent another hour to make this maxscript support msh as well.

Enjoy.
You do not have the required permissions to view the files attached to this post.
Last edited by fatduck on Sun Jun 10, 2007 10:42 pm, edited 2 times in total.

Ghostrider
ultra-n00b
Posts: 4
Joined: Mon Apr 30, 2007 9:09 pm
Been thanked: 1 time

Post by Ghostrider » Fri Jun 08, 2007 9:21 am

Fatduck, I like to say your effort is greatly appreciated. :) Many of the SWG models can be used to greatly enhance the Jedi Academy and Battlefront games. The ATAT & ATST models alone can make a huge difference. See below:

Image
Image

However, I have encountered a problem with the script. It seems any interior model files, whether it be an interior of a building or a cockpit, the UV won’t display correctly. Sometimes the interior files will crash the script outright. There is screenshot of what an interior model looks like if it imports below.

Image

If you like to take look, I have attached a zip file containing the error message Max gave me when the script crashed, the model that crashed it, a cockpit file, and a file that the script works perfectly with.
You do not have the required permissions to view the files attached to this post.

fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 93 times

Post by fatduck » Fri Jun 08, 2007 2:50 pm

Ghostrider, your zip file seems have problem! I can't open the files inside the "Script error" folder!?

Please re-upload it and I'll check to see if any problem!

Ghostrider
ultra-n00b
Posts: 4
Joined: Mon Apr 30, 2007 9:09 pm
Been thanked: 1 time

Post by Ghostrider » Fri Jun 08, 2007 10:06 pm

Sorry about that. I have attached a new one. If you still have trouble with this zip file should I use winrar instead?
You do not have the required permissions to view the files attached to this post.

fatduck
mega-veteran
mega-veteran
Posts: 315
Joined: Wed Aug 02, 2006 10:07 pm
Has thanked: 10 times
Been thanked: 93 times

Post by fatduck » Sat Jun 09, 2007 12:02 pm

OK, the crash problem should be fixed!
But I'm not sure if the UV will correct form file to file!? Since it use some kind of FVF to store "Vertex Element", so the position of UV data might be different.

These happened because the version of the .msh/.mgn updated!

Go back to the above post to download the latest maxscript.

Ghostrider
ultra-n00b
Posts: 4
Joined: Mon Apr 30, 2007 9:09 pm
Been thanked: 1 time

Post by Ghostrider » Sun Jun 10, 2007 6:35 pm

Fatduck, when I first ran your script it would only import the mgn files and whenever I tried to import a msh file it would crash and give me this in listener:
-- Error occurred in i loop; filename: D:\3dsMax8\Scripts\SoulburnScripts\SWG_model_importer.ms; position: 4105
-- Frame:
-- mm1: undefined
-- boundary: undefined
-- f1: 40
-- f2: undefined
-- i: 1
-- f3: undefined
-- called in readINDX(); filename: D:\3dsMax8\Scripts\SoulburnScripts\SWG_model_importer.ms; position: 4304
-- Frame:
-- sizeElement: 4
-- FCary: #()
-- datasize: 532
-- numIndex: 132
-- f: <BinStream:C:\Temp\NOLF Files\MsScript error\thm_nboo_thed_emp_retreat_r11_mesh_r11.msh>
-- called in impMGN.pressed(); filename: D:\3dsMax8\Scripts\SoulburnScripts\SWG_model_importer.ms; position: 5435
-- Frame:
So I decided to delete these lines (;mm1=boundary mm1 f1) from your script then it started working perfectly.

All of the files would import and vast majority of the time the UV data would load correctly as well, when the UV data didn’t load it was always a floor or a wall which are easy to fix. So you might want to update your script. Again great work and thank you for your effort, it's very much appreciated.

Post Reply