Join also our Discord channel! Click here.

Granado Espada

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

Granado Espada

Post by chrrox » Sat Jun 12, 2010 12:57 pm

Here is a max script to load them into 3ds max with bones.
If someone wants to help me figure out the weighting ill add it to the max script.

Code: Select all

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

fname = GetOpenFileName caption:"Open Granado Espada Model File" types:"Granado Espada Model File(*.lma)|*.lma"
f = fopen fname "rb"   --open file in read only format


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

fn Readword fstream = (
return readshort fstream #unsigned
)

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

struct Mesh_Info_Struct
(
	Mesh_Name,vertstart,vertend,vertcount,facecount
)
struct Offset_Info_Struct
(
	Section_Start,Vert_Start,Face_Start,vertsize
)
total_size = getFileSize fname
print total_size
idstring = readlong f
id1 = readbyte f#unsigned
id2 = readbyte f#unsigned
id3 = readbyte f#unsigned
Type_0_offset_array =#()
Type_1_offset_array =#()
Type_2_offset_array =#()
Type_3_offset_array =#()
Type_3_2_offset_array =#()
Type_4_offset_array =#()
Type_5_offset_array =#()
Type_6_offset_array =#()
Type_7_offset_array =#()
Mesh_Name_array =#()
do (
type = readlong f
size = readlong f
type2 = readlong f
print type
print size
print type2
printoffset (ftell f)
if type == 0 do (

append Type_0_offset_array (ftell f)

)
if type == 1 do (
append Type_1_offset_array (ftell f)
)
if type == 2 do (
append Type_2_offset_array (ftell f)
)
if type == 3 do (
if type2 == 2 do (
append Type_3_offset_array (ftell f)
)
if type2 == 10000 do (
append Type_3_2_offset_array (ftell f)
)
)
if type == 4 do (
append Type_4_offset_array (ftell f)
)
if type == 5 do (
append Type_6_offset_array (ftell f)
)
if type == 6 do (
append Type_6_offset_array (ftell f)
)
if type == 7 do (
append Type_7_offset_array (ftell f)
)
fseek f size #seek_cur
)while (ftell f) != total_size
print Type_0_offset_array.count
print Type_1_offset_array.count
print Type_2_offset_array.count
print Type_3_offset_array.count
print Type_4_offset_array.count
print Type_5_offset_array.count
print Type_6_offset_array.count
print Type_7_offset_array.count

for a = 1 to Type_0_offset_array.count  do (
fseek f Type_0_offset_array[a]#seek_set
bone_name = readstring f
print bone_name
if isvalidnode (getNodeByName bone_name) != true then (
fseek f (0x28 - (bone_name.count + 1))#seek_cur
bone_parent = readstring f
if bone_parent != "" do (
fseek f (0x28 - (bone_parent.count + 1))#seek_cur
)
if bone_parent == "" do (
fseek f 0x27 #seek_cur
)
print (getNodeByName bone_name)
if (getNodeByName bone_name) != "undefined" do (
fseek f 0x28#seek_cur
m11 = readfloat f; m12 = readfloat f; m13 = readfloat f; m14 = readfloat f
m21 = readfloat f; m22 = readfloat f; m23 = readfloat f; m24 = readfloat f
m31 = readfloat f; m32 = readfloat f; m33 = readfloat f; m34 = readfloat f
m41 = readfloat f; m42 = readfloat f; m43 = readfloat f; m44 = readfloat f
tfm = matrix3 [m11,m12,m13] [m21,m22,m23] [m31,m32,m33] [m41,m42,m43]
	newBone = bonesys.createbone	\
				  tfm.row4	\
				  (tfm.row4 + 0.01 * (normalize tfm.row1)) \
				  (normalize tfm.row3)
			newBone.name   = bone_name
			newBone.width  = 0.3
			newBone.height = 0.3
			newBone.transform = inverse tfm
			newBone.wirecolor = yellow
			newbone.showlinks = true
			newBone.setBoneEnable false 0
			newBone.pos.controller      = TCB_position ()
			newBone.rotation.controller = TCB_rotation ()
			newBone.name   = bone_name
			newBone.width  = 0.3
			newBone.height = 0.3
			newBone.setBoneEnable false 0
			newBone.pos.controller      = TCB_position ()
			newBone.rotation.controller = TCB_rotation ()

 if (bone_parent != "") then (
 newBone.parent = getNodeByName bone_parent
 )
 )
)
)
for a = 1 to Type_7_offset_array.count do (
fseek f Type_7_offset_array[a]#seek_set
Mesh_name = readstring f
fseek f (0x28 - (Mesh_name.count + 1))#seek_cur
if Mesh_name != "env_normal" do (

append Mesh_Name_array Mesh_name 
)
print Mesh_name
print "-----------------"
)
for a = 1 to Type_4_offset_array.count do (
fseek f Type_4_offset_array[a]#seek_set
fseek f -8#seek_cur
tsize = readlong f
t2 = readlong f
unk01 = readlong f
t4_count = (tsize / 9)
for b = 1 to t4_count do (
type = readbyte f#unsigned
bone_id = readlong f
weight = readfloat f
printoffset type
print bone_id
print weight
	print "----------"
	
)
printoffset (ftell f)
)

