Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Gal Gun x360

Post questions about game models here, or help out others!
Post Reply
chrrox
Moderator
Posts: 2602
Joined: Sun May 18, 2008 3:01 pm
Has thanked: 57 times
Been thanked: 1422 times

Gal Gun x360

Post by chrrox »

Here is a max script to import these models mre info here
viewtopic.php?f=10&t=5982

Code: Select all

if (heapSize < 200000) then
   heapSize = 30000000 -- allow ~ 40 MB instead of just 7.5 MB. Prevents "Runtime Error: Out of scripter memory"

fname = getOpenFileName \
caption:"Gal Gun Model File" \
types:"Gal Gun Model File(*.gmd)|*.gmd" \
historyCategory:"Gal Gun Object Presets"
f = fopen fname "rb"

fn ReadBEShort fstream = (
short = readshort fstream #unsigned
short = bit.swapBytes short 2 1
b = (bit.get short 16)
for i = 17 to 32 do short = bit.set short i b
return short
)

fn PrintOffset Var =
(
   local Var = Var
print ("This is the offset 0x" + (bit.intAsHex Var) as string)
   Var
)

fn floatSwap2 f =
(
   i = bit.floatAsInt f
   h = bit.intashex i
   while h.count < 8 do h = "0" + h
   
   s = (substring h 7 2) + (substring h 5 2) + (substring h 3 2) + (substring h 1 2)
   bit.intAsFloat (bit.hexasint s)
)   

