Guest User

Untitled

a guest
Dec 19th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.20 KB | None | 0 0
  1. struct test
  2. (
  3. mnamesize=0,
  4. mname=0,
  5. scaleminx=0,
  6. scaleminy=0,
  7. scaleminz=0,
  8. scalemult=0,
  9. nmo=#()
  10. )
  11.  
  12. Verticesarr = #()
  13. Polytrisarr = #()
  14. TexCoordsarr = #()
  15. FaceTexsarr = #()
  16. morphsarr=#()
  17. structarr=#()
  18.  
  19.  
  20. rollout unnamedRollout "Tri file morph" width:347 height:673
  21. (
  22. editText edt1 "" pos:[22,35] width:304 height:26
  23. button btn1 "Openfile" pos:[128,71] width:95 height:29
  24. listBox lbx1 "Morphname" pos:[24,357] width:296 height:18
  25. editText edt2 "" pos:[20,138] width:306 height:25
  26. editText edt6 "" pos:[18,198] width:309 height:25
  27. editText edt7 "" pos:[16,255] width:311 height:25
  28. editText edt8 "" pos:[16,310] width:311 height:25
  29. label lbl2 "Nr Morphs" pos:[21,285] width:121 height:22
  30. label lbl3 "nr UvVertices" pos:[19,230] width:121 height:22
  31. label lbl4 "nr Polytris" pos:[22,171] width:121 height:22
  32. label lbl5 "nr Vertices" pos:[23,108] width:121 height:22
  33. label lbl6 "Filename" pos:[26,8] width:121 height:22
  34. button btn2 "Load morph" pos:[127,623] width:95 height:28
  35.  
  36. on btn1 pressed do
  37. (
  38. txt = GetOpenFileName \
  39. caption:"Open Texture File" \
  40. types: "tri files (*.tri)|*.tri|All Files (*.*)|*.*|"
  41. edt1.text= txt
  42.  
  43. )
  44.  
  45. fn readfile=
  46. (
  47. --f = openFile edt1.text mode:"rb"
  48. f=fopen edt1.text "rb"
  49. fseek f 0x0008 #seek_cur
  50. vertices=ReadLong f #unsigned
  51. --vertices=ReadLong f #unsigned --// number of vertices
  52. polytris=ReadLong f #unsigned--// number of tri faces
  53. polyquads=ReadLong f #unsigned--// number of quad faces
  54. unknown2=ReadLong f #unsigned
  55. unknown3=ReadLong f #unsigned
  56. uvvertices=ReadLong f #unsigned--// number of uv map vertices
  57. flags=ReadLong f #unsigned--// flags?
  58. --// bit 0 must be 1 or crashes
  59. --// bit 1 true=don't display face
  60. ---// bit 2 no effect?
  61. nummorphs=ReadLong f #unsigned--// number of morphs
  62. nummodifiers=ReadLong f #unsigned--// number of modifiers
  63. modvertices=ReadLong f #unsigned--// number of vertices to replace by modifiers
  64. unknown7=ReadLong f #unsigned
  65. unknown8=ReadLong f #unsigned
  66. unknown9=ReadLong f #unsigned
  67. unknown10=ReadLong f #unsigned
  68. edt2.text=vertices as string
  69. edt6.text=polytris as string
  70. edt7.text=uvvertices as string
  71. edt8.text=nummorphs as string
  72. for a=1 to vertices do
  73. (
  74. x=ReadFloat f
  75. y=ReadFloat f
  76. z=ReadFloat f
  77. ver = [x, y, z]
  78. append Verticesarr ver
  79. )
  80.  
  81. for b=1 to polytris do
  82. (
  83. x=ReadLong f #unsigned
  84. y=ReadLong f #unsigned
  85. z=ReadLong f #unsigned
  86. ver = [x+1, y+1, z+1]
  87. append polytrisarr ver
  88. )
  89. for c=1 to vertices do
  90. (
  91. u=ReadFloat f
  92. v=ReadFloat f
  93. ver = [u,v]
  94. append TexCoordsarr ver
  95. )
  96.  
  97. for d=1 to polytris do
  98. (
  99. x=ReadLong f #unsigned
  100. y=ReadLong f #unsigned
  101. z=ReadLong f #unsigned
  102. ver = [x, y, z]
  103. append FaceTexsarr ver
  104. )
  105.  
  106. for d=1 to nummorphs do
  107. (
  108. testar=test()
  109. mnamesize=ReadLong f #unsigned
  110. mname=ReadString f
  111. scaleminx=Readbyte f #unsigned
  112. scaleminy=Readbyte f #unsigned
  113. scaleminz=Readbyte f #unsigned
  114. scalemult=Readbyte f #unsigned
  115. for l=1 to vertices do
  116. (
  117. x=ReadShort f #signed
  118. y=ReadShort f #signed
  119. z=ReadShort f #signed
  120. vers=[x,y,z]
  121. append testar.nmo vers
  122. )
  123. testar.mname=mname
  124. --append testar.nmo morphsarr
  125. --ver=[mnamesize,mname,scaleminx,scaleminy,scaleminz,scalemult]
  126. append structarr testar
  127. lbx1.items = append lbx1.items mname
  128.  
  129. )
  130.  
  131. )
  132.  
  133. on btn2 pressed do
  134. (
  135. readfile()
  136. o=mesh vertices:Verticesarr faces:polytrisarr
  137. o.name="Skinny Morph"
  138. select $'Skinny Morph'
  139. )
  140.  
  141. on lbx1 doubleClicked sel do
  142. (
  143. cando=#()
  144. --mesh vertices:structarr[sel].nmo faces:polytrisarr
  145. for l=1 to Verticesarr.count do
  146. (
  147. ol=structarr[sel].nmo[l]
  148. mok=[ol.x,ol.y,ol.z]
  149. --mok=[ol.x,-ol.y,ol.z]
  150. a=Verticesarr[l].x + mok.x / 100000
  151. b=Verticesarr[l].y + mok.y / 100000
  152. c=Verticesarr[l].z + mok.z / 100000
  153. morpi=[a,b,c]
  154. meshop.setVert $ l morpi
  155. )
  156. update $
  157. )
  158.  
  159. )createDialog unnamedRollout
Advertisement
Add Comment
Please, Sign In to add comment