for a = 1 to Type_3_offset_array.count do (
fseek f Type_3_offset_array[a]#seek_set
	
unk01 = readlong f
unk02 = readlong f
unk03 = readlong f
unk04 = readlong f
Mesh_Count = readlong f
unk06 = readlong f
for c = 1 to Mesh_Count do (
unk07 = readlong f
Vert_array = #()    --define arrays for verts, normals, UV and Faces
Normal_array = #()
UV_array = #()
Face_array = #()	

Fcount = (readlong f) / 3
Vcount = readlong f
for i = 1 to Vcount do (   --* number of verts count
vx = readfloat f     --read xyz coordinates
vy = readfloat f
vz = readfloat f
append Vert_array [vx,vy,vz] --save verts to Vert_array
        --since UV in Max are in point3 format, so we add 0 for z value
nx = readlong f    --read Normal ??
ny = readlong f
nz = readlong f
--append Normal_array [nx,ny,nz] --save normals to Normal_array
tu = readfloat f     --read UV float value
tv = (readfloat f) * -1 
append UV_array [tu,tv,0]  --save UVs to UV_array
b1 = readlong f
)

for k = 1 to Fcount do (
f1 = (readlong f) + 1  --read face indices, games are start form 0, but Max start from 1
f2 = (readlong f) + 1  --so we add 1 to each index
f3 = (readlong f) + 1
append Face_array [f1,f2,f3] --save faces to Face_array
)

msh = mesh vertices:Vert_array faces:Face_array   --build mesh
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]
)	
)


for a = 1 to Type_3_2_offset_array.count do (
fseek f Type_3_2_offset_array[a]#seek_set
	
Vert_array = #()    --define arrays for verts, normals, UV and Faces
Normal_array = #()
UV_array = #()
Face_array = #()	

unk01 = readlong f
unk02 = readlong f
unk03 = readlong f
unk04 = readlong f
unk05 = readlong f
unk06 = readbyte f
Mesh_Name = readstring f
fseek f (0x107 - (Mesh_name.count + 1))#seek_cur

Fcount = (readlong f) / 3
Vcount = readlong f
for i = 1 to Vcount do (   --* number of verts count
vx = readfloat f     --read xyz coordinates
vy = readfloat f
vz = readfloat f
append Vert_array [vx,vy,vz] --save verts to Vert_array
        --since UV in Max are in point3 format, so we add 0 for z value
nx = readlong f    --read Normal ??
ny = readlong f
nz = readlong f
--append Normal_array [nx,ny,nz] --save normals to Normal_array
tu = readfloat f     --read UV float value
tv = (readfloat f) * -1 
append UV_array [tu,tv,0]  --save UVs to UV_array
b1 = readfloat f 
b2 = readfloat f 
b3 = readfloat f 
)

for k = 1 to Fcount do (
f1 = (readlong f) + 1  --read face indices, games are start form 0, but Max start from 1
f2 = (readlong f) + 1  --so we add 1 to each index
f3 = (readlong f) + 1
append Face_array [f1,f2,f3] --save faces to Face_array
)

msh = mesh vertices:Vert_array faces:Face_array   --build mesh
msh.numTVerts = UV_array.count
buildTVFaces msh
msh.name = Mesh_Name
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]
	
)
fclose f



pixellegolas
ultra-veteran
ultra-veteran
Posts: 423
Joined: Mon Aug 11, 2008 11:30 pm
Has thanked: 27 times
Been thanked: 15 times

Re: Granado Espada

