Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- f=open("Ezreal.obj","r")
- lines=f.readlines()
- f.close()
- verticies=[]
- faces=[]
- texture=(0,0)
- colors=["1,0,0,1","0,1,0,1","0,0,1,1"]
- vertcount=0
- elementcount=0
- facecheck1=0
- facecheck2=0
- facecount=0
- for line in lines:
- if line.startswith("v "):
- verts=line.split(" ")
- verticies.append((verts[1],verts[2],verts[3].split("\n")[0]))
- facecheck1+=1
- vertcount+=3
- if line.startswith("f "):
- face=line.split(" ")
- del face[0]
- faces.append((face[0].split("/")[0],face[1].split("/")[0],face[2].split("/")[0]))
- elementcount+=3
- facecheck2+=1
- facecount+=1
- print face[0].split("/")[0],face[1].split("/")[0],face[2].split("/")[0]
- f=open("Ezrealarray.txt","w")
- f.write("float tri[]={")
- for vert in verticies:
- f.write(vert[0]+","+vert[1]+","+vert[2]+","+random.choice(colors)+",0,0,"+"\n")
- f.write("};")
- f.close()
- f=open("Ezrealelementarray.txt","w")
- f.write("unsigned int ind[]={")
- for face in faces:
- f.write(face[0]+","+face[1]+","+face[2]+",\n")
- f.write("};")
- f.close()
- print "This object has:"
- print vertcount,"verticies"
- print elementcount,"elements"
- if facecheck1==facecheck2:
- print "faces number match in verticies and elements."
- print facecount,"faces"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement