资源简介
根据OpenGL提供的直线,多边形绘制算法(橡皮筋效果),实现基于鼠标交互的卡通人物设计与绘制。使用颜色填充与反走样技术对卡通人物外貌以及衣着进行绘制。实现对卡通人物轮廓的交互控制,点击鼠标左键可以对人物五官位置进行拖拽移动调整。按“↑”按键能够实现卡通人物绕坐标原点(或指定点)进行旋转。
代码片段和文件信息
#include “stdafx.h“
#include
#include
#include
#include
//#include
#include
#include
#include
using namespace std;
#define Glass 1
#define EyeL 3
#define EyeR 4
#define Mouth 5
#define Cap1 6
#define Cap2 7
#define Clothes1 8
#define Clothes2 9
#define PI 3.1416
#define MAX_CHAR 128
static int EYEL_COLOR = 0;
static int EYER_COLOR = 0;
static int MOUTH_COLOR = 0;
static int CAP1_COLOR = 7;
static int CAP2_COLOR = 6;
static int CLOTHES1_COLOR = 3;
static int CLOTHES2_COLOR = 4;
GLuint texture[4];
GLuint base;
BOOL GLASS_STATE;
BOOL EYEL_STATE;
BOOL EYER_STATE;
BOOL MOUTH_STATE;
BOOL CAP1_STATE;
BOOL CAP2_STATE;
BOOL CLOTHES1_STATE;
BOOL CLOTHES2_STATE;
GLuint GlassCor[2] = { 00 };
GLuint StoneCor[2] = { 2010 };
GLuint EyeLCor[2] = { -1148 };
GLuint EyeRCor[2] = { 1148 };
GLuint MouthCor[2] = { 025 };
GLuint Cap1Cor[2] = { 059 };
GLuint Cap2Cor[2] = { 10072 };
GLuint Clothes1Cor[2] = { 0-9 };
GLuint Clothes2Cor[2] = { 100-60 };
int Wide = 800;
int High = 600;
const int N = 50;
int select_part = 0;
static GLfloat theta = 0;
static GLfloat scal = 1;
static GLfloat colors[8][3] = {
{ 0.0 0.0 0.0 }{ 1.0 0.0 0.0 }{ 0.0 1.0 0.0 }{ 0.50.50.75 }
{ 0.0 1.0 1.0 }{ 1.0 0.0 1.0 }{ 1.0 1.0 0.0 }{ 1.0 1.0 1.0 } };
void paintframe();
void DrawSphereTexture(int x int y)
{
glEnable(GL_BLEND); //启用混合功能,将图形颜色同周围颜色相混合
glBlendFunc(GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_POINT_SMOOTH); //点抗锯齿
glEnable(GL_LINE_SMOOTH); //线抗锯齿
glEnable(GL_POLYGON_SMOOTH); //多边形抗锯齿
glEnable(GL_POLYGON_SMOOTH_HINT);
//画头部
glLoadIdentity();
glRotatef(theta 0.0 0.0 1.0);
glScaled(scal scal 1);
glColor3f(0.5 0.5f 1.0f);
glColor3f(0.5f 0.5f 1.0f);
glBegin(GL_POLYGON);
glVertex2f(-25 59);
glVertex2f(25 59);
glVertex2f(25 25);
glVertex2f(-25 25);
glEnd();
// 画脖子
glLoadIdentity();
glRotatef(theta 0.0 0.0 1.0);
glScaled(scal scal 1);
glColor3f(1.0 0.8 0.0);
glBegin(GL_POLYGON);
glVertex2f(-17 25);
glVertex2f(17 25);
glVertex2f(17 21);
glVertex2f(-17 21);
glEnd();
//画身体
glLoadIdentity();
glRotatef(theta 0.0 0.0 1.0);
glScaled(scal scal 1);
glColor3f(0.5f 0.5f 1.0f);
glBegin(GL_POLYGON);
glVertex2f(-33 21);
glVertex2f(33 21);
glVertex2f(33 -39);
glVertex2f(-33 -39);
glEnd();
//画左手臂
glLoadIdentity();
glRotatef(theta 0.0 0.0 1.0);
glScaled(scal scal 1);
glColor3f(1.0f 0.8f 1.0f);
glBegin(GL_POLYGON);
glVertex2f(-33 21);
glVertex2f(-52 -4);
glVertex2f(-42 -4);
glVertex2f(-33 8);
glEnd();
glColor3f(1.0f 0.8f 1.0f);
glBegin(GL_POLYGON);
glVertex2f(-51 -4);
glVertex2f(-51 -29);
glVertex2f(-43 -29);
glVertex2f(-43
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-04-19 10:34 exper1\
目录 0 2017-03-24 18:45 exper1\.vs\
目录 0 2017-03-24 18:45 exper1\.vs\exper1\
目录 0 2017-03-24 18:45 exper1\.vs\exper1\v14\
文件 31744 2017-04-19 10:34 exper1\.vs\exper1\v14\.suo
目录 0 2017-04-08 14:07 exper1\Debug\
文件 74240 2017-04-08 14:07 exper1\Debug\exper1.exe
文件 405040 2017-04-08 14:07 exper1\Debug\exper1.ilk
文件 1216512 2017-04-08 14:07 exper1\Debug\exper1.pdb
目录 0 2017-04-19 10:33 exper1\exper1\
文件 1300 2017-03-24 18:45 exper1\exper1.sln
文件 30081024 2017-04-19 10:34 exper1\exper1.VC.db
目录 0 2017-04-08 14:07 exper1\exper1\Debug\
文件 534 2017-04-08 14:07 exper1\exper1\Debug\exper1.log
文件 104451 2017-04-08 14:07 exper1\exper1\Debug\exper1.obj
文件 3407872 2017-03-24 18:47 exper1\exper1\Debug\exper1.pch
目录 0 2017-04-08 14:07 exper1\exper1\Debug\exper1.tlog\
文件 1666 2017-04-08 14:07 exper1\exper1\Debug\exper1.tlog\CL.command.1.tlog
文件 24918 2017-04-08 14:07 exper1\exper1\Debug\exper1.tlog\CL.read.1.tlog
文件 1540 2017-04-08 14:07 exper1\exper1\Debug\exper1.tlog\CL.write.1.tlog
文件 228 2017-04-08 14:07 exper1\exper1\Debug\exper1.tlog\exper1.lastbuildstate
文件 1558 2017-04-08 14:07 exper1\exper1\Debug\exper1.tlog\li
文件 4342 2017-04-08 14:07 exper1\exper1\Debug\exper1.tlog\li
文件 830 2017-04-08 14:07 exper1\exper1\Debug\exper1.tlog\li
文件 12234 2017-03-24 18:47 exper1\exper1\Debug\stdafx.obj
文件 576512 2017-04-08 14:07 exper1\exper1\Debug\vc140.idb
文件 241664 2017-04-08 14:07 exper1\exper1\Debug\vc140.pdb
文件 24159 2017-04-19 10:33 exper1\exper1\exper1.cpp
文件 8034 2017-03-24 18:45 exper1\exper1\exper1.vcxproj
文件 1313 2017-03-24 18:45 exper1\exper1\exper1.vcxproj.filters
文件 1503 2017-03-24 18:45 exper1\exper1\ReadMe.txt
............此处省略7个文件信息
- 上一篇:moodle教学教材
- 下一篇:cdll反编译工具包.rar
相关资源
- 直线的四种裁剪算法
- Computer graphics with opengl 4th edition 计算
- 山东大学计算机图形学实验课程资源
- 计算机图形学(OpenGL版)第3版.pdf
- OpenGL SuperBible 7 pdf
- OpenGL编程指南(原书第8版) + OpenGL超
- VS2017OpenGL 配置步骤
- 读OBJ模型,加载多纹理
- OpenGL红宝书第七版带目录完整版PDF+源
- opengl自定义函数实现平移旋转缩放
- OpenGL 3D场景绘制 SiriusPrx 荒岛古堡.r
- OpenGL一个室内三维渲染OBJ文件导入和
- NeHe OpenGL Qt4教学代码
- Opengl 蘑菇、萤火虫、地形三维建模
- OPENGL纹理贴图正方体
- OpenGL编程精粹源代码
- NeHe_OpenGL_VC版本1-48课全部教程以及源
- 计算机图形学实验OpenGL
- opengl 视频纹理处理
- OpenGL物理碰撞效果
- OpenGL小游戏
- OpenGL超级宝典第五版pdf及其随书源码
- OpenGL读取bunny文件+斯坦福兔子
- OpenGL开发的教室场景可以漫游
- OpenGL高级编程与可视化系统开发-系统
- opengl读取.obj三维模型,arcball实现鼠标
- OpenGL超级宝典 第5版 中文版 完整书签
- Computer Graphics with OpenGL 4th edition 高清
- OpenGL 4.0 Shading Language Cookbook及完整源
- Computer_Graphics_with_OpenGL_4th_ed.pdf
评论
共有 条评论