Advanced Transformations (Multiple Translations and Rotations)

Здесь есть возможность читать онлайн «Advanced Transformations (Multiple Translations and Rotations)» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Advanced Transformations (Multiple Translations and Rotations): краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Advanced Transformations (Multiple Translations and Rotations)»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

Advanced Transformations (Multiple Translations and Rotations) — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Advanced Transformations (Multiple Translations and Rotations)», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

• rotate 2*radiusdegrees on the y axis

• Transform 2 units on the z-axis

• draw the object

• pop the matrix

• repeat

Step3 :Creating complicated paths in simple ways

By now you should start thinking that transformations are not so difficult after all. At the moment our code looks like that:

glPushMatrix();

//draw ten icosahedrons

for (int i = 0 ; i < 10 ; i++) {

glPushMatrix();

glRotatef(36*i,0.0,0.0,1.0);

glTranslatef(10.0,0.0,0.0);

glRotatef(2*angle,0.0,1.0,0.0);

glTranslatef(0.0,0.0,2.0);

createIcoToruses(i);

glPopMatrix();

}

glPopMatrix();

At this point, we can simply add a glRotatecall just before the first glPushMatrix, in order to rotate the whole system in 1, 2 or 3 dimensions:

glPushMatrix();

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

glPushMatrix();

…previous code…

glPopMatrix();

glPopMatrix();

Resulting in the following:

Ops, what is this cube doing in the middle of our system? It is there to show how to add a new completely unrelated system of transformations in our scene. To do so we have to add some new code before the previously explained one.

This bit is easy, we just save the matrix, rotate it in all three axes, draw the cube-sphere object and restore the matrix before drawing our system of icosahedrons and toruses:

glPushMatrix();

glRotatef(angle,1.0,1.0,1.0);

glColor3f(1.0,0.5,0.0);

glutSolidSphere(2.5,20,20);

glColor3f(1.0,0.0,0.0);

glutSolidCube(4.0);

glPopMatrix() ;

glPushMatrix();

…the previously explained code that creates the icos. and toruses

glPopMatrix();

Are you impressed? You should not be,… yet. This system of objects looks very impressive but still you can see that the objects follow a certain pattern. If we add another rotation just before drawing the current scene, then things become quite chaotic:

glPushMatrix();

glRotatef(angle,1.0,1.0,1.0);

drawCubeSphere();

drawIcoToruses();

glPopMatrix();

If now we 'forget' to clear the color buffer, but remember to clear the depth buffer we could have a commercially looking screen saver!

PS: Thanks to Chris Mathers for the clearing the depth buffer idea.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Advanced Transformations (Multiple Translations and Rotations)»

Представляем Вашему вниманию похожие книги на «Advanced Transformations (Multiple Translations and Rotations)» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Advanced Transformations (Multiple Translations and Rotations)»

Обсуждение, отзывы о книге «Advanced Transformations (Multiple Translations and Rotations)» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x