Post by pixellegolas » Mon Jun 14, 2010 12:19 pm

that is pure coolness chrrox :)

Szkaradek123
mega-veteran
mega-veteran
Posts: 292
Joined: Wed May 05, 2010 8:21 pm
Location: Poland Głogów
Has thanked: 21 times
Been thanked: 605 times

Re: Granado Espada

Post by Szkaradek123 » Tue Jun 29, 2010 4:29 pm

look at :
line 167-179
line 231
line 261
You do not have the required permissions to view the files attached to this post.

User avatar
chrrox
Moderator
Posts: 2565
Joined: Sun May 18, 2008 3:01 pm
Has thanked: 57 times
Been thanked: 1311 times

Re: Granado Espada

Post by chrrox » Wed Jun 30, 2010 3:02 am

Thanks I will try this as soon as i can.

Szkaradek123
mega-veteran
mega-veteran
Posts: 292
Joined: Wed May 05, 2010 8:21 pm
Location: Poland Głogów
Has thanked: 21 times
Been thanked: 605 times

Re: Granado Espada

Post by Szkaradek123 » Sun Jul 11, 2010 4:32 pm

The contents of this post was deleted because of possible forum rules violation.
You do not have the required permissions to view the files attached to this post.

napoleon321
advanced
Posts: 59
Joined: Tue Nov 16, 2010 12:11 pm
Has thanked: 9 times
Been thanked: 4 times

Re: Granado Espada

Post by napoleon321 » Sun Nov 21, 2010 9:36 pm

Nice work chrrox. Thanks.

Szkaradek123
mega-veteran
mega-veteran
Posts: 292
Joined: Wed May 05, 2010 8:21 pm
Location: Poland Głogów
Has thanked: 21 times
Been thanked: 605 times

Re: Granado Espada

Post by Szkaradek123 » Fri Jan 28, 2011 8:40 pm

The contents of this post was deleted because of possible forum rules violation.


Upadate: 2014-07-01

http://www.mediafire.com/download/82wha ... BPC%5D.zip
Last edited by Szkaradek123 on Tue Jul 01, 2014 10:18 am, edited 1 time in total.

pixellegolas
ultra-veteran
ultra-veteran
Posts: 423
Joined: Mon Aug 11, 2008 11:30 pm
Has thanked: 27 times
Been thanked: 15 times

Re: Granado Espada

Post by pixellegolas » Fri Apr 08, 2011 11:52 pm

Havent had the chance to try this plugin until now but just wanted to say it works great :) Are you planning animations to?

User avatar
almondega
ultra-n00b
Posts: 5
Joined: Sat Jan 02, 2010 11:39 pm
Been thanked: 3 times

Re: Granado Espada

Post by almondega » Sun Apr 17, 2011 3:31 pm

Wow!

Animations support would be amazing.
:wink:

Slozhny
beginner
Posts: 26
Joined: Sun Aug 30, 2009 11:03 pm
Been thanked: 2 times

Re: Granado Espada

Post by Slozhny » Tue Apr 26, 2011 11:18 am

to Szkaradek123
Your script (import with weight.rar [2.32 KiB]) is incorrect. Some language mistakes (((

gv2mancia
ultra-n00b
Posts: 4
Joined: Thu Jun 16, 2011 3:10 pm
Has thanked: 3 times

Re: Granado Espada

Post by gv2mancia » Tue Nov 22, 2011 2:49 pm

could you update the 3dsmax script that import with weight please?

Thanks chroxx and Szkaradek123 so much :)

artworkplay
veteran
Posts: 114
Joined: Wed Oct 05, 2011 9:40 pm
Has thanked: 49 times
Been thanked: 4 times

Re: Granado Espada

Post by artworkplay » Tue May 15, 2012 11:48 pm

Szkaradek123 wrote:look at :
line 167-179
line 231
line 261
Hate to bring up a closed topic but I keep getting a maxscript filein exception error when I try this with 2012.
Where could I get the fix for this?

zdsmdbh
n00b
Posts: 19
Joined: Wed Nov 13, 2013 3:03 am
Has thanked: 43 times
Been thanked: 3 times

Re: Granado Espada

Post by zdsmdbh » Wed Apr 30, 2014 1:53 pm

Sorry to bump this old topic
Model there are really nice,hope somebody will realease a script with weight
Here's some sample files
http://1drv.ms/1hRHOlY

Thanks

Post Reply