This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def selected_vertex(): | |
for vert in bpy.context.selected_objects[0].data.vertices: | |
if vert.select: | |
return vert; | |
return None | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bmesh | |
def normalize_selected(): | |
m = bpy.context.active_object.data # get selected object's mesh | |
bm = bmesh.new() # create an empty BMesh | |
bm.from_mesh(m) # fill it in from a Mesh | |
for v in bm.verts: | |
if v.select: | |
v.co.normalize() | |
bm.to_mesh(m) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A blender script that creates a triangular grid of different blends of three meshes | |
# of identical topology in a triangle. | |
# | |
# 'a', 'b', and 'c' are the meshes to be blended. | |
# 'n' is the "height" of the triangle | |
# 'side' is the length of the side of the triangle in which the | |
# blended meshes will be arranged | |
def blendingTriangle(scene, a, b, c, n, side): | |
index = 0; | |
# the vertices of the positions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make sure to add references to Newtonsoft.Json.dll and System.Core.dll into Tools\Options\Scripting\References | |
// e.g., C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Core.dll;C:\Users\username\AppData\Local\Programs\Fiddler\Newtonsoft.Json.dll | |
public static void OnBeforeResponse(Session oSession) | |
{ | |
if (m_Hide304s && oSession.responseCode == 304) | |
{ | |
oSession["ui-hide"] = "true"; | |
} | |
if (oSession.oRequest.host == "www.myhost.com" && |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following function is adapted from | |
# Nick Keeline "Cloud Generator" addNewObject | |
# from object_cloud_gen.py (an addon that comes with the Blender 2.6 package) | |
# Create a clone of object "coypobj" at all vertices in the "verticesFrom" object | |
# Usage example: cloneAtVertices(bpy.context.scene, bpy.data.objects['ball'], bpy.data.objects['positions']) | |
def cloneAtVertices(scene, copyobj, verticesFrom): | |
index = 0; | |
for v in verticesFrom.data.vertices: | |
index = index + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function download(url, name) { | |
fetch(url) | |
.then(resp => resp.blob()) | |
.then(blob => { | |
const url = window.URL.createObjectURL(blob); | |
const a = document.createElement('a'); | |
a.style.display = 'none'; | |
a.href = url; | |
a.download = name; | |
document.body.appendChild(a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double2 cartesianToPolar(double2 z) | |
{ | |
return double2(length(z), atan2(z.y, z.x)); | |
} | |
double2 polarToCartesian(double2 p) | |
{ | |
return double2(p.x * cos(p.y), p.x * sin(p.y)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float loopWithPause(float scale) { | |
// sinusoidal, with a short pause at start/end | |
float overshoot = 1.5; | |
// iTime is a variable available in shadertoy.com | |
// Replace with your own variable as needed | |
float t = iTime * scale; // scale time here | |
float a = clamp((mod(t, 2.0) - 1.0) * overshoot, -1.0, 1.0); | |
return sin(a * PI); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec2 clamp(vec2 p) { | |
return clamp(p, 0, 1); | |
} | |
vec2 repeat(vec2 p) { | |
return fract(p); | |
} | |
vec2 mirrorRepeat(vec2 p) { | |
vec2 q = fract(p * 0.5) * 2.0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming triangle side, x = 1 unit | |
# Height of triangle, H = sqrt(x) * x / 2 = 0.866025403784438 | |
# Height of centroid h = x / (2 * sqrt(3)) = 0.288675134594812; 2h = 0.577350269189624 | |
# Lower Right Vertex: (x/2, -h) | |
v 0.5 -0.288675134594812 0 | |
# Top Vertex: (0, 2h) | |
v 0 0.577350269189624 0 | |
# Lower Left Vertex (-x/2, -h) | |
v -0.5 -0.288675134594812 0 | |
# Note: OBJ format uses 1-based indexing, not 0-based |
OlderNewer