# ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### #Author Stephen Jones. www.sjonesart.com/gl.php. Copy and paste into #Blender's Text windoaw and hit alt p after altering filename below. import import import import

bpy mathutils os collections

#you need to alter this to reflect where you want to store your xml file filename='C:\\c#\\Tutorials\\08ShadedTextures\\Game\\Scene\\assets\\xml\\pillar.xml' frame=1 class Struct: def __init__ (self, *argv, **argd): if len(argd): # Update by dictionary self.__dict__.update (argd) else: # Update by position attrs = filter (lambda x: x[0:2] != "__", dir(self)) for n in range(len(argv)): setattr(self, attrs[n], argv[n]) class Vat(Struct): faceIndex=0 v1=v2=v3=v4=0 vert1=vert2=vert3=vert4=mathutils.Vector() coord1=coord2=coord3=coord4=mathutils.Vector() norm1=norm2=norm3=norm4=mathutils.Vector() tan1=tan2=tan3=tan4=mathutils.Vector() def roundVec3(v): return round(v[0], 4), round(v[1], 4), round(v[2], 4) def roundVec2(v): #uv values are 1.0 - uv to spin things around to fit the geometry return round(v[0], 4), round(v[1], 4) flippy=mathutils.Matrix() flippy[1].y=0.0 flippy[1].z=-1.0 flippy[2].y=1.0

flippy[2].z=0.0

context=bpy.context scene=context.scene scene.frame_set(frame) scene.update obj=context.object mesh=obj.to_mesh(scene, True, 'PREVIEW') mesh.transform(obj.matrix_world) mesh.transform(flippy)

smooth=mesh.faces[0].use_smooth quads=list() tris=list() count=0 #get face index, add to Vat object and store Vat in either tri or quad list for f in mesh.faces: tmp=Vat() tmp.faceIndex=f.index if len(f.vertices)==3: tris.append(tmp) if len(f.vertices)==4: quads.append(tmp) #get data for tris and add to respective Vat for t in tris: t.v1=mesh.faces[t.faceIndex].vertices[0] t.v2=mesh.faces[t.faceIndex].vertices[1] t.v3=mesh.faces[t.faceIndex].vertices[2] for t in tris: t.vert1=roundVec3(tuple(mesh.vertices[t.v1].co)) t.vert2=roundVec3(tuple(mesh.vertices[t.v2].co)) t.vert3=roundVec3(tuple(mesh.vertices[t.v3].co)) if mesh.faces[q.faceIndex].use_smooth: t.norm1=roundVec3(tuple(mesh.vertices[t.v1].normal)) t.norm2=roundVec3(tuple(mesh.vertices[t.v2].normal)) t.norm3=roundVec3(tuple(mesh.vertices[t.v3].normal)) else: t.norm1=roundVec3(tuple(mesh.faces[t.faceIndex].normal)) t.norm2=roundVec3(tuple(mesh.faces[t.faceIndex].normal)) t.norm3=roundVec3(tuple(mesh.faces[t.faceIndex].normal)) t.coords1=roundVec2(tuple(mesh.uv_textures[0].data[t.faceIndex].uv1)) t.coords2=roundVec2(tuple(mesh.uv_textures[0].data[t.faceIndex].uv2)) t.coords3=roundVec2(tuple(mesh.uv_textures[0].data[t.faceIndex].uv3)) #get data for quads and add to respective Vat for q in quads: q.v1=mesh.faces[q.faceIndex].vertices[0] q.v2=mesh.faces[q.faceIndex].vertices[1] q.v3=mesh.faces[q.faceIndex].vertices[2] q.v4=mesh.faces[q.faceIndex].vertices[3] for q in quads: q.vert1=roundVec3(tuple(mesh.vertices[q.v1].co)) q.vert2=roundVec3(tuple(mesh.vertices[q.v2].co))

q.vert3=roundVec3(tuple(mesh.vertices[q.v3].co)) q.vert4=roundVec3(tuple(mesh.vertices[q.v4].co)) if mesh.faces[q.faceIndex].use_smooth: q.norm1=roundVec3(tuple(mesh.vertices[q.v1].normal)) q.norm2=roundVec3(tuple(mesh.vertices[q.v2].normal)) q.norm3=roundVec3(tuple(mesh.vertices[q.v3].normal)) q.norm4=roundVec3(tuple(mesh.vertices[q.v4].normal)) else: q.norm1=roundVec3(tuple(mesh.faces[q.faceIndex].normal)) q.norm2=roundVec3(tuple(mesh.faces[q.faceIndex].normal)) q.norm3=roundVec3(tuple(mesh.faces[q.faceIndex].normal)) q.norm4=roundVec3(tuple(mesh.faces[q.faceIndex].normal)) q.coords1=roundVec2(tuple(mesh.uv_textures[0].data[q.faceIndex].uv1)) q.coords2=roundVec2(tuple(mesh.uv_textures[0].data[q.faceIndex].uv2)) q.coords3=roundVec2(tuple(mesh.uv_textures[0].data[q.faceIndex].uv3)) q.coords4=roundVec2(tuple(mesh.uv_textures[0].data[q.faceIndex].uv4))

