home *** CD-ROM | disk | FTP | other *** search
Text File | 2019-10-16 | 35.7 KB | 1,472 lines |
- if (heapSize < 20000000) then
- heapSize = 200000000
- gname = getOpenFileName \
- caption:"Open .fbx from Bones folder" \
- types:"Warframe_Bones (*.fbx)|*.fbx" \
- historyCategory:"WarframeBNEObjectPresets"
- g = fopen gname "rb"
- fname = getOpenFileName \
- caption:"Open .fbx from Mesh folder" \
- types:"Warframe (*.fbx)|*.fbx" \
- historyCategory:"WarframeMSHObjectPresets"
- f = fopen fname "rb"
-
- clearlistener()
-
- fn readHalfFloat fstream = (
- hf=readshort fstream #unsigned
- sign = bit.get hf 16
- exponent = (bit.shift (bit.and hf (bit.hexasint "7C00")) -10) as integer - 16
- fraction = bit.and hf (bit.hexasint "03FF")
- if sign==true then sign = 1 else sign = 0
- exponentF = exponent + 127
- outputAsFloat = bit.or (bit.or (bit.shift fraction 13) \
- (bit.shift exponentF 23)) (bit.shift sign 31)
- return bit.intasfloat outputasfloat*2
- )
-
- fn ReadFixedString bstream fixedLen =
- (
- local str = ""
- for i = 1 to fixedLen do
- (
- str += bit.intAsChar (ReadByte bstream #unsigned)
- )
- str
- )
-
- struct weight_data
- (
- boneids,weights
- )
- struct mesh_info_struct
- (
- meshname,FacePos,FaceCount
- )
- struct Bone_Info_Struct
- (
- Bone1,Bone2,Bone3,Bone4
- )
- struct Weight_Info_Struct
- (
- Weight1,Weight2,Weight3,Weight4
- )
- struct BoneMap_Struct
- (
- BoneMapId
- )
-
- BoneCount=#()
- BoneCount1=#()
- VertexCount=#()
- TotalFaces=#()
- NumMorph=#()
-
- clearlistener()
-
- fseek g 0x10 #seek_set
- SkelCount = readlong g
- modelPathS = readlong g
- modelPath = ReadFixedString g modelPathS
- matNameS = readlong g
- matName = ReadFixedString g matNameS
- Print ("Strings End @ 0x"+((bit.intAsHex(ftell g))as string))
- if matNameS!=0 then readbyte g
- StaticOrRigged=readlong g
- print ("StaticOrRigged:"+StaticOrRigged as string)
- if StaticOrRigged==71 then (
- fseek g 0x68 #seek_cur
- UsedBones = readlong g
- append VertexCount (readshort g)
- Unk=readshort g
- append TotalFaces (readlong g)
- append NumMorph (readlong g)
- fseek g 0xC6 #seek_cur
- )
- if StaticOrRigged==82 then (
- fseek g 0x6C #seek_cur
- UsedBones = readlong g
- Print ("Pos @ 0x"+((bit.intAsHex(ftell g))as string))
- append VertexCount (readshort g)
- Unk=readshort g
- append TotalFaces (readlong g)
- append NumMorph (readlong g)
- fseek g 0xC6 #seek_cur
- )
- ---------------------------------------------------------------------------------------------------------
- if StaticOrRigged==237 or StaticOrRigged==477 then (
- fseek g 0x6A #seek_cur
- append BoneCount (readlong g)
- BoneNamesArray = #()
- for x = 1 to BoneCount[1] do (
- BoneNameSize = readlong g
- BoneName = ReadFixedString g BoneNameSize
- append BoneNamesArray BoneName
- )
- append TotalFaces (readlong g)
- UsedBones = readlong g
- append VertexCount (readlong g)
- append NumMorph (readlong g)
- fseek g 0x4 #seek_cur
- parse = readlong g
- if parse!=2 then fseek g 0x3D #seek_cur
- if parse==2 then fseek g 0x5D #seek_cur
- append BoneCount1 (readlong g)
- BoneNamesArray1 = #()
- boneparent_array = #()
- for y = 1 to BoneCount1[1] do (
- BoneNameSize1 = readlong g
- BoneName1 = ReadFixedString g BoneNameSize1
- append BoneNamesArray1 BoneName1
- boneparent=readshort g
- boneId=readshort g
- append boneparent_array boneparent
- )
- fseek g 0xA2 #seek_cur
- )
-
- if StaticOrRigged==248 then (
- fseek g 0x7A #seek_cur
- append BoneCount (readlong g)
- BoneNamesArray = #()
- for x = 1 to BoneCount[1] do (
- BoneNameSize = readlong g
- BoneName = ReadFixedString g BoneNameSize
- append BoneNamesArray BoneName
- )
- append TotalFaces (readlong g)
- UsedBones = readlong g
- append VertexCount (readlong g)
- append NumMorph (readlong g)
- fseek g 0x4 #seek_cur
- parse = readlong g
- if parse!=2 then fseek g 0x3D #seek_cur
- if parse==2 then fseek g 0x5D #seek_cur
- append BoneCount1 (readlong g)
- BoneNamesArray1 = #()
- boneparent_array = #()
- for y = 1 to BoneCount1[1] do (
- BoneNameSize1 = readlong g
- BoneName1 = ReadFixedString g BoneNameSize1
- append BoneNamesArray1 BoneName1
- boneparent=readshort g
- boneId=readshort g
- append boneparent_array boneparent
- )
- fseek g 0xA2 #seek_cur
- )
-
- if StaticOrRigged==252 then (
- fseek g 0x7E #seek_cur
- append BoneCount (readlong g)
- BoneNamesArray = #()
- for x = 1 to BoneCount[1] do (
- BoneNameSize = readlong g
- BoneName = ReadFixedString g BoneNameSize
- append BoneNamesArray BoneName
- )
- Print ("!!!! @ 0x"+((bit.intAsHex(ftell g))as string))
- append TotalFaces (readlong g)
- UsedBones = readlong g
- append VertexCount (readlong g)
- append NumMorph (readlong g)
- fseek g 0x4 #seek_cur
- parse = readlong g
- if parse!=2 then fseek g 0x3D #seek_cur
- if parse==2 then fseek g 0x5D #seek_cur
- append BoneCount1 (readlong g)
- BoneNamesArray1 = #()
- boneparent_array = #()
- for y = 1 to BoneCount1[1] do (
- BoneNameSize1 = readlong g
- BoneName1 = ReadFixedString g BoneNameSize1
- append BoneNamesArray1 BoneName1
- boneparent=readshort g
- boneId=readshort g
- append boneparent_array boneparent
- )
- fseek g 0xA2 #seek_cur
- )
-
- Print ("End @ 0x"+((bit.intAsHex(ftell g))as string))
-
- Print ("Mesh Info Start @ 0x"+((bit.intAsHex(ftell g))as string))
-
- MeshInfoArray= #()
- MeshCount=readlong g
- for a = 1 to MeshCount do (
- fseek g 0x20 #seek_cur
- NameSize=readlong g
- meshname = ReadFixedString g NameSize
- FacePos=readlong g
- Lod_1=readlong g
- Lod_2=readlong g
- Lod_3=readlong g
- Lod_4=readlong g
- FaceCount=readlong g
- Lod_1_Count=readlong g
- Lod_2_Count=readlong g
- Lod_3_Count=readlong g
- Lod_4_Count=readlong g
- fseek g 0x34 #seek_cur
- append MeshInfoArray (mesh_info_struct meshname:meshname FacePos:FacePos FaceCount:FaceCount)
- )
-
- print MeshInfoArray
-
- Print ("Mesh Info End @ 0x"+((bit.intAsHex(ftell g))as string))
-
- UsedBoneCount =#()
- if NumMorph[1]!=0 then
- for x = 1 to 1 do (
- MorphCount =readlong g
- for x = 1 to MorphCount do (
- MorphNameSize = readlong g
- MorphName = ReadFixedString g MorphNameSize
- null = readlong g
- )
-
- print ("MorphCount:"+ NumMorph[1] as string)
-
- Print ("Morph End @ 0x"+((bit.intAsHex(ftell g))as string))
-
- Print ("Map Start @ 0x"+((bit.intAsHex(ftell g))as string))
-
- MeshParts=readlong g
- BoneMapStart = (ftell g)
- for a = 1 to MeshParts do (
- append UsedBoneCount (readlong g)
- for x = 1 to UsedBoneCount[a] do (
- UsedBoneId=readlong g
- )
- )
- )
-
- wordCount=readlong g
- for i=1 to wordCount do (
- readshort g
- )
- readlong g
-
- Print ("Map Start @ 0x"+((bit.intAsHex(ftell g))as string))
-
- MeshParts=readlong g
- BoneMapStart = (ftell g)
- for a = 1 to MeshParts do (
- append UsedBoneCount (readlong g)
- for x = 1 to UsedBoneCount[a] do (
- UsedBoneId=readlong g
- )
- )
-
- VCount =#()
-
- Print ("Map End @ 0x"+((bit.intAsHex(ftell g))as string))
-
- if NumMorph[1]!=0 then
- for i = 1 to 1 do (
- Mcount = readlong g
- fseek g 0x18 #seek_cur
- for x = 1 to MeshParts do (
- LongCount00=readlong g
- for i=1 to (LongCount00) do (
- readlong g
- )
- LongCount01=readlong g
- for i=1 to (LongCount01) do (
- readlong g
- )
- longCount = readlong g
- Print ("VCount Start @ 0x"+((bit.intAsHex(ftell g))as string))
- append VCount (readlong g)
- for i=1 to (LongCount-1) do (
- readlong g
- )
- Count=readlong g
- for x = 1 to Count do (
- NameSize = readlong g
- fseek g NameSize #seek_cur
- )
- Print ("VCount End @ 0x"+((bit.intAsHex(ftell g))as string))
- MorphStrCount=readlong g
- for i=1 to (MorphStrCount) do (
- readfloat g
- )
- LongCount02=readlong g
- for i=1 to (LongCount02) do (
- readlong g
- )
- )
- )
-
- if NumMorph[1]==0 then fseek g 0x0 #seek_cur
-
- print ("MVertex Count: "+(VCount as string))
- print ("Vertex Count: "+(VertexCount as string))
-
- -------------------------------------------------------------------------------------------------
-
- fseek f 0x0 #seek_set
- StrCheck=ReadFixedString f 8
- print StrCheck
- if StaticOrRigged==237 or StaticOrRigged==248 or StaticOrRigged==477 then
- if StrCheck=="NXSMESH" then (
- print "Type 71+Rigged"
- fseek f 0x0 #seek_set
- for i = 1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- vertArray2=#()
- faceArray2 =#()
- UVarray=#()
-
- fseek f 0xC #seek_cur
- FaceType=readlong f
- UnkHash=readlong f
- ColVertCount=readlong f
- ColFaceCount=readlong f
-
- Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x =1 to ColVertCount do (
-
- vx = readFloat f
- vy = readFloat f
- vz = readFloat f
-
- append vertArray2 ([-vx,-vz,vy]*100)
- )
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- if FaceType==6 then (
- for x = 1 to ColFaceCount do (
- fa=readbyte f #unsigned + 1
- fb=readbyte f #unsigned + 1
- fc=readbyte f #unsigned + 1
- append faceArray2 [fc,fb,fa]
- )
-
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- FaceOrderCount=(readlong f+1)
-
- if ColFaceCount==FaceOrderCount then
- for i=1 to (FaceOrderCount) do (
- readbyte f
- )
-
- if ColFaceCount!=FaceOrderCount then
- for i=1 to ColFaceCount do (
- readshort f
- )
-
- Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))
- )
-
- if FaceType==10 then (
- for x = 1 to ColFaceCount do (
- fa=readshort f #unsigned + 1
- fb=readshort f #unsigned + 1
- fc=readshort f #unsigned + 1
- append faceArray2 [fc,fb,fa]
- )
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- FaceOrderCount=(readlong f+1)
-
- for i=1 to ColFaceCount do (
- readshort f
- )
-
- Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))
- )
-
- msh2 = mesh vertices:vertArray2 faces:faceArray2
- msh2.name=(("Collison Mesh_")+i as string)
-
- fseek f 0x5B #seek_cur
-
- BNECount=readlong f
- pad2=readbyte f
- for i=1 to BNECount do (
- getPos = ftell f + 128
- fseek f getPos #seek_set
- )
-
- Print ("BNE End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- fseek f 0x1C #seek_cur
-
- FaceOrderCount2=(readlong f)
-
- for i=1 to FaceOrderCount2 do (
- readbyte f
- )
- Print ("NXE End @ 0x"+((bit.intAsHex(ftell f))as string))
- )
-
- BNArr = #()
- fseek f 0x2 #seek_cur
- for a = 1 to BoneCount[1] do (
- getPos = ftell f + 64
- fseek f getPos #seek_set
- )
-
- BNArr1 = #()
- for a = 1 to BoneCount1[1] do ( --second bones section
- getPos = ftell f + 64
- fseek f getPos #seek_set
- )
-
-
- for x =1 to BoneCount1[1] do (
- check = readshort f
- )
-
- for x =1 to BoneCount1[1] do (
- check1 = readshort f
- )
-
- fseek f 0x8 #seek_cur
-
- if NumMorph[1]==0 then
- for i = 1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- UVarray=#()
- W1_array=#()
- B1_array=#()
- Weight_array=#()
- UsedBoneCountArray =#()
-
- fseek g BoneMapStart #seek_set
-
- num = readlong g
- for x = 1 to num do (
- BoneMapId=(readlong g+1)
- append UsedBoneCountArray (BoneMap_Struct BoneMapId:BoneMapId)
- )
-
- BoneMapStart+=(num*4)+4
- -- print UsedBoneCountArray
-
- vertOffset = (ftell f)
-
- print vertOffset
-
- NumVert=VertexCount[1]
-
- Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x =1 to NumVert do (
-
- vx = readHalfFloat f
- vy = readHalfFloat f
- vz = readHalfFloat f
- fseek f 0xA #seek_cur
- tu = readHalfFloat f
- tv = readHalfFloat f*-1
- tu00 = readHalfFloat f
- tv00 = readHalfFloat f*-1
- bone1 = readbyte f #unsigned
- bone2 = readbyte f #unsigned
- bone3 = readbyte f #unsigned
- bone4 = readbyte f #unsigned
- weight1 = readbyte f #unsigned
- weight2 = readbyte f #unsigned
- weight3 = readbyte f #unsigned
- weight4 =readbyte f #unsigned
-
- append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
- append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
- append vertArray ([-vx,-vz,vy]*100)
- append UVarray [tu,tv,0]
- )
-
- num_compare=UsedBoneCount[i]
-
- for b = 1 to W1_array.count Do (
- w = (weight_data boneids:#() weights:#())
- maxweight = 0
-
- if(W1_array[b].Weight1 != 0) then
- maxweight = maxweight + W1_array[b].Weight1
- if(B1_array[b].Bone1 > num_compare ) then (W1_array[b].Weight1)=0
- if((B1_array[b].Bone1+1) > num_compare ) then (B1_array[b].Bone1)=0
- if(W1_array[b].Weight2 != 0) then
- maxweight = maxweight + W1_array[b].Weight2
- if(B1_array[b].Bone2 > num_compare) then (W1_array[b].Weight2)=0
- if((B1_array[b].Bone2+1) > num_compare) then (B1_array[b].Bone2)=0
- if(W1_array[b].Weight3 != 0) then
- maxweight = maxweight + W1_array[b].Weight3
- if(B1_array[b].Bone3 > num_compare) then (W1_array[b].Weight3)=0
- if((B1_array[b].Bone3+1) > num_compare ) then (B1_array[b].Bone3)=0
- if(W1_array[b].Weight4 != 0) then
- maxweight = maxweight + W1_array[b].Weight4
- if(B1_array[b].Bone4 > num_compare) then (W1_array[b].Weight4)=0
- if((B1_array[b].Bone4+1) > num_compare ) then (B1_array[b].Bone4)=0
-
- if(maxweight != 0) then
- (
- if(W1_array[b].Weight1 != 0) then
- (
- w1 = W1_array[b].Weight1 as float
- append w.boneids (B1_array[b].Bone1 + 1)
- append w.weights (w1/255)
- )
- if(W1_array[b].Weight2 != 0) then
- (
- w2 = W1_array[b].Weight2 as float
- append w.boneids (B1_array[b].Bone2 + 1)
- append w.weights (w2/255)
- )
- if(W1_array[b].Weight3 != 0) then
- (
- w3 = W1_array[b].Weight3 as float
- append w.boneids (B1_array[b].Bone3 + 1)
- append w.weights (w3/255)
- )
- if(W1_array[b].Weight4 != 0) then
- (
- w4 = W1_array[b].Weight4 as float
- append w.boneids (B1_array[b].Bone4 + 1)
- append w.weights (w4/255)
- )
- )
- append Weight_array w
- )
-
- FaceStart = (ftell f)
- faceOffset = (MeshInfoArray[i].FacePos)*2
-
- print num_compare
- print NumVert
- print faceOffset
- print FaceStart
-
- fseek f (FaceStart+faceOffset) #seek_set
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
- fa=readshort f + 1
- fb=readshort f + 1
- fc=readshort f + 1
- append faceArray [fc,fb,fa]
- )
-
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- fseek f vertOffset #seek_set
-
- try(
- msh = mesh vertices:vertArray faces:faceArray
- msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
- msh.numTVerts = UVarray.count
- buildTVFaces msh
- for j = 1 to UVarray.count do setTVert msh j UVarray[j]
- for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
-
-
- -- max modify mode
- -- select msh
- -- skinMod = skin ()
- -- addModifier msh skinMod
- -- for i = 1 to UsedBoneCount[i] do
- -- (
- -- maxbone = getnodebyname BoneNamesArray[(UsedBoneCountArray[i].BoneMapId)]
- -- if i != UsedBoneCount[i] then
- -- skinOps.addBone skinMod maxbone 0
- -- else
- -- skinOps.addBone skinMod maxbone 1
- -- )
- -- modPanel.setCurrentObject skinMod
- -- for i = 1 to NumVert do (
- -- w = Weight_array[i]
- -- bi = #() --bone index array
- -- wv = #() --weight value array
- --
- -- for j = 1 to w.boneids.count do
- -- (
- -- boneid = w.boneids[j]
- -- weight = w.weights[j]
- -- append bi boneid
- -- append wv weight
- -- )
- --
- -- skinOps.ReplaceVertexWeights skinMod i bi wv
- -- )
- )catch(format "failed!!\n")
- )
- )
-
- -----------------------------------------------------------------------------------------
-
- if StaticOrRigged==237 or StaticOrRigged==248 or StaticOrRigged==252 or StaticOrRigged==477 then
- if StrCheck!="NXSMESH" then (
- BNArr = #()
- fseek f 0x2 #seek_set
- for a = 1 to BoneCount[1] do (
- getPos = ftell f + 64
- fseek f getPos #seek_set
- )
-
- BNArr1 = #()
- for a = 1 to BoneCount1[1] do ( --second bones section
- getPos = ftell f + 64
- fseek f getPos #seek_set
- )
-
-
- for x =1 to BoneCount1[1] do (
- check = readshort f
- )
-
- for x =1 to BoneCount1[1] do (
- check1 = readshort f
- )
-
- fseek f 0x8 #seek_cur
-
- if NumMorph[1]==0 then
- for i = 1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- UVarray=#()
- W1_array=#()
- B1_array=#()
- Weight_array=#()
- UsedBoneCountArray =#()
-
- fseek g BoneMapStart #seek_set
-
- num = readlong g
- for x = 1 to num do (
- BoneMapId=(readlong g+1)
- append UsedBoneCountArray (BoneMap_Struct BoneMapId:BoneMapId)
- )
-
- BoneMapStart+=(num*4)+4
- -- print UsedBoneCountArray
-
- vertOffset = (ftell f)
-
- print vertOffset
-
- NumVert=VertexCount[1]
-
- Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x =1 to NumVert do (
-
- vx = readHalfFloat f
- vy = readHalfFloat f
- vz = readHalfFloat f
- fseek f 0xA #seek_cur
- tu = readHalfFloat f
- tv = readHalfFloat f*-1
- tu00 = readHalfFloat f
- tv00 = readHalfFloat f*-1
- bone1 = readbyte f #unsigned
- bone2 = readbyte f #unsigned
- bone3 = readbyte f #unsigned
- bone4 = readbyte f #unsigned
- weight1 = readbyte f #unsigned
- weight2 = readbyte f #unsigned
- weight3 = readbyte f #unsigned
- weight4 =readbyte f #unsigned
-
- append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
- append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
- append vertArray ([-vx,-vz,vy]*100)
- append UVarray [tu,tv,0]
- )
-
- num_compare=UsedBoneCount[i]
-
- for b = 1 to W1_array.count Do (
- w = (weight_data boneids:#() weights:#())
- maxweight = 0
-
- if(W1_array[b].Weight1 != 0) then
- maxweight = maxweight + W1_array[b].Weight1
- if(B1_array[b].Bone1 > num_compare ) then (W1_array[b].Weight1)=0
- if((B1_array[b].Bone1+1) > num_compare ) then (B1_array[b].Bone1)=0
- if(W1_array[b].Weight2 != 0) then
- maxweight = maxweight + W1_array[b].Weight2
- if(B1_array[b].Bone2 > num_compare) then (W1_array[b].Weight2)=0
- if((B1_array[b].Bone2+1) > num_compare) then (B1_array[b].Bone2)=0
- if(W1_array[b].Weight3 != 0) then
- maxweight = maxweight + W1_array[b].Weight3
- if(B1_array[b].Bone3 > num_compare) then (W1_array[b].Weight3)=0
- if((B1_array[b].Bone3+1) > num_compare ) then (B1_array[b].Bone3)=0
- if(W1_array[b].Weight4 != 0) then
- maxweight = maxweight + W1_array[b].Weight4
- if(B1_array[b].Bone4 > num_compare) then (W1_array[b].Weight4)=0
- if((B1_array[b].Bone4+1) > num_compare ) then (B1_array[b].Bone4)=0
-
- if(maxweight != 0) then
- (
- if(W1_array[b].Weight1 != 0) then
- (
- w1 = W1_array[b].Weight1 as float
- append w.boneids (B1_array[b].Bone1 + 1)
- append w.weights (w1/255)
- )
- if(W1_array[b].Weight2 != 0) then
- (
- w2 = W1_array[b].Weight2 as float
- append w.boneids (B1_array[b].Bone2 + 1)
- append w.weights (w2/255)
- )
- if(W1_array[b].Weight3 != 0) then
- (
- w3 = W1_array[b].Weight3 as float
- append w.boneids (B1_array[b].Bone3 + 1)
- append w.weights (w3/255)
- )
- if(W1_array[b].Weight4 != 0) then
- (
- w4 = W1_array[b].Weight4 as float
- append w.boneids (B1_array[b].Bone4 + 1)
- append w.weights (w4/255)
- )
- )
- append Weight_array w
- )
-
- FaceStart = (ftell f)
- faceOffset = (MeshInfoArray[i].FacePos)*2
-
- print num_compare
- print NumVert
- print faceOffset
- print FaceStart
-
- fseek f (FaceStart+faceOffset) #seek_set
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
- fa=readshort f + 1
- fb=readshort f + 1
- fc=readshort f + 1
- append faceArray [fc,fb,fa]
- )
-
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- fseek f vertOffset #seek_set
-
- try(
- msh = mesh vertices:vertArray faces:faceArray
- msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
- msh.numTVerts = UVarray.count
- buildTVFaces msh
- for j = 1 to UVarray.count do setTVert msh j UVarray[j]
- for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
-
-
- -- max modify mode
- -- select msh
- -- skinMod = skin ()
- -- addModifier msh skinMod
- -- for i = 1 to UsedBoneCount[i] do
- -- (
- -- maxbone = getnodebyname BoneNamesArray[(UsedBoneCountArray[i].BoneMapId)]
- -- if i != UsedBoneCount[i] then
- -- skinOps.addBone skinMod maxbone 0
- -- else
- -- skinOps.addBone skinMod maxbone 1
- -- )
- -- modPanel.setCurrentObject skinMod
- -- for i = 1 to NumVert do (
- -- w = Weight_array[i]
- -- bi = #() --bone index array
- -- wv = #() --weight value array
- --
- -- for j = 1 to w.boneids.count do
- -- (
- -- boneid = w.boneids[j]
- -- weight = w.weights[j]
- -- append bi boneid
- -- append wv weight
- -- )
- --
- -- skinOps.ReplaceVertexWeights skinMod i bi wv
- -- )
- )catch(format "failed!!\n")
- )
-
- -------------------------------------------------
- vertOffset=(ftell f)
- vertStart=(ftell f)
- if NumMorph[1]!=0 then
- for i = 1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- UVarray=#()
- W1_array=#()
- B1_array=#()
- Weight_array=#()
- UsedBoneCountArray =#()
-
- fseek g BoneMapStart #seek_set
-
- num = readlong g
- for x = 1 to num do (
- BoneMapId=(readlong g+1)
- append UsedBoneCountArray (BoneMap_Struct BoneMapId:BoneMapId)
- )
-
- BoneMapStart+=(num*4)+4
- -- print UsedBoneCountArray
-
- print vertOffset
-
- fseek f vertStart #seek_set
-
- NumVert=VCount[i]
-
- Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x =1 to NumVert do (
-
- vx = readHalfFloat f
- vy = readHalfFloat f
- vz = readHalfFloat f
- fseek f 0xA #seek_cur
- tu = readHalfFloat f
- tv = readHalfFloat f*-1
- tu00 = readHalfFloat f
- tv00 = readHalfFloat f*-1
- bone1 = readbyte f #unsigned
- bone2 = readbyte f #unsigned
- bone3 = readbyte f #unsigned
- bone4 = readbyte f #unsigned
- weight1 = readbyte f #unsigned
- weight2 = readbyte f #unsigned
- weight3 = readbyte f #unsigned
- weight4 =readbyte f #unsigned
-
- append W1_array (Weight_Info_Struct Weight1:Weight1 Weight2:Weight2 Weight3:Weight3 Weight4:Weight4)
- append B1_array (Bone_Info_Struct Bone1:Bone1 Bone2:Bone2 Bone3:Bone3 Bone4:Bone4)
- append vertArray ([-vx,-vz,vy]*100)
- append UVarray [tu,tv,0]
- )
-
- num_compare=UsedBoneCount[i]
-
- for b = 1 to W1_array.count Do (
- w = (weight_data boneids:#() weights:#())
- maxweight = 0
-
- if(W1_array[b].Weight1 != 0) then
- maxweight = maxweight + W1_array[b].Weight1
- if(B1_array[b].Bone1 > num_compare ) then (W1_array[b].Weight1)=0
- if((B1_array[b].Bone1+1) > num_compare ) then (B1_array[b].Bone1)=0
- if(W1_array[b].Weight2 != 0) then
- maxweight = maxweight + W1_array[b].Weight2
- if(B1_array[b].Bone2 > num_compare) then (W1_array[b].Weight2)=0
- if((B1_array[b].Bone2+1) > num_compare) then (B1_array[b].Bone2)=0
- if(W1_array[b].Weight3 != 0) then
- maxweight = maxweight + W1_array[b].Weight3
- if(B1_array[b].Bone3 > num_compare) then (W1_array[b].Weight3)=0
- if((B1_array[b].Bone3+1) > num_compare ) then (B1_array[b].Bone3)=0
- if(W1_array[b].Weight4 != 0) then
- maxweight = maxweight + W1_array[b].Weight4
- if(B1_array[b].Bone4 > num_compare) then (W1_array[b].Weight4)=0
- if((B1_array[b].Bone4+1) > num_compare ) then (B1_array[b].Bone4)=0
-
- if(maxweight != 0) then
- (
- if(W1_array[b].Weight1 != 0) then
- (
- w1 = W1_array[b].Weight1 as float
- append w.boneids (B1_array[b].Bone1 + 1)
- append w.weights (w1/255)
- )
- if(W1_array[b].Weight2 != 0) then
- (
- w2 = W1_array[b].Weight2 as float
- append w.boneids (B1_array[b].Bone2 + 1)
- append w.weights (w2/255)
- )
- if(W1_array[b].Weight3 != 0) then
- (
- w3 = W1_array[b].Weight3 as float
- append w.boneids (B1_array[b].Bone3 + 1)
- append w.weights (w3/255)
- )
- if(W1_array[b].Weight4 != 0) then
- (
- w4 = W1_array[b].Weight4 as float
- append w.boneids (B1_array[b].Bone4 + 1)
- append w.weights (w4/255)
- )
- )
- append Weight_array w
- )
-
- VertexEnd=vertOffset+(VertexCount[1]*32)
-
- fseek f VertexEnd #seek_set
-
- print VertexEnd
-
- Print ("Vertex End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x=1 to NumMorph[1] do (
- getPos = ftell f + 16
- fseek f getPos #seek_set
- )
-
- FaceStart = (ftell f)
- faceOffset = (MeshInfoArray[i].FacePos)*2
-
- print num_compare
- print NumVert
- print faceOffset
- print FaceStart
-
- fseek f (FaceStart+faceOffset) #seek_set
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
- fa=readshort f + 1
- fb=readshort f + 1
- fc=readshort f + 1
- append faceArray [fc,fb,fa]
- )
-
- vertStart+=NumVert*32
-
- try(
- msh = mesh vertices:vertArray faces:faceArray
- msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
- msh.numTVerts = UVarray.count
- buildTVFaces msh
- for j = 1 to UVarray.count do setTVert msh j UVarray[j]
- for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
-
-
- -- max modify mode
- -- select msh
- -- skinMod = skin ()
- -- addModifier msh skinMod
- -- for i = 1 to UsedBoneCount[i] do
- -- (
- -- maxbone = getnodebyname BoneNamesArray[(UsedBoneCountArray[i].BoneMapId)]
- -- if i != UsedBoneCount[i] then
- -- skinOps.addBone skinMod maxbone 0
- -- else
- -- skinOps.addBone skinMod maxbone 1
- -- )
- -- modPanel.setCurrentObject skinMod
- -- for i = 1 to NumVert do (
- -- w = Weight_array[i]
- -- bi = #() --bone index array
- -- wv = #() --weight value array
- --
- -- for j = 1 to w.boneids.count do
- -- (
- -- boneid = w.boneids[j]
- -- weight = w.weights[j]
- -- append bi boneid
- -- append wv weight
- -- )
- --
- -- skinOps.ReplaceVertexWeights skinMod i bi wv
- -- )
- )catch(format "failed!!\n")
- )
- )
-
- -----------------------------------------------------------------------------------------
- fseek f 0x0 #seek_set
- StrCheck=ReadFixedString f 8
- print StrCheck
- if StaticOrRigged==71 then
- if StrCheck=="NXSMESH" then (
- fseek f 0xC #seek_cur
- FaceType=readlong f
- UnkHash=readlong f
- ColVertCount=readlong f
- ColFaceCount=readlong f
- fseek f 0x0 #seek_set
- print "Type 71+Static+Collision"
- for i = 1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- vertArray2=#()
- faceArray2 =#()
- UVarray=#()
-
- fseek f 0xC #seek_cur
- FaceType=readlong f
- UnkHash=readlong f
- ColVertCount=readlong f
- ColFaceCount=readlong f
-
- Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x =1 to ColVertCount do (
-
- vx = readFloat f
- vy = readFloat f
- vz = readFloat f
-
- append vertArray2 ([-vx,-vz,vy]*100)
- )
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- if FaceType==6 then (
- for x = 1 to ColFaceCount do (
- fa=readbyte f #unsigned + 1
- fb=readbyte f #unsigned + 1
- fc=readbyte f #unsigned + 1
- append faceArray2 [fc,fb,fa]
- )
-
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- FaceOrderCount=(readlong f+1)
-
- if ColFaceCount==FaceOrderCount then
- for i=1 to (FaceOrderCount) do (
- readbyte f
- )
-
- if ColFaceCount!=FaceOrderCount then
- for i=1 to ColFaceCount do (
- readshort f
- )
-
- Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))
- )
-
- if FaceType==10 then (
- for x = 1 to ColFaceCount do (
- fa=readshort f #unsigned + 1
- fb=readshort f #unsigned + 1
- fc=readshort f #unsigned + 1
- append faceArray2 [fc,fb,fa]
- )
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- FaceOrderCount=(readlong f+1)
-
- for i=1 to ColFaceCount do (
- readshort f
- )
-
- Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))
- )
-
- msh2 = mesh vertices:vertArray2 faces:faceArray2
- msh2.name=(("Collison Mesh_")+i as string)
-
- fseek f 0x5B #seek_cur
-
- Print ("BNE Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- BNECount=readlong f
- pad2=readbyte f
- for i=1 to BNECount do (
- getPos = ftell f + 128
- fseek f getPos #seek_set
- )
-
- Print ("BNE End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- fseek f 0x1C #seek_cur
-
- FaceOrderCount2=(readlong f)
-
- for i=1 to FaceOrderCount2 do (
- readbyte f
- )
- Print ("NXE End @ 0x"+((bit.intAsHex(ftell f))as string))
- )
-
- fseek f 0x2 #seek_cur
-
- if NumMorph[1]==0 then
- for i = 1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- UVarray=#()
-
- Print ("Mesh Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- print (VertexCount[1] as string)
-
- VertexStart=ftell f
-
- for x =1 to VertexCount[1] do (
- getPos = ftell f + 24
- vx = readHalfFloat f
- vy = readHalfFloat f
- vz = readHalfFloat f
- fseek f 0xA #seek_cur
- tu = readHalfFloat f
- tv = readHalfFloat f*-1
- fseek f getPos #seek_set
- append vertArray ([-vx,-vz,vy]*100)
- append UVarray [tu,tv,0]
- )
-
- FaceStart = (ftell f)
- faceOffset = (MeshInfoArray[i].FacePos)*2
-
- fseek f (FaceStart+faceOffset) #seek_set
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
- fa=readshort f #unsigned + 1
- fb=readshort f #unsigned + 1
- fc=readshort f #unsigned + 1
- append faceArray [fc,fb,fa]
- )
-
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- fseek f VertexStart #seek_set
-
- msh = mesh vertices:vertArray faces:faceArray
- msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
- msh.numTVerts = UVarray.count
- buildTVFaces msh
- for j = 1 to UVarray.count do setTVert msh j UVarray[j]
- for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
- )
- if NumMorph[1]!=0 then
- for i = 1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- UVarray=#()
-
- Print ("Mesh Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- print (VertexCount[1] as string)
-
- VertexStart=ftell f
-
- for x =1 to VertexCount[1] do (
- getPos = ftell f + 24
- vx = readHalfFloat f
- vy = readHalfFloat f
- vz = readHalfFloat f
- fseek f 0xA #seek_cur
- tu = readHalfFloat f
- tv = readHalfFloat f*-1
- fseek f getPos #seek_set
- append vertArray ([-vx,-vz,vy]*100)
- append UVarray [tu,tv,0]
- )
-
- FaceStart = (ftell f)
- faceOffset = (MeshInfoArray[i].FacePos)*2
-
- fseek f (FaceStart+faceOffset) #seek_set
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
- fa=readshort f #unsigned + 1
- fb=readshort f #unsigned + 1
- fc=readshort f #unsigned + 1
- append faceArray [fc,fb,fa]
- )
-
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- fseek f VertexStart #seek_set
-
- msh = mesh vertices:vertArray faces:faceArray
- msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
- msh.numTVerts = UVarray.count
- buildTVFaces msh
- for j = 1 to UVarray.count do setTVert msh j UVarray[j]
- for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
- )
- )
- -----------------------------------------------------------------------------------------
- if StaticOrRigged==82 then
- if StrCheck=="NXSMESH" then (
- fseek f 0xC #seek_cur
- FaceType=readlong f
- UnkHash=readlong f
- ColVertCount=readlong f
- ColFaceCount=readlong f
- fseek f 0x0 #seek_set
- print "Type 71+Static+Collision"
- for i = 1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- vertArray2=#()
- faceArray2 =#()
- UVarray=#()
-
- fseek f 0xC #seek_cur
- FaceType=readlong f
- UnkHash=readlong f
- ColVertCount=readlong f
- ColFaceCount=readlong f
-
- Print ("Vertex Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x =1 to ColVertCount do (
-
- vx = readFloat f
- vy = readFloat f
- vz = readFloat f
-
- append vertArray2 ([-vx,-vz,vy]*100)
- )
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- if FaceType==6 then (
- for x = 1 to ColFaceCount do (
- fa=readbyte f #unsigned + 1
- fb=readbyte f #unsigned + 1
- fc=readbyte f #unsigned + 1
- append faceArray2 [fc,fb,fa]
- )
-
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- FaceOrderCount=(readlong f+1)
-
- if ColFaceCount==FaceOrderCount then
- for i=1 to (FaceOrderCount) do (
- readbyte f
- )
-
- if ColFaceCount!=FaceOrderCount then
- for i=1 to ColFaceCount do (
- readshort f
- )
-
- Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))
- )
-
- if FaceType==10 then (
- for x = 1 to ColFaceCount do (
- fa=readshort f #unsigned + 1
- fb=readshort f #unsigned + 1
- fc=readshort f #unsigned + 1
- append faceArray2 [fc,fb,fa]
- )
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- FaceOrderCount=(readlong f+1)
-
- for i=1 to ColFaceCount do (
- readshort f
- )
-
- Print ("Face Order End @ 0x"+((bit.intAsHex(ftell f))as string))
- )
-
- msh2 = mesh vertices:vertArray2 faces:faceArray2
- msh2.name=(("Collison Mesh_")+i as string)
-
- fseek f 0x5B #seek_cur
-
- Print ("BNE Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- BNECount=readlong f
- pad2=readbyte f
- for i=1 to BNECount do (
- getPos = ftell f + 112
- fseek f getPos #seek_set
- )
-
- Print ("BNE @ 0x"+((bit.intAsHex(ftell f))as string))
-
- fseek f 0x1C #seek_cur
-
- FaceOrderCount2=(readlong f)
-
- for i=1 to FaceOrderCount2 do (
- readbyte f
- )
- Print ("NXE End @ 0x"+((bit.intAsHex(ftell f))as string))
- )
-
- fseek f 0x2 #seek_cur
-
- if NumMorph[1]==0 then
- for i = 1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- UVarray=#()
-
- Print ("Mesh Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- print (VertexCount[1] as string)
-
- VertexStart=ftell f
-
- for x =1 to VertexCount[1] do (
- getPos = ftell f + 24
- vx = readHalfFloat f
- vy = readHalfFloat f
- vz = readHalfFloat f
- fseek f 0xA #seek_cur
- tu = readHalfFloat f
- tv = readHalfFloat f*-1
- fseek f getPos #seek_set
- append vertArray ([-vx,-vz,vy]*100)
- append UVarray [tu,tv,0]
- )
-
- Print ("Mesh End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- FaceStart = (ftell f)
- faceOffset = (MeshInfoArray[i].FacePos)*2
-
- fseek f (FaceStart+faceOffset) #seek_set
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
- fa=readshort f #unsigned + 1
- fb=readshort f #unsigned + 1
- fc=readshort f #unsigned + 1
- append faceArray [fc,fb,fa]
- )
-
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- fseek f VertexStart #seek_set
-
- msh = mesh vertices:vertArray faces:faceArray
- msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
- msh.numTVerts = UVarray.count
- buildTVFaces msh
- for j = 1 to UVarray.count do setTVert msh j UVarray[j]
- for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
- )
- if NumMorph[1]!=0 then
- for i = 1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- UVarray=#()
-
- Print ("Mesh Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- print (VertexCount[1] as string)
-
- VertexStart=ftell f
-
- for x =1 to VertexCount[1] do (
- getPos = ftell f + 24
- vx = readHalfFloat f
- vy = readHalfFloat f
- vz = readHalfFloat f
- fseek f 0xA #seek_cur
- tu = readHalfFloat f
- tv = readHalfFloat f*-1
- fseek f getPos #seek_set
- append vertArray ([-vx,-vz,vy]*100)
- append UVarray [tu,tv,0]
- )
-
- FaceStart = (ftell f)
- faceOffset = (MeshInfoArray[i].FacePos)*2
-
- fseek f (FaceStart+faceOffset) #seek_set
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
- fa=readshort f #unsigned + 1
- fb=readshort f #unsigned + 1
- fc=readshort f #unsigned + 1
- append faceArray [fc,fb,fa]
- )
-
- Print ("Face End @ 0x"+((bit.intAsHex(ftell f))as string))
-
- fseek f VertexStart #seek_set
-
- msh = mesh vertices:vertArray faces:faceArray
- msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
- msh.numTVerts = UVarray.count
- buildTVFaces msh
- for j = 1 to UVarray.count do setTVert msh j UVarray[j]
- for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
- )
- )
- -----------------------------------------------------------------------------------------
- if StaticOrRigged==71 or StaticOrRigged==82 then
- if StrCheck!="NXSMESH" then (
- print "Type 71+StaticNoCollision"
- fseek f 0x0 #seek_set
- for i=1 to MeshCount do (
-
- vertArray=#()
- faceArray =#()
- UVarray=#()
-
- fseek f 0x2 #seek_cur
-
- Print ("Mesh Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- print (VertexCount[1] as string)
-
- for x =1 to VertexCount[1] do (
- getPos = ftell f + 24
- vx = readHalfFloat f
- vy = readHalfFloat f
- vz = readHalfFloat f
- fseek f 0xA #seek_cur
- tu = readHalfFloat f
- tv = readHalfFloat f*-1
- fseek f getPos #seek_set
- append vertArray ([-vx,-vz,vy]*100)
- append UVarray [tu,tv,0]
- )
-
- FaceStart = (ftell f)
- faceOffset = (MeshInfoArray[i].FacePos)*2
-
- fseek f (FaceStart+faceOffset) #seek_set
-
- Print ("Face Start @ 0x"+((bit.intAsHex(ftell f))as string))
-
- for x = 1 to (MeshInfoArray[i].FaceCount)/3 do (
- fa=readshort f #unsigned + 1
- fb=readshort f #unsigned + 1
- fc=readshort f #unsigned + 1
- append faceArray [fc,fb,fa]
- )
-
- msh = mesh vertices:vertArray faces:faceArray
- msh.name=((MeshInfoArray[i].meshname)+"_"+i as string)
- msh.numTVerts = UVarray.count
- buildTVFaces msh
- for j = 1 to UVarray.count do setTVert msh j UVarray[j]
- for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
- )
- )
- ---------------------------------------------------------------------------------------------------------
- fclose g
- fclose f