Tugas grafika komputer Labsheet 9 kali ini adalah gambar robot menggunakan Dev C++
#include
#include
#include
#include
#include
#define obj 25
typedef struct {float m[4][4];} matrix3D_t;
typedef struct {float v[4];} vector3D_t;
typedef struct {float x; float y; float z;} point3D_t;
typedef struct {float x; float y;} point2D_t;
typedef struct {float r; float g; float b;} color_t;
int static move = 0;
bool stat = false, tempStat = false;
//////////// matrices and vectors 3D ////////////
matrix3D_t createIdentity(void) {
matrix3D_t u;
int i,j;
for (i=0;i<4 -="" 0.="" 0="" 1="" 220="" 2="" 2d="" 3d="" a.m="" a.v="" a0="" a1="" a2="" a="" ambient="" and="" axes="" b.m="" b.v="" b0="" b1="" b2="" b="" blue="" buat="" buff="" c.m="" c.v="" c1="" c2="" c="" calculation="" can="" coefficient="" col.b="" col.g="" col.r="" col="" color="" color_t="" colorofobject="" colwhite="{0.8,0.8,0.8};" convex="" cs="" define="" diffuse="" display="" draw3d="" drawaxes="" drawcharx="" drawchary="" drawcharz="" drawdot="" drawline="" drawpolygon="" drawpolyline="" drawshape="" dx="" dy="" dz="" ector2point2d="" else="" end="" exp="" eyelength="" face="" face_t="" faces="" factorx="" factory="" factorz="" fc="" fillpolygon="" fills="" float="" for="" funcpositive="" function="" functions="" gl_color_buffer_bit="" glbegin="" glclear="" glcolor3f="" glend="" glutswapbuffers="" glvertex2f="" gradatepolygon="" green="" halfaxis1="" halfaxis="" homogenizevector="" hongmodel="" i="" if="" ight="" in="" int="" invvec1="" j="" jumlah="" k="" kamb="" kdif="" kspe="" light="" lightvector="" log="" mat="" matrices="" matrix3d_t="" matrix="" n:="" n="" nl="funcPositive(tmp);" normal="" normalvector="" num="" number="" numberoffaces="" numberofvertices="" object3d_t="" object="" objek="" obyek.fc="" obyek.pnt="" obyek="" of="" oint2vector="" olwhite="" only="" opengl="" operator="" p1.x="" p1.y="" p1="" p2.x="" p2.y="" p2="" p="" perspective.m="" perspective="" perspectivemtx="" phongmodel="" pnt.x="" pnt.y="" pnt.z="" pnt="" point2d_t="" point2vector="" point3d_t="" points="" polygons="" power="" r="" red="" reflection="" reflectionvector="(2.*(Light*Normal)*" return="" rotate.m="" rotate="" rotation="" rotationxmtx="" rotationymtx="" rotationzmtx="" rv="funcPositive(tmp);" scale.m="" scale="" scaling="" scalingmtx="" setcolor="" short="" sn="" specular="" struct="" the="" theta="" titik="" tmp="ReflectionVector*View;" to="" trans.m="" trans="" translation="" translationmtx="" typedef="" u.m="" u="" umberofvertices="" unitvector="" userdraw="" v.v="" v0.v="" v0="" v1.v="" v1="" v="" vec.v="" vec1="" vec2="" vec="" vecbuff="" vecnormal.v="" vecnormal="(vecbuff[1]-vecbuff[0])^" vector2point2d="" vector2point3d="" vector3d_t="" vector="" vectors="" ver="" vertices="" view="" viewvector="" void="" x-14="" x1="" x2="" x="" y1="" y2="" y="" yth="" z="" zrata="">=0){
for(j=0;j=0){
for(j=0;j=0){
for(j=0;j=0){
for(j=0;j0) b=b+h[i-1];
for(j=0;jz[j+1]) {
ztemp=z[j];
z[j]=z[j+1];
z[j+1]=ztemp;
temp=objek[j];
objek[j]=objek[j+1];
objek[j+1]=temp;
matTemp=mat[j];
mat[j]=mat[j+1];
mat[j+1]=matTemp;
}
}
}
for(i=0;i= 60) {
if(tick >= 60) tick = 60;
if(tick <= -60) tick = -60;
tempStat = false;
stat = false;
move = -move;
}
else if(fabs(theta) < 1 && fabs(theta) > 0)
stat = tempStat;
tick += move;
printf(" %d\n",tick);
//printf(" %d\n",theta);
if(tick == 0 && stat == false) move = 0;
}
void keyboard (unsigned char key, int x, int y) {
switch (key) {
case 'm':
printf("Button M Presed\n");
move = 5;
tempStat = true;
break;
case 'b':
printf("Button B Presed\n");
move = -5;
tempStat = true;
break;
default:
break;
}
}
int main(int argc, char **argv) {
glutInit(&argc,argv);
glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB );
glutInitWindowPosition(150,20);
glutInitWindowSize(1000,700);
glutCreateWindow ("Study Kasus Model Robot 3D dengan menggunakan OpenGL");
glClearColor(0.0, 0.0, 0.0, 0.0);
gluOrtho2D(-500., 500., -350.0, 350.0);
glutIdleFunc(display); // idle event call back
glutKeyboardFunc(keyboard);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
4>
0 terbaik