Users browsing this thread: 7 Guest(s)
Sonic Model Ripping Thread
Code:
fseek f 0x28 #seek_set --
BoneCount = ReadBElong f
BoneTableOffset = ReadBElong f + 0x18
BoneTableOffset2 = ReadBElong f + 0x18
BoneTableOffset3 = ReadBElong f + 0x18
UnkCountt = ReadBElong f
MeshCount = ReadBElong f

fseek f BoneTableOffset#seek_set
struct BoneOffset (
BoneTOffset
)
Bone_Offset_array = #()
for i = 1 to BoneCount Do (
BoneTOffset = ReadBElong f + 0x18
append Bone_Offset_array (BoneOffset BoneTOffset:BoneTOffset)
)
print Bone_Offset_array
struct BoneData (
BoneID, BoneNameOffset, BoneName, BoneParentID
)
Bone_Data_array = #()
BoneID = -1
for k in Bone_Offset_array Do (
fseek f k.BoneTOffset#seek_set
BoneID += 1
BoneParentID = ReadBElong f
BoneNameOffset = ReadBElong f
BoneName = readstring f
append Bone_Data_array ( BoneData BoneID:BoneID BoneNameOffset:BoneNameOffset BoneName:BoneName BoneParentID:BoneParentID )
)F$?-\$vW&qiH
print Bone_Data_array

BNArr = #()

for i = 1 to BoneCount Do (
m11 = ReadBEfloat f; m12 = ReadBEfloat f; m13 = ReadBEfloat f; m14 = ReadBEfloat f
m21 = ReadBEfloat f; m22 = ReadBEfloat f; m23 = ReadBEfloat f; m24 = ReadBEfloat f
m31 = ReadBEfloat f; m32 = ReadBEfloat f; m33 = ReadBEfloat f; m34 = ReadBEfloat f
m41 = ReadBEfloat f; m42 = ReadBEfloat f; m43 = ReadBEfloat f; m44 = ReadBEfloat 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_Data_array[i].BoneName
                        newBone.width  = 0.01
                        newBone.height = 0.01
                        
                        pos = [m14,m24,m34]
                        pos = pos * tfm
                                          
                        newBone.pos.x = (-1)*pos.x
                        newBone.pos.y = (-1)*pos.y
                        newBone.pos.z = (-1)*pos.z
                                          
                        newBone.setBoneEnable false 0
                        newBone.pos.controller      = TCB_position ()
                        newBone.rotation.controller = TCB_rotation ()
                        if (Bone_Data_array[i].BoneParentID != -1) then
                                          newBone.parent = BNArr[Bone_Data_array[i].BoneParentID+1]
                        BNArr[i] = newBone
                                  )


fseek f 0x68#seek_set

for c = 1 to MeshCount Do (
Vert_array = #()    --define arrays for verts, normals, UV and Faces
Normal_array = #()
UV_array = #()
Face_array = #()
offsetstart = (ReadBElong f) + 0x18
tablestart = ftell f
        fseek f offsetstart#seek_set
Count1 = ReadBElong f
FaceCount = ReadBElong f        
Count3 = ReadBElong f        
VertCount = ReadBElong f        
VertSize = ReadBElong f
Count6 = ReadBElong f
Count7 = ReadBElong f
Count8 = ReadBElong f
Count9 = ReadBElong f
Count10 = ReadBElong f        
Count11 = ReadBElong f
FaceStart = ftell f
VerStart = (FaceCount * 2) + FaceStart


StartDirection = -1
f1 = (ReadBEword f) + 1
f2 = (ReadBEword f) + 1  
FaceDirection = StartDirection
Do (
f3 = (ReadBEword f)
if (f3==0xFFFF) then (
f1 = (ReadBEword f) + 1
f2 = (ReadBEword f) + 1
FaceDirection = StartDirection
) else (
f3 += 1
FaceDirection *= -1
if (f1!=f2)AND(f2!=f3)AND(f3!=f1) then (
if FaceDirection > 0 then append Face_array [f1,f2,f3]
else append Face_array [f1,f3,f2]
)
f1 = f2
f2 = f3
)
) while ((ftell f) != (VerStart + 2))
fseek f VerStart#seek_set
deleteitem Face_array Face_array.count
test = readshort f
if test != 0x0000 Do (
         fseek f -2 #seek_cur
)
for v = 1 to VertCount Do (
vx = ReadBEfloat f  --read xyz coordinates
vy = ReadBEfloat f
vz = ReadBEfloat f
fseek f 0x8 #seek_cur
nx = ReadBElong f    --read Normal ??
ny = ReadBElong f
nz = ReadBElong f
tu = ReadBEHalfFloat f   --read UV float value
tv = ReadBEHalfFloat f * -1
fseek f 0x8 #seek_cur

append Vert_array [vx,vy,vz] --save verts to Vert_array
append Normal_array [nx,ny,nz] --save normals to Normal_array
append UV_array [tu,tv,0]  --save UVs to UV_array
)
fseek f tablestart#seek_set
msh = mesh vertices:Vert_array faces:Face_array   --build mesh
msh.numTVerts = UV_array.count
buildTVFaces msh    
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]
)

