當前位置:首頁 » 課程設計 » opengl課程設計代碼

opengl課程設計代碼

發布時間: 2021-03-06 17:54:31

『壹』 計算機課程設計《利用opengl實現 會動的自行車》

啊等等等等等等等等等

『貳』 高分求計算機圖形學OpenGL現有的代碼

我也不是很懂,你驗收一下(有兩個參考資料)
CS 535
WEILER-ATHERTON
PROBLEM
Implement Weiler-Atherton. You should draw each polygon in a different color and fill the clip areas generated with a third color.
NOTES:
The Weiler-Atherton algorithm is the most general of the clipping algorithms. We have two 2D polygons (may be convex or concave and they both may have holes). The polygon to be clipped is called the SUBJECT polygon and the polygon defining the clipping area is called the CLIP polygon. To make the algorithm work easier (in the data structures, etc.) we usually assume that the exterior vertices are given clockwise and the hole vertices are given counterclockwise. In clipping we usually want to find the parts of the subject polygon that are inside the clip polygon. However, this algorithm can be used in modeling to find the "union", "intersection", and "difference" of the polygons.
The data structures are several circular linked lists of vertices which are also linked together and the clipping is done by traversing these. The lists could be doubly linked. This enables the traversal in either direction at any node in the list. Starting at a particular node and traversing in one direction will proce the interior polygon(s) while starting at a different node and traversing can proce the outside. Note that procing the exterior does need the doubly linking and care must be taken in performing the traversal.

STEP 1:
The first phase of the building of the data structures occurs when we input the edges and put them in two linked lists - the SUBJ list and the CLIP list. The vertices are place in order from input (thus clockwise). There are separate lists for the exterior and for each hole. Thus, the initial build is a standard queue insert (input a vertex - insert it at end of list). Note that this creates a list in which a standard list traversal is equivalent to "walking around" the polygon edge visiting the vertices in order.
STEP 2:
The second phase of the list building is computing and inserting the INTERSECTION points. If we have a SUBJECT polygon edge (SVi to SVi+1) that intersects a CLIP polygon edge (CVj to CVj+1) at a point INTER. Note that the edges form straight lines that may intersect, we are assuming that the line segments SVi to SVi+1 intersects the line segment CVj to CVj+1. The intersection point INTER is then inserted on BOTH of the linked lists - SUBJ and CLIP. It is inserted BETWEEN SVi and SVi+1 on the SUBJ list and CVj and CVj+1 on the CLIP list. The idea is still that traversing the list using a standard list traversal we would encounter the points in their geometric order. Note that there may be several intersection points between any given pair of vertices and they must be inserted in the correct order in the lists. This is done by using the t and u values computed in the vector line intersection subprogram. Each intersection point thus has TWO nodes - one on each list (SUBJ and CLIP). We link these two entries together which provides a way of getting from one list to the other.
STEP 2.5:
Any straight line divides the plane into two half-planes. Thus each polygon edge (extended to a line) will divide the plane into two half-planes. Because we listed the vertices clockwise, we consider the half-plane to the right as containing the interior of the polygon. Thus the right half-plane is called the interior half-plane. If we consider ourselves as "walking along" a polygon edge, then we can categorize each of the INTERSECTION points as "entering" or "exiting". This is usually done from the SUBJ polygon's point of view. Thus, as we walk along the SUBJ polygon edge SVi to SVi+1 and we encounter intersection point INTER, we can ask the question - am I "entering" the CLIP polygon or am I "exiting" the CLIP polygon? The second part of computing the intersection point is to classify them as "entering" or "exiting". We create one or two lists - one for entering intersections and one for exiting intersections.
STEP3:
Once the lists are built the basic idea to do the clipping is as follows
Pick an entry from the ENTERING list - it will be an intersection point (and delete it)
Locate that point on the SUBJ list
Traverse the current (SUBJ) list until you find the next intersection point - it should be an exiting or entering point. Output each vertex encountered to some data structure, say POLY
Follow the link from the current (SUBJ) list to the other (CLIP) list and
Continue the traversal until you find the next intersection (Note: delete each entering intersection from the ENTERING list - not the linked lists. By deleting it we will get the distinct intersecting polygons and not plicate a polygon multiple times).
Terminate the traversal when you get to an intersection that is the SAME as the initial one that you removed from the ENTERING list. At this point POLY will have one of the clip regions and can be output.
REPEAT the construction and output of POLY until the ENTERING list is empty.
Remark: For the exterior, try starting with an EXITING point. Start the traversal on the SUBJ list (same direction as the Interior). At what point do you need to use the double link and to traverse in the opposite direction? (Hint: look at the CLIP polygon list).
IMPLEMENTATION:
In the below data structures we place all of the vertices and intersection points in a 1D array and use the subscript instead of the actual coordinates.
const int MAXVERT = 500;
const int MAXPOLYV = 50;
const int MAXH = 10;

struct Point2D
{float x,y;
};
typedef Point2D Vertices[MAXVERT];

enum VerType = {Polygon, Intersection};

typedef struct ClipListRec * ClipPtr;
struct ClipListRec
{ int Vindex;
ClipPtr next;
VerType Kind;
float t;
ClipPtr otherList;
}

struct Polygon
{ int nVertex;
int vert[MAXPOLYV];
ClipPtr list;
}
struct GenPolygon
{ Polygon exterior;
int numHoles;
Polygon Holes[MAXH];
}

GenPolygon Sub,Clip;
int entering[MAXVERT],exiting[MAXVERT];
Vertices V;
int numVertex = 0; // size of the array of verticies
int clipPoly[MAXVERT]; // a clip polygon

int readPoint();
{ cin >> inX; cin >> inY;
if (numVertex < MAXVERT)
{ V[numVertex].x = inX;
V[numVertex].y = inY;
idNo = numVertex;
numVertex++;
}
else
idNo = -1;
return idNo;
}

void readPolygon (GenPolygon p)
{ cin >> p.exterior.nVertex;
for (i = 0; i < p.exterior.nVertex; i++)
{ newId = readPoint();
if (newId < 0)
error
else
{ insertAtRear (p.exterior.list,newId);
p.exterior.vert[i] = newId;
}
}
// now do the holes basically the same way
. . .
}
// the "main" program loop would then be (pseudocode)
while (!(entering))
{ nextInter = delete (entering);
SEARCH (SubjectPolygon,nextInter,ptr1);
AddToOutputList (ptr1->. . .)
StartPoint = ptr1->. . .
ptr1 = prt1->next;
while (ptr1->. . . != StartPoint)
{ AddToOutputList (ptr1->. . .);
if (ptr1-> . . == INTERSECTION)
ptr1 = prt1->otherList->next;
else
ptr1 = ptr1->next;
}
FixListForOutput();
DrawPolygon();
EmptyOutputList();
}
參考資料:http://cs1.bradley.e/public/jcm/weileratherton.html
http://tianminghui0210.blog.163.com/blog/static/471909200751041116174/

『叄』 opengl游戲程序設計 中文版

我推薦幾本
初學的2D
《Visual C++游戲編程基礎》
《Visual C++經典游戲程序設計》
一般現在都可以版直接學3D,學權好3D,2D就不在話下了
《nehe教程》這個是只有電子書,很好的OPENGL教程,讓你對3D圖形更感興趣呵呵
《OPENGL游戲編程》,作者徐明亮,感覺算國內比較好的書了
《3D游戲編程大師技巧》,這書跟《Windows游戲編程大師技巧》有點聯系,不過不多,反正也是看思想,代碼也不要看了。
還有好多書可以去電驢上載。。。太多了,游戲中的每一個部分都可以單獨寫成一本書。。以後還要更細化的。。祝你成功,為中國游戲做貢獻。

『肆』 OPENGL設計小車源代碼

別急,哥給你做了...待會給你..

『伍』 關於計算機圖形學(OpenGL版)里的代碼

登陸 http://www.xmission.com/~nate/glut.html下載glut-3.7.6-bin.zip,然後安源裝。。。具體安裝方法:.h文件放到VC的安裝目錄...\VC98\Include\GL下。。。.lib和.dll文件放到系統盤:\windows\system32下。。。

『陸』 OpenGL如何實現B樣條曲線和曲面的繪制(C語言)

你說的是計算機圖形學的課程設計吧,我有C編寫的代碼,可以運行,是畫B樣條曲線和曲面的,我發到你郵箱里了,你參考一下吧。

『柒』 求OpenGL編程指南第四版源代碼!

OpenGL貼吧里的資源里就有,直接進入貼吧,找置頂資源,分分鍾搞定

『捌』 急!求一個OpenGL編寫的源代碼,簡單的,最好是原創小作品。希望好心人幫幫忙~

//Win32 Console Application