#calculate tangents and add to Vat def cross(u, v): ret=mathutils.Vector() ret.x=u[1]*v[2]-u[2]-v[1] ret.y=u[2]*v[0]-u[0]*v[2] ret.z=u[0]*v[1]-u[1]*v[0] return roundVec3(ret) up=mathutils.Vector() up.y=1.0 for t in tris: if t.norm1[0]==up[0] and t.norm1[1]==up[1] and t.norm1[2]==up[2]: print("same") t.tan1=cross(up, t.norm1) if t.norm2[0]==up[0] and t.norm2[1]==up[1] and t.norm2[2]==up[2]: print("same") t.tan2=cross(up, t.norm2) if t.norm3[0]==up[0] and t.norm3[1]==up[1] and t.norm3[2]==up[2]: print("same") t.tan3=cross(up, t.norm3) for q in quads: if q.norm1[0]==up[0] and q.norm1[1]==up[1] print("same") q.tan1=cross(up, q.norm1) if q.norm2[0]==up[0] and q.norm2[1]==up[1] print("same") q.tan2=cross(up, q.norm2) if q.norm3[0]==up[0] and q.norm3[1]==up[1] print("same") q.tan3=cross(up, q.norm3) if q.norm4[0]==up[0] and q.norm4[1]==up[1] print("same") q.tan4=cross(up, q.norm4)

#multiply vertex positions by 10 def mult(v, n): ret=mathutils.Vector() ret.x=v[0]*n

and q.norm1[2]==up[2]:

and q.norm2[2]==up[2]:

and q.norm3[2]==up[2]:

and q.norm4[2]==up[2]:

ret.y=v[1]*n ret.z=v[2]*n return roundVec3(ret) for t in tris: t.vert1=mult(t.vert1, 10) t.vert2=mult(t.vert2, 10) t.vert3=mult(t.vert3, 10) for q in quads: q.vert1=mult(q.vert1, q.vert2=mult(q.vert2, q.vert3=mult(q.vert3, q.vert4=mult(q.vert4,

10) 10) 10) 10)

#construct xml print strings tv="" tn="" tc="" tt=""

for t in tris: tv=tv + "%.6f tv=tv + "%.6f tv=tv + "%.6f tn=tn + "%.6f tn=tn + "%.6f tn=tn + "%.6f tc=tc + "%.6f tc=tc + "%.6f tc=tc + "%.6f tt=tt + "%.6f tt=tt + "%.6f tt=tt + "%.6f

%.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f

%.6f " %t.vert1 %.6f " %t.vert2 %.6f " %t.vert3 %.6f " %t.norm1 %.6f " %t.norm2 %.6f " %t.norm3 " %t.coords1 " %t.coords2 " %t.coords3 %.6f " %t.tan1 %.6f " %t.tan2 %.6f " %t.tan3

%.6f %.6f %.6f %.6f %.6f

%.6f %.6f %.6f %.6f %.6f

tv=tv.rstrip(' ') tv=tv + "
\n" tn=tn.rstrip(' ') tn=tn + "\n" tc=tc.rstrip(' ') tc=tc + "\n" tt=tt.rstrip(' ') tt=tt + "\n"

qv="" qn="" qc="" qt=""

for q in quads: qv=qv + "%.6f qv=qv + "%.6f qv=qv + "%.6f qv=qv + "%.6f qn=qn + "%.6f

" " " " "

%q.vert1 %q.vert2 %q.vert3 %q.vert4 %q.norm1

qn=qn qn=qn qn=qn qc=qc qc=qc qc=qc qc=qc qt=qt qt=qt qt=qt qt=qt

+ + + + + + + + + + +

"%.6f "%.6f "%.6f "%.6f "%.6f "%.6f "%.6f "%.6f "%.6f "%.6f "%.6f

%.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f %.6f

%.6f " %q.norm2 %.6f " %q.norm3 %.6f " %q.norm4 " %q.coords1 " %q.coords2 " %q.coords3 " %q.coords4 %.6f " %q.tan1 %.6f " %q.tan2 %.6f " %q.tan3 %.6f " %q.tan4

qv=qv.rstrip(' ') qv=qv + "
\n" qn=qn.rstrip(' ') qn=qn + "\n" qc=qc.rstrip(' ') qc=qc + "\n" qt=qt.rstrip(' ') qt=qt + "\n"

file=open(filename, 'w') file.write('\n') file.write('\n') file.write(tv) file.write(tn) file.write(tc) file.write(tt) file.write(qv) file.write(qn) file.write(qc) file.write(qt) file.write(' \n') file.write('back.png\n') file.write('subwayHKwall_n.png\n') file.write('subwayHKpillar_t.png\n') file.write("") file.close()

