Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
29 views

Fractal Tree Project

Uploaded by

Jaid Mulla UT
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Fractal Tree Project

Uploaded by

Jaid Mulla UT
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Fractal Tree

Project Submitted to the Savitribai Phule Pune University


in partial
fulfillment of the requirements for the award of the Degree of
BACHELOR’S IN COMPUTER SCIENCE

By
Mulla Jaid Munnabhai.
Seat Number:-27.
and
Mahangade Vandan Deepak.
Seat Number:-29.

Name of the Guide


Prof.Kharade.G.

Savitribai Phule Pune University


2019-20
Vidya Pratishthan’s

ARTS, SCIENCE & COMMERCE COLLEGE


Vidyanagari, Baramati, Dist. Pune (413 133) Phone / Fax No. : 91-02112-243488 Resi. : 243832
 Affiliated to PuneUniversity I.D. No. : PU/PN/ASC/101/1994  Jr. College Code No.: J 11.02.016
‘BEST COLLEGE AWARD’ by PuneUniversity, Pune  NAAC reaccredited ‘B+’ Grade

‘BEST PRINCIPAL AWARD’ by PuneUniversity, Pune BEST VANSHRI AWARD by Mah.Govt.


--------------------------------------------------------------------------------------------------------

CERTIFICATE

This is to certify that the project entitled “Fractal Tree” is the


bonafide project work carried out by Mr. Mulla Jaid Munnabhai and
Mr. Mahangade Vandan Deepak student of BSc.(Computer Science)
Savitribai Phule Pune University, Pune, during the year 2019-2020, in
partial fulfillment of the requirements for the award of the Degree
Bachelors’ in Computer Science and that the project has not formed the
basis for the award previously of any degree, diploma, associate ship,
fellowship or any other similar title.

Project Guide H.O.D.


Department,
Computer Science

Internal Examiner External Examiner

Place: Baramati
Date: /03/2020
ACKNOWLEDGEMENT

We wish to express our thanks to “Vidya Pratishthan’s Arts,Science and


Commerce College, Baramati” for allowing us to take part in project on “Fractal
Tree”.

We are thankful to our principal who has given us the opportunity science
department & our company guide & all the friends who have always have been a
great source of inspiration for us.

We are especially thank full to those who directly or indirectly helped us in


completion of this project successfully. to do this project.

We would also like to give our sincere gratitude to Prof. Joshi G.R. (Head of
Department, Computer Science) who guided us to develop the system “Fractal
Tree”.
FRACTAL TREE
INDEX
Sr.No Topic Page No
1 Computer graphics concepts used in project. 6
2 OpenGL library and methods used in project. 7
3 Code. 9
4 Output Screen. 21
5 Bibliography. 22
Computer graphics concepts used in project

Computer graphics is all about producing pictures by computer. Computer


graphics concepts used in project are:

1.Pixel or point:

A computer image is made up of a number of tiny dots or


“Pictures elements”. These are called pixels. The location of a pixel is represented
as a pair(x,y)in 2-D space or a triplet(x,y,z) in three dimensional space. The
attributes of a point are color and thickness.

2.Resolution:

The maximum number of pixels that can be displayed on the screen


without overlap is called the resolution. It is expressed as a the number of pixels
displayed horizontally X maximum no of pixels displayed vertically.

3.Curves:

Many graphics system support common special cases of curves such as


circles, ellipse, circular arcs and Bezier. Curves are approximated using polylines
and made up of short segment.
OpenGL library and methods used in project

OpenGL library:
GL utility toolkit-provides function for opening windows, managing
,menus and managing events.
1. glClear Basic GL:

Provides basic set of function.


2. GLUT:

OpenGL methods:

1. glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,ch[i]):-
2. glLoadIdentity():- Reset The Projection Matrix
3. ghRasterPos2f(xpos,ypos):-
4. glClearColor():-set display window color
5. glBegin(GL_QUADS):-Start draw a polygon
6. glColor3f():- Set ball color
7. glVertex2f():- Define the vertex
8. glClear():-Clear display window.
9. glEnd():-We are done polygon
10. glTranslatef():-Move an object.
11. glPointSize():-
12. glutPostRedisplay():-
13. glMatrixMode(GL_PROJECTION):-Specifies the weather projection will modify
using argument GL_PROJECTION for mode. Subsequent command affect the
specified matrix.
14. glOrtho2D():-
15. glMatrixMode(GL_MODELVIEW):-
16. glutSwapBuffer():-
17. glutInit():-Initialise OpenGL
18. glutInitDisplayMode(GLUT_RGB/GLUT_DOUBLE):-Set display mode.
19. glutInitWindowPosition():- Set window position.
20. glutWindowSize():- Set window size.
21. glutCreateWindow():-open screen window with the specified previously
specified size position & other properties.
22. glutDisplayFunc():-Image to be drawn initially.
23. glutSpecialFunc(2specialkey):-
24. glutKeyboardFunc():-When Keyboard Is pressed.
25. glutIdleFunc(display):-Even if there are no events, redraw our gl scene.
26. glutMainLoop():-Start Event Processing Engine

Code
#include<windows.h>

#ifdef __APPLE__

#include <GLUT/glut.h>

#else

#include <GL/glut.h>

#include<GL/glu.h>

#endif

#include <stdlib.h>

int flag=1;

GLfloat angle,angle2;

int moving,startx,starty;

/* GLUT callback Handlers*/

static void resize(int width, int height)

const float ar=(float) width/(float) height;

glViewport(0, 0, width, height);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(-15.0, 15.0,-1.0, 20.0,-15.0, 15.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

void makecylinder(float height,float Base)


{

GLUquadricObj *qobj;

qobj = gluNewQuadric();

glColor3f(0.64f, 0.16f, 0.16f);

glPushMatrix();

glRotatef(-90,1.0f,0.0f,0.0f);

gluCylinder(qobj, Base, Base - (0.2* Base), height, 20, 20);

glPopMatrix();

void maketree(float height, float Base)

glPushMatrix();

float angle;

makecylinder(height, Base);

glTranslatef(0.0f, height,0.0f);

height-=height*0.2f;

Base-=Base*0.31;

for(int a=0; a<3; a++)

angle = 20+((rand()%50));

if(angle >48)

angle=-(20+((rand()%50)));

if (height > 1)

glPushMatrix();
if (flag)

glRotatef(angle, 1.0f, 0.0f, 1.0f);

else

glRotatef(angle, 0.0f, 1.0f, 1.0f);

flag = !flag;

maketree(height, Base); //recursive call

glPopMatrix();

else

glColor3f(0.0f, 1.0f/a, 0.0f);

glutSolidSphere(0.1f,10,10);// for fruits.

//Glut.glutSwapBuffers();

glPopMatrix();

static void display(void)

const double t = glutGet(GLUT_ELAPSED_TIME)/1000.0;

const double a=t*90.0;

srand(GLUT_ELAPSED_TIME);

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glLoadIdentity();

glRotatef(angle,0,1,0);
glRotatef(angle2,0,0,1);

maketree(4.0f,0.1f);

glutSwapBuffers();

glFlush();

static void key(unsigned char key, int x, int y)

switch (key)

case 27 :

case 'q':

exit(0);

break;

glutPostRedisplay();

void mouse(int btn,int state, int x,int y)

if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN)

moving=1;
startx=x;

starty=y;

if(btn==GLUT_LEFT_BUTTON && state==GLUT_UP)

moving=0;

void motion(int x,int y)

if(moving)

angle=angle+(x-startx);

angle2=angle2+(y-starty);

startx=x;

starty=y;

glutPostRedisplay();

/* Program entry point */

int main(int argc, char *argv[])

{
glutInit(&argc, argv);

glutInitWindowSize(640,480);

glutInitWindowPosition(10,10);

glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);

glutCreateWindow("GLUT Shapes");

glutReshapeFunc(resize);

glutDisplayFunc(display);

glutKeyboardFunc(key);

glutMouseFunc(mouse);

glutMotionFunc(motion);

glClearColor(1,1,1,1);

glEnable(GL_DEPTH_TEST);

glutMainLoop();

return EXIT_SUCCESS;

}
OUTPUT:
Bibliography

For the completion of our project documentation we have referred the following book.

1.Computer Graphics.

-Poonam Ponde.

2.www.graphicsminiproject.com

You might also like