I Get this but i jsut an unexpeced End-of-file when i try to run it in max
Thanked by:


Messages In This Thread
Sonic Model Ripping Thread - by Lugana Rysniq - 02-02-2011, 10:28 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 02-09-2011, 07:48 PM
RE: Sonic Model Ripping Thread - by MikeyLevi - 02-10-2011, 10:56 PM
RE: Sonic Model Ripping Thread - by Modemo - 02-21-2011, 02:55 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 02-21-2011, 03:32 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 02-21-2011, 04:58 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 02-22-2011, 01:57 AM
RE: Sonic Model Ripping Thread - by Azu - 02-22-2011, 04:41 AM
RE: Sonic Model Ripping Thread - by Shadowth117 - 02-22-2011, 12:25 PM
RE: Sonic Model Ripping Thread - by Azu - 02-22-2011, 02:02 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 02-23-2011, 02:42 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 02-24-2011, 12:19 AM
RE: Sonic Model Ripping Thread - by Shadowth117 - 02-24-2011, 01:25 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 02-24-2011, 02:49 AM
RE: Sonic Model Ripping Thread - by Shadowth117 - 02-24-2011, 02:16 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 02-24-2011, 08:10 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 02-25-2011, 02:45 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 02-25-2011, 04:17 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 02-25-2011, 06:01 PM
RE: Sonic Model Ripping Thread - by MikeyLevi - 02-26-2011, 02:31 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 02-26-2011, 03:06 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 02-27-2011, 04:00 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 05-29-2011, 06:06 AM
RE: Sonic Model Ripping Thread - by MikeyLevi - 05-29-2011, 09:36 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 05-30-2011, 02:41 AM
RE: Sonic Model Ripping Thread - by MikeyLevi - 06-01-2011, 08:45 PM
RE: Sonic Model Ripping Thread - by Maxpphire - 05-01-2011, 01:50 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 05-01-2011, 03:47 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 05-08-2011, 02:36 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 05-08-2011, 03:58 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 05-08-2011, 08:37 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 05-29-2011, 11:06 AM
RE: Sonic Model Ripping Thread - by KyroAtelerix - 06-02-2011, 08:05 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 06-06-2011, 12:48 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 06-02-2011, 11:20 PM
RE: Sonic Model Ripping Thread - by Crett - 06-06-2011, 05:46 PM
RE: Sonic Model Ripping Thread - by MikeyLevi - 06-12-2011, 05:07 PM
RE: Sonic Model Ripping Thread - by superfan91 - 06-15-2011, 12:19 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 06-24-2011, 01:48 AM
RE: Sonic Model Ripping Thread - by Shadowth117 - 06-24-2011, 04:58 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 06-24-2011, 01:03 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 06-24-2011, 07:37 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 06-25-2011, 10:06 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 06-26-2011, 02:50 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 06-27-2011, 02:46 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 06-26-2011, 01:41 PM
RE: Sonic Model Ripping Thread - by superfan91 - 06-27-2011, 07:36 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 06-27-2011, 07:57 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 06-28-2011, 12:30 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 06-28-2011, 01:48 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 07-01-2011, 12:09 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 07-01-2011, 06:14 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 07-01-2011, 06:45 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 07-01-2011, 09:39 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 06-30-2011, 09:46 PM
RE: Sonic Model Ripping Thread - by Azu - 06-30-2011, 10:24 PM
RE: Sonic Model Ripping Thread - by Tiberious - 07-01-2011, 03:15 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 07-01-2011, 10:34 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 07-02-2011, 12:30 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 07-03-2011, 05:35 PM
RE: Sonic Model Ripping Thread - by superfan91 - 07-08-2011, 03:52 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 07-09-2011, 05:51 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 07-04-2011, 05:05 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 07-09-2011, 07:29 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 07-11-2011, 12:49 AM
RE: Sonic Model Ripping Thread - by Shadowth117 - 07-11-2011, 10:29 AM
RE: Sonic Model Ripping Thread - by superfan91 - 07-29-2011, 12:54 AM
RE: Sonic Model Ripping Thread - by Friedslick6 - 07-29-2011, 01:37 PM
RE: Sonic Model Ripping Thread - by superfan91 - 07-30-2011, 07:26 PM
RE: Sonic Model Ripping Thread - by GrimmJeel - 07-30-2011, 09:53 PM
RE: Sonic Model Ripping Thread - by GrimmJeel - 07-29-2011, 02:08 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 07-30-2011, 09:52 PM
RE: Sonic Model Ripping Thread - by ManikDX - 07-31-2011, 08:07 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 08-01-2011, 02:25 PM
RE: Sonic Model Ripping Thread - by MaverickDVNT - 08-05-2011, 03:22 AM
RE: Sonic Model Ripping Thread - by Azu - 08-05-2011, 03:33 AM
RE: Sonic Model Ripping Thread - by Shadowth117 - 08-05-2011, 10:56 AM
RE: Sonic Model Ripping Thread - by Azu - 08-05-2011, 11:00 AM
RE: Sonic Model Ripping Thread - by Shadowth117 - 08-05-2011, 11:17 AM
RE: Sonic Model Ripping Thread - by ManikDX - 08-05-2011, 04:13 PM
RE: Sonic Model Ripping Thread - by tuxmask75 - 08-07-2011, 08:32 AM
RE: Sonic Model Ripping Thread - by ManikDX - 08-07-2011, 08:43 AM
RE: Sonic Model Ripping Thread - by ManikDX - 08-07-2011, 05:35 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-08-2011, 03:00 AM
RE: Sonic Model Ripping Thread - by ManikDX - 08-08-2011, 03:50 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-09-2011, 07:44 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-10-2011, 05:20 AM
RE: Sonic Model Ripping Thread - by Azu - 08-10-2011, 02:42 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-10-2011, 02:50 PM
RE: Sonic Model Ripping Thread - by ManikDX - 08-10-2011, 06:37 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-10-2011, 02:35 PM
RE: Sonic Model Ripping Thread - by Azu - 08-10-2011, 03:07 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-10-2011, 03:43 PM
RE: Sonic Model Ripping Thread - by MikeyLevi - 08-15-2011, 05:05 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-20-2011, 08:44 PM
RE: Sonic Model Ripping Thread - by Azu - 08-20-2011, 09:43 PM
RE: Sonic Model Ripping Thread - by ManikDX - 08-21-2011, 06:15 AM
RE: Sonic Model Ripping Thread - by ManikDX - 08-14-2011, 06:16 AM
RE: Sonic Model Ripping Thread - by Azu - 08-15-2011, 05:09 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-16-2011, 04:14 PM
RE: Sonic Model Ripping Thread - by ManikDX - 08-18-2011, 03:58 AM
RE: Sonic Model Ripping Thread - by superfan91 - 08-20-2011, 08:26 PM
RE: Sonic Model Ripping Thread - by MikeyLevi - 08-21-2011, 01:13 PM
RE: Sonic Model Ripping Thread - by Friedslick6 - 08-22-2011, 05:39 AM
RE: Sonic Model Ripping Thread - by Azu - 08-21-2011, 12:42 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-21-2011, 03:11 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-22-2011, 08:35 PM
RE: Sonic Model Ripping Thread - by MikeyLevi - 08-23-2011, 11:09 AM
RE: Sonic Model Ripping Thread - by Shadowth117 - 08-23-2011, 01:14 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 08-23-2011, 03:30 PM
RE: Sonic Model Ripping Thread - by Friedslick6 - 08-25-2011, 05:11 AM
RE: Sonic Model Ripping Thread - by MikeyLevi - 08-25-2011, 05:13 AM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-25-2011, 03:05 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-25-2011, 11:54 AM
RE: Sonic Model Ripping Thread - by MikeyLevi - 08-25-2011, 07:09 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-25-2011, 07:47 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 08-25-2011, 09:59 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-26-2011, 01:50 AM
RE: Sonic Model Ripping Thread - by MikeyLevi - 08-29-2011, 07:21 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 08-29-2011, 08:01 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-29-2011, 08:07 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 08-29-2011, 08:19 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-29-2011, 11:10 PM
RE: Sonic Model Ripping Thread - by MikeyLevi - 08-30-2011, 01:03 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 08-30-2011, 02:02 PM
RE: Sonic Model Ripping Thread - by Shadowth117 - 10-03-2011, 06:01 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 10-07-2011, 06:06 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 10-08-2011, 01:59 PM
RE: Sonic Model Ripping Thread - by Lugana Rysniq - 10-08-2011, 07:37 PM
RE: Sonic Model Ripping Thread - by Doronetty - 12-11-2011, 06:33 AM
RE: Sonic Model Ripping Thread - by Vipershark - 12-11-2011, 01:50 PM

Forum Jump: