You are on page 1of 64

COMPUTER GRAPHICS LAB

MR.LONELY

http://www.vidyarthiplus.com

CODING :
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<graphics.h> void mycircle(); void myellipse(); void myline(); int dx,dy,x,y,p,xa,ya,xb,yb,rx,ry; int xlen,ylen,px,py,r,ch,xc,yc; int rx1,rx2,ry1,ry2; int midx,midy,xn,grok; int st,et; void mid(int,int); void main() { int dx,dy,x,y,p; int xa,ya,xb,yb; int gdriver=DETECT,gmode,errorcode; initgraph(&gdriver,&gmode,); errorcode=graphresult(); if(errorcode!=grok) { printf(Graphics error %s,grapherrormsg(errorcode)); printf(\n Press any key to halt); getch(); exit(1); } do { printf(\n1. Circle \n2. Ellipse \n3. Line \n4. Exit); printf(\nEnter your choice: ); scanf(%d,&ch); switch(ch) { case 1: mycircle(); break; case 2: myellipse();
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

break; case 3: myline(); break; case 4: exit(0); default: printf(\nEnter correct choice); } } while(ch<=3); getch(); } void mycircle(); { printf(\nEnter the center and radius: ); scanf(%d%d%d,&xc,&yc,&r); x=0; y=r; mid(x,y); while(x<y) { if(p<0) x++; else { x++; y--; } if(p<0) p=p+2*(x+1); else p=p+2*(x-y)+1; mid(x,y); } } void myellipse() { printf(\nEnter the 8 angles: ); scanf(%d,&st); printf(\nEnter the angle: );
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

scanf(%d,&et); printf(\nEnter the rx and ry value: ); scanf(%d%d,&rx,&ry); midx=getmaxx()/2+100; midy=getmaxy()/2+100; ellipse(midx,midy,st,et,rx,ry); getch(); } void myline() { printf(\nEnter the values of xa,ya: ); scanf(%d%d,&xa,&ya); printf(\nEnter the values of xb,yb: ); scanf(%d%d,&xb,&yb); dx=abs(xa-xb); dy=abs(ya-dx); if(xa>xb) { x=xb; y=yb; xn=xa; } else { x=xa; y=ya; xn=xb; } putpixel(x,y,255); while(x<xn) { x++; if(p<0) p=p+2*dy; else { y++; p=p+2*(dy-dx); } putpixel(x,y,255); midx=getmaxx()/2;
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

midy=getmaxy()/2; } } void mid(int x,int y) { putpixel(xc+x,yc+y,255); putpixel(xc-x,yc+y,255); putpixel(xc+x,yc-y,255); putpixel(xc-x,yc-y,255); putpixel(xc+y,yc+x,255); putpixel(xc-y,yc+x,255); putpixel(xc+y,yc-x,255); putpixel(xc-y,yc-x,255); }

OUTPUT :
1. Circle 2. Ellipse 3. Line 4. Exit Enter your choice: 1 Enter the center and radius: 150 150 150

1. Circle 2. Ellipse 3. Line 4. Exit Enter your choice: 2 Enter the rx and ry values: 40 20

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

1. Circle 2. Ellipse 3. Line 4. Exit Enter your choice: 3 Enter the values of xa and ya: 100 100 Enter the values of xb and yb: 300 300

1. Circle 2. Ellipse 3. Line 4. Exit Enter your choice: 4 CODING : #include<stdio.h> #include<conio.h> #include<graphics.h> #include<string.h> void main() { char ch=y; int gd=DETECT,gm,x1,x2; int rad,sa,ea,xrad,y,yrad; initgraph(&gd,&gm,); while(ch==y) { cleardevice(); setbkcolor(9); outtextxy(100,105,Enter your choice: ); outtextxy(100,105,1. Line); outtextxy(100,105,2. Circle); outtextxy(100,105,3. Box); outtextxy(100,105,4. Arc);
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

outtextxy(100,105,5. Ellipse); outtextxy(100,105,6. Rectangle); outtextxy(100,105,7. Exit); ch=getch(); cleardevice(); switch(ch) { case 1: line(100,200,300,400); break; case 2: circle(200,200,100); break; case 3: setfillstyle(5,4); bar(100,300,200,100); break; case 4: setfillstyle(5,4); arc(200,200,100,300,100); break; case 5: setfillstyle(5,4); fillellipse(100,200,50,100); break; case 6: settextstyle(DEFAULT_FONT,0,2); line(100,100,100,300); line(300,300,100,300); line(100,100,300,100); line(300,100,300,300); break; case 7: closegraph(); return; } ch=y; getch(); } }
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

OUTPUT
1. 2. 3. 4. 5. 6. 7. Line Circle Box Arc Ellipse Rectangle Exit
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

Enter your choice: 1

1. 2. 3. 4. 5. 6. 7.

Line Circle Box Arc Ellipse Rectangle Exit

Enter your choice: 2

1. 2. 3. 4. 5. 6. 7.

Line Circle Box Arc Ellipse Rectangle Exit

Enter your choice: 3

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

1. Line 2. Circle 3. Box 4. Arc 5. Ellipse 6. Rectangle 7. Exit Enter your choice:4

1. Line 2. Circle 3. Box 4. Arc 5. Ellipse 6. Rectangle 7. Exit Enter your choice: 5

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

1. Line 2. Circle 3. Box 4. Arc 5. Ellipse 6. Rectangle 7. Exit Enter your choice: 6

1. Line 2. Circle 3. Box 4. Arc 5. Ellipse 6. Rectangle 7. Exit Enter your choice: 7

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

CODING :
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> void main() { int opt,tx,ty,an,shx,poly[50],poly1[50]; int I,n=0,t; int gd=DETECT,gm; initgraph(&gd,&gm,); printf(Enter the number of lines to draw: ); scanf(%d,&n); t=(n+1)*2; for(i=0;i<t;i+=2) { printf(\nEnter (x,y) values: ); scanf(%d%d,&poly[i],&poly1[i]); } do { Cleardevice(); for(i=0;i<=t;i++) { poly1[i]=poly[i]; poly1[i+1]=poly[i+1]; } drawpoly(n+1,poly1);
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

printf(\nBasic geometric transformation); printf(\n1. Translation\n2. Rotation\n3. Scaling); printf(\nOther transformation); printf(\n4. Reflection\n5. Shear\n6. Exit); printf(\nEnter your option: ); scanf(%d,&opt); switch(opt) { case 1: printf(\nEnter (tx,ty) values: ); scanf(%d%d,&tx,&ty); for(i=0;i<=t;i+=2) { poly[i]=poly[i+1]+tx; poly1[i+1]=poly[i+1]+ty; } drawpoly(n+1,poly1); break; case 2: printf(\nEnter the angle to rotate: ); scanf(%d,&an); for(i=0;i<=t;i+=2) { poly1[i]=(poly[i]*cos(an))-(poly[i+1]*sin(an)); poly1[i]=(poly[i]*sin(an))-(poly[i+1]*cos(an)); } drawpoly(n+1,poly1); break; case 3: printf(\nEnter scaling factor (x,y): ); scanf(%d%d,&tx,&ty); for(i=0;i<=t;i+=2) { poly1[i]=(poly[i]*tx); poly1[i+1]=(poly[i+1]*ty); } drawpoly(n+1,poly1); break; case 4: for(i=0;i<=t;i++) {
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

poly1[i]=250-poly[i]; poly1[i+1]=poly[i+1]; } drawpoly(n+1,poly1); break; case 5: printf(\nEnter the shear value: ); scanf(%d%d,&shx,&tx); for(i=0;i<=t;i+=2) { poly1[i]=poly[i]+(shx*poly[i+1]-tx); poly1[i+1]=poly[i+1]; } drawpoly(n+1,poly1); break; case 6: exit(0); } Getch(); } while(opt<6); closegraph(); }

OUTPUT :
Enter the number of lines to draw: 3 Enter (x,y) values: 200 200 Enter (x,y) values: 150 250 Enter (x,y) values: 250 250 Enter (x,y) values: 200 200

Basic geometric transformation: 1. Translation


http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

2. Rotation 3. Scaling Other transformation 4. Reflection 5. Shear 6. Exit Enter your choice: 1 Enter (tx,ty) values: 40 40

Basic geometric transformation: 1. Translation 2. Rotation 3. Scaling Other transformation 4. Reflection 5. Shear 6. Exit Enter your choice: 2 Enter the angle to rotate: 60