#include <gl/glut.h>
#include <math.h>
const int n = 60;
const GLfloat R = 0.2f;
const GLfloat Pi = 3.1415926536f;
void myDisplay(void)
{
int i;
glClear(GL_COLOR_BUFFER_BIT);

//點
glPointSize(2.0);
glBegin(GL_POINTS);
glVertex2f(0.0f, 0.0f);
glEnd();
//由閉合折線組成的圓
glBegin(GL_LINE_LOOP);
glColor3f(1.0,1.0,0.0);
for(i=0; i<n; ++i)
glVertex2f(R*cos(2*Pi/n*i), R*sin(2*Pi/n*i));
glEnd();
//由不閉合折線組成的兩個三角形構成的六星陣圖
glBegin(GL_LINE_STRIP);
glColor3f(1.0,0.0,0.0);
glVertex2f(0.0,0.2);
glVertex2f(0.1732,-0.1);
glVertex2f(-0.1732,-0.1);
glVertex2f(0.0,0.2);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(0.0,-0.2);
glVertex2f(0.1732,0.1);
glVertex2f(-0.1732,0.1);
glVertex2f(0.0,-0.2);
glEnd();
//連續三角形組成的扇形
glBegin(GL_TRIANGLE_FAN);
glVertex2f(0.5,0.5);
glVertex2f(0.5,1.0);
glColor3f(0.8,0.2,0.5);
glVertex2f(0.8,0.9);
glColor3f(0.2,0.5,0.8);
glVertex2f(0.9,0.8);
glColor3f(0.8,0.5,0.2);
glVertex2f(1.0,0.5);
glEnd();
//虛線
glLineWidth(3.0);
glEnable(GL_LINE_STIPPLE);
glLineStipple(2, 0x0F0F);
glBegin(GL_LINES);
glColor3f(0.0,0.0,1.0);
glVertex2f(-0.5f, 1.0f);
glColor3f(1.0,1.0,1.0);
glVertex2f(-0.5f,-1.0f);
glEnd();
//線
glLineWidth(0.5);
glDisable(GL_LINE_STIPPLE);
glBegin(GL_LINES);
glColor3f(1.0,0.0,0.0);
glVertex2f(0.5f, 1.0f);
glColor3f(1.0,1.0,1.0);
glVertex2f(1.0f, 0.5f);
glEnd();
glFlush();
}

int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(0, 0);
glutInitWindowSize(600, 600);
glutCreateWindow("第一個OpenGL程序");
glutDisplayFunc(&myDisplay);
glutMainLoop();
return 0;
}

『玖』 急求opengl程序代碼

#include<windows.h>
#include<stdlib.h>
#include<stdio.h>
#include<GL/glut.h>
#include<math.h>

void drawline(float x1,float y1,float x2,float y2) //The function to draw a line from point(x1,y1) to point (x2,y2)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (0.0, 0.0, 0.0);
glBegin(GL_LINES);
glVertex2f(x1,y1);
glVertex2f(x2,y2);
}

void _display(void)
{
#define pi 3.1415926
GLfloat theta,r=18;
GLint n=16;
theta=2*pi/n;
GLfloat vertex_list[16][2];
for(int i=0;i<n;i++) //Find the vertex
{
vertex_list[i][0]=25+r*cos(i*theta);
vertex_list[i][1]=25+r*sin(i*theta);

}
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (0.0, 0.0, 0.0);
glBegin(GL_LINE_LOOP);
for(int j=0;j<n;j++)
{

for(int k=j;k<n;k++)
{
drawline(vertex_list[j][0],vertex_list[j][1],vertex_list[k][0],vertex_list[k][1]);

}
}

glEnd();
glFlush ();
}

void _init (void)
{
glClearColor (1.0, 1.0, 1.0, 0.0);
glColor3f(1.0, 0.0, 0.0) ;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 50.0, 0.0, 50.0);
glMatrixMode(GL_MODELVIEW);
}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 0);
glutCreateWindow ("hello");
_init ();
glutDisplayFunc(_display);
glutMainLoop();

return 0;
}

一個正十六邊形 各點相連的圖形
我自己寫的 你看看行不行

『拾』 計算機圖形學(openGL)代碼

直接用winAPI寫的可以,用glut等寫的就不行,得安裝其類庫。 追問: 就是想知道怎麼安裝的........ - - 回答: 你用的是glut庫嗎?或者 程序編譯 報什麼錯誤啊 追問: 用dec C ,就是不知道glut 庫函數 在哪有下,下載完了放在哪個目錄.... 回答: http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip 這個是官網最新版本,下好之後 將壓縮包內的.h文件放到...\Microsoft Visual Studio 10\VC\PlatformSDK\Include\gl目錄下 將. lib文件 放到...\Microsoft Visual Studio 10\VC\PlatformSDK\Lib目錄下 將. dll文件 放到C:\windows\system32目錄下

熱點內容
幼師專業怎麼樣 發布:2021-03-16 21:42:13 瀏覽:24
音樂小毛驢故事 發布:2021-03-16 21:40:57 瀏覽:196
昂立中學生教育閘北 發布:2021-03-16 21:40:47 瀏覽:568
建築業一建報考條件 發布:2021-03-16 21:39:53 瀏覽:666
2017年教師資格注冊結果 發布:2021-03-16 21:39:49 瀏覽:642
中國教師資格證查分 發布:2021-03-16 21:39:41 瀏覽:133
踵什麼成語有哪些 發布:2021-03-16 21:38:20 瀏覽:962
東營幼師專業學校 發布:2021-03-16 21:35:26 瀏覽:467
機械電子研究生課程 發布:2021-03-16 21:33:36 瀏覽:875
杭州朝日教育培訓中心怎麼樣 發布:2021-03-16 21:33:28 瀏覽:238