fn ReadBEword fstream = (
return (bit.swapBytes (readshort fstream #unsigned) 1 2)
)

   fn convertTo32 input16 = (
      inputAsInt = input16
      sign = bit.get inputAsInt 16
      exponent = (bit.shift (bit.and inputAsInt (bit.hexasint "7C00")) -10) as integer - 16
      fraction = bit.and inputAsInt (bit.hexasint "03FF")
      if sign==true then sign = 1 else sign = 0
      exponentF = exponent + 127
      --Ouput 32 bit integer representing a 32 bit float
      outputAsFloat = bit.or (bit.or (bit.shift fraction 13) (bit.shift exponentF 23)) (bit.shift sign 31)
      --Output Check   
      return bit.intasfloat outputasfloat
   )

fn ReadBEHalfFloat fstream = (
return convertTo32(ReadBEword fstream)
)

fn ReadBElong fstream = (
long = readlong fstream
long = bit.swapBytes long 1 4
long = bit.swapBytes long 2 3
return long
)

fn ReadBEfloat fstream = (
return floatSwap2(readfloat fstream)
)

fn ReadFixedString bstream fixedLen =
(
   local str = ""
   for i = 1 to fixedLen do
   (
      str += bit.intAsChar (ReadByte bstream #unsigned)
   )
   str
)

struct weight_data
(
   boneids,weights
)

Version = ReadBElong f
print Version
Unk02 = ReadBElong f
Unk03 = ReadBElong f
Vstart = ReadBElong f
Unk05 = ReadBElong f
MeshCount = ReadBElong f
Unk07 = ReadBElong f
MStart_Array = #()
if Version == 0x1050000 Do (
while (ftell f) <= Vstart Do (
test = ReadBElong f
if test == 0xFF060800 do (
append MStart_Array (ftell f)
)
)
)
if Version == 0x1010000 Do (
while (ftell f) <= Vstart Do (
test = ReadBElong f
if test == 0xFF060700 do (
append MStart_Array (ftell f)
)
)
)
print MStart_Array
fseek f 0x40#seek_set
test = 0
do (
test = ReadBElong f
) while test != 0xFFFF0000
fseek f -12#seek_cur
BoneCount = ReadBEword f
fseek f 0x6#seek_cur
BNArr = #()
for a = 1 to BoneCount Do (
BoneParent = ReadBEword f
BoneUnk = ReadBEword f
m11 = ReadBEFloat f; m12 = ReadBEFloat f; m13 = ReadBEFloat f
m21 = ReadBEFloat f; m22 = ReadBEFloat f; m23 = ReadBEFloat f
m31 = ReadBEFloat f; m32 = ReadBEFloat f; m33 = ReadBEFloat f
m41 = ReadBEFloat f; m42 = ReadBEFloat f; m43 = ReadBEFloat f
tfm = matrix3 [m11,m12,m13] [m21,m22,m23] [m31,m32,m33] [m41,m42,m43]

m11 = ReadBEFloat f; m12 = ReadBEFloat f; m13 = ReadBEFloat f
m21 = ReadBEFloat f; m22 = ReadBEFloat f; m23 = ReadBEFloat f
m31 = ReadBEFloat f; m32 = ReadBEFloat f; m33 = ReadBEFloat f
m41 = ReadBEFloat f; m42 = ReadBEFloat f; m43 = ReadBEFloat f
tfm2 = matrix3 [m11,m12,m13] [m21,m22,m23] [m31,m32,m33] [m41,m42,m43]
print tfm
print tfm2
print "---"
	
newBone = bonesys.createbone	\
				  tfm.row4	\
				  (tfm.row4 + 0.01 * (normalize tfm.row1)) \
				  (normalize tfm.row3)
			newBone.name = (a as string)
			newBone.width  = 0.01
			newBone.height = 0.01
			newBone.transform = tfm
			newBone.setBoneEnable false 0
			newBone.wirecolor = yellow
			newbone.showlinks = true
			newBone.pos.controller      = TCB_position ()
			newBone.rotation.controller = TCB_rotation ()


 if (BoneParent != -1) then
 newBone.parent = BNArr[BoneParent + 1]
append BNArr newBone	
)
fseek f MStart_Array[MeshCount]#seek_set
VOff_Array = #()
FOff_Array = #()
for a = 1 to MeshCount Do (
VNull = ReadBElong f
VOff = (ReadBElong f) + 0x14
append VOff_Array VOff
)
for a = 1 to MeshCount Do (
FNull = ReadBElong f
FOff = (ReadBElong f) + 0x14
append FOff_Array  FOff
)
print VOff_Array
print FOff_Array


for a = 1 to MeshCount Do (
Vert_array = #()
UV_array = #()
Normal_array = #()
Face_array = #()

fseek f VOff_Array[a]#seek_set
VType1 = ReadBElong f
VCount = ReadBElong f
VType2 = ReadBElong f
for b = 1 to VCount Do (
vx = ReadBEfloat f
vy = ReadBEfloat f
vz = ReadBEfloat f
	if VType1 == 28 do (
fseek f 0x30#seek_cur
tu = 0
tv = 0
	)
	if VType1 == 29 do (
NX = ReadBEfloat f
NY = ReadBEfloat f
NZ = ReadBEfloat f
Unk07 = ReadBElong f --color
tu = ReadBEfloat f * 1
tv = ReadBEfloat f * -1
Unk04 = ReadBElong f
Unk05 = ReadBElong f
Unk06 = ReadBElong f
Unk08 = ReadBElong f
Unk09 = ReadBElong f
Unk10 = ReadBElong f
Unk11 = ReadBElong f
Unk12 = ReadBElong f
	)
	if VType1 == 38 do (
NX = ReadBEfloat f
NY = ReadBEfloat f
NZ = ReadBEfloat f
Unk04 = ReadBElong f
Unk05 = ReadBElong f
Unk06 = ReadBElong f
Unk07 = ReadBElong f --color
tu = ReadBEfloat f * 1
tv = ReadBEfloat f * -1
Unk08 = ReadBElong f
Unk09 = ReadBElong f
Unk10 = ReadBElong f
Unk11 = ReadBElong f
Unk12 = ReadBElong f
Unk13 = ReadBElong f
Unk16 = ReadBElong f
Unk17 = ReadBElong f
	)
append Vert_array [vx,(vy * -1),(vz * -1)]
append UV_array [tu,tv,0]
)

fseek f FOff_Array[a]#seek_set	
FType1 = ReadBElong f
FCount = ReadBElong f
FType2 = ReadBElong f
for b = 1 to FCount / 3 Do (
f1 = (ReadBElong f) + 1
f2 = (ReadBElong f) + 1
f3 = (ReadBElong f) + 1
append Face_array [f1,f2,f3]
)

msh = mesh vertices:Vert_array faces:Face_array
msh.numTVerts = UV_array.count
buildTVFaces msh
--msh.name = Mesh_Name_array[a]
for j = 1 to UV_array.count do setTVert msh j UV_array[j]
for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
for j = 1 to Normal_array.count do setNormal msh j Normal_array[j]

)
epopoe
advanced
Posts: 56
Joined: Thu Feb 11, 2010 2:22 am
Has thanked: 6 times
Been thanked: 4 times

Re: Gal Gun x360

Post by epopoe »

thank you chrrox

but i got an error

---------------------------
MAXScript FileIn Exception
---------------------------
-- Unable to convert: undefined to type: Integer64
---------------------------


---------------------------
fn ReadBElong fstream = (
long = readlong fstream

long = bit.swapBytes long 1 4 <--error in here

long = bit.swapBytes long 2 3
return long
)
You do not have the required permissions to view the files attached to this post.
chrrox
Moderator
Posts: 2602
Joined: Sun May 18, 2008 3:01 pm
Has thanked: 57 times
Been thanked: 1422 times

Re: Gal Gun x360

Post by chrrox »

you would have to post the file.
epopoe
advanced
Posts: 56
Joined: Thu Feb 11, 2010 2:22 am
Has thanked: 6 times
Been thanked: 4 times

Re: Gal Gun x360

Post by epopoe »

now I solved this problem

That I didnt decompess gmd files

thanks chrrox interest in my problem

Image
You do not have the required permissions to view the files attached to this post.
epopoe
advanced
Posts: 56
Joined: Thu Feb 11, 2010 2:22 am
Has thanked: 6 times
Been thanked: 4 times

Re: Gal Gun x360

Post by epopoe »

This is a part of akira's texture

how can I import bin format
who can help me


(Sorry about wrong grammar,English always hard for me)
You do not have the required permissions to view the files attached to this post.
Post Reply