Entries from 2014-01-01 to 1 year

GL test project on Eclipse with MinGW

I'm so confused in MS Windows environment...

hemisphere_saddle.py

You can twist hemisphere along x and y axis. Try rx=-1.0 (and let ry=1.0 as default), it will make a saddle. #!BPY import bpy import math def vert(n,rx,ry): yield (0.0, 0.0, 1.0) for k in range(1, n+1): theta = float(k)*math.pi/2.0/float(n…

MapVertsOnSurface_ver3.py

Dijkstra detection part is the same as dijkstra.py. If isRing is True, only verts on the shortest pathes between selected 3 verts will be mapped, otherwise all verts mapped.Now eF(evaluation function) is detachable. Choose one from distBtw…

Dijkstra.py

It takes significant time to compute. hahaha... import bmesh import math class VDijkstra: def __init__(self, vert): self.id = vert.index self.v = vert self.bestParent = None self.dist2start = float('inf') self.distances = {} # init peers s…

EnRound.py

Another version of makeRound.py.Map vertices onto a sphere with the given centre in Edit mode. The radius of sphere will be the average distance to the centre. The default centre is 3d-cursor, otherwise average(i.e. gravity) of verts.Pleas…

makeRound.py

Replace selected verts onto a circle in Edit mode. import bmesh import numpy as np def makeRound(): if bpy.ops.object.mode_set.poll(): bpy.ops.object.mode_set(mode='OBJECT', toggle=False) if bpy.ops.object.mode_set.poll(): bpy.ops.object.m…

pinch/zoom for Android Java

This humble code interpretes the distance between two pointers as the ratio. static final int NumberOfMyPointers = 2; static final float minimumDistance2object = 0.1f; static final float maximumDistance2object = 3.0f; static final float Ma…

blender exporter

import bpy import math import time import bmesh from os.path import expanduser # 2014 march 14 sphere is not yet implemented. # Inputs: # c_=cylinder, lc_=looped-cylinder, f_=frame, h_=hemisphere, l_=line, p_=pipe, r_=ribbon, s_=sphere # #…

SeamedPipe.py (includes SeamedLine)

