Advertisement
_keegan_

Untitled

Feb 1st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. clearlistener()
  2. /*
  3. Art Station dat Files
  4.  
  5. (c) 2015 by Taylor Mouse
  6.  
  7. v1.0 Initial script
  8. v1.1 Clean up
  9. */
  10.  
  11. /* Data from the json file */
  12. file = @"C:\Downloads\Rosomak\mesh0.dat"
  13.  
  14. theName = "sp_rosomak_ads_123"
  15. indexCount = 98280
  16. wireCount = 88808
  17. indexTypeSize = 2
  18. vertexCount = 28184
  19. offset = ( indexCount + wireCount ) * indexTypeSize
  20.  
  21. stream = fopen file "rb"
  22.  
  23. /* INDICES */
  24. indices = #()
  25. faces = #()
  26.  
  27. if( indexTypeSize == 2) then
  28. (
  29. for i = 1 to (indexCount / 3) do
  30. (
  31. a = ( readshort stream #unsigned ) + 1
  32. b = ( readshort stream #unsigned ) + 1
  33. c = ( readshort stream #unsigned) + 1
  34.  
  35. append faces [a,b,c]
  36.  
  37. )
  38. )
  39. if( indexTypeSize == 4) then
  40. (
  41. for i = 1 to indexCount do
  42. (
  43. a = ( readshort stream #unsigned ) + 1
  44. b = ( readshort stream #unsigned ) + 1
  45. c = ( readshort stream #unsigned) + 1
  46. d = ( readshort stream #unsigned) + 1
  47.  
  48. append faces [a,b,c,d]
  49.  
  50. )
  51. )
  52.  
  53.  
  54. /* VERTICES */
  55. fseek stream offset #seek_set
  56.  
  57. vertices = #()
  58. uvs = #()
  59. normals = #()
  60. vColor = #()
  61.  
  62. for v= 1 to vertexCount do
  63. (
  64. x = readfloat stream * 20
  65. y = readfloat stream * 20
  66. z = readfloat stream * 20
  67. u = readfloat stream
  68. v = readfloat stream
  69. nx = readfloat stream
  70. ny = readfloat stream
  71. r = (readbyte stream) as integer
  72. g = (readbyte stream) as integer
  73. b = (readbyte stream) as integer
  74. a = (readbyte stream) as integer
  75.  
  76. append vertices [x,-z,y]
  77. append uvs [u,v,0.0]
  78. --append normals [nx, ny, 1.0]
  79. --append vColor [r,g,b,a]
  80.  
  81. )
  82. theMesh = mesh name:theName vertices:vertices faces:faces tverts:uvs --vnorms:normals
  83. theMesh.WireColor = Color (random 0 128) (random 0 255) (random 0 128)
  84. buildTVFaces theMesh false
  85. for i = 1 to faces.count do
  86. ( setTVFace theMesh i faces[i] )
  87.  
  88. update theMesh
  89.  
  90. fclose stream
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement