Ejemplo n.º 1
0
/* if we have strokes for scenes (3d view)/clips (movie clip editor)
 * and objects/tracks, multiple data blocks have to be drawn */
static void gp_draw_data_all(Scene *scene, bGPdata *gpd, int offsx, int offsy, int winx, int winy,
                             int cfra, int dflag, const char spacetype)
{
	bGPdata *gpd_source = NULL;
	
	if (scene) {
		if (spacetype == SPACE_VIEW3D) {
			gpd_source = (scene->gpd ? scene->gpd : NULL);
		}
		else if (spacetype == SPACE_CLIP && scene->clip) {
			/* currently drawing only gpencil data from either clip or track, but not both - XXX fix logic behind */
			gpd_source = (scene->clip->gpd ? scene->clip->gpd : NULL);
		}
		
		if (gpd_source) {
			gp_draw_data(gpd_source, offsx, offsy, winx, winy, cfra, dflag);
		}
	}
	
	/* scene/clip data has already been drawn, only object/track data is drawn here
	 * if gpd_source == gpd, we don't have any object/track data and we can skip */
	if (gpd_source == NULL || (gpd_source && gpd_source != gpd)) {
		gp_draw_data(gpd, offsx, offsy, winx, winy, cfra, dflag);
	}
}
Ejemplo n.º 2
0
void draw_gpencil_view3d (Scene *scene, View3D *v3d, ARegion *ar, short only3d)
{
    bGPdata *gpd;
    int dflag = 0;
    rcti rect;
    RegionView3D *rv3d= ar->regiondata;

    /* check that we have grease-pencil stuff to draw */
    gpd= gpencil_data_get_active_v3d(scene); // XXX
    if (gpd == NULL) return;

    /* when rendering to the offscreen buffer we don't want to
     * deal with the camera border, otherwise map the coords to the camera border. */
    if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_RENDER_OGL)) {
        rctf rectf;
        ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &rectf, TRUE); /* no shift */
        BLI_copy_rcti_rctf(&rect, &rectf);
    }
    else {
        rect.xmin = 0;
        rect.ymin = 0;
        rect.xmax = ar->winx;
        rect.ymax = ar->winy;
    }

    /* draw it! */
    if (only3d) dflag |= (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_NOSTATUS);

    gp_draw_data(gpd, rect.xmin, rect.ymin, rect.xmax, rect.ymax, CFRA, dflag);
}
Ejemplo n.º 3
0
// XXX porting note, ogl render will probably be a window with one 3d region
void draw_gpencil_oglrender (bContext *C)
{
	ScrArea *sa= CTX_wm_area(C);
	View3D *v3d= (View3D *)sa->spacedata.first;
	ARegion *ar= CTX_wm_region(C);
	Scene *scene= CTX_data_scene(C);
	bGPdata *gpd;
	
	/* assume gpencil data comes from v3d */
	if (v3d == NULL) return;
	gpd= gpencil_data_get_active(C);
	if (gpd == NULL) return;
	
	/* pass 1: draw 3d-strokes ------------ > */
	gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, (GP_DRAWDATA_NOSTATUS|GP_DRAWDATA_ONLY3D));
	
	/* pass 2: draw 2d-strokes ------------ > */
		/* adjust view matrices */
	wmOrtho2(-0.375f, (float)(ar->winx)-0.375f, -0.375f, (float)(ar->winy)-0.375f); // XXX may not be correct anymore
	glLoadIdentity();
	
		/* draw it! */
	gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, GP_DRAWDATA_NOSTATUS);
}
Ejemplo n.º 4
0
/* draw grease-pencil sketches to specified 3d-view assuming that matrices are already set correctly 
 * Note: this gets called twice - first time with only3d=1 to draw 3d-strokes, second time with only3d=0 for screen-aligned strokes
 */