Be aware the generated loop is incomplete. Connecting part has triangulated planes, not squared ones. (I do not know exact word for it, sorry. :( ) import math import bmesh import numpy as np ''' SeamedPipe ''' def deselect(): for x in bpy…

Saru-no-Koshikake-Broken.py

import math import bmesh def deselect(): for x in bpy.data.objects: x.select = False # bpy.ops.object.delete() # n=disks m=fins q=lenth r0=min radius, r1=max radius, s=h to w ratio def genVert(n, m, q, r0, r1, s): dR = (r1-r0)/float(n) d =…

Saru-no-Koshikake.py

import math import bmesh def deselect(): for x in bpy.data.objects: x.select = False # bpy.ops.object.delete() # n=disks m=fins q=lenth r=radius s=h to w ratio def genVert(n, m, q, r, s): d = 1.0 for i in range(n): yield(0.0, 0.0, q*float(…

detect vert-links in bmesh

# just print edges by verts for v in bm.verts: for e in v.link_edges: vv = e.other_vert(v) print(v.co, vv.co) # make verts-link list as array "xs" import bmesh ao = bpy.context.scene.objects.active m = ao.data bm = bmesh.new() bm.from_mesh…

Line 2 Window Frame Looped

# let u, v vectors on the plane. b the origin on it. # let a a point off plane. and n a normal of the plane. import sys import bmesh import numpy as np def mapOnPlane(a, b0, b1, b2): u = np.array([b1[0]-b0[0], b1[1]-b0[1], b1[2]-b0[2]]) v …

Line 2 Window Frame

# let u, v vectors on the plane. b the origin on it. # let a a point off plane. and n a normal of the plane. import sys import bmesh import numpy as np def mapOnPlane(a, b0, b1, b2): u = np.array([b1[0]-b0[0], b1[1]-b0[1], b1[2]-b0[2]]) v …

Mapping On A Plane

# let u, v vectors on the plane. b the origin on it. # let a a point off plane. and n a normal of the plane. import sys import bmesh import numpy as np def mapOnPlane(a, b0, b1, b2): u = np.array([b1[0]-b0[0], b1[1]-b0[1], b1[2]-b0[2]]) v …

Seamed Line in Blender 2.6

bl_info = { "name": "Simple Liner", "category": "Add Curve", } import bmesh ########################################## # number of edges (vertices = edges + 1) n = 3 ########################################## def genVert(n): for i in range…

GlExporter.py

import bpy import math import bmesh # Supposing every object has a name which begins with one of # followings: c_, s_, h_ # c_ stands for cylinder, s_ sphere and h_ hemisphere respectively. # 2014 march 14 sphere is not yet implemented. # …

1393249177**Still Developing* UV unwrapper for HexHemisphere only Visible Faces

import bmesh import math ''' msh = bpy.data.meshes.new('hexHemisphereMesh') obj = bpy.data.objects.new('hexHemisphere', msh) bpy.context.scene.objects.link(obj) ''' ######################### nnn = 5 ######################### #w = 1.0/float…

hemisphere visible faces only

#!BPY import bpy import math ############# n = 5 ############# m = bpy.data.meshes.new('hemisphereMesh0') o = bpy.data.objects.new('hemisphere0', m) bpy.context.scene.objects.link(o) def vert(): yield (0.0, 0.0, 1.0) for k in range(1, n+1)…

Cylinder BMesh UV mapping for Blender 2.6 or later

It seems that bmesh data are refreshed when the mode is changed from "edit" to "object", though I have not figured out the exact moment yet. The code is the same as ever. import bmesh import math msh = bpy.data.meshes.new('cylinderMesh') o…

bm.loops.layers.uv

>>> bm.loops.layers.uv <BMLayerCollection object at 0x7efeed558e90> >>> bm.loops.layers.uv.active <BMLayerItem object at 0x7efeed453a20> >>> uv_lay <BMLayerItem object at 0x7efeed453b40> >>> loop[uv_lay].uv Vector((0.20000000298023224, 35.79999923706055)) >>> loop[uv_lay] </bmlayeritem></bmlayeritem></bmlayercollection>

cylinder.py

#!BPY import bpy import math ''' for x in bpy.context.scene.objects: bpy.context.scene.objects.unlink(x) for x in bpy.data.objects: bpy.data.objects.remove(x) for x in bpy.data.objects: x.select = True bpy.ops.object.delete() ''' #########…

uv.py for Blender 2.6

import bpy import bmesh obj = bpy.context.active_object me = obj.data bm = bmesh.from_edit_mesh(me) uv_layer = bm.loops.layers.uv.verify() bm.faces.layers.tex.verify() # currently blender needs both layers. uv_lay = bm.loops.layers.uv.acti…

operator_uv.py from Blender 2.6 Python script template

import bpy import bmesh def main(context): obj = context.active_object me = obj.data bm = bmesh.from_edit_mesh(me) uv_layer = bm.loops.layers.uv.verify() bm.faces.layers.tex.verify() # currently blender needs both layers. # adjust UVs for …

Python Blender UV mapping

Vertices of the object seem to lie there: bpy.data.meshes['Icosphere'].uv_layers.data.vertices[0].co.xyz

python script for blender 2.6: hex-meshed hemisphere

#!BPY import bpy m = bpy.data.meshes.new('hemisphereMesh') o = bpy.data.objects.new('hemisphere', m) bpy.context.scene.objects.link(o) n = 30 #the number of latitudes def vert(): yield (0.0, 0.0, 1.0) for k in range(1, n+1): theta = float(…

python script on Blender 2.6

#!BPY import bpy list (bpy.data.objects) for x in bpy.context.scene.objects: bpy.context.scene.objects.unlink(x) for x in bpy.data.objects: bpy.data.objects.remove(x) for x in bpy.data.objects: x.select = True bpy.ops.object.delete() list …

triangles in COLLADA format

<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> <asset> <contributor> <author>Blender User</author> <authoring_tool>Blender 2.69.0 r60991</authoring_tool> </contributor> <created>2014-01-14T21:08:56</created> <modified>2014-01-14T…</modified></asset></collada>