06-3DRenderingandIllum

06-3DRenderingandIll - How to Make a Brush Now that weve got all the background lets make a brush Intro to 3D Rendering and Illumination Lecture 6

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Intro to 3D Rendering Intro to 3D Rendering and Illumination and Illumination Lecture 6 CPSC 478/578 Spring 2005 How to Make a Brush ± Now that we’ve got all the background, lets make a brush! Example. . .triangleBrush! ± Make a copy of pointBrush.h/cpp and rename them triangleBrush.h/cpp. ± Add them to the impressionist project. ± Go through the code and change all pointBrush labels to triangleBrush. PointBrush class PointBrush : public ImpBrush { public: PointBrush( ImpressionistDoc* pDoc = NULL, char* name = NULL ); void BrushBegin( const Point source, const Point target ); void BrushMove( const Point source, const Point target ); void BrushEnd( const Point source, const Point target ); char* BrushName( void ); }; Brushmaking, continued. . . ± Now, open up impressionistDoc.cpp ± Add triangleBrush.h to the includes ± Scroll down a bit, and add triangleBrush to the selectable brushes. Pick a constant for it. ± Go to ImpBrush.h and add the constant for triangleBrush to the enum. ± Go to impressionistUI.cpp, and add the triangle brush to the brush menu. Sample Code ImpBrush::c_pBrushes[BRUSH_LINES] = new PointBrush( this, "Lines" ); ImpBrush::c_pBrushes[BRUSH_SCATTERED_POINTS] = new PointBrush( this, "Scattered Points" ); ImpBrush::c_pBrushes[BRUSH_SCATTERED_LINES] = new PointBrush( this, "Scattered Lines" ); ImpBrush::c_pBrushes[BRUSH_SCATTERED_CIRCLES] = new PointBrush( this, "Scattered Circles" ); enum { BRUSH_POINTS = 0, BRUSH_LINES, BRUSH_SCATTERED_POINTS, BRUSH_SCATTERED_LINES, BRUSH_SCATTERED_CIRCLES, NUM_BRUSH_TYPE // Make sure this stays at the end! }; Brushmaking, continued again ± Run Impressionist. See the triangle brush. And, well, see the triangle brush make points instead of triangles. ± Open triangleBrush.cpp and go to BrushMove. Here’s what’s there now: glBegin( GL_POINTS ); SetColor( source ); glVertex2d( target.x, target.y ); glEnd(); ± Triangles need 3 vertices. Let’s center ours around the target point where the user clicked. ± How do we do this?
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Brushmaking, continued again ± We do it like so: int size = pDoc->getSize(); int Ax,Ay,Bx,By,Cx,Cy; Ax = target.x - (.5*size); Ay = target.y - (.5*size); Bx = target.x + (.5*size); By = target.y - (.5*size); Cx = target.x; Cy = target.y + (.5*size); glBegin( GL_POLYGON ); SetColor( source ); glVertex2i( Ax, Ay ); glVertex2i( Bx, By ); glVertex2i( Cx, Cy ); glEnd(); Filter Kernel Hints ± Remember how filter kernels are applied to an image. Look at sample program. void ImpressionistDoc::applyFilter(…) ± What could go wrong? ± What cases should we handle? One sample case: how do you handle the case if the filter kernel is partially outside the original image? ± We will be looking closely at your filter kernel. void ImpressionistDoc::applyFilter( const unsigned char* sourceBuffer, int srcBufferWidth, int srcBufferHeight, unsigned char* destBuffer, const double *filterKernel, int knlWidth, int knlHeight, double divisor, double offset ) { // This needs to be implemented for image filtering to work.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/21/2009 for the course CPSC 478 taught by Professor Hollyrushmeier during the Spring '05 term at Yale.

Page1 / 9

06-3DRenderingandIll - How to Make a Brush Now that weve got all the background lets make a brush Intro to 3D Rendering and Illumination Lecture 6

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online