本文整理汇总了C++中copy_m3_m4函数的典型用法代码示例。如果您正苦于以下问题:C++ copy_m3_m4函数的具体用法?C++ copy_m3_m4怎么用?C++ copy_m3_m4使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copy_m3_m4函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: env_rotate_scene
void env_rotate_scene(Render *re, float mat[4][4], int do_rotate)
{
GroupObject *go;
ObjectRen *obr;
ObjectInstanceRen *obi;
LampRen *lar = NULL;
HaloRen *har = NULL;
float imat[3][3], mat_inverse[4][4], smat[4][4], tmat[4][4], cmat[3][3], tmpmat[4][4];
int a;
if (do_rotate == 0) {
invert_m4_m4(tmat, mat);
copy_m3_m4(imat, tmat);
copy_m4_m4(mat_inverse, mat);
}
else {
copy_m4_m4(tmat, mat);
copy_m3_m4(imat, mat);
invert_m4_m4(mat_inverse, tmat);
}
for (obi = re->instancetable.first; obi; obi = obi->next) {
/* append or set matrix depending on dupli */
if (obi->flag & R_DUPLI_TRANSFORMED) {
copy_m4_m4(tmpmat, obi->mat);
mul_m4_m4m4(obi->mat, tmat, tmpmat);
}
else if (do_rotate == 1)
copy_m4_m4(obi->mat, tmat);
else
unit_m4(obi->mat);
copy_m3_m4(cmat, obi->mat);
invert_m3_m3(obi->nmat, cmat);
transpose_m3(obi->nmat);
/* indicate the renderer has to use transform matrices */
if (do_rotate == 0)
obi->flag &= ~R_ENV_TRANSFORMED;
else {
obi->flag |= R_ENV_TRANSFORMED;
copy_m4_m4(obi->imat, mat_inverse);
}
}
for (obr = re->objecttable.first; obr; obr = obr->next) {
for (a = 0; a < obr->tothalo; a++) {
if ((a & 255) == 0) har = obr->bloha[a >> 8];
else har++;
mul_m4_v3(tmat, har->co);
}
/* imat_ren is needed for correct texture coordinates */
mul_m4_m4m4(obr->ob->imat_ren, re->viewmat, obr->ob->obmat);
invert_m4(obr->ob->imat_ren);
}
开发者ID:JasonWilkins,项目名称:blender-viewport_fx,代码行数:60,代码来源:envmap.c
示例2: add_primitive_bone
/* v3d and rv3d are allowed to be NULL */
void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d)
{
Object *obedit = scene->obedit; // XXX get from context
bArmature *arm = obedit->data;
float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
EditBone *bone;
/* Get inverse point for head and orientation for tail */
invert_m4_m4(obedit->imat, obedit->obmat);
mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
copy_m3_m4(obmat, rv3d->viewmat);
else unit_m3(obmat);
copy_m3_m4(viewmat, obedit->obmat);
mul_m3_m3m3(totmat, obmat, viewmat);
invert_m3_m3(imat, totmat);
ED_armature_deselect_all(obedit, 0);
/* Create a bone */
bone = ED_armature_edit_bone_add(arm, "Bone");
arm->act_edbone = bone;
copy_v3_v3(bone->head, curs);
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
else
add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:34,代码来源:armature_add.c
示例3: walk_ray_cast
/**
* \param ray_distance Distance to the hit point
* \param r_location Location of the hit point
* \param r_normal Normal of the hit surface, transformed to always face the camera
*/
static bool walk_ray_cast(bContext *C, RegionView3D *rv3d, WalkInfo *walk, float r_location[3], float r_normal[3], float *ray_distance)
{
float dummy_dist_px = 0;
float ray_normal[3] = {0, 0, 1}; /* forward */
float ray_start[3];
float mat[3][3]; /* 3x3 copy of the view matrix so we can move along the view axis */
bool ret;
*ray_distance = TRANSFORM_DIST_MAX_RAY;
copy_v3_v3(ray_start, rv3d->viewinv[3]);
copy_m3_m4(mat, rv3d->viewinv);
mul_m3_v3(mat, ray_normal);
mul_v3_fl(ray_normal, -1);
normalize_v3(ray_normal);
ret = snapObjectsRayEx(CTX_data_scene(C), NULL, NULL, NULL, NULL, SCE_SNAP_MODE_FACE,
NULL, NULL,
ray_start, ray_normal, ray_distance,
NULL, &dummy_dist_px, r_location, r_normal, SNAP_ALL);
/* dot is positive if both rays are facing the same direction */
if (dot_v3v3(ray_normal, r_normal) > 0) {
copy_v3_fl3(r_normal, -r_normal[0], -r_normal[1], -r_normal[2]);
}
/* artifically scale the distance to the scene size */
*ray_distance /= walk->grid;
return ret;
}
开发者ID:Bforartists,项目名称:Bforartists,代码行数:39,代码来源:view3d_walk.c
示例4: object_origin_clear_exec
static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
float *v1, *v3;
float mat[3][3];
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
if (ob->parent) {
/* vectors pointed to by v1 and v3 will get modified */
v1 = ob->loc;
v3 = ob->parentinv[3];
copy_m3_m4(mat, ob->parentinv);
negate_v3_v3(v3, v1);
mul_m3_v3(mat, v3);
}
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
CTX_DATA_END;
DAG_ids_flush_update(bmain, 0);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:28,代码来源:object_transform.c
示例5: setLocalConstraint
void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
if (t->flag & T_EDIT) {
float obmat[3][3];
copy_m3_m4(obmat, t->scene->obedit->obmat);
normalize_m3(obmat);
setConstraint(t, obmat, mode, text);
}
else {
if (t->total == 1) {
setConstraint(t, t->data->axismtx, mode, text);
}
else {
strncpy(t->con.text + 1, text, 48);
copy_m3_m3(t->con.mtx, t->data->axismtx);
t->con.mode = mode;
getConstraintMatrix(t);
startConstraint(t);
t->con.drawExtra = drawObjectConstraint;
t->con.applyVec = applyObjectConstraintVec;
t->con.applySize = applyObjectConstraintSize;
t->con.applyRot = applyObjectConstraintRot;
t->redraw = 1;
}
}
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:27,代码来源:transform_constraints.c
示例6: ED_armature_transform_bones
void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4])
{
EditBone *ebone;
float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
float mat3[3][3];
copy_m3_m4(mat3, mat);
normalize_m3(mat3);
/* Do the rotations */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
float tmat[3][3];
/* find the current bone's roll matrix */
ED_armature_ebone_to_mat3(ebone, tmat);
/* transform the roll matrix */
mul_m3_m3m3(tmat, mat3, tmat);
/* transform the bone */
mul_m4_v3(mat, ebone->head);
mul_m4_v3(mat, ebone->tail);
/* apply the transformed roll back */
mat3_to_vec_roll(tmat, NULL, &ebone->roll);
ebone->rad_head *= scale;
ebone->rad_tail *= scale;
ebone->dist *= scale;
/* we could be smarter and scale by the matrix along the x & z axis */
ebone->xwidth *= scale;
ebone->zwidth *= scale;
}
}
开发者ID:diekev,项目名称:blender,代码行数:34,代码来源:armature_edit.c
示例7: paintface_minmax
bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
{
const Mesh *me;
const MPoly *mp;
const MLoop *ml;
const MVert *mvert;
int a, b;
bool ok = false;
float vec[3], bmat[3][3];
me = BKE_mesh_from_object(ob);
if (!me || !me->mloopuv) {
return ok;
}
copy_m3_m4(bmat, ob->obmat);
mvert = me->mvert;
mp = me->mpoly;
for (a = me->totpoly; a > 0; a--, mp++) {
if (mp->flag & ME_HIDE || !(mp->flag & ME_FACE_SEL))
continue;
ml = me->mloop + mp->totloop;
for (b = 0; b < mp->totloop; b++, ml++) {
mul_v3_m3v3(vec, bmat, mvert[ml->v].co);
add_v3_v3v3(vec, vec, ob->obmat[3]);
minmax_v3v3_v3(r_min, r_max, vec);
}
ok = true;
}
return ok;
}
开发者ID:mgschwan,项目名称:blensor,代码行数:35,代码来源:editface.c
示例8: rigid_orthogonalize_R
static void rigid_orthogonalize_R(float R[][3])
{
HMatrix M, Q, S;
copy_m4_m3(M, R);
polar_decomp(M, Q, S);
copy_m3_m4(R, Q);
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:8,代码来源:meshlaplacian.c
示例9: init_curve_deform
static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd)
{
invert_m4_m4(ob->imat, ob->obmat);
mult_m4_m4m4(cd->objectspace, ob->imat, par->obmat);
invert_m4_m4(cd->curvespace, cd->objectspace);
copy_m3_m4(cd->objectspace3, cd->objectspace);
cd->no_rot_axis = 0;
}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:8,代码来源:lattice.c
示例10: armature_bone_primitive_add_exec
static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
Object *obedit = CTX_data_edit_object(C);
EditBone *bone;
float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
char name[MAXBONENAME];
RNA_string_get(op->ptr, "name", name);
copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C)));
/* Get inverse point for head and orientation for tail */
invert_m4_m4(obedit->imat, obedit->obmat);
mul_m4_v3(obedit->imat, curs);
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
copy_m3_m4(obmat, rv3d->viewmat);
else unit_m3(obmat);
copy_m3_m4(viewmat, obedit->obmat);
mul_m3_m3m3(totmat, obmat, viewmat);
invert_m3_m3(imat, totmat);
ED_armature_deselect_all(obedit);
/* Create a bone */
bone = ED_armature_edit_bone_add(obedit->data, name);
copy_v3_v3(bone->head, curs);
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
else
add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:41,代码来源:armature_add.c
示例11: ED_armature_ebone_from_mat4
void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4])
{
float mat3[3][3];
copy_m3_m4(mat3, mat);
/* We want normalized matrix here, to be consistent with ebone_to_mat. */
BLI_ASSERT_UNIT_M3(mat3);
sub_v3_v3(ebone->tail, ebone->head);
copy_v3_v3(ebone->head, mat[3]);
add_v3_v3(ebone->tail, mat[3]);
ED_armature_ebone_from_mat3(ebone, mat3);
}
开发者ID:mgschwan,项目名称:blensor,代码行数:13,代码来源:armature_utils.c
示例12: RotationBetween
static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3])
{
float angle, start[3], end[3];
sub_v3_v3v3(start, p1, t->center_global);
sub_v3_v3v3(end, p2, t->center_global);
// Angle around a constraint axis (error prone, will need debug)
if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) {
float axis[3], tmp[3];
t->con.applyRot(t, NULL, axis, NULL);
project_v3_v3v3(tmp, end, axis);
sub_v3_v3v3(end, end, tmp);
project_v3_v3v3(tmp, start, axis);
sub_v3_v3v3(start, start, tmp);
normalize_v3(end);
normalize_v3(start);
cross_v3_v3v3(tmp, start, end);
if (dot_v3v3(tmp, axis) < 0.0f)
angle = -acosf(dot_v3v3(start, end));
else
angle = acosf(dot_v3v3(start, end));
}
else {
float mtx[3][3];
copy_m3_m4(mtx, t->viewmat);
mul_m3_v3(mtx, end);
mul_m3_v3(mtx, start);
angle = atan2f(start[1], start[0]) - atan2f(end[1], end[0]);
}
if (angle > (float)M_PI) {
angle = angle - 2 * (float)M_PI;
}
else if (angle < -((float)M_PI)) {
angle = 2.0f * (float)M_PI + angle;
}
return angle;
}
开发者ID:diekev,项目名称:blender,代码行数:49,代码来源:transform_snap.c
示例13: camera_frame_fit_data_init
static void camera_frame_fit_data_init(
const Scene *scene, const Object *ob,
CameraParams *params, CameraViewFrameData *data)
{
float camera_rotmat_transposed_inversed[4][4];
unsigned int i;
/* setup parameters */
BKE_camera_params_init(params);
BKE_camera_params_from_object(params, ob);
/* compute matrix, viewplane, .. */
if (scene) {
BKE_camera_params_compute_viewplane(params, scene->r.xsch, scene->r.ysch, scene->r.xasp, scene->r.yasp);
}
else {
BKE_camera_params_compute_viewplane(params, 1, 1, 1.0f, 1.0f);
}
BKE_camera_params_compute_matrix(params);
/* initialize callback data */
copy_m3_m4(data->camera_rotmat, (float (*)[4])ob->obmat);
normalize_m3(data->camera_rotmat);
/* To transform a plane which is in its homogeneous representation (4d vector),
* we need the inverse of the transpose of the transform matrix... */
copy_m4_m3(camera_rotmat_transposed_inversed, data->camera_rotmat);
transpose_m4(camera_rotmat_transposed_inversed);
invert_m4(camera_rotmat_transposed_inversed);
/* Extract frustum planes from projection matrix. */
planes_from_projmat(params->winmat,
/* left right top bottom near far */
data->plane_tx[2], data->plane_tx[0], data->plane_tx[3], data->plane_tx[1], NULL, NULL);
/* Rotate planes and get normals from them */
for (i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) {
mul_m4_v4(camera_rotmat_transposed_inversed, data->plane_tx[i]);
normalize_v3_v3(data->normal_tx[i], data->plane_tx[i]);
}
copy_v4_fl(data->dist_vals_sq, FLT_MAX);
data->tot = 0;
data->is_ortho = params->is_ortho;
if (params->is_ortho) {
/* we want (0, 0, -1) transformed by camera_rotmat, this is a quicker shortcut. */
negate_v3_v3(data->camera_no, data->camera_rotmat[2]);
data->dist_to_cam = FLT_MAX;
}
}
开发者ID:JasonWilkins,项目名称:blender-viewport_fx,代码行数:49,代码来源:camera.c
示例14: obmat_to_viewmat
static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
{
float bmat[4][4];
float tmat[3][3];
rv3d->view = RV3D_VIEW_USER; /* don't show the grid */
copy_m4_m4(bmat, ob->obmat);
normalize_m4(bmat);
invert_m4_m4(rv3d->viewmat, bmat);
/* view quat calculation, needed for add object */
copy_m3_m4(tmat, rv3d->viewmat);
mat3_to_quat(rv3d->viewquat, tmat);
}
开发者ID:greg100795,项目名称:blender-git,代码行数:15,代码来源:view3d_view.c
示例15: ED_armature_apply_transform
void ED_armature_apply_transform(Object *ob, float mat[4][4])
{
EditBone *ebone;
bArmature *arm = ob->data;
float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
float mat3[3][3];
copy_m3_m4(mat3, mat);
normalize_m3(mat3);
/* Put the armature into editmode */
ED_armature_to_edit(ob);
/* Do the rotations */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
float delta[3], tmat[3][3];
/* find the current bone's roll matrix */
sub_v3_v3v3(delta, ebone->tail, ebone->head);
vec_roll_to_mat3(delta, ebone->roll, tmat);
/* transform the roll matrix */
mul_m3_m3m3(tmat, mat3, tmat);
/* transform the bone */
mul_m4_v3(mat, ebone->head);
mul_m4_v3(mat, ebone->tail);
/* apply the transfiormed roll back */
mat3_to_vec_roll(tmat, NULL, &ebone->roll);
ebone->rad_head *= scale;
ebone->rad_tail *= scale;
ebone->dist *= scale;
/* we could be smarter and scale by the matrix along the x & z axis */
ebone->xwidth *= scale;
ebone->zwidth *= scale;
}
/* Turn the list into an armature */
ED_armature_from_edit(ob);
ED_armature_edit_free(ob);
}
开发者ID:244xiao,项目名称:blender,代码行数:44,代码来源:armature_edit.c
示例16: fix_bonelist_roll
/* also sets restposition in armature (arm_mat) */
static void fix_bonelist_roll(ListBase *bonelist, ListBase *editbonelist)
{
Bone *curBone;
EditBone *ebone;
float premat[3][3];
float postmat[3][3];
float difmat[3][3];
float imat[3][3];
for (curBone = bonelist->first; curBone; curBone = curBone->next) {
/* sets local matrix and arm_mat (restpos) */
BKE_armature_where_is_bone(curBone, curBone->parent);
/* Find the associated editbone */
for (ebone = editbonelist->first; ebone; ebone = ebone->next)
if (ebone->temp.bone == curBone)
break;
if (ebone) {
/* Get the ebone premat */
ED_armature_ebone_to_mat3(ebone, premat);
/* Get the bone postmat */
copy_m3_m4(postmat, curBone->arm_mat);
invert_m3_m3(imat, premat);
mul_m3_m3m3(difmat, imat, postmat);
#if 0
printf("Bone %s\n", curBone->name);
print_m4("premat", premat);
print_m4("postmat", postmat);
print_m4("difmat", difmat);
printf("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2])));
#endif
curBone->roll = -atan2f(difmat[2][0], difmat[2][2]);
/* and set restposition again */
BKE_armature_where_is_bone(curBone, curBone->parent);
}
fix_bonelist_roll(&curBone->childbase, editbonelist);
}
}
开发者ID:bitfusionio,项目名称:blender,代码行数:43,代码来源:armature_utils.c
示例17: walkApply
static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
{
#define WALK_ROTATE_FAC 2.2f /* more is faster */
#define WALK_TOP_LIMIT DEG2RADF(85.0f)
#define WALK_BOTTOM_LIMIT DEG2RADF(-80.0f)
#define WALK_MOVE_SPEED base_speed
#define WALK_BOOST_FACTOR ((void)0, walk->speed_factor)
/* walk mode - Ctrl+Shift+F
* a walk loop where the user can move move the view as if they are in a walk game
*/
RegionView3D *rv3d = walk->rv3d;
ARegion *ar = walk->ar;
float mat[3][3]; /* 3x3 copy of the view matrix so we can move along the view axis */
float dvec[3] = {0.0f, 0.0f, 0.0f}; /* this is the direction that's added to the view offset per redraw */
/* Camera Uprighting variables */
float upvec[3] = {0.0f, 0.0f, 0.0f}; /* stores the view's up vector */
int moffset[2]; /* mouse offset from the views center */
float tmp_quat[4]; /* used for rotating the view */
#ifdef NDOF_WALK_DEBUG
{
static unsigned int iteration = 1;
printf("walk timer %d\n", iteration++);
}
#endif
{
/* mouse offset from the center */
copy_v2_v2_int(moffset, walk->moffset);
/* apply moffset so we can re-accumulate */
walk->moffset[0] = 0;
walk->moffset[1] = 0;
/* revert mouse */
if (walk->is_reversed) {
moffset[1] = -moffset[1];
}
/* Should we redraw? */
if ((walk->active_directions) ||
moffset[0] || moffset[1] ||
walk->teleport.state == WALK_TELEPORT_STATE_ON ||
walk->gravity_state != WALK_GRAVITY_STATE_OFF)
{
float dvec_tmp[3];
/* time how fast it takes for us to redraw,
* this is so simple scenes don't walk too fast */
double time_current;
float time_redraw;
#ifdef NDOF_WALK_DRAW_TOOMUCH
walk->redraw = 1;
#endif
time_current = PIL_check_seconds_timer();
time_redraw = (float)(time_current - walk->time_lastdraw);
walk->time_lastdraw = time_current;
/* base speed in m/s */
walk->speed = WALK_MOVE_SPEED;
if (walk->is_fast) {
walk->speed *= WALK_BOOST_FACTOR;
}
else if (walk->is_slow) {
walk->speed *= 1.0f / WALK_BOOST_FACTOR;
}
copy_m3_m4(mat, rv3d->viewinv);
{
/* rotate about the X axis- look up/down */
if (moffset[1]) {
float angle;
float y;
/* relative offset */
y = (float) moffset[1] / ar->winy;
/* speed factor */
y *= WALK_ROTATE_FAC;
/* user adjustement factor */
y *= walk->mouse_speed;
/* clamp the angle limits */
/* it ranges from 90.0f to -90.0f */
angle = -asinf(rv3d->viewmat[2][2]);
if (angle > WALK_TOP_LIMIT && y > 0.0f)
y = 0.0f;
else if (angle < WALK_BOTTOM_LIMIT && y < 0.0f)
y = 0.0f;
//.........这里部分代码省略.........
开发者ID:Bforartists,项目名称:Bforartists,代码行数:101,代码来源:view3d_walk.c
示例18: make_child_duplis_faces
static void make_child_duplis_faces(const DupliContext *ctx, void *userdata, Object *inst_ob)
{
FaceDupliData *fdd = userdata;
MPoly *mpoly = fdd->mpoly, *mp;
MLoop *mloop = fdd->mloop;
MVert *mvert = fdd->mvert;
float (*orco)[3] = fdd->orco;
MLoopUV *mloopuv = fdd->mloopuv;
int a, totface = fdd->totface;
bool use_texcoords = ELEM(ctx->eval_ctx->mode, DAG_EVAL_RENDER, DAG_EVAL_PREVIEW);
float child_imat[4][4];
DupliObject *dob;
invert_m4_m4(inst_ob->imat, inst_ob->obmat);
/* relative transform from parent to child space */
mul_m4_m4m4(child_imat, inst_ob->imat, ctx->object->obmat);
for (a = 0, mp = mpoly; a < totface; a++, mp++) {
MLoop *loopstart = mloop + mp->loopstart;
float space_mat[4][4], obmat[4][4];
if (UNLIKELY(mp->totloop < 3))
continue;
/* obmat is transform to face */
get_dupliface_transform(mp, loopstart, mvert, fdd->use_scale, ctx->object->dupfacesca, obmat);
/* make offset relative to inst_ob using relative child transform */
mul_mat3_m4_v3(child_imat, obmat[3]);
/* XXX ugly hack to ensure same behavior as in master
* this should not be needed, parentinv is not consistent
* outside of parenting.
*/
{
float imat[3][3];
copy_m3_m4(imat, inst_ob->parentinv);
mul_m4_m3m4(obmat, imat, obmat);
}
/* apply obmat _after_ the local face transform */
mul_m4_m4m4(obmat, inst_ob->obmat, obmat);
/* space matrix is constructed by removing obmat transform,
* this yields the worldspace transform for recursive duplis
*/
mul_m4_m4m4(space_mat, obmat, inst_ob->imat);
dob = make_dupli(ctx, inst_ob, obmat, a, false, false);
if (use_texcoords) {
float w = 1.0f / (float)mp->totloop;
if (orco) {
int j;
for (j = 0; j < mp->totloop; j++) {
madd_v3_v3fl(dob->orco, orco[loopstart[j].v], w);
}
}
if (mloopuv) {
int j;
for (j = 0; j < mp->totloop; j++) {
madd_v2_v2fl(dob->uv, mloopuv[mp->loopstart + j].uv, w);
}
}
}
/* recursion */
make_recursive_duplis(ctx, inst_ob, space_mat, a, false);
}
}
开发者ID:DrangPo,项目名称:blender,代码行数:70,代码来源:object_dupli.c
示例19: snap_sel_to_grid_exec
static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
RegionView3D *rv3d = CTX_wm_region_data(C);
TransVertStore tvs = {NULL};
TransVert *tv;
float gridf, imat[3][3], bmat[3][3], vec[3];
int a;
gridf = rv3d->gridview;
if (obedit) {
if (ED_transverts_check_obedit(obedit))
ED_transverts_create_from_obedit(&tvs, obedit, 0);
if (tvs.transverts_tot == 0)
return OPERATOR_CANCELLED;
copy_m3_m4(bmat, obedit->obmat);
invert_m3_m3(imat, bmat);
tv = tvs.transverts;
for (a = 0; a < tvs.transverts_tot; a++, tv++) {
copy_v3_v3(vec, tv->loc);
mul_m3_v3(bmat, vec);
add_v3_v3(vec, obedit->obmat[3]);
vec[0] = gridf * floorf(0.5f + vec[0] / gridf);
vec[1] = gridf * floorf(0.5f + vec[1] / gridf);
vec[2] = gridf * floorf(0.5f + vec[2] / gridf);
sub_v3_v3(vec, obedit->obmat[3]);
mul_m3_v3(imat, vec);
copy_v3_v3(tv->loc, vec);
}
ED_transverts_update_obedit(&tvs, obedit);
ED_transverts_free(&tvs);
}
else {
struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID);
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan;
bArmature *arm = ob->data;
invert_m4_m4(ob->imat, ob->obmat);
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone->flag & BONE_SELECTED) {
if (pchan->bone->layer & arm->layer) {
if ((pchan->bone->flag & BONE_CONNECTED) == 0) {
float nLoc[3];
/* get nearest grid point to snap to */
copy_v3_v3(nLoc, pchan->pose_mat[3]);
/* We must operate in world space! */
mul_m4_v3(ob->obmat, nLoc);
vec[0] = gridf * floorf(0.5f + nLoc[0] / gridf);
vec[1] = gridf * floorf(0.5f + nLoc[1] / gridf);
vec[2] = gridf * floorf(0.5f + nLoc[2] / gridf);
/* Back in object space... */
mul_m4_v3(ob->imat, vec);
/* Get location of grid point in pose space. */
BKE_armature_loc_pose_to_bone(pchan, vec, vec);
/* adjust location */
if ((pchan->protectflag & OB_LOCK_LOCX) == 0)
pchan->loc[0] = vec[0];
if ((pchan->protectflag & OB_LOCK_LOCY) == 0)
pchan->loc[1] = vec[1];
if ((pchan->protectflag & OB_LOCK_LOCZ) == 0)
pchan->loc[2] = vec[2];
/* auto-keyframing */
ED_autokeyframe_pchan(C, scene, ob, pchan, ks);
}
/* if the bone has a parent and is connected to the parent,
* don't do anything - will break chain unless we do auto-ik.
*/
}
}
}
ob->pose->flag |= (POSE_LOCKED | POSE_DO_UNLOCK);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
else {
vec[0] = -ob->obmat[3][0] + gridf * floorf(0.5f + ob->obmat[3][0] / gridf);
vec[1] = -ob->obmat[3][1] + gridf * floorf(0.5f + ob->obmat[3][1] / gridf);
vec[2] = -ob->obmat[3][2] + gridf * floorf(0.5f + ob->obmat[3][2] / gridf);
if (ob->parent) {
float originmat[3][3];
BKE_object_where_is_calc_ex(scene, NULL, ob, originmat);
invert_m3_m3(imat, originmat);
mul_m3_v3(imat, vec);
//.........这里部分代码省略.........
开发者ID:diekev,项目名称:blender,代码行数:101,代码来源:view3d_snap.c
示例20: snap_curs_to_sel_ex
static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
{
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
TransVertStore tvs = {NULL};
TransVert *tv;
float bmat[3][3], vec[3], min[3], max[3], centroid[3];
int count, a;
count = 0;
INIT_MINMAX(min, max);
zero_v3(centroid);
if (obedit) {
if (ED_transverts_check_obedit(obedit))
ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS | TM_SKIP_HANDLES);
if (tvs.transverts_tot == 0) {
return false;
}
copy_m3_m4(bmat, obedit->obmat);
tv = tvs.transverts;
for (a = 0; a < tvs.transverts_tot; a++, tv++) {
copy_v3_v3(vec, tv->loc);
mul_m3_v3(bmat, vec);
add_v3_v3(vec, obedit->obmat[3]);
add_v3_v3(centroid, vec);
minmax_v3v3_v3(min, max, vec);
}
if (v3d->around == V3D_AROUND_CENTER_MEAN) {
mul_v3_fl(centroid, 1.0f / (float)tvs.transverts_tot);
copy_v3_v3(cursor, centroid);
}
else {
mid_v3_v3v3(cursor, min, max);
}
ED_transverts_free(&tvs);
}
else {
Object *obact = CTX_data_active_object(C);
if (obact && (obact->mode & OB_MODE_POSE)) {
bArmature *arm = obact->data;
bPoseChannel *pchan;
for (pchan = obact->pose->chanbase.first; pchan; pchan = pchan->next) {
if (arm->layer & pchan->bone->layer) {
if (pchan->bone->flag & BONE_SELECTED) {
copy_v3_v3(vec, pchan->pose_head);
mul_m4_v3(obact->obmat, vec);
add_v3_v3(centroid, vec);
minmax_v3v3_v3(min, max, vec);
count++;
}
}
}
}
else {
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{
copy_v3_v3(vec, ob->obmat[3]);
/* special case for camera -- snap to bundles */
if (ob->type == OB_CAMERA) {
/* snap to bundles should happen only when bundles are visible */
if (v3d->flag2 & V3D_SHOW_RECONSTRUCTION) {
bundle_midpoint(scene, ob, vec);
}
}
add_v3_v3(centroid, vec);
minmax_v3v3_v3(min, max, vec);
count++;
}
CTX_DATA_END;
}
if (count == 0) {
return false;
}
if (v3d->around == V3D_AROUND_CENTER_MEAN) {
mul_v3_fl(centroid, 1.0f / (float)count);
copy_v3_v3(cursor, centroid);
}
else {
mid_v3_v3v3(cursor, min, max);
}
}
开发者ID:diekev,项目名称:blender,代码行数:94,代码来源:view3d_snap.c
注:本文中的copy_m3_m4函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论