Let pull down 12 x 3 set
Pull back machine 12 x 3 set
Barbell curl 12 x 3
Romanian deadlift 12 x 3 set
Sit ups 30 x 3 set

Jogging 6km/h 60 mins

'운동(Workout) > 운동일지' 카테고리의 다른 글

8월1일  (0) 2016.08.01
7월 27일 운동  (0) 2016.07.27
7월 26일 운동  (0) 2016.07.26
7월 14일 운동일지  (0) 2016.07.15
7월12일 운동일지  (0) 2016.07.15
Bench Press 12 x 3 set
Shoulder Press Machine 12 x 3 set
Lying Triceps Extension 12 x 3 set
Dumbell Press 12 6 6 6
Sit up 30 x 3 set

Jogging 6km/h 60 mins

'운동(Workout) > 운동일지' 카테고리의 다른 글

8월1일  (0) 2016.08.01
7월 27일 운동  (0) 2016.07.27
7월 26일 운동  (0) 2016.07.26
7월 14일 운동일지  (0) 2016.07.15
7월 13일 운동일지  (0) 2016.07.15

I made this project for assignment for my Computer Graphics course. This is a program like a 'Paint'. I can draw line, points, polygons as clicking points on the window. And also, I can change the color of them(RGB + Alpha) and size of lines(or points)



This is how my program looks like. On the top there are UI buttons. User clicks the button to change the color, size, type of drawing etc.






 Each drawings are saved with struct 'Polygon' which have points(Pts), color information(as a array), type of drawing(will be lines, points, or polygon etc). Variable 'ptsize' means when its' type is points, the size of point. Similary, variable 'linesize' means when its' type is line(line, lineloop, polygon, linestrip), the size of lines.



And here is settings of the world and 'main' function of the C++ project.



This is first part of display callback function 'Render' Here, I activated blending mode and initialized color. And with 'for' loop, I draw all members of a array 'PolyList' using switch sentence following each member's type.



