-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 903687f
Showing
79 changed files
with
2,456 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_project_file> | ||
<FileVersion major="1" minor="6" /> | ||
<Project> | ||
<Option title="L-systems" /> | ||
<Option pch_mode="2" /> | ||
<Option compiler="gcc" /> | ||
<Build> | ||
<Target title="Debug"> | ||
<Option output="bin/Debug/L-systems" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Debug/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-g" /> | ||
</Compiler> | ||
</Target> | ||
<Target title="Release"> | ||
<Option output="bin/Release/L-systems" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Release/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-O2" /> | ||
</Compiler> | ||
<Linker> | ||
<Add option="-s" /> | ||
</Linker> | ||
</Target> | ||
</Build> | ||
<Compiler> | ||
<Add option="-Wall" /> | ||
<Add option="-fexceptions" /> | ||
</Compiler> | ||
<Linker> | ||
<Add library="GL" /> | ||
<Add library="glut" /> | ||
</Linker> | ||
<Unit filename="main.cpp" /> | ||
<Extensions> | ||
<code_completion /> | ||
<debugger /> | ||
</Extensions> | ||
</Project> | ||
</CodeBlocks_project_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_layout_file> | ||
<FileVersion major="1" minor="0" /> | ||
<ActiveTarget name="Debug" /> | ||
<File name="main.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="849" topLine="24" /> | ||
</Cursor> | ||
</File> | ||
</CodeBlocks_layout_file> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <iostream> | ||
#include <string> | ||
#include <math.h> | ||
#include <GL/glut.h> | ||
#include <glm/glm.hpp> | ||
|
||
using namespace glm; | ||
using namespace std; | ||
|
||
int W=1000; | ||
int H=1000; | ||
int n=0; | ||
float d = 1.0; | ||
float delta = 90 * 3.14/180; | ||
vec2 p0 = vec2(0.0, 0.0); | ||
vec2 v = vec2(0.0, d); | ||
bool done = false; | ||
|
||
|
||
void display(void); | ||
void init(void); | ||
void keyboard (unsigned char key, int x, int y); | ||
void reshape(int w, int h); | ||
void drawLine(vec2 p, vec2 q); | ||
void L(string s, int n); | ||
|
||
int main (int argc, char** argv) { | ||
int win; | ||
|
||
glutInit(&argc,argv); | ||
|
||
glutInitWindowSize(W,H); | ||
glutInitWindowPosition(100,100); | ||
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); | ||
win = glutCreateWindow("plant"); | ||
glutSetWindow(win); | ||
glutKeyboardFunc(keyboard); | ||
init(); | ||
glutDisplayFunc(display); | ||
glutMainLoop(); | ||
return 0; | ||
} | ||
|
||
|
||
void keyboard (unsigned char key, int x, int y){ | ||
switch(key){ | ||
case '.': | ||
n++; | ||
p0 = vec2(0.0, 0.0); | ||
d /= 2; | ||
v = vec2(0.0, d); | ||
done = false; | ||
glutPostRedisplay(); | ||
break; | ||
case ',': | ||
if (n > 0) | ||
{ | ||
n--; | ||
d *= 2; | ||
} | ||
p0 = vec2(0.0, 0.0); | ||
v = vec2(0.0, d); | ||
done = false; | ||
glutPostRedisplay(); | ||
break; | ||
case 'q': | ||
exit(0); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void init() { | ||
glClearColor(1.0, 1.0, 1.0, 1.0); | ||
glShadeModel (GL_FLAT); | ||
glMatrixMode(GL_PROJECTION); | ||
glLoadIdentity(); | ||
glOrtho(-10.0, 10.0, -10.0, 10.0, -1.0, 1.0); | ||
glMatrixMode(GL_MODELVIEW); | ||
glLoadIdentity(); | ||
} | ||
|
||
|
||
|
||
void reshape(int w, int h) | ||
{ | ||
glViewport (0, 0, (GLsizei) w, (GLsizei) h); | ||
glMatrixMode(GL_PROJECTION); | ||
glLoadIdentity(); | ||
glOrtho(-10.0, 10.0, -10.0, 10.0, -1.0, 1.0); | ||
glMatrixMode(GL_MODELVIEW); | ||
glLoadIdentity(); | ||
} | ||
|
||
void display() { | ||
|
||
glClear(GL_COLOR_BUFFER_BIT); | ||
|
||
string axiom ("-F"); | ||
|
||
glLineWidth(5); | ||
|
||
if (!done) | ||
{ | ||
L(axiom, n); | ||
glFlush(); | ||
done = true; | ||
} | ||
|
||
} | ||
|
||
void L(string s, int n) | ||
{ | ||
//cout << s << '\n' << "n = " << n << '\n' << s.size() << "\n\n"; | ||
|
||
for (int i=0; i<s.size(); i++) | ||
{ | ||
if (s[i] == 'F') | ||
{ | ||
if (n > 0) | ||
{ | ||
L("F-F+F+FF-F-F+F", n-1); | ||
} | ||
else | ||
{ | ||
drawLine(p0, vec2(p0.x+v.x, p0.y+v.y)); | ||
p0 = vec2(p0.x+v.x, p0.y+v.y); | ||
} | ||
} | ||
else if (s[i] == 'f') | ||
{ | ||
p0 = vec2(p0.x+v.x, p0.y+v.y); | ||
} | ||
else if (s[i] == '+') | ||
{ | ||
v = vec2(v.x * cos(delta)- v.y * sin(delta), v.x * sin(delta) + v.y * cos(delta)); | ||
} | ||
else if (s[i] == '-') | ||
{ | ||
v = vec2(v.x * cos(-delta)- v.y * sin(-delta), v.x * sin(-delta) + v.y * cos(-delta)); | ||
} | ||
} | ||
|
||
} | ||
|
||
void drawLine(vec2 p, vec2 q) | ||
{ | ||
glColor3f(1.0, 0.0, 0.0); | ||
glLineWidth(2); | ||
glBegin(GL_LINES); | ||
glVertex2f(p.x, p.y); | ||
glVertex2f(q.x, q.y); | ||
//printf("%.2f , %.2f-> %.2f , %.2f\n", p.x, p.y, q.x, q.y); | ||
glEnd(); | ||
|
||
} | ||
|
||
|
||
|
||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Geometric primitives graphic computacional using OpenGL. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_project_file> | ||
<FileVersion major="1" minor="6" /> | ||
<Project> | ||
<Option title="circulo" /> | ||
<Option pch_mode="2" /> | ||
<Option compiler="gcc" /> | ||
<Build> | ||
<Target title="Debug"> | ||
<Option output="bin/Debug/circulo" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Debug/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-g" /> | ||
</Compiler> | ||
<Linker> | ||
<Add library="glut" /> | ||
</Linker> | ||
</Target> | ||
<Target title="Release"> | ||
<Option output="bin/Release/circulo" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Release/" /> | ||
<Option type="0" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-O2" /> | ||
</Compiler> | ||
<Linker> | ||
<Add option="-s" /> | ||
</Linker> | ||
</Target> | ||
</Build> | ||
<Compiler> | ||
<Add option="-Wall" /> | ||
</Compiler> | ||
<Linker> | ||
<Add library="GL" /> | ||
<Add library="X11" /> | ||
</Linker> | ||
<Unit filename="main.cpp" /> | ||
<Extensions> | ||
<code_completion /> | ||
<debugger /> | ||
</Extensions> | ||
</Project> | ||
</CodeBlocks_project_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# depslib dependency file v1.0 | ||
1528825678 source:/home/marcus/Dropbox/Semestre 2018.1/Computação grafica/testes Trabalho/circulo/main.cpp | ||
<GL/glut.h> | ||
<stdlib.h> | ||
<glm/glm.hpp> | ||
<bits/stdc++.h> | ||
<iostream> | ||
|
||
1529967460 source:/home/marcus/Dropbox/Semestre 2018.1/Computação grafica/Trabalho final/circulo/main.cpp | ||
<GL/glut.h> | ||
<stdlib.h> | ||
<glm/glm.hpp> | ||
<bits/stdc++.h> | ||
<iostream> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_layout_file> | ||
<FileVersion major="1" minor="0" /> | ||
<ActiveTarget name="Debug" /> | ||
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="541" topLine="18" /> | ||
</Cursor> | ||
</File> | ||
</CodeBlocks_layout_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include <GL/glut.h> | ||
#include <stdlib.h> | ||
#include <glm/glm.hpp> | ||
#include <bits/stdc++.h> | ||
#include <iostream> | ||
|
||
using namespace glm; | ||
using namespace std; | ||
|
||
class Circle | ||
{ | ||
public: | ||
float PI = 3.1415926f; | ||
float raio; | ||
int n_points; | ||
vector<vec2> arestas; | ||
Circle(float raio, int npoints); | ||
|
||
}; | ||
|
||
Circle::Circle(float raio, int n) | ||
{ | ||
this->n_points = n; | ||
this->raio = raio; | ||
|
||
for (int i=0; i < n; i++) | ||
{ | ||
float theta = 2.0f * this->PI * float(i) / float(n); | ||
vec2 v = vec2(cos(theta)*raio,sin(theta)*raio); | ||
arestas.push_back(v); | ||
} | ||
|
||
} | ||
|
||
void drawCircle(void) | ||
{ | ||
Circle *c = new Circle(20.0,40); | ||
glBegin(GL_LINE_LOOP); | ||
|
||
for (int i=0; i < c->arestas.size() ; i++) | ||
{ | ||
glColor3f(0.0, 0.0, 0.0); | ||
glVertex2f(c->arestas[i].x,c->arestas[i].y); | ||
} | ||
|
||
glEnd(); | ||
} | ||
|
||
void init(void) | ||
{ | ||
glClearColor(1.0, 1.0, 1.0, 1.0); | ||
glShadeModel (GL_SMOOTH); | ||
} | ||
|
||
void display(void) | ||
{ | ||
glClear(GL_COLOR_BUFFER_BIT); | ||
drawCircle(); | ||
glFlush(); | ||
} | ||
|
||
void reshape(int w, int h) | ||
{ | ||
glViewport (0, 0, (GLsizei) w, (GLsizei) h); | ||
glMatrixMode(GL_PROJECTION); | ||
glLoadIdentity(); | ||
glOrtho(-40.0, 40.0, -40.0, 40.0, -1.0, 1.0); | ||
glMatrixMode(GL_MODELVIEW); | ||
glLoadIdentity(); | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
glutInit(&argc, argv); | ||
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); | ||
glutInitWindowSize (250, 250); | ||
glutInitWindowPosition (100, 100); | ||
glutCreateWindow ("Circulo"); | ||
init (); | ||
glutDisplayFunc(display); | ||
glutReshapeFunc(reshape); | ||
glutMainLoop(); | ||
return 0; | ||
} |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.