Basic geometric transformation: 1. Translation


http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

2. Rotation 3. Scaling Other transformation 4. Reflection 5. Shear 6. Exit Enter your choice: 3 Enter scaling factor: 1 2

Basic geometric transformation: 1. Translation 2. Rotation 3. Scaling Other transformation 4. Reflection 5. Shear 6. Exit Enter your choice: 4

Basic geometric transformation: 1. Translation 2. Rotation 3. Scaling


http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

Other transformation 4. Reflection 5. Shear 6. Exit Enter your choice: 5

Basic geometric transformation: 1. Translation 2. Rotation 3. Scaling Other transformation 4. Reflection 5. Shear 6. Exit Enter your choice: 6

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

CODING :
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<math.h> #include<graphics.h> typedef struct coordinate { int x,y; char code[4]; }pt; void drawwindow(); void drawline(pt p1,pt p2,int cl); pt setcode(pt p); int visibility(pt p1,pt p2); int resetenddpoint(pt p1,pt p2); int main() { int gd=DETECT,gm,v; pt p1,p2,temp; initgraph(&gd,&gm,c:\\tc\\bg:); clrscr(); cleardevice(); printf(\nEnter the endpoint1(x,y): ); scanf(%d%d,&p1.x,&p1.y); printf(\nEnter the endpoint2(x,y): ); scanf(%d%d,&p2.x,&p2.y); printf(\nClipping window); drawwindow(); getch(); clrscr(); printf(BEFORE CLIPPING); drawwindow(); drawline(p1,p2,5); getch();
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

p1=setcode(p1); p2=setcode(p2); v=visibility(p1,p2); switch(v) { case 0: clrscr(); drawwindow(); drawline(p1,p2,5); break; case 1: clrscr(); drawwindow(); break; case 2: clrscr(); printf(AFTER CLIPPING); p1=resetendpoint(p1,p2); p2=resetendpoint(p2,p1); drawwindow(p1,p2,5); drawline(p1,p2,5); break; } getch(); closegraph(); return(0); } void drawwindow() { setcolor(RED); line(150,100,450,100); line(450,100,450,350); line(450,350,150,350); line(150,350,150,100); }
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

void drawline(pt p1,pt p2,int cl) { setcolor(cl); line(p1.x,p1.y,p2.x,p2.y); } pt setcode(pt p) { pt ptemp; if(p.y<100) ptemp.code[0]=1; else ptemp.code[0]=0; if(p.y>350) ptemp.code[1]=1; else ptemp.code[1]=0; if(p.x>450) ptemp.code[2]=1; else ptemp.code[2]=0; if(p.x<150) ptemp.code[3]=1; else ptemp.code[3]=0; ptemp.x=p.x; ptemp.y=p.y; return(ptemp); } int visibility(pt p1,pt p2) { int i,flag=0; for(i=0;i<4;i++) { if((p1.code[i]!=0)||(p2.code[i]!=0)) flag=1;
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

} if(flag==0) return(0); for(i=0;i<4;i++) { if((p1.code[i]==p2.code[i])&&(p1.code[i]==1)) flag=0; } if(flag==0) return(1); return(2); } pt resetendpoint(pt p1,pt p2) { pt temp; int x,y,i; float m,k; if(p1.code[3]==1) x=150; if(p1.code[2]==1) x=450; if((p1.code[3]==1)||(p1.code[2]==1)) { m=(float)(p2.y-p1.y)/(p2.x-p1.x); k=(p1.y+(m*(x-p1.x))); temp.y=k; temp.x=k; for(i=0;i<4;i++) temp.code[i]=p1.code[i]; if(temp.y<=350&&temp.y>=100) return(temp); } if(p1.code[0]==1) y=100; if(p1.code[1]==1)
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

y=350; if((p1.code[0]==1)||(p1.code[1]==1)) { m=(float)(p2.y-p1.y)/(p2.x-p1.x); k=(float)p1.x+(float)(y-p1.y)/m; temp.x=k; temp.y=y; for(i=0;i<4;i++) temp.code[i]=p1.code[i]; return(temp); } else return(p1); }

OUTPUT :
Enter endpoint1(x,y): 50 50 Enter endpoint2(x,y): 500 500 CLIPPING WINDOW

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