This is second part of 'Render' function, which draw preview of current drawing. So 'Render' function which consists of 2 part is similar with previous project that I posted just before in same category(see this: http://busterworld.tistory.com/12)

So here in the second part, if user is clicked 1st point, program draws a preview of object with points that Polygon struct already have and current mouse position. Then, I drew UI on the top with 'drawPalette()' function.





This is mouse callback function, which will be called when user click with mouse. If button clicked is left button, the point information will be saved in temporary point struct variable. Then, if position of the point is in one of the buttons on top UI, proper variables will be changed following which button is clicked.



And when user didn't clicked any button on UI, the point will be added in temporary Polygon struct 'TmpPolygon'. This will be used when Render function draw preview.




This is end of mouse function. When user clicked right button of mouse, this means user finished drawing one object. So temporary polygon will be added in the PolyList and TmpPolygon will be initialized. And I printed current alpha value as window title.



This is MouseMotion function, which is called when user move mouse cursor. This will save current position of mouse in realtimePt Point struct variable.



For UI, I draw several quads as buttons. This is the code


void drawPalette()
{
 glLineWidth(1);
 //Draw UI
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 0 * 20, ymax - 20, 1);
 glVertex3f(xmin + 40 * 20, ymax - 20, 1);
 glVertex3f(xmin + 40 * 20, ymax, 1);
 glVertex3f(xmin + 0 * 20, ymax, 1);
 //Red Palette
 glColor3f(1, 0, 0);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 0 * 20, ymax - 20, 1);
 glVertex3f(xmin + 1 * 20, ymax - 20, 1);
 glVertex3f(xmin + 1 * 20, ymax, 1);
 glVertex3f(xmin + 0 * 20, ymax, 1);
 glEnd();

 //Green  Palette
 glColor3f(0, 1, 0);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 1 * 20, ymax - 20, 1);
 glVertex3f(xmin + 2 * 20, ymax - 20, 1);
 glVertex3f(xmin + 2 * 20, ymax, 1);
 glVertex3f(xmin + 1 * 20, ymax, 1);
 glEnd();

 //Blue  Palette
 glColor3f(0, 0, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 2 * 20, ymax - 20, 1);
 glVertex3f(xmin + 3 * 20, ymax - 20, 1);
 glVertex3f(xmin + 3 * 20, ymax, 1);
 glVertex3f(xmin + 2 * 20, ymax, 1);
 glEnd();

 //Yellow  Palette
 glColor3f(1, 1, 0);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 3 * 20, ymax - 20, 1);
 glVertex3f(xmin + 4 * 20, ymax - 20, 1);
 glVertex3f(xmin + 4 * 20, ymax, 1);
 glVertex3f(xmin + 3 * 20, ymax, 1);
 glEnd();

 //Violet  Palette
 glColor3f(1, 0, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 4 * 20, ymax - 20, 1);
 glVertex3f(xmin + 5 * 20, ymax - 20, 1);
 glVertex3f(xmin + 5 * 20, ymax, 1);
 glVertex3f(xmin + 4 * 20, ymax, 1);
 glEnd();

 //Skyblue  Palette
 glColor3f(0, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 5 * 20, ymax - 20, 1);
 glVertex3f(xmin + 6 * 20, ymax - 20, 1);
 glVertex3f(xmin + 6 * 20, ymax, 1);
 glVertex3f(xmin + 5 * 20, ymax, 1);
 glEnd();

 //White  Palette
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 6 * 20, ymax - 20, 1);
 glVertex3f(xmin + 7 * 20, ymax - 20, 1);
 glVertex3f(xmin + 7 * 20, ymax, 1);
 glVertex3f(xmin + 6 * 20, ymax, 1);
 glEnd();

 //Black  Palette
 glColor3f(0, 0, 0);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 7 * 20, ymax - 20, 1);
 glVertex3f(xmin + 8 * 20, ymax - 20, 1);
 glVertex3f(xmin + 8 * 20, ymax, 1);
 glVertex3f(xmin + 7 * 20, ymax, 1);
 glEnd();

 //Alpha Up
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 8 * 20, ymax - 20, 1);
 glVertex3f(xmin + 9 * 20, ymax - 20, 1);
 glVertex3f(xmin + 9 * 20, ymax, 1);
 glVertex3f(xmin + 8 * 20, ymax, 1);
 glEnd();
 
 glColor3f(0, 0, 0);
 glBegin(GL_LINES);
 glVertex3f(xmin + 9 * 20, ymax - 20, 1);
 glVertex3f(xmin + 9 * 20, ymax, 1);
 glVertex3f(xmin + 8.25 * 20, ymax - 12, 1);
 glVertex3f(xmin + 8.5 * 20, ymax - 8, 1);
 glVertex3f(xmin + 8.5 * 20, ymax - 8, 1);
 glVertex3f(xmin + 8.75 * 20, ymax - 12, 1);
 glEnd();

 //Alpha Down
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 9 * 20, ymax - 20, 1);
 glVertex3f(xmin + 10 * 20, ymax - 20, 1);
 glVertex3f(xmin + 10 * 20, ymax, 1);
 glVertex3f(xmin + 9 * 20, ymax, 1);
 glEnd();

 glColor3f(0, 0, 0);
 glBegin(GL_LINES);
 glVertex3f(xmin + 10 * 20, ymax - 20, 1);
 glVertex3f(xmin + 10 * 20, ymax, 1); 
 glVertex3f(xmin + 9.25 * 20, ymax - 8, 1);
 glVertex3f(xmin + 9.5 * 20, ymax - 12, 1);
 glVertex3f(xmin + 9.5 * 20, ymax - 12, 1);
 glVertex3f(xmin + 9.75 * 20, ymax - 8, 1);
 glEnd();

 //Draw Circle
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 10 * 20, ymax - 20, 1);
 glVertex3f(xmin + 11 * 20, ymax - 20, 1);
 glVertex3f(xmin + 11 * 20, ymax, 1);
 glVertex3f(xmin + 10 * 20, ymax, 1);
 glEnd();
 glColor3f(0, 0, 0);
 drawCircle(xmin + 10.5 * 20, ymax - 10, 5);

 //Draw Polygon
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 11 * 20, ymax - 20, 1);
 glVertex3f(xmin + 12 * 20, ymax - 20, 1);
 glVertex3f(xmin + 12 * 20, ymax, 1);
 glVertex3f(xmin + 11 * 20, ymax, 1);
 glEnd();
 glColor3f(0, 0, 0);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 11.25 * 20, ymax - 15, 1);
 glVertex3f(xmin + 11.75 * 20, ymax - 15, 1);
 glVertex3f(xmin + 11.75 * 20, ymax - 5, 1);
 glVertex3f(xmin + 11.25 * 20, ymax - 5, 1);
 glEnd();

 //Draw Line Loop
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 12 * 20, ymax - 20, 1);
 glVertex3f(xmin + 13 * 20, ymax - 20, 1);
 glVertex3f(xmin + 13 * 20, ymax, 1);
 glVertex3f(xmin + 12 * 20, ymax, 1);
 glEnd();
 glColor3f(0, 0, 0);
 glBegin(GL_LINE_LOOP);
 glVertex3f(xmin + 12.25 * 20, ymax - 15, 1);
 glVertex3f(xmin + 12.75 * 20, ymax - 15, 1);
 glVertex3f(xmin + 12.75 * 20, ymax - 5, 1);
 glVertex3f(xmin + 12.25 * 20, ymax - 5, 1);
 glEnd();

 //Draw Line Strip
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 13 * 20, ymax - 20, 1);
 glVertex3f(xmin + 14 * 20, ymax - 20, 1);
 glVertex3f(xmin + 14 * 20, ymax, 1);
 glVertex3f(xmin + 13 * 20, ymax, 1);
 glEnd();
 glColor3f(0, 0, 0);
 glBegin(GL_LINE_STRIP);
 glVertex3f(xmin + 13.75 * 20, ymax - 15, 1);
 glVertex3f(xmin + 13.25 * 20, ymax - 15, 1);
 glVertex3f(xmin + 13.75 * 20, ymax - 5, 1);
 glVertex3f(xmin + 13.25 * 20, ymax - 5, 1);
 glEnd();

 //Draw Lines
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 14 * 20, ymax - 20, 1);
 glVertex3f(xmin + 15 * 20, ymax - 20, 1);
 glVertex3f(xmin + 15 * 20, ymax, 1);
 glVertex3f(xmin + 14 * 20, ymax, 1);
 glEnd();
 glColor3f(0, 0, 0);
 glLineWidth(0.5);
 glBegin(GL_LINES);
 glVertex3f(xmin + 14.25 * 20, ymax - 17, 1);
 glVertex3f(xmin + 14.75 * 20, ymax - 3, 1);
 glEnd();


 //Line size Down
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 15 * 20, ymax - 20, 1);
 glVertex3f(xmin + 16 * 20, ymax - 20, 1);
 glVertex3f(xmin + 16 * 20, ymax, 1);
 glVertex3f(xmin + 15 * 20, ymax, 1);
 glEnd();
 glColor3f(0, 0, 0);
 glLineWidth(3);
 glBegin(GL_LINES);
 glVertex3f(xmin + 15.25 * 20, ymax - 10, 1);
 glVertex3f(xmin + 15.75 * 20, ymax - 10, 1);
 glEnd();

 //Line size Up
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 16 * 20, ymax - 20, 1);
 glVertex3f(xmin + 17 * 20, ymax - 20, 1);
 glVertex3f(xmin + 17 * 20, ymax, 1);
 glVertex3f(xmin + 16 * 20, ymax, 1);
 glEnd();
 glColor3f(0, 0, 0);
 glLineWidth(0.5);
 glBegin(GL_LINES);
 glVertex3f(xmin + 16.25 * 20, ymax - 10, 1);
 glVertex3f(xmin + 16.75 * 20, ymax - 10, 1);
 glEnd();

 //Draw Point (size Up)
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 17 * 20, ymax - 20, 1);
 glVertex3f(xmin + 18 * 20, ymax - 20, 1);
 glVertex3f(xmin + 17 * 20, ymax, 1);
 glVertex3f(xmin + 18 * 20, ymax, 1);
 glEnd();

 glColor3f(0, 0, 0);
 /*glBegin(GL_LINES);
 glVertex3f(xmin + 17 * 20, ymax - 20, 1);
 glVertex3f(xmin + 17 * 20, ymax, 1);
 glVertex3f(xmin + 16.25 * 20, ymax - 12, 1);
 glVertex3f(xmin + 16.5 * 20, ymax - 8, 1);
 glVertex3f(xmin + 16.5 * 20, ymax - 8, 1);
 glVertex3f(xmin + 16.75 * 20, ymax - 12, 1);
 glEnd();*/

 glPointSize(4.0);
 glBegin(GL_POINTS);
 glVertex3f(xmin + 17.5 * 20, ymax - 10, 1);
 glEnd();

 //Draw Point (size Down)
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 18 * 20, ymax - 20, 1);
 glVertex3f(xmin + 19 * 20, ymax - 20, 1);
 glVertex3f(xmin + 19 * 20, ymax, 1);
 glVertex3f(xmin + 18 * 20, ymax, 1);
 glEnd();

 glColor3f(0, 0, 0);
 /*glBegin(GL_LINES);
 glVertex3f(xmin + 18 * 20, ymax - 20, 1);
 glVertex3f(xmin + 18 * 20, ymax, 1);
 glVertex3f(xmin + 17.25 * 20, ymax - 8, 1);
 glVertex3f(xmin + 17.5 * 20, ymax - 12, 1);
 glVertex3f(xmin + 17.5 * 20, ymax - 12, 1);
 glVertex3f(xmin + 17.75 * 20, ymax - 8, 1);
 glEnd();*/

 glPointSize(1.0);
 glBegin(GL_POINTS);
 glVertex3f(xmin + 18.5 * 20, ymax - 10, 1);
 glEnd();

 //Reset
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(xmin + 19 * 20, ymax - 20, 1);
 glVertex3f(xmin + 20 * 20, ymax - 20, 1);
 glVertex3f(xmin + 20 * 20, ymax, 1);
 glVertex3f(xmin + 19 * 20, ymax, 1);
 glEnd();
 glColor3f(0, 0, 0);
 glBegin(GL_LINES);
 glVertex3f(xmin + 19.3 * 20, ymax - 5, 1);
 glVertex3f(xmin + 19.3 * 20, ymax - 17, 1);
 glVertex3f(xmin + 19.3 * 20, ymax - 10, 1);
 glVertex3f(xmin + 19.8 * 20, ymax - 17, 1);
 glEnd();
 glBegin(GL_LINE_LOOP);
 glVertex3f(xmin + 19.25 * 20, ymax - 5, 1);
 glVertex3f(xmin + 19.8 * 20, ymax - 5, 1);
 glVertex3f(xmin + 19.8 * 20, ymax - 10, 1);
 glVertex3f(xmin + 19.3 * 20, ymax - 10, 1);
 glEnd();
}



