Index: release/scripts/ui/space_view3d.py =================================================================== --- release/scripts/ui/space_view3d.py (revision 32899) +++ release/scripts/ui/space_view3d.py (working copy) @@ -2167,6 +2167,7 @@ box.prop(bg, "opacity", slider=True) if bg.view_axis != 'CAMERA': + box.prop(bg, "object") box.prop(bg, "size") row = box.row(align=True) row.prop(bg, "offset_x", text="X") Index: source/blender/makesdna/DNA_view3d_types.h =================================================================== --- source/blender/makesdna/DNA_view3d_types.h (revision 32895) +++ source/blender/makesdna/DNA_view3d_types.h (working copy) @@ -65,6 +65,7 @@ typedef struct BGpic { struct BGpic *next, *prev; + struct Object *ob; struct Image *ima; struct ImageUser iuser; float xof, yof, size, blend; Index: source/blender/blenloader/intern/readfile.c =================================================================== --- source/blender/blenloader/intern/readfile.c (revision 32895) +++ source/blender/blenloader/intern/readfile.c (working copy) @@ -4581,6 +4581,7 @@ } for(bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) { + bgpic->ob= newlibadr_us(fd, sc->id.lib, bgpic->ob); bgpic->ima= newlibadr_us(fd, sc->id.lib, bgpic->ima); } if(v3d->localvd) { @@ -4791,6 +4792,7 @@ v3d->ob_centre= restore_pointer_by_name(newmain, (ID *)v3d->ob_centre, 1); for(bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) { + bgpic->ob= restore_pointer_by_name(newmain, (ID *)bgpic->ob, 1); bgpic->ima= restore_pointer_by_name(newmain, (ID *)bgpic->ima, 1); } if(v3d->localvd) { Index: source/blender/editors/space_view3d/view3d_draw.c =================================================================== --- source/blender/editors/space_view3d/view3d_draw.c (revision 32895) +++ source/blender/editors/space_view3d/view3d_draw.c (working copy) @@ -1250,8 +1250,8 @@ for ( bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next ) { - - if( (bgpic->view == 0) || /* zero for any */ + if( (bgpic->ob) || + (bgpic->view == 0) || /* zero for any */ (bgpic->view & (1<view)) || /* check agaist flags */ (rv3d->persp==RV3D_CAMOB && bgpic->view == (1<rect==NULL) IMB_rect_from_float(ibuf); + /* 3D object placement */ + if(bgpic->ob) { + if((bgpic->ob->lay & v3d->lay) && (bgpic->ob->restrictflag & OB_RESTRICT_VIEW)==0) { + Object *ob= bgpic->ob; + ImBuf *ibuf = ima ? BKE_image_get_ibuf(ima, NULL) : NULL; + float scale, ofsx, ofsy; + + //Calculate Image scale + scale = bgpic->size / (float)MAX2(ibuf->x, ibuf->y); + + //Setup GL params + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + //Set color to outline color and object alpha + glColor4f(1.0f, 1.0f, 1.0f, bgpic->blend); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + + glMultMatrixf(ob->obmat); + + ofsx= bgpic->xof * ibuf->x; + ofsy= bgpic->yof * ibuf->y; + + //Set the object scale + glScalef(scale, scale, scale); + + //Draw the Image on the screen + glaDrawPixelsTex(ofsx, ofsy, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect); + glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + + /* Reset GL settings */ + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glDisable(GL_BLEND); + } + } + /* 2D placement */ + else { if(rv3d->persp==RV3D_CAMOB) { rctf vb; @@ -1355,6 +1395,7 @@ glDepthMask(1); if(v3d->zbuf) glEnable(GL_DEPTH_TEST); + } } } } @@ -2351,8 +2392,8 @@ star_stuff_term_func); } } - if(v3d->flag & V3D_DISPBGPICS) draw_bgpic(scene, ar, v3d); } + if(v3d->flag & V3D_DISPBGPICS) draw_bgpic(scene, ar, v3d); } else { ED_region_pixelspace(ar);