資源簡介
三維模型布爾運算
相交
相減
求并
三維模型布爾運算 求并、交、差
三維模型布爾運算 求并、交、差
三維模型布爾運算 求并、交、差
代碼片段和文件信息
#include?
#include?
#include?
#include?“./core/CSGWorld.h“
#include?“./core/BooleanModeller.h“
using?namespace?std;
GLfloat?g_fView[3]?=?{0.0?0.0?2.0};
GLfloat g_fAngle[3]?=?{0.0};
int g_iAreaSizeX?=?64;
int g_iAreaSizeY?=?64;
const?float?g_fOffset?=?.5;
CSGWorld g_csgTester;
BooleanModeller* g_pBooleanModeller(0);
Solid* g_pUnionModel(0);
Solid* g_pDifferenceModel(0);
Solid* g_pIntersectionModel(0);
void?init();
void?display();
void?mouse(int?button?int?state?int?x?int?y);
void?keyboard(unsigned?char?key?int?x?int?y);
void?reshape(int?w?int?h);
void?setup();
void?destroy();
void?viewTransform();
int?main(int?argc?char**?argv)
{
glutInit(&argc?argv);
glutInitDisplayMode?(GLUT_DOUBLE?|?GLUT_RGB);
glutInitWindowSize?(800?800);?
glutInitWindowPosition?(100?100);
glutCreateWindow?(argv[0]);
init?();
glutDisplayFunc(display);?
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
//glutMotionFunc(motion);
glutMainLoop();
return?0;
}
void?init(void)?
{
glClearColor?(0.0?0.0?0.0?0.0);
glShadeModel?(GL_FLAT);
setup();
}
void?display(void)
{
glClear?(GL_COLOR_BUFFER_BIT);
glLoadIdentity?();?????????????/*?clear?the?matrix?*/
/*?viewing?transformation??*/
gluLookAt?(g_fView[0]?g_fView[1]?g_fView[2]?0.0?0.0?0.0?0.0?1.0?0.0);
//?normal
glPushMatrix();
{
glTranslatef(-g_fOffset?g_fOffset?0.0f);
viewTransform();
g_csgTester.Render();
}glPopMatrix();
//?union
glPushMatrix();
{
glTranslatef(g_fOffset?g_fOffset?0.0f);
viewTransform();
g_pUnionModel->Render();
}glPopMatrix();
//?difference
glPushMatrix();
{
glTranslatef(-g_fOffset?-g_fOffset?0.0f);
viewTransform();
g_pDifferenceModel->Render();
}glPopMatrix();
//?intersection
glPushMatrix();
{
glTranslatef(g_fOffset?-g_fOffset?0.0f);
viewTransform();
g_pIntersectionModel->Render();
}glPopMatrix();
glutSwapBuffers();
}
void?reshape?(int?w?int?h)
{
glViewport?(0?0?(GLsizei)?w?(GLsizei)?h);?
glMatrixMode?(GL_PROJECTION);
glLoadIdentity?();
//glFrustum?(-1.0?1.0?-1.0?1.0?1.5?20.0);
gluPerspective(601.00.0001500);
//gluOrtho2D(?0?w?0?h?);
glMatrixMode?(GL_MODELVIEW);
}
void?viewTransform()
{
glRotatef(g_fAngle[0]?0.0?1.0?0.0);
glRotatef(g_fAngle[1]?1.0?.0?0.0);
glRotatef(g_fAngle[2]?0.0?.0?1.0);
}
void?keyboard(unsigned?char?key?int?x?int?y)
{
switch?(key)?
{
case?27:
destroy();
exit(0);
break;
case?‘w‘:
g_fAngle[0]?+=?5.0;
break;
case?‘s‘:
g_fAngle[0]?-=?5.0;
break;
case?‘q‘:
g_fAngle[1]?+=?5.0;
break;
case?‘e‘:
g_fAngle[1]?-=?5.0;
break;
case?‘x‘:
g_fAngle[2]?+=?5.0;
break;
case?‘d‘:
g_fAngle[2]?-=?5.0;
break;
//?adjust?the?view?point
case?‘n‘:
g_fView[2]?+=?0.1f;
break;
case?‘m‘:
g_fView[2]?-=?0.1f;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2011-06-18?17:34??CsgTest\
?????文件?????????731??2009-09-08?13:28??CsgTest\box.txt
?????文件???????15555??2009-09-08?13:28??CsgTest\cone.txt
?????目錄???????????0??2010-06-20?13:51??CsgTest\core\
?????文件????????3491??2009-09-08?13:28??CsgTest\core\BooleanModeller.cpp
?????文件?????????893??2009-09-08?13:28??CsgTest\core\BooleanModeller.h
?????文件????????1408??2009-09-08?13:28??CsgTest\core\Bound.cpp
?????文件?????????673??2009-09-08?13:28??CsgTest\core\Bound.h
?????文件?????????494??2009-09-08?13:28??CsgTest\core\Color.cpp
?????文件?????????440??2009-09-08?13:28??CsgTest\core\Color.h
?????文件????????1392??2009-09-08?13:28??CsgTest\core\ColorSet.cpp
?????文件?????????773??2009-09-08?13:28??CsgTest\core\ColorSet.h
?????文件????????7417??2010-06-20?13:50??CsgTest\core\CSGWorld.cpp
?????文件?????????798??2010-06-20?10:58??CsgTest\core\CSGWorld.h
?????文件???????10037??2009-09-08?13:28??CsgTest\core\Face.cpp
?????文件????????1584??2009-09-08?13:28??CsgTest\core\Face.h
?????文件????????2008??2009-09-08?13:28??CsgTest\core\FaceSet.cpp
?????文件?????????781??2009-09-08?13:28??CsgTest\core\FaceSet.h
?????文件????????1304??2009-09-08?13:28??CsgTest\core\IntSet.cpp
?????文件?????????697??2009-09-08?13:28??CsgTest\core\IntSet.h
?????文件????????5168??2009-09-08?13:28??CsgTest\core\Line.cpp
?????文件?????????899??2009-09-08?13:28??CsgTest\core\Line.h
?????文件???????27195??2009-09-08?13:28??CsgTest\core\ob
?????文件????????1853??2009-09-08?13:28??CsgTest\core\ob
?????文件????????6713??2009-09-08?13:28??CsgTest\core\Segment.cpp
?????文件????????2014??2009-09-08?13:28??CsgTest\core\Segment.h
?????文件????????8060??2009-09-08?13:28??CsgTest\core\Solid.cpp
?????文件????????1177??2009-09-08?13:28??CsgTest\core\Solid.h
?????文件????????4576??2009-09-08?13:28??CsgTest\core\Vector.cpp
?????文件????????2461??2009-09-08?13:28??CsgTest\core\Vector.h
?????文件????????1802??2009-09-08?13:28??CsgTest\core\VectorSet.cpp
............此處省略10個文件信息
評論
共有 條評論