This is my function that draws a circle. It draws a circle which radius size is r, at (x, y)

This is final version of my project. I finished making waterwheel, and change colors of all objects. Then, I added ground and light






This is new part that connect main house and sub house on the right.




I added ground and light




 


So finally I finished it!!



I almost finished modeling on 2nd, May.








I made cubes which is light brown color, and handrails are made of cylinders (all brown and pink modelings)




This is first look of waterwheel. later, I edited on the center of it and added more components.






I made OpenGL Project that draws lines. User click two points in the window, and line is drawed with them. Also, when user click 1st point, I drew line in real time that connect 1st point and current mouse position. So, user can see the line which will be made before clicking 2nd point.


This is 'main' function of the project.




I made 'line' struct, and array of lines. line struct contains 4 integer variables that represent 2 points (x1, y1), (x2, y2) and 3 float variables that represent RGB color of the line



In display callback function 'Render()', I drew all lines in the array lines that user created before, and then if user clicked 1st point of new line(when variable draw is true), draw a line connecting that point(tmp[0], tmp[1]) and current mouse position(tmp[2], tmp[3])



In mouse callback function "MouseFunc" which means user clicked certain position for point,


when the clicked point is 1st point of the line,




set line's RGB color for random value, and variable 'draw' as true. And save the coordinate of the point in array 'tmp[0]', 'tmp[1]'.


