SHARE
TWEET

Binary short vertex W[weight] pass OBJ/3D/geometry

MaKiPL Sep 4th, 2015 (edited) 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #This deletes additional, in most cases unused weight short (signed int16) byte value
  2. #Should only be used for binary encoded vertices: short x, short y, short z, short W
  3. #Works only with 8 bytes per vertex files. Checks if Total_Length MOD(%) 8 is 0
  4. #Because: TotalLength/8 is total vertices count and should NOT BE float
  5. #Use only with custom/binary geometry formats.
  6.  
  7. import sys
  8. import os.path
  9. print 'Vertices w [weight] delete script\n By MaKiPL'
  10.  
  11. OpenFile = "StageTest.dat"   #You can change ME! :3
  12. NewFile = "StageTestNew.dat" #You can change ME also! :3
  13.  
  14. fs = open(OpenFile, "rb")
  15. buffer = fs.read()
  16. Length = len(buffer)
  17. fs.close()
  18.  
  19. if (Length % 8) != 0:
  20.         sys.exit("BAD FILE! (File_length MOD 8) IS NOT 0!")
  21.        
  22.  
  23. if os.path.exists(NewFile):
  24.         os.remove(NewFile)
  25. fw = open(NewFile, "ab")
  26. a = 8 #Bajt 7 i 8
  27. index = 2 # Index is 0 + Last one is postincernated before loop is fired
  28. fw.write(buffer[:6])
  29. while a < Length:
  30.         fw.write(buffer[a:a+6])
  31.         print "I: " + str(index) + r"/" + str(Length/8)
  32.         a = a+8
  33.         index = index + 1
  34. fw.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top