Blender 2_59 12_7_11.pdf

#Author Stephen Jones. www.sjonesart.com/gl.php. Copy and paste into. #Blender's Text windoaw and hit alt p after altering filename below. import bpy.

33KB Sizes 3 Downloads 155 Views

Recommend Documents

Computer Science E-259 Lectures - Computer Science E-259: XML ...
Sep 17, 2007 - most important new technology development of the last two years." Michael Vizard ... applications: what are the tools and technologies necessary to put ... XML. When. ▫ The World Wide Web Consortium (W3C) formed an XML.

Computer Science E-259
Oct 1, 2007 - structure and content of an XML document. ▫ SAX does this by the type and order of events that are invoked. ▫ DOM does this by using objects in ...

AP-259.pdf
memory-mapped, and portions of memory may be. shared between the 82786 and the CPU. 7-234. Page 3 of 18. AP-259.pdf. AP-259.pdf. Open. Extract.

Computer Science E-259
Oct 1, 2007 - By Definition. ▫ The result of parsing a document with a DOM parser is a. DOM tree that matches the structure of that document. ▫ After parsing is ...

Computer Science E-259
Dec 3, 2007 - Redefines simple and complex types, groups, and attribute groups from an external schema redefine. Describes the format of non-XML data ...

Computer Science E-259
Jan 7, 2008 - Yahoo! UI Library http://developer.yahoo.com/yui/ ..... how to program in JavaScript and PHP, how to configure. Apache and MySQL, how to ...

Computer Science E-259
Nov 19, 2007 - labeling the information content of diverse data sources .... .... ELEMENT article (url, headline_text, source, media_type, cluster,.

Computer Science E-259
Oct 1, 2007 - DOCTYPE students SYSTEM "student.dtd">.

Computer Science E-259
Nov 29, 2007 - these foundations, the course will explore in detail a number of case studies that utilize XML in e-business: e-commerce, web personalization, ...

Blender Python Script
Apr 24, 2013 - sequence so that computer generated imagery (CGI) could be .... Press “a” twice to select all objects, then press “Delete” on your keyboard ...

Computer Science E-259
Nov 19, 2007 - ELEMENT article (url, headline_text, source, media_type, cluster, tagline, document_url ... http://www.oasis-open.org/specs/index.php#dbv4.1.

Computer Science E-259
Oct 22, 2007 - Computer Science E-259. XML with Java. Lecture 5: ... XPath 1.0. ▫ Location Paths. ▫ Data Types ... Data Types. ▫ boolean. ▫ number. ▫ string.

Computer Science E-259
Nov 29, 2007 - students with previous Java programming and web development experience, this course introduces XML as a key enabling technology in today's e-business applications. Students will learn the fundamentals of XML: schemas, XSL stylesheets,

Computer Science E-259
Oct 22, 2007 - 6. Copyright © 2007, David J. Malan . All Rights Reserved. XSLT 1.0, Continued. Data Types. ▫ boolean. ▫ number. ▫ string. ▫ node-set. ▫ external object. ▫ result tree fragment ...

Computer Science E-259
Jan 7, 2008 - . 4019 2445 .... with SQL, and how to use Ajax with both XML and JSON. The course ...

GO Ms 259.pdf
Sign in. Loading… Page 1. Whoops! There was a problem loading more pages. Retrying... GO Ms 259.pdf. GO Ms 259.pdf. Open. Extract. Open with. Sign In.

pdf blender tutorial
File: Pdf blender tutorial. Download now. Click here if your download doesn't start automatically. Page 1 of 1. pdf blender tutorial. pdf blender tutorial. Open.

Blender Hotkeys Cheatsheet.pdf
Sign in. Loading… Whoops! There was a problem loading more pages. Retrying... Whoops! There was a problem previewing this document. Retrying.

Blender Encyclopedia Modifiers-Anderson Baptista-blenderguru.com.pdf
... last month, trying out every single modifier and creating examples for each... So let's tackle each one (starting from left to right). The Modify group. Mesh Cache.

Computer Science E-259 - Fas Harvard
Cut through the hype and get to the value. ▫ Focus on. ▫ practicality: what you need to know to do real work. ▫ applications: what are the tools and technologies.

Computer Science E-259 - Fas Harvard
Computer Science E-259. XML with Java. Lecture 5: XPath 1.0 (and 2.0) and XSLT ... All Rights Reserved. Computer Science E-259. Last Time. ▫ CSS Level 2.

Computer Science E-259 - Fas Harvard
Page 2 .... . . .... unidirectional hyperlinks of today's HTML, as well as.

Computer Science E-259 - Fas Harvard
All Rights Reserved. Computer Science E-259. XML with Java. Lecture 2: XML 1.1 and SAX 2.0.2. 24 September 2007. David J. Malan [email protected] ...