BTW when the clicked point is 2nd point of the line,



set 'draw' variable as false and save all information about temporary line into new member of array 'lines'





And for information of mouse position in real time, I used glutPassiveMotionFunc callback function 'MouseMotion'. In this function, I set coordinates of mouse position into tmp[2], tmp[3] and call Render function. So in 'render' function, Computer will draw a line with mouse cursor after 1st point of new line is clicked.



This is the code of my first OpenGL project. I drew simple a house, a tree, a car, and a animation character "Sponge Bob"


#include <stdlib.h>
#include <gl/glut.h>
#include <math.h>

int Width = 600, Height = 600;

void Render();
void Reshape(int w, int h);
void Draw_Apple(float a, float b, float c);

void SetupViewTransform()
{
 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();
 glTranslatef(0.0, 0.0, -10.0);
}

void SetupViewVolume()
{
 glMatrixMode(GL_PROJECTION);
 glLoadIdentity();
 glOrtho(-10.0, 10.0, -10.0, 10.0, -100.0, 100.0);
}

int main(int argc, char **argv)
{
 glutInit(&argc, argv);

 glutInitWindowSize(Width, Height);
 glutInitWindowPosition(0, 0);

 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

 glutCreateWindow("A SimpleGL Program");

 glutDisplayFunc(Render);
 glutReshapeFunc(Reshape);

 glutMainLoop();
 return 0;
}

