Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clearlistener()
- /*
- Art Station dat Files
- (c) 2015 by Taylor Mouse
- v1.0 Initial script
- v1.1 Clean up
- */
- /* Data from the json file */
- file = @"C:\Downloads\Rosomak\mesh0.dat"
- theName = "sp_rosomak_ads_123"
- indexCount = 98280
- wireCount = 88808
- indexTypeSize = 2
- vertexCount = 28184
- offset = ( indexCount + wireCount ) * indexTypeSize
- stream = fopen file "rb"
- /* INDICES */
- indices = #()
- faces = #()
- if( indexTypeSize == 2) then
- (
- for i = 1 to (indexCount / 3) do
- (
- a = ( readshort stream #unsigned ) + 1
- b = ( readshort stream #unsigned ) + 1
- c = ( readshort stream #unsigned) + 1
- append faces [a,b,c]
- )
- )
- if( indexTypeSize == 4) then
- (
- for i = 1 to indexCount do
- (
- a = ( readshort stream #unsigned ) + 1
- b = ( readshort stream #unsigned ) + 1
- c = ( readshort stream #unsigned) + 1
- d = ( readshort stream #unsigned) + 1
- append faces [a,b,c,d]
- )
- )
- /* VERTICES */
- fseek stream offset #seek_set
- vertices = #()
- uvs = #()
- normals = #()
- vColor = #()
- for v= 1 to vertexCount do
- (
- x = readfloat stream * 20
- y = readfloat stream * 20
- z = readfloat stream * 20
- u = readfloat stream
- v = readfloat stream
- nx = readfloat stream
- ny = readfloat stream
- r = (readbyte stream) as integer
- g = (readbyte stream) as integer
- b = (readbyte stream) as integer
- a = (readbyte stream) as integer
- append vertices [x,-z,y]
- append uvs [u,v,0.0]
- --append normals [nx, ny, 1.0]
- --append vColor [r,g,b,a]
- )
- theMesh = mesh name:theName vertices:vertices faces:faces tverts:uvs --vnorms:normals
- theMesh.WireColor = Color (random 0 128) (random 0 255) (random 0 128)
- buildTVFaces theMesh false
- for i = 1 to faces.count do
- ( setTVFace theMesh i faces[i] )
- update theMesh
- fclose stream
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement