I have two questions
- The following code generates random poses of a hand and its fingers (ive only included the pinky and wrist here to save space)
import bpy
import random
import time
import string
import random
import os
from mathutils import *
from math import *
def rand_lim(lims):
x = lims[0] + random.random() * (lims[1] - lims[0]);
return x
hand = bpy.data.objects["Armature"];
scale = rand_lim( (0.8 , 1.0) );
hand.scale = ( scale, scale, scale );
hand.rotation_mode = 'ZXY'
rx = rand_lim((-45.0,45.0)); ry = rand_lim((-45.0,45.0));rz = rand_lim((-45.0,45.0));
hand.rotation_euler = ( rx/57.3, ry/57.3, rz/57.3 );
x = rand_lim((-0.5,0.5)); y = rand_lim((-0.5,0.5)); z = rand_lim((-0.5,0.3));
hand.location = ( x , y , z );
hand_pose = hand.pose;
for bone in hand_pose.bones:
bone.rotation_mode = "XYZ";
bone.rotation_euler = (0,0,0);
# bone_name - which bone
# phi - left right angle
# theta - forward backward angle
def set_rot( pose, bone_name, phi_lims, theta_lims ):
phi = rand_lim(phi_lims);
theta = rand_lim(theta_lims);
pose.bones[bone_name].rotation_euler = ( -phi/57.3, 0 , -theta/57.3 );
set_rot(hand_pose, 'wrist', ( -10 , 10 ), ( -30 , 30 ) );
set_rot(hand_pose, 'pinkybase', ( -3 , 3 ), ( -2 , 2 ) );
set_rot(hand_pose, 'pinkylower', ( -5 , 5 ), ( -3 , 90 ) );
set_rot(hand_pose, 'pinkymiddle', ( 0 , 0 ), ( 0 , 90 ) );
set_rot(hand_pose, 'pinkytop', ( 0 , 0 ), ( 0 , 90 ) );
How can I convert this to do the same in BGE?
How can I print out the depth and color buffer of the current BGE viewport?
How do I specifically access the viewport? Is bgl.glReadPixels enough and if so on what?