User:1/mario script backup

clearlistener rollout dr2otr_ex "Dead Rising 2: OTR - Exporter" width:232 height:220 (	button btn1 ">> Import" pos:[9,7] width:80 height:32	button btn2 ">> Inject" pos:[9,71] width:80 height:32	checkbox chk1 "Make Backup" pos:[105,134] width:110 height:16 enabled:true checked:false	checkbox chk2 "Import Skin" pos:[104,62] width:110 height:16 checked:true	button btn3 "<< Export" pos:[9,39] width:80 height:32	button btn4 ">> Pack" pos:[9,135] width:80 height:32	button btn5 "<< Unpack" pos:[9,103] width:80 height:32	label lbl2 "" pos:[292,286] width:29 height:15	checkbox chk3 "" pos:[104,28] width:14 height:16	editText edt1 "MatID:" pos:[120,29] width:77 height:16	checkbox chk5 "Import Normals" pos:[104,80] width:110 height:16	progressBar pb1 "ProgressBar" pos:[10,172] width:213 height:21 color:red	button btn9 "Info" pos:[173,198] width:50 height:17	label lbl1 "v0.4c" pos:[139,199] width:33 height:16	label lbl6 "By: Mario_Kart64n" pos:[9,199] width:108 height:16	checkbox chk54 "MultumInParvo" pos:[104,116] width:110 height:16 enabled:false checkbox chk55 "Bone Names" pos:[104,98] width:110 height:16 enabled:false checked:false groupBox grp1 "Options" pos:[93,8] width:130 height:159 button btn20 "+" pos:[157,45] width:16 height:17 label lbl12 "NormMap" pos:[104,46] width:52 height:13 spinner spn2 "" pos:[174,45] width:34 height:16 range:[-5,5,1]

local mscale=39.3700787 local nmV=1 local nmR=false local nmG=false local nmS=false

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

fn readbig fstream =( startpos=ftell fstream unk01=readlong fstream #unsigned unk02=readlong fstream #unsigned fsize=readlong fstream #unsigned files=readlong fstream #unsigned unk04=readlong fstream #unsigned names_offset=readlong fstream #unsigned local infoArray=#;infoArray[files]=[0,0,0,0] for i = 1 to files do( NameOff=(readlong fstream #unsigned)+startpos unk05=readlong fstream #unsigned zsize=readlong fstream #unsigned size=readlong fstream #unsigned offset=(readlong fstream #unsigned)+startpos type=readlong fstream #unsigned -- 0x0004 = Info (Header Information) -- 0x0020 = Data (Geometry) -- 0x0100 = BIG (BIG Package File) -- if type!=0x0004 OR type!=0x0020 OR type!=0x0100 DO Print ("ERROR: Type: 0x"+((bit.intAsHex(ftell fstream))as string)) zip=readlong fstream #unsigned infoArray[i]=[type,NameOff,offset,size]);return infoArray)

fn readBIGXML mstream =(struct xmlTag (name,info,count) xmlInfo=(xmlTag name:# info:# count:#);while mstream.eos==false do( str=mstream.readLine as stringstream;if str!=undefined do(peek="" while peek!="<" AND eof str!=true do (peek=readChar str);xmlEnt="";xmlTag="";xmlDat="" while peek!=">" AND eof str!=true do (peek=readChar str;if peek!=">" do xmlTag+=peek) xmlEnt=(readDelimitedString (xmlTag as stringstream) " ");if xmlEnt=="entry" OR xmlEnt=="files" do( while peek!="<" AND eof str!=true do (peek=readChar str;if peek!="<" do xmlDat+=peek) subTag=xmlTag as stringstream;counter=0;while eof subTag!=true do(counter+=1;skipToString subTag " " subDat=readDelimitedString subTag "=";skipToString subTag "\"";subEnt=readDelimitedString subTag "\""	append xmlInfo.name subDat;append xmlInfo.info subEnt);append xmlInfo.count counter)));return xmlInfo)

fn writeDDSheader streamin texW texH texM texC = ( texP=0 writelong streamin 0x20534444 #unsigned -- File ID writelong streamin 0x7C #unsigned -- Header Size case of( -- dwFlags (texC=="DXT1"): (writelong streamin 0x00081007 #unsigned;texP=((texW*texH)/0x02)) (texC=="DXT3"): (writelong streamin 0x00081007 #unsigned;texP=(texW*texH)) (texC=="DXT5"): (writelong streamin 0x00081007 #unsigned;texP=(texW*texH)) (texC=="ATI1"): (writelong streamin 0x000A1007 #unsigned;texP=((texW*texH)/0x20)) (texC=="ATI2"): (writelong streamin 0x000A1007 #unsigned;texP=(texW*texH)) (texC=="P8"): (writelong streamin 0x000A1007 #unsigned;texP=((texW*texH)/0x02)) (texC=="ARGB16"): (writelong streamin 0x00081007 #unsigned;texP=(((texW*texH)/0x8)*0x10)) (texC=="ARGB32"): (writelong streamin 0x00081007 #unsigned;texP=(((texW*texH)/0x4)*0x10))) writelong streamin texH #unsigned -- Texture Width writelong streamin texW #unsigned -- Texture Height writelong streamin texP #unsigned -- Pitch (#of bytes in a single row across the texture) writelong streamin 0x00 #unsigned -- Image Depth? Not Used, for Image Volume writelong streamin texM #unsigned -- Texture MIP Count for i = 1 to 11 do writelong streamin 0x00 #unsigned -- Reserved Space writelong streamin 0x20 #unsigned -- Size of PIXEL_FORMAT info, always 32bytes; case of( (texC=="DXT1"): (writelong streamin 0x04;writelong streamin 0x31545844 #unsigned writelong streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writelong streamin 0x00001000 #unsigned) (texC=="DXT3"): (writelong streamin 0x04;writelong streamin 0x33545844 #unsigned writelong streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writelong streamin 0x00001000 #unsigned) (texC=="DXT5"): (writelong streamin 0x04;writelong streamin 0x35545844 #unsigned writelong streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writelong streamin 0x00001000 #unsigned) (texC=="ATI1"): (writelong streamin 0x04;writelong streamin 0x31495441 #unsigned writelong streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writelong streamin 0x00401008 #unsigned) (texC=="ATI2"): (writelong streamin 0x04;writelong streamin 0x32495441 #unsigned writelong streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writelong streamin 0x00401008 #unsigned) (texC=="P8"): (writelong streamin 0x20;writelong streamin 0x20203850 #unsigned writelong streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writelong streamin 0x00401008 #unsigned) (texC=="ARGB16"): (writelong streamin 0x41;writelong streamin 0x00000000 #unsigned writelong streamin 0x10;writebyte streamin 0x00;writebyte streamin 0x0F;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0xF0;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x0F;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0xF0;writebyte streamin 0x00 writebyte streamin 0x00;writelong streamin 0x00001000 #unsigned) (texC=="ARGB32"): (writelong streamin 0x41;writelong streamin 0x00000000 #unsigned writelong streamin 0x20;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0xFF writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0xFF;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0xFF;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00;writebyte streamin 0x00 writebyte streamin 0xFF;writelong streamin 0x00001000 #unsigned)) for i = 1 to 4 do writelong streamin 0x00 #unsigned) -- Reserved Space for CAPS fn addshort ptr c =(((ptr[(c+0)]*0x0001)+(ptr[(c+1)]*0x0100))) fn addlong ptr c =(((ptr[(c+0)]*0x00000001)+(ptr[(c+1)]*0x00000100)+ \ (ptr[(c+2)]*0x00010000)+(ptr[(c+3)]*0x01000000)))

on spn2 changed theValue do nmV=theValue on btn20 pressed do( rollout normopt "Tangent Options" width:160 height:110 ( groupBox grp4 "Normal Map Direction" pos:[6,2] width:148 height:80 checkbox chk19 "Flip Red (X)" pos:[27,21] width:100 height:16 checked:nmR button btn21 "OK" pos:[46,85] width:65 height:21 checkbox chk20 "Flip Green (Y)" pos:[27,39] width:100 height:16 checked:nmG checkbox chk21 "Swap Red n Green" pos:[27,57] width:110 height:16 checked:nmS

on chk19 changed theState do nmR=theState on chk20 changed theState do nmG=theState on chk21 changed theState do nmS=theState on btn21 pressed do DestroyDialog normopt

) CreateDialog normopt style:#(#style_border) )

on btn1 pressed do(	-- Import fsource = GetOpenFileName \ caption:"[PC] Dead Rising 2: OTR - Model Imporer" \ types: "Big files (*.big)|*.BIG|" if (fsource!=undefined) AND ((doesFileExist fsource)==true) then( f = fopen fsource "rb" -- from chrrox's bms and max script

skinON=chk2.checked normON=chk5.checked

-- OBJ=$*;DELETE OBJ

undo off(with redraw off ( local bone_count=0

BNArr=#

bigInfo=readbig f -- print bigInfo fseek f bigInfo[1][2] #seek_set -- names_offsets=#;names_offsets[files]="" names=#;names[bigInfo.count]="" for i = 1 to bigInfo.count do( -- names_offsets[i]=ftell f names[i]=readstring f)

find=findItem names "SceneHeader" if find!=0 then( fseek f bigInfo[find][3] #seek_set sh_ukn01=readlong f #unsigned sh_ukn02=readlong f #unsigned sh_ukn03=readlong f #unsigned msh_count=readlong f #unsigned mat_count=readlong f #unsigned

fseek f bigInfo[(findItem names "SceneDescription")][3] #seek_set mshNames=#;mshNames[msh_count]="" for i = 1 to msh_count do(mshNames[i]=ReadFixedString f 36) fseek f bigInfo[(findItem names "MatArray")][3] #seek_set texInfo=#;texInfo[mat_count]=[0,0] texIndex=#;texIndex[mat_count]=0 for i = 1 to mat_count do( mt_ukn01=readlong f #unsigned -- index mt_ukn02=readlong f #unsigned mt_ukn03=readlong f #unsigned -- count mt_ukn04=readlong f #unsigned -- offset mt_ukn05=readlong f #unsigned mt_ukn06=readlong f #unsigned mt_ukn07=readlong f #unsigned mt_ukn08=readlong f #unsigned mt_ukn09=readlong f #unsigned texInfo[i]=[mt_ukn03,mt_ukn04] texIndex[i]=mt_ukn01 )

fseek f bigInfo[(findItem names "MatTextureInfoArray")][3] #seek_set texNames=# mm = MultiMaterial mm.numsubs=mat_count meditMaterials[1]=mm for i = 1 to mat_count do( texStr=# -- fseek f (bigInfo[(findItem names "MatTextureInfoArray")][3]+texInfo[i][2]) #seek_set	for x = 1 to texInfo[i][1] do( mt_ukn01=readlong f #unsigned texName=(ReadFixedString f 52) mt_ukn02=readlong f #unsigned mt_ukn03=readlong f #unsigned mt_ukn04=readlong f #unsigned mt_ukn05=readlong f #unsigned mt_ukn06=readlong f #unsigned -- flag mt_ukn07=readlong f #unsigned mt_ukn08=readlong f #unsigned mt_ukn09=readlong f #unsigned mt_ukn10=readlong f #unsigned mt_ukn11=readlong f #unsigned mt_ukn12=readlong f #unsigned if mt_ukn06==1 do append texStr texName ) if texStr.count==0 do append texStr "" append texNames texStr ) print texNames -- 	print (texNames[x][1]+".dds")

for x = 1 to mat_count do(	texPath=((getFilenamePath fsource)+"\\"+texNames[x][1]+".dds")	mm.materialList[x].diffuseMap = Bitmaptexture fileName:texPath --(texNames[x][1]+".dds")) mm.materialList[x].opacityMap = Bitmaptexture fileName:texPath mm.materialList[x].diffuseMap.alphaSource = 2 mm.materialList[x].opacityMap.monoOutput = 1 mm.materialList[x].opacityMap.preMultAlpha = off mm.materialList[x].opacityMap.alphaSource = 0

) fseek f bigInfo[(findItem names "persistent.big")][3] #seek_set mshInfo=readbig f fseek f mshInfo[1][2] #seek_set -- names_offsets2=#;names_offsets2[mshInfo.count]="" names2=#;names2[mshInfo.count]="" for i = 1 to mshInfo.count do( -- names_offsets2[i]=ftell f names2[i]=readstring f)

mshHeader=#;mshHeader[msh_count]=[0,0,0,0];(for i = 1 to msh_count do (mshHeader[i]=[0,0,0,0])) drawInfo=#;drawInfo[msh_count]=0;(for i = 1 to msh_count do (drawInfo[i]=0)) matIndex=#;matIndex[msh_count]=0;(for i = 1 to msh_count do (matIndex[i]=0))

struct renderStrip (matID,uknA,uknB,uknC,uknD,uknE,type) geoInfo = (renderStrip matID:# uknA:# uknB:# uknC:# uknD:# uknE:# type:#);a=msh_count geoInfo.matID[a]=0;geoInfo.uknA[a]=0;geoInfo.uknB[a]=0;geoInfo.uknC[a]=0;geoInfo.uknD[a]=0;geoInfo.uknD[a]=0;geoInfo.type[a]=0

for i = 1 to names2.count do( fullName=names2[i] mshName=fullName as stringstream

baseName=readDelimitedString mshName " " compName=readDelimitedString mshName " " -- numName=readDelimitedString mshName " " find=findItem mshNames baseName

fseek f mshInfo[i][3] #seek_set case of (

(fullName=="_BOUNDINGBOX_"): ( bMax=[(readfloat f*mscale),(readfloat f*mscale),(readfloat f*mscale)] bMin=[(readfloat f*mscale),(readfloat f*mscale),(readfloat f*mscale)] -- Dummy pos:[0,0,((bMin.y-bMax.y)/2)] boxsize:[(bMin.x-bMax.x),(bMin.z-bMax.z),(bMin.y-bMax.y)] isSelected:on ) (fullName=="_ANIMLIB_SKELETON_"): ( if skinON==true do( BNArr=# struct Bone_data (	BoneID,BoneParent,tfm ) BoneDataArray = # file_version=readlong f #unsigned bone_count=readshort f #unsigned bone_flag=readshort f #unsigned

boneNames=#;boneNames[bone_count]="" bonePos=#;bonePos[bone_count]=[0,0,0] boneRot=#;boneRot[bone_count]=[0,0,0] boneIdx=#;boneIdx[bone_count]=0 boneChild=#;boneChild[bone_count]=0 boneArray=# for i = 1 to bone_count do( p1=-readfloat f p2=-readfloat f p3=readfloat f p4=readfloat f

p5=readfloat f*mscale p6=readfloat f*mscale p7=-readfloat f*mscale p8=readfloat f

pA=readshort f #unsigned pB=readshort f #unsigned -- String Offset

-- boneRot[i]=[p1,p3,p2,p4] boneRot[i]=[p1,p3,p2,p4] bonePos[i]=[p5,p7,p6] -- $.transform.RotationPart

) for i = 1 to bone_count do( boneIdx[i]=readbyte f +1

if boneIdx[i]!=0 do boneChild[(boneIdx[i])]=i

)-- #unsigned

if bone_flag==1 then ( for i = 1 to bone_count do( boneNames[i]=readstring f ) )else( presetbnames=# case of( (bone_count==30): ( presetbnames=#("dummy01", "arrow", "root", "pelvis", "l_thigh", "l_calf", "l_foot", "r_thigh", "r_calf", "r_foot", "transroot", "spine", "spine1", "spine2", "neck", "head", "jaw", "l_clavicle", "l_upperarm", "l_uparm_twist", "l_forearm", "l_farm_twist", "l_hand", "r_clavicle", "r_upperarm", "r_uparm_twist", "r_forearm", "r_farm_twist", "r_hand", "r_hand_prop") ) (bone_count==98): ( presetbnames=#("ROOT", "arrow", "root", "transroot", "spine", "spine1", "pelvis", "l_thigh", "r_thigh", "l_calf", "r_calf", "l_foot", "r_foot", "l_toe", "r_toe", "spine2", "jiggle", "l_clavicle", "r_clavicle", "r_upperarm", "r_uparm_twist", "l_upperarm", "l_uparm_twist", "neck", "head", "l_eyebrowcorner", "l_eyelidbottom", "l_lipcorner", "l_toplipmid", "l_nostril", "l_eyelidmid", "l_toplipmid2", "l_eyebrowtop", "l_cheekupper", "r_eyebrowtop", "r_eyebrowcorner", "r_eyelidmid", "leye", "reye", "r_forearm", "l_forearm", "r_farm_twist", "l_farm_twist", "r_hand", "l_hand", "root_prop", "l_hip_prop", "r_hip_prop", "jaw", "r_lowerlipcorner", "l_lowerlipmid", "l_lowerlipcorner", "r_eyelidbottom", "r_nostril", "r_cheekupper", "r_toplipmid", "r_toplipmid2", "r_lipcorner", "r_lowerlipmid", "tongue", "ponytailbase", "ponytailmid", "l_thumb1", "l_thumb2", "l_thumb3", "l_index1", "l_index2", "l_index3", "l_middle1", "l_middle2", "l_middle3", "l_ring1", "l_ring2", "l_ring3", "l_pinky1", "l_pinky2", "l_pinky3", "r_thumb1", "r_thumb2", "r_thumb3", "r_index1", "r_index2", "r_index3", "r_middle1", "r_middle2", "r_middle3", "r_ring1", "r_ring2", "r_ring3", "r_pinky1", "r_pinky2", "r_pinky3", "r_hand_prop", "l_hand_prop", "prop_rshoulder", "prop_back", "l_toe_nub", "r_toe_nub")	) ) if presetbnames.count!=0 then( for i = 1 to bone_count do( num="" if i < 10 do num+="0" if i < 100 do num+="0" -- if i < 1000 do num+="0" boneNames[i]=(num+(i as string)+" "+presetbnames[i])

) )else( for i = 1 to bone_count do( num="" if i < 10 do num+="0" if i < 100 do num+="0" -- if i < 1000 do num+="0" boneNames[i]=("Bone"+num+(i as string))

)

)

)

-- for i = 1 to bone_count do( -- pos=bonePos[i] -- idx=boneIdx[i]+1 -- -- if boneIdx[i]!=0xFF do pos=bonePos[idx]*bonePos[i]

-- obj=Dummy pos:pos name:boneNames[i] boxsize:[.01,.01,.01] isSelected:on -- append boneArray obj -- obj.parent=boneArray[idx]

-- )

-- for i = 1 to bone_count do( -- BoneParent=boneIdx[i]+1 -- tfm = (quat (boneRot[i][1]) (boneRot[i][2]) (boneRot[i][3]) (boneRot[i][4])) as matrix3 -- tfm.row4 = [(bonePos[i][1]),(bonePos[i][2]),(bonePos[i][3])] -- arr = #(i,BoneParent,tfm) -- append BoneDataArray arr

-- )

for a = 1 to bone_count Do ( -- print BoneDataArray[a][1] -- print BoneDataArray[a][2] -- print BoneDataArray[a][3]

tfm = (quat (boneRot[i][1]) (boneRot[i][2]) (boneRot[i][3]) (boneRot[i][4])) as matrix3 tfm.row4 = [(bonePos[i][1]),(bonePos[i][2]),(bonePos[i][3])]

newBone = bonesys.createbone tfm.row4 (bonePos[(boneChild[i])]*mscale) -(normalize tfm.row3) newBone.name = boneNames[a] newBone.width = 0.02*mscale newBone.height = 0.02*mscale -- 			newBone.transform = tfm -- 			newBone.setBoneEnable false 0 -- 			newBone.wirecolor = yellow -- 			newbone.showlinks = true -- 			newBone.pos.controller     = TCB_position -- 			newBone.rotation.controller = TCB_rotation append BNArr newBone ) for a = 1 to bone_count Do ( tfm = (quat (boneRot[a][1]) (boneRot[a][2]) (boneRot[a][3]) (boneRot[a][4])) as matrix3 tfm.row4 = [(bonePos[a][1]),(bonePos[a][2]),(bonePos[a][3])]

if ((boneIdx[a]) != 0) then (

tfm = (tfm * BNArr[(boneIdx[a])].transform)

BNArr[a].parent = BNArr[(boneIdx[a])]

) BNArr[a].transform = tfm

) for a = 1 to bone_count Do ( BNArr[a].length=0.0254*mscale -- BNArr[a].realignBoneToChild BNArr[a].resetBoneStretch )

)

) (compName=="CommandBuffer"): ( while (ftell f)!=(mshInfo[i][3]+mshInfo[i][4]) do(

if (readbyte f)==11 do(	if (readbyte f)==0 do( if (readbyte f)==0 do(			if (readbyte f)==0 do( if (readbyte f)==8 do(		drawInfo[find]=readbyte f		) )		)		)	) ) )

(compName=="D3DVertexDesc"): (

)

(compName=="desc"): (

)

(compName=="RenderStrip"): ( geoInfo.matID[find]=readlong f #unsigned+1 geoInfo.uknA[find]=readlong f #unsigned geoInfo.uknB[find]=readlong f #unsigned geoInfo.uknC[find]=readlong f #unsigned --+1 -- Bone ID geoInfo.uknD[find]=readlong f #unsigned -- Bone Count geoInfo.uknE[find]=readlong f #unsigned geoInfo.type[find]=readlong f #unsigned;print geoInfo.type[find] matIndex[find]=(findItem texIndex geoInfo.matID[find]) )

(compName=="IBHeader"): ( seekName=ReadFixedString f 36 as stringstream strName=(readDelimitedString seekName " ") strIndex=(readDelimitedString seekName " ") if strIndex=="" do strIndex="0" seekName=(strName+" Indices "+strIndex) ukn00=readlong f -- always -1 ? face_count=readlong f #unsigned ukn01=readlong f #unsigned ukn02=readlong f #unsigned mshHeader[find][2]=(findItem names seekName) mshHeader[find][4]=face_count )

(compName=="VBHeader"): ( seekName=ReadFixedString f 36 as stringstream strName=(readDelimitedString seekName " ") strIndex=(readDelimitedString seekName " ") if strIndex=="" do strIndex="0" seekName=(strName+" Vertices "+strIndex) ukn00=readlong f -- always -1 ? vert_count=readlong f #unsigned ukn01=readlong f #unsigned ukn02=readlong f #unsigned mshHeader[find][1]=(findItem names seekName) mshHeader[find][3]=vert_count )

(compName=="VDHeader"): (

)

)

) -- print mshHeader -- print drawInfo -- print names -- msh_count=0 for i = 1 to msh_count do( pb1.value = 100.*i/msh_count vertArray=#;vertArray[(mshHeader[i][3])]=[0,0,0] uvwArray=#;uvwArray[(mshHeader[i][3])]=[0,0,0] normArray=#;normArray[(mshHeader[i][3])]=[0,0,0] faceArray=# boneIDArray=#;boneIDArray[(mshHeader[i][3])]=[0,0,0,0] weightArray=#;weightArray[(mshHeader[i][3])]=[0,0,0,0]

fseek f bigInfo[(mshHeader[i][1])][3] #seek_set case of ( (geoInfo.type[i]==27): ( -- hair, or other objects using opacity for x = 1 to mshHeader[i][3] do( vx = readfloat f * mscale vy = readfloat f * mscale vz = readfloat f * mscale tu = readfloat f tv = (readfloat f * -1) + 1 w1 = (readbyte f #unsigned as float)/255.0 w2 = (readbyte f #unsigned as float)/255.0 w3 = (readbyte f #unsigned as float)/255.0 w4 = (readbyte f #unsigned as float)/255.0 -- if mshNames[i]=="geo_headShape" do ( -- 	-- 	print [w1,w2,w3,w4] -- 	Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string)) -- 	-- 	) b1 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) b2 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) b3 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) b4 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) -- if (b1+b2+b3+b4)==0 do b1=1 -- if b1!=0 do b1+=geoInfo.uknC[i] -- if b2!=0 do b2+=geoInfo.uknC[i] -- if b3!=0 do b3+=geoInfo.uknC[i] -- if b4!=0 do b4+=geoInfo.uknC[i]

unk1 = readfloat f unk1 = readfloat f unk1 = readfloat f unk1 = readfloat f nx = readfloat f ny = readfloat f nz = readfloat f

w1+=(1-(w1+w2+w3+w4))

boneIDArray[x]=[b1,b2,b3,b4] weightArray[x]=[w1,w2,w3,w4]

vertArray[x]=[vx,-vz,vy] uvwArray[x]=[tu,tv,0] normArray[x]=[nx,-nz,ny] )) (geoInfo.type[i]==29): ( -- common skinned mesh for x = 1 to mshHeader[i][3] do( vx = readfloat f * mscale vy = readfloat f * mscale vz = readfloat f * mscale tu = readfloat f tv = (readfloat f * -1) + 1 w1 = (readbyte f #unsigned as float)/255.0 w2 = (readbyte f #unsigned as float)/255.0 w3 = (readbyte f #unsigned as float)/255.0 w4 = (readbyte f #unsigned as float)/255.0 -- if mshNames[i]=="geo_headShape" do ( -- 	-- 	print [w1,w2,w3,w4] -- 	Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string)) -- 	-- 	) b1 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) b2 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) b3 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) b4 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) -- if (b1+b2+b3+b4)==0 do b1=1 -- if b1!=0 do b1+=geoInfo.uknC[i] -- if b2!=0 do b2+=geoInfo.uknC[i] -- if b3!=0 do b3+=geoInfo.uknC[i] -- if b4!=0 do b4+=geoInfo.uknC[i]

unk1 = readfloat f unk1 = readfloat f unk1 = readfloat f unk1 = readfloat f nx = readfloat f ny = readfloat f nz = readfloat f

w1+=(1-(w1+w2+w3+w4))

boneIDArray[x]=[b1,b2,b3,b4] weightArray[x]=[w1,w2,w3,w4]

vertArray[x]=[vx,-vz,vy] uvwArray[x]=[tu,tv,0] normArray[x]=[nx,-nz,ny] )) (geoInfo.type[i]==32): ( -- eyes, mouth, accessories, shoes, clothes? for x = 1 to mshHeader[i][3] do( vx = readfloat f * mscale vy = readfloat f * mscale vz = readfloat f * mscale tu = readfloat f tv = (readfloat f * -1) + 1 w1 = (readbyte f #unsigned as float)/255.0 w2 = (readbyte f #unsigned as float)/255.0 w3 = (readbyte f #unsigned as float)/255.0 w4 = (readbyte f #unsigned as float)/255.0 -- if mshNames[i]=="geo_headShape" do ( -- 	-- 	print [w1,w2,w3,w4] -- 	Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string)) -- 	-- 	) b1 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) b2 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) b3 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) b4 = (((readbyte f #unsigned/3)+1)+geoInfo.uknC[i]) -- if (b1+b2+b3+b4)==0 do b1=1 -- if b1!=0 do b1+=geoInfo.uknC[i] -- if b2!=0 do b2+=geoInfo.uknC[i] -- if b3!=0 do b3+=geoInfo.uknC[i] -- if b4!=0 do b4+=geoInfo.uknC[i]

unk1 = readfloat f unk1 = readfloat f unk1 = readfloat f unk1 = readfloat f nx = readfloat f ny = readfloat f nz = readfloat f

w1+=(1-(w1+w2+w3+w4))

boneIDArray[x]=[b1,b2,b3,b4] weightArray[x]=[w1,w2,w3,w4]

vertArray[x]=[vx,-vz,vy] uvwArray[x]=[tu,tv,0] normArray[x]=[nx,-nz,ny] )) (geoInfo.type[i]==30): ( for x = 1 to mshHeader[i][3] do( vx = readfloat f * mscale vy = readfloat f * mscale vz = readfloat f * mscale ukn = readfloat f -- always -1? ukn = readfloat f -- always -1? boneIDArray[x]=[1,0,0,0] weightArray[x]=[1,0,0,0] vertArray[x]=[vx,-vz,vy] uvwArray[x]=[0,0,0] normArray[x]=[0,0,0] )

)

(geoInfo.type[i]==14): ( for x = 1 to mshHeader[i][3] do( vx = readfloat f * mscale vy = readfloat f * mscale vz = readfloat f * mscale ukn = readfloat f -- always -1? boneIDArray[x]=1 weightArray[x]=1 vertArray[x]=[vx,-vz,vy] uvwArray[x]=[0,0,0] normArray[x]=[0,0,0] )

)

)

fseek f bigInfo[(mshHeader[i][2])][3] #seek_set if drawInfo[i]==4 then( StartDirection = -1 fa =readshort f #unsigned + 1 fb =readshort f #unsigned + 1 FaceDirection = StartDirection IndexCounter = 2 Do ( fc =readshort f #unsigned IndexCounter += 1 if (fc==0xFFFF) then ( fa =readshort f #unsigned + 1 fb =readshort f #unsigned + 1 FaceDirection = StartDirection IndexCounter += 2 ) else ( fc += 1 FaceDirection *= -1 if (fa!=fb)AND(fb!=fc)AND(fc!=fa) then ( if FaceDirection > 0 then append faceArray [fa,fb,fc] else append faceArray [fa,fc,fb] ) fa = fb fb = fc ) ) while IndexCounter !=mshHeader[i][4] )else( for x = 1 to (mshHeader[i][4]/3) do( fa=readshort f #unsigned+1 fb=readshort f #unsigned+1 fc=readshort f #unsigned+1 append faceArray[fa,fb,fc] ) )

-- if geoInfo.type[i]==27 do(

msh = mesh vertices:vertArray faces:faceArray msh.numTVerts = vertArray.count buildTVFaces msh -- msh.name = ((i as string)+" "+mshNames[i]) msh.name = mshNames[i] msh.material=mm.materialList[(matIndex[i])]

setUserProp msh "MatID" (geoInfo.matID[i]-1)

for j = 1 to vertArray.count do setTVert msh j uvwArray[j] if geoInfo.type[i]==29 do for j = 1 to vertArray.count do setNormal msh j normArray[j] -- Normals Don't Stick, lost when modifers are added for j = 1 to faceArray.count do setTVFace msh j faceArray[j]

if skinON==true do(

select msh max modify mode skinMod = skin addModifier msh skinMod for x = 1 to BNArr.count do ( if x!=BNArr.count then skinOps.addbone skinMod (BNArr[x]) 0 else skinOps.addbone skinMod (BNArr[x]) 1 ) modPanel.setCurrentObject skinMod for x = 1 to weightArray.count do( bi = # --bone index array wv = # --weight value array for j = 1 to 4 do	( boneid = boneIDArray[x][j] weight = weightArray[x][j] -- bone check, enable to import bad bone ids if boneid>=bone_count do ( -- print "bad" boneid=1	)

if weight!=0 do( append bi boneid append wv weight	) )

skinOps.ReplaceVertexWeights skinMod x bi wv ) ) --enable skin loop

if normON==true do( select msh max modify mode normMod = Edit_Normals addModifier msh normMod normMod.displayLength = 0 my_verts = #{1..(normMod.GetNumNormals node:msh)} normMod.SetSelection my_verts node:msh normMod.Break for n = 1 to (normMod.GetNumFaces node:msh) do( vertID=getFace msh n for c = 1 to 3 do( normID=normMod.GetNormalID n c node:msh normMod.EditNormalsMod.SetNormal normID normArray[(vertID[c])] node:msh normMod.SetNormal normID normArray[(vertID[c])] node:msh normMod.EditNormalsMod.MakeExplicit )) subobjectLevel = 0 )

-- addModifier msh2 normMod

) pb1.value = 0

PRINT "DONE!!!!" Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string)) fclose g fclose f )else(Print "No Scene Data")))) else (Print "Aborted.") ) --end import

on btn2 pressed do(

obj=selection if obj.count!=0 then( -- fsource="M:\\Dead.Rising.2.Off.The.Record-KaOs\\data\\models\\Errors\\srv_madison\\srv_madison (MOD).big"	fsource = GetOpenFileName \ caption:"Select a BIG File to Inject to" \ types: "Big files (*.big)|*.BIG|"

if (fsource!=undefined) AND ((doesFileExist fsource)==true) then( if chk1.checked==true do( num=1 newfile=(fsource+".bak"+(num as string)) while ((doesFileExist newfile)!=false) do( num+=1 newfile=(fsource+".bak"+(num as string)) ) copyFile fsource newfile )

f = fopen fsource "r+"

undo off(with redraw off (

bigInfo=readbig f

fseek f bigInfo[1][2] #seek_set names=#;names[bigInfo.count]="" namesD=#;namesD[bigInfo.count]="" namesA=#;namesA[bigInfo.count]="" for i = 1 to bigInfo.count do( names[i]=readstring f baseName=names[i] as stringstream namesD[i]=readDelimitedString baseName " " namesA[i]=readDelimitedString baseName " " )

find=findItem names "SceneHeader" if find!=0 then( fseek f (bigInfo[find][3]+12) #seek_set msh_count=readlong f #unsigned

fseek f bigInfo[(findItem names "SceneDescription")][3] #seek_set mshNames=#;mshNames[msh_count]="" for i = 1 to msh_count do(mshNames[i]=ReadFixedString f 36)

for i = 1 to obj.count do( vidx=0 fidx=0 for x = 1 to 2 do( find=findItem namesD obj[i].name case of( (namesA[find]=="Vertices"): (vidx=find) (namesA[find]=="Indices"): (fidx=find) ) namesD[find]="" ) if vidx!=0 AND fidx!=0 then( tmesh = snapshotAsMesh obj[i] num_verts = tmesh.numverts num_faces = tmesh.numfaces if (bigInfo[vidx][4]/56)==num_verts then( fseek f bigInfo[vidx][3] #seek_set for x = 1 to num_verts do( vert = getVert tmesh x tvert = getTVert tmesh x -- norm = getNormal tmesh x writefloat f (vert.x/mscale) writefloat f (vert.z/mscale) writefloat f (vert.y/-mscale) writefloat f tvert.x writefloat f ((tvert.y * -1) +1) -- fseek f 1 #seek_cur -- w1 -- fseek f 1 #seek_cur -- w2 -- fseek f 1 #seek_cur -- w3 -- fseek f 1 #seek_cur -- w4 -- fseek f 1 #seek_cur -- b1 -- fseek f 1 #seek_cur -- b2 -- fseek f 1 #seek_cur -- b3 -- fseek f 1 #seek_cur -- b4 -- fseek f 4 #seek_cur -- unknown? -- fseek f 4 #seek_cur -- unknown? -- fseek f 4 #seek_cur -- unknown? -- fseek f 4 #seek_cur -- unknown? -- writefloat f norm.x -- writefloat f norm.z -- writefloat f norm.y fseek f 36 #seek_cur -- skips the rest ))else( faceArray=# fseek f bigInfo[fidx][3] #seek_set if ((bigInfo[fidx][4]/2)/3)==num_faces then( for x = 1 to num_faces do( fa=readshort f #unsigned+1 fb=readshort f #unsigned+1 fc=readshort f #unsigned+1 append faceArray[fa,fb,fc]) )else(StartDirection = -1 fa =readshort f #unsigned + 1 fb =readshort f #unsigned + 1 FaceDirection = StartDirection IndexCounter = 2;Do ( fc =readshort f #unsigned IndexCounter += 1 if (fc==0xFFFF) then ( fa =readshort f #unsigned + 1 fb =readshort f #unsigned + 1 FaceDirection = StartDirection;IndexCounter += 2 ) else (fc += 1;FaceDirection *= -1 if (fa!=fb)AND(fb!=fc)AND(fc!=fa) then ( if FaceDirection > 0 then append faceArray [fa,fb,fc] else (append faceArray [fa,fc,fb]));fa = fb;fb = fc ))while IndexCounter !=(bigInfo[fidx][4]/2) if num_faces!=faceArray.count do (faceArray=#))

if faceArray.count!=0 then( vertArray=#;vertArray[(bigInfo[vidx][4]/56)]=[0,0,0];for x = 1 to (bigInfo[vidx][4]/56) do (vertArray=[0,0,0]) uvwArray=#;uvwArray[(bigInfo[vidx][4]/56)]=[0,0,0];for x = 1 to (bigInfo[vidx][4]/56) do (uvwArray=[0,0,0]) -- normArray=#;normArray[(bigInfo[vidx][4]/56)]=[0,0,0];for x = 1 to (bigInfo[vidx][4]/56) do (normArray=[0,0,0]) for y = 1 to faceArray.count do( face=faceArray[y] for x = 1 to 3 do( vertArray[(face[x])]=getVert tmesh face[x] uvwArray[(face[x])]=getTVert tmesh face[x]) -- normArray[(face[x])]=getTVert tmesh face[x]) )

for x = 1 to (bigInfo[vidx][4]/56) do( vert = vertArray[x] tvert = uvwArray[x] -- norm = normArray[x] writefloat f (vert.x/mscale) writefloat f (vert.z/mscale) writefloat f (vert.y/-mscale) writefloat f tvert.x writefloat f ((tvert.y * -1) +1) -- fseek f 1 #seek_cur -- w1 -- fseek f 1 #seek_cur -- w2 -- fseek f 1 #seek_cur -- w3 -- fseek f 1 #seek_cur -- w4 -- fseek f 1 #seek_cur -- b1 -- fseek f 1 #seek_cur -- b2 -- fseek f 1 #seek_cur -- b3 -- fseek f 1 #seek_cur -- b4 -- fseek f 4 #seek_cur -- unknown? -- fseek f 4 #seek_cur -- unknown? -- fseek f 4 #seek_cur -- unknown? -- fseek f 4 #seek_cur -- unknown? -- writefloat f norm.x -- writefloat f norm.z -- writefloat f norm.y fseek f 36 #seek_cur -- skips the rest ))else(errors+=(obj[i].name+"tttt\n")));delete tmesh)else(errors+=(obj[i].name+"\n"))) fflush f

)else(Print "No Scene Data")))

fclose f ) else (Print "Aborted."))else(MessageBox "Nothing Selected?")

) --end inject

on btn3 pressed do( -- export

-- skinON=chk2.checked matON=chk3.checked matID=edt1.text as integer -- OBJ=$*;DELETE OBJ

if selection.count==1 then( fsource = GetOpenFileName \ caption:"[PC] Dead Rising 2:OTR - \"persistent.big\" Patcher \\ Model Exporter" \ types: "Big files (*.big)|*.BIG|" -- if chk1.checked==true do( -- num=1 -- newfile=(fsource+".bak"+(num as string)) -- while ((doesFileExist newfile)!=false) do( -- num+=1 -- newfile=(fsource+".bak"+(num as string)) -- ) -- copyFile fsource newfile -- ) if (fsource!=undefined) AND ((doesFileExist fsource)==true) then( f = fopen fsource "r+" -- fext= 		getFilenameType fsource fpath= 		getFilenamePath fsource -- fname= 	getFilenameFile fsource -- fsize=         getFileSize fsource perBIG=readbig f fseek f perBIG[1][2] #seek_set names=#;names[perBIG.count]="" seekArray=# for i = 1 to perBIG.count do(names[i]=readstring f) for i = 1 to names.count do( fullName=names[i] as stringstream baseName=(readDelimitedString fullName " ") compName=(readDelimitedString fullName" ")

if baseName==selection[1].name do( classesArr = #("RenderStrip","VBHeader","IBHeader","CommandBuffer") find=findItem classesArr compName;if find!=0 do append seekArray i))

if seekArray.count==4 then(

tmesh = selection[1] num_verts = tmesh.numverts num_tverts = tmesh.numtverts num_faces = tmesh.numfaces skinMod=undefined bone_count=0 for i = 1 to tmesh.modifiers.count do ( -- Get Skin Data if classOf tmesh.modifiers[i]==Skin do ( skinMod=tmesh.modifiers[i]))

struct bone_data(name,position,parent,child) struct mesh_data(faces,vertices) struct mesh_data(name,matname,faces,vertices,matinfo) struct vertex_data(position,normal,tangent,colour,texture1,texture2,texture3,boneids,weights) struct material_data(diffmap,dirtmap,specmap,normmap,bumpmap1,bumpmap2,maskmap,envmap) meshBuffer = (mesh_data faces:# vertices:#) matBuffer = (material_data diffmap:# dirtmap:# specmap:# normmap:# bumpmap1:# bumpmap2:# maskmap:# envmap:#) meshBuffer = (mesh_data name:# matname:# faces:# vertices:# matinfo:#) vertBuffer = (vertex_data position:# normal:# tangent:# colour:# texture1:# texture2:# texture3:# boneids:# weights:#) boneBuffer = (bone_data name:# position:# parent:# child:#) vertBuffer.position [(num_faces*3)] = [0,0,0] vertBuffer.normal [(num_faces*3)] = [0,0,0] vertBuffer.tangent [(num_faces*3)] = [0,0,0] vertBuffer.colour [(num_faces*3)] = [0,0,0] vertBuffer.texture1 [(num_faces*3)] = [0,0,0] vertBuffer.texture2 [(num_faces*3)] = [0,0,0] vertBuffer.texture3 [(num_faces*3)] = [0,0,0] vertBuffer.boneids [(num_faces*3)] = [0,0,0,0] vertBuffer.weights [(num_faces*3)] = [0,0,0,0] weightBuffer=#;weightBuffer[num_verts]=0.0 boneIDBuffer=#;boneIDBuffer[num_verts]=0 vertCollection=# -- arrays reset on each mesh / material ID normCollection=# tvertCollection=# faceCollection=# boneCheck=# vertCollection[(num_faces*3)] = [0,0,0,0] normCollection[(num_faces*3)] = [0,0,0] tvertCollection[(num_faces*3)] = [0,0,0,0] faceCollection[num_faces] = [0,0] faceBuffer=# faceBuffer[(num_faces*3)]=0

boneMin=1024 boneMax=0 undo off(with redraw off ( if skinMod!=undefined then ( max modify mode modPanel.setCurrentObject skinMod bone_count=skinOps.GetNumberBones skinMod skinOps.RemoveZeroWeights skinMod for i = 1 to tmesh.numverts do( vertex_bone_count = skinOps.GetVertexWeightCount skinMod i -- #of weights per vert if vertex_bone_count!=0 then( weightCollection=#;weightCollection[vertex_bone_count]=0.0 boneidCollection=#;boneidCollection[vertex_bone_count]=0 for x = 1 to vertex_bone_count do( bone_weight = skinops.getvertexweight skinMod i x bone_index = skinOps.GetVertexWeightBoneID skinMod i x if bone_index==0 do bone_index=1 if bone_index<=boneMin do boneMin=bone_index if bone_index>=boneMax do boneMax=bone_index if x<=4 do ( -- limits to four bones weights per vertex weightCollection[x]=bone_weight boneidCollection[x]=bone_index)) )else( --dead weight found, nothing fancy just append weight to bone1 weightCollection=#;weightCollection[1]=0.0 boneidCollection=#;boneidCollection[1]=0 bone_index = 1 weightCollection[1]=1.0 boneidCollection[1]=1) if vertex_bone_count<=4 then ( for x = (vertex_bone_count+1) to 4 do( weightCollection[x]=0 boneidCollection[x]=0)) else( w=weightCollection[1]+weightCollection[2]+weightCollection[3]+weightCollection[4] d=1-w;weightCollection[1]=(weightCollection[1]+d)) b1=boneidCollection[1]--1 -- convert to base 0 b2=boneidCollection[2]--1 b3=boneidCollection[3]--1 b4=boneidCollection[4]--1 -- if b1<=0 do b1=0 -- if b2<=0 do b2=0 -- if b3<=0 do b3=0 -- if b4<=0 do b4=0 boneIDBuffer[i]=[b1,b2,b3,b4] weightBuffer[i]=[(weightCollection[1]),(weightCollection[2]),(weightCollection[3]),(weightCollection[4])] ))else( for x = 1 to tmesh.numverts do( -- static mesh, fix skin info weightBuffer[x]=[1,0,0,0] if tmesh.parent!=undefined then boneid=findItem boneBuffer.name tmesh.parent.name -- weight to a possible parent else boneid=findItem boneBuffer.name tmesh.name -- if no parent weight to scene root boneid-=1 -- convert to base 0 if boneid<=0 do boneid=0 -- convert to base 0 boneIDBuffer[x]=[boneid,0,0,0])) boneMin-=1

vertCount=0 -- Counts used to index through my arrays faceCount=0

modNorm = Edit_Normals addModifier selection[1] modNorm tan1 =#;tan1[(num_verts * 2)] = [0,0,0] tan2 =#;tan2[((num_verts * 2) + num_verts)] = [0,0,0] -- nom =#;nom[(num_verts)]=[0,0,0] for i = 1 to tan1.count do tan1[i]=[0,0,0] for i = 1 to tan2.count do tan2[i]=[0,0,0] -- for i = 1 to nom.count do nom[i]=[0,0,0]

tangent=# for y = 1 to num_faces do   ( vertexIndices = getFace tmesh y textureIndices = getTVFace tmesh y

i1 = vertexIndices[1] i2 = vertexIndices[2] i3 = vertexIndices[3] i4 = textureIndices[1] i5 = textureIndices[2] i6 = textureIndices[3] v1 = getVert tmesh i1 v2 = getVert tmesh i2 v3 = getVert tmesh i3

W1 = getTVert tmesh i4 W2 = getTVert tmesh i5 W3 = getTVert tmesh i6 x1 = v2[1] - v1[1] x2 = v3[1] - v1[1] y1 = v2[2] - v1[2] y2 = v3[2] - v1[2] z1 = v2[3] - v1[3] z2 = v3[3] - v1[3] s1 = w2[1] - w1[1] s2 = w3[1] - w1[1] t1 = w2[2] - w1[2] t2 = w3[2] - w1[2] r = 1.0 / (s1 * t2 - s2 * t1)

sdir = [((t2 * x1 - t1 * x2) * r),((t2 * y1 - t1 * y2) * r),((t2 * z1 - t1 * z2) * r)] tdir = [((s1 * x2 - s2 * x1) * r),((s1 * y2 - s2 * y1) * r),((s1 * z2 - s2 * z1) * r)] tan1[i1] += sdir tan1[i2] += sdir tan1[i3] += sdir

tan2[i1] += tdir tan2[i2] += tdir tan2[i3] += tdir -- nom[i1]=modNorm.GetNormal (modNorm.GetNormalID i 1) node:selection[1] -- nom[i2]=modNorm.GetNormal (modNorm.GetNormalID i 2) node:selection[1] -- nom[i3]=modNorm.GetNormal (modNorm.GetNormalID i 3) node:selection[1] ) -- deletemodifier selection[1] modNorm tangent=# faceCounter=0 count=0 -- count for resetable arrays	for x = 1 to num_faces do ( findex=getFace tmesh x tindex=getTVFace tmesh x

for y = 1 to 3 do( vert=getVert tmesh findex[y] tvert=getTVert tmesh tindex[y] norm=modNorm.GetNormal (modNorm.GetNormalID x y)

n = norm t = tan1[(findex[y])] -- Gram-Schmidt orthogonalize tangent=[0,0,0,-nmV] tang = (t - n * (Dot n t)) if nmR=true do tang[1]=-tang[1] if nmG=true do tang[2]=-tang[2] tangent[1]=tang[1] tangent[2]=tang[2] tangent[3]=tang[3] if nmS=true do (tangent[1]=tang[2];tangent[2]=tang[1])

-- Calculate handedness if (Dot (Cross n t) tan2[(findex[y])]) >=0 do tangent[4] = nmV

vertCull=findItem vertCollection [vert.x,vert.y,vert.z,(findex[y])] tvertCull=findItem tvertCollection [tvert.x,tvert.y,0,(tindex[y])] normCull=findItem normCollection norm if vertCull!=0 do (if normCollection[vertCull]!=norm do normCull=0) if vertCull!=tvertCull OR vertCull==0 OR normCull==0 then( --not found count+=1;faceCount+=1;vertCount+=1 vertCollection[count]=[vert.x,vert.y,vert.z,(findex[y])] tvertCollection[count]=[tvert.x,tvert.y,0,(tindex[y])] normCollection[count]=norm vertBuffer.position[vertCount]=[vert.x,vert.y,vert.z,(findex[y])] -- Face ID is left, relates to the Skin Weight vertBuffer.texture1[vertCount]=[tvert.x,tvert.y,0] vertBuffer.colour[vertCount]=cvert vertBuffer.normal[vertCount]=norm vertBuffer.tangent[vertCount]=[(tangent[1]),(tangent[2]),(tangent[3]),(tangent[4])] vertBuffer.boneids[vertCount]=boneIDBuffer[(findex[y])] vertBuffer.weights[vertCount]=weightBuffer[(findex[y])] faceBuffer[faceCount]=count )else(faceCount+=1;faceBuffer[faceCount]=vertCull)

)

faceCounter+=1

)

deleteModifier tmesh modNorm

print ("Vert Count: "+(count as string)) print ("Face Count: "+(faceCounter as string)) ))

--oldVcount=0 -- may use to check commandbuffer --oldFcount=0 -- may use to check commandbuffer vbName="" ibName="" cbOffset=0 for x = 1 to 4 do( fullName=names[(seekArray[x])] as stringstream baseName=(readDelimitedString fullName " ") compName=(readDelimitedString fullName" ") fseek f (perBIG[(seekArray[x])][3]) #seek_set case of( (compName=="RenderStrip"): ( if matON==true then(writelong f matID)else(fseek f 4 #seek_cur) -- fseek f 0 #seek_cur -- 	writelong s 63 -- writelong s 0 fseek f 4 #seek_cur --63 fseek f 4 #seek_cur -- 0 writelong f boneMin #unsigned -- start bone writelong f (boneMax-boneMin) #unsigned-- end bone fseek f 4 #seek_cur -- 0 -- writelong f 0x1D  -- vertex type, just force type 29 ) (compName=="VBHeader"): ( vbName=ReadFixedString f 36 fseek f 4 #seek_cur -- (-1), endline --oldVcount=readlong f #unsigned;fseek f -4 #seek_cur writelong f count writelong f 56) -- relates to vertexType, force 56bytes per vertex definition (compName=="IBHeader"): ( ibName=ReadFixedString f 36 fseek f 4 #seek_cur -- (-1), endline --oldFcount=readlong f #unsigned;fseek f -4 #seek_cur writelong f faceBuffer.count) (compName=="CommandBuffer"): ( cbOffset=seekArray[x] ) ) )

fseek f perBIG[cbOffset][3] #seek_set print perBIG[cbOffset][3] thingfound=false while (ftell f)!=(perBIG[cbOffset][3]+perBIG[cbOffset][4]) do(

if (readbyte f)==11 do(	if thingfound==false do( if (readbyte f)==0 do(			if (readbyte f)==0 do( if (readbyte f)==0 do(			if (readbyte f)==8 do( thingfound=true getPos=ftell f		fseek f getPos #seek_set writebyte f 3 fseek f (getPos+11) #seek_set writelong f count #unsigned --vertex count fseek f (getPos+19) #seek_set writelong f faceBuffer.count #unsigned --face count fseek f 0 #seek_set fflush f		)		) )		)	)	) ) fflush f fclose f

fullName=ibName as stringstream baseName=(readDelimitedString fullName " ") compName=(readDelimitedString fullName" ") -- createFile (fpath+(baseName+" Indices "+compName)) spath=(fpath+(baseName+" Indices "+compName)) if doesFileExist spath==true then( s = fopen spath "wb" ftr=1 for x = 1 to faceCounter do( fa=faceBuffer[(ftr)]-1;ftr+=1 fb=faceBuffer[(ftr)]-1;ftr+=1 fc=faceBuffer[(ftr)]-1;ftr+=1 writeshort s fa #unsigned writeshort s fb #unsigned writeshort s fc #unsigned ) fflush s fclose s )else(MessageBox "Error Opening:\n"+(baseName+" Indices "+compName))

fullName=vbName as stringstream baseName=(readDelimitedString fullName " ") compName=(readDelimitedString fullName" ") -- createFile (fpath+(baseName+" Vertices "+compName)) spath=(fpath+(baseName+" Vertices "+compName)) if doesFileExist spath==true then( s = fopen (fpath+(baseName+" Vertices "+compName)) "wb" for x = 1 to count do( writefloat s (vertBuffer.position[x][1]/mscale) writefloat s (vertBuffer.position[x][3]/mscale) writefloat s (vertBuffer.position[x][2]/-mscale) writefloat s vertBuffer.texture1[x][1] writefloat s ((vertBuffer.texture1[x][2] * -1) +1) w1=floor (vertBuffer.weights[x][1]*0xFF) w2=floor (vertBuffer.weights[x][2]*0xFF) w3=floor (vertBuffer.weights[x][3]*0xFF) w4=floor (vertBuffer.weights[x][4]*0xFF) w1+=(0xFF-(w1+w2+w3+w4))

writebyte s w1 #unsigned writebyte s w2 #unsigned writebyte s w3 #unsigned writebyte s w4 #unsigned b1=((vertBuffer.boneids[x][1]-(boneMin+1))*3);if b1<=0 do b1=0 b2=((vertBuffer.boneids[x][2]-(boneMin+1))*3);if b2<=0 do b2=0 b3=((vertBuffer.boneids[x][3]-(boneMin+1))*3);if b3<=0 do b3=0 b4=((vertBuffer.boneids[x][4]-(boneMin+1))*3);if b4<=0 do b4=0 writebyte s b1 #unsigned writebyte s b2 #unsigned writebyte s b3 #unsigned writebyte s b4 #unsigned writefloat s vertBuffer.tangent[x][1] writefloat s vertBuffer.tangent[x][3] writefloat s -vertBuffer.tangent[x][2] writefloat s vertBuffer.tangent[x][4] writefloat s vertBuffer.normal[x][1] writefloat s vertBuffer.normal[x][3] writefloat s -vertBuffer.normal[x][2] pb1.value = 100.*x/count ) fflush s fclose s )else(MessageBox "Error Opening:\n"+(baseName+" Vertices "+compName))

)else(MessageBox "ERROR\nFailed to Find Components In \"persistent.big\"")

pb1.value = 0 MessageBox "DONE!!!!" ) else (Print "Aborted.") )else(MessageBox "Please Only Select \"ONE\" object at a time")

-- gc light:true ) -- end export

on btn4 pressed do( -- repack textures

fsource = GetOpenFileName \ caption:"Open a \"bigfile.xml\" to rebuild" \ types: "BIGFILE XML (*.xml)|*.xml|" if (fsource!=undefined) AND ((doesFileExist fsource)==true) then( f=MemStreamMgr.openFile fsource fsize=		f.size fext= 		getFilenameType fsource fpath= 		getFilenamePath fsource fname= 	getFilenameFile fsource clearlistener

rdxml=readBIGXML f;MemStreamMgr.close f createFile (fpath+"bigfile.big") f = fopen (fpath+"bigfile.big") "r+" counter=1;fversion=0;filePaths=# struct bigstuff (name,type,t1,t2) biginput=(bigstuff name:# type:# t2:# t1:#) for i = 1 to rdxml.count.count do( itmN="";itmD=32;itmT1=0xE0;itmT2=0 for x = 1 to rdxml.count[i] do( datName=rdxml.name[counter] case of((datName=="version"): (fversion=rdxml.info[counter]) (datName=="name"): (itmN=rdxml.info[counter]) (datName=="alignment"): (itmD=rdxml.info[counter]) (datName=="tex01"): (itmT1=rdxml.info[counter]) (datName=="tex02"): (itmT2=rdxml.info[counter]);) counter+=	1);if itmN!="" do(append biginput.name itmN append biginput.type itmD;append biginput.t1 itmT1;append biginput.t2 itmT2)) filepaths=#;filepaths[biginput.name.count]="";nameSize=0 ddsInfo=#;ddsInfo[biginput.name.count]=[0,0,0,0] fileSizes=#;fileSizes[biginput.name.count]=0 for i = 1 to biginput.name.count do ( texW=0 texH=0 texC=0 texM=0 fsize=1 spath="" nameSize+=(biginput.name[i].count+1) if doesFileExist (fpath+biginput.name[i])==true then(

spath=(fpath+biginput.name[i]) fsize=getFileSize spath )else( if doesFileExist (fpath+biginput.name[i]+".dds")==true do ( spath=(fpath+biginput.name[i]+".dds") t = fopen spath "rb" fseek t 12 #seek_set texW=readlong t #unsigned texH=readlong t #unsigned fseek t 4 #seek_cur texM=readlong t #unsigned fseek t 0x54 #seek_set texC=readFixedString t 4 case of( (texC=="DXT1"): (texC=2) (texC=="DXT5"): (texC=1)) fsize=(((texW*texH)/texC)+((16*1)+32)) -- 1 represents the mip count, but for now its disabled to 1 fflush t fclose t )) filepaths[i]=spath ddsInfo[i]=[texW,texH,texC,texM] fileSizes[i]=fsize )

case of( (fversion=="0"): (writelong f 0x01020304) (fversion=="1"): (writelong f 0x02030405) (fversion=="2"): (writelong f 0x03040506)) offsetCount=((6*4)+(7*4*biginput.name.count)+nameSize) padSize=((ceil ((offsetCount as float)/16)*16)-(offsetCount)) as integer -- print padSize offsetCount+=padSize stringCount=((6*4)+(7*4*biginput.name.count)) writelong f offsetCount #unsigned -- data offset writelong f 0 writelong f biginput.name.count writelong f 24 writelong f stringCount #unsigned -- string offset padArray=#;padArray[biginput.name.count]=0 for i = 1 to biginput.name.count do( fsize=fileSizes[i]--;if fsize==0 do fsize=1 writelong f stringCount #unsigned -- string offset writelong f 0x48534148 #unsigned -- checksum writelong f fsize #unsigned -- file size (compresses), compression not supported writelong f fsize #unsigned -- file size, uncompressed writelong f offsetCount #unsigned -- data offset writelong f (biginput.type[i]as integer) -- type writelong f 0 offsetCount+=fsize padding=((ceil ((offsetCount as float)/16)*16)-(offsetCount)) as integer

padArray[i]=padding offsetCount+=padding stringCount+=(biginput.name[i].count+1) ) for i = 1 to biginput.name.count do(writestring f biginput.name[i]) for i = 1 to padSize do(writebyte f 0) for i = 1 to biginput.name.count do(

if filepaths[i]!="" then( if (getFilenameType filepaths[i])!=".dds"then( g = fopen filepaths[i] "rb" for x = 1 to (getFileSize filepaths[i]) do(writebyte f (readbyte g #unsigned) #unsigned) fflush g;fclose g )else( --insert import code for DDS g = fopen filepaths[i] "rb" fseek g 0x80 #seek_set writebyte f 0 writebyte f 1 writebyte f 1 case of ( (ddsInfo[i][3]==2):( writebyte f (biginput.t1[i]as integer) writeshort f ddsInfo[i][1] writeshort f ddsInfo[i][2] writebyte f 8 writebyte f 24 writebyte f 1 --mip count, 8 mips seems to be common writebyte f 4 -- 4 or 8 ) (ddsInfo[i][3]==1):( writebyte f (biginput.t1[i]as integer) writeshort f ddsInfo[i][1] writeshort f ddsInfo[i][2] writebyte f 10 writebyte f 24 writebyte f 1 --mip count, 8 mips seems to be common writebyte f 8 -- 4 or 8 )	 ) -- 	fsize=(getFileSize filepaths[i])-0x80 fsize=((ddsInfo[i][1]*ddsInfo[i][2])/ddsInfo[i][3]) writelong f (biginput.t2[i]as integer) --#unsigned writelong f 24 --table offset writelong f 0 writelong f 0x30 -- offset fo texture, fixed because mips are disabled writelong f fsize #unsigned -- 	 print ("Last Read @ 0x"+((bit.intAsHex(fsize))as string)) writebyte f 0 writebyte f 0 writebyte f 0 writebyte f 0x80 writelong f 0 writelong f 0 writelong f 0 for x = 1 to fsize do(writebyte f (readbyte g #unsigned) #unsigned) fflush g;fclose g	print fsize ))else(writebyte f 0) pb1.value = 100.*i/biginput.name.count ) -- for i = 1 to 16 do (writebyte f 0 #unsigned) fsize=ftell f fseek f 8 #seek_set writelong f fsize #unsigned -- print filepaths

pb1.value = 0 messagebox "Done!" fflush f fclose f

) else (Print "Aborted.")

)	-- end repack textures

on btn5 pressed do( -- unpack textures --=========================================================================== -- fsource="M:\\Dead.Rising.2.Off.The.Record-KaOs\\data\\models\\npcs_big\\export\\cast_sullivan.big"

fsource = GetOpenFileName \ caption:"texture pooper" \ types: "All Files (*.*)|*.*|Tex (*.tex)|*.tex|Big (*.big)|*.big|" if (fsource!=undefined) AND ((doesFileExist fsource)==true) then( f = fopen fsource "rb" -- fext= 		getFilenameType fsource fext="";for i = 2 to (getFilenameType fsource).count do fext+=(getFilenameType fsource)[i] fpath= 		getFilenamePath fsource fbatch=		getFiles (fpath+"*"+fext) fname= 	getFilenameFile fsource fsize= 		getFileSize fsource

fileID=readlong f #unsigned if fileID==0x01020304 OR fileID==0x02030405 OR fileID==0x03040506 then( dataOffset=readlong f #unsigned -- offset to data fileSize=readlong f #unsigned -- total file size files=readlong f #unsigned -- file count unk04=readlong f #unsigned -- header size? always 0x18? names_offset=readlong f #unsigned --offset to string table -- local infoArray=#;infoArray[files]=[0,0,0,0] -- struct bigInfo (name,zsize,offset,type,flag) bigArray=#;bigArray[files]=[0,0,0,0] bigFlag=#;bigFlag[files]=0 bigStr=#;bigStr[files]="" makeDir (fpath+fname+"_"+fext) bs= createFile (fpath+fname+"_"+fext+"\\"+"bigfile.xml") -- s = fopen (fpath+"\\"+fname+"_"+fext+"\\"+"bigfile.xml") "wt" format "\n" to:bs case of( (fileID==0x01020304): (format "\n" 0 to:bs) (fileID==0x02030405): (format "\n" 1 to:bs) (fileID==0x03040506): (format "\n" 2 to:bs)) for i = 1 to files do( NameOff=(readlong f #unsigned) --offset to string unk05=readlong f #unsigned -- hash zsize=readlong f #unsigned size=readlong f #unsigned offset=(readlong f #unsigned) type=readlong f #unsigned -- 0x0004 = Info (Header Information) -- 0x0010 = Data (Texture) -- 0x0020 = Data (Geometry) -- 0x0100 = BIG (BIG Package File) -- if type!=0x0004 OR type!=0x0020 OR type!=0x0100 DO Print ("ERROR: Type: 0x"+((bit.intAsHex(ftell f))as string)) zip=readlong f #unsigned -- flag, to switch on compression schemes -- infoArray[i]=[type,NameOff,offset,size] bigArray[i]=[NameOff,zsize,offset,type] bigFlag[i]=zip )

fseek f names_offset #seek_set for i = 1 to files do(	bigStr[i]=readstring f

)

for i = 1 to files do( -- memBuffer=# -- memBuffer[(bigArray[i][2])]=0 fseek f bigArray[i][3] #seek_set

if bigArray[i][4]!=16 then ( -- 	createFile (fpath+fname+"_"+fext+"\\"+bigStr[i]) sfileA = fopen (fpath+fname+"_"+fext+"\\"+bigStr[i]) "wb" -- 	for x = 1 to bigArray[i][2] do (memBuffer[x]=readbyte f #unsigned) -- 	for x = 1 to bigArray[i][2] do (writebyte s memBuffer[x] #unsigned) for x = 1 to bigArray[i][2] do (writebyte sFileA (readbyte f #unsigned) #unsigned)	format " % \n" bigStr[i] (bigArray[i][4]as integer) bigStr[i] to:bs	fclose sfileA	) else( -- texture file -- createFile (fpath+fname+"_"+fext+"\\"+bigStr[i]+".dds") sFileB = fopen (fpath+fname+"_"+fext+"\\"+bigStr[i]+".dds") "wb" ukn01=readbyte f #unsigned -- Unknown always 0? ukn02=readbyte f #unsigned -- Unknown always 1? ukn03=readbyte f #unsigned -- Unknown always 1? ukn04=readbyte f #unsigned -- Unknown STORE texW=readshort f #unsigned texH=readshort f #unsigned texC=readbyte f #unsigned -- compression flag? STORE ukn05=readbyte f #unsigned -- Unknown always 0x24? STORE texM=readbyte f #unsigned --;texM=0 -- MIP count ukn06=readbyte f #unsigned -- Unknown always 0x04/0x08? STORE ukn07=readlong f #unsigned -- Unknown, checksum? STORE mtable=readlong f #unsigned fseek f (bigArray[i][3]+mtable) #seek_set tOffset=readlong f #unsigned tSize=readlong f #unsigned fseek f (bigArray[i][3]+tOffset) #seek_set case of( (texC==0x00): (texC="ARGB32") (texC==0x08): (texC="DXT1") (texC==0x0A): (texC="DXT5")) writeDDSheader sFileB texW texH 0 texC for x = 1 to tSize do (writebyte sFileB (readbyte f #unsigned) #unsigned) format "%.) \t[%x%] [%,%,%] \t%: \t%.dds\n" i texW texH texM ukn05 ukn06 texC bigStr[i] format " % \n" bigStr[i] (bigArray[i][4]as integer) ukn04 ukn07 bigStr[i] to:bs fclose sfileA fclose sfileB fclose s )

pb1.value = 100.*i/files ) format " " to:bs fflush bs close bs fclose s fclose f pb1.value = 0 Print "Done!" )else(MessageBox "ERROR\n??Not A Compatible Big File")) else (Print "Aborted.") -- gc

)-- end unpack textures

on btn9 pressed do(MessageBox "Script created to mod Models in NPC.BIG File. \nUse Gibb's BIG Unpacker/Packer to get char models in and out. \nSame with textures")

) createDialog dr2otr_ex