void draw_gpencil_3dview (bContext *C, short only3d)
{
	ARegion *ar= CTX_wm_region(C);
	Scene *scene= CTX_data_scene(C);
	bGPdata *gpd;
	int dflag = 0;
	
	/* check that we have grease-pencil stuff to draw */
	gpd= gpencil_data_get_active(C); // XXX
	if (gpd == NULL) return;
	
	/* draw it! */
	if (only3d) dflag |= (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_NOSTATUS);
	gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag);
}
Ejemplo n.º 5
0
/* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly 
 * Note: this gets called twice - first time with onlyv2d=1 to draw 'canvas' strokes, second time with onlyv2d=0 for screen-aligned strokes
 */
void draw_gpencil_2dview (bContext *C, short onlyv2d)
{
	ScrArea *sa= CTX_wm_area(C);
	ARegion *ar= CTX_wm_region(C);
	Scene *scene= CTX_data_scene(C);
	bGPdata *gpd;
	int dflag = 0;
	
	/* check that we have grease-pencil stuff to draw */
	if (sa == NULL) return;
	gpd= gpencil_data_get_active(C); // XXX
	if (gpd == NULL) return;
	
	/* special hack for Image Editor */
	// FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled
	if (sa->spacetype == SPACE_IMAGE)
		dflag |= GP_DRAWDATA_IEDITHACK;
	
	/* draw it! */
	if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D|GP_DRAWDATA_NOSTATUS);
	gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag);
}
Ejemplo n.º 6
0
/* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */
void draw_gpencil_2dimage (bContext *C, ImBuf *ibuf)
{
	ScrArea *sa= CTX_wm_area(C);
	ARegion *ar= CTX_wm_region(C);
	Scene *scene= CTX_data_scene(C);
	bGPdata *gpd;
	int offsx, offsy, sizex, sizey;
	int dflag = GP_DRAWDATA_NOSTATUS;
	
	/* check that we have grease-pencil stuff to draw */
	if (ELEM(NULL, sa, ibuf)) return;
	gpd= gpencil_data_get_active(C); // XXX
	if (gpd == NULL) return;
	
	/* calculate rect */
	switch (sa->spacetype) {
		case SPACE_IMAGE: /* image */
		{
			
			/* just draw using standard scaling (settings here are currently ignored anyways) */
			// FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled
			offsx= 0;
			offsy= 0;
			sizex= ar->winx;
			sizey= ar->winy;
			
			wmOrtho2(ar->v2d.cur.xmin, ar->v2d.cur.xmax, ar->v2d.cur.ymin, ar->v2d.cur.ymax);
			
			dflag |= GP_DRAWDATA_ONLYV2D|GP_DRAWDATA_IEDITHACK;
		}
			break;
			
		case SPACE_SEQ: /* sequence */
		{
			SpaceSeq *sseq= (SpaceSeq *)sa->spacedata.first;
			float zoom, zoomx, zoomy;
			
			/* calculate accessory values */
			zoom= (float)(SEQ_ZOOM_FAC(sseq->zoom));
			if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
				/* XXX sequencer zoom should store it? */
				zoomx = zoom; //  * ((float)G.scene->r.xasp / (float)G.scene->r.yasp);
				zoomy = zoom;
			} 
			else
				zoomx = zoomy = zoom;
			
			/* calculate transforms (Note: we use ibuf here, as we have it) */
			sizex= (int)(zoomx * ibuf->x);
			sizey= (int)(zoomy * ibuf->y);
			offsx= (int)( (ar->winx-sizex)/2 + sseq->xof );
			offsy= (int)( (ar->winy-sizey)/2 + sseq->yof );
			
			dflag |= GP_DRAWDATA_ONLYI2D;
		}
			break;
			
		default: /* for spacetype not yet handled */
			offsx= 0;
			offsy= 0;
			sizex= ar->winx;
			sizey= ar->winy;
			
			dflag |= GP_DRAWDATA_ONLYI2D;
			break;
	}
	
	
	/* draw it! */
	gp_draw_data(gpd, offsx, offsy, sizex, sizey, CFRA, dflag);
}