Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct test
- (
- mnamesize=0,
- mname=0,
- scaleminx=0,
- scaleminy=0,
- scaleminz=0,
- scalemult=0,
- nmo=#()
- )
- Verticesarr = #()
- Polytrisarr = #()
- TexCoordsarr = #()
- FaceTexsarr = #()
- morphsarr=#()
- structarr=#()
- rollout unnamedRollout "Tri file morph" width:347 height:673
- (
- editText edt1 "" pos:[22,35] width:304 height:26
- button btn1 "Openfile" pos:[128,71] width:95 height:29
- listBox lbx1 "Morphname" pos:[24,357] width:296 height:18
- editText edt2 "" pos:[20,138] width:306 height:25
- editText edt6 "" pos:[18,198] width:309 height:25
- editText edt7 "" pos:[16,255] width:311 height:25
- editText edt8 "" pos:[16,310] width:311 height:25
- label lbl2 "Nr Morphs" pos:[21,285] width:121 height:22
- label lbl3 "nr UvVertices" pos:[19,230] width:121 height:22
- label lbl4 "nr Polytris" pos:[22,171] width:121 height:22
- label lbl5 "nr Vertices" pos:[23,108] width:121 height:22
- label lbl6 "Filename" pos:[26,8] width:121 height:22
- button btn2 "Load morph" pos:[127,623] width:95 height:28
- on btn1 pressed do
- (
- txt = GetOpenFileName \
- caption:"Open Texture File" \
- types: "tri files (*.tri)|*.tri|All Files (*.*)|*.*|"
- edt1.text= txt
- )
- fn readfile=
- (
- --f = openFile edt1.text mode:"rb"
- f=fopen edt1.text "rb"
- fseek f 0x0008 #seek_cur
- vertices=ReadLong f #unsigned
- --vertices=ReadLong f #unsigned --// number of vertices
- polytris=ReadLong f #unsigned--// number of tri faces
- polyquads=ReadLong f #unsigned--// number of quad faces
- unknown2=ReadLong f #unsigned
- unknown3=ReadLong f #unsigned
- uvvertices=ReadLong f #unsigned--// number of uv map vertices
- flags=ReadLong f #unsigned--// flags?
- --// bit 0 must be 1 or crashes
- --// bit 1 true=don't display face
- ---// bit 2 no effect?
- nummorphs=ReadLong f #unsigned--// number of morphs
- nummodifiers=ReadLong f #unsigned--// number of modifiers
- modvertices=ReadLong f #unsigned--// number of vertices to replace by modifiers
- unknown7=ReadLong f #unsigned
- unknown8=ReadLong f #unsigned
- unknown9=ReadLong f #unsigned
- unknown10=ReadLong f #unsigned
- edt2.text=vertices as string
- edt6.text=polytris as string
- edt7.text=uvvertices as string
- edt8.text=nummorphs as string
- for a=1 to vertices do
- (
- x=ReadFloat f
- y=ReadFloat f
- z=ReadFloat f
- ver = [x, y, z]
- append Verticesarr ver
- )
- for b=1 to polytris do
- (
- x=ReadLong f #unsigned
- y=ReadLong f #unsigned
- z=ReadLong f #unsigned
- ver = [x+1, y+1, z+1]
- append polytrisarr ver
- )
- for c=1 to vertices do
- (
- u=ReadFloat f
- v=ReadFloat f
- ver = [u,v]
- append TexCoordsarr ver
- )
- for d=1 to polytris do
- (
- x=ReadLong f #unsigned
- y=ReadLong f #unsigned
- z=ReadLong f #unsigned
- ver = [x, y, z]
- append FaceTexsarr ver
- )
- for d=1 to nummorphs do
- (
- testar=test()
- mnamesize=ReadLong f #unsigned
- mname=ReadString f
- scaleminx=Readbyte f #unsigned
- scaleminy=Readbyte f #unsigned
- scaleminz=Readbyte f #unsigned
- scalemult=Readbyte f #unsigned
- for l=1 to vertices do
- (
- x=ReadShort f #unsigned
- y=ReadShort f #unsigned
- z=ReadShort f #unsigned
- vers=[x,y,z]
- append testar.nmo vers
- )
- testar.mname=mname
- --append testar.nmo morphsarr
- --ver=[mnamesize,mname,scaleminx,scaleminy,scaleminz,scalemult]
- append structarr testar
- lbx1.items = append lbx1.items mname
- )
- )
- on btn2 pressed do
- (
- readfile()
- o=mesh vertices:Verticesarr faces:polytrisarr
- o.name="Skinny Morph"
- select $'Skinny Morph'
- )
- on lbx1 doubleClicked sel do
- (
- cando=#()
- --mesh vertices:structarr[sel].nmo faces:polytrisarr
- for l=1 to Verticesarr.count do
- (
- ol=structarr[sel].nmo[l]
- mok=[ol.x,ol.y,ol.z]
- mok=[ol.x,-ol.y,ol.z]
- a=Verticesarr[l].x - mok.x
- b=Verticesarr[l].y - mok.y
- c=Verticesarr[l].z - mok.z
- morpi=[a,b,c]
- meshop.setVert $ l morpi
- )
- update $
- )
- )createDialog unnamedRollout
Advertisement
Add Comment
Please, Sign In to add comment