BEFORE CLIPPING

AFTER CLIPPING

CODING :
#include<stdio.h> #include<conio.h> #include<string.h> #include<math.h> #include<graphics.h> #include<type.h> #define HEADER POLYGON CLIPPING SUTHERLAND HODGEMAN ALGORITHM int xwmin,ywmin,xwmax,ywmax; int x[10],y[10],a[10],b[10],p[20]; char pas[20]; int ptr,n,pent,flag;
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

void getdata; void conspoly; void clip; int visible(int e,int x1,int y1,int x2,int y2) { void clipdraw(); void getdata() { int i,c,r; setcolor(RED); settextstyle(4,0,1); outtextxy(10,5,HEADER); outtextxy(150,25,input window size); outtextxy(25,40,window left); scanf(%d,&xwmin); outtextxy(25,55,window top); scanf(%d,&ymin); outtextxy(25,55,window right); scanf(%d,&xwmax); outtextxy(25,55,window bottom); scanf(%d,&ywmax); outtextxy(150,95,Input polygon points); outtextxy(25,110,No. of sides); scanf(%d,&n); outtextxy(25,125,x-value : y-value); c=5; r=13; for(i=0;i<n;i++) { gotoxy(c,r); scanf(%d,&x[i]); gotoxy(c+=20,r++); scanf(%d,&y[i]); c=5; } } void conspoly() { int i; cleardevice(); setcolor(10);
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

settextstyle(3,0,1); outtextxy(100,40,Before clipping); rectangle(xwmin,ywmin,xwmax,ywmax); moveto(x[0],y[0]); for(i=0;i<n;i++) lineto(x[i],y[i]); lineto(x[0],y[0]); getch(); } void clip() { int i,fx,fy,sx,sy,e=1,vi,k; while(e<5) { i=0; pent=n,n=0,ptr=0; while(i<pent) { if(!i) { fx=x[0]; fy=y[0]; } Else intersect(e,sx,sy,x[i],y[i]); sx=x[i]; sy=y[i]; vi=visible(e,sx,sy); if(vi) { a[ptr]=sx; b[ptr]=sy; ptr++; n++; } i++; } Intersect(e,fx,fy,sx,sy); e++; for(k=0;k<n;k++) {
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

x[k]=a[k]; y[k]=b[k]; } k=0; for(i=0;i<n;i++) { p[k]=x[i]; p[k+1]=y[i]; k+=2; } cleardevice(); sprintf(pos,pass %d,n-4); outtextxy(100,50,pas); fillpoly(n,p); rectangle(xwmin,ywmin,xwmax,ywmax); getch(); } } int visible(int e,int x,int y) { if(e==1) { if(x>=xwmin) return(1); else return(0); } else if(e==2) { if(y>=ywmin) return(1); else return(0); } else if(e==3) { if(x<=xwmax) return(1); else return(0); }
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

else if(e==4) { if(y<=ywmax) return(1); else return (0); } return 0; } void intersect(int e,int x1,int y1,int x2,int y2) { float slope; int f=0; if(x2==x1) { slope=(float)(y2-y1)/(x2-x1); f=1; } else { slope=(float)(y2-y1)/(x2-x1); f=2; } if(e==1) { if((x1<=xwmin&&x2>=xwmin)||(x1>=xwmin&&x2<=xwmin)) { a[ptr]=xwmin; if(f==2) b[ptr]=slope*(xwmin-x1)+y1; else b[ptr]=(xwmin-x1)/slope+y1; ptr++; n++; } } else if(e==2) { if((y1>=ywmin&&y2<=ywmin)||(y1<=ywmin&&y2>=ywmin)) { b[ptr]=ywmin;
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

if(f==2) a[ptr]=(ywmin-y1)/slope+x1; else a[ptr]=slope*(ywmin-y1)+x1; ptr++; n++; } } else if(e==3) { if((x1<=xwmax&&x2>=xwmax)||(x1>=xwmax&&x2<=xwmax)) { a[ptr]=xwmax; if(f==2) b[ptr]=slope*(xwmax-x1)+y1; else b[ptr]=(xwmax-x1)/slope+y1; ptr++; n++; } } else if(e==4) { if((y1<=ywmax&&y2>=ywmax)||(y1>=ywmax&&y2<=ywmax)) { b[ptr]=ywmax; if(f==2) a[ptr]=(ywmax-y1)/slope+x1; else a[ptr]=slope*(ywmax-y1)+x1; ptr++; n++; } } } void clipdraw() { int k=0,i; for(i=0;i<n;i++) { p[k]=a[i];
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

p[k+1]=b[i]; k+=2; } cleardevice(); outtextxy(100,50,Clipped polygon image); setfillstyle(3,BLUE); fillpoly(n,p); rectangle(xwmin,ywmin,xwmax,ywmax); getch(); } void main() { int gd=DETECT,gm; initgraph(&gd,&gm,); getdata(); conspoly(); clip(); clipdraw(); closegraph(); }

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

OUTPUT :
POLYGON CLIPPING SUTHERLAND HODGEMAN ALGORITHM Input window size Window left: 100 Window top: 100 Window right: 300 Window bottom: 300 Input polygon points No. of sides: 4 X values 50 175 400 275 BEFORE CLIPPING

Y values 175 50 275 400

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

PASS 1:

PASS 2:

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

PASS 3:

PASS 4:

CODING :
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> void main() {
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

int op,poly[20],poly1[20],poly2[20],poly3[20]; int tx,ty,sx,sy,xr,yr,a,i,n,t; int gd=DETECT,gm; clrscr(); initgraph(&gd,&gm,); printf(\nEnter the number of edges: ); scanf(%d,&n); n=n+1; t=2*n; for(i=0;i<t;i+=2) { printf(\nEnter the X and Y coordinates: ); scanf(%d%d,&poly[i],&poly[i+1]); poly[i]=poly[i]+40; poly[i+1]=poly[i+1]+40; poly1[i]=poly[i]+90; poly1[i+1]=poly[i+1]+90; } poly[t]=poly[0]; poly[t+1]=poly[1]; poly1[t]=poly1[0]; poly1[t+1]=poly1[1]; do { sleep(2); clrscr(); cleardevice(); outtextxy(70,70,Original image); drawpoly(n,poly1); drawpoly(n,poly1); for(i=0;i<t;i+=2) line(poly[i],poly[i+1],poly1[i],poly1[i+1]); printf(\n3D transformation \n1. Translation\n2. Scaling\n3. Rotate\n4. Reflection\n5. Exit); printf(\nEnter your option: ); scanf(%d,&op); switch(op) { case 1: printf(\nEnter the translation factor); scanf(%d%d,&tx,&ty); for(i=0;i<t;i+=2)
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

{ poly2[i]=poly[i]+tx; poly2[i+1]=poly[i+1]+ty; poly3[i]=poly1[i]+tx; poly3[i+1]=poly1[i+1]+ty; } poly2[t]=poly2[0]; poly2[t+1]=poly2[1]; poly3[t]=poly3[0]; poly3[t+1]=poly3[1]; drawpoly(n,poly2); drawpoly(n,poly3); for(i=0;i<t;i+=2) line(poly2[i],poly2[i+1],poly3[i],poly3[i+1]); break; case 2: printf(\nEnter the scaling factor: ); scanf(%d%d,&sx,&sy); for(i=0;i<t;i+=2) { poly2[i]=poly[i]*sx; poly2[i+1]=poly[i+1]*sy; poly3[i]=poly1[i]*sx; poly3[i+1]=poly1[i+1]*sy; } poly2[t]=poly2[0]; poly2[t+1]=poly2[1]; poly3[t]=poly3[0]; poly3[t+1]=poly3[1]; drawpoly(n,poly2); drawpoly(n,poly3); for(i=0;i<t;i+=2) line(poly2[i],poly2[i+1],poly3[i],poly3[i+1]); break; case 3: printf(\nEnter the rotation factor: ); scanf(%d%d%d,&xr,&yr,&a); for(i=0;i<t;i+=2) { poly2[i]=xr+((poly[i]-xr)*cos(a))-((poly[i+1]-yr)*sin(a)); poly2[i+1]=yr+((poly[i+1]-yr)*cos(a))-((poly[i]-xr)*sin(a));
http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

poly3[i]=xr+((poly1[i]-xr)*cos(a))-((poly1[i+1]-yr)*sin(a)); poly3[i+1]=yr+((poly1[i+1]-yr)*cos(a))-((poly1[i]-xr)*sin(a)); } poly2[t]=poly2[0]; poly2[t+1]=poly2[1]; poly3[t]=poly3[0]; poly3[t+1]=poly3[1]; drawpoly(n,poly2); drawpoly(n,poly3); for(i=0;i<t;i+=2) line(poly2[i],poly2[i+1],poly3[i],poly3[i+1]); sleep(2); break; case 4: printf(\nReflection); for(i=0;i<t;i+=2) { poly2[i]=640-poly[i]; poly2[i+1]=poly[i+1]; poly3[i]=640-poly1[i]; poly3[i+1]=poly1[i+1]; } poly2[t]=poly2[0]; poly2[t+1]=poly2[1]; poly3[t]=poly3[0]; poly3[t+1]=poly3[1]; drawpoly(n,poly2); drawpoly(n,poly3); for(i=0;i<t;i+=2) line(poly2[i],poly2[i+1],poly3[i],poly3[i+1]); break; case 5: exit(0); } }while(op<=5); getch(); closegraph(); }

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

OUTPUT :
Enter the number of edges: 4 Enter the x and y coordinates: 100 100 Enter the x and y coordinates: 100 200 Enter the x and y coordinates: 200 200 Enter the x and y coordinates: 200 100 Enter the x and y coordinates: 100 100 3D TRANSFORMATION 1. Translation 2. Scaling 3. Rotation 4. Reflection 5. Exit ORIGINAL IMAGE

Enter your option: 1 Enter the translation factor: 50 50

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

Enter your option: 2 Enter the scaling factor: 2 2

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

Enter your option: 3 Enter the rotation factor: 100 200 100

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

Enter your option: 4 REFLETION

Enter your option: 5

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

EXNO: 9

DRAWING 3D SCENES AND 3D OBJECTS.

AIM: To draw 3-D scene and 3-D object using MAYA. PROCEDURE FOR 3-D SCENE: 1. Open the MAYA software.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

2. In the shelf, select the paint effects tab.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

3. Select the GET BRUSH option in the paint effects tab.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

4. A new window titled VISOR opens, displaying all the available brushes.

5. In the VISOR window select the Ocean Examples tab.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

6. Select the scene of your choice and drag the scene to the GRID using the Mouse Middle Button. A D scene appears as shown in the below figure. 7. The scene obtained is called a wireframe and appears as shown below.

3-

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

8. Press the key 5 in the number pad to apply a surface to the 3-D scene.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

9. Press the key 6 in the number pad to apply a surface to the 3-D scene.

10. Press the IPRRENDER button in the tool bar to obtain the final output of the 3-D scene created.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

PROCEDURE FOR 3D OBJECT: 1. Open the MAYA software.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

2. Draw a polygon structure using the polygon draw tool. Wired polygon structure will appear.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

3. Press the key 5 in the number pad to apply a surface to the 3D Scene.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

4. Now select the object and choose edit option in the left pane. Select Material attribute and choose the color. The color is applied to the object.

5. Press the IPRRENDER button in the tool barto obtain the final output of the 3D object created.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

RESULT: Thus the 3-D scene and 3D object was successfully created using MAYA.

EX NO 10

GENERATING FRACTAL IMAGES

AIM: To generate a fractal in MAYA

PROCEDURE: 1.Open the MAYA software.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

2. Draw a polygon structure using the polygon draw tool.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

3. Press Space Bar until a menu appears.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

4. In the menu that appears Right Click at the top of the menu for the hypershade menu to appear and select Hypershade and Perspective option.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

5. In the hypershade menu select the FRACTAL texture from the hypershade window.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

6. Select the texture icon from the work area and press Ctrl+a to open the attribute window of the object.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

7. In the attribute window make the desired changes to the texture like changing the color etc.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

8. Select the texture icon from the work area and right click till the menu appears. Select the object and select the option Assign Textures Material To Selection.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

9. The object drawn appears as shown in the below diagram.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

10. Press 6 in the number pad to assign the designed texture to the object.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

11. Press the IPR RENDER button in the tool bar to obtain the actual output of the object, which opens in the render window.

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

http://www.vidyarthiplus.com

RESULT : Thus the fractal images are generated using MAYA software.

http://www.vidyarthiplus.com

You might also like