WEEK16
到 settings - compiler - Search directories
Compiler C:\OpenCV2.1\include 和 Linker C:\OpenCV2.1\lib
接著換 Linker settings
新增
cv210
excore210
highgui210
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,0);
glBegin(GL_POLYGON);
glVertex2f(0.5, 0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(-0.5, -0.5);
glVertex2f(0.5, -0.5);
glEnd();
glColor3f(0,1,0);
glutSolidTeapot( 0.3 );
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week16");
glutDisplayFunc(display);
glutMainLoop();
}
#include <GL/glut.h>
float teapotX = 0, teapotY = 0;
void motion(int x, int y) {
teapotX = (x-150)/150.0;
teapotY = (150-y)/150.0;
glutPostRedisplay();
}
void display() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(teapotX, teapotY, 0);
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week16");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
#include <GL/glut.h>
float teapotX = 0, teapotY = 0, angle = 0, oldX = 0, oldY = 0;
void mouse(int button, int state, int x, int y) {
oldX = x;
oldY = y;
}
void motion(int x, int y) {
//teapotX = (x-150)/150.0;
angle += x - oldX;//teapotY = (150-y)/150.0;
oldX = x;
glutPostRedisplay();
}
void display() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angle, 0, 0, 1); //glTranslatef(teapotX, teapotY, 0);
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week16");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
#include <stdio.h>
#include <GL/glut.h>
float teapotX = 0, teapotY = 0, angle = 0, oldX = 0, oldY = 0;
void mouse(int button, int state, int x, int y) {
oldX = x;
oldY = y;
}
void motion(int x, int y) {
teapotX = (x-150)/150.0;
teapotY = (150-y)/150.0;
angle += x - oldX;
oldX = x;
glutPostRedisplay();
printf(" glTranslatef( %.2f, %.2f, 0 ); \n", teapotX, teapotY );
}
void display() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glColor3f(1,1,1);
//glRotatef(angle, 0, 0, 1);
glTranslatef(teapotX, teapotY, 0);
glutSolidTeapot( 0.3 );
glPopMatrix();
glColor3f(0,1,0);
glutSolidTeapot( 0.02 );
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week16");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
#include <stdio.h>
#include <GL/glut.h>
float teapotX = 0, teapotY = 0, angle = 0, oldX = 0, oldY = 0;
void mouse(int button, int state, int x, int y) {
oldX = x;
oldY = y;
}
void motion(int x, int y) {
teapotX = (x-150)/150.0;
teapotY = (150-y)/150.0;
angle += x - oldX;
oldX = x;
glutPostRedisplay();
printf(" glTranslatef( %.2f, %.2f, 0 ); \n", teapotX, teapotY );
}
void display() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glColor3f(1,1,1);
//glTranslatef( 0.42, -0.06, 0 );
glRotatef(angle, 0, 0, 1);
glTranslatef( 0.42, -0.06, 0 );//glTranslatef(teapotX, teapotY, 0);
glutSolidTeapot( 0.3 );
glPopMatrix();
glColor3f(0,1,0);
glutSolidTeapot( 0.02 );
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week16");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
#include <stdio.h>
#include <GL/glut.h>
float teapotX = 0, teapotY = 0, angle = 0, oldX = 0, oldY = 0;
void mouse(int button, int state, int x, int y) {
oldX = x;
oldY = y;
}
void motion(int x, int y) {
teapotX = (x-150)/150.0;
teapotY = (150-y)/150.0;
angle += x - oldX;
oldX = x;
glutPostRedisplay();
printf(" glTranslatef( %.2f, %.2f, 0 ); \n", teapotX, teapotY );
}
void display() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glColor3f(1,1,1);
glTranslatef(-0.42, +0.06, 0 );
glRotatef(angle, 0, 0, 1);
glTranslatef( 0.42, -0.06, 0 );//glTranslatef(teapotX, teapotY, 0);
glutSolidTeapot( 0.3 );
glPopMatrix();
glColor3f(0,1,0);
glutSolidTeapot( 0.02 );
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week16");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include <stdio.h>
#include <GL/glut.h>
#include "glm.h"
GLMmodel * head = NULL;
GLMmodel * body = NULL; ///GLMmodel * gundam = NULL;
GLMmodel * arm1 = NULL, * arm2 = NULL;
GLMmodel * hand1 = NULL, * hand2 = NULL;
float teapotX = 0, teapotY = 0, angle = 0, angle2 = 0, oldX = 0, oldY = 0;
int myTexture(char * filename)
{
IplImage * img = cvLoadImage(filename);
cvCvtColor(img,img, CV_BGR2RGB);
glEnable(GL_TEXTURE_2D);
GLuint id;
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_2D, id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img->width, img->height, 0, GL_RGB, GL_UNSIGNED_BYTE, img->imageData);
return id;
}
void mouse(int button, int state, int x, int y) {
oldX = x;
oldY = y;
}
void motion(int x, int y) {
teapotX += (x - oldX) / 150.0 * 10; ///teapotX = (x-150)/150.0;
teapotY += (oldY - y) / 150.0 * 10; ///teapotY = (150-y)/150.0;
angle += x - oldX;
angle2 += oldY - y;
oldX = x;
oldY = y;
glutPostRedisplay();
printf(" glTranslatef( %.2f, %.2f, 0 ); \n", teapotX, teapotY );
}
void display() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glScalef(1.6, 1.6, 1.6);
glTranslatef(0, -0.5, 0);///往下一半
glPushMatrix();
glColor3f(1,1,1);
glScalef(0.04, 0.04, 0.04);
///glRotatef(angle, 0, 1, 0);
glmDraw(body, GLM_MATERIAL|GLM_TEXTURE);///glmDraw(gundam, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();///左手
glTranslatef(-4.07, +21.33, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef( 4.07, -21.33, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(arm1, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();
glTranslatef(-4.40, +18.53, 0 );
glRotatef(angle, 0, 1, 0);
glRotatef(angle2, 1, 0, 0);
glTranslatef( 4.40, -18.53, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(hand1, GLM_MATERIAL|GLM_TEXTURE);
glPopMatrix();
glPopMatrix();
glPushMatrix();///右手
glTranslatef(+4.07, +21.33, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef(-4.07, -21.33, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(arm2, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();
glTranslatef(+4.40, +18.53, 0 );
glRotatef(angle, 0, 1, 0);
glRotatef(angle2, 1, 0, 0);
glTranslatef(-4.40, -18.53, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(hand2, GLM_MATERIAL|GLM_TEXTURE);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef(-0.00, +22.53, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef( 0.00, -22.53, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(head, GLM_MATERIAL|GLM_TEXTURE);
glPopMatrix();
glPopMatrix();
glColor3f(0,1,0);
glutSolidTeapot( 0.02 );
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutInitWindowSize(500,500);
glutCreateWindow("week16");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
head = glmReadOBJ("model/head.obj");
body = glmReadOBJ("model/body.obj"); ///gundam = glmReadOBJ("model/Gundam.obj");
arm1 = glmReadOBJ("model/arm1.obj");
arm2 = glmReadOBJ("model/arm2.obj");
hand1 = glmReadOBJ("model/hand1.obj");
hand2 = glmReadOBJ("model/hand2.obj");
myTexture("model/Diffuse.jpg");
glEnable(GL_DEPTH_TEST);
glutMainLoop();
}
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include <stdio.h>
#include <GL/glut.h>
#include "glm.h"
GLMmodel * head = NULL;
GLMmodel * body = NULL; ///GLMmodel * gundam = NULL;
GLMmodel * arm1 = NULL, * arm2 = NULL;
GLMmodel * hand1 = NULL, * hand2 = NULL;
GLMmodel * bot = NULL;
GLMmodel * leg1 = NULL, * leg2 = NULL;
GLMmodel * knee1 = NULL, * knee2 = NULL;
GLMmodel * foot1 = NULL, * foot2 = NULL;
float teapotX = 0, teapotY = 0, angle = 0, angle2 = 0, oldX = 0, oldY = 0;
int myTexture(char * filename)
{
IplImage * img = cvLoadImage(filename);
cvCvtColor(img,img, CV_BGR2RGB);
glEnable(GL_TEXTURE_2D);
GLuint id;
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_2D, id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img->width, img->height, 0, GL_RGB, GL_UNSIGNED_BYTE, img->imageData);
return id;
}
void mouse(int button, int state, int x, int y) {
oldX = x;
oldY = y;
}
void motion(int x, int y) {
teapotX += (x - oldX) / 150.0 * 10; ///teapotX = (x-150)/150.0;
teapotY += (oldY - y) / 150.0 * 10; ///teapotY = (150-y)/150.0;
angle += x - oldX;
angle2 += oldY - y;
oldX = x;
oldY = y;
glutPostRedisplay();
printf(" glTranslatef( %.2f, %.2f, 0 ); \n", teapotX, teapotY );
}
void display() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glScalef(1.6, 1.6, 1.6);
glTranslatef(0, -0.5, 0);///往下一半
glPushMatrix();
glColor3f(1,1,1);
glScalef(0.04, 0.04, 0.04);
///glRotatef(angle, 0, 1, 0);
glmDraw(body, GLM_MATERIAL|GLM_TEXTURE);///glmDraw(gundam, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();///左手
glTranslatef(-4.07, +21.33, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef( 4.07, -21.33, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(arm1, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();
glTranslatef(-4.40, +18.53, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef( 4.40, -18.53, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(hand1, GLM_MATERIAL|GLM_TEXTURE);
glPopMatrix();
glPopMatrix();
glPushMatrix();///右手
glTranslatef(+4.07, +21.33, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef(-4.07, -21.33, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(arm2, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();
glTranslatef(+4.40, +18.53, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef(-4.40, -18.53, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(hand2, GLM_MATERIAL|GLM_TEXTURE);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glTranslatef(-0.00, +22.53, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef( 0.00, -22.53, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(head, GLM_MATERIAL|GLM_TEXTURE);
glPopMatrix();
glPushMatrix();///左腳
glmDraw(bot, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();
glTranslatef(-2.00, +14.27, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef( 2.00, -14.27, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(leg1, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();
glTranslatef(-2.00, +9.87, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef( 2.00, -9.87, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(knee1, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();
glTranslatef(-2.13, +2.40, 0 );
glRotatef(angle, 0, 1, 0);
glRotatef(angle2, 1, 0, 0);
glTranslatef( 2.13, -2.40, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(foot1, GLM_MATERIAL|GLM_TEXTURE);
glPopMatrix();
glPopMatrix();
glPopMatrix();
glPopMatrix();
glPushMatrix();///右腳
glmDraw(bot, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();
glTranslatef(+2.00, +14.27, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef(-2.00, -14.27, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(leg2, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();
glTranslatef(+2.00, +9.87, 0 );
///glRotatef(angle, 0, 1, 0);
///glRotatef(angle2, 1, 0, 0);
glTranslatef(-2.00, -9.87, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(knee2, GLM_MATERIAL|GLM_TEXTURE);
glPushMatrix();
glTranslatef(+2.13, +2.40, 0 );
glRotatef(angle, 0, 1, 0);
glRotatef(angle2, 1, 0, 0);
glTranslatef(-2.13, -2.40, 0 );///glTranslatef(teapotX, teapotY, 0);
glmDraw(foot2, GLM_MATERIAL|GLM_TEXTURE);
glPopMatrix();
glPopMatrix();
glPopMatrix();
glPopMatrix();
glPopMatrix();
glColor3f(0,1,0);
glutSolidTeapot( 0.02 );
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutInitWindowSize(500,500);
glutCreateWindow("week16");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
head = glmReadOBJ("model/head.obj");
body = glmReadOBJ("model/body.obj"); ///gundam = glmReadOBJ("model/Gundam.obj");
arm1 = glmReadOBJ("model/arm1.obj");
arm2 = glmReadOBJ("model/arm2.obj");
hand1 = glmReadOBJ("model/hand1.obj");
hand2 = glmReadOBJ("model/hand2.obj");
bot = glmReadOBJ("model/bot.obj");
leg1 = glmReadOBJ("model/leg1.obj");
leg2 = glmReadOBJ("model/leg2.obj");
knee1 = glmReadOBJ("model/knee1.obj");
knee2 = glmReadOBJ("model/knee2.obj");
foot1 = glmReadOBJ("model/foot1.obj");
foot2 = glmReadOBJ("model/foot2.obj");
myTexture("model/Diffuse.jpg");
glEnable(GL_DEPTH_TEST);
glutMainLoop();
}
沒有留言:
張貼留言