Bo‘yalgan 3d obektlar chizish
glutSolidTorus(ichki radius, tashqi radius, tomonlar soni, xalqalar soni); //torus
glutSolidCube(tomonlar o‘lchami); // kub
glutSolidCone(radius, balandlik, quvurg‘alar soni, xalqalar soni);// konus
glutSolidSphere(radius, gorizantal halqalar soni, vertikal xalqalar soni);// sfera
glutSolidTeapot(o‘lchami);// choynak
glutSolidDodecahedron();//Dodеkaedr
glutSolidIcosahedron();//Ikosaedr
glutSolidOctahedron();//Oktaedr
glutSolidTetrahedron(); // Tеtraedr
4. Laboratoriya ishiga oid namunalar
Torus va choynak chizish
#include
#include
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glColor3ub(255,20,90);
glutSolidTorus(1,6,12,20);
glColor3ub(255,20,190);
glutWireTorus(1,6,12,20);
glColor3ub(255,20,190);
glutSolidTeapot(3);
glColor3ub(5,250,250);
glutWireTeapot(3);
glBegin(GL_LINES);
glColor3ub(0,0,255);
glVertex3f(0, 0, 0); glVertex3f(10, 0, 0);
glVertex3f(0, 0, 0); glVertex3f(0, 10, 0);
glVertex3f(0, 0, 0); glVertex3f(0, 0, 10);
glEnd(); glFlush();}
void xossalar() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0, 1.2, 2, 20);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(3.5, 7, 5, 0, 3, 0, 0, 3, 0); }
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(80, 80);
glutInitWindowSize(800, 600);
glutCreateWindow("A Simple 3d objects");
glutDisplayFunc(display);
xossalar();
glutMainLoop(); }
2.Torus chizish
#include
#include
#include
#include
#include
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glutWireTorus(0.5, 3, 15, 30);
glBegin(GL_LINES);
glColor3f(1, 0, 0); glVertex3f(0, 0, 0); glVertex3f(10, 0, 0);
glColor3f(0, 1, 0); glVertex3f(0, 0, 0); glVertex3f(0, 10, 0);
glColor3f(0, 0, 1); glVertex3f(0, 0, 0); glVertex3f(0, 0, 10);
glEnd();
glFlush();}
void init() {
glClearColor(0.0, 0.0, 0.0, 1.0);
glColor3f(1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, 4.0/3.0, 1, 40);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(4, 6, 5, 0, 0, 0, 0, 1, 0);}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(80, 80);
glutInitWindowSize(800, 600);
glutCreateWindow("A Simple Torus");
glutDisplayFunc(display);
init(); glutMainLoop();}
Nazorat savollari
1.glBegin va glEnd qanday ma’noni anglatadi?
2.Qanday 3d obekt funksiyalarini bilasiz?
3.Kordinatalar tizimi nima?
4.Proyeksiyalash nima?
3-laboratoriya ishi uchun topshiriqlar
Tartib raqami bo‘yicha berilgan variantlarni oling. 3d obektlarni chizishda glu kutubxonasi funksiyalaridan foydalaning va obekt ostiga to‘r chizing.
3d obektlar ikki xil qovurg‘ali va bo‘yalgan usulda tasvirlang. (Wire v a solid)
Do'stlaringiz bilan baham: |