void Render()
{
 glClearColor(1.0f, 0.81f, 0.42f, 1.0f);
 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

 SetupViewTransform();

 SetupViewVolume();

 //house
 glMatrixMode(GL_MODELVIEW);
 glTranslatef(5.0, 2.0, 0.0);

 glBegin(GL_TRIANGLES);
 glColor3f(1.0, 0.6, 0.6);
 glVertex3f(-2.0, 0.0, 0.0);
 glColor3f(1.0, 0.0, 0.0);
 glVertex3f(2.0, 0.0, 0.0);
 glColor3f(1.0, 0.6, 0.6);
 glVertex3f(0.0, 2.0, 0.0);
 glEnd();

 glTranslatef(0.0, -1.0, 0.0);

 glBegin(GL_QUADS);
 glColor3f(1.0, 1.0, 0.9);
 glVertex3f(-1.8, 1.0, 0.0);
 glColor3f(1.0, 1.0, 0.7);
 glVertex3f(-1.8, -2.0, 0.0);
 glVertex3f(1.8, -2.0, 0.0);
 glVertex3f(1.8, 1.0, 0.0);
 glEnd();

 //house window
 glTranslatef(0.8, 0, 0.0);

 glBegin(GL_QUADS);
 glColor3f(0.7, 1.0, 1.0);
 glVertex3f(-0.8, 0.7, 0.0);
 glColor3f(0.4, 1.0, 1.0);
 glVertex3f(-0.8, -0.7, 0.0);
 glColor3f(0.7, 1.0, 1.0);
 glVertex3f(0.8, -0.7, 0.0);
 glColor3f(0.7, 1.0, 1.0);
 glVertex3f(0.8, 0.7, 0.0);
 glEnd();


 //car
 glTranslatef(-5.8, -6.5, 0);

 glBegin(GL_POLYGON);
 glColor3f(0.3, 0.3, 1);
 glVertex3f(0.5, 0, 0);
 for (int i = 90; i <= 180; i++)
 {
  glVertex3f(1.5 * cos(i * 3.1416 / 180), sin(i * 3.1416 / 180), 0);
 }
 glEnd();

 glColor3f(0.3, 0.3, 1);

 glBegin(GL_QUADS);
 glVertex3f(0, 0, 0);
 glVertex3f(4, 0, 0);
 glVertex3f(4, 2, 0);
 glVertex3f(0, 2, 0);
 glEnd();

 glBegin(GL_POLYGON);
 glVertex3f(4, 0, 0);
 for (int i = 0; i <= 90; i++)
 {
  glVertex3f(4 +  1.5 * cos(i *3.1416 / 180), sin(i*3.1416 / 180), 0);
 }

 glEnd();  
 
 //wheel 1
 glBegin(GL_POLYGON);
 glColor3f(0, 0, 0);
 for (int i = 0; i <= 360; i++)
 {
  glVertex3f(0.6 * cos(i * 3.1416 / 180), 0.6 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();

 //wheel 2
 glBegin(GL_POLYGON);
 glColor3f(0, 0, 0);
 for (int i = 0; i <= 360; i++)
 {
  glVertex3f(4 + 0.6 * cos(i * 3.1416 / 180), 0.6 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();


 //window of the car
 glTranslatef(0.3, 1, 0);
 glBegin(GL_QUADS);
 glColor3f(0.9, 0.9, 1);
 glVertex3f(0, 0, 0);
 glVertex3f(0, 0.8, 0);
 glVertex3f(3.4, 0.8, 0);
 glVertex3f(3.4, 0, 0);
 glEnd();

 //tree

 glTranslatef(-1, 2, 0);
 glBegin(GL_QUADS);
 glColor3f(0.65, 0.3, 0.13);
 glVertex3f(0, 0, 0);
 glVertex3f(2, 0, 0);
 glVertex3f(1.5, 6, 0);
 glVertex3f(0.5, 6, 0);
 glEnd();

 glTranslatef(1, 7, -3);
 glBegin(GL_POLYGON);
 glColor3f(0.2, 0.9, 0.15);
 for (int i = 0; i <= 360; i++)
 {
  glVertex3f(2 * cos(i * 3.1416 / 180), 4 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();

 // apples

 Draw_Apple(-0.5, 3, 0);

 Draw_Apple(-0.5, -2, 0);

 Draw_Apple(2.1, 1, 0);
 
 Draw_Apple(0.2, -1.2, 0);
 
 Draw_Apple(-1, -1.7, 0);

 Draw_Apple(-1, -1, 0);

 //SpongeBob Body
 glTranslatef(-8, -5, 0);
 glBegin(GL_QUADS);
 glColor3f(1, 1, 0);
 glVertex3f(0, 0, 0);
 glVertex3f(4, 0, 0);
 glVertex3f(4, 5, 0);
 glVertex3f(0, 5, 0);
 glEnd();

 //Left Eye
 glColor3f(1, 1, 1);
 glBegin(GL_POLYGON);
 for (int i = 0; i <= 360; i++)
 {
  glVertex3f(1.25 + 0.5 * cos(i * 3.1416 / 180), 3.75 + 0.5 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();
 glColor3f(0.357, 0.345, 0.87);
 glBegin(GL_POLYGON);
 for (int i = 0; i <= 360; i++)
 {
  glVertex3f(1.25 + 0.2 * cos(i * 3.1416 / 180), 3.75 + 0.2 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();
 glColor3f(0, 0, 0);
 glBegin(GL_POLYGON);
 for (int i = 0; i <= 360; i++)
 {
  glVertex3f(1.25 + 0.1 * cos(i * 3.1416 / 180), 3.75 + 0.1 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();

 //Right Eye
 glColor3f(1, 1, 1);
 glBegin(GL_POLYGON);
 for (int i = 0; i <= 360; i++)
 {
  glVertex3f(2.75 + 0.5 * cos(i * 3.1416 / 180), 3.75 + 0.5 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();
 glColor3f(0.357, 0.345, 0.87);
 glBegin(GL_POLYGON);
 for (int i = 0; i <= 360; i++)
 {
  glVertex3f(2.75 + 0.2 * cos(i * 3.1416 / 180), 3.75 + 0.2 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();
 glColor3f(0, 0, 0);
 glBegin(GL_POLYGON);
 for (int i = 0; i <= 360; i++)
 {
  glVertex3f(2.75 + 0.1 * cos(i * 3.1416 / 180), 3.75 + 0.1 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();

 //nose
 glColor3f(0, 0, 0);
 glBegin(GL_LINE_STRIP);
 for (int i = -30; i <= 210; i++)
 {
  glVertex3f(2 + 0.25 * cos(i * 3.1416 / 180), 3 + 0.25 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();

 //mouth
 glBegin(GL_LINE_STRIP);
 for (int i = 180; i <= 360; i++)
 {
  glVertex3f(2 + 0.8 * cos(i * 3.1416 / 180), 2.5 + 0.4 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();

 //Pants
 glColor3f(0.65, 0.3, 0.13);
 glBegin(GL_QUADS);
 glVertex3f(0, 0, 0);
 glVertex3f(4, 0, 0);
 glVertex3f(4, 0.75, 0);
 glVertex3f(0, 0.75, 0);
 glEnd();

 glColor3f(0, 0, 0);
 glBegin(GL_QUADS);
 glVertex3f(0.25, 0.5, 0);
 glVertex3f(1.25, 0.5, 0);
 glVertex3f(1.25, 0.65, 0);
 glVertex3f(0.25, 0.65, 0);

 glVertex3f(1.5, 0.5, 0);
 glVertex3f(2.5, 0.5, 0);
 glVertex3f(2.5, 0.65, 0);
 glVertex3f(1.5, 0.65, 0);

 glVertex3f(2.75, 0.5, 0);
 glVertex3f(3.75, 0.5, 0);
 glVertex3f(3.75, 0.65, 0);
 glVertex3f(2.75, 0.65, 0);
 glEnd();

 //Shirt
 glColor3f(1, 1, 1);
 glBegin(GL_QUADS);
 glVertex3f(0, 0.75, 0);
 glVertex3f(4, 0.75, 0);
 glVertex3f(4, 1.5, 0);
 glVertex3f(0, 1.5, 0);
 glEnd();


 //necktie

 glColor3f(1, 0, 0);
 glBegin(GL_TRIANGLES);
 glVertex3f(1.75, 1.5, 0);
 glVertex3f(2, 1.35, 0);
 glVertex3f(2.15, 1.5, 0);
 glEnd();

 glBegin(GL_QUADS);
 glVertex3f(2, 1.35, 0);
 glVertex3f(1.75, 1, 0);
 glVertex3f(2, 0.75, 0);
 glVertex3f(2.15, 1, 0);
 glEnd();


 glutSwapBuffers();
}

void Reshape(int w, int h)
{
 glViewport(0, 0, w, h);
 Width = w;
 Height = h;
}

void Draw_Apple(float a, float b, float c)
{
 glTranslatef(a, b, c);
 glBegin(GL_POLYGON);
 glColor3f(1, 0, 0);
 for (int i = 0; i <= 360; i++)
 {
  glVertex3f(0.5 * cos(i * 3.1416 / 180), 0.5 * sin(i * 3.1416 / 180), 0);
 }
 glEnd();

 glBegin(GL_TRIANGLES);
 glColor3f(1, 1, 1);
 glVertex3f(0.25, 0.20, 1);
 glVertex3f(0.25, 0.35, 1);
 glVertex3f(-0.05, 0.32, 1);
 glEnd();
}





The first assignment in Computer Graphics course was making program that draws line of simple equation that includes two points that user write x and y coordinates of them.




So, when user write (0, 0) and (49, 29) the program should draw simple equation y = 29 / 49 x


All points on the equation would be rounded off


First, this is my function that round off the parameter.



When user enter 4 numbers, there is a slope of simple equation


Then by the case if 'm' is bigger than 1 or not, print red dot on every 'y's which are on the equation.



And this is the result.


Red dots are simple equation which contains two points (41, 2) and (1, 25)


This algorithm is used on rasterization a line on pixel coordinate of monitor.

'작업물(Works) > ComputerGraphics' 카테고리의 다른 글

빛 정리(Ambient, Diffuse, Specular, Emissive)  (0) 2022.04.19
[OpenGL]Paint Program  (0) 2016.07.11
[OpenGL]Mouse Callback Function  (0) 2016.07.08
[OpenGL]First OpenGL Project  (0) 2016.07.08


I had Mid Term project for 3d modeling course in the University. And I chose this building. Because I thought making stairs and waterwheel would be exciting and colors in the buildings were beautiful.



First, I made objects which I thought is easy to make. And I asked advices for stairs to my professor. And he made basic structure of stair part, and I added several, small, long cubes to the part.


So I made this stair structure.

My first building modeling. Every objects are made from simple cube. I used connect, inset, extrude, chamfer function.




Top of the window on the roof is used chamfer function to be curved. And bars in the window are made of long cubes rotated.



This window is also made from a cube. I used tesselate function to make small windows on top half on big cube.



I made this part with big cube. Actually I don't remember exactly how I made this, but maybe I deleted two faces of it and extrude top part


I made big house on the left first, and duplicated it then rotated it. And edited front face, and made other objects like windows, pillars, and etc

+ Recent posts