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>

drawing in OpenGL ES 2.0 on Android

This is the drawing part. Beware of texture uniform. It looks a bit strange but otherwise causes some error. With "glUniform1i(loc_myTex, texID);" instead of "glUniform1i(loc_myTex, 0);", no texture is seen. void MyObject::draw() { // glBi…

How to set window flags in Android NDK

Full screen mode for example, ANativeActivity_setWindowFlags(app->activity, AWINDOW_FLAG_FULLSCREEN, 0); where app is the ptr to struct android_app defined in android_native_app_glue.h.This function is the NDK version of android.view.Windo…

When you change API level on Eclipse,

You have to adjust both project property and AndroidManifest.xml.

When you want preference screen in live wallpaper,

(1) put in AndroidManifest.xml(2)put android:settingsActivity="com.foo.FooSettings" in tab in foo.xml under @xml(3)write foo_settings.xml and string.xml then put them into @xml and @value respectively.(4)write Java codes using addPreferenc…

EGL in Android NDK

EGL is only supported after android-9, that is, OS 2.3.1 Gingerbread.

W/O Lighting

glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); consumes 64Kbytes more than glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); in top RSS. The difference looks very small. :)

Loading texture in OpenGL

The order of gl-functions in loadTex is critical. typedef struct TextureInfo_ { int width; int height; int pixelSize; int colorType; // int algnType; // 0=unsigned char, 1=uint32_t void* pPix; int id; const char* fileName; } TextureInfo; v…

undocumented native window format in NDK

You can find only 3 formats in android/native_window.h. enum { WINDOW_FORMAT_RGBA_8888 = 1, WINDOW_FORMAT_RGBX_8888 = 2, WINDOW_FORMAT_RGB_565 = 4, }; But actually, it has others. When you set up the attributes like this const EGLint attri…

Android NDK: read JPG from assets and sdcard

Some parts of the code are borrowed from Independent JPEG Group and Android NDKでlibjpegをビルドして利用する(UsefullCode.net)Resulted texture will have dummy alpha components (0xff) for compatibility with PNG. static uint32_t make8888(int …

how to import existing files as an Eclipse project

1)make sure no project is selected2)file->import->Existing Projects into Work Space3)select root directry4)check "Copy projects into workspace" (*IMPORTANT this may overwrite existing project)5)refresh 6)finish

fseek doesn't look working

void myLoadAsset(AAssetManager* mngr){ const char imageFilename[] = "myImage.png"; AAsset* asset = AAssetManager_open(mngr, imageFilename, AASSET_MODE_UNKNOWN); FILE* fp = (FILE*)AAsset_getBuffer(asset); // AAsset_seek(asset, 1000, SEEK_SE…

asset manager const void* AAsset_getBuffer(AAsset* asset);

const void* AAsset_getBuffer(AAsset* asset);Dianne Hackborn says: I suggest not using getBuffer() for a compressed file. It really only make sense for a file that isn't compressed, where this can give you a direct pointer to the mmapped da…

object types in ndk assetmanager

getBuffer returns the pointer to the mmapped image of the asset. openFileDescriptor returns the file descriptor to the mmapped image of the asset. fdopen(file descriptor) returns the pointer to the